当前位置: 首页>>代码示例>>C#>>正文


C# BoundingBoxD.GetCornersUnsafe方法代码示例

本文整理汇总了C#中BoundingBoxD.GetCornersUnsafe方法的典型用法代码示例。如果您正苦于以下问题:C# BoundingBoxD.GetCornersUnsafe方法的具体用法?C# BoundingBoxD.GetCornersUnsafe怎么用?C# BoundingBoxD.GetCornersUnsafe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BoundingBoxD的用法示例。


在下文中一共展示了BoundingBoxD.GetCornersUnsafe方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RasterSectorsForPhysics

        // Iterate over sector boxes in a range.
        // TODO: Dumb version of this for small boxes
        private unsafe void RasterSectorsForPhysics(BoundingBoxD range)
        {
            range.InflateToMinimum(EnvironmentDefinition.SectorSize);

            Vector2I top = new Vector2I(1 << m_clipmaps[0].Depth) - 1;

            Vector3D* pos = stackalloc Vector3D[8];

            range.GetCornersUnsafe(pos);

            // bitmask for faces, 7th bit is simple bit
            int markedFaces = 0;
            int firstFace = 0;

            for (var i = 0; i < 8; ++i)
            {
                Vector3D copy = pos[i];

                int index = MyPlanetCubemapHelper.FindCubeFace(ref copy);
                firstFace = index;
                index = 1 << index;

                if ((markedFaces & ~index) != 0) markedFaces |= 0x40;

                markedFaces |= index;
            }

            // This way we can ensure a single code path.
            int startFace = 0;
            int endFace = 5;

            // If we only encounter one face we narrow it down.
            if ((markedFaces & 0x40) == 0)
            {
                startFace = endFace = firstFace;
            }

            for (int face = startFace; face <= endFace; ++face)
            {
                if (((1 << face) & markedFaces) == 0)
                    continue;

                double size = m_clipmaps[face].LeafSize;

                // Offset 
                var offset = 1 << m_clipmaps[face].Depth - 1;

                BoundingBox2D bounds = BoundingBox2D.CreateInvalid();
                for (int i = 0; i < 8; ++i)
                {
                    Vector3D copy = pos[i];

                    Vector2D normCoords;
                    MyPlanetCubemapHelper.ProjectForFace(ref copy, face, out normCoords);
                    bounds.Include(normCoords);
                }

                bounds.Min += 1;
                bounds.Min *= offset;

                bounds.Max += 1;
                bounds.Max *= offset;

                // Calculate bounds in sectors.
                var start = new Vector2I((int)bounds.Min.X, (int)bounds.Min.Y);
                var end = new Vector2I((int)bounds.Max.X, (int)bounds.Max.Y);

                Vector2I.Max(ref start, ref Vector2I.Zero, out start);
                Vector2I.Min(ref end, ref top, out end);

                for (int x = start.X; x <= end.X; ++x)
                    for (int y = start.Y; y <= end.Y; ++y)
                    {
                        EnsurePhysicsSector(x, y, face);
                    }
            }
        }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:79,代码来源:MyPlanetEnvironmentComponent.cs

示例2: CountCornersInside

 private int CountCornersInside(ref MatrixD aabbWorldTransform, ref BoundingBoxD aabb)
 {
     unsafe
     {
         const int cornerCount = 8;
         Vector3D* corners = stackalloc Vector3D[cornerCount];
         aabb.GetCornersUnsafe(corners);
         for (int i = 0; i < cornerCount; i++)
         {
             Vector3D.Transform(ref corners[i], ref aabbWorldTransform, out corners[i]);
         }
         return CountPointsInside(corners, cornerCount);
     }
 }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:14,代码来源:MyVoxelBase.cs


注:本文中的BoundingBoxD.GetCornersUnsafe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。