From d2ef0d362cfcc10f594a7ece17b40680a6d7a506 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 9 Sep 2014 01:52:48 +0200 Subject: [PATCH] Implement vanilla distance threshold for AI processing (Bug #1876) --- apps/openmw/mwmechanics/actors.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 9e11529dd3..2abaf7591f 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -1117,7 +1117,11 @@ namespace MWMechanics { updateActor(iter->first, duration); - if (MWBase::Environment::get().getMechanicsManager()->isAIActive()) + // AI processing is only done within distance of 7168 units to the player. Note the "AI distance" slider doesn't affect this + // (it only does some throttling for targets beyond the "AI distance", so doesn't give any guarantees as to whether AI will be enabled or not) + if (MWBase::Environment::get().getMechanicsManager()->isAIActive() && + Ogre::Vector3(player.getRefData().getPosition().pos).squaredDistance(Ogre::Vector3(iter->first.getRefData().getPosition().pos)) + <= 7168*7168) { if (timerUpdateAITargets == 0) {