From 2bc95df265b4e75de057a0769b919bb5f15dd678 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 12 May 2015 16:49:21 +0200 Subject: [PATCH] Actor collision object placement fix --- apps/openmw/mwphysics/actor.cpp | 7 +++++-- apps/openmw/mwphysics/actor.hpp | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwphysics/actor.cpp b/apps/openmw/mwphysics/actor.cpp index edad7e196..1a712461e 100644 --- a/apps/openmw/mwphysics/actor.cpp +++ b/apps/openmw/mwphysics/actor.cpp @@ -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() diff --git a/apps/openmw/mwphysics/actor.hpp b/apps/openmw/mwphysics/actor.hpp index 1f5838543..513985c94 100644 --- a/apps/openmw/mwphysics/actor.hpp +++ b/apps/openmw/mwphysics/actor.hpp @@ -6,6 +6,7 @@ #include "../mwworld/ptr.hpp" #include +#include #include class btDynamicsWorld; @@ -109,6 +110,7 @@ namespace MWPhysics osg::Vec3f mMeshTranslation; osg::Vec3f mHalfExtents; + osg::Quat mRotation; osg::Vec3f mScale; osg::Vec3f mPosition;