Use maximum step size of 62 units for stepping down (Fixes #1809)

This commit is contained in:
scrawl 2014-12-21 16:56:14 +01:00
parent edc128572d
commit e5de253169

View file

@ -93,7 +93,9 @@ namespace MWWorld
{ {
static const float sMaxSlope = 49.0f; static const float sMaxSlope = 49.0f;
static const float sStepSize = 32.0f; static const float sStepSizeUp = 34.0f;
static const float sStepSizeDown = 62.0f;
// Arbitrary number. To prevent infinite loops. They shouldn't happen but it's good to be prepared. // Arbitrary number. To prevent infinite loops. They shouldn't happen but it's good to be prepared.
static const int sMaxIterations = 8; static const int sMaxIterations = 8;
@ -155,7 +157,7 @@ namespace MWWorld
*/ */
OEngine::Physic::ActorTracer tracer, stepper; OEngine::Physic::ActorTracer tracer, stepper;
stepper.doTrace(colobj, position, position+Ogre::Vector3(0.0f,0.0f,sStepSize), engine); stepper.doTrace(colobj, position, position+Ogre::Vector3(0.0f,0.0f,sStepSizeUp), engine);
if(stepper.mFraction < std::numeric_limits<float>::epsilon()) if(stepper.mFraction < std::numeric_limits<float>::epsilon())
return false; // didn't even move the smallest representable amount return false; // didn't even move the smallest representable amount
// (TODO: shouldn't this be larger? Why bother with such a small amount?) // (TODO: shouldn't this be larger? Why bother with such a small amount?)
@ -178,7 +180,7 @@ namespace MWWorld
return false; // didn't even move the smallest representable amount return false; // didn't even move the smallest representable amount
/* /*
* Try moving back down sStepSize using stepper. * Try moving back down sStepSizeDown using stepper.
* NOTE: if there is an obstacle below (e.g. stairs), we'll be "stepping up". * NOTE: if there is an obstacle below (e.g. stairs), we'll be "stepping up".
* Below diagram is the case where we "stepped over" an obstacle in front. * Below diagram is the case where we "stepped over" an obstacle in front.
* *
@ -192,7 +194,7 @@ namespace MWWorld
* +--+ +--+ * +--+ +--+
* ============================================== * ==============================================
*/ */
stepper.doTrace(colobj, tracer.mEndPos, tracer.mEndPos-Ogre::Vector3(0.0f,0.0f,sStepSize), engine); stepper.doTrace(colobj, tracer.mEndPos, tracer.mEndPos-Ogre::Vector3(0.0f,0.0f,sStepSizeDown), engine);
if(stepper.mFraction < 1.0f && getSlope(stepper.mPlaneNormal) <= sMaxSlope) if(stepper.mFraction < 1.0f && getSlope(stepper.mPlaneNormal) <= sMaxSlope)
{ {
// don't allow stepping up other actors // don't allow stepping up other actors
@ -453,7 +455,7 @@ namespace MWWorld
{ {
Ogre::Vector3 from = newPosition; Ogre::Vector3 from = newPosition;
Ogre::Vector3 to = newPosition - (physicActor->getOnGround() ? Ogre::Vector3 to = newPosition - (physicActor->getOnGround() ?
Ogre::Vector3(0,0,sStepSize+2.f) : Ogre::Vector3(0,0,2.f)); Ogre::Vector3(0,0,sStepSizeDown+2.f) : Ogre::Vector3(0,0,2.f));
tracer.doTrace(colobj, from, to, engine); tracer.doTrace(colobj, from, to, engine);
if(tracer.mFraction < 1.0f && getSlope(tracer.mPlaneNormal) <= sMaxSlope if(tracer.mFraction < 1.0f && getSlope(tracer.mPlaneNormal) <= sMaxSlope
&& tracer.mHitObject->getBroadphaseHandle()->m_collisionFilterGroup != OEngine::Physic::CollisionType_Actor) && tracer.mHitObject->getBroadphaseHandle()->m_collisionFilterGroup != OEngine::Physic::CollisionType_Actor)