Skip to content

Commit ba86e37

Browse files
committed
Merge branch 'fix_9252' into 'master'
Fix poor LOD selection during active grid object paging Closes #9252 See merge request OpenMW/openmw!5470
2 parents 062dc51 + 4883ea3 commit ba86e37

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

apps/openmw/mwrender/objectpaging.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "objectpaging.hpp"
22

3-
#include <type_traits>
3+
#include <limits>
44
#include <unordered_map>
55
#include <vector>
66

@@ -677,6 +677,8 @@ namespace MWRender
677677
const float smallestDistanceToChunk = (size > 1 / 8.f) ? (size * cellSize) : 0.f;
678678
const float higherDistanceToChunk
679679
= activeGrid ? ((size < 1) ? 5 : 3) * cellSize * size + 1 : smallestDistanceToChunk + 1;
680+
const LODRange lodDistances = activeGrid ? LODRange{ 0.f, std::numeric_limits<float>::max() }
681+
: LODRange{ smallestDistanceToChunk, higherDistanceToChunk };
680682

681683
AnalyzeVisitor analyzeVisitor(copyMask);
682684
const float minSize = mMinSizeMergeFactor ? mMinSize * mMinSizeMergeFactor : mMinSize;
@@ -770,7 +772,7 @@ namespace MWRender
770772
const auto emplaced = nodes.emplace(std::move(cnode), InstanceList());
771773
if (emplaced.second)
772774
{
773-
analyzeVisitor.mDistances = LODRange{ smallestDistanceToChunk, higherDistanceToChunk } / ref.mScale;
775+
analyzeVisitor.mDistances = lodDistances / ref.mScale;
774776
const osg::Node* const nodePtr = emplaced.first->first.get();
775777
// const-trickery required because there is no const version of NodeVisitor
776778
const_cast<osg::Node*>(nodePtr)->accept(analyzeVisitor);
@@ -849,7 +851,7 @@ namespace MWRender
849851
// BufferObjects of the original geometry. (ensured by needvbo() in optimizer.cpp)
850852
copyop.setCopyFlags(merge ? osg::CopyOp::DEEP_COPY_NODES | osg::CopyOp::DEEP_COPY_DRAWABLES
851853
: osg::CopyOp::DEEP_COPY_NODES);
852-
copyop.mDistances = LODRange{ smallestDistanceToChunk, higherDistanceToChunk } / ref.mScale;
854+
copyop.mDistances = lodDistances / ref.mScale;
853855
copyop.copy(cnode, trans);
854856

855857
if (activeGrid)

0 commit comments

Comments
 (0)