mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
An implementation of btMotionState is required for kineamtic bodies.
This commit is contained in:
parent
5158b9b5bf
commit
5bea667a74
@ -34,7 +34,7 @@ BulletRigidBodyNode(const char *name) : BulletBodyNode(name) {
|
|||||||
btVector3 inertia(0, 0, 0);
|
btVector3 inertia(0, 0, 0);
|
||||||
|
|
||||||
// Motion state and construction info
|
// Motion state and construction info
|
||||||
btDefaultMotionState *motion = new btDefaultMotionState();
|
MotionState *motion = new MotionState(_sync);
|
||||||
btRigidBody::btRigidBodyConstructionInfo ci(mass, motion, _shape, inertia);
|
btRigidBody::btRigidBodyConstructionInfo ci(mass, motion, _shape, inertia);
|
||||||
|
|
||||||
// Additional damping
|
// Additional damping
|
||||||
@ -451,3 +451,24 @@ set_angular_factor(const LVector3f &factor) {
|
|||||||
_rigid->setAngularFactor(LVecBase3f_to_btVector3(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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -91,6 +91,22 @@ protected:
|
|||||||
private:
|
private:
|
||||||
virtual void shape_changed();
|
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;
|
CPT(TransformState) _sync;
|
||||||
bool _sync_disable;
|
bool _sync_disable;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user