solved: single CompoundCollision instance for multiple bodys

banal

13-01-2008 16:05:07

Hi forum

I have multiple Classes, each representing a Object consisting of a Ogre Entity a SceneNode, and a OgreNewt Body.
Basically the whole Physic Setup is handled inside the class (setting Collision, Mass, Inertia etc).

Since collision objects can be defined once and then be re-used ( according to this WIKI Article) i thought it might be a good idea to store the Collision Object in a static member variable. Sort of a singleton.

This seems to work nicely for Primitive Shapes but i have some Classes where i use CompoundCollision Objects. Using them results in the following behaviour:
Only the last created Object will collide with the World. All previously created instances don't.
Do i have to keep the std::vector that contains all primitive shapes that form the CompoundCollision Object as well? Could that be the Problem here?

I'd be thankful for any pointers as how to solve this issue
-- banal

Edit: i did a test and kept the std::vector<OgreNewt::Collision*> as static Member as well. Nothing changed.
Could this be a bug that occurs with the CompoundCollision Objects? Do these Objects always have to be "re-built"?

walaber

14-01-2008 02:09:18

yes, compoundcollision objects are unique... save the original collision objects that it is made from, and then make the compound collision new every time you need it... that should fix it.

banal

14-01-2008 07:51:11

Hi walaber

That fixed it indeed. Thanks so much!