From a55604c549357c61890239168d64c23dcad276b8 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 23 Feb 2017 22:35:17 +0100 Subject: [PATCH] Avoid unnecessary AABB update when actor position has not changed --- apps/openmw/mwphysics/physicssystem.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index c3e2d7c1b..40a3070d8 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -1419,14 +1419,18 @@ namespace MWPhysics osg::Vec3f position = physicActor->getPosition(); float oldHeight = position.z(); + bool positionChanged = false; for (int i=0; igetPtr(), physicActor, iter->second, physicsDt, world->isFlying(iter->first), waterlevel, slowFall, mCollisionWorld, mStandingCollisions); - physicActor->setPosition(position); + if (position != physicActor->getPosition()) + positionChanged = true; + physicActor->setPosition(position); // always set even if unchanged to make sure interpolation is correct } - mCollisionWorld->updateSingleAabb(physicActor->getCollisionObject()); + if (positionChanged) + mCollisionWorld->updateSingleAabb(physicActor->getCollisionObject()); float interpolationFactor = mTimeAccum / physicsDt; osg::Vec3f interpolated = position * interpolationFactor + physicActor->getPreviousPosition() * (1.f - interpolationFactor);