Remove superfluous velocity reflection in movement solver.

The slide projection negates the reflection effect.
Just to be sure I've compared the resulting vectors
with and without reflection at runtime.
pull/124/head
logzero 8 years ago
parent 50fd913058
commit e58de5e410

@ -366,10 +366,7 @@ namespace MWPhysics
newPosition.z() <= swimlevel)
{
const osg::Vec3f down(0,0,-1);
float movelen = velocity.normalize();
osg::Vec3f reflectdir = reflect(velocity, down);
reflectdir.normalize();
velocity = slide(reflectdir, down)*movelen;
velocity = slide(velocity, down);
// NOTE: remainingTime is unchanged before the loop continues
continue; // velocity updated, calculate nextpos again
}
@ -413,12 +410,7 @@ namespace MWPhysics
else
{
// Can't move this way, try to find another spot along the plane
osg::Vec3f direction = velocity;
float movelen = direction.normalize();
osg::Vec3f reflectdir = reflect(velocity, tracer.mPlaneNormal);
reflectdir.normalize();
osg::Vec3f newVelocity = slide(reflectdir, tracer.mPlaneNormal)*movelen;
osg::Vec3f newVelocity = slide(velocity, tracer.mPlaneNormal);
// Do not allow sliding upward if there is gravity.
// Stepping will have taken care of that.

Loading…
Cancel
Save