|
|
@ -29,6 +29,18 @@ namespace MWScript
|
|
|
|
{
|
|
|
|
{
|
|
|
|
namespace Transformation
|
|
|
|
namespace Transformation
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
void moveStandingActors(const MWWorld::Ptr &ptr, const osg::Vec3f& diff)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::vector<MWWorld::Ptr> actors;
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWorld()->getActorsStandingOn (ptr, actors);
|
|
|
|
|
|
|
|
for (auto& actor : actors)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
osg::Vec3f actorPos(actor.getRefData().getPosition().asVec3());
|
|
|
|
|
|
|
|
actorPos += diff;
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWorld()->moveObject(actor, actorPos.x(), actorPos.y(), actorPos.z());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class R>
|
|
|
|
template<class R>
|
|
|
|
class OpSetScale : public Interpreter::Opcode0
|
|
|
|
class OpSetScale : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -666,6 +678,10 @@ namespace MWScript
|
|
|
|
osg::Vec3f diff = ptr.getRefData().getBaseNode()->getAttitude() * posChange;
|
|
|
|
osg::Vec3f diff = ptr.getRefData().getBaseNode()->getAttitude() * posChange;
|
|
|
|
osg::Vec3f worldPos(ptr.getRefData().getPosition().asVec3());
|
|
|
|
osg::Vec3f worldPos(ptr.getRefData().getPosition().asVec3());
|
|
|
|
worldPos += diff;
|
|
|
|
worldPos += diff;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// We should move actors, standing on moving object, too.
|
|
|
|
|
|
|
|
// This approach can be used to create elevators.
|
|
|
|
|
|
|
|
moveStandingActors(ptr, diff);
|
|
|
|
MWBase::Environment::get().getWorld()->moveObject(ptr, worldPos.x(), worldPos.y(), worldPos.z());
|
|
|
|
MWBase::Environment::get().getWorld()->moveObject(ptr, worldPos.x(), worldPos.y(), worldPos.z());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -688,22 +704,21 @@ namespace MWScript
|
|
|
|
runtime.pop();
|
|
|
|
runtime.pop();
|
|
|
|
|
|
|
|
|
|
|
|
const float *objPos = ptr.getRefData().getPosition().pos;
|
|
|
|
const float *objPos = ptr.getRefData().getPosition().pos;
|
|
|
|
|
|
|
|
osg::Vec3f diff;
|
|
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr updated;
|
|
|
|
|
|
|
|
if (axis == "x")
|
|
|
|
if (axis == "x")
|
|
|
|
{
|
|
|
|
diff.x() += movement;
|
|
|
|
updated = MWBase::Environment::get().getWorld()->moveObject(ptr, objPos[0]+movement, objPos[1], objPos[2]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (axis == "y")
|
|
|
|
else if (axis == "y")
|
|
|
|
{
|
|
|
|
diff.y() += movement;
|
|
|
|
updated = MWBase::Environment::get().getWorld()->moveObject(ptr, objPos[0], objPos[1]+movement, objPos[2]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (axis == "z")
|
|
|
|
else if (axis == "z")
|
|
|
|
{
|
|
|
|
diff.z() += movement;
|
|
|
|
updated = MWBase::Environment::get().getWorld()->moveObject(ptr, objPos[0], objPos[1], objPos[2]+movement);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
throw std::runtime_error ("invalid movement axis: " + axis);
|
|
|
|
throw std::runtime_error ("invalid movement axis: " + axis);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// We should move actors, standing on moving object, too.
|
|
|
|
|
|
|
|
// This approach can be used to create elevators.
|
|
|
|
|
|
|
|
moveStandingActors(ptr, diff);
|
|
|
|
|
|
|
|
MWBase::Environment::get().getWorld()->moveObject(ptr, objPos[0]+diff.x(), objPos[1]+diff.y(), objPos[2]+diff.z());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|