From 6e3fd3479067c3128076437a4cb2a7e4c363ac06 Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 5 May 2024 13:33:27 +0200 Subject: [PATCH] Calculate floor and ceil of bounds once --- apps/openmw/mwrender/objectpaging.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwrender/objectpaging.cpp b/apps/openmw/mwrender/objectpaging.cpp index d207604248..e44f4de96c 100644 --- a/apps/openmw/mwrender/objectpaging.cpp +++ b/apps/openmw/mwrender/objectpaging.cpp @@ -589,6 +589,8 @@ namespace MWRender const osg::Vec2f minBound = (center - osg::Vec2f(size / 2.f, size / 2.f)); const osg::Vec2f maxBound = (center + osg::Vec2f(size / 2.f, size / 2.f)); + const osg::Vec2i floorMinBound(std::floor(minBound.x()), std::floor(minBound.y())); + const osg::Vec2i ceilMaxBound(std::ceil(maxBound.x()), std::ceil(maxBound.y())); struct InstanceList { std::vector mInstances; @@ -617,10 +619,10 @@ namespace MWRender if (size < 1.f) { const osg::Vec3f cellPos = ref.mPosition / cellSize; - if ((minBound.x() > std::floor(minBound.x()) && cellPos.x() < minBound.x()) - || (minBound.y() > std::floor(minBound.y()) && cellPos.y() < minBound.y()) - || (maxBound.x() < std::ceil(maxBound.x()) && cellPos.x() >= maxBound.x()) - || (maxBound.y() < std::ceil(maxBound.y()) && cellPos.y() >= maxBound.y())) + if ((minBound.x() > floorMinBound.x() && cellPos.x() < minBound.x()) + || (minBound.y() > floorMinBound.y() && cellPos.y() < minBound.y()) + || (maxBound.x() < ceilMaxBound.x() && cellPos.x() >= maxBound.x()) + || (maxBound.y() < ceilMaxBound.y() && cellPos.y() >= maxBound.y())) continue; }