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.
pull/124/head
logzero 8 years ago
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…
Cancel
Save