mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
Merge branch 'vec3_vs_xyz' into 'master'
Use Vec3f instead of x,y,z in World API See merge request OpenMW/openmw!730
This commit is contained in:
commit
5cdf1e7e6b
@ -283,10 +283,10 @@ namespace MWBase
|
||||
virtual void deleteObject (const MWWorld::Ptr& ptr) = 0;
|
||||
virtual void undeleteObject (const MWWorld::Ptr& ptr) = 0;
|
||||
|
||||
virtual MWWorld::Ptr moveObject (const MWWorld::Ptr& ptr, float x, float y, float z, bool movePhysics=true, bool moveToActive=false) = 0;
|
||||
virtual MWWorld::Ptr moveObject (const MWWorld::Ptr& ptr, const osg::Vec3f& position, bool movePhysics=true, bool moveToActive=false) = 0;
|
||||
///< @return an updated Ptr in case the Ptr's cell changes
|
||||
|
||||
virtual MWWorld::Ptr moveObject(const MWWorld::Ptr &ptr, MWWorld::CellStore* newCell, float x, float y, float z, bool movePhysics=true) = 0;
|
||||
virtual MWWorld::Ptr moveObject(const MWWorld::Ptr &ptr, MWWorld::CellStore* newCell, const osg::Vec3f& position, bool movePhysics=true) = 0;
|
||||
///< @return an updated Ptr
|
||||
|
||||
virtual MWWorld::Ptr moveObjectBy(const MWWorld::Ptr &ptr, osg::Vec3f vec, bool moveToActive, bool ignoreCollisions) = 0;
|
||||
@ -294,8 +294,7 @@ namespace MWBase
|
||||
|
||||
virtual void scaleObject (const MWWorld::Ptr& ptr, float scale) = 0;
|
||||
|
||||
virtual void rotateObject(const MWWorld::Ptr& ptr, float x, float y, float z,
|
||||
RotationFlags flags = RotationFlag_inverseOrder) = 0;
|
||||
virtual void rotateObject(const MWWorld::Ptr& ptr, const osg::Vec3f& rot, RotationFlags flags = RotationFlag_inverseOrder) = 0;
|
||||
|
||||
virtual MWWorld::Ptr placeObject(const MWWorld::ConstPtr& ptr, MWWorld::CellStore* cell, ESM::Position pos) = 0;
|
||||
///< Place an object. Makes a copy of the Ptr.
|
||||
|
@ -834,9 +834,7 @@ namespace MWClass
|
||||
ptr.getRefData().setCustomData(nullptr);
|
||||
|
||||
// Reset to original position
|
||||
MWBase::Environment::get().getWorld()->moveObject(ptr, ptr.getCellRef().getPosition().pos[0],
|
||||
ptr.getCellRef().getPosition().pos[1],
|
||||
ptr.getCellRef().getPosition().pos[2]);
|
||||
MWBase::Environment::get().getWorld()->moveObject(ptr, ptr.getCellRef().getPosition().asVec3());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1388,9 +1388,7 @@ namespace MWClass
|
||||
ptr.getRefData().setCustomData(nullptr);
|
||||
|
||||
// Reset to original position
|
||||
MWBase::Environment::get().getWorld()->moveObject(ptr, ptr.getCellRef().getPosition().pos[0],
|
||||
ptr.getCellRef().getPosition().pos[1],
|
||||
ptr.getCellRef().getPosition().pos[2]);
|
||||
MWBase::Environment::get().getWorld()->moveObject(ptr, ptr.getCellRef().getPosition().asVec3());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ namespace MWInput
|
||||
}
|
||||
else if (key == "playerlooking" && !value)
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->rotateObject(player.getPlayer(), 0.f, 0.f, 0.f);
|
||||
MWBase::Environment::get().getWorld()->rotateObject(player.getPlayer(), osg::Vec3f());
|
||||
}
|
||||
mSwitches[key] = value;
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ namespace MWLua
|
||||
}
|
||||
else
|
||||
{
|
||||
MWWorld::Ptr newObj = world->moveObject(obj, cell, mPos.x(), mPos.y(), mPos.z());
|
||||
world->rotateObject(newObj, mRot.x(), mRot.y(), mRot.z());
|
||||
MWWorld::Ptr newObj = world->moveObject(obj, cell, mPos);
|
||||
world->rotateObject(newObj, mRot);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,11 +93,12 @@ namespace MWMechanics
|
||||
|
||||
void AiTravel::fastForward(const MWWorld::Ptr& actor, AiState& state)
|
||||
{
|
||||
if (!isWithinMaxRange(osg::Vec3f(mX, mY, mZ), actor.getRefData().getPosition().asVec3()))
|
||||
osg::Vec3f pos(mX, mY, mZ);
|
||||
if (!isWithinMaxRange(pos, actor.getRefData().getPosition().asVec3()))
|
||||
return;
|
||||
// does not do any validation on the travel target (whether it's in air, inside collision geometry, etc),
|
||||
// that is the user's responsibility
|
||||
MWBase::Environment::get().getWorld()->moveObject(actor, mX, mY, mZ);
|
||||
MWBase::Environment::get().getWorld()->moveObject(actor, pos);
|
||||
actor.getClass().adjustPosition(actor, false);
|
||||
reset();
|
||||
}
|
||||
|
@ -744,8 +744,8 @@ namespace MWMechanics
|
||||
|
||||
state.moveIn(new AiWanderStorage());
|
||||
|
||||
MWBase::Environment::get().getWorld()->moveObject(actor, static_cast<float>(dest.mX),
|
||||
static_cast<float>(dest.mY), static_cast<float>(dest.mZ));
|
||||
osg::Vec3f pos(static_cast<float>(dest.mX), static_cast<float>(dest.mY), static_cast<float>(dest.mZ));
|
||||
MWBase::Environment::get().getWorld()->moveObject(actor, pos);
|
||||
actor.getClass().adjustPosition(actor, false);
|
||||
}
|
||||
|
||||
|
@ -2394,12 +2394,15 @@ void CharacterController::update(float duration)
|
||||
if(!isKnockedDown() && !isKnockedOut())
|
||||
{
|
||||
if (rot != osg::Vec3f())
|
||||
world->rotateObject(mPtr, rot.x(), rot.y(), rot.z(), true);
|
||||
world->rotateObject(mPtr, rot, true);
|
||||
}
|
||||
else //avoid z-rotating for knockdown
|
||||
{
|
||||
if (rot.x() != 0 && rot.y() != 0)
|
||||
world->rotateObject(mPtr, rot.x(), rot.y(), 0.0f, true);
|
||||
{
|
||||
rot.z() = 0.0f;
|
||||
world->rotateObject(mPtr, rot, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!mMovementAnimationControlled)
|
||||
|
@ -958,7 +958,7 @@ namespace MWPhysics
|
||||
if (mWaterCollision && mPosition.z() < mWaterlevel && canMoveToWaterSurface(mActorRaw, mWaterlevel, world))
|
||||
{
|
||||
mPosition.z() = mWaterlevel;
|
||||
MWBase::Environment::get().getWorld()->moveObject(mActorRaw->getPtr(), mPosition.x(), mPosition.y(), mPosition.z(), false);
|
||||
MWBase::Environment::get().getWorld()->moveObject(mActorRaw->getPtr(), mPosition, false);
|
||||
}
|
||||
mOldHeight = mPosition.z();
|
||||
mRefpos = mActorRaw->getPtr().getRefData().getPosition();
|
||||
|
@ -167,17 +167,17 @@ namespace MWScript
|
||||
// XYZ axis use the inverse (XYZ) rotation order like vanilla SetAngle.
|
||||
// UWV axis use the standard (ZYX) rotation order like TESCS/OpenMW-CS and the rest of the game.
|
||||
if (axis == "x")
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,angle,ay,az,MWBase::RotationFlag_inverseOrder);
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,osg::Vec3f(angle,ay,az),MWBase::RotationFlag_inverseOrder);
|
||||
else if (axis == "y")
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,angle,az,MWBase::RotationFlag_inverseOrder);
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,osg::Vec3f(ax,angle,az),MWBase::RotationFlag_inverseOrder);
|
||||
else if (axis == "z")
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,angle,MWBase::RotationFlag_inverseOrder);
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,osg::Vec3f(ax,ay,angle),MWBase::RotationFlag_inverseOrder);
|
||||
else if (axis == "u")
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,angle,ay,az,MWBase::RotationFlag_none);
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,osg::Vec3f(angle,ay,az),MWBase::RotationFlag_none);
|
||||
else if (axis == "w")
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,angle,az,MWBase::RotationFlag_none);
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,osg::Vec3f(ax,angle,az),MWBase::RotationFlag_none);
|
||||
else if (axis == "v")
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,angle,MWBase::RotationFlag_none);
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,osg::Vec3f(ax,ay,angle),MWBase::RotationFlag_none);
|
||||
}
|
||||
};
|
||||
|
||||
@ -393,17 +393,17 @@ namespace MWScript
|
||||
if(store)
|
||||
{
|
||||
MWWorld::Ptr base = ptr;
|
||||
ptr = MWBase::Environment::get().getWorld()->moveObject(ptr,store,x,y,z);
|
||||
ptr = MWBase::Environment::get().getWorld()->moveObject(ptr,store,osg::Vec3f(x,y,z));
|
||||
dynamic_cast<MWScript::InterpreterContext&>(runtime.getContext()).updatePtr(base,ptr);
|
||||
|
||||
float ax = ptr.getRefData().getPosition().rot[0];
|
||||
float ay = ptr.getRefData().getPosition().rot[1];
|
||||
auto rot = ptr.getRefData().getPosition().asRotationVec3();
|
||||
// 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.
|
||||
// See "Morrowind Scripting for Dummies (9th Edition)" pages 50 and 54 for reference.
|
||||
if(ptr != MWMechanics::getPlayer())
|
||||
zRot = zRot/60.0f;
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,osg::DegreesToRadians(zRot));
|
||||
rot.z() = osg::DegreesToRadians(zRot);
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,rot);
|
||||
|
||||
ptr.getClass().adjustPosition(ptr, false);
|
||||
}
|
||||
@ -444,22 +444,22 @@ namespace MWScript
|
||||
if (ptr == MWMechanics::getPlayer())
|
||||
{
|
||||
MWWorld::CellStore* cell = MWBase::Environment::get().getWorld()->getExterior(cx,cy);
|
||||
ptr = MWBase::Environment::get().getWorld()->moveObject(ptr,cell,x,y,z);
|
||||
ptr = MWBase::Environment::get().getWorld()->moveObject(ptr, cell, osg::Vec3(x, y, z));
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = MWBase::Environment::get().getWorld()->moveObject(ptr, x, y, z, true, true);
|
||||
ptr = MWBase::Environment::get().getWorld()->moveObject(ptr, osg::Vec3f(x, y, z), true, true);
|
||||
}
|
||||
dynamic_cast<MWScript::InterpreterContext&>(runtime.getContext()).updatePtr(base,ptr);
|
||||
|
||||
float ax = ptr.getRefData().getPosition().rot[0];
|
||||
float ay = ptr.getRefData().getPosition().rot[1];
|
||||
auto rot = ptr.getRefData().getPosition().asRotationVec3();
|
||||
// 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.
|
||||
// See "Morrowind Scripting for Dummies (9th Edition)" pages 50 and 54 for reference.
|
||||
if(ptr != MWMechanics::getPlayer())
|
||||
zRot = zRot/60.0f;
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,osg::DegreesToRadians(zRot));
|
||||
rot.z() = osg::DegreesToRadians(zRot);
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,rot);
|
||||
ptr.getClass().adjustPosition(ptr, false);
|
||||
}
|
||||
};
|
||||
@ -621,16 +621,14 @@ namespace MWScript
|
||||
Interpreter::Type_Float rotation = osg::DegreesToRadians(runtime[0].mFloat*MWBase::Environment::get().getFrameDuration());
|
||||
runtime.pop();
|
||||
|
||||
float ax = ptr.getRefData().getPosition().rot[0];
|
||||
float ay = ptr.getRefData().getPosition().rot[1];
|
||||
float az = ptr.getRefData().getPosition().rot[2];
|
||||
|
||||
auto rot = ptr.getRefData().getPosition().asRotationVec3();
|
||||
if (axis == "x")
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax+rotation,ay,az);
|
||||
rot.x() += rotation;
|
||||
else if (axis == "y")
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay+rotation,az);
|
||||
rot.y() += rotation;
|
||||
else if (axis == "z")
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,az+rotation);
|
||||
rot.z() += rotation;
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr,rot);
|
||||
}
|
||||
};
|
||||
|
||||
@ -682,15 +680,10 @@ namespace MWScript
|
||||
if (!ptr.isInCell())
|
||||
return;
|
||||
|
||||
float xr = ptr.getCellRef().getPosition().rot[0];
|
||||
float yr = ptr.getCellRef().getPosition().rot[1];
|
||||
float zr = ptr.getCellRef().getPosition().rot[2];
|
||||
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr, xr, yr, zr);
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr, ptr.getCellRef().getPosition().asRotationVec3());
|
||||
|
||||
dynamic_cast<MWScript::InterpreterContext&>(runtime.getContext()).updatePtr(ptr,
|
||||
MWBase::Environment::get().getWorld()->moveObject(ptr, ptr.getCellRef().getPosition().pos[0],
|
||||
ptr.getCellRef().getPosition().pos[1], ptr.getCellRef().getPosition().pos[2]));
|
||||
MWBase::Environment::get().getWorld()->moveObject(ptr, ptr.getCellRef().getPosition().asVec3()));
|
||||
|
||||
}
|
||||
};
|
||||
|
@ -55,10 +55,10 @@ namespace MWWorld
|
||||
int cellY;
|
||||
world->positionToIndex(mPosition.pos[0],mPosition.pos[1],cellX,cellY);
|
||||
world->moveObject(actor,world->getExterior(cellX,cellY),
|
||||
mPosition.pos[0],mPosition.pos[1],mPosition.pos[2]);
|
||||
mPosition.asVec3());
|
||||
}
|
||||
else
|
||||
world->moveObject(actor,world->getInterior(mCellName),mPosition.pos[0],mPosition.pos[1],mPosition.pos[2]);
|
||||
world->moveObject(actor,world->getInterior(mCellName),mPosition.asVec3());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ namespace
|
||||
const ESM::Position & newpos = iter->mData.getPosition();
|
||||
const MWWorld::Ptr ptr(&*iter, cellstore);
|
||||
if ((oldscale != iter->mRef.getScale() || oldpos.asVec3() != newpos.asVec3() || oldpos.rot[0] != newpos.rot[0] || oldpos.rot[1] != newpos.rot[1] || oldpos.rot[2] != newpos.rot[2]) && !ptr.getClass().isActor())
|
||||
MWBase::Environment::get().getWorld()->moveObject(ptr, newpos.pos[0], newpos.pos[1], newpos.pos[2]);
|
||||
MWBase::Environment::get().getWorld()->moveObject(ptr, newpos.asVec3());
|
||||
if (!iter->mData.isEnabled())
|
||||
{
|
||||
iter->mData.enable();
|
||||
|
@ -842,12 +842,8 @@ namespace MWWorld
|
||||
mRendering.updatePlayerPtr(player);
|
||||
|
||||
if (adjustPlayerPos) {
|
||||
world->moveObject(player, pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||
|
||||
float x = pos.rot[0];
|
||||
float y = pos.rot[1];
|
||||
float z = pos.rot[2];
|
||||
world->rotateObject(player, x, y, z);
|
||||
world->moveObject(player, pos.asVec3());
|
||||
world->rotateObject(player, pos.asRotationVec3());
|
||||
|
||||
player.getClass().adjustPosition(player, true);
|
||||
}
|
||||
@ -921,12 +917,8 @@ namespace MWWorld
|
||||
if(mCurrentCell != nullptr && *mCurrentCell == *cell)
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
world->moveObject(world->getPlayerPtr(), position.pos[0], position.pos[1], position.pos[2]);
|
||||
|
||||
float x = position.rot[0];
|
||||
float y = position.rot[1];
|
||||
float z = position.rot[2];
|
||||
world->rotateObject(world->getPlayerPtr(), x, y, z);
|
||||
world->moveObject(world->getPlayerPtr(), position.asVec3());
|
||||
world->rotateObject(world->getPlayerPtr(), position.asRotationVec3());
|
||||
|
||||
if (adjustPlayerPos)
|
||||
world->getPlayerPtr().getClass().adjustPosition(world->getPlayerPtr(), true);
|
||||
|
@ -1128,18 +1128,12 @@ namespace MWWorld
|
||||
}
|
||||
}
|
||||
|
||||
MWWorld::Ptr World::moveObject(const Ptr &ptr, CellStore* newCell, float x, float y, float z, bool movePhysics)
|
||||
MWWorld::Ptr World::moveObject(const Ptr &ptr, CellStore* newCell, const osg::Vec3f& position, bool movePhysics)
|
||||
{
|
||||
ESM::Position pos = ptr.getRefData().getPosition();
|
||||
|
||||
pos.pos[0] = x;
|
||||
pos.pos[1] = y;
|
||||
pos.pos[2] = z;
|
||||
|
||||
std::memcpy(pos.pos, &position, sizeof(osg::Vec3f));
|
||||
ptr.getRefData().setPosition(pos);
|
||||
|
||||
osg::Vec3f vec(x, y, z);
|
||||
|
||||
CellStore *currCell = ptr.isInCell() ? ptr.getCell() : nullptr; // currCell == nullptr should only happen for player, during initial startup
|
||||
bool isPlayer = ptr == mPlayer->getPlayer();
|
||||
bool haveToMove = isPlayer || (currCell && mWorldScene->isCellActive(*currCell));
|
||||
@ -1228,7 +1222,7 @@ namespace MWWorld
|
||||
}
|
||||
if (haveToMove && newPtr.getRefData().getBaseNode())
|
||||
{
|
||||
mWorldScene->updateObjectPosition(newPtr, vec, movePhysics);
|
||||
mWorldScene->updateObjectPosition(newPtr, position, movePhysics);
|
||||
if (movePhysics)
|
||||
{
|
||||
if (const auto object = mPhysics->getObject(ptr))
|
||||
@ -1237,7 +1231,7 @@ namespace MWWorld
|
||||
}
|
||||
|
||||
if (isPlayer)
|
||||
mWorldScene->playerMoved(vec);
|
||||
mWorldScene->playerMoved(position);
|
||||
else
|
||||
{
|
||||
mRendering->pagingBlacklistObject(mStore.find(ptr.getCellRef().getRefId()), ptr);
|
||||
@ -1247,10 +1241,10 @@ namespace MWWorld
|
||||
return newPtr;
|
||||
}
|
||||
|
||||
MWWorld::Ptr World::moveObject (const Ptr& ptr, float x, float y, float z, bool movePhysics, bool moveToActive)
|
||||
MWWorld::Ptr World::moveObject(const Ptr& ptr, const osg::Vec3f& position, bool movePhysics, bool moveToActive)
|
||||
{
|
||||
int cellX, cellY;
|
||||
positionToIndex(x, y, cellX, cellY);
|
||||
positionToIndex(position.x(), position.y(), cellX, cellY);
|
||||
|
||||
CellStore* cell = ptr.getCell();
|
||||
CellStore* newCell = getExterior(cellX, cellY);
|
||||
@ -1259,7 +1253,7 @@ namespace MWWorld
|
||||
if (cell->isExterior() || (moveToActive && isCellActive && ptr.getClass().isActor()))
|
||||
cell = newCell;
|
||||
|
||||
return moveObject(ptr, cell, x, y, z, movePhysics);
|
||||
return moveObject(ptr, cell, position, movePhysics);
|
||||
}
|
||||
|
||||
MWWorld::Ptr World::moveObjectBy(const Ptr& ptr, osg::Vec3f vec, bool moveToActive, bool ignoreCollisions)
|
||||
@ -1269,8 +1263,8 @@ namespace MWWorld
|
||||
if (actor)
|
||||
actor->adjustPosition(vec, ignoreCollisions);
|
||||
if (ptr.getClass().isActor())
|
||||
return moveObject(ptr, newpos.x(), newpos.y(), newpos.z(), false, moveToActive && ptr != getPlayerPtr());
|
||||
return moveObject(ptr, newpos.x(), newpos.y(), newpos.z());
|
||||
return moveObject(ptr, newpos, false, moveToActive && ptr != getPlayerPtr());
|
||||
return moveObject(ptr, newpos);
|
||||
}
|
||||
|
||||
void World::scaleObject (const Ptr& ptr, float scale)
|
||||
@ -1294,7 +1288,7 @@ namespace MWWorld
|
||||
updateNavigatorObject(*object);
|
||||
}
|
||||
|
||||
void World::rotateObjectImp(const Ptr& ptr, const osg::Vec3f& rot, MWBase::RotationFlags flags)
|
||||
void World::rotateObject(const Ptr& ptr, const osg::Vec3f& rot, MWBase::RotationFlags flags)
|
||||
{
|
||||
const float pi = static_cast<float>(osg::PI);
|
||||
|
||||
@ -1377,7 +1371,7 @@ namespace MWWorld
|
||||
pos.z() = std::min(pos.z(), traced.z());
|
||||
}
|
||||
|
||||
moveObject(ptr, ptr.getCell(), pos.x(), pos.y(), pos.z());
|
||||
moveObject(ptr, ptr.getCell(), pos);
|
||||
}
|
||||
|
||||
void World::fixPosition()
|
||||
@ -1416,11 +1410,6 @@ namespace MWWorld
|
||||
}
|
||||
}
|
||||
|
||||
void World::rotateObject (const Ptr& ptr, float x, float y, float z, MWBase::RotationFlags flags)
|
||||
{
|
||||
rotateObjectImp(ptr, osg::Vec3f(x, y, z), flags);
|
||||
}
|
||||
|
||||
void World::rotateWorldObject (const Ptr& ptr, osg::Quat rotate)
|
||||
{
|
||||
if(ptr.getRefData().getBaseNode() != nullptr)
|
||||
@ -1536,7 +1525,7 @@ namespace MWWorld
|
||||
auto* physactor = mPhysics->getActor(actor);
|
||||
assert(physactor);
|
||||
const auto position = physactor->getSimulationPosition();
|
||||
moveObject(actor, position.x(), position.y(), position.z(), false, false);
|
||||
moveObject(actor, position, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1546,7 +1535,7 @@ namespace MWWorld
|
||||
auto* physactor = mPhysics->getActor(*player);
|
||||
assert(physactor);
|
||||
const auto position = physactor->getSimulationPosition();
|
||||
moveObject(*player, position.x(), position.y(), position.z(), false, false);
|
||||
moveObject(*player, position, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1604,14 +1593,16 @@ namespace MWWorld
|
||||
bool World::rotateDoor(const Ptr door, MWWorld::DoorState state, float duration)
|
||||
{
|
||||
const ESM::Position& objPos = door.getRefData().getPosition();
|
||||
float oldRot = objPos.rot[2];
|
||||
auto oldRot = objPos.asRotationVec3();
|
||||
auto newRot = oldRot;
|
||||
|
||||
float minRot = door.getCellRef().getPosition().rot[2];
|
||||
float maxRot = minRot + osg::DegreesToRadians(90.f);
|
||||
|
||||
float diff = duration * osg::DegreesToRadians(90.f) * (state == MWWorld::DoorState::Opening ? 1 : -1);
|
||||
float targetRot = std::min(std::max(minRot, oldRot + diff), maxRot);
|
||||
rotateObject(door, objPos.rot[0], objPos.rot[1], targetRot, MWBase::RotationFlag_none);
|
||||
float targetRot = std::clamp(oldRot.z() + diff, minRot, maxRot);
|
||||
newRot.z() = targetRot;
|
||||
rotateObject(door, newRot, MWBase::RotationFlag_none);
|
||||
|
||||
bool reached = (targetRot == maxRot && state != MWWorld::DoorState::Idle) || targetRot == minRot;
|
||||
|
||||
@ -1662,7 +1653,7 @@ namespace MWWorld
|
||||
MWBase::Environment::get().getSoundManager()->stopSound3D(door, closeSound);
|
||||
}
|
||||
|
||||
rotateObject(door, objPos.rot[0], objPos.rot[1], oldRot, MWBase::RotationFlag_none);
|
||||
rotateObject(door, oldRot, MWBase::RotationFlag_none);
|
||||
}
|
||||
|
||||
return reached;
|
||||
@ -2279,7 +2270,7 @@ namespace MWWorld
|
||||
pos.pos[0] -= adjust.x();
|
||||
pos.pos[1] -= adjust.y();
|
||||
pos.pos[2] -= adjust.z();
|
||||
moveObject(dropped, pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||
moveObject(dropped, pos.asVec3());
|
||||
}
|
||||
}
|
||||
|
||||
@ -2513,7 +2504,7 @@ namespace MWWorld
|
||||
player.getClass().getInventoryStore(player).setContListener(anim);
|
||||
|
||||
scaleObject(player, player.getCellRef().getScale()); // apply race height
|
||||
rotateObject(player, 0.f, 0.f, 0.f, MWBase::RotationFlag_inverseOrder | MWBase::RotationFlag_adjust);
|
||||
rotateObject(player, osg::Vec3f(), MWBase::RotationFlag_inverseOrder | MWBase::RotationFlag_adjust);
|
||||
|
||||
MWBase::Environment::get().getMechanicsManager()->add(getPlayerPtr());
|
||||
MWBase::Environment::get().getWindowManager()->watchActor(getPlayerPtr());
|
||||
@ -3859,8 +3850,8 @@ namespace MWWorld
|
||||
return true;
|
||||
|
||||
const ESM::Position& origPos = ptr.getCellRef().getPosition();
|
||||
MWBase::Environment::get().getWorld()->moveObject(ptr, origPos.pos[0], origPos.pos[1], origPos.pos[2]);
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr, origPos.rot[0], origPos.rot[1], origPos.rot[2]);
|
||||
MWBase::Environment::get().getWorld()->moveObject(ptr, origPos.asVec3());
|
||||
MWBase::Environment::get().getWorld()->rotateObject(ptr, origPos.asRotationVec3());
|
||||
ptr.getClass().adjustPosition(ptr, true);
|
||||
}
|
||||
return true;
|
||||
|
@ -133,8 +133,6 @@ namespace MWWorld
|
||||
|
||||
void updateWeather(float duration, bool paused = false);
|
||||
|
||||
void rotateObjectImp (const Ptr& ptr, const osg::Vec3f& rot, MWBase::RotationFlags flags);
|
||||
|
||||
Ptr copyObjectToCell(const ConstPtr &ptr, CellStore* cell, ESM::Position pos, int count, bool adjustPos);
|
||||
|
||||
void updateSoundListener();
|
||||
@ -372,10 +370,10 @@ namespace MWWorld
|
||||
|
||||
void undeleteObject (const Ptr& ptr) override;
|
||||
|
||||
MWWorld::Ptr moveObject (const Ptr& ptr, float x, float y, float z, bool movePhysics=true, bool moveToActive=false) override;
|
||||
MWWorld::Ptr moveObject (const Ptr& ptr, const osg::Vec3f& position, bool movePhysics=true, bool moveToActive=false) override;
|
||||
///< @return an updated Ptr in case the Ptr's cell changes
|
||||
|
||||
MWWorld::Ptr moveObject (const Ptr& ptr, CellStore* newCell, float x, float y, float z, bool movePhysics=true) override;
|
||||
MWWorld::Ptr moveObject (const Ptr& ptr, CellStore* newCell, const osg::Vec3f& position, bool movePhysics=true) override;
|
||||
///< @return an updated Ptr
|
||||
|
||||
MWWorld::Ptr moveObjectBy(const Ptr& ptr, osg::Vec3f vec, bool moveToActive, bool ignoreCollisions) override;
|
||||
@ -387,8 +385,7 @@ namespace MWWorld
|
||||
/// @note Rotations via this method use a different rotation order than the initial rotations in the CS. This
|
||||
/// could be considered a bug, but is needed for MW compatibility.
|
||||
/// \param adjust indicates rotation should be set or adjusted
|
||||
void rotateObject (const Ptr& ptr, float x, float y, float z,
|
||||
MWBase::RotationFlags flags = MWBase::RotationFlag_inverseOrder) override;
|
||||
void rotateObject (const Ptr& ptr, const osg::Vec3f& rot, MWBase::RotationFlags flags = MWBase::RotationFlag_inverseOrder) override;
|
||||
|
||||
MWWorld::Ptr placeObject(const MWWorld::ConstPtr& ptr, MWWorld::CellStore* cell, ESM::Position pos) override;
|
||||
///< Place an object. Makes a copy of the Ptr.
|
||||
|
Loading…
x
Reference in New Issue
Block a user