Showing the changes to libraries/physics/src/ObjectMotionState.cpp (1 of 14 files). Show all
Unified · Split
| @@ -14,7 +14,9 @@ · 13 unmodified lines | |||
| 14 | #include <math.h> | 14 | #include <math.h> |
| 15 | 15 | ||
| 16 | #include "BulletUtil.h" | 16 | #include "BulletUtil.h" |
| 17 | #include "KinematicController.h" | ||
| 17 | #include "ObjectMotionState.h" | 18 | #include "ObjectMotionState.h" |
| 19 | #include "PhysicsEngine.h" | ||
| 18 | 20 | ||
| 19 | const float MIN_DENSITY = 200.0f; | 21 | const float MIN_DENSITY = 200.0f; |
| 20 | const float DEFAULT_DENSITY = 1000.0f; | 22 | const float DEFAULT_DENSITY = 1000.0f; |
| @@ -67,6 +69,10 @@ ObjectMotionState::ObjectMotionState() : · 46 unmodified lines | |||
| 67 | ObjectMotionState::~ObjectMotionState() { | 69 | ObjectMotionState::~ObjectMotionState() { |
| 68 | // NOTE: you MUST remove this MotionState from the world before you call the dtor. | 70 | // NOTE: you MUST remove this MotionState from the world before you call the dtor. |
| 69 | assert(_body == NULL); | 71 | assert(_body == NULL); |
| 72 | if (_kinematicController) { | ||
| 73 | delete _kinematicController; | ||
| 74 | _kinematicController = NULL; | ||
| 75 | } | ||
| 70 | } | 76 | } |
| 71 | 77 | ||
| 72 | void ObjectMotionState::setDensity(float density) { | 78 | void ObjectMotionState::setDensity(float density) { |
| @@ -121,11 +127,9 @@ bool ObjectMotionState::doesNotNeedToSendUpdate() const { · 48 unmodified lines | |||
| 121 | return !_body->isActive() && _numNonMovingUpdates > MAX_NUM_NON_MOVING_UPDATES; | 127 | return !_body->isActive() && _numNonMovingUpdates > MAX_NUM_NON_MOVING_UPDATES; |
| 122 | } | 128 | } |
| 123 | 129 | ||
| 124 | const float FIXED_SUBSTEP = 1.0f / 60.0f; | ||
| 125 | |||
| 126 | bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { | 130 | bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { |
| 127 | assert(_body); | 131 | assert(_body); |
| 128 | float dt = (float)(simulationFrame - _sentFrame) * FIXED_SUBSTEP; | 132 | float dt = (float)(simulationFrame - _sentFrame) * PHYSICS_ENGINE_FIXED_SUBSTEP; |
| 129 | _sentFrame = simulationFrame; | 133 | _sentFrame = simulationFrame; |
| 130 | bool isActive = _body->isActive(); | 134 | bool isActive = _body->isActive(); |
| 131 | 135 | ||
| @@ -186,4 +190,11 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { · 54 unmodified lines | |||
| 186 | return (fabsf(glm::dot(actualRotation, _sentRotation)) < MIN_ROTATION_DOT); | 190 | return (fabsf(glm::dot(actualRotation, _sentRotation)) < MIN_ROTATION_DOT); |
| 187 | } | 191 | } |
| 188 | 192 | ||
| 193 | void ObjectMotionState::removeKinematicController() { | ||
| 194 | if (_kinematicController) { | ||
| 195 | delete _kinematicController; | ||
| 196 | _kinematicController = NULL; | ||
| 197 | } | ||
| 198 | } | ||
| 199 | |||
| 189 | #endif // USE_BULLET_PHYSICS | 200 | #endif // USE_BULLET_PHYSICS |