mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 19:14:59 +02:00
Merge pull request #13425 from sabrina-shanman/crash-strafe
Fix crash when walking sideways
This commit is contained in:
commit
24bae8eddc
1 changed files with 8 additions and 5 deletions
|
@ -108,12 +108,15 @@ bool MyCharacterController::testRayShotgun(const glm::vec3& position, const glm:
|
|||
btScalar lengthAxis = axis.length();
|
||||
if (lengthAxis > FLT_EPSILON) {
|
||||
// we're walking sideways
|
||||
btScalar angle = acosf(lengthAxis / adjustedDirection.length());
|
||||
if (rayDirection.dot(forward) < 0.0f) {
|
||||
angle = PI - angle;
|
||||
btScalar cosAngle = lengthAxis / adjustedDirection.length();
|
||||
if (cosAngle < 1.0f) {
|
||||
btScalar angle = acosf(cosAngle);
|
||||
if (rayDirection.dot(forward) < 0.0f) {
|
||||
angle = PI - angle;
|
||||
}
|
||||
axis /= lengthAxis;
|
||||
rotation = btMatrix3x3(btQuaternion(axis, angle)) * rotation;
|
||||
}
|
||||
axis /= lengthAxis;
|
||||
rotation = btMatrix3x3(btQuaternion(axis, angle)) * rotation;
|
||||
} else if (rayDirection.dot(forward) < 0.0f) {
|
||||
// we're walking backwards
|
||||
rotation = btMatrix3x3(btQuaternion(_currentUp, PI)) * rotation;
|
||||
|
|
Loading…
Reference in a new issue