mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-04 04:45:35 +00:00
Check if the actor still exists /first/
This commit is contained in:
parent
a72cd896ca
commit
25d64989b3
1 changed files with 19 additions and 25 deletions
|
@ -1309,12 +1309,16 @@ namespace MWPhysics
|
|||
PtrVelocityList::iterator iter = mMovementQueue.begin();
|
||||
for(;iter != mMovementQueue.end();++iter)
|
||||
{
|
||||
ActorMap::iterator foundActor = mActors.find(iter->first);
|
||||
if (foundActor == mActors.end()) // actor was already removed from the scene
|
||||
continue;
|
||||
Actor* physicActor = foundActor->second;
|
||||
|
||||
float waterlevel = -std::numeric_limits<float>::max();
|
||||
const MWWorld::CellStore *cell = iter->first.getCell();
|
||||
if(cell->getCell()->hasWater())
|
||||
waterlevel = cell->getWaterLevel();
|
||||
|
||||
|
||||
const MWMechanics::MagicEffects& effects = iter->first.getClass().getCreatureStats(iter->first).getMagicEffects();
|
||||
|
||||
bool waterCollision = false;
|
||||
|
@ -1322,20 +1326,16 @@ namespace MWPhysics
|
|||
{
|
||||
if (!world->isUnderwater(iter->first.getCell(), osg::Vec3f(iter->first.getRefData().getPosition().asVec3())))
|
||||
waterCollision = true;
|
||||
else
|
||||
else if (physicActor->getCollisionMode())
|
||||
{
|
||||
Actor *actor = getActor(iter->first);
|
||||
// Actor can collide
|
||||
if (actor->getCollisionMode())
|
||||
{
|
||||
const osg::Vec3f actorPosition = actor->getPosition();
|
||||
const osg::Vec3f actorPosition = physicActor->getPosition();
|
||||
const osg::Vec3f destinationPosition(actorPosition.x(), actorPosition.y(), waterlevel);
|
||||
ActorTracer tracer;
|
||||
tracer.doTrace(actor->getCollisionObject(), actorPosition, destinationPosition, mCollisionWorld);
|
||||
tracer.doTrace(physicActor->getCollisionObject(), actorPosition, destinationPosition, mCollisionWorld);
|
||||
if (tracer.mFraction >= 1.0f)
|
||||
{
|
||||
waterCollision = true;
|
||||
actor->setPosition(destinationPosition);
|
||||
physicActor->setPosition(destinationPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1345,12 +1345,6 @@ namespace MWPhysics
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ActorMap::iterator foundActor = mActors.find(iter->first);
|
||||
if (foundActor == mActors.end()) // actor was already removed from the scene
|
||||
continue;
|
||||
Actor* physicActor = foundActor->second;
|
||||
physicActor->setCanWaterWalk(waterCollision);
|
||||
|
||||
// Slow fall reduces fall speed by a factor of (effect magnitude / 200)
|
||||
|
|
Loading…
Reference in a new issue