1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 21:42:13 +00:00

Update the PhysicActor's RigidBody when moving

This works, but is less than ideal. As it is now, the rigid body gets updated
twice as the position and rotation are set separately. They should instead be
updated together.
This commit is contained in:
Chris Robinson 2013-02-19 04:18:15 -08:00
parent 1399a06c76
commit 89fabdb3a9
3 changed files with 13 additions and 0 deletions

View File

@ -414,6 +414,10 @@ namespace MWWorld
mEngine->boxAdjustExternal(handleToMesh[handle], body, node->getScale().x, position, node->getOrientation());
}
}
else if(OEngine::Physic::PhysicActor *physact = mEngine->getCharacter(handle))
{
physact->setPosition(position);
}
}
void PhysicsSystem::rotateObject (const Ptr& ptr)

View File

@ -55,6 +55,12 @@ namespace Physic
}
void PhysicActor::setPosition(const Ogre::Vector3 &pos)
{
if(pos != getPosition())
mEngine->adjustRigidBody(mBody, pos, getRotation(), mBoxScaledTranslation, mBoxRotation);
}
void PhysicActor::setRotation(const Ogre::Quaternion &quat)
{
if(!quat.equals(getRotation(), Ogre::Radian(0))){
@ -62,6 +68,7 @@ namespace Physic
}
}
Ogre::Vector3 PhysicActor::getPosition()
{
btVector3 vec = mBody->getWorldTransform().getOrigin();

View File

@ -69,6 +69,8 @@ namespace Physic
~PhysicActor();
void setPosition(const Ogre::Vector3 &pos);
/**
* This adjusts the rotation of a PhysicActor
* If we have any problems with this (getting stuck in pmove) we should change it