dynamic body creation/destroing..

celic

11-05-2006 08:50:18

Hi, betajaen!!

I have a scene, let it be a track which contains many sub-tracks ( I mean meshes here ). So, when I'm initializing the scene I create one staticBody per mesh, in order to drive on the road surface. But this approach isn't the best I guess, cause it's to expensive :(

How could I say to nxOgre which track region to consider active for collisions and which not? Or should I create these bodies dynamically and remove them just after the vehicle pass the track..?

Hope you understood me.. :)
Thanks!

betajaen

11-05-2006 11:06:48

Stages will be (once I write the code) are meant for that sort of thing to turn off and on collisions and physics for a particular part of a scene.

I don't think there is any real expense leaving them in, obviously you can not show the mesh in Ogre when it's out of view, i.e. culling.

But you could use "fake stages" using triggers. Scatter them around the scene then, assign one stage which is active and the rest are inactive then you can make all of the bodies in the inactive stages sleep (and not show them if needed), then from moving one stage to another just wake up all the bodies in that stage, and put to sleep the others.

celic

11-05-2006 13:22:57

So, I could create no matter how many bodies for the collision, the idea is to switch them off, I mean to make them sleep..!? Thus, they won't make any impact on the performance?!

Thanks a lot! :)

betajaen

11-05-2006 13:31:02

In theory yes. :D

celic

11-05-2006 15:50:51

Ok, thanks a lot betajaen!!! :D