1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-21 09:39:56 +00:00

Merge branch 'filter_physics_actors' into 'master'

Do not perform physics simulation for actors outside processing range

See merge request OpenMW/openmw!1934
This commit is contained in:
psi29a 2022-05-29 19:19:35 +00:00
commit af82140dda
7 changed files with 22 additions and 1 deletions

View File

@ -669,6 +669,8 @@ namespace MWBase
virtual MWRender::RenderingManager* getRenderingManager() = 0;
virtual MWRender::PostProcessor* getPostProcessor() = 0;
virtual void setActorActive(const MWWorld::Ptr& ptr, bool value) = 0;
};
}

View File

@ -1593,10 +1593,12 @@ namespace MWMechanics
if (!inRange)
{
actor.getPtr().getRefData().getBaseNode()->setNodeMask(0);
world->setActorCollisionMode(actor.getPtr(), false, false);
world->setActorActive(actor.getPtr(), false);
continue;
}
world->setActorActive(actor.getPtr(), true);
const bool isDead = actor.getPtr().getClass().getCreatureStats(actor.getPtr()).isDead();
if (!isDead && (!godmode || !isPlayer) && actor.getPtr().getClass().getCreatureStats(actor.getPtr()).isParalyzed())
ctrl.skipAnim();

View File

@ -27,6 +27,7 @@ Actor::Actor(const MWWorld::Ptr& ptr, const Resource::BulletShape* shape, Physic
, mForce(0.f, 0.f, 0.f), mOnGround(true), mOnSlope(false)
, mInternalCollisionMode(true)
, mExternalCollisionMode(true)
, mActive(false)
, mTaskScheduler(scheduler)
{
mPtr = ptr;

View File

@ -152,6 +152,10 @@ namespace MWPhysics
bool canMoveToWaterSurface(float waterlevel, const btCollisionWorld* world) const;
bool isActive() const { return mActive; }
void setActive(bool value) { mActive = value; }
private:
MWWorld::Ptr mStandingOnPtr;
/// Removes then re-adds the collision object to the dynamics world
@ -190,6 +194,7 @@ namespace MWPhysics
bool mOnSlope;
bool mInternalCollisionMode;
bool mExternalCollisionMode;
bool mActive;
PhysicsTaskScheduler* mTaskScheduler;

View File

@ -712,6 +712,9 @@ namespace MWPhysics
const MWBase::World *world = MWBase::Environment::get().getWorld();
for (const auto& [ref, physicActor] : mActors)
{
if (!physicActor->isActive())
continue;
auto ptr = physicActor->getPtr();
if (!ptr.getClass().isMobile(ptr))
continue;

View File

@ -3997,4 +3997,10 @@ namespace MWWorld
{
return mRendering->getPostProcessor();
}
void World::setActorActive(const MWWorld::Ptr& ptr, bool value)
{
if (MWPhysics::Actor* const actor = mPhysics->getActor(ptr))
actor->setActive(value);
}
}

View File

@ -751,6 +751,8 @@ namespace MWWorld
MWRender::RenderingManager* getRenderingManager() override { return mRendering.get(); }
MWRender::PostProcessor* getPostProcessor() override;
void setActorActive(const MWWorld::Ptr& ptr, bool value) override;
};
}