forked from teamnwah/openmw-tes3coop
Rotate movement vector to world space before passing to the movement solver
This commit is contained in:
parent
6b32fa7999
commit
1a5cb8760d
2 changed files with 14 additions and 5 deletions
|
@ -183,7 +183,16 @@ Ogre::Vector3 CharacterController::update(float duration)
|
||||||
|
|
||||||
if(duration > 0.0f)
|
if(duration > 0.0f)
|
||||||
{
|
{
|
||||||
Ogre::Vector3 pos(mPtr.getRefData().getPosition().pos);
|
const ESM::Position &refpos = mPtr.getRefData().getPosition();
|
||||||
|
|
||||||
|
// Rotates first around z, then y, then x
|
||||||
|
movement = (Ogre::Quaternion(Ogre::Radian(-refpos.rot[0]), Ogre::Vector3::UNIT_X)*
|
||||||
|
Ogre::Quaternion(Ogre::Radian(-refpos.rot[1]), Ogre::Vector3::UNIT_Y)*
|
||||||
|
Ogre::Quaternion(Ogre::Radian(-refpos.rot[2]), Ogre::Vector3::UNIT_Z)) *
|
||||||
|
movement;
|
||||||
|
|
||||||
|
Ogre::Vector3 pos(refpos.pos);
|
||||||
|
|
||||||
// FIXME: Get the actual radius for the object. Maybe this should go into mwworld to replace pmove?
|
// FIXME: Get the actual radius for the object. Maybe this should go into mwworld to replace pmove?
|
||||||
Ogre::Vector3 res = mMovementSolver->move(pos, movement, duration, Ogre::Vector3(15,15,30));
|
Ogre::Vector3 res = mMovementSolver->move(pos, movement, duration, Ogre::Vector3(15,15,30));
|
||||||
MWBase::Environment::get().getWorld()->moveObject(mPtr, res.x, res.y, res.z);
|
MWBase::Environment::get().getWorld()->moveObject(mPtr, res.x, res.y, res.z);
|
||||||
|
|
|
@ -9,6 +9,7 @@ namespace MWMechanics
|
||||||
MovementSolver::MovementSolver(const MWWorld::Ptr &ptr)
|
MovementSolver::MovementSolver(const MWWorld::Ptr &ptr)
|
||||||
: mPtr(ptr)
|
: mPtr(ptr)
|
||||||
, mEngine(MWBase::Environment::get().getWorld()->getPhysicEngine())
|
, mEngine(MWBase::Environment::get().getWorld()->getPhysicEngine())
|
||||||
|
, verticalVelocity(0.0f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,11 +72,10 @@ float MovementSolver::getSlope(const Ogre::Vector3 &normal)
|
||||||
|
|
||||||
Ogre::Vector3 MovementSolver::move(const Ogre::Vector3 &position, const Ogre::Vector3 &movement, float time, const Ogre::Vector3 &halfExtents)
|
Ogre::Vector3 MovementSolver::move(const Ogre::Vector3 &position, const Ogre::Vector3 &movement, float time, const Ogre::Vector3 &halfExtents)
|
||||||
{
|
{
|
||||||
mPhysicActor = mEngine->getCharacter(mPtr.getRefData().getHandle());
|
|
||||||
|
|
||||||
/* Anything to collide with? */
|
/* Anything to collide with? */
|
||||||
if(1 || !mPhysicActor || !mPhysicActor->getCollisionMode())
|
mPhysicActor = mEngine->getCharacter(mPtr.getRefData().getHandle());
|
||||||
return position+movement;
|
if(!mPhysicActor || !mPhysicActor->getCollisionMode())
|
||||||
|
return position + movement;
|
||||||
|
|
||||||
traceResults trace; //no initialization needed
|
traceResults trace; //no initialization needed
|
||||||
int iterations=0, maxIterations=50; //arbitrary number. To prevent infinite loops. They shouldn't happen but it's good to be prepared.
|
int iterations=0, maxIterations=50; //arbitrary number. To prevent infinite loops. They shouldn't happen but it's good to be prepared.
|
||||||
|
|
Loading…
Reference in a new issue