|
|
|
@ -1617,7 +1617,7 @@ namespace MWWorld
|
|
|
|
|
return result.mHit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool World::rotateDoor(const Ptr door, int state, float duration)
|
|
|
|
|
bool World::rotateDoor(const Ptr door, MWWorld::DoorState state, float duration)
|
|
|
|
|
{
|
|
|
|
|
const ESM::Position& objPos = door.getRefData().getPosition();
|
|
|
|
|
float oldRot = objPos.rot[2];
|
|
|
|
@ -1626,10 +1626,10 @@ namespace MWWorld
|
|
|
|
|
float maxRot = minRot + osg::DegreesToRadians(90.f);
|
|
|
|
|
|
|
|
|
|
float diff = duration * osg::DegreesToRadians(90.f);
|
|
|
|
|
float targetRot = std::min(std::max(minRot, oldRot + diff * (state == 1 ? 1 : -1)), maxRot);
|
|
|
|
|
float targetRot = std::min(std::max(minRot, oldRot + diff * (state == MWWorld::DoorState::Opening ? 1 : -1)), maxRot);
|
|
|
|
|
rotateObject(door, objPos.rot[0], objPos.rot[1], targetRot);
|
|
|
|
|
|
|
|
|
|
bool reached = (targetRot == maxRot && state) || targetRot == minRot;
|
|
|
|
|
bool reached = (targetRot == maxRot && state != MWWorld::DoorState::Idle) || targetRot == minRot;
|
|
|
|
|
|
|
|
|
|
/// \todo should use convexSweepTest here
|
|
|
|
|
std::vector<MWWorld::Ptr> collisions = mPhysics->getCollisions(door, MWPhysics::CollisionType_Door, MWPhysics::CollisionType_Actor);
|
|
|
|
@ -1658,7 +1658,7 @@ namespace MWWorld
|
|
|
|
|
|
|
|
|
|
void World::processDoors(float duration)
|
|
|
|
|
{
|
|
|
|
|
std::map<MWWorld::Ptr, int>::iterator it = mDoorStates.begin();
|
|
|
|
|
auto it = mDoorStates.begin();
|
|
|
|
|
while (it != mDoorStates.end())
|
|
|
|
|
{
|
|
|
|
|
if (!mWorldScene->isCellActive(*it->first.getCell()) || !it->first.getRefData().getBaseNode())
|
|
|
|
@ -1675,7 +1675,7 @@ namespace MWWorld
|
|
|
|
|
if (reached)
|
|
|
|
|
{
|
|
|
|
|
// Mark as non-moving
|
|
|
|
|
it->first.getClass().setDoorState(it->first, 0);
|
|
|
|
|
it->first.getClass().setDoorState(it->first, MWWorld::DoorState::Idle);
|
|
|
|
|
mDoorStates.erase(it++);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -2510,32 +2510,32 @@ namespace MWWorld
|
|
|
|
|
|
|
|
|
|
void World::activateDoor(const MWWorld::Ptr& door)
|
|
|
|
|
{
|
|
|
|
|
int state = door.getClass().getDoorState(door);
|
|
|
|
|
auto state = door.getClass().getDoorState(door);
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
case MWWorld::DoorState::Idle:
|
|
|
|
|
if (door.getRefData().getPosition().rot[2] == door.getCellRef().getPosition().rot[2])
|
|
|
|
|
state = 1; // if closed, then open
|
|
|
|
|
state = MWWorld::DoorState::Opening; // if closed, then open
|
|
|
|
|
else
|
|
|
|
|
state = 2; // if open, then close
|
|
|
|
|
state = MWWorld::DoorState::Closing; // if open, then close
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
state = 1; // if closing, then open
|
|
|
|
|
case MWWorld::DoorState::Closing:
|
|
|
|
|
state = MWWorld::DoorState::Opening; // if closing, then open
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
case MWWorld::DoorState::Opening:
|
|
|
|
|
default:
|
|
|
|
|
state = 2; // if opening, then close
|
|
|
|
|
state = MWWorld::DoorState::Closing; // if opening, then close
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
door.getClass().setDoorState(door, state);
|
|
|
|
|
mDoorStates[door] = state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void World::activateDoor(const Ptr &door, int state)
|
|
|
|
|
void World::activateDoor(const Ptr &door, MWWorld::DoorState state)
|
|
|
|
|
{
|
|
|
|
|
door.getClass().setDoorState(door, state);
|
|
|
|
|
mDoorStates[door] = state;
|
|
|
|
|
if (state == 0)
|
|
|
|
|
if (state == MWWorld::DoorState::Idle)
|
|
|
|
|
{
|
|
|
|
|
mDoorStates.erase(door);
|
|
|
|
|
rotateDoor(door, state, 1);
|
|
|
|
|