mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 16:09:39 +00:00
Remove last remains of Ogre math
This commit is contained in:
parent
364b785e8f
commit
b70383d127
15 changed files with 72 additions and 141 deletions
|
@ -1797,7 +1797,7 @@ void CharacterController::update(float duration)
|
||||||
if (mMovementState == CharState_TurnLeft || mMovementState == CharState_TurnRight)
|
if (mMovementState == CharState_TurnLeft || mMovementState == CharState_TurnRight)
|
||||||
{
|
{
|
||||||
if (duration > 0)
|
if (duration > 0)
|
||||||
mAnimation->adjustSpeedMult(mCurrentMovement, std::min(1.5f, std::abs(rot.z()) / duration / Ogre::Math::PI));
|
mAnimation->adjustSpeedMult(mCurrentMovement, std::min(1.5f, std::abs(rot.z()) / duration / static_cast<float>(osg::PI)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mSkipAnim)
|
if (!mSkipAnim)
|
||||||
|
|
|
@ -31,10 +31,10 @@ namespace
|
||||||
|
|
||||||
float getFightDistanceBias(const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2)
|
float getFightDistanceBias(const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2)
|
||||||
{
|
{
|
||||||
Ogre::Vector3 pos1 (actor1.getRefData().getPosition().pos);
|
osg::Vec3f pos1 (actor1.getRefData().getPosition().asVec3());
|
||||||
Ogre::Vector3 pos2 (actor2.getRefData().getPosition().pos);
|
osg::Vec3f pos2 (actor2.getRefData().getPosition().asVec3());
|
||||||
|
|
||||||
float d = pos1.distance(pos2);
|
float d = (pos1 - pos2).length();
|
||||||
|
|
||||||
static const int iFightDistanceBase = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
static const int iFightDistanceBase = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
||||||
"iFightDistanceBase")->getInt();
|
"iFightDistanceBase")->getInt();
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace MWMechanics
|
||||||
MWWorld::CellRefList<ESM::Door>& doors = cell->get<ESM::Door>();
|
MWWorld::CellRefList<ESM::Door>& doors = cell->get<ESM::Door>();
|
||||||
MWWorld::CellRefList<ESM::Door>::List& refList = doors.mList;
|
MWWorld::CellRefList<ESM::Door>::List& refList = doors.mList;
|
||||||
MWWorld::CellRefList<ESM::Door>::List::iterator it = refList.begin();
|
MWWorld::CellRefList<ESM::Door>::List::iterator it = refList.begin();
|
||||||
Ogre::Vector3 pos(actor.getRefData().getPosition().pos);
|
osg::Vec3f pos(actor.getRefData().getPosition().asVec3());
|
||||||
|
|
||||||
/// TODO: How to check whether the actor is facing a door? Below code is for
|
/// TODO: How to check whether the actor is facing a door? Below code is for
|
||||||
/// the player, perhaps it can be adapted.
|
/// the player, perhaps it can be adapted.
|
||||||
|
@ -50,7 +50,7 @@ namespace MWMechanics
|
||||||
for (; it != refList.end(); ++it)
|
for (; it != refList.end(); ++it)
|
||||||
{
|
{
|
||||||
MWWorld::LiveCellRef<ESM::Door>& ref = *it;
|
MWWorld::LiveCellRef<ESM::Door>& ref = *it;
|
||||||
if(pos.squaredDistance(Ogre::Vector3(ref.mData.getPosition().pos)) < minSqr)
|
if((pos - ref.mData.getPosition().asVec3()).length2() < minSqr)
|
||||||
if((closed && ref.mData.getLocalRotation().rot[2] == 0) ||
|
if((closed && ref.mData.getLocalRotation().rot[2] == 0) ||
|
||||||
(!closed && ref.mData.getLocalRotation().rot[2] >= 1))
|
(!closed && ref.mData.getLocalRotation().rot[2] >= 1))
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,9 +22,9 @@ namespace MWMechanics
|
||||||
public:
|
public:
|
||||||
PathFinder();
|
PathFinder();
|
||||||
|
|
||||||
static float sgn(Ogre::Radian a)
|
static float sgn(float val)
|
||||||
{
|
{
|
||||||
if(a.valueRadians() > 0)
|
if(val > 0)
|
||||||
return 1.0;
|
return 1.0;
|
||||||
return -1.0;
|
return -1.0;
|
||||||
}
|
}
|
||||||
|
@ -77,12 +77,6 @@ namespace MWMechanics
|
||||||
mPath.push_back(point);
|
mPath.push_back(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// utility function to convert a Ogre::Vector3 to a Pathgrid::Point
|
|
||||||
static ESM::Pathgrid::Point MakePathgridPoint(const Ogre::Vector3& v)
|
|
||||||
{
|
|
||||||
return ESM::Pathgrid::Point(static_cast<int>(v[0]), static_cast<int>(v[1]), static_cast<int>(v[2]));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// utility function to convert a osg::Vec3f to a Pathgrid::Point
|
/// utility function to convert a osg::Vec3f to a Pathgrid::Point
|
||||||
static ESM::Pathgrid::Point MakePathgridPoint(const osg::Vec3f& v)
|
static ESM::Pathgrid::Point MakePathgridPoint(const osg::Vec3f& v)
|
||||||
{
|
{
|
||||||
|
@ -100,12 +94,6 @@ namespace MWMechanics
|
||||||
return osg::Vec3f(static_cast<float>(p.mX), static_cast<float>(p.mY), static_cast<float>(p.mZ));
|
return osg::Vec3f(static_cast<float>(p.mX), static_cast<float>(p.mY), static_cast<float>(p.mZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// utility function to convert a Pathgrid::Point to a Ogre::Vector3
|
|
||||||
static Ogre::Vector3 MakeOgreVector3(const ESM::Pathgrid::Point& p)
|
|
||||||
{
|
|
||||||
return Ogre::Vector3(static_cast<Ogre::Real>(p.mX), static_cast<Ogre::Real>(p.mY), static_cast<Ogre::Real>(p.mZ));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool mIsPathConstructed;
|
bool mIsPathConstructed;
|
||||||
|
|
|
@ -115,13 +115,14 @@ namespace MWMechanics
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
ESM::Position ipos = mActor.getRefData().getPosition();
|
ESM::Position ipos = mActor.getRefData().getPosition();
|
||||||
Ogre::Vector3 pos(ipos.pos);
|
osg::Vec3f pos(ipos.asVec3());
|
||||||
Ogre::Quaternion rot(Ogre::Radian(-ipos.rot[2]), Ogre::Vector3::UNIT_Z);
|
|
||||||
|
osg::Quat rot (-ipos.rot[2], osg::Vec3f(0,0,1));
|
||||||
const float distance = 50;
|
const float distance = 50;
|
||||||
pos = pos + distance*rot.yAxis();
|
pos = pos + (rot * osg::Vec3f(0,1,0)) * distance;
|
||||||
ipos.pos[0] = pos.x;
|
ipos.pos[0] = pos.x();
|
||||||
ipos.pos[1] = pos.y;
|
ipos.pos[1] = pos.y();
|
||||||
ipos.pos[2] = pos.z;
|
ipos.pos[2] = pos.z();
|
||||||
ipos.rot[0] = 0;
|
ipos.rot[0] = 0;
|
||||||
ipos.rot[1] = 0;
|
ipos.rot[1] = 0;
|
||||||
ipos.rot[2] = 0;
|
ipos.rot[2] = 0;
|
||||||
|
|
|
@ -1062,26 +1062,4 @@ void NpcAnimation::updatePtr(const MWWorld::Ptr &updated)
|
||||||
mHeadAnimationTime->updatePtr(updated);
|
mHeadAnimationTime->updatePtr(updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void NpcAnimation::setHeadPitch(Ogre::Radian pitch)
|
|
||||||
{
|
|
||||||
mHeadPitch = pitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NpcAnimation::setHeadYaw(Ogre::Radian yaw)
|
|
||||||
{
|
|
||||||
mHeadYaw = yaw;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ogre::Radian NpcAnimation::getHeadPitch() const
|
|
||||||
{
|
|
||||||
return mHeadPitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ogre::Radian NpcAnimation::getHeadYaw() const
|
|
||||||
{
|
|
||||||
return mHeadYaw;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,8 +120,6 @@ private:
|
||||||
void addPartGroup(int group, int priority, const std::vector<ESM::PartReference> &parts,
|
void addPartGroup(int group, int priority, const std::vector<ESM::PartReference> &parts,
|
||||||
bool enchantedGlow=false, osg::Vec4f* glowColor=NULL);
|
bool enchantedGlow=false, osg::Vec4f* glowColor=NULL);
|
||||||
|
|
||||||
//void applyAlpha(float alpha, Ogre::Entity* ent, NifOgre::ObjectScenePtr scene);
|
|
||||||
|
|
||||||
osg::ref_ptr<NeckController> mFirstPersonNeckController;
|
osg::ref_ptr<NeckController> mFirstPersonNeckController;
|
||||||
osg::ref_ptr<RotateController> mHeadController;
|
osg::ref_ptr<RotateController> mHeadController;
|
||||||
|
|
||||||
|
@ -171,19 +169,12 @@ public:
|
||||||
virtual Resource::ResourceSystem* getResourceSystem();
|
virtual Resource::ResourceSystem* getResourceSystem();
|
||||||
|
|
||||||
// WeaponAnimation
|
// WeaponAnimation
|
||||||
//virtual NifOgre::ObjectScenePtr getWeapon() { return mObjectParts[ESM::PRT_Weapon]; }
|
|
||||||
virtual void showWeapon(bool show) { showWeapons(show); }
|
virtual void showWeapon(bool show) { showWeapons(show); }
|
||||||
//virtual void configureAddedObject(NifOgre::ObjectScenePtr object, MWWorld::Ptr ptr, int slot);
|
|
||||||
|
|
||||||
void setViewMode(ViewMode viewMode);
|
void setViewMode(ViewMode viewMode);
|
||||||
|
|
||||||
void updateParts();
|
void updateParts();
|
||||||
|
|
||||||
/// \brief Applies a translation to the arms and hands.
|
|
||||||
/// This may be called multiple times before the animation
|
|
||||||
/// is updated to add additional offsets.
|
|
||||||
//void addFirstPersonOffset(const Ogre::Vector3 &offset);
|
|
||||||
|
|
||||||
/// Rebuilds the NPC, updating their root model, animation sources, and equipment.
|
/// Rebuilds the NPC, updating their root model, animation sources, and equipment.
|
||||||
void rebuild();
|
void rebuild();
|
||||||
|
|
||||||
|
|
|
@ -56,16 +56,11 @@ namespace MWRender
|
||||||
virtual osg::Node* getWeaponNode() = 0;
|
virtual osg::Node* getWeaponNode() = 0;
|
||||||
virtual Resource::ResourceSystem* getResourceSystem() = 0;
|
virtual Resource::ResourceSystem* getResourceSystem() = 0;
|
||||||
|
|
||||||
|
|
||||||
//virtual NifOgre::ObjectScenePtr getWeapon() = 0;
|
|
||||||
virtual void showWeapon(bool show) = 0;
|
virtual void showWeapon(bool show) = 0;
|
||||||
//virtual void configureAddedObject(NifOgre::ObjectScenePtr object, MWWorld::Ptr ptr, int slot) = 0;
|
|
||||||
|
|
||||||
/// A relative factor (0-1) that decides if and how much the skeleton should be pitched
|
/// A relative factor (0-1) that decides if and how much the skeleton should be pitched
|
||||||
/// to indicate the facing orientation of the character, for ranged weapon aiming.
|
/// to indicate the facing orientation of the character, for ranged weapon aiming.
|
||||||
float mPitchFactor;
|
float mPitchFactor;
|
||||||
|
|
||||||
//void pitchSkeleton(float xrot, Ogre::SkeletonInstance* skel);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1045,8 +1045,8 @@ namespace MWScript
|
||||||
msg << "Cell: " << MWBase::Environment::get().getWorld()->getCellName(cell) << std::endl;
|
msg << "Cell: " << MWBase::Environment::get().getWorld()->getCellName(cell) << std::endl;
|
||||||
if (cell->getCell()->isExterior())
|
if (cell->getCell()->isExterior())
|
||||||
msg << "Grid: " << cell->getCell()->getGridX() << " " << cell->getCell()->getGridY() << std::endl;
|
msg << "Grid: " << cell->getCell()->getGridX() << " " << cell->getCell()->getGridY() << std::endl;
|
||||||
Ogre::Vector3 pos (ptr.getRefData().getPosition().pos);
|
osg::Vec3f pos (ptr.getRefData().getPosition().asVec3());
|
||||||
msg << "Coordinates: " << pos << std::endl;
|
msg << "Coordinates: " << pos.x() << " " << pos.y() << " " << pos.z() << std::endl;
|
||||||
msg << "Model: " << ptr.getClass().getModel(ptr) << std::endl;
|
msg << "Model: " << ptr.getClass().getModel(ptr) << std::endl;
|
||||||
if (!ptr.getClass().getScript(ptr).empty())
|
if (!ptr.getClass().getScript(ptr).empty())
|
||||||
msg << "Script: " << ptr.getClass().getScript(ptr) << std::endl;
|
msg << "Script: " << ptr.getClass().getScript(ptr) << std::endl;
|
||||||
|
|
|
@ -84,9 +84,9 @@ namespace MWScript
|
||||||
Interpreter::Type_Float angle = runtime[0].mFloat;
|
Interpreter::Type_Float angle = runtime[0].mFloat;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
float ax = Ogre::Radian(ptr.getRefData().getPosition().rot[0]).valueDegrees();
|
float ax = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[0]);
|
||||||
float ay = Ogre::Radian(ptr.getRefData().getPosition().rot[1]).valueDegrees();
|
float ay = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[1]);
|
||||||
float az = Ogre::Radian(ptr.getRefData().getPosition().rot[2]).valueDegrees();
|
float az = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[2]);
|
||||||
|
|
||||||
MWWorld::LocalRotation localRot = ptr.getRefData().getLocalRotation();
|
MWWorld::LocalRotation localRot = ptr.getRefData().getLocalRotation();
|
||||||
|
|
||||||
|
@ -127,15 +127,15 @@ namespace MWScript
|
||||||
|
|
||||||
if (axis == "x")
|
if (axis == "x")
|
||||||
{
|
{
|
||||||
runtime.push(Ogre::Radian(ptr.getCellRef().getPosition().rot[0]).valueDegrees());
|
runtime.push(osg::RadiansToDegrees(ptr.getCellRef().getPosition().rot[0]));
|
||||||
}
|
}
|
||||||
else if (axis == "y")
|
else if (axis == "y")
|
||||||
{
|
{
|
||||||
runtime.push(Ogre::Radian(ptr.getCellRef().getPosition().rot[1]).valueDegrees());
|
runtime.push(osg::RadiansToDegrees(ptr.getCellRef().getPosition().rot[1]));
|
||||||
}
|
}
|
||||||
else if (axis == "z")
|
else if (axis == "z")
|
||||||
{
|
{
|
||||||
runtime.push(Ogre::Radian(ptr.getCellRef().getPosition().rot[2]).valueDegrees());
|
runtime.push(osg::RadiansToDegrees(ptr.getCellRef().getPosition().rot[2]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw std::runtime_error ("invalid rotation axis: " + axis);
|
throw std::runtime_error ("invalid rotation axis: " + axis);
|
||||||
|
@ -156,15 +156,15 @@ namespace MWScript
|
||||||
|
|
||||||
if (axis=="x")
|
if (axis=="x")
|
||||||
{
|
{
|
||||||
runtime.push(Ogre::Radian(ptr.getRefData().getPosition().rot[0]).valueDegrees());
|
runtime.push(osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[0]));
|
||||||
}
|
}
|
||||||
else if (axis=="y")
|
else if (axis=="y")
|
||||||
{
|
{
|
||||||
runtime.push(Ogre::Radian(ptr.getRefData().getPosition().rot[1]).valueDegrees());
|
runtime.push(osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[1]));
|
||||||
}
|
}
|
||||||
else if (axis=="z")
|
else if (axis=="z")
|
||||||
{
|
{
|
||||||
runtime.push(Ogre::Radian(ptr.getRefData().getPosition().rot[2]).valueDegrees());
|
runtime.push(osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[2]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw std::runtime_error ("invalid rotation axis: " + axis);
|
throw std::runtime_error ("invalid rotation axis: " + axis);
|
||||||
|
@ -326,8 +326,8 @@ namespace MWScript
|
||||||
ptr = MWWorld::Ptr(ptr.getBase(), store);
|
ptr = MWWorld::Ptr(ptr.getBase(), store);
|
||||||
dynamic_cast<MWScript::InterpreterContext&>(runtime.getContext()).updatePtr(ptr);
|
dynamic_cast<MWScript::InterpreterContext&>(runtime.getContext()).updatePtr(ptr);
|
||||||
|
|
||||||
float ax = Ogre::Radian(ptr.getRefData().getPosition().rot[0]).valueDegrees();
|
float ax = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[0]);
|
||||||
float ay = Ogre::Radian(ptr.getRefData().getPosition().rot[1]).valueDegrees();
|
float ay = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[1]);
|
||||||
// Note that you must specify ZRot in minutes (1 degree = 60 minutes; north = 0, east = 5400, south = 10800, west = 16200)
|
// Note that you must specify ZRot in minutes (1 degree = 60 minutes; north = 0, east = 5400, south = 10800, west = 16200)
|
||||||
// except for when you position the player, then degrees must be used.
|
// except for when you position the player, then degrees must be used.
|
||||||
// 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.
|
||||||
|
@ -382,8 +382,8 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
dynamic_cast<MWScript::InterpreterContext&>(runtime.getContext()).updatePtr(ptr);
|
dynamic_cast<MWScript::InterpreterContext&>(runtime.getContext()).updatePtr(ptr);
|
||||||
|
|
||||||
float ax = Ogre::Radian(ptr.getRefData().getPosition().rot[0]).valueDegrees();
|
float ax = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[0]);
|
||||||
float ay = Ogre::Radian(ptr.getRefData().getPosition().rot[1]).valueDegrees();
|
float ay = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[1]);
|
||||||
// Note that you must specify ZRot in minutes (1 degree = 60 minutes; north = 0, east = 5400, south = 10800, west = 16200)
|
// Note that you must specify ZRot in minutes (1 degree = 60 minutes; north = 0, east = 5400, south = 10800, west = 16200)
|
||||||
// except for when you position the player, then degrees must be used.
|
// except for when you position the player, then degrees must be used.
|
||||||
// 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.
|
||||||
|
@ -567,9 +567,9 @@ namespace MWScript
|
||||||
Interpreter::Type_Float rotation = (runtime[0].mFloat*MWBase::Environment::get().getFrameDuration());
|
Interpreter::Type_Float rotation = (runtime[0].mFloat*MWBase::Environment::get().getFrameDuration());
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
float ax = Ogre::Radian(ptr.getRefData().getLocalRotation().rot[0]).valueDegrees();
|
float ax = osg::RadiansToDegrees(ptr.getRefData().getLocalRotation().rot[0]);
|
||||||
float ay = Ogre::Radian(ptr.getRefData().getLocalRotation().rot[1]).valueDegrees();
|
float ay = osg::RadiansToDegrees(ptr.getRefData().getLocalRotation().rot[1]);
|
||||||
float az = Ogre::Radian(ptr.getRefData().getLocalRotation().rot[2]).valueDegrees();
|
float az = osg::RadiansToDegrees(ptr.getRefData().getLocalRotation().rot[2]);
|
||||||
|
|
||||||
if (axis == "x")
|
if (axis == "x")
|
||||||
{
|
{
|
||||||
|
@ -604,9 +604,9 @@ namespace MWScript
|
||||||
|
|
||||||
const float *objRot = ptr.getRefData().getPosition().rot;
|
const float *objRot = ptr.getRefData().getPosition().rot;
|
||||||
|
|
||||||
float ax = Ogre::Radian(objRot[0]).valueDegrees();
|
float ax = osg::RadiansToDegrees(objRot[0]);
|
||||||
float ay = Ogre::Radian(objRot[1]).valueDegrees();
|
float ay = osg::RadiansToDegrees(objRot[1]);
|
||||||
float az = Ogre::Radian(objRot[2]).valueDegrees();
|
float az = osg::RadiansToDegrees(objRot[2]);
|
||||||
|
|
||||||
if (axis == "x")
|
if (axis == "x")
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,8 +40,7 @@ namespace MWWorld
|
||||||
for(std::set<MWWorld::Ptr>::iterator it = followers.begin();it != followers.end();++it)
|
for(std::set<MWWorld::Ptr>::iterator it = followers.begin();it != followers.end();++it)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr follower = *it;
|
MWWorld::Ptr follower = *it;
|
||||||
if (Ogre::Vector3(follower.getRefData().getPosition().pos).squaredDistance(
|
if ((follower.getRefData().getPosition().asVec3() - actor.getRefData().getPosition().asVec3()).length2()
|
||||||
Ogre::Vector3( actor.getRefData().getPosition().pos))
|
|
||||||
<= 800*800)
|
<= 800*800)
|
||||||
teleport(*it);
|
teleport(*it);
|
||||||
}
|
}
|
||||||
|
|
|
@ -418,9 +418,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 = Ogre::Radian(pos.rot[0]).valueDegrees();
|
float x = osg::RadiansToDegrees(pos.rot[0]);
|
||||||
float y = Ogre::Radian(pos.rot[1]).valueDegrees();
|
float y = osg::RadiansToDegrees(pos.rot[1]);
|
||||||
float z = Ogre::Radian(pos.rot[2]).valueDegrees();
|
float z = osg::RadiansToDegrees(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);
|
||||||
|
@ -475,9 +475,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 = Ogre::Radian(position.rot[0]).valueDegrees();
|
float x = osg::RadiansToDegrees(position.rot[0]);
|
||||||
float y = Ogre::Radian(position.rot[1]).valueDegrees();
|
float y = osg::RadiansToDegrees(position.rot[1]);
|
||||||
float z = Ogre::Radian(position.rot[2]).valueDegrees();
|
float z = osg::RadiansToDegrees(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);
|
||||||
|
|
|
@ -66,10 +66,11 @@ namespace
|
||||||
// Wraps a value to (-PI, PI]
|
// Wraps a value to (-PI, PI]
|
||||||
void wrap(float& rad)
|
void wrap(float& rad)
|
||||||
{
|
{
|
||||||
|
const float pi = static_cast<float>(osg::PI);
|
||||||
if (rad>0)
|
if (rad>0)
|
||||||
rad = std::fmod(rad+Ogre::Math::PI, 2.0f*Ogre::Math::PI)-Ogre::Math::PI;
|
rad = std::fmod(rad+pi, 2.0f*pi)-pi;
|
||||||
else
|
else
|
||||||
rad = std::fmod(rad-Ogre::Math::PI, 2.0f*Ogre::Math::PI)+Ogre::Math::PI;
|
rad = std::fmod(rad-pi, 2.0f*pi)+pi;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1220,24 +1221,24 @@ namespace MWWorld
|
||||||
mWorldScene->updateObjectScale(ptr);
|
mWorldScene->updateObjectScale(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::rotateObjectImp (const Ptr& ptr, Ogre::Vector3 rot, bool adjust)
|
void World::rotateObjectImp (const Ptr& ptr, const osg::Vec3f& rot, bool adjust)
|
||||||
{
|
{
|
||||||
const float two_pi = Ogre::Math::TWO_PI;
|
const float pi = static_cast<float>(osg::PI);
|
||||||
const float pi = Ogre::Math::PI;
|
const float two_pi = pi*2.f;
|
||||||
|
|
||||||
ESM::Position pos = ptr.getRefData().getPosition();
|
ESM::Position pos = ptr.getRefData().getPosition();
|
||||||
float *objRot = pos.rot;
|
float *objRot = pos.rot;
|
||||||
if(adjust)
|
if(adjust)
|
||||||
{
|
{
|
||||||
objRot[0] += rot.x;
|
objRot[0] += rot.x();
|
||||||
objRot[1] += rot.y;
|
objRot[1] += rot.y();
|
||||||
objRot[2] += rot.z;
|
objRot[2] += rot.z();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
objRot[0] = rot.x;
|
objRot[0] = rot.x();
|
||||||
objRot[1] = rot.y;
|
objRot[1] = rot.y();
|
||||||
objRot[2] = rot.z;
|
objRot[2] = rot.z();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ptr.getClass().isActor())
|
if(ptr.getClass().isActor())
|
||||||
|
@ -1246,7 +1247,7 @@ namespace MWWorld
|
||||||
* currently it's done so for rotating the camera, which needs
|
* currently it's done so for rotating the camera, which needs
|
||||||
* clamping.
|
* clamping.
|
||||||
*/
|
*/
|
||||||
const float half_pi = Ogre::Math::HALF_PI;
|
const float half_pi = pi/2.f;
|
||||||
|
|
||||||
if(objRot[0] < -half_pi) objRot[0] = -half_pi;
|
if(objRot[0] < -half_pi) objRot[0] = -half_pi;
|
||||||
else if(objRot[0] > half_pi) objRot[0] = half_pi;
|
else if(objRot[0] > half_pi) objRot[0] = half_pi;
|
||||||
|
@ -1272,9 +1273,9 @@ namespace MWWorld
|
||||||
void World::localRotateObject (const Ptr& ptr, float x, float y, float z)
|
void World::localRotateObject (const Ptr& ptr, float x, float y, float z)
|
||||||
{
|
{
|
||||||
LocalRotation rot = ptr.getRefData().getLocalRotation();
|
LocalRotation rot = ptr.getRefData().getLocalRotation();
|
||||||
rot.rot[0]=Ogre::Degree(x).valueRadians();
|
rot.rot[0]=osg::DegreesToRadians(x);
|
||||||
rot.rot[1]=Ogre::Degree(y).valueRadians();
|
rot.rot[1]=osg::DegreesToRadians(y);
|
||||||
rot.rot[2]=Ogre::Degree(z).valueRadians();
|
rot.rot[2]=osg::DegreesToRadians(z);
|
||||||
|
|
||||||
wrap(rot.rot[0]);
|
wrap(rot.rot[0]);
|
||||||
wrap(rot.rot[1]);
|
wrap(rot.rot[1]);
|
||||||
|
@ -1332,9 +1333,9 @@ 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, Ogre::Vector3(Ogre::Degree(x).valueRadians(),
|
rotateObjectImp(ptr, osg::Vec3f(osg::DegreesToRadians(x),
|
||||||
Ogre::Degree(y).valueRadians(),
|
osg::DegreesToRadians(y),
|
||||||
Ogre::Degree(z).valueRadians()),
|
osg::DegreesToRadians(z)),
|
||||||
adjust);
|
adjust);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2904,8 +2905,7 @@ namespace MWWorld
|
||||||
World::DetectionType mType;
|
World::DetectionType mType;
|
||||||
bool operator() (MWWorld::Ptr ptr)
|
bool operator() (MWWorld::Ptr ptr)
|
||||||
{
|
{
|
||||||
if (Ogre::Vector3(ptr.getRefData().getPosition().pos).squaredDistance(
|
if ((ptr.getRefData().getPosition().asVec3() - mDetector.getRefData().getPosition().asVec3()).length2() >= mSquaredDist)
|
||||||
Ogre::Vector3(mDetector.getRefData().getPosition().pos)) >= mSquaredDist)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!ptr.getRefData().isEnabled() || ptr.getRefData().isDeleted())
|
if (!ptr.getRefData().isEnabled() || ptr.getRefData().isDeleted())
|
||||||
|
@ -3096,13 +3096,13 @@ namespace MWWorld
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ESM::Position ipos = mPlayer->getPlayer().getRefData().getPosition();
|
ESM::Position ipos = mPlayer->getPlayer().getRefData().getPosition();
|
||||||
Ogre::Vector3 pos(ipos.pos);
|
osg::Vec3f pos(ipos.asVec3());
|
||||||
Ogre::Quaternion rot(Ogre::Radian(-ipos.rot[2]), Ogre::Vector3::UNIT_Z);
|
osg::Quat rot(-ipos.rot[2], osg::Vec3f(0,0,1));
|
||||||
const float distance = 50;
|
const float distance = 50;
|
||||||
pos = pos + distance*rot.yAxis();
|
pos = pos + (rot * osg::Vec3f(0,1,0)) * distance;
|
||||||
ipos.pos[0] = pos.x;
|
ipos.pos[0] = pos.x();
|
||||||
ipos.pos[1] = pos.y;
|
ipos.pos[1] = pos.y();
|
||||||
ipos.pos[2] = pos.z;
|
ipos.pos[2] = pos.z();
|
||||||
ipos.rot[0] = 0;
|
ipos.rot[0] = 0;
|
||||||
ipos.rot[1] = 0;
|
ipos.rot[1] = 0;
|
||||||
ipos.rot[2] = 0;
|
ipos.rot[2] = 0;
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace MWWorld
|
||||||
void updateWeather(float duration, bool paused = false);
|
void updateWeather(float duration, bool paused = false);
|
||||||
int getDaysPerMonth (int month) const;
|
int getDaysPerMonth (int month) const;
|
||||||
|
|
||||||
void rotateObjectImp (const Ptr& ptr, Ogre::Vector3 rot, bool adjust);
|
void rotateObjectImp (const Ptr& ptr, const osg::Vec3f& rot, bool adjust);
|
||||||
|
|
||||||
Ptr moveObjectImp (const Ptr& ptr, float x, float y, float z);
|
Ptr moveObjectImp (const Ptr& ptr, float x, float y, float z);
|
||||||
///< @return an updated Ptr in case the Ptr's cell changes
|
///< @return an updated Ptr in case the Ptr's cell changes
|
||||||
|
|
|
@ -17,13 +17,7 @@ struct Quaternion
|
||||||
float mValues[4];
|
float mValues[4];
|
||||||
|
|
||||||
Quaternion() {}
|
Quaternion() {}
|
||||||
Quaternion (Ogre::Quaternion q)
|
|
||||||
{
|
|
||||||
mValues[0] = q.w;
|
|
||||||
mValues[1] = q.x;
|
|
||||||
mValues[2] = q.y;
|
|
||||||
mValues[3] = q.z;
|
|
||||||
}
|
|
||||||
Quaternion(const osg::Quat& q)
|
Quaternion(const osg::Quat& q)
|
||||||
{
|
{
|
||||||
mValues[0] = q.w();
|
mValues[0] = q.w();
|
||||||
|
@ -32,11 +26,6 @@ struct Quaternion
|
||||||
mValues[3] = q.z();
|
mValues[3] = q.z();
|
||||||
}
|
}
|
||||||
|
|
||||||
operator Ogre::Quaternion () const
|
|
||||||
{
|
|
||||||
return Ogre::Quaternion(mValues[0], mValues[1], mValues[2], mValues[3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
operator osg::Quat () const
|
operator osg::Quat () const
|
||||||
{
|
{
|
||||||
return osg::Quat(mValues[1], mValues[2], mValues[3], mValues[0]);
|
return osg::Quat(mValues[1], mValues[2], mValues[3], mValues[0]);
|
||||||
|
@ -48,12 +37,7 @@ struct Vector3
|
||||||
float mValues[3];
|
float mValues[3];
|
||||||
|
|
||||||
Vector3() {}
|
Vector3() {}
|
||||||
Vector3 (Ogre::Vector3 v)
|
|
||||||
{
|
|
||||||
mValues[0] = v.x;
|
|
||||||
mValues[1] = v.y;
|
|
||||||
mValues[2] = v.z;
|
|
||||||
}
|
|
||||||
Vector3(const osg::Vec3f& v)
|
Vector3(const osg::Vec3f& v)
|
||||||
{
|
{
|
||||||
mValues[0] = v.x();
|
mValues[0] = v.x();
|
||||||
|
@ -61,11 +45,6 @@ struct Vector3
|
||||||
mValues[2] = v.z();
|
mValues[2] = v.z();
|
||||||
}
|
}
|
||||||
|
|
||||||
operator Ogre::Vector3 () const
|
|
||||||
{
|
|
||||||
return Ogre::Vector3(&mValues[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
operator osg::Vec3f () const
|
operator osg::Vec3f () const
|
||||||
{
|
{
|
||||||
return osg::Vec3f(mValues[0], mValues[1], mValues[2]);
|
return osg::Vec3f(mValues[0], mValues[1], mValues[2]);
|
||||||
|
|
Loading…
Reference in a new issue