mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
RotateWorld: rotate around world axis (bug #4426)
This commit is contained in:
parent
d73c6ebe60
commit
24863f620b
@ -564,6 +564,8 @@ namespace MWBase
|
||||
|
||||
virtual bool isPlayerInJail() const = 0;
|
||||
|
||||
virtual void rotateWorldObject (const MWWorld::Ptr& ptr, osg::Quat rotate) = 0;
|
||||
|
||||
/// Return terrain height at \a worldPos position.
|
||||
virtual float getTerrainHeightAt(const osg::Vec3f& worldPos) const = 0;
|
||||
|
||||
|
@ -579,26 +579,25 @@ namespace MWScript
|
||||
Interpreter::Type_Float rotation = osg::DegreesToRadians(runtime[0].mFloat*MWBase::Environment::get().getFrameDuration());
|
||||
runtime.pop();
|
||||
|
||||
const float *objRot = ptr.getRefData().getPosition().rot;
|
||||
if (!ptr.getRefData().getBaseNode())
|
||||
return;
|
||||
|
||||
float ax = objRot[0];
|
||||
float ay = objRot[1];
|
||||
float az = objRot[2];
|
||||
// We can rotate actors only around Z axis
|
||||
if (ptr.getClass().isActor() && (axis == "x" || axis == "y"))
|
||||
return;
|
||||
|
||||
osg::Quat rot;
|
||||
if (axis == "x")
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax+rotation,ay,az);
|
||||
}
|
||||
rot = osg::Quat(rotation, -osg::X_AXIS);
|
||||
else if (axis == "y")
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay+rotation,az);
|
||||
}
|
||||
rot = osg::Quat(rotation, -osg::Y_AXIS);
|
||||
else if (axis == "z")
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,az+rotation);
|
||||
}
|
||||
rot = osg::Quat(rotation, -osg::Z_AXIS);
|
||||
else
|
||||
throw std::runtime_error ("invalid rotation axis: " + axis);
|
||||
|
||||
osg::Quat attitude = ptr.getRefData().getBaseNode()->getAttitude();
|
||||
MWBase::Environment::get().getWorld()->rotateWorldObject(ptr, attitude * rot);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1342,6 +1342,15 @@ namespace MWWorld
|
||||
rotateObjectImp(ptr, osg::Vec3f(x, y, z), adjust);
|
||||
}
|
||||
|
||||
void World::rotateWorldObject (const Ptr& ptr, osg::Quat rotate)
|
||||
{
|
||||
if(ptr.getRefData().getBaseNode() != 0)
|
||||
{
|
||||
mRendering->rotateObject(ptr, rotate);
|
||||
mPhysics->updateRotation(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
MWWorld::Ptr World::placeObject(const MWWorld::ConstPtr& ptr, MWWorld::CellStore* cell, ESM::Position pos)
|
||||
{
|
||||
return copyObjectToCell(ptr,cell,pos,ptr.getRefData().getCount(),false);
|
||||
|
@ -214,6 +214,8 @@ namespace MWWorld
|
||||
|
||||
void setWaterHeight(const float height) override;
|
||||
|
||||
void rotateWorldObject (const MWWorld::Ptr& ptr, osg::Quat rotate) override;
|
||||
|
||||
bool toggleWater() override;
|
||||
bool toggleWorld() override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user