Search code examples
c++pointersbulletphysics

Bullet physics crashing because of invalid reference?


I'm making a game with bullet physics where I have a Platform class, which contains a btBoxShape, btDefaultMotionState and a btRigidBody as members. When exiting my game it crashes. I store the Platform objects in an std::vector, and I think this is the problem. When I push back more Platforms, the vector resizes and moves in memory. This means that whatever pointer to the shape and motionstate that the rigid body has is invalidated. How should I solve this?


Solution

  • A std:deque will not invalidate the references.