From 58297ffbf46abf178f02f4bb73d424817e4627ed Mon Sep 17 00:00:00 2001 From: fredzio Date: Fri, 18 Dec 2020 21:18:04 +0100 Subject: [PATCH] Move stats update into their own function. --- apps/openmw/mwphysics/mtphysics.cpp | 24 ++++++++++++++---------- apps/openmw/mwphysics/mtphysics.hpp | 1 + 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwphysics/mtphysics.cpp b/apps/openmw/mwphysics/mtphysics.cpp index 60a7259f80..4838cab505 100644 --- a/apps/openmw/mwphysics/mtphysics.cpp +++ b/apps/openmw/mwphysics/mtphysics.cpp @@ -230,16 +230,7 @@ namespace MWPhysics mMovedActors.emplace_back(data.mActorRaw->getPtr()); } } - - if (mFrameNumber == frameNumber - 1) - { - stats.setAttribute(mFrameNumber, "physicsworker_time_begin", mTimer->delta_s(mFrameStart, mTimeBegin)); - stats.setAttribute(mFrameNumber, "physicsworker_time_taken", mTimer->delta_s(mTimeBegin, mTimeEnd)); - stats.setAttribute(mFrameNumber, "physicsworker_time_end", mTimer->delta_s(mFrameStart, mTimeEnd)); - } - mFrameStart = frameStart; - mTimeBegin = mTimer->tick(); - mFrameNumber = frameNumber; + updateStats(frameStart, frameNumber, stats); } // init @@ -523,4 +514,17 @@ namespace MWPhysics actorData.mActorRaw->setStandingOnPtr(actorData.mStandingOn); } } + + void PhysicsTaskScheduler::updateStats(osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats) + { + if (mFrameNumber == frameNumber - 1) + { + stats.setAttribute(mFrameNumber, "physicsworker_time_begin", mTimer->delta_s(mFrameStart, mTimeBegin)); + stats.setAttribute(mFrameNumber, "physicsworker_time_taken", mTimer->delta_s(mTimeBegin, mTimeEnd)); + stats.setAttribute(mFrameNumber, "physicsworker_time_end", mTimer->delta_s(mFrameStart, mTimeEnd)); + } + mFrameStart = frameStart; + mTimeBegin = mTimer->tick(); + mFrameNumber = frameNumber; + } } diff --git a/apps/openmw/mwphysics/mtphysics.hpp b/apps/openmw/mwphysics/mtphysics.hpp index 90e1007b87..b35ebd5ee9 100644 --- a/apps/openmw/mwphysics/mtphysics.hpp +++ b/apps/openmw/mwphysics/mtphysics.hpp @@ -57,6 +57,7 @@ namespace MWPhysics void refreshLOSCache(); void updateAabbs(); void updatePtrAabb(const std::weak_ptr& ptr); + void updateStats(osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats); std::unique_ptr mWorldFrameData; std::vector mActorsFrameData;