コード例 #1
0
        public override void DebugDrawInvalidTriangles()
        {
            base.DebugDrawInvalidTriangles();

            MyRenderComponentCubeGrid gridRender = m_cubeGrid.Render;
            MyCubeGridRenderData      data       = gridRender.RenderData;

            foreach (var cell in data.Cells)
            {
                HashSet <MyCubePart> parts = cell.Value.CubeParts;
                foreach (var part in parts)
                {
                    MyModel model = part.Model;
                    if (model != null)
                    {
                        int triCount = model.GetTrianglesCount();
                        for (int i = 0; i < triCount; ++i)
                        {
                            var triangle = model.GetTriangle(i);
                            if (MyUtils.IsWrongTriangle(model.GetVertex(triangle.I0), model.GetVertex(triangle.I1), model.GetVertex(triangle.I2)))
                            {
                                Vector3 v0 = Vector3.Transform(model.GetVertex(triangle.I0), (Matrix)m_cubeGrid.PositionComp.WorldMatrix);
                                Vector3 v1 = Vector3.Transform(model.GetVertex(triangle.I1), (Matrix)m_cubeGrid.PositionComp.WorldMatrix);
                                Vector3 v2 = Vector3.Transform(model.GetVertex(triangle.I2), (Matrix)m_cubeGrid.PositionComp.WorldMatrix);
                                VRageRender.MyRenderProxy.DebugDrawLine3D(v0, v1, Color.Purple, Color.Purple, false);
                                VRageRender.MyRenderProxy.DebugDrawLine3D(v1, v2, Color.Purple, Color.Purple, false);
                                VRageRender.MyRenderProxy.DebugDrawLine3D(v2, v0, Color.Purple, Color.Purple, false);
                                Vector3 center = (v0 + v1 + v2) / 3f;
                                VRageRender.MyRenderProxy.DebugDrawLine3D(center, center + Vector3.UnitX, Color.Yellow, Color.Yellow, false);
                                VRageRender.MyRenderProxy.DebugDrawLine3D(center, center + Vector3.UnitY, Color.Yellow, Color.Yellow, false);
                                VRageRender.MyRenderProxy.DebugDrawLine3D(center, center + Vector3.UnitZ, Color.Yellow, Color.Yellow, false);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
 public MyCubeGridRenderData(MyRenderComponentCubeGrid grid)
 {
     m_gridRender = grid;
 }
コード例 #3
0
        public override bool DebugDraw()
        {
            if (MyDebugDrawSettings.DEBUG_DRAW_GRID_NAMES || MyDebugDrawSettings.DEBUG_DRAW_GRID_CONTROL)
            {
                string text  = "";
                var    color = Color.White;

                if (MyDebugDrawSettings.DEBUG_DRAW_GRID_NAMES)
                {
                    text += m_cubeGrid.ToString() + " ";
                }
                if (MyDebugDrawSettings.DEBUG_DRAW_GRID_CONTROL)
                {
                    var controllingPlayer = Sync.Players.GetControllingPlayer(m_cubeGrid);
                    if (controllingPlayer != null)
                    {
                        text += "Controlled by: " + controllingPlayer.DisplayName;
                        color = Color.LightGreen;
                    }
                }

                MyRenderProxy.DebugDrawText3D(m_cubeGrid.PositionComp.WorldAABB.Center, text, color, 0.7f, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            }

            MyRenderComponentCubeGrid gridRender = m_cubeGrid.Render;

            if (MyDebugDrawSettings.DEBUG_DRAW_BLOCK_GROUPS)
            {
                var tpos = m_cubeGrid.PositionComp.WorldMatrix.Translation;
                foreach (var group in m_cubeGrid.BlockGroups)
                {
                    MyRenderProxy.DebugDrawText3D(tpos, group.Name.ToString(), Color.Red, 1, false);
                    tpos += m_cubeGrid.PositionComp.WorldMatrix.Right * group.Name.Length * 0.1f;
                }
            }

            if (MyDebugDrawSettings.DEBUG_DRAW_GRID_DIRTY_BLOCKS)
            {
                foreach (var b in m_dirtyBlocks)
                {
                    var color = m_cubeGrid.GetCubeBlock(b.Key) != null?Color.Red.ToVector3() : Color.Yellow.ToVector3();

                    var m = Matrix.CreateScale(m_cubeGrid.GridSize) * Matrix.CreateTranslation(b.Key * m_cubeGrid.GridSize) * m_cubeGrid.WorldMatrix;
                    MyRenderProxy.DebugDrawOBB(m, color, 0.15f, false, true);
                }
            }

            // Bone debug draw
            if (MyDebugDrawSettings.DEBUG_DRAW_DISPLACED_BONES)
            {
                Vector3 cameraPos = (Vector3)MySector.MainCamera.Position;

                foreach (var bone in m_cubeGrid.Skeleton.Bones)
                {
                    var bonePos = (bone.Key / (float)m_cubeGrid.Skeleton.BoneDensity) * gridRender.GridSize + bone.Value;
                    bonePos -= new Vector3(gridRender.GridSize / m_cubeGrid.Skeleton.BoneDensity);
                    Vector3 pos = Vector3.Transform(bonePos, (Matrix)m_cubeGrid.PositionComp.WorldMatrix);
                    MyRenderProxy.DebugDrawSphere(pos, 0.05f, Color.Red.ToVector3(), 0.5f, false, true);
                    if ((cameraPos - pos).LengthSquared() < 200.0f)
                    {
                        MyRenderProxy.DebugDrawText3D(pos, bone.Key.ToString(), Color.Red, 0.4f, false);
                    }
                }
            }

            if (MyDebugDrawSettings.DEBUG_DRAW_STRUCTURAL_INTEGRITY &&
                m_cubeGrid.StructuralIntegrity != null)
            {
                m_cubeGrid.StructuralIntegrity.DebugDraw();
            }

            if (MyDebugDrawSettings.DEBUG_DRAW_CUBES)
            {
                foreach (var cubeBlock in m_cubeGrid.CubeBlocks)
                {
                    var cb = cubeBlock.FatBlock;
                    if (cb == null)
                    {
                        continue;
                    }

                    cb.DebugDraw();
                }
            }

            m_cubeGrid.GridSystems.DebugDraw();

            if (MyDebugDrawSettings.DEBUG_DRAW_GRID_TERMINAL_SYSTEMS)
            {
                /* if (grid.OnBlockAdded != null)
                 * {
                 *   MyRenderProxy.DebugDrawText3D(Entity.PositionComp.WorldMatrix.Translation + new Vector3(0.0f, 0.0f, 0.5f), grid.OnBlockAdded.GetInvocationList().Count().ToString(), Color.NavajoWhite, 1.0f, false);
                 * }*/
            }

            if (MyFakes.ENABLE_TRASH_REMOVAL && MyDebugDrawSettings.DEBUG_DRAW_TRASH_REMOVAL)
            {
                Color color        = m_cubeGrid.IsTrash() ? Color.Red : Color.Green;
                float sphereRadius = m_cubeGrid.PositionComp.LocalAABB.HalfExtents.AbsMax();
                MyRenderProxy.DebugDrawSphere(m_cubeGrid.Physics != null ? m_cubeGrid.Physics.CenterOfMassWorld : m_cubeGrid.PositionComp.WorldMatrix.Translation, sphereRadius, color, 1.0f, false);
            }

            if (MyDebugDrawSettings.DEBUG_DRAW_GRID_ORIGINS)
            {
                MyRenderProxy.DebugDrawAxis(m_cubeGrid.PositionComp.WorldMatrix, 1.0f, false);
            }

            if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW && MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_ALL)
            {
                foreach (MySlimBlock block in m_cubeGrid.GetBlocks())
                {
                    if ((m_cubeGrid.GridIntegerToWorld(block.Position) - MySector.MainCamera.Position).LengthSquared() < 200)
                    {
                        DebugDrawMountPoints(block);
                    }
                }
            }

            foreach (var b in m_cubeGrid.GetBlocks())
            {
                if (b.FatBlock is MyFracturedBlock)
                {
                    MyRenderProxy.DebugDrawText3D(m_cubeGrid.GridIntegerToWorld(b.Position), "F", Color.Red, 1, false);
                }
            }
            return(base.DebugDraw());
        }
コード例 #4
0
 public MyCubeGridRenderCell(MyRenderComponentCubeGrid gridRender)
 {
     m_gridRenderComponent = gridRender;
     EdgeViewDistance = gridRender.GridSizeEnum == Common.ObjectBuilders.MyCubeSize.Large ? 130 : 35;
 }
コード例 #5
0
        public override bool DebugDraw()
        {
            if (MyDebugDrawSettings.DEBUG_DRAW_FIXED_BLOCK_QUERIES)
            {
                foreach (var b in m_cubeGrid.GetBlocks())
                {
                    var geometryBox = b.FatBlock.GetGeometryLocalBox();
                    //geometryBox.Inflate(0.5f);
                    Vector3 halfExtents = geometryBox.Size / 2;

                    Vector3D pos;
                    b.ComputeScaledCenter(out pos);
                    pos += geometryBox.Center;
                    pos  = Vector3D.Transform(pos, m_cubeGrid.WorldMatrix);

                    Matrix blockMatrix;
                    b.Orientation.GetMatrix(out blockMatrix);
                    var q = Quaternion.CreateFromRotationMatrix(blockMatrix * m_cubeGrid.WorldMatrix.GetOrientation());

                    Sandbox.Engine.Physics.MyPhysics.GetPenetrationsBox(ref halfExtents, ref pos, ref q, m_penetrations, Sandbox.Engine.Physics.MyPhysics.CollideWithStaticLayer);
                    bool isStatic = false;
                    foreach (var p in m_penetrations)
                    {
                        var e = p.GetCollisionEntity();
                        if (e != null && e is MyVoxelMap)
                        {
                            isStatic = true;
                            break;
                        }
                    }

                    m_penetrations.Clear();



                    MyOrientedBoundingBoxD obb = new MyOrientedBoundingBoxD(pos, halfExtents, q);
                    MyRenderProxy.DebugDrawOBB(obb, isStatic ? Color.Green : Color.Red, 0.1f, false, false);
                }
            }

            if (MyDebugDrawSettings.DEBUG_DRAW_GRID_NAMES || MyDebugDrawSettings.DEBUG_DRAW_GRID_CONTROL)
            {
                string text  = "";
                var    color = Color.White;

                if (MyDebugDrawSettings.DEBUG_DRAW_GRID_NAMES)
                {
                    text += m_cubeGrid.ToString() + " ";
                }
                if (MyDebugDrawSettings.DEBUG_DRAW_GRID_CONTROL)
                {
                    var controllingPlayer = Sync.Players.GetControllingPlayer(m_cubeGrid);
                    if (controllingPlayer != null)
                    {
                        text += "Controlled by: " + controllingPlayer.DisplayName;
                        color = Color.LightGreen;
                    }
                }

                MyRenderProxy.DebugDrawText3D(m_cubeGrid.PositionComp.WorldAABB.Center, text, color, 0.7f, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            }

            MyRenderComponentCubeGrid gridRender = m_cubeGrid.Render;

            if (MyDebugDrawSettings.DEBUG_DRAW_BLOCK_GROUPS)
            {
                var tpos = m_cubeGrid.PositionComp.WorldMatrix.Translation;
                foreach (var group in m_cubeGrid.BlockGroups)
                {
                    MyRenderProxy.DebugDrawText3D(tpos, group.Name.ToString(), Color.Red, 1, false);
                    tpos += m_cubeGrid.PositionComp.WorldMatrix.Right * group.Name.Length * 0.1f;
                }
            }

            if (MyDebugDrawSettings.DEBUG_DRAW_GRID_DIRTY_BLOCKS)
            {
                foreach (var b in m_dirtyBlocks)
                {
                    var color = m_cubeGrid.GetCubeBlock(b.Key) != null?Color.Red.ToVector3() : Color.Yellow.ToVector3();

                    var m = Matrix.CreateScale(m_cubeGrid.GridSize) * Matrix.CreateTranslation(b.Key * m_cubeGrid.GridSize) * m_cubeGrid.WorldMatrix;
                    MyRenderProxy.DebugDrawOBB(m, color, 0.15f, false, true);
                }
            }

            // Bone debug draw
            if (MyDebugDrawSettings.DEBUG_DRAW_DISPLACED_BONES)
            {
                Vector3 cameraPos = (Vector3)MySector.MainCamera.Position;

                foreach (var bone in m_cubeGrid.Skeleton.Bones)
                {
                    var bonePos = (bone.Key / (float)m_cubeGrid.Skeleton.BoneDensity) * gridRender.GridSize + bone.Value;
                    bonePos -= new Vector3(gridRender.GridSize / m_cubeGrid.Skeleton.BoneDensity);
                    Vector3 pos = Vector3.Transform(bonePos, (Matrix)m_cubeGrid.PositionComp.WorldMatrix);
                    MyRenderProxy.DebugDrawSphere(pos, 0.05f, Color.Red.ToVector3(), 0.5f, false, true);
                    if ((cameraPos - pos).LengthSquared() < 200.0f)
                    {
                        MyRenderProxy.DebugDrawText3D(pos, bone.Key.ToString(), Color.Red, 0.4f, false);
                    }
                }
            }

            if (MyDebugDrawSettings.DEBUG_DRAW_STRUCTURAL_INTEGRITY &&
                m_cubeGrid.StructuralIntegrity != null)
            {
                m_cubeGrid.StructuralIntegrity.DebugDraw();
            }

            if (MyDebugDrawSettings.DEBUG_DRAW_CUBES)
            {
                foreach (var cubeBlock in m_cubeGrid.CubeBlocks)
                {
                    var cb = cubeBlock.FatBlock;
                    if (cb == null)
                    {
                        continue;
                    }

                    cb.DebugDraw();
                }
            }

            m_cubeGrid.GridSystems.DebugDraw();

            if (MyDebugDrawSettings.DEBUG_DRAW_GRID_TERMINAL_SYSTEMS)
            {
                /* if (grid.OnBlockAdded != null)
                 * {
                 *   MyRenderProxy.DebugDrawText3D(Entity.PositionComp.WorldMatrix.Translation + new Vector3(0.0f, 0.0f, 0.5f), grid.OnBlockAdded.GetInvocationList().Count().ToString(), Color.NavajoWhite, 1.0f, false);
                 * }*/
            }

            if (MyFakes.ENABLE_TRASH_REMOVAL && MyDebugDrawSettings.DEBUG_DRAW_TRASH_REMOVAL)
            {
                Color color        = m_cubeGrid.IsTrash() ? Color.Red : Color.Green;
                float sphereRadius = m_cubeGrid.PositionComp.LocalAABB.HalfExtents.AbsMax();
                MyRenderProxy.DebugDrawSphere(m_cubeGrid.Physics != null ? m_cubeGrid.Physics.CenterOfMassWorld : m_cubeGrid.PositionComp.WorldMatrix.Translation, sphereRadius, color, 1.0f, false);
            }

            if (MyDebugDrawSettings.DEBUG_DRAW_GRID_ORIGINS)
            {
                MyRenderProxy.DebugDrawAxis(m_cubeGrid.PositionComp.WorldMatrix, 1.0f, false);
            }

            if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW && MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_ALL)
            {
                foreach (MySlimBlock block in m_cubeGrid.GetBlocks())
                {
                    if ((m_cubeGrid.GridIntegerToWorld(block.Position) - MySector.MainCamera.Position).LengthSquared() < 200)
                    {
                        DebugDrawMountPoints(block);
                    }
                }
            }

            if (MyDebugDrawSettings.DEBUG_DRAW_BLOCK_INTEGRITY)
            {
                if (MySector.MainCamera != null && (MySector.MainCamera.Position - m_cubeGrid.PositionComp.WorldVolume.Center).Length() < 16 + m_cubeGrid.PositionComp.WorldVolume.Radius)
                {
                    foreach (var cubeBlock in m_cubeGrid.CubeBlocks)
                    {
                        var pos = m_cubeGrid.GridIntegerToWorld(cubeBlock.Position);
                        if (m_cubeGrid.GridSizeEnum == MyCubeSize.Large || (MySector.MainCamera != null && (MySector.MainCamera.Position - pos).LengthSquared() < 9))
                        {
                            float integrity = 0;
                            if (cubeBlock.FatBlock is MyCompoundCubeBlock)
                            {
                                foreach (var b in (cubeBlock.FatBlock as MyCompoundCubeBlock).GetBlocks())
                                {
                                    integrity += b.Integrity;
                                }
                            }
                            else
                            {
                                integrity = cubeBlock.Integrity;
                            }
                            MyRenderProxy.DebugDrawText3D(m_cubeGrid.GridIntegerToWorld(cubeBlock.Position), ((int)integrity).ToString(), Color.White, m_cubeGrid.GridSizeEnum == MyCubeSize.Large ? 0.65f : 0.5f, false);
                        }
                    }
                }
            }

            return(base.DebugDraw());
        }
コード例 #6
0
        public override void DebugDraw()
        {
            MatrixD  worldMatrix;
            Vector3D vectord4;

            if (MyDebugDrawSettings.DEBUG_DRAW_GRID_AABB)
            {
                MatrixD worldMatrix = this.m_cubeGrid.PositionComp.WorldMatrix;
                MyRenderProxy.DebugDrawOBB(new MyOrientedBoundingBoxD(this.m_cubeGrid.PositionComp.LocalAABB, worldMatrix), Color.Yellow, 0.2f, false, true, false);
                MyRenderProxy.DebugDrawAxis(worldMatrix, 1f, false, false, false);
            }
            if (MyDebugDrawSettings.DEBUG_DRAW_FIXED_BLOCK_QUERIES)
            {
                foreach (MySlimBlock local1 in this.m_cubeGrid.GetBlocks())
                {
                    Vector3D    vectord;
                    Matrix      matrix;
                    BoundingBox geometryLocalBox = local1.FatBlock.GetGeometryLocalBox();
                    Vector3     halfExtents      = geometryLocalBox.Size / 2f;
                    local1.ComputeScaledCenter(out vectord);
                    vectord = Vector3D.Transform(vectord + geometryLocalBox.Center, this.m_cubeGrid.WorldMatrix);
                    local1.Orientation.GetMatrix(out matrix);
                    worldMatrix = this.m_cubeGrid.WorldMatrix;
                    Quaternion rotation = Quaternion.CreateFromRotationMatrix((MatrixD)(matrix * worldMatrix.GetOrientation()));
                    MyPhysics.GetPenetrationsBox(ref halfExtents, ref vectord, ref rotation, this.m_penetrations, 14);
                    bool flag = false;
                    using (List <HkBodyCollision> .Enumerator enumerator2 = this.m_penetrations.GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            IMyEntity collisionEntity = enumerator2.Current.GetCollisionEntity();
                            if ((collisionEntity != null) && (collisionEntity is MyVoxelMap))
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    this.m_penetrations.Clear();
                    MyRenderProxy.DebugDrawOBB(new MyOrientedBoundingBoxD(vectord, halfExtents, rotation), flag ? Color.Green : Color.Red, 0.1f, false, false, false);
                }
            }
            if (MyDebugDrawSettings.DEBUG_DRAW_GRID_NAMES || MyDebugDrawSettings.DEBUG_DRAW_GRID_CONTROL)
            {
                string text  = "";
                Color  white = Color.White;
                if (MyDebugDrawSettings.DEBUG_DRAW_GRID_NAMES)
                {
                    text = text + this.m_cubeGrid.ToString() + " ";
                }
                if (MyDebugDrawSettings.DEBUG_DRAW_GRID_CONTROL)
                {
                    MyPlayer controllingPlayer = Sync.Players.GetControllingPlayer(this.m_cubeGrid);
                    if (controllingPlayer != null)
                    {
                        text  = text + "Controlled by: " + controllingPlayer.DisplayName;
                        white = Color.LightGreen;
                    }
                }
                MyRenderProxy.DebugDrawText3D(this.m_cubeGrid.PositionComp.WorldAABB.Center, text, white, 0.7f, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, -1, false);
            }
            MyRenderComponentCubeGrid render = this.m_cubeGrid.Render;

            if (MyDebugDrawSettings.DEBUG_DRAW_BLOCK_GROUPS)
            {
                worldMatrix = this.m_cubeGrid.PositionComp.WorldMatrix;
                Vector3D translation = worldMatrix.Translation;
                foreach (MyBlockGroup group in this.m_cubeGrid.BlockGroups)
                {
                    MyRenderProxy.DebugDrawText3D(translation, group.Name.ToString(), Color.Red, 1f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false);
                    worldMatrix  = this.m_cubeGrid.PositionComp.WorldMatrix;
                    translation += (worldMatrix.Right * group.Name.Length) * 0.10000000149011612;
                }
            }
            if (MyDebugDrawSettings.DEBUG_DRAW_GRID_DIRTY_BLOCKS)
            {
                foreach (KeyValuePair <Vector3I, MyTimeSpan> pair in this.m_dirtyBlocks)
                {
                    Vector3 vector1;
                    if (this.m_cubeGrid.GetCubeBlock(pair.Key) == null)
                    {
                        vector1 = Color.Yellow.ToVector3();
                    }
                    else
                    {
                        vector1 = Color.Red.ToVector3();
                    }
                    Vector3 color = vector1;
                    MyRenderProxy.DebugDrawOBB((Matrix.CreateScale(this.m_cubeGrid.GridSize) * Matrix.CreateTranslation(pair.Key * this.m_cubeGrid.GridSize)) * this.m_cubeGrid.WorldMatrix, color, 0.15f, false, true, true, false);
                }
            }
            if (MyDebugDrawSettings.DEBUG_DRAW_DISPLACED_BONES)
            {
                Vector3D position = MySector.MainCamera.Position;
                foreach (MySlimBlock block in this.m_cubeGrid.CubeBlocks)
                {
                    MyCube cube;
                    if (this.m_cubeGrid.TryGetCube(block.Position, out cube))
                    {
                        int num = 0;
                        foreach (MyCubePart part in cube.Parts)
                        {
                            if ((part.Model.BoneMapping != null) && (num == MyPetaInputComponent.DEBUG_INDEX))
                            {
                                for (int i = 0; i < Math.Min(part.Model.BoneMapping.Length, 9); i++)
                                {
                                    Matrix   orientation = part.InstanceData.LocalMatrix.GetOrientation();
                                    Vector3I vectori     = Vector3I.Round(Vector3.Transform((Vector3)(((part.Model.BoneMapping[i] * 1f) - Vector3.One) * 1f), orientation));
                                    Vector3I bonePos     = Vector3I.Round(Vector3.Transform((Vector3)(((part.Model.BoneMapping[i] * 1f) - Vector3.One) * 1f), orientation) + Vector3.One);
                                    Vector3  bone        = this.m_cubeGrid.Skeleton.GetBone(block.Position, bonePos);
                                    Vector3D vectord3    = Vector3D.TransformNormal(bone, this.m_cubeGrid.PositionComp.WorldMatrix);
                                    Vector3D vectord6    = Vector3D.Transform((Vector3)(this.m_cubeGrid.GridSize * (block.Position + (vectori / 2f))), this.m_cubeGrid.PositionComp.WorldMatrix);
                                    MyRenderProxy.DebugDrawSphere(vectord6, 0.025f, Color.Green, 0.5f, false, true, true, false);
                                    MyRenderProxy.DebugDrawText3D(vectord6, i.ToString(), Color.Green, 0.5f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false);
                                    Color?colorTo = null;
                                    MyRenderProxy.DebugDrawArrow3D(vectord6, vectord6 + vectord3, Color.Red, colorTo, false, 0.1, null, 0.5f, false);
                                }
                            }
                            num++;
                        }
                    }
                }
            }
            if (MyDebugDrawSettings.DEBUG_DRAW_STRUCTURAL_INTEGRITY && (this.m_cubeGrid.StructuralIntegrity != null))
            {
                this.m_cubeGrid.StructuralIntegrity.DebugDraw();
            }
            if (MyDebugDrawSettings.DEBUG_DRAW_CUBES)
            {
                foreach (MySlimBlock local2 in this.m_cubeGrid.CubeBlocks)
                {
                    Matrix matrix4;
                    local2.GetLocalMatrix(out matrix4);
                    MyRenderProxy.DebugDrawAxis(matrix4 * this.m_cubeGrid.WorldMatrix, 1f, false, false, false);
                    MyCubeBlock fatBlock = local2.FatBlock;
                    if (fatBlock != null)
                    {
                        fatBlock.DebugDraw();
                    }
                }
            }
            this.m_cubeGrid.GridSystems.DebugDraw();
            bool flag1 = MyDebugDrawSettings.DEBUG_DRAW_GRID_TERMINAL_SYSTEMS;

            if (MyDebugDrawSettings.DEBUG_DRAW_GRID_ORIGINS)
            {
                MyRenderProxy.DebugDrawAxis(this.m_cubeGrid.PositionComp.WorldMatrix, 1f, false, false, false);
            }
            if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW && MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_ALL)
            {
                foreach (MySlimBlock block3 in this.m_cubeGrid.GetBlocks())
                {
                    vectord4 = this.m_cubeGrid.GridIntegerToWorld(block3.Position) - MySector.MainCamera.Position;
                    if (vectord4.LengthSquared() < 200.0)
                    {
                        this.DebugDrawMountPoints(block3);
                    }
                }
            }
            if (MyDebugDrawSettings.DEBUG_DRAW_BLOCK_INTEGRITY && (MySector.MainCamera != null))
            {
                vectord4 = MySector.MainCamera.Position - this.m_cubeGrid.PositionComp.WorldVolume.Center;
                if (vectord4.Length() < (16.0 + this.m_cubeGrid.PositionComp.WorldVolume.Radius))
                {
                    using (HashSet <MySlimBlock> .Enumerator enumerator = this.m_cubeGrid.CubeBlocks.GetEnumerator())
                    {
                        MySlimBlock current;
                        float       num4;
                        goto TR_0011;
TR_0002:
                        MyRenderProxy.DebugDrawText3D(this.m_cubeGrid.GridIntegerToWorld(current.Position), ((int)num4).ToString(), Color.White, (this.m_cubeGrid.GridSizeEnum == MyCubeSize.Large) ? 0.65f : 0.5f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false);
TR_0011:
                        while (true)
                        {
                            if (!enumerator.MoveNext())
                            {
                                break;
                            }
                            current = enumerator.Current;
                            Vector3D vectord5 = this.m_cubeGrid.GridIntegerToWorld(current.Position);
                            if (this.m_cubeGrid.GridSizeEnum != MyCubeSize.Large)
                            {
                                if (MySector.MainCamera == null)
                                {
                                    continue;
                                }
                                if ((MySector.MainCamera.Position - vectord5).LengthSquared() >= 9.0)
                                {
                                    continue;
                                }
                            }
                            num4 = 0f;
                            if (current.FatBlock is MyCompoundCubeBlock)
                            {
                                foreach (MySlimBlock block5 in (current.FatBlock as MyCompoundCubeBlock).GetBlocks())
                                {
                                    num4 += block5.Integrity * block5.BlockDefinition.MaxIntegrityRatio;
                                }
                            }
                            else
                            {
                                num4 = current.Integrity * current.BlockDefinition.MaxIntegrityRatio;
                            }
                            goto TR_0002;
                        }
                    }
                }
            }
            base.DebugDraw();
        }