public static void DrawGeometry(HkGeometry geometry, MatrixD worldMatrix, Color color, bool depthRead = false, bool shaded = false) { var msg = MyRenderProxy.PrepareDebugDrawTriangles(); try { for (int i = 0; i < geometry.TriangleCount; i++) { int a, b, c, m; geometry.GetTriangle(i, out a, out b, out c, out m); msg.AddIndex(a); msg.AddIndex(b); msg.AddIndex(c); } for (int i = 0; i < geometry.VertexCount; i++) { msg.AddVertex(geometry.GetVertex(i)); } } finally { MyRenderProxy.DebugDrawTriangles(msg, worldMatrix, color, depthRead, shaded); } }
public static void DrawGeometry(HkGeometry geometry, MatrixD worldMatrix, Color color, bool depthRead = false, bool shaded = false) { MyRenderMessageDebugDrawTriangles msgInterface = MyRenderProxy.PrepareDebugDrawTriangles(); try { int triangleIndex = 0; while (true) { int num2; int num3; int num4; int num5; if (triangleIndex >= geometry.TriangleCount) { for (int i = 0; i < geometry.VertexCount; i++) { msgInterface.AddVertex(geometry.GetVertex(i)); } break; } geometry.GetTriangle(triangleIndex, out num2, out num3, out num4, out num5); msgInterface.AddIndex(num2); msgInterface.AddIndex(num3); msgInterface.AddIndex(num4); triangleIndex++; } } finally { msgInterface.Color = color; MyRenderProxy.DebugDrawTriangles(msgInterface, new MatrixD?(worldMatrix), depthRead, shaded, false, false); } }
public override void Draw() { base.Draw(); foreach (var line in m_lines) { MyRenderProxy.DebugDrawLine3D(line.From, line.To, line.ColorFrom, line.ColorTo, line.DepthRead); } if (ShowDebugDrawTests) { Vector3D position = new Vector3D(1000000000.0, 1000000000.0, 1000000000.0); MyRenderProxy.DebugDrawLine3D(position, position + Vector3D.Up, Color.Red, Color.Blue, true); position += Vector3D.Left; MyRenderProxy.DebugDrawLine3D(position, position + Vector3D.Up, Color.Red, Color.Blue, false); MyRenderProxy.DebugDrawLine2D(new Vector2(10, 10), new Vector2(50, 50), Color.Red, Color.Blue); position += Vector3D.Left; MyRenderProxy.DebugDrawPoint(position, Color.White, true); position += Vector3D.Left; MyRenderProxy.DebugDrawPoint(position, Color.White, false); position += Vector3D.Left; MyRenderProxy.DebugDrawSphere(position, 0.5f, Color.White, 1.0f, true); position += Vector3D.Left; MyRenderProxy.DebugDrawAABB(new BoundingBoxD(position - Vector3D.One * 0.5, position + Vector3D.One * 0.5), Color.White, 1.0f, 1.0f, true); position += Vector3D.Left; //MyRenderProxy.DebugDrawCone(position, Vector3D.Up, Vector3D.One, Color.Yellow, true); position += Vector3D.Left; MyRenderProxy.DebugDrawAxis(MatrixD.CreateFromTransformScale(Quaternion.Identity, position, Vector3D.One * 0.5), 1.0f, true); position += Vector3D.Left; MyRenderProxy.DebugDrawOBB(new MyOrientedBoundingBoxD(position, Vector3D.One * 0.5, Quaternion.Identity), Color.White, 1.0f, true, false); position += Vector3D.Left; MyRenderProxy.DebugDrawCylinder(MatrixD.CreateFromTransformScale(Quaternion.Identity, position, Vector3D.One * 0.5), Color.White, 1.0f, true, true); position += Vector3D.Left; MyRenderProxy.DebugDrawTriangle(position, position + Vector3D.Up, position + Vector3D.Left, Color.White, true, true); position += Vector3D.Left; var msg = MyRenderProxy.PrepareDebugDrawTriangles(); msg.AddTriangle(position, position + Vector3D.Up, position + Vector3D.Left); msg.AddTriangle(position, position + Vector3D.Left, position - Vector3D.Up); MyRenderProxy.DebugDrawTriangles(msg, MatrixD.Identity, Color.White, true, true); position += Vector3D.Left; MyRenderProxy.DebugDrawCapsule(position, position + Vector3D.Up, 0.5f, Color.White, true); MyRenderProxy.DebugDrawText2D(new Vector2(100, 100), "text", Color.Green, 1.0f); position += Vector3D.Left; MyRenderProxy.DebugDrawText3D(position, "3D Text", Color.Blue, 1.0f, true); } }
public override bool DebugDraw() { VRageRender.MyRenderProxy.DebugDrawAABB(WorldAABB, Vector3I.One, 1f, 1f, true); VRageRender.MyRenderProxy.DebugDrawLine3D(PositionLeftBottomCorner, PositionLeftBottomCorner + new Vector3(1f, 0f, 0f), Color.Red, Color.Red, true); VRageRender.MyRenderProxy.DebugDrawLine3D(PositionLeftBottomCorner, PositionLeftBottomCorner + new Vector3(0f, 1f, 0f), Color.Green, Color.Green, true); VRageRender.MyRenderProxy.DebugDrawLine3D(PositionLeftBottomCorner, PositionLeftBottomCorner + new Vector3(0f, 0f, 1f), Color.Blue, Color.Blue, true); Storage.DebugDraw(this, MyFakes.DEBUG_DRAW_VOXELS_MODE, (int)MyFakes.VOXEL_OCTREE_DEBUG_DRAW_DEPTH); if (MyFakes.DEBUG_DRAW_VOXEL_GEOMETRY_CELL) { var line = new Line(MySector.MainCamera.Position, MySector.MainCamera.Position + 50f * MySector.MainCamera.ForwardVector); MyIntersectionResultLineTriangleEx?result; bool depthRead = true; if (Geometry.Intersect(ref line, out result, IntersectionFlags.ALL_TRIANGLES)) { var cellCoord = new Vector3I(result.Value.IntersectionPointInObjectSpace / MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_METRES); var cell = Geometry.GetCell(MyLodTypeEnum.LOD0, ref cellCoord); if (cell != null) { MyVoxelVertex tmp; var triangleBatch = MyRenderProxy.PrepareDebugDrawTriangles(); for (int i = 0; i < cell.VoxelVerticesCount; ++i) { cell.GetUnpackedVertex(i, out tmp); triangleBatch.AddVertex(tmp.Position); tmp.Position += PositionLeftBottomCorner; MyRenderProxy.DebugDrawLine3D(tmp.Position, tmp.Position + tmp.Normal * MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF, Color.Gray, Color.White, depthRead); } for (int i = 0; i < cell.VoxelTrianglesCount; ++i) { triangleBatch.AddIndex(cell.VoxelTriangles[i].VertexIndex2); triangleBatch.AddIndex(cell.VoxelTriangles[i].VertexIndex1); triangleBatch.AddIndex(cell.VoxelTriangles[i].VertexIndex0); } MyRenderProxy.DebugDrawTriangles(triangleBatch, Matrix.CreateTranslation(PositionLeftBottomCorner), Color.CornflowerBlue, depthRead, false); } } } return(base.DebugDraw()); }
public static void DrawCollisionShape(HkShape shape, MatrixD worldMatrix, float alpha, ref int shapeIndex, string customText = null, bool isPhantom = false) { var color = GetShapeColor(shape.ShapeType, ref shapeIndex, isPhantom); if (isPhantom) { alpha *= alpha; } color.A = (byte)(alpha * 255); bool shaded = true; float expandSize = 0.02f; float expandRatio = 1.035f; bool drawCustomText = false; switch (shape.ShapeType) { case HkShapeType.Sphere: { var sphere = (HkSphereShape)shape; float radius = sphere.Radius; VRageRender.MyRenderProxy.DebugDrawSphere(worldMatrix.Translation, radius, color, alpha, true, shaded); if (isPhantom) { VRageRender.MyRenderProxy.DebugDrawSphere(worldMatrix.Translation, radius, color, 1.0f, true, false); VRageRender.MyRenderProxy.DebugDrawSphere(worldMatrix.Translation, radius, color, 1.0f, true, false, false); } drawCustomText = true; break; } case HkShapeType.Capsule: { // Sphere and OBB to show cylinder space var capsule = (HkCapsuleShape)shape; Vector3D vertexA = Vector3.Transform(capsule.VertexA, worldMatrix); Vector3D vertexB = Vector3.Transform(capsule.VertexB, worldMatrix); VRageRender.MyRenderProxy.DebugDrawCapsule(vertexA, vertexB, capsule.Radius, color, true, shaded); drawCustomText = true; break; } case HkShapeType.Cylinder: { // Sphere and OBB to show cylinder space var cylinder = (HkCylinderShape)shape; VRageRender.MyRenderProxy.DebugDrawCylinder(worldMatrix, cylinder.VertexA, cylinder.VertexB, cylinder.Radius, color, alpha, true, shaded); drawCustomText = true; break; } case HkShapeType.Box: { var box = (HkBoxShape)shape; VRageRender.MyRenderProxy.DebugDrawOBB(MatrixD.CreateScale(box.HalfExtents * 2 + new Vector3(expandSize)) * worldMatrix, color, alpha, true, shaded); if (isPhantom) { VRageRender.MyRenderProxy.DebugDrawOBB(Matrix.CreateScale(box.HalfExtents * 2 + new Vector3(expandSize)) * worldMatrix, color, 1.0f, true, false); VRageRender.MyRenderProxy.DebugDrawOBB(Matrix.CreateScale(box.HalfExtents * 2 + new Vector3(expandSize)) * worldMatrix, color, 1.0f, true, false, false); } drawCustomText = true; break; } case HkShapeType.ConvexVertices: { var convexShape = (HkConvexVerticesShape)shape; Vector3 center; convexShape.GetGeometry(DebugGeometry, out center); Vector3D transformedCenter = Vector3D.Transform(center, worldMatrix.GetOrientation()); var matrix = worldMatrix; matrix = MatrixD.CreateScale(expandRatio) * matrix; matrix.Translation -= transformedCenter * (expandRatio - 1); //matrix.Translation += transformedCenter; DrawGeometry(DebugGeometry, matrix, color, true, true); drawCustomText = true; break; } case HkShapeType.ConvexTranslate: { var translateShape = (HkConvexTranslateShape)shape; DrawCollisionShape((HkShape)translateShape.ChildShape, Matrix.CreateTranslation(translateShape.Translation) * worldMatrix, alpha, ref shapeIndex, customText); break; } case HkShapeType.ConvexTransform: { var transformShape = (HkConvexTransformShape)shape; DrawCollisionShape(transformShape.ChildShape, transformShape.Transform * worldMatrix, alpha, ref shapeIndex, customText); break; } case HkShapeType.Mopp: { var compoundShape = (HkMoppBvTreeShape)shape; DrawCollisionShape(compoundShape.ShapeCollection, worldMatrix, alpha, ref shapeIndex, customText); break; } case HkShapeType.List: { var listShape = (HkListShape)shape; var iterator = listShape.GetIterator(); while (iterator.IsValid) { //string text = (customText ?? string.Empty) + "[" + iterator.CurrentShapeKey + "]"; DrawCollisionShape(iterator.CurrentValue, worldMatrix, alpha, ref shapeIndex, customText); iterator.Next(); } break; } case HkShapeType.StaticCompound: { var compoundShape = (HkStaticCompoundShape)shape; if (DebugDrawFlattenHierarchy) { var it = compoundShape.GetIterator(); while (it.IsValid) { if (compoundShape.IsShapeKeyEnabled(it.CurrentShapeKey)) { string text = (customText ?? string.Empty) + "-" + it.CurrentShapeKey + "-"; DrawCollisionShape(it.CurrentValue, worldMatrix, alpha, ref shapeIndex, text); } it.Next(); } } else { for (int i = 0; i < compoundShape.InstanceCount; i++) { bool enabled = compoundShape.IsInstanceEnabled(i); string text; if (enabled) { text = (customText ?? string.Empty) + "<" + i + ">"; } else { text = (customText ?? string.Empty) + "(" + i + ")"; } if (enabled) { DrawCollisionShape(compoundShape.GetInstance(i), compoundShape.GetInstanceTransform(i) * worldMatrix, alpha, ref shapeIndex, text); } } } break; } case HkShapeType.Triangle: { HkTriangleShape tri = (HkTriangleShape)shape; VRageRender.MyRenderProxy.DebugDrawTriangle(tri.Pt0, tri.Pt1, tri.Pt2, Color.Green, false, false); break; } case HkShapeType.BvTree: { var gridShape = (HkGridShape)shape; if (HkGridShapeCellDebugDraw && !gridShape.Base.IsZero) { Vector3S min, max; var cellSize = gridShape.CellSize; int count = gridShape.GetShapeInfoCount(); for (int i = 0; i < count; i++) { try { gridShape.GetShapeInfo(i, out min, out max, m_tmpShapeList); Vector3 size = max * cellSize - min * cellSize; Vector3 center = (max * cellSize + min * cellSize) / 2.0f; size += Vector3.One * cellSize; var clr = color; if (min == max) { clr = new Color(1.0f, 0.2f, 0.1f); } VRageRender.MyRenderProxy.DebugDrawOBB(Matrix.CreateScale(size + new Vector3(expandSize)) * Matrix.CreateTranslation(center) * worldMatrix, clr, alpha, true, shaded); } finally { m_tmpShapeList.Clear(); } } } else { var msg = MyRenderProxy.PrepareDebugDrawTriangles(); try { using (HkShapeBuffer buf = new HkShapeBuffer()) { var treeShape = (HkBvTreeShape)shape; for (var i = treeShape.GetIterator(buf); i.IsValid; i.Next()) { var child = i.CurrentValue; if (child.ShapeType == HkShapeType.Triangle) { var tri = (HkTriangleShape)child; msg.AddTriangle(tri.Pt0, tri.Pt1, tri.Pt2); } else { DrawCollisionShape(child, worldMatrix, alpha, ref shapeIndex); } } } } finally { MyRenderProxy.DebugDrawTriangles(msg, worldMatrix, color, false, false); } } break; } case HkShapeType.BvCompressedMesh: { if (MyDebugDrawSettings.DEBUG_DRAW_TRIANGLE_PHYSICS) { var meshShape = (HkBvCompressedMeshShape)shape; meshShape.GetGeometry(DebugGeometry); DrawGeometry(DebugGeometry, worldMatrix, Color.Green, false, false); drawCustomText = true; } break; } case HkShapeType.Bv: { var bvShape = (HkBvShape)shape; DrawCollisionShape(bvShape.BoundingVolumeShape, worldMatrix, alpha, ref shapeIndex, null, true); DrawCollisionShape(bvShape.ChildShape, worldMatrix, alpha, ref shapeIndex); break; } case HkShapeType.PhantomCallback: { // Nothing to draw, it's just shape with events MyRenderProxy.DebugDrawText3D(worldMatrix.Translation, "Phantom", Color.Green, 0.75f, false); break; } default: break; } if (drawCustomText && customText != null) { color.A = 255; MyRenderProxy.DebugDrawText3D(worldMatrix.Translation, customText, color, 0.8f, false); } }
public override void DebugDraw() { var minCorner = m_planet.PositionLeftBottomCorner; m_planet.Components.Get <MyPlanetEnvironmentComponent>().DebugDraw(); m_planet.DebugDrawPhysics(); if (MyDebugDrawSettings.DEBUG_DRAW_VOXEL_MAP_AABB) { VRageRender.MyRenderProxy.DebugDrawAABB(m_planet.PositionComp.WorldAABB, Color.White, 1f, 1f, true); VRageRender.MyRenderProxy.DebugDrawLine3D(minCorner, minCorner + new Vector3(1f, 0f, 0f), Color.Red, Color.Red, true); VRageRender.MyRenderProxy.DebugDrawLine3D(minCorner, minCorner + new Vector3(0f, 1f, 0f), Color.Green, Color.Green, true); VRageRender.MyRenderProxy.DebugDrawLine3D(minCorner, minCorner + new Vector3(0f, 0f, 1f), Color.Blue, Color.Blue, true); VRageRender.MyRenderProxy.DebugDrawAxis(m_planet.PositionComp.WorldMatrix, 2f, false); VRageRender.MyRenderProxy.DebugDrawSphere(m_planet.PositionComp.GetPosition(), 1, Color.OrangeRed, 1, false); } m_planet.Storage.DebugDraw(m_planet, MyDebugDrawSettings.DEBUG_DRAW_VOXELS_MODE); m_planet.DebugDrawPhysics(); if (MyDebugDrawSettings.DEBUG_DRAW_VOXEL_GEOMETRY_CELL) { LineD worldLine; if (false) { var entityMatrix = MySession.Static.ControlledEntity.Entity.WorldMatrix; worldLine = new LineD(entityMatrix.Translation, entityMatrix.Translation + 25f * entityMatrix.Forward); } else { var camera = MySector.MainCamera; worldLine = new LineD(camera.Position, camera.Position + 25f * camera.ForwardVector); } VRage.Game.Models.MyIntersectionResultLineTriangleEx?result; bool depthRead = true; if (m_planet.GetIntersectionWithLine(ref worldLine, out result)) { var t = result.Value.Triangle.InputTriangle; MyRenderProxy.DebugDrawTriangle( t.Vertex0 + minCorner, t.Vertex1 + minCorner, t.Vertex2 + minCorner, Color.Red, true, false); Vector3I cellCoord, voxelCoord; var worldPosition = result.Value.IntersectionPointInWorldSpace; BoundingBoxD voxelAabb; MyVoxelCoordSystems.WorldPositionToVoxelCoord(minCorner, ref worldPosition, out voxelCoord); MyVoxelCoordSystems.VoxelCoordToWorldAABB(minCorner, ref voxelCoord, out voxelAabb); MyRenderProxy.DebugDrawAABB(voxelAabb, Vector3.UnitY, 1f, 1f, true); MyVoxelCoordSystems.WorldPositionToGeometryCellCoord(minCorner, ref worldPosition, out cellCoord); MyVoxelCoordSystems.GeometryCellCoordToWorldAABB(minCorner, ref cellCoord, out voxelAabb); MyRenderProxy.DebugDrawAABB(voxelAabb, Vector3.UnitZ, 1f, 1f, true); bool isEmpty; MyIsoMesh cell; if (m_planet.Storage.Geometry.TryGetMesh(new MyCellCoord(0, cellCoord), out isEmpty, out cell) && !isEmpty) { MyVoxelVertex tmp; var triangleBatch = MyRenderProxy.PrepareDebugDrawTriangles(); for (int i = 0; i < cell.VerticesCount; ++i) { cell.GetUnpackedVertex(i, out tmp); triangleBatch.AddVertex(tmp.Position); tmp.Position += minCorner; MyRenderProxy.DebugDrawLine3D(tmp.Position, tmp.Position + tmp.Normal * MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF, Color.Gray, Color.White, depthRead); } for (int i = 0; i < cell.TrianglesCount; ++i) { triangleBatch.AddIndex(cell.Triangles[i].VertexIndex2); triangleBatch.AddIndex(cell.Triangles[i].VertexIndex1); triangleBatch.AddIndex(cell.Triangles[i].VertexIndex0); } MyRenderProxy.DebugDrawTriangles(triangleBatch, Matrix.CreateTranslation(minCorner), Color.CornflowerBlue, depthRead, false); } } } }
public static unsafe void DrawCollisionShape(HkShape shape, MatrixD worldMatrix, float alpha, ref int shapeIndex, string customText = null, bool isPhantom = false) { Color color = GetShapeColor(shape.ShapeType, ref shapeIndex, isPhantom); if (isPhantom) { alpha *= alpha; } color.A = (byte)(alpha * 255f); bool smooth = true; float num = 0.02f; float num2 = 1.035f; bool flag2 = false; HkShapeType shapeType = shape.ShapeType; switch (shapeType) { case HkShapeType.Sphere: { float radius = ((HkSphereShape)shape).Radius; MyRenderProxy.DebugDrawSphere(worldMatrix.Translation, radius, color, alpha, true, smooth, true, false); if (isPhantom) { MyRenderProxy.DebugDrawSphere(worldMatrix.Translation, radius, color, 1f, true, false, true, false); MyRenderProxy.DebugDrawSphere(worldMatrix.Translation, radius, color, 1f, true, false, false, false); } flag2 = true; goto TR_0003; } case HkShapeType.Cylinder: { HkCylinderShape shape4 = (HkCylinderShape)shape; MyRenderProxy.DebugDrawCylinder(worldMatrix, shape4.VertexA, shape4.VertexB, shape4.Radius, color, alpha, true, smooth, false); flag2 = true; goto TR_0003; } case HkShapeType.Triangle: { HkTriangleShape shape12 = (HkTriangleShape)shape; MyRenderProxy.DebugDrawTriangle(shape12.Pt0, shape12.Pt1, shape12.Pt2, Color.Green, false, false, false); goto TR_0003; } case HkShapeType.Box: { HkBoxShape shape5 = (HkBoxShape)shape; MyRenderProxy.DebugDrawOBB(MatrixD.CreateScale((shape5.HalfExtents * 2f) + new Vector3(num)) * worldMatrix, color, alpha, true, smooth, true, false); if (isPhantom) { MyRenderProxy.DebugDrawOBB(Matrix.CreateScale((shape5.HalfExtents * 2f) + new Vector3(num)) * worldMatrix, color, 1f, true, false, true, false); MyRenderProxy.DebugDrawOBB(Matrix.CreateScale((shape5.HalfExtents * 2f) + new Vector3(num)) * worldMatrix, color, 1f, true, false, false, false); } flag2 = true; goto TR_0003; } case HkShapeType.Capsule: { HkCapsuleShape shape3 = (HkCapsuleShape)shape; MyRenderProxy.DebugDrawCapsule(Vector3.Transform(shape3.VertexA, worldMatrix), Vector3.Transform(shape3.VertexB, worldMatrix), shape3.Radius, color, true, smooth, false); flag2 = true; goto TR_0003; } case HkShapeType.ConvexVertices: { Vector3 vector; ((HkConvexVerticesShape)shape).GetGeometry(DebugGeometry, out vector); Vector3D vectord2 = Vector3D.Transform(vector, worldMatrix.GetOrientation()); MatrixD xd = worldMatrix; xd = MatrixD.CreateScale((double)num2) * xd; MatrixD *xdPtr1 = (MatrixD *)ref xd; xdPtr1.Translation -= vectord2 * (num2 - 1f); DrawGeometry(DebugGeometry, xd, color, true, true); flag2 = true; goto TR_0003; } case HkShapeType.TriSampledHeightFieldCollection: case HkShapeType.TriSampledHeightFieldBvTree: case HkShapeType.SampledHeightField: case HkShapeType.ExtendedMesh: case HkShapeType.Transform: case HkShapeType.CompressedMesh: case HkShapeType.Collection: case HkShapeType.User0: case HkShapeType.User1: case HkShapeType.User2: goto TR_0003; case HkShapeType.List: { HkShapeContainerIterator iterator = ((HkListShape)shape).GetIterator(); while (iterator.IsValid) { DrawCollisionShape(iterator.CurrentValue, worldMatrix, alpha, ref shapeIndex, customText, false); iterator.Next(); } goto TR_0003; } case HkShapeType.Mopp: DrawCollisionShape((HkShape)((HkMoppBvTreeShape)shape).ShapeCollection, worldMatrix, alpha, ref shapeIndex, customText, false); goto TR_0003; case HkShapeType.ConvexTranslate: { HkConvexTranslateShape shape7 = (HkConvexTranslateShape)shape; DrawCollisionShape((HkShape)shape7.ChildShape, Matrix.CreateTranslation(shape7.Translation) * worldMatrix, alpha, ref shapeIndex, customText, false); goto TR_0003; } case HkShapeType.ConvexTransform: { HkConvexTransformShape shape8 = (HkConvexTransformShape)shape; DrawCollisionShape((HkShape)shape8.ChildShape, shape8.Transform * worldMatrix, alpha, ref shapeIndex, customText, false); goto TR_0003; } case HkShapeType.StaticCompound: { HkStaticCompoundShape shape11 = (HkStaticCompoundShape)shape; if (DebugDrawFlattenHierarchy) { HkShapeContainerIterator iterator2 = shape11.GetIterator(); while (iterator2.IsValid) { if (shape11.IsShapeKeyEnabled(iterator2.CurrentShapeKey)) { object[] objArray1 = new object[4]; object[] objArray2 = new object[4]; objArray2[0] = customText ?? string.Empty; object[] local2 = objArray2; local2[1] = "-"; local2[2] = iterator2.CurrentShapeKey; local2[3] = "-"; string str = string.Concat(local2); DrawCollisionShape(iterator2.CurrentValue, worldMatrix, alpha, ref shapeIndex, str, false); } iterator2.Next(); } } else { for (int i = 0; i < shape11.InstanceCount; i++) { string str2; bool flag3 = shape11.IsInstanceEnabled(i); if (flag3) { object[] objArray3 = new object[4]; object[] objArray4 = new object[4]; objArray4[0] = customText ?? string.Empty; object[] local4 = objArray4; local4[1] = "<"; local4[2] = i; local4[3] = ">"; str2 = string.Concat(local4); } else { object[] objArray5 = new object[4]; object[] objArray6 = new object[4]; objArray6[0] = customText ?? string.Empty; object[] local6 = objArray6; local6[1] = "("; local6[2] = i; local6[3] = ")"; str2 = string.Concat(local6); } if (flag3) { DrawCollisionShape(shape11.GetInstance(i), shape11.GetInstanceTransform(i) * worldMatrix, alpha, ref shapeIndex, str2, false); } } } goto TR_0003; } case HkShapeType.BvCompressedMesh: break; case HkShapeType.BvTree: { HkGridShape shape13 = (HkGridShape)shape; if (HkGridShapeCellDebugDraw && !shape13.Base.IsZero) { float cellSize = shape13.CellSize; int shapeInfoCount = shape13.GetShapeInfoCount(); for (int i = 0; i < shapeInfoCount; i++) { try { Vector3S vectors; Vector3S vectors2; shape13.GetShapeInfo(i, out vectors, out vectors2, m_tmpShapeList); Vector3 position = (Vector3)(((vectors2 * cellSize) + (vectors * cellSize)) / 2f); Color color2 = color; if (vectors == vectors2) { color2 = new Color(1f, 0.2f, 0.1f); } MyRenderProxy.DebugDrawOBB((Matrix.CreateScale((((vectors2 * cellSize) - (vectors * cellSize)) + (Vector3.One * cellSize)) + new Vector3(num)) * Matrix.CreateTranslation(position)) * worldMatrix, color2, alpha, true, smooth, true, false); } finally { m_tmpShapeList.Clear(); } } } else { MyRenderMessageDebugDrawTriangles msgInterface = MyRenderProxy.PrepareDebugDrawTriangles(); try { using (HkShapeBuffer buffer = new HkShapeBuffer()) { HkShapeContainerIterator iterator3 = ((HkBvTreeShape)shape).GetIterator(buffer); while (iterator3.IsValid) { HkShape currentValue = iterator3.CurrentValue; if (currentValue.ShapeType != HkShapeType.Triangle) { DrawCollisionShape(currentValue, worldMatrix, alpha, ref shapeIndex, null, false); } else { HkTriangleShape shape17 = (HkTriangleShape)currentValue; msgInterface.AddTriangle(shape17.Pt0, shape17.Pt1, shape17.Pt2); } iterator3.Next(); } goto TR_0003; } } finally { msgInterface.Color = color; MyRenderProxy.DebugDrawTriangles(msgInterface, new MatrixD?(worldMatrix), false, false, false, false); } break; } goto TR_0003; } default: if (shapeType == HkShapeType.Bv) { HkBvShape shape19 = (HkBvShape)shape; DrawCollisionShape(shape19.BoundingVolumeShape, worldMatrix, alpha, ref shapeIndex, null, true); DrawCollisionShape(shape19.ChildShape, worldMatrix, alpha, ref shapeIndex, null, false); } else if (shapeType == HkShapeType.PhantomCallback) { MyRenderProxy.DebugDrawText3D(worldMatrix.Translation, "Phantom", Color.Green, 0.75f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false); } goto TR_0003; } if (MyDebugDrawSettings.DEBUG_DRAW_TRIANGLE_PHYSICS) { ((HkBvCompressedMeshShape)shape).GetGeometry(DebugGeometry); DrawGeometry(DebugGeometry, worldMatrix, Color.Green, false, false); flag2 = true; } TR_0003: if (flag2 && (customText != null)) { color.A = 0xff; MyRenderProxy.DebugDrawText3D(worldMatrix.Translation, customText, color, 0.8f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false); } }