diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 6e8d58642..1728af659 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -312,7 +312,7 @@ namespace MWBase virtual bool castRay (float x1, float y1, float z1, float x2, float y2, float z2) = 0; - virtual void setActorCollisionMode(const MWWorld::Ptr& ptr, bool enabled) = 0; + virtual void setActorCollisionMode(const MWWorld::Ptr& ptr, bool internal, bool external) = 0; virtual bool isActorCollisionEnabled(const MWWorld::Ptr& ptr) = 0; virtual bool toggleCollisionMode() = 0; diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 03ed862e6..769425053 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -1457,7 +1457,7 @@ namespace MWMechanics if (!inRange) { iter->first.getRefData().getBaseNode()->setNodeMask(0); - world->setActorCollisionMode(iter->first, false); + world->setActorCollisionMode(iter->first, false, false); continue; } else if (!isPlayer) @@ -1474,7 +1474,7 @@ namespace MWMechanics continue; } - world->setActorCollisionMode(iter->first, true); + world->setActorCollisionMode(iter->first, true, !iter->first.getClass().getCreatureStats(iter->first).isDeathAnimationFinished()); ctrl->update(duration); // Fade away actors on large distance (>90% of actor's processing distance) diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index c1a08227e..18fc06481 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -1216,33 +1216,6 @@ namespace MWPhysics return false; } - void PhysicsSystem::setActorCollisionMode(const MWWorld::Ptr& ptr, bool enabled) - { - ActorMap::iterator found = mActors.find(ptr); - if (found != mActors.end()) - { - bool cmode = found->second->getCollisionMode(); - if (cmode == enabled) - return; - - cmode = enabled; - found->second->enableCollisionMode(cmode); - found->second->enableCollisionBody(cmode); - } - } - - bool PhysicsSystem::isActorCollisionEnabled(const MWWorld::Ptr& ptr) - { - ActorMap::iterator found = mActors.find(ptr); - if (found != mActors.end()) - { - bool cmode = found->second->getCollisionMode(); - return cmode; - } - - return false; - } - void PhysicsSystem::queueObjectMovement(const MWWorld::Ptr &ptr, const osg::Vec3f &movement) { PtrVelocityList::iterator iter = mMovementQueue.begin(); diff --git a/apps/openmw/mwphysics/physicssystem.hpp b/apps/openmw/mwphysics/physicssystem.hpp index 7d7f5a33c..76fbcf8c6 100644 --- a/apps/openmw/mwphysics/physicssystem.hpp +++ b/apps/openmw/mwphysics/physicssystem.hpp @@ -92,8 +92,6 @@ namespace MWPhysics const HeightField* getHeightField(int x, int y) const; bool toggleCollisionMode(); - bool isActorCollisionEnabled(const MWWorld::Ptr& ptr); - void setActorCollisionMode(const MWWorld::Ptr& ptr, bool enabled); void stepSimulation(float dt); void debugDraw(); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 35d653f7d..672e6db24 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1684,14 +1684,20 @@ namespace MWWorld } } - void World::setActorCollisionMode(const MWWorld::Ptr& ptr, bool enabled) + void World::setActorCollisionMode(const MWWorld::Ptr& ptr, bool internal, bool external) { - mPhysics->setActorCollisionMode(ptr, enabled); + MWPhysics::Actor *physicActor = mPhysics->getActor(ptr); + if (physicActor && physicActor->getCollisionMode() != internal) + { + physicActor->enableCollisionMode(internal); + physicActor->enableCollisionBody(external); + } } bool World::isActorCollisionEnabled(const MWWorld::Ptr& ptr) { - return mPhysics->isActorCollisionEnabled(ptr); + MWPhysics::Actor *physicActor = mPhysics->getActor(ptr); + return physicActor && physicActor->getCollisionMode(); } bool World::toggleCollisionMode() diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 07679d139..98e82bb86 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -421,7 +421,7 @@ namespace MWWorld bool castRay (float x1, float y1, float z1, float x2, float y2, float z2) override; - void setActorCollisionMode(const Ptr& ptr, bool enabled) override; + void setActorCollisionMode(const Ptr& ptr, bool internal, bool external) override; bool isActorCollisionEnabled(const Ptr& ptr) override; bool toggleCollisionMode() override;