Showing the changes to libraries/physics/src/ObjectMotionState.cpp (1 of 7 files). Show all
Unified · Split
| @@ -12,7 +12,6 @@ · 11 unmodified lines | |||
| 12 | #include <math.h> | 12 | #include <math.h> |
| 13 | 13 | ||
| 14 | #include "BulletUtil.h" | 14 | #include "BulletUtil.h" |
| 15 | #include "KinematicController.h" | ||
| 16 | #include "ObjectMotionState.h" | 15 | #include "ObjectMotionState.h" |
| 17 | #include "PhysicsEngine.h" | 16 | #include "PhysicsEngine.h" |
| 18 | 17 | ||
| @@ -56,10 +55,6 @@ ObjectMotionState::ObjectMotionState() : · 37 unmodified lines | |||
| 56 | ObjectMotionState::~ObjectMotionState() { | 55 | ObjectMotionState::~ObjectMotionState() { |
| 57 | // NOTE: you MUST remove this MotionState from the world before you call the dtor. | 56 | // NOTE: you MUST remove this MotionState from the world before you call the dtor. |
| 58 | assert(_body == NULL); | 57 | assert(_body == NULL); |
| 59 | if (_kinematicController) { | ||
| 60 | delete _kinematicController; | ||
| 61 | _kinematicController = NULL; | ||
| 62 | } | ||
| 63 | } | 58 | } |
| 64 | 59 | ||
| 65 | void ObjectMotionState::setFriction(float friction) { | 60 | void ObjectMotionState::setFriction(float friction) { |
| @@ -108,6 +103,15 @@ bool ObjectMotionState::doesNotNeedToSendUpdate() const { · 42 unmodified lines | |||
| 108 | 103 | ||
| 109 | bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { | 104 | bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { |
| 110 | assert(_body); | 105 | assert(_body); |
| 106 | // if we've never checked before, our _sentFrame will be 0, and we need to initialize our state | ||
| 107 | if (_sentFrame == 0) { | ||
| 108 | _sentPosition = bulletToGLM(_body->getWorldTransform().getOrigin()); | ||
| 109 | _sentVelocity = bulletToGLM(_body->getLinearVelocity()); | ||
| 110 | _sentAngularVelocity = bulletToGLM(_body->getAngularVelocity()); | ||
| 111 | _sentFrame = simulationFrame; | ||
| 112 | return false; | ||
| 113 | } | ||
| 114 | |||
| 111 | float dt = (float)(simulationFrame - _sentFrame) * PHYSICS_ENGINE_FIXED_SUBSTEP; | 115 | float dt = (float)(simulationFrame - _sentFrame) * PHYSICS_ENGINE_FIXED_SUBSTEP; |
| 112 | _sentFrame = simulationFrame; | 116 | _sentFrame = simulationFrame; |
| 113 | bool isActive = _body->isActive(); | 117 | bool isActive = _body->isActive(); |
| @@ -164,13 +168,6 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { · 50 unmodified lines | |||
| 164 | return (fabsf(glm::dot(actualRotation, _sentRotation)) < MIN_ROTATION_DOT); | 168 | return (fabsf(glm::dot(actualRotation, _sentRotation)) < MIN_ROTATION_DOT); |
| 165 | } | 169 | } |
| 166 | 170 | ||
| 167 | void ObjectMotionState::removeKinematicController() { | ||
| 168 | if (_kinematicController) { | ||
| 169 | delete _kinematicController; | ||
| 170 | _kinematicController = NULL; | ||
| 171 | } | ||
| 172 | } | ||
| 173 | |||
| 174 | void ObjectMotionState::setRigidBody(btRigidBody* body) { | 171 | void ObjectMotionState::setRigidBody(btRigidBody* body) { |
| 175 | // give the body a (void*) back-pointer to this ObjectMotionState | 172 | // give the body a (void*) back-pointer to this ObjectMotionState |
| 176 | if (_body != body) { | 173 | if (_body != body) { |
| @@ -183,3 +180,8 @@ void ObjectMotionState::setRigidBody(btRigidBody* body) { · 6 unmodified lines | |||
| 183 | } | 180 | } |
| 184 | } | 181 | } |
| 185 | } | 182 | } |
| 183 | |||
| 184 | void ObjectMotionState::setKinematic(bool kinematic, uint32_t substep) { | ||
| 185 | _isKinematic = kinematic; | ||
| 186 | _lastKinematicSubstep = substep; | ||
| 187 | } | ||