mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 01:31:37 +02:00
add check to avoid divide by zero
This commit is contained in:
parent
f00a3cafb6
commit
0f643b7d66
1 changed files with 27 additions and 25 deletions
|
@ -275,6 +275,7 @@ void CharacterController::playerStep(btCollisionWorld* collisionWorld, btScalar
|
|||
// to move over the _stepPoint at target speed
|
||||
float horizontalDistance = (_stepPoint - _stepPoint.dot(_currentUp) * _currentUp).length();
|
||||
float horizontalTargetSpeed = (_targetVelocity - _targetVelocity.dot(_currentUp) * _currentUp).length();
|
||||
if (horizontalTargetSpeed > FLT_EPSILON) {
|
||||
float timeToStep = horizontalDistance / horizontalTargetSpeed;
|
||||
float stepUpSpeed = _stepHeight / timeToStep;
|
||||
|
||||
|
@ -306,6 +307,7 @@ void CharacterController::playerStep(btCollisionWorld* collisionWorld, btScalar
|
|||
velocity -= vDotUp * _currentUp;
|
||||
}
|
||||
}
|
||||
}
|
||||
_rigidBody->setLinearVelocity(velocity + _parentVelocity);
|
||||
_ghost.setWorldTransform(_rigidBody->getWorldTransform());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue