1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-01 20:15:33 +00:00

Use separate inputs for swimming and flying

This commit is contained in:
Chris Robinson 2013-08-21 00:55:26 -07:00
parent a546ace94d
commit 9f09bb6f6f

View file

@ -107,7 +107,7 @@ namespace MWWorld
} }
static Ogre::Vector3 move(const MWWorld::Ptr &ptr, const Ogre::Vector3 &movement, float time, static Ogre::Vector3 move(const MWWorld::Ptr &ptr, const Ogre::Vector3 &movement, float time,
bool gravity, OEngine::Physic::PhysicEngine *engine) bool isSwimming, bool isFlying, OEngine::Physic::PhysicEngine *engine)
{ {
const ESM::Position &refpos = ptr.getRefData().getPosition(); const ESM::Position &refpos = ptr.getRefData().getPosition();
Ogre::Vector3 position(refpos.pos); Ogre::Vector3 position(refpos.pos);
@ -132,7 +132,7 @@ namespace MWWorld
bool isOnGround = false; bool isOnGround = false;
Ogre::Vector3 inertia(0.0f); Ogre::Vector3 inertia(0.0f);
Ogre::Vector3 velocity; Ogre::Vector3 velocity;
if(!gravity) if(isSwimming || isFlying)
{ {
velocity = (Ogre::Quaternion(Ogre::Radian( -refpos.rot[2]), Ogre::Vector3::UNIT_Z)* velocity = (Ogre::Quaternion(Ogre::Radian( -refpos.rot[2]), Ogre::Vector3::UNIT_Z)*
Ogre::Quaternion(Ogre::Radian( -refpos.rot[1]), Ogre::Vector3::UNIT_Y)* Ogre::Quaternion(Ogre::Radian( -refpos.rot[1]), Ogre::Vector3::UNIT_Y)*
@ -181,7 +181,7 @@ namespace MWWorld
// We hit something. Try to step up onto it. // We hit something. Try to step up onto it.
if(stepMove(colobj, newPosition, velocity, remainingTime, engine)) if(stepMove(colobj, newPosition, velocity, remainingTime, engine))
isOnGround = gravity; // Only on the ground if there's gravity isOnGround = !(isSwimming || 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
@ -192,7 +192,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(gravity) if(!(isSwimming || isFlying))
velocity.z = std::min(velocity.z, 0.0f); velocity.z = std::min(velocity.z, 0.0f);
} }
} }
@ -209,7 +209,7 @@ namespace MWWorld
isOnGround = false; isOnGround = false;
} }
if(isOnGround || !gravity) if(isOnGround || isSwimming || isFlying)
physicActor->setInertialForce(Ogre::Vector3(0.0f)); physicActor->setInertialForce(Ogre::Vector3(0.0f));
else else
{ {
@ -569,8 +569,8 @@ namespace MWWorld
{ {
Ogre::Vector3 newpos; Ogre::Vector3 newpos;
newpos = MovementSolver::move(iter->first, iter->second, mTimeAccum, newpos = MovementSolver::move(iter->first, iter->second, mTimeAccum,
!world->isSwimming(iter->first) && world->isSwimming(iter->first),
!world->isFlying(iter->first), mEngine); world->isFlying(iter->first), mEngine);
mMovementResults.push_back(std::make_pair(iter->first, newpos)); mMovementResults.push_back(std::make_pair(iter->first, newpos));
} }