|
|
|
@ -810,33 +810,50 @@ namespace MWWorld
|
|
|
|
|
|
|
|
|
|
void World::rotateObjectImp (const Ptr& ptr, Ogre::Vector3 rot, bool adjust)
|
|
|
|
|
{
|
|
|
|
|
if (mRendering->rotateObject(ptr, rot, adjust))
|
|
|
|
|
const float two_pi = Ogre::Math::TWO_PI;
|
|
|
|
|
const float pi = Ogre::Math::PI;
|
|
|
|
|
|
|
|
|
|
float *objRot = ptr.getRefData().getPosition().rot;
|
|
|
|
|
if(adjust)
|
|
|
|
|
{
|
|
|
|
|
objRot[0] += rot.x;
|
|
|
|
|
objRot[1] += rot.y;
|
|
|
|
|
objRot[2] += rot.z;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// rotate physically iff renderer confirm so
|
|
|
|
|
float *objRot = ptr.getRefData().getPosition().rot;
|
|
|
|
|
objRot[0] = rot.x;
|
|
|
|
|
objRot[1] = rot.y;
|
|
|
|
|
objRot[2] = rot.z;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float fullRotateRad=Ogre::Degree(360).valueRadians();
|
|
|
|
|
if(Class::get(ptr).isActor())
|
|
|
|
|
{
|
|
|
|
|
/* HACK? Actors shouldn't really be rotating around X (or Y), but
|
|
|
|
|
* currently it's done so for rotating the camera, which needs
|
|
|
|
|
* clamping.
|
|
|
|
|
*/
|
|
|
|
|
const float half_pi = Ogre::Math::HALF_PI;
|
|
|
|
|
|
|
|
|
|
if(objRot[0] < -half_pi) objRot[0] = -half_pi;
|
|
|
|
|
else if(objRot[0] > half_pi) objRot[0] = half_pi;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
while(objRot[0] < -pi) objRot[0] += two_pi;
|
|
|
|
|
while(objRot[0] > pi) objRot[0] -= two_pi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while(objRot[0]>=fullRotateRad)
|
|
|
|
|
objRot[0] -= fullRotateRad;
|
|
|
|
|
while(objRot[1]>=fullRotateRad)
|
|
|
|
|
objRot[1] -= fullRotateRad;
|
|
|
|
|
while(objRot[2]>=fullRotateRad)
|
|
|
|
|
objRot[2] -= fullRotateRad;
|
|
|
|
|
|
|
|
|
|
while(objRot[0]<=-fullRotateRad)
|
|
|
|
|
objRot[0] += fullRotateRad;
|
|
|
|
|
while(objRot[1]<=-fullRotateRad)
|
|
|
|
|
objRot[1] += fullRotateRad;
|
|
|
|
|
while(objRot[2]<=-fullRotateRad)
|
|
|
|
|
objRot[2] += fullRotateRad;
|
|
|
|
|
|
|
|
|
|
if (ptr.getRefData().getBaseNode() != 0) {
|
|
|
|
|
mPhysics->rotateObject(ptr);
|
|
|
|
|
}
|
|
|
|
|
while(objRot[1] < -pi) objRot[1] += two_pi;
|
|
|
|
|
while(objRot[1] > pi) objRot[1] -= two_pi;
|
|
|
|
|
|
|
|
|
|
while(objRot[2] < -pi) objRot[2] += two_pi;
|
|
|
|
|
while(objRot[2] > pi) objRot[2] -= two_pi;
|
|
|
|
|
|
|
|
|
|
if(ptr.getRefData().getBaseNode() != 0)
|
|
|
|
|
{
|
|
|
|
|
mRendering->rotateObject(ptr);
|
|
|
|
|
mPhysics->rotateObject(ptr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|