Code: Select all
public DynamicObject(int modelNum, string name, Vector3 pos)
: base(modelNum, name, pos)
{
Vector3[] vertices;
int[] indices;
TriangleMesh.GetVerticesAndIndicesFromModel(GameModels.getModel(modelNum).PhysicsModel, out vertices, out indices);
float scaleFactor = GameModels.getModel(modelNum).PhysicsScale.M11;
Vector3 scale = new Vector3(scaleFactor,scaleFactor,scaleFactor);
for (int i = 0; i < vertices.Length; i++ )
{
vertices[i] = Vector3.Multiply(vertices[i], scale);
}
body = new ConvexHull(pos, vertices, 50f);
body.Tag = GameModels.getModel(modelNum);
}
It managed to spawn them fine, but then suddenly threw an AurgumentException after a while on the:
Code: Select all
body = new ConvexHull(pos, vertices, 50f);
It seems to generate the exception sometimes, but the rest of the time the framerate just drops from 63 to around 27.
What does this mean and how do I fix it?