public void UpdateSoftBody(SoftBody softBody, ShapeData shapeData) { // Could just allocate a Vector3 array here at each frame, but reusing shapeData.SoftBodyData is faster. // Probably uses more memory though. softBody.GetVertexNormalData(ref shapeData.SoftBodyData); shapeData.SetDynamicVertexBuffer(device, shapeData.SoftBodyData); if (softBody.Faces.Count == 0 && softBody.Tetras.Count == 0) { shapeData.PrimitiveTopology = PrimitiveTopology.LineList; } }
public void UpdateSoftBody(SoftBody softBody, ShapeData shapeData) { softBody.GetVertexNormalData(out shapeData.SoftBodyVertices, out shapeData.SoftBodyNormals); shapeData.SetDynamicVertexBuffer(shapeData.SoftBodyVertices); if (shapeData.SoftBodyNormals != null) { shapeData.SetDynamicNormalBuffer(shapeData.SoftBodyNormals); } else { shapeData.SetDynamicNormalBuffer(new Vector3[shapeData.VertexCount]); // hack, should use a different shader that doesn't process normals shapeData.PrimitiveType = BeginMode.Lines; } }