|
|
|
@ -286,8 +286,9 @@ namespace MWWorld
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
OEngine::Physic::ActorTracer tracer;
|
|
|
|
|
bool wasOnGround = false;
|
|
|
|
|
bool isOnGround = false;
|
|
|
|
|
bool isOnGround = physicActor->getOnGround();
|
|
|
|
|
if (movement.z > 0.f)
|
|
|
|
|
isOnGround = false;
|
|
|
|
|
Ogre::Vector3 inertia(0.0f);
|
|
|
|
|
Ogre::Vector3 velocity;
|
|
|
|
|
|
|
|
|
@ -320,23 +321,6 @@ namespace MWWorld
|
|
|
|
|
velocity = newVelocity;
|
|
|
|
|
}
|
|
|
|
|
inertia = velocity; // NOTE: velocity is for z axis only in this code block
|
|
|
|
|
|
|
|
|
|
if(!(movement.z > 0.0f)) // falling or moving horizontally (or stationary?) check if we're on ground now
|
|
|
|
|
{
|
|
|
|
|
wasOnGround = physicActor->getOnGround(); // store current state
|
|
|
|
|
tracer.doTrace(colobj, position, position - Ogre::Vector3(0,0,2), engine); // check if down 2 possible
|
|
|
|
|
if(tracer.mFraction < 1.0f && getSlope(tracer.mPlaneNormal) <= sMaxSlope)
|
|
|
|
|
{
|
|
|
|
|
const btCollisionObject* standingOn = tracer.mHitObject;
|
|
|
|
|
if (const OEngine::Physic::RigidBody* body = dynamic_cast<const OEngine::Physic::RigidBody*>(standingOn))
|
|
|
|
|
{
|
|
|
|
|
standingCollisionTracker[ptr.getRefData().getHandle()] = body->mName;
|
|
|
|
|
}
|
|
|
|
|
isOnGround = true;
|
|
|
|
|
// if we're on the ground, don't try to fall any more
|
|
|
|
|
velocity.z = std::max(0.0f, velocity.z);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ptr.getClass().getMovementSettings(ptr).mPosition[2] = 0;
|
|
|
|
|
|
|
|
|
@ -439,12 +423,22 @@ namespace MWWorld
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(isOnGround || wasOnGround)
|
|
|
|
|
if (!(inertia.z > 0.f) && !(newPosition.z < waterlevel || isFlying))
|
|
|
|
|
{
|
|
|
|
|
tracer.doTrace(colobj, newPosition, newPosition - Ogre::Vector3(0,0,sStepSize+2.0f), engine);
|
|
|
|
|
Ogre::Vector3 from = newPosition;
|
|
|
|
|
Ogre::Vector3 to = newPosition - (isOnGround ?
|
|
|
|
|
Ogre::Vector3(0,0,sStepSize+2.f) : Ogre::Vector3(0,0,2.f));
|
|
|
|
|
tracer.doTrace(colobj, from, to, engine);
|
|
|
|
|
if(tracer.mFraction < 1.0f && getSlope(tracer.mPlaneNormal) <= sMaxSlope)
|
|
|
|
|
{
|
|
|
|
|
const btCollisionObject* standingOn = tracer.mHitObject;
|
|
|
|
|
if (const OEngine::Physic::RigidBody* body = dynamic_cast<const OEngine::Physic::RigidBody*>(standingOn))
|
|
|
|
|
{
|
|
|
|
|
standingCollisionTracker[ptr.getRefData().getHandle()] = body->mName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newPosition.z = tracer.mEndPos.z + 1.0f;
|
|
|
|
|
|
|
|
|
|
isOnGround = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|