Rotation system fixes

This commit is contained in:
Glorf 2013-04-24 21:42:04 +02:00
parent e3a9f73eb6
commit 53fb17da10
2 changed files with 11 additions and 6 deletions

View file

@ -153,15 +153,15 @@ namespace MWScript
if (axis=="x") if (axis=="x")
{ {
runtime.push(Ogre::Radian(ptr.getRefData().getPosition().rot[0]).valueDegrees()+ptr.getRefData().getLocalRotation().rot[0]); runtime.push(Ogre::Radian(ptr.getCellRef().mPos.rot[0]).valueDegrees()+ptr.getRefData().getLocalRotation().rot[0]);
} }
else if (axis=="y") else if (axis=="y")
{ {
runtime.push(Ogre::Radian(ptr.getRefData().getPosition().rot[1]).valueDegrees()+ptr.getRefData().getLocalRotation().rot[1]); runtime.push(Ogre::Radian(ptr.getCellRef().mPos.rot[1]).valueDegrees()+ptr.getRefData().getLocalRotation().rot[1]);
} }
else if (axis=="z") else if (axis=="z")
{ {
runtime.push(Ogre::Radian(ptr.getRefData().getPosition().rot[2]).valueDegrees()+ptr.getRefData().getLocalRotation().rot[2]); runtime.push(Ogre::Radian(ptr.getCellRef().mPos.rot[2]).valueDegrees()+ptr.getRefData().getLocalRotation().rot[2]);
} }
else else
throw std::runtime_error ("invalid ration axis: " + axis); throw std::runtime_error ("invalid ration axis: " + axis);
@ -563,17 +563,14 @@ namespace MWScript
if (axis == "x") if (axis == "x")
{ {
ptr.getRefData().getLocalRotation().rot[0]+=rotation;
MWBase::Environment::get().getWorld()->localRotateObject(ptr, rotation, Ogre::Vector3::UNIT_X); MWBase::Environment::get().getWorld()->localRotateObject(ptr, rotation, Ogre::Vector3::UNIT_X);
} }
else if (axis == "y") else if (axis == "y")
{ {
ptr.getRefData().getLocalRotation().rot[1]+=rotation;
MWBase::Environment::get().getWorld()->localRotateObject(ptr, rotation, Ogre::Vector3::UNIT_Y); MWBase::Environment::get().getWorld()->localRotateObject(ptr, rotation, Ogre::Vector3::UNIT_Y);
} }
else if (axis == "z") else if (axis == "z")
{ {
ptr.getRefData().getLocalRotation().rot[2]+=rotation;
MWBase::Environment::get().getWorld()->localRotateObject(ptr, rotation, Ogre::Vector3::UNIT_Z); MWBase::Environment::get().getWorld()->localRotateObject(ptr, rotation, Ogre::Vector3::UNIT_Z);
} }

View file

@ -827,6 +827,14 @@ namespace MWWorld
void World::localRotateObject (const Ptr& ptr, float rotation, Ogre::Vector3 axis) void World::localRotateObject (const Ptr& ptr, float rotation, Ogre::Vector3 axis)
{ {
if (ptr.getRefData().getBaseNode() != 0) { if (ptr.getRefData().getBaseNode() != 0) {
if(axis==Ogre::Vector3::UNIT_X)
ptr.getRefData().getLocalRotation().rot[0]+=rotation;
else if(axis==Ogre::Vector3::UNIT_Y)
ptr.getRefData().getLocalRotation().rot[1]+=rotation;
else if(axis==Ogre::Vector3::UNIT_Z)
ptr.getRefData().getLocalRotation().rot[2]+=rotation;
ptr.getRefData().getBaseNode()->rotate(Ogre::Quaternion(Ogre::Radian(Ogre::Degree(-rotation).valueRadians()), axis)); ptr.getRefData().getBaseNode()->rotate(Ogre::Quaternion(Ogre::Radian(Ogre::Degree(-rotation).valueRadians()), axis));
mPhysics->rotateObject(ptr); mPhysics->rotateObject(ptr);
} }