mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 16:19:41 +00:00
Revert to original variable names.
This commit is contained in:
parent
22c544d9d7
commit
f57c11254f
1 changed files with 15 additions and 17 deletions
|
@ -129,21 +129,20 @@ 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 + halfExtents.z; // NOTE: remember to restore before returning
|
position.z += halfExtents.z;
|
||||||
float actorWaterlevel = waterlevel - halfExtents.z * 0.5;
|
waterlevel -= halfExtents.z * 0.5;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A 3/4 submerged example
|
* A 3/4 submerged example
|
||||||
*
|
*
|
||||||
* +---+
|
* +---+
|
||||||
* | |
|
* | |
|
||||||
* | | <- waterlevel
|
* | | <- (original waterlevel)
|
||||||
* | |
|
* | |
|
||||||
* | | <- newPosition <- actorWaterlevel
|
* | | <- position <- waterlevel
|
||||||
* | |
|
* | |
|
||||||
* | |
|
* | |
|
||||||
* | |
|
* | |
|
||||||
* +---+ <- position
|
* +---+ <- (original position)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
OEngine::Physic::ActorTracer tracer;
|
OEngine::Physic::ActorTracer tracer;
|
||||||
|
@ -162,9 +161,7 @@ namespace MWWorld
|
||||||
//<< " above waterline, z pos = "<<std::to_string(position.z ) << std::endl;
|
//<< " above waterline, z pos = "<<std::to_string(position.z ) << std::endl;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// FIXME: Choose one
|
if(position.z < waterlevel || isFlying) // under water by any amount or can fly
|
||||||
//if((position.z < waterlevel) || isFlying) // under water by any amount or can fly
|
|
||||||
if((newPosition.z < actorWaterlevel) || isFlying) // 3/4 under water or can fly
|
|
||||||
{
|
{
|
||||||
// TODO: Shouldn't water have higher drag in calculating velocity?
|
// TODO: Shouldn't water have higher drag in calculating velocity?
|
||||||
velocity = (Ogre::Quaternion(Ogre::Radian(refpos.rot[2]), Ogre::Vector3::NEGATIVE_UNIT_Z)*
|
velocity = (Ogre::Quaternion(Ogre::Radian(refpos.rot[2]), Ogre::Vector3::NEGATIVE_UNIT_Z)*
|
||||||
|
@ -172,7 +169,7 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
velocity = Ogre::Quaternion(Ogre::Radian(refpos.rot[2]), Ogre::Vector3::NEGATIVE_UNIT_Z)* movement;
|
velocity = Ogre::Quaternion(Ogre::Radian(refpos.rot[2]), Ogre::Vector3::NEGATIVE_UNIT_Z) * movement;
|
||||||
// not in water nor can fly, so need to deal with gravity
|
// not in water nor can fly, so need to deal with gravity
|
||||||
if(!physicActor->getOnGround())
|
if(!physicActor->getOnGround())
|
||||||
{
|
{
|
||||||
|
@ -185,7 +182,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, newPosition, newPosition - Ogre::Vector3(0,0,2), engine);
|
tracer.doTrace(colobj, position, position - 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;
|
||||||
}
|
}
|
||||||
|
@ -197,6 +194,7 @@ namespace MWWorld
|
||||||
velocity.z = std::max(0.0f, velocity.z); // NOTE: two different velocity assignments above
|
velocity.z = std::max(0.0f, velocity.z); // NOTE: two different velocity assignments above
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ogre::Vector3 newPosition = position;
|
||||||
/*
|
/*
|
||||||
* A loop to find newPosition using tracer, if successful different from the starting position.
|
* A loop to find newPosition using tracer, if successful different from the starting position.
|
||||||
* nextpos is the local variable used to find potential newPosition, using velocity and remainingTime
|
* nextpos is the local variable used to find potential newPosition, using velocity and remainingTime
|
||||||
|
@ -210,13 +208,13 @@ 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 < 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
|
||||||
!isBipedal && // not bipedal (assume bipedals can walk)
|
!isBipedal && // not bipedal (assume bipedals can walk)
|
||||||
!isNpc && // FIXME: shouldn't really need this
|
!isNpc && // FIXME: shouldn't really need this
|
||||||
((nextpos.z + halfExtents.z) > waterlevel)) // but about to go above water
|
nextpos.z > waterlevel && // but about to go above water
|
||||||
|
newPosition.z <= waterlevel)
|
||||||
{
|
{
|
||||||
const Ogre::Vector3 down(0,0,-1);
|
const Ogre::Vector3 down(0,0,-1);
|
||||||
Ogre::Real movelen = velocity.normalise();
|
Ogre::Real movelen = velocity.normalise();
|
||||||
|
@ -241,7 +239,7 @@ namespace MWWorld
|
||||||
// We hit something. Try to step up onto it.
|
// We hit something. Try to step up onto it.
|
||||||
// NOTE: May need to stop slaughterfish step out of the water.
|
// NOTE: May need to stop slaughterfish step out of the water.
|
||||||
if((canWalk || isBipedal || isNpc) && stepMove(colobj, newPosition, velocity, remainingTime, engine))
|
if((canWalk || isBipedal || isNpc) && stepMove(colobj, newPosition, velocity, remainingTime, engine))
|
||||||
isOnGround = !((newPosition.z < actorWaterlevel) || isFlying); // Only on the ground if there's gravity
|
isOnGround = !(newPosition.z < waterlevel || isFlying); // Only on the ground if there's gravity
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Can't move this way, try to find another spot along the plane
|
// Can't move this way, try to find another spot along the plane
|
||||||
|
@ -252,7 +250,7 @@ namespace MWWorld
|
||||||
|
|
||||||
// Do not allow sliding upward if there is gravity. Stepping will have taken
|
// Do not allow sliding upward if there is gravity. Stepping will have taken
|
||||||
// care of that.
|
// care of that.
|
||||||
if(!(newPosition.z < actorWaterlevel) || isFlying)
|
if(!(newPosition.z < waterlevel || isFlying))
|
||||||
velocity.z = std::min(velocity.z, 0.0f);
|
velocity.z = std::min(velocity.z, 0.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,7 +267,7 @@ namespace MWWorld
|
||||||
isOnGround = false;
|
isOnGround = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isOnGround || (newPosition.z < actorWaterlevel) || isFlying)
|
if(isOnGround || newPosition.z < waterlevel || isFlying)
|
||||||
physicActor->setInertialForce(Ogre::Vector3(0.0f));
|
physicActor->setInertialForce(Ogre::Vector3(0.0f));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue