123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #ifndef GODOT_MOTION_STATE_H
- #define GODOT_MOTION_STATE_H
- #include "rigid_body_bullet.h"
- #include <LinearMath/btMotionState.h>
- class RigidBodyBullet;
- // This class is responsible to move kinematic actor
- // and sincronize rendering engine with Bullet
- /// DOC:
- /// http://www.bulletphysics.org/mediawiki-1.5.8/index.php/MotionStates#What.27s_a_MotionState.3F
- class GodotMotionState : public btMotionState {
-
- btTransform bodyKinematicWorldTransf;
-
- btTransform bodyCurrentWorldTransform;
- RigidBodyBullet *owner;
- public:
- GodotMotionState(RigidBodyBullet *p_owner) :
- bodyKinematicWorldTransf(btMatrix3x3(1., 0., 0., 0., 1., 0., 0., 0., 1.), btVector3(0., 0., 0.)),
- bodyCurrentWorldTransform(btMatrix3x3(1., 0., 0., 0., 1., 0., 0., 0., 1.), btVector3(0., 0., 0.)),
- owner(p_owner) {}
-
-
-
-
-
-
-
- virtual void getWorldTransform(btTransform &worldTrans) const {
- worldTrans = bodyKinematicWorldTransf;
- }
-
-
-
-
-
-
-
-
- virtual void setWorldTransform(const btTransform &worldTrans) {
- bodyCurrentWorldTransform = worldTrans;
- owner->notify_transform_changed();
- }
- public:
-
-
- void moveBody(const btTransform &newWorldTransform) {
- bodyKinematicWorldTransf = newWorldTransform;
- }
-
- const btTransform &getCurrentWorldTransform() const {
- return bodyCurrentWorldTransform;
- }
- };
- #endif
|