forked from mirror/openmw-tes3mp
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)
|
if (!mSkipAnim)
|
||||||
{
|
{
|
||||||
rot *= osg::RadiansToDegrees(1.0f);
|
|
||||||
if(mHitState != CharState_KnockDown && mHitState != CharState_KnockOut)
|
if(mHitState != CharState_KnockDown && mHitState != CharState_KnockOut)
|
||||||
{
|
{
|
||||||
world->rotateObject(mPtr, rot.x(), rot.y(), rot.z(), true);
|
world->rotateObject(mPtr, rot.x(), rot.y(), rot.z(), true);
|
||||||
|
|
|
@ -85,12 +85,12 @@ namespace MWScript
|
||||||
|
|
||||||
std::string axis = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string axis = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
Interpreter::Type_Float angle = runtime[0].mFloat;
|
Interpreter::Type_Float angle = osg::DegreesToRadians(runtime[0].mFloat);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
float ax = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[0]);
|
float ax = ptr.getRefData().getPosition().rot[0];
|
||||||
float ay = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[1]);
|
float ay = ptr.getRefData().getPosition().rot[1];
|
||||||
float az = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[2]);
|
float az = ptr.getRefData().getPosition().rot[2];
|
||||||
|
|
||||||
MWWorld::LocalRotation localRot = ptr.getRefData().getLocalRotation();
|
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.
|
// See "Morrowind Scripting for Dummies (9th Edition)" pages 50 and 54 for reference.
|
||||||
if(ptr != MWMechanics::getPlayer())
|
if(ptr != MWMechanics::getPlayer())
|
||||||
zRot = zRot/60.0f;
|
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);
|
ptr.getClass().adjustPosition(ptr, false);
|
||||||
}
|
}
|
||||||
|
@ -603,14 +603,14 @@ namespace MWScript
|
||||||
|
|
||||||
std::string axis = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string axis = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
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();
|
runtime.pop();
|
||||||
|
|
||||||
const float *objRot = ptr.getRefData().getPosition().rot;
|
const float *objRot = ptr.getRefData().getPosition().rot;
|
||||||
|
|
||||||
float ax = osg::RadiansToDegrees(objRot[0]);
|
float ax = objRot[0];
|
||||||
float ay = osg::RadiansToDegrees(objRot[1]);
|
float ay = objRot[1];
|
||||||
float az = osg::RadiansToDegrees(objRot[2]);
|
float az = objRot[2];
|
||||||
|
|
||||||
if (axis == "x")
|
if (axis == "x")
|
||||||
{
|
{
|
||||||
|
|
|
@ -419,9 +419,9 @@ namespace MWWorld
|
||||||
if (adjustPlayerPos) {
|
if (adjustPlayerPos) {
|
||||||
world->moveObject(player, pos.pos[0], pos.pos[1], pos.pos[2]);
|
world->moveObject(player, pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||||
|
|
||||||
float x = osg::RadiansToDegrees(pos.rot[0]);
|
float x = pos.rot[0];
|
||||||
float y = osg::RadiansToDegrees(pos.rot[1]);
|
float y = pos.rot[1];
|
||||||
float z = osg::RadiansToDegrees(pos.rot[2]);
|
float z = pos.rot[2];
|
||||||
world->rotateObject(player, x, y, z);
|
world->rotateObject(player, x, y, z);
|
||||||
|
|
||||||
player.getClass().adjustPosition(player, true);
|
player.getClass().adjustPosition(player, true);
|
||||||
|
@ -476,9 +476,9 @@ namespace MWWorld
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
world->moveObject(world->getPlayerPtr(), position.pos[0], position.pos[1], position.pos[2]);
|
world->moveObject(world->getPlayerPtr(), position.pos[0], position.pos[1], position.pos[2]);
|
||||||
|
|
||||||
float x = osg::RadiansToDegrees(position.rot[0]);
|
float x = position.rot[0];
|
||||||
float y = osg::RadiansToDegrees(position.rot[1]);
|
float y = position.rot[1];
|
||||||
float z = osg::RadiansToDegrees(position.rot[2]);
|
float z = position.rot[2];
|
||||||
world->rotateObject(world->getPlayerPtr(), x, y, z);
|
world->rotateObject(world->getPlayerPtr(), x, y, z);
|
||||||
|
|
||||||
world->getPlayerPtr().getClass().adjustPosition(world->getPlayerPtr(), true);
|
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)
|
void World::rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust)
|
||||||
{
|
{
|
||||||
rotateObjectImp(ptr, osg::Vec3f(osg::DegreesToRadians(x),
|
rotateObjectImp(ptr, osg::Vec3f(x, y, z), adjust);
|
||||||
osg::DegreesToRadians(y),
|
|
||||||
osg::DegreesToRadians(z)),
|
|
||||||
adjust);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::Ptr World::safePlaceObject(const MWWorld::Ptr& ptr, MWWorld::CellStore* cell, ESM::Position pos)
|
MWWorld::Ptr World::safePlaceObject(const MWWorld::Ptr& ptr, MWWorld::CellStore* cell, ESM::Position pos)
|
||||||
|
@ -1403,12 +1400,12 @@ namespace MWWorld
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const ESM::Position& objPos = it->first.getRefData().getPosition();
|
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 minRot = it->first.getCellRef().getPosition().rot[2];
|
||||||
float maxRot = minRot + 90.f;
|
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);
|
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);
|
rotateObject(it->first, objPos.rot[0], objPos.rot[1], targetRot);
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,7 @@ namespace MWWorld
|
||||||
|
|
||||||
virtual void scaleObject (const Ptr& ptr, float scale);
|
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
|
/// \param adjust indicates rotation should be set or adjusted
|
||||||
virtual void rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust = false);
|
virtual void rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust = false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue