mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-15 21:09:40 +00:00
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)
|
||||
{
|
||||
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?
|
||||
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);
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace MWMechanics
|
|||
MovementSolver::MovementSolver(const MWWorld::Ptr &ptr)
|
||||
: mPtr(ptr)
|
||||
, 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)
|
||||
{
|
||||
mPhysicActor = mEngine->getCharacter(mPtr.getRefData().getHandle());
|
||||
|
||||
/* Anything to collide with? */
|
||||
if(1 || !mPhysicActor || !mPhysicActor->getCollisionMode())
|
||||
return position+movement;
|
||||
mPhysicActor = mEngine->getCharacter(mPtr.getRefData().getHandle());
|
||||
if(!mPhysicActor || !mPhysicActor->getCollisionMode())
|
||||
return position + movement;
|
||||
|
||||
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.
|
||||
|
|
Loading…
Reference in a new issue