1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-03 19:49:41 +00:00

Fix extreme frame drop when running into certain corners (Fixes #2023)

This commit is contained in:
scrawl 2015-01-15 00:58:12 +01:00
parent d387c207d1
commit cef72385d4

View file

@ -350,6 +350,8 @@ namespace MWWorld
velocity *= 1.f-(fStromWalkMult * (angle.valueDegrees()/180.f)); velocity *= 1.f-(fStromWalkMult * (angle.valueDegrees()/180.f));
} }
Ogre::Vector3 origVelocity = velocity;
Ogre::Vector3 newPosition = position; Ogre::Vector3 newPosition = position;
/* /*
* A loop to find newPosition using tracer, if successful different from the starting position. * A loop to find newPosition using tracer, if successful different from the starting position.
@ -427,10 +429,18 @@ namespace MWWorld
else else
{ {
// Can't move this way, try to find another spot along the plane // Can't move this way, try to find another spot along the plane
Ogre::Real movelen = velocity.normalise(); Ogre::Vector3 direction = velocity;
Ogre::Real movelen = direction.normalise();
Ogre::Vector3 reflectdir = velocity.reflect(tracer.mPlaneNormal); Ogre::Vector3 reflectdir = velocity.reflect(tracer.mPlaneNormal);
reflectdir.normalise(); reflectdir.normalise();
velocity = slide(reflectdir, tracer.mPlaneNormal)*movelen;
Ogre::Vector3 newVelocity = slide(reflectdir, tracer.mPlaneNormal)*movelen;
if ((newVelocity-velocity).squaredLength() < 0.01)
break;
if (velocity.dotProduct(origVelocity) <= 0.f)
break;
velocity = newVelocity;
// Do not allow sliding upward if there is gravity. Stepping will have taken // Do not allow sliding upward if there is gravity. Stepping will have taken
// care of that. // care of that.