1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00

Apparently fall trace needs to be done with the middle of the object.

This commit is contained in:
cc9cii 2014-03-16 08:57:55 +11:00
parent 43757efdc4
commit fdbd564700

View File

@ -129,8 +129,7 @@ namespace MWWorld
/* Anything to collide with? */ /* Anything to collide with? */
btCollisionObject *colobj = physicActor->getCollisionBody(); btCollisionObject *colobj = physicActor->getCollisionBody();
Ogre::Vector3 halfExtents = physicActor->getHalfExtents(); Ogre::Vector3 halfExtents = physicActor->getHalfExtents();
Ogre::Vector3 newPosition = position; // FIXME: not sure if a copy is needed Ogre::Vector3 newPosition = position + halfExtents.z; // NOTE: remember to restore before returning
newPosition.z += halfExtents.z; // NOTE: remember to restore before returning
float actorWaterlevel = waterlevel - halfExtents.z * 0.5; float actorWaterlevel = waterlevel - halfExtents.z * 0.5;
/* /*
@ -186,7 +185,7 @@ namespace MWWorld
{ {
wasOnGround = physicActor->getOnGround(); wasOnGround = physicActor->getOnGround();
// TODO: Find out if there is a significance with the value 2 used here // TODO: Find out if there is a significance with the value 2 used here
tracer.doTrace(colobj, position, position - Ogre::Vector3(0,0,2), engine); tracer.doTrace(colobj, newPosition, newPosition - Ogre::Vector3(0,0,2), engine);
if(tracer.mFraction < 1.0f && getSlope(tracer.mPlaneNormal) <= sMaxSlope) if(tracer.mFraction < 1.0f && getSlope(tracer.mPlaneNormal) <= sMaxSlope)
isOnGround = true; isOnGround = true;
} }
@ -211,6 +210,7 @@ namespace MWWorld
// If not able to fly, walk or bipedal don't allow to move out of water // If not able to fly, walk or bipedal don't allow to move out of water
// FIXME: this if condition may not work for large creatures or situations // FIXME: this if condition may not work for large creatures or situations
// where the creature gets above the waterline for some reason // where the creature gets above the waterline for some reason
// Therefore starting under water is commented out below.
if(//(newPosition.z + halfExtents.z) <= waterlevel && // started fully under water if(//(newPosition.z + halfExtents.z) <= waterlevel && // started fully under water
!isFlying && // can't fly !isFlying && // can't fly
!canWalk && // can't walk !canWalk && // can't walk
@ -269,7 +269,7 @@ namespace MWWorld
isOnGround = false; isOnGround = false;
} }
if(isOnGround || ((newPosition.z) < actorWaterlevel) || isFlying) if(isOnGround || (newPosition.z < actorWaterlevel) || isFlying)
physicActor->setInertialForce(Ogre::Vector3(0.0f)); physicActor->setInertialForce(Ogre::Vector3(0.0f));
else else
{ {