Showing the changes to libraries/physics/src/ObjectActionSpring.cpp (1 of 8 files). Show all
Unified · Split
| @@ -25,13 +25,23 @@ ObjectActionSpring::~ObjectActionSpring() { · 24 unmodified lines | ||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | void ObjectActionSpring::updateActionWorker(btScalar deltaTimeStep) { |
| 28 | + if (!tryLockForRead()) { | |
| 29 | + // don't risk hanging the thread running the physics simulation | |
| 30 | + qDebug() << "ObjectActionSpring::updateActionWorker lock failed"; | |
| 31 | + return; | |
| 32 | + } | |
| 33 | + | |
| 28 | 34 | void* physicsInfo = _ownerEntity->getPhysicsInfo(); |
| 29 | 35 | if (!physicsInfo) { |
| 36 | + unlock(); | |
| 37 | + qDebug() << "ObjectActionSpring::updateActionWorker no physicsInfo"; | |
| 30 | 38 | return; |
| 31 | 39 | } |
| 32 | 40 | ObjectMotionState* motionState = static_cast<ObjectMotionState*>(physicsInfo); |
| 33 | 41 | btRigidBody* rigidBody = motionState->getRigidBody(); |
| 34 | 42 | if (!rigidBody) { |
| 43 | + unlock(); | |
| 44 | + qDebug() << "ObjectActionSpring::updateActionWorker no rigidBody"; | |
| 35 | 45 | return; |
| 36 | 46 | } |
| 37 | 47 | |
| @@ -79,6 +89,8 @@ void ObjectActionSpring::updateActionWorker(btScalar deltaTimeStep) { · 41 unmodified lines | ||
| 79 | 89 | rigidBody->setAngularVelocity(glmToBullet(glm::vec3(0.0f))); |
| 80 | 90 | } |
| 81 | 91 | } |
| 92 | + | |
| 93 | + unlock(); | |
| 82 | 94 | } |
| 83 | 95 | |
| 84 | 96 | |