mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 16:06:44 +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);
|
moveObjectImp(player->first, vec.x, vec.y, vec.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
processDoors(duration);
|
||||||
|
|
||||||
|
mPhysEngine->stepSimulation (duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::processDoors(float duration)
|
||||||
|
{
|
||||||
// doors
|
// doors
|
||||||
for (std::map<MWWorld::Ptr, int>::iterator it = mDoorStates.begin(); it != mDoorStates.end(); ++it)
|
for (std::map<MWWorld::Ptr, int>::iterator it = mDoorStates.begin(); it != mDoorStates.end(); ++it)
|
||||||
{
|
{
|
||||||
if (!it->first.getRefData().getCount())
|
if (it->first.isEmpty() || !it->first.getRefData().getCount())
|
||||||
mDoorStates.erase(it);
|
mDoorStates.erase(it++);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mPlayer->getPlayer().getCell() != it->first.getCell())
|
if (!mWorldScene->isCellActive(*it->first.getCell()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float oldRot = Ogre::Radian(it->first.getRefData().getLocalRotation().rot[2]).valueDegrees();
|
float oldRot = Ogre::Radian(it->first.getRefData().getLocalRotation().rot[2]).valueDegrees();
|
||||||
float diff = duration * 90 * (it->second ? 1 : -1);
|
float diff = duration * 90 * (it->second ? 1 : -1);
|
||||||
float targetRot = std::min(std::max(0.f, oldRot + diff), 90.f);
|
float targetRot = std::min(std::max(0.f, oldRot + diff), 90.f);
|
||||||
|
@ -1016,8 +1024,6 @@ namespace MWWorld
|
||||||
mDoorStates.erase(it);
|
mDoorStates.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mPhysEngine->stepSimulation (duration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool World::toggleCollisionMode()
|
bool World::toggleCollisionMode()
|
||||||
|
|
|
@ -272,6 +272,9 @@ namespace MWWorld
|
||||||
virtual void doPhysics(const PtrMovementList &actors, float duration);
|
virtual void doPhysics(const PtrMovementList &actors, float duration);
|
||||||
///< Run physics simulation and modify \a world accordingly.
|
///< Run physics simulation and modify \a world accordingly.
|
||||||
|
|
||||||
|
virtual void processDoors(float duration);
|
||||||
|
///< Run physics simulation and modify \a world accordingly.
|
||||||
|
|
||||||
virtual bool toggleCollisionMode();
|
virtual bool toggleCollisionMode();
|
||||||
///< Toggle collision mode for player. If disabled player object should ignore
|
///< Toggle collision mode for player. If disabled player object should ignore
|
||||||
/// collisions and gravity.
|
/// collisions and gravity.
|
||||||
|
|
Loading…
Reference in a new issue