示例#1
0
 private static void DrawNodes(ref Matrix worldMatrix, Color color, Dictionary <UInt64, MyOctreeNode> octree)
 {
     using (var batch = MyRenderProxy.DebugDrawBatchAABB(worldMatrix, color, true, true))
     {
         MyCellCoord cell = new MyCellCoord();
         foreach (var entry in octree)
         {
             cell.SetUnpack(entry.Key);
             cell.Lod += LeafLodCount;
             var data = entry.Value;
             for (int i = 0; i < MyOctreeNode.CHILD_COUNT; ++i)
             {
                 if (data.HasChild(i))
                 {
                     continue;
                 }
                 Vector3I childOffset;
                 ComputeChildCoord(i, out childOffset);
                 var          voxelPos = (cell.CoordInLod << (cell.Lod + 1)) + (childOffset << cell.Lod);
                 var          lodSize  = MyVoxelConstants.VOXEL_SIZE_IN_METRES * (1 << cell.Lod);
                 var          center   = voxelPos * MyVoxelConstants.VOXEL_SIZE_IN_METRES + 0.5f * lodSize;
                 BoundingBoxD bb       = new BoundingBoxD(
                     center - 0.5f * lodSize,
                     center + 0.5f * lodSize);
                 batch.Add(ref bb);
             }
         }
     }
 }
示例#2
0
        public override void DebugDraw()
        {
            base.DebugDraw();

            if (m_aabbPhantom != null && MyDebugDrawSettings.DEBUG_DRAW_VOXEL_MAP_AABB && IsInWorld)
            {
                var offset = ClusterToWorld(Vector3D.Zero);

                BoundingBoxD phantom = (BoundingBoxD)m_aabbPhantom.Aabb;
                phantom.Translate(offset);

                MyRenderProxy.DebugDrawAABB(phantom, Color.Orange, 1.0f, 1.0f, true);
            }

            if (MyDebugDrawSettings.DEBUG_DRAW_VOXEL_PHYSICS_PREDICTION)
            {
                foreach (var entity in m_nearbyEntities)
                {
                    if (entity.MarkedForClose)
                    {
                        continue;
                    }

                    var worldAabb = entity.WorldAABB;
                    MyRenderProxy.DebugDrawAABB(worldAabb, Color.Bisque, 1f, 1f, true);
                    MyRenderProxy.DebugDrawLine3D(GetWorldMatrix().Translation, worldAabb.Center, Color.Bisque, Color.BlanchedAlmond, true);

                    BoundingBoxD predAabb;
                    GetPrediction(entity, out predAabb);
                    MyRenderProxy.DebugDrawAABB(predAabb, Color.Crimson, 1f, 1f, true);
                }

                using (var batch = MyRenderProxy.DebugDrawBatchAABB(GetWorldMatrix(), new Color(Color.Cyan, 0.2f), true, false))
                {
                    int i = 0;
                    foreach (var entry in m_workTracker)
                    {
                        i++;
                        BoundingBoxD localAabb;
                        var          localCell = entry.Key;

                        localAabb.Min  = localCell.CoordInLod << localCell.Lod;
                        localAabb.Min *= MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_METRES;
                        localAabb.Min -= m_voxelMap.SizeInMetresHalf;
                        localAabb.Max  = localAabb.Min + MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_METRES;

                        batch.Add(ref localAabb);
                        if (i > 250)
                        {
                            break;
                        }
                    }
                }
            }
        }
示例#3
0
 public override unsafe void DebugDraw()
 {
     base.DebugDraw();
     if (((this.m_aabbPhantom != null) && MyDebugDrawSettings.DEBUG_DRAW_VOXEL_MAP_AABB) && this.IsInWorld)
     {
         BoundingBoxD aabb = this.m_aabbPhantom.Aabb;
         aabb.Translate(this.ClusterToWorld(Vector3.Zero));
         MyRenderProxy.DebugDrawAABB(aabb, Color.Orange, 1f, 1f, true, false, false);
     }
     if (MyDebugDrawSettings.DEBUG_DRAW_VOXEL_PHYSICS_PREDICTION)
     {
         foreach (IMyEntity entity in this.m_nearbyEntities)
         {
             if (!entity.MarkedForClose)
             {
                 BoundingBoxD xd3;
                 BoundingBoxD worldAABB = entity.WorldAABB;
                 MyRenderProxy.DebugDrawAABB(worldAABB, Color.Bisque, 1f, 1f, true, false, false);
                 MyRenderProxy.DebugDrawLine3D(this.GetWorldMatrix().Translation, worldAABB.Center, Color.Bisque, Color.BlanchedAlmond, true, false);
                 this.GetPrediction(entity, out xd3);
                 MyRenderProxy.DebugDrawAABB(xd3, Color.Crimson, 1f, 1f, true, false, false);
             }
         }
         using (IMyDebugDrawBatchAabb aabb = MyRenderProxy.DebugDrawBatchAABB(this.GetWorldMatrix(), new Color(Color.Cyan, 0.2f), true, false))
         {
             int num = 0;
             foreach (KeyValuePair <MyCellCoord, MyPrecalcJobPhysicsPrefetch> pair in this.m_workTracker)
             {
                 BoundingBoxD xd5;
                 num++;
                 MyCellCoord key = pair.Key;
                 xd5.Min = (Vector3D)(key.CoordInLod << key.Lod);
                 Vector3D *vectordPtr1 = (Vector3D *)ref xd5.Min;
                 vectordPtr1[0] *= 8.0;
                 Vector3D *vectordPtr2 = (Vector3D *)ref xd5.Min;
                 vectordPtr2[0] -= this.m_voxelMap.SizeInMetresHalf;
                 BoundingBoxD *xdPtr1 = (BoundingBoxD *)ref xd5;
                 xdPtr1->Max = xd5.Min + 8f;
                 Color?color = null;
                 aabb.Add(ref xd5, color);
                 if (num > 250)
                 {
                     break;
                 }
             }
         }
     }
 }
