Showing the changes to libraries/physics/src/ObjectActionSpring.cpp (1 of 3 files). Show all
Unified · Split
| @@ -13,6 +13,8 @@ · 12 unmodified lines | ||
| 13 | 13 | |
| 14 | 14 | #include "ObjectActionSpring.h" |
| 15 | 15 | |
| 16 | +const float SPRING_MAX_SPEED = 10.0f; | |
| 17 | + | |
| 16 | 18 | const uint16_t ObjectActionSpring::springVersion = 1; |
| 17 | 19 | |
| 18 | 20 | ObjectActionSpring::ObjectActionSpring(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) : |
| @@ -70,6 +72,11 @@ void ObjectActionSpring::updateActionWorker(btScalar deltaTimeStep) { · 51 unmodified lines | ||
| 70 | 72 | float offsetLength = glm::length(offset); |
| 71 | 73 | float speed = offsetLength / _linearTimeScale; |
| 72 | 74 | |
| 75 | + // cap speed | |
| 76 | + if (speed > SPRING_MAX_SPEED) { | |
| 77 | + speed = SPRING_MAX_SPEED; | |
| 78 | + } | |
| 79 | + | |
| 73 | 80 | if (offsetLength > IGNORE_POSITION_DELTA) { |
| 74 | 81 | glm::vec3 newVelocity = glm::normalize(offset) * speed; |
| 75 | 82 | rigidBody->setLinearVelocity(glmToBullet(newVelocity)); |