diff --git a/panda/src/bullet/bulletRigidBodyNode.cxx b/panda/src/bullet/bulletRigidBodyNode.cxx index 93eddedc99..4328952f73 100644 --- a/panda/src/bullet/bulletRigidBodyNode.cxx +++ b/panda/src/bullet/bulletRigidBodyNode.cxx @@ -34,7 +34,7 @@ BulletRigidBodyNode(const char *name) : BulletBodyNode(name) { btVector3 inertia(0, 0, 0); // Motion state and construction info - btDefaultMotionState *motion = new btDefaultMotionState(); + MotionState *motion = new MotionState(_sync); btRigidBody::btRigidBodyConstructionInfo ci(mass, motion, _shape, inertia); // Additional damping @@ -451,3 +451,24 @@ set_angular_factor(const LVector3f &factor) { _rigid->setAngularFactor(LVecBase3f_to_btVector3(factor)); } +//////////////////////////////////////////////////////////////////// +// Function: BulletRigidBodyNode::MotionState::getWorldTransform +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void BulletRigidBodyNode::MotionState:: +getWorldTransform(btTransform &trans) const { + + trans = TransformState_to_btTrans(_sync); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletRigidBodyNode::MotionState::setWorldTransform +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void BulletRigidBodyNode::MotionState:: +setWorldTransform(const btTransform &trans) { + +} + diff --git a/panda/src/bullet/bulletRigidBodyNode.h b/panda/src/bullet/bulletRigidBodyNode.h index 1935fb413e..bf71b0255d 100644 --- a/panda/src/bullet/bulletRigidBodyNode.h +++ b/panda/src/bullet/bulletRigidBodyNode.h @@ -91,6 +91,22 @@ protected: private: virtual void shape_changed(); + // The motion state is required only for kinematic bodies. + // For kinematic nodies getWorldTransform is called each frame, and + // should return the current world transform of the node. + class MotionState : public btMotionState { + + public: + MotionState(CPT(TransformState) & sync) : _sync(sync) {}; + ~MotionState() {}; + + virtual void getWorldTransform(btTransform &trans) const; + virtual void setWorldTransform(const btTransform &trans); + + private: + CPT(TransformState) &_sync; + }; + CPT(TransformState) _sync; bool _sync_disable;