private unsafe void DebugDrawShape(string blockName, HkShape shape, MatrixD worldMatrix) { float num = 1.05f; float num2 = 0.02f; if (MyPerGameSettings.Game == GameEnum.SE_GAME) { num2 = 0.1f; } switch (shape.ShapeType) { case HkShapeType.Box: MyRenderProxy.DebugDrawOBB(MatrixD.CreateScale((((HkBoxShape)shape).HalfExtents * 2f) + new Vector3(num2)) * worldMatrix, Color.Red, 0f, true, false, true, false); return; case HkShapeType.Capsule: case HkShapeType.TriSampledHeightFieldCollection: case HkShapeType.TriSampledHeightFieldBvTree: break; case HkShapeType.ConvexVertices: { GeometryCenterPair pair; HkConvexVerticesShape shape7 = (HkConvexVerticesShape)shape; if (!this.m_cachedGeometry.TryGetValue(blockName, out pair)) { Vector3 vector; HkGeometry geometry = new HkGeometry(); shape7.GetGeometry(geometry, out vector); GeometryCenterPair pair1 = new GeometryCenterPair(); pair1.Geometry = geometry; pair1.Center = vector; pair = pair1; if (!string.IsNullOrEmpty(blockName)) { this.m_cachedGeometry.Add(blockName, pair); } } Vector3D vectord = Vector3D.Transform(pair.Center, worldMatrix.GetOrientation()); MatrixD xd = worldMatrix; xd = MatrixD.CreateScale((double)num) * xd; MatrixD *xdPtr1 = (MatrixD *)ref xd; xdPtr1.Translation -= vectord * (num - 1f); this.DrawGeometry(pair.Geometry, xd, Color.Olive, false, false); break; } case HkShapeType.List: { HkShapeContainerIterator iterator = ((HkListShape)shape).GetIterator(); int num3 = 0; while (iterator.IsValid) { num3++; this.DebugDrawShape(blockName + num3, iterator.CurrentValue, worldMatrix); iterator.Next(); } return; } case HkShapeType.Mopp: { HkMoppBvTreeShape shape4 = (HkMoppBvTreeShape)shape; this.DebugDrawShape(blockName, (HkShape)shape4.ShapeCollection, worldMatrix); return; } case HkShapeType.ConvexTranslate: { HkConvexTranslateShape shape6 = (HkConvexTranslateShape)shape; this.DebugDrawShape(blockName, (HkShape)shape6.ChildShape, Matrix.CreateTranslation(shape6.Translation) * worldMatrix); return; } case HkShapeType.ConvexTransform: { HkConvexTransformShape shape5 = (HkConvexTransformShape)shape; this.DebugDrawShape(blockName, (HkShape)shape5.ChildShape, shape5.Transform * worldMatrix); return; } default: return; } }
private unsafe void AddPhysicalShape(HkShape shape, Matrix rdWorldMatrix) { switch (shape.ShapeType) { case HkShapeType.Sphere: { HkSphereShape shape7 = (HkSphereShape)shape; m_icosphereMesh.AddTrianglesToWorldVertices(rdWorldMatrix.Translation, shape7.Radius); return; } case HkShapeType.Cylinder: case HkShapeType.Triangle: case HkShapeType.TriSampledHeightFieldCollection: case HkShapeType.TriSampledHeightFieldBvTree: break; case HkShapeType.Box: { HkBoxShape shape2 = (HkBoxShape)shape; Vector3D min = new Vector3D((double)-shape2.HalfExtents.X, (double)-shape2.HalfExtents.Y, (double)-shape2.HalfExtents.Z); Vector3D max = new Vector3D((double)shape2.HalfExtents.X, (double)shape2.HalfExtents.Y, (double)shape2.HalfExtents.Z); BoundingBoxD bbox = new BoundingBoxD(min, max); this.BoundingBoxToTranslatedTriangles(bbox, rdWorldMatrix); return; } case HkShapeType.Capsule: return; case HkShapeType.ConvexVertices: { Vector3 vector; HkConvexVerticesShape shape9 = (HkConvexVerticesShape)shape; HkGeometry geometry = new HkGeometry(); shape9.GetGeometry(geometry, out vector); int triangleIndex = 0; while (true) { int num2; int num3; int num4; int num5; if (triangleIndex >= geometry.TriangleCount) { int vertexIndex = 0; while (true) { if (vertexIndex >= geometry.VertexCount) { WorldVerticesInfo worldVertices = m_worldVertices; worldVertices.VerticesMaxValue += geometry.VertexCount; break; } Vector3 vertex = geometry.GetVertex(vertexIndex); Vector3 *vectorPtr1 = (Vector3 *)ref vertex; Vector3.Transform(ref (Vector3) ref vectorPtr1, ref rdWorldMatrix, out vertex); m_worldVertices.Vertices.Add(vertex); vertexIndex++; } break; } geometry.GetTriangle(triangleIndex, out num2, out num3, out num4, out num5); m_worldVertices.Triangles.Add(m_worldVertices.VerticesMaxValue + num2); m_worldVertices.Triangles.Add(m_worldVertices.VerticesMaxValue + num3); m_worldVertices.Triangles.Add(m_worldVertices.VerticesMaxValue + num4); triangleIndex++; } break; } case HkShapeType.List: { HkShapeContainerIterator iterator = ((HkListShape)shape).GetIterator(); while (iterator.IsValid) { this.AddPhysicalShape(iterator.CurrentValue, rdWorldMatrix); iterator.Next(); } return; } case HkShapeType.Mopp: { HkMoppBvTreeShape shape4 = (HkMoppBvTreeShape)shape; this.AddPhysicalShape((HkShape)shape4.ShapeCollection, rdWorldMatrix); return; } case HkShapeType.ConvexTranslate: { HkConvexTranslateShape shape6 = (HkConvexTranslateShape)shape; Matrix matrix = Matrix.CreateTranslation(shape6.Translation); this.AddPhysicalShape((HkShape)shape6.ChildShape, matrix * rdWorldMatrix); return; } case HkShapeType.ConvexTransform: { HkConvexTransformShape shape5 = (HkConvexTransformShape)shape; this.AddPhysicalShape((HkShape)shape5.ChildShape, shape5.Transform * rdWorldMatrix); return; } default: return; } }