Merged pull request #1723

pull/447/head
Marc Zinnschlag 7 years ago
commit 2ab31b0c18

@ -564,6 +564,8 @@ namespace MWBase
virtual bool isPlayerInJail() const = 0; virtual bool isPlayerInJail() const = 0;
virtual void rotateWorldObject (const MWWorld::Ptr& ptr, osg::Quat rotate) = 0;
/// Return terrain height at \a worldPos position. /// Return terrain height at \a worldPos position.
virtual float getTerrainHeightAt(const osg::Vec3f& worldPos) const = 0; 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()); Interpreter::Type_Float rotation = osg::DegreesToRadians(runtime[0].mFloat*MWBase::Environment::get().getFrameDuration());
runtime.pop(); runtime.pop();
const float *objRot = ptr.getRefData().getPosition().rot; if (!ptr.getRefData().getBaseNode())
return;
float ax = objRot[0]; // We can rotate actors only around Z axis
float ay = objRot[1]; if (ptr.getClass().isActor() && (axis == "x" || axis == "y"))
float az = objRot[2]; return;
osg::Quat rot;
if (axis == "x") if (axis == "x")
{ rot = osg::Quat(rotation, -osg::X_AXIS);
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax+rotation,ay,az);
}
else if (axis == "y") else if (axis == "y")
{ rot = osg::Quat(rotation, -osg::Y_AXIS);
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay+rotation,az);
}
else if (axis == "z") else if (axis == "z")
{ rot = osg::Quat(rotation, -osg::Z_AXIS);
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,az+rotation);
}
else else
throw std::runtime_error ("invalid rotation axis: " + axis); 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); 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) MWWorld::Ptr World::placeObject(const MWWorld::ConstPtr& ptr, MWWorld::CellStore* cell, ESM::Position pos)
{ {
return copyObjectToCell(ptr,cell,pos,ptr.getRefData().getCount(),false); return copyObjectToCell(ptr,cell,pos,ptr.getRefData().getCount(),false);

@ -214,6 +214,8 @@ namespace MWWorld
void setWaterHeight(const float height) override; void setWaterHeight(const float height) override;
void rotateWorldObject (const MWWorld::Ptr& ptr, osg::Quat rotate) override;
bool toggleWater() override; bool toggleWater() override;
bool toggleWorld() override; bool toggleWorld() override;

Loading…
Cancel
Save