mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +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
1 changed files with 6 additions and 5 deletions
|
@ -402,17 +402,18 @@ namespace MWPhysics
|
||||||
reflectdir.normalize();
|
reflectdir.normalize();
|
||||||
|
|
||||||
osg::Vec3f newVelocity = slide(reflectdir, tracer.mPlaneNormal)*movelen;
|
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)
|
if ((newVelocity-velocity).length2() < 0.01)
|
||||||
break;
|
break;
|
||||||
if ((velocity * origVelocity) <= 0.f)
|
if ((velocity * origVelocity) <= 0.f)
|
||||||
break; // ^ dot product
|
break; // ^ dot product
|
||||||
|
|
||||||
velocity = newVelocity;
|
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 a new issue