From d8051095d669c552123f4662ea501c9cd021e6bd Mon Sep 17 00:00:00 2001 From: gugus Date: Tue, 29 May 2012 10:36:12 +0200 Subject: [PATCH] rotation are updated in the physis system --- apps/openmw/mwworld/physicssystem.cpp | 13 +++++++++++-- apps/openmw/mwworld/world.cpp | 8 ++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 808c712a0..c4e34a540 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -288,17 +288,26 @@ namespace MWWorld void PhysicsSystem::rotateObject (const std::string& handle, const Ogre::Quaternion& rotation) { - if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle)) + if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle)) { // TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow // start positions others than 0, 0, 0 act->setRotation(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w)); } + if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle)) + { + body->setWorldTransform(btTransform(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w),body->getWorldTransform().getOrigin())); + } } void PhysicsSystem::scaleObject (const std::string& handle, float scale) { - + if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle)) + { + // TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow + // start positions others than 0, 0, 0 + //body->setWorldTransform(btTransform().se + } } bool PhysicsSystem::toggleCollisionMode() diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 116710a1e..69da98096 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -625,9 +625,6 @@ namespace MWWorld { MWWorld::Class::get(ptr).adjustRotation(ptr,x,y,z); - /*ptr.getRefData().getPosition().rot[0] = x; - ptr.getRefData().getPosition().rot[0] = y; - ptr.getRefData().getPosition().rot[0] = z;*/ if(WorldAxis) { ptr.getRefData().getBaseNode()->rotate(Ogre::Vector3::UNIT_X,Ogre::Degree(x)); @@ -652,11 +649,13 @@ namespace MWWorld ptr.getRefData().getPosition().rot[0] = rx.valueRadians(); ptr.getRefData().getPosition().rot[0] = ry.valueRadians(); ptr.getRefData().getPosition().rot[0] = rz.valueRadians(); + + mPhysics->rotateObject(Class::get(ptr).getId(ptr),ptr.getRefData().getBaseNode()->getOrientation()); //ptr.getRefData().getBaseNode()->rotate(ptr.getRefData().getBaseNode()->get //mPhysics->scaleObject( Class::get(ptr).getId(ptr), scale ); } - void setObjectRotation (Ptr ptr,float x,float y,float z) + void World::setObjectRotation (Ptr ptr,float x,float y,float z) { MWWorld::Class::get(ptr).adjustRotation(ptr,x,y,z); @@ -668,6 +667,7 @@ namespace MWWorld Ogre::Quaternion roty(Ogre::Degree(y),Ogre::Vector3::UNIT_Y); Ogre::Quaternion rotz(Ogre::Degree(z),Ogre::Vector3::UNIT_Z); ptr.getRefData().getBaseNode()->setOrientation(rotx*roty*rotz); + mPhysics->rotateObject(Class::get(ptr).getId(ptr),ptr.getRefData().getBaseNode()->getOrientation()); } void World::indexToPosition (int cellX, int cellY, float &x, float &y, bool centre) const