Page 1 of 1

query if a btRigidBody object is already in btDynamicsWorld?

Posted: Thu Aug 02, 2018 4:24 pm
by ed_welch
Quick question: Anyone know how to query if a btRigidBody object is already in btDynamicsWorld?

Re: query if a btRigidBody object is already in btDynamicsWorld?

Posted: Thu Aug 02, 2018 6:34 pm
by drleviathan
You can call btCollisionObject::getWorldArrayIndex() on the body and check its value.

btCollisionWorld::addCollisionObject() will call btCollisionObject::setWorldArrayIndex(N) on the body, where N is a non-negative index.

btCollisionWorld::removeCollisionObject() will call btCollisionObject::setWorldArrayIndex(-1) on the body.