Page 1 of 1

StaticGroup

Posted: Mon Jun 04, 2012 11:26 pm
by codedjinn
Hi,

I have a map built out of a bunch of models, each which I create as StaticMesh objects and then I add all those instances to a StaticGroup for improved performance. (As I have read on one of the other forums). What I can't understand though, if I add new dynamic physical objects (for testing I just use a Box prefab for now) it will report that a NaN transform was encountered. If I remove the StaticMeshes and StaticGroup, and just add a plane object (Box prefab with 1000,1,1000 dimensions), I never get a NaN exception.

Happens in the BEPUphysics.Entities.Entity class

Error occurs at method:

Code: Select all

 public void ApplyLinearImpulse(ref Vector3 impulse)
line:

Code: Select all

linearVelocity.Validate();
Any help or suggestions would be appreciated.
Jaco

Re: StaticGroup

Posted: Mon Jun 04, 2012 11:32 pm
by Norbo
Could you reproduce the issue in a BEPUphysicsDemos demo for me to debug?

Are there any absolutely massive shapes involved? Say, a triangle a few million units across with an exposed edge in the play area which could be collided with? Though I haven't observed it directly, I would not be surprised if that sort of stress could throw a few NaNs out.

If that ApplyLinearImpulse is called from an external context (as opposed to say, the solver), make sure the impulse passed in is valid.

Re: StaticGroup

Posted: Tue Jun 05, 2012 12:00 am
by codedjinn
Hi,

I will try and repro it for you via the demo. The thing is, the meshes are really simple, they are boxes themselves. To elaborate, my map is basically a 2d array, so each box is a "tile" inside the world, so if you have a 32x32 map, it would be 1024 objects I would like to group together. What I did before using the StaticGroup, was to extract the vertex and index data from each "tile" model, and then pass that into one StaticMesh object, but that also gave the same issue. As for forces, I am simply adding 1x1x1 mass 1f boxes randomly and let gravity do its work.

EDIT:

No need to worry anymore! Thanks for the advise to try and repro problem in the demo project. So what happened was that instead of using the extracted vertices and
indicis data from my custom content processor, I used the TriangleMesh.Get.... helper method, and then constructed the static meshes and grouped them together...and it worked. So I went back to my project, replaced my ( obviously flawed code :P ) with BEPU extraction method...and all is working good. So the NaN values were obviously been calculated because bad data was pushed into the system.

Thank you very much again for your help.