mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Rotations: World::rotateObject takes radians instead of degrees
Cuts down on the amount of redundant degree<->radians conversions in the codebase.
This commit is contained in:
parent
6405049add
commit
666fbba1e0
5 changed files with 21 additions and 25 deletions
|
@ -1816,7 +1816,6 @@ void CharacterController::update(float duration)
|
|||
|
||||
if (!mSkipAnim)
|
||||
{
|
||||
rot *= osg::RadiansToDegrees(1.0f);
|
||||
if(mHitState != CharState_KnockDown && mHitState != CharState_KnockOut)
|
||||
{
|
||||
world->rotateObject(mPtr, rot.x(), rot.y(), rot.z(), true);
|
||||
|
|
|
@ -85,12 +85,12 @@ namespace MWScript
|
|||
|
||||
std::string axis = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
Interpreter::Type_Float angle = runtime[0].mFloat;
|
||||
Interpreter::Type_Float angle = osg::DegreesToRadians(runtime[0].mFloat);
|
||||
runtime.pop();
|
||||
|
||||
float ax = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[0]);
|
||||
float ay = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[1]);
|
||||
float az = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[2]);
|
||||
float ax = ptr.getRefData().getPosition().rot[0];
|
||||
float ay = ptr.getRefData().getPosition().rot[1];
|
||||
float az = ptr.getRefData().getPosition().rot[2];
|
||||
|
||||
MWWorld::LocalRotation localRot = ptr.getRefData().getLocalRotation();
|
||||
|
||||
|
@ -337,7 +337,7 @@ namespace MWScript
|
|||
// See "Morrowind Scripting for Dummies (9th Edition)" pages 50 and 54 for reference.
|
||||
if(ptr != MWMechanics::getPlayer())
|
||||
zRot = zRot/60.0f;
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,zRot);
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,osg::DegreesToRadians(zRot));
|
||||
|
||||
ptr.getClass().adjustPosition(ptr, false);
|
||||
}
|
||||
|
@ -603,14 +603,14 @@ namespace MWScript
|
|||
|
||||
std::string axis = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
Interpreter::Type_Float rotation = (runtime[0].mFloat*MWBase::Environment::get().getFrameDuration());
|
||||
Interpreter::Type_Float rotation = osg::DegreesToRadians(runtime[0].mFloat*MWBase::Environment::get().getFrameDuration());
|
||||
runtime.pop();
|
||||
|
||||
const float *objRot = ptr.getRefData().getPosition().rot;
|
||||
|
||||
float ax = osg::RadiansToDegrees(objRot[0]);
|
||||
float ay = osg::RadiansToDegrees(objRot[1]);
|
||||
float az = osg::RadiansToDegrees(objRot[2]);
|
||||
float ax = objRot[0];
|
||||
float ay = objRot[1];
|
||||
float az = objRot[2];
|
||||
|
||||
if (axis == "x")
|
||||
{
|
||||
|
|
|
@ -419,9 +419,9 @@ namespace MWWorld
|
|||
if (adjustPlayerPos) {
|
||||
world->moveObject(player, pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||
|
||||
float x = osg::RadiansToDegrees(pos.rot[0]);
|
||||
float y = osg::RadiansToDegrees(pos.rot[1]);
|
||||
float z = osg::RadiansToDegrees(pos.rot[2]);
|
||||
float x = pos.rot[0];
|
||||
float y = pos.rot[1];
|
||||
float z = pos.rot[2];
|
||||
world->rotateObject(player, x, y, z);
|
||||
|
||||
player.getClass().adjustPosition(player, true);
|
||||
|
@ -476,9 +476,9 @@ namespace MWWorld
|
|||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
world->moveObject(world->getPlayerPtr(), position.pos[0], position.pos[1], position.pos[2]);
|
||||
|
||||
float x = osg::RadiansToDegrees(position.rot[0]);
|
||||
float y = osg::RadiansToDegrees(position.rot[1]);
|
||||
float z = osg::RadiansToDegrees(position.rot[2]);
|
||||
float x = position.rot[0];
|
||||
float y = position.rot[1];
|
||||
float z = position.rot[2];
|
||||
world->rotateObject(world->getPlayerPtr(), x, y, z);
|
||||
|
||||
world->getPlayerPtr().getClass().adjustPosition(world->getPlayerPtr(), true);
|
||||
|
|
|
@ -1317,10 +1317,7 @@ namespace MWWorld
|
|||
|
||||
void World::rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust)
|
||||
{
|
||||
rotateObjectImp(ptr, osg::Vec3f(osg::DegreesToRadians(x),
|
||||
osg::DegreesToRadians(y),
|
||||
osg::DegreesToRadians(z)),
|
||||
adjust);
|
||||
rotateObjectImp(ptr, osg::Vec3f(x, y, z), adjust);
|
||||
}
|
||||
|
||||
MWWorld::Ptr World::safePlaceObject(const MWWorld::Ptr& ptr, MWWorld::CellStore* cell, ESM::Position pos)
|
||||
|
@ -1403,12 +1400,12 @@ namespace MWWorld
|
|||
else
|
||||
{
|
||||
const ESM::Position& objPos = it->first.getRefData().getPosition();
|
||||
float oldRot = osg::RadiansToDegrees(objPos.rot[2]);
|
||||
float oldRot = objPos.rot[2];
|
||||
|
||||
float minRot = osg::RadiansToDegrees(it->first.getCellRef().getPosition().rot[2]);
|
||||
float maxRot = minRot + 90.f;
|
||||
float minRot = it->first.getCellRef().getPosition().rot[2];
|
||||
float maxRot = minRot + osg::DegreesToRadians(90.f);
|
||||
|
||||
float diff = duration * 90.f;
|
||||
float diff = duration * osg::DegreesToRadians(90.f);
|
||||
float targetRot = std::min(std::max(minRot, oldRot + diff * (it->second == 1 ? 1 : -1)), maxRot);
|
||||
rotateObject(it->first, objPos.rot[0], objPos.rot[1], targetRot);
|
||||
|
||||
|
|
|
@ -349,7 +349,7 @@ namespace MWWorld
|
|||
|
||||
virtual void scaleObject (const Ptr& ptr, float scale);
|
||||
|
||||
/// World rotates object, uses degrees
|
||||
/// World rotates object, uses radians
|
||||
/// \param adjust indicates rotation should be set or adjusted
|
||||
virtual void rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust = false);
|
||||
|
||||
|
|
Loading…
Reference in a new issue