mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 03:50:16 +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();
|
btScalar lengthAxis = axis.length();
|
||||||
if (lengthAxis > FLT_EPSILON) {
|
if (lengthAxis > FLT_EPSILON) {
|
||||||
// we're walking sideways
|
// we're walking sideways
|
||||||
btScalar angle = acosf(lengthAxis / adjustedDirection.length());
|
btScalar cosAngle = lengthAxis / adjustedDirection.length();
|
||||||
if (rayDirection.dot(forward) < 0.0f) {
|
if (cosAngle < 1.0f) {
|
||||||
angle = PI - angle;
|
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) {
|
} else if (rayDirection.dot(forward) < 0.0f) {
|
||||||
// we're walking backwards
|
// we're walking backwards
|
||||||
rotation = btMatrix3x3(btQuaternion(_currentUp, PI)) * rotation;
|
rotation = btMatrix3x3(btQuaternion(_currentUp, PI)) * rotation;
|
||||||
|
|
Loading…
Reference in a new issue