mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-22 08:41:34 +00:00
Fix physics to not trigger Bullet assert in Debug
When physics attempts to move by a very small amount, precision losses caused Bullet to trigger an assert in debug from normalizing a zero length vector.
This commit is contained in:
parent
0668019c86
commit
51c45796b1
1 changed files with 22 additions and 6 deletions
|
@ -299,6 +299,8 @@ namespace MWWorld
|
||||||
continue; // velocity updated, calculate nextpos again
|
continue; // velocity updated, calculate nextpos again
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!newPosition.positionCloses(nextpos, 0.00000001))
|
||||||
|
{
|
||||||
// trace to where character would go if there were no obstructions
|
// trace to where character would go if there were no obstructions
|
||||||
tracer.doTrace(colobj, newPosition, nextpos, engine);
|
tracer.doTrace(colobj, newPosition, nextpos, engine);
|
||||||
|
|
||||||
|
@ -309,6 +311,20 @@ namespace MWWorld
|
||||||
remainingTime *= (1.0f-tracer.mFraction); // FIXME: remainingTime is no longer used so don't set it?
|
remainingTime *= (1.0f-tracer.mFraction); // FIXME: remainingTime is no longer used so don't set it?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The current position and next position are nearly the same, so just exit.
|
||||||
|
// Note: Bullet can trigger an assert in debug modes if the positions
|
||||||
|
// are the same, since that causes it to attempt to normalize a zero
|
||||||
|
// length vector (which can also happen with nearly identical vectors, since
|
||||||
|
// precision can be lost due to any math Bullet does internally). Since we
|
||||||
|
// aren't performing any collision detection, we want to reject the next
|
||||||
|
// position, so that we don't slowly move inside another object.
|
||||||
|
remainingTime *= (1.0f-tracer.mFraction); // FIXME: remainingTime is no longer used so don't set it?
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Ogre::Vector3 oldPosition = newPosition;
|
Ogre::Vector3 oldPosition = newPosition;
|
||||||
// We hit something. Try to step up onto it. (NOTE: stepMove does not allow stepping over)
|
// We hit something. Try to step up onto it. (NOTE: stepMove does not allow stepping over)
|
||||||
|
|
Loading…
Reference in a new issue