History

add support for non-physical kinematic movement

Andrew Meadows committed 11 years ago

Commit d173afa1 parent 1b7074e7 files · +176 −61Browse files

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

Unified · Split

libraries/physics/src/ObjectMotionState.cpp+14−12
@@ -12,7 +12,6 @@ · 11 unmodified lines
1212 #include <math.h>
1313
1414 #include "BulletUtil.h"
15−#include "KinematicController.h"
1615 #include "ObjectMotionState.h"
1716 #include "PhysicsEngine.h"
1817
@@ -56,10 +55,6 @@ ObjectMotionState::ObjectMotionState() : · 37 unmodified lines
5655 ObjectMotionState::~ObjectMotionState() {
5756 // NOTE: you MUST remove this MotionState from the world before you call the dtor.
5857 assert(_body == NULL);
59− if (_kinematicController) {
60− delete _kinematicController;
61− _kinematicController = NULL;
62− }
6358 }
6459
6560 void ObjectMotionState::setFriction(float friction) {
@@ -108,6 +103,15 @@ bool ObjectMotionState::doesNotNeedToSendUpdate() const { · 42 unmodified lines
108103
109104 bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) {
110105 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+
111115 float dt = (float)(simulationFrame - _sentFrame) * PHYSICS_ENGINE_FIXED_SUBSTEP;
112116 _sentFrame = simulationFrame;
113117 bool isActive = _body->isActive();
@@ -164,13 +168,6 @@ bool ObjectMotionState::shouldSendUpdate(uint32_t simulationFrame) { · 50 unmodified lines
164168 return (fabsf(glm::dot(actualRotation, _sentRotation)) < MIN_ROTATION_DOT);
165169 }
166170
167−void ObjectMotionState::removeKinematicController() {
168− if (_kinematicController) {
169− delete _kinematicController;
170− _kinematicController = NULL;
171− }
172−}
173−
174171 void ObjectMotionState::setRigidBody(btRigidBody* body) {
175172 // give the body a (void*) back-pointer to this ObjectMotionState
176173 if (_body != body) {
@@ -183,3 +180,8 @@ void ObjectMotionState::setRigidBody(btRigidBody* body) { · 6 unmodified lines
183180 }
184181 }
185182 }
183+
184+void ObjectMotionState::setKinematic(bool kinematic, uint32_t substep) {
185+ _isKinematic = kinematic;
186+ _lastKinematicSubstep = substep;
187+}

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