mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:23:52 +00:00
Put door physics in a separate method, some fixes
This commit is contained in:
parent
9343b4459e
commit
4ee1a6ee02
2 changed files with 14 additions and 5 deletions
|
@ -979,15 +979,23 @@ namespace MWWorld
|
|||
moveObjectImp(player->first, vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
processDoors(duration);
|
||||
|
||||
mPhysEngine->stepSimulation (duration);
|
||||
}
|
||||
|
||||
void World::processDoors(float duration)
|
||||
{
|
||||
// doors
|
||||
for (std::map<MWWorld::Ptr, int>::iterator it = mDoorStates.begin(); it != mDoorStates.end(); ++it)
|
||||
{
|
||||
if (!it->first.getRefData().getCount())
|
||||
mDoorStates.erase(it);
|
||||
if (it->first.isEmpty() || !it->first.getRefData().getCount())
|
||||
mDoorStates.erase(it++);
|
||||
else
|
||||
{
|
||||
if (mPlayer->getPlayer().getCell() != it->first.getCell())
|
||||
if (!mWorldScene->isCellActive(*it->first.getCell()))
|
||||
continue;
|
||||
|
||||
float oldRot = Ogre::Radian(it->first.getRefData().getLocalRotation().rot[2]).valueDegrees();
|
||||
float diff = duration * 90 * (it->second ? 1 : -1);
|
||||
float targetRot = std::min(std::max(0.f, oldRot + diff), 90.f);
|
||||
|
@ -1016,8 +1024,6 @@ namespace MWWorld
|
|||
mDoorStates.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
mPhysEngine->stepSimulation (duration);
|
||||
}
|
||||
|
||||
bool World::toggleCollisionMode()
|
||||
|
|
|
@ -272,6 +272,9 @@ namespace MWWorld
|
|||
virtual void doPhysics(const PtrMovementList &actors, float duration);
|
||||
///< Run physics simulation and modify \a world accordingly.
|
||||
|
||||
virtual void processDoors(float duration);
|
||||
///< Run physics simulation and modify \a world accordingly.
|
||||
|
||||
virtual bool toggleCollisionMode();
|
||||
///< Toggle collision mode for player. If disabled player object should ignore
|
||||
/// collisions and gravity.
|
||||
|
|
Loading…
Reference in a new issue