From e58de5e410549e9da9cd30989ba0d8f03a019224 Mon Sep 17 00:00:00 2001 From: logzero Date: Sat, 24 Dec 2016 12:29:09 +0100 Subject: [PATCH] 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. --- apps/openmw/mwphysics/physicssystem.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 494ff681cd..ab7117a106 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -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.