mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
Merge pull request #12894 from sethalves/fix-tractor-action-crazy
fix bug that caused tractor action to go crazy
This commit is contained in:
commit
87f60e1e25
1 changed files with 9 additions and 4 deletions
|
@ -47,19 +47,22 @@ ObjectActionTractor::~ObjectActionTractor() {
|
|||
bool ObjectActionTractor::getTarget(float deltaTimeStep, glm::quat& rotation, glm::vec3& position,
|
||||
glm::vec3& linearVelocity, glm::vec3& angularVelocity,
|
||||
float& linearTimeScale, float& angularTimeScale) {
|
||||
SpatiallyNestablePointer other = getOther();
|
||||
bool success { true };
|
||||
EntityItemPointer other = std::dynamic_pointer_cast<EntityItem>(getOther());
|
||||
withReadLock([&]{
|
||||
linearTimeScale = _linearTimeScale;
|
||||
angularTimeScale = _angularTimeScale;
|
||||
|
||||
if (!_otherID.isNull()) {
|
||||
if (other) {
|
||||
if (other && other->isReadyToComputeShape()) {
|
||||
rotation = _desiredRotationalTarget * other->getWorldOrientation();
|
||||
position = other->getWorldOrientation() * _desiredPositionalTarget + other->getWorldPosition();
|
||||
} else {
|
||||
// we should have an "other" but can't find it, so disable the tractor.
|
||||
// we should have an "other" but can't find it, or its collision shape isn't loaded,
|
||||
// so disable the tractor.
|
||||
linearTimeScale = FLT_MAX;
|
||||
angularTimeScale = FLT_MAX;
|
||||
success = false;
|
||||
}
|
||||
} else {
|
||||
rotation = _desiredRotationalTarget;
|
||||
|
@ -68,7 +71,7 @@ bool ObjectActionTractor::getTarget(float deltaTimeStep, glm::quat& rotation, gl
|
|||
linearVelocity = glm::vec3();
|
||||
angularVelocity = glm::vec3();
|
||||
});
|
||||
return true;
|
||||
return success;
|
||||
}
|
||||
|
||||
bool ObjectActionTractor::prepareForTractorUpdate(btScalar deltaTimeStep) {
|
||||
|
@ -122,6 +125,8 @@ bool ObjectActionTractor::prepareForTractorUpdate(btScalar deltaTimeStep) {
|
|||
linearTractorCount++;
|
||||
position += positionForAction;
|
||||
}
|
||||
} else {
|
||||
return false; // we don't have both entities loaded, so don't do anything
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue