History

support for simple kinematic motion

Andrew Meadows committed 11 years ago

Commit 250fd981 parent 04b4a9514 files · +251 −31Browse files

Showing the changes to libraries/physics/src/ObjectMotionState.cpp (1 of 14 files). Show all

Unified · Split

libraries/physics/src/ObjectMotionState.cpp+14−3
@@ -14,7 +14,9 @@ · 13 unmodified lines
1414 #include <math.h>
1515
1616 #include "BulletUtil.h"
17+#include "KinematicController.h"
1718 #include "ObjectMotionState.h"
19+#include "PhysicsEngine.h"
1820
1921 const float MIN_DENSITY = 200.0f;
2022 const float DEFAULT_DENSITY = 1000.0f;
@@ -67,6 +69,10 @@ ObjectMotionState::ObjectMotionState() : · 46 unmodified lines
6769 ObjectMotionState::~ObjectMotionState() {
6870 // NOTE: you MUST remove this MotionState from the world before you call the dtor.
6971 assert(_body == NULL);
72+ if (_kinematicController) {
73+ delete _kinematicController;
74+ _kinematicController = NULL;
75+ }
7076 }
7177
7278 void ObjectMotionState::setDensity(float density) {
@@ -121,11 +127,9 @@ bool ObjectMotionState::doesNotNeedToSendUpdate() const { · 48 unmodified lines
121127 return !_body->isActive() && _numNonMovingUpdates > MAX_NUM_NON_MOVING_UPDATES;
122128 }
123129
124−const float FIXED_SUBSTEP = 1.0f / 60.0f;
125−
126130 bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) {
127131 assert(_body);
128− float dt = (float)(simulationFrame - _sentFrame) * FIXED_SUBSTEP;
132+ float dt = (float)(simulationFrame - _sentFrame) * PHYSICS_ENGINE_FIXED_SUBSTEP;
129133 _sentFrame = simulationFrame;
130134 bool isActive = _body->isActive();
131135
@@ -186,4 +190,11 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { · 54 unmodified lines
186190 return (fabsf(glm::dot(actualRotation, _sentRotation)) < MIN_ROTATION_DOT);
187191 }
188192
193+void ObjectMotionState::removeKinematicController() {
194+ if (_kinematicController) {
195+ delete _kinematicController;
196+ _kinematicController = NULL;
197+ }
198+}
199+
189200 #endif // USE_BULLET_PHYSICS

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t