mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-16 16:10:58 +00:00
Apply sliding upward check to new velocity.
This helps to capture the case where new velocity only differs in the z component (normal pointing up). TODO: Find a better way to handle the normal pointing up case.
This commit is contained in:
parent
0b08802910
commit
4f6e65e481
@ -402,17 +402,18 @@ namespace MWPhysics
|
||||
reflectdir.normalize();
|
||||
|
||||
osg::Vec3f newVelocity = slide(reflectdir, tracer.mPlaneNormal)*movelen;
|
||||
|
||||
// Do not allow sliding upward if there is gravity.
|
||||
// Stepping will have taken care of that.
|
||||
if(!(newPosition.z() < swimlevel || isFlying))
|
||||
newVelocity.z() = std::min(newVelocity.z(), 0.0f);
|
||||
|
||||
if ((newVelocity-velocity).length2() < 0.01)
|
||||
break;
|
||||
if ((velocity * origVelocity) <= 0.f)
|
||||
break; // ^ dot product
|
||||
|
||||
velocity = newVelocity;
|
||||
|
||||
// Do not allow sliding upward if there is gravity. Stepping will have taken
|
||||
// care of that.
|
||||
if(!(newPosition.z() < swimlevel || isFlying))
|
||||
velocity.z() = std::min(velocity.z(), 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user