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.
actorid
Chris Robinson 12 years ago
parent 1399a06c76
commit 89fabdb3a9

@ -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)

@ -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();

@ -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

Loading…
Cancel
Save