Actor collision object placement fix

c++11
scrawl 10 years ago
parent 65f0195c71
commit 2bc95df265

@ -87,7 +87,7 @@ void Actor::updatePosition()
osg::Vec3f position = mPtr.getRefData().getPosition().asVec3();
btTransform tr = mCollisionObject->getWorldTransform();
osg::Vec3f scaledTranslation = osg::componentMultiply(mMeshTranslation, mScale);
osg::Vec3f scaledTranslation = mRotation * osg::componentMultiply(mMeshTranslation, mScale);
osg::Vec3f newPosition = scaledTranslation + position;
tr.setOrigin(toBullet(newPosition));
@ -97,8 +97,11 @@ void Actor::updatePosition()
void Actor::updateRotation ()
{
btTransform tr = mCollisionObject->getWorldTransform();
tr.setRotation(toBullet(mPtr.getRefData().getBaseNode()->getAttitude()));
mRotation = mPtr.getRefData().getBaseNode()->getAttitude();
tr.setRotation(toBullet(mRotation));
mCollisionObject->setWorldTransform(tr);
updatePosition();
}
void Actor::updateScale()

@ -6,6 +6,7 @@
#include "../mwworld/ptr.hpp"
#include <osg/Vec3f>
#include <osg/Quat>
#include <osg/ref_ptr>
class btDynamicsWorld;
@ -109,6 +110,7 @@ namespace MWPhysics
osg::Vec3f mMeshTranslation;
osg::Vec3f mHalfExtents;
osg::Quat mRotation;
osg::Vec3f mScale;
osg::Vec3f mPosition;

Loading…
Cancel
Save