示例#4
0
 private static void DrawLeaves(ref Matrix worldMatrix, Color color, Dictionary <UInt64, IMyOctreeLeafNode> octree)
 {
     using (var batch = MyRenderProxy.DebugDrawBatchAABB(worldMatrix, color, true, true))
     {
         MyCellCoord cell = new MyCellCoord();
         foreach (var entry in octree)
         {
             cell.SetUnpack(entry.Key);
             cell.Lod += LeafLodCount;
             var data     = entry.Value;
             var voxelPos = cell.CoordInLod << cell.Lod;
             var bb       = new BoundingBoxD(
                 voxelPos * MyVoxelConstants.VOXEL_SIZE_IN_METRES,
                 (voxelPos + (1 << cell.Lod)) * MyVoxelConstants.VOXEL_SIZE_IN_METRES);
             batch.Add(ref bb);
         }
     }
 }
        public void DebugDraw()
        {
            if (MyPlanetEnvironmentSessionComponent.DebugDrawSectors)
            {
                if (MyPlanetEnvironmentSessionComponent.DebugDrawDynamicObjectClusters)
                {
                    using (var batch = MyRenderProxy.DebugDrawBatchAABB(MatrixD.Identity, new Color(Color.Green, 0.2f), true, true))
                    {
                        foreach (var box in m_sectorBoxes)
                        {
                            BoundingBoxD bb = box;
                            batch.Add(ref bb);
                        }
                    }
                }
            }

            if (MyPlanetEnvironmentSessionComponent.DebugDrawProxies)
            {
                foreach (var proxy in Proxies.Values)
                {
                    proxy.DebugDraw();
                }

                foreach (var proxy in OutgoingProxies.Values)
                {
                    proxy.DebugDraw(true);
                }
            }

            if (MyPlanetEnvironmentSessionComponent.DebugDrawCollisionCheckers)
            {
                if (m_obstructorsPerSector != null)
                {
                    foreach (var obbList in m_obstructorsPerSector.Values)
                    {
                        foreach (var obb in obbList)
                        {
                            MyRenderProxy.DebugDrawOBB(obb, Color.Red, 0.1f, true, true);
                        }
                    }
                }
            }
        }
示例#6
0
        private static void DrawScaledNodes(ref Matrix worldMatrix, Color color, Dictionary <UInt64, MyOctreeNode> octree)
        {
            using (var batch = MyRenderProxy.DebugDrawBatchAABB(worldMatrix, color, true, true))
            {
                MyCellCoord cell = new MyCellCoord();
                foreach (var entry in octree)
                {
                    cell.SetUnpack(entry.Key);
                    cell.Lod += LeafLodCount;
                    var data = entry.Value;
                    for (int i = 0; i < MyOctreeNode.CHILD_COUNT; ++i)
                    {
                        if (data.HasChild(i) && cell.Lod != LeafLodCount)
                        {
                            continue;
                        }
                        Vector3I childOffset;
                        ComputeChildCoord(i, out childOffset);
                        float ratio = data.GetData(i) / MyVoxelConstants.VOXEL_CONTENT_FULL_FLOAT;
                        if (ratio == 0f)
                        {
                            continue;
                        }

                        var voxelPos = (cell.CoordInLod << (cell.Lod + 1)) + (childOffset << cell.Lod);
                        var lodSize  = MyVoxelConstants.VOXEL_SIZE_IN_METRES * (1 << cell.Lod);
                        var center   = voxelPos * MyVoxelConstants.VOXEL_SIZE_IN_METRES + 0.5f * lodSize;
                        ratio    = (float)Math.Pow((double)ratio * MyVoxelConstants.VOXEL_VOLUME_IN_METERS, 0.3333);
                        lodSize *= ratio;
                        BoundingBoxD bb = new BoundingBoxD(
                            center - 0.5f * lodSize,
                            center + 0.5f * lodSize);
                        batch.Add(ref bb);
                    }
                }
            }
        }