From 119f3d9814d32310088734459a526e38ed498308 Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Tue, 12 Oct 2021 21:40:09 +0100 Subject: [PATCH] WS30: Remove VPB Max range and LoD scaling Better to scale from the camera than mess with the LoD itself. --- simgear/scene/model/ModelRegistry.cxx | 42 +------------------------- simgear/scene/util/SGSceneFeatures.hxx | 6 ---- 2 files changed, 1 insertion(+), 47 deletions(-) diff --git a/simgear/scene/model/ModelRegistry.cxx b/simgear/scene/model/ModelRegistry.cxx index 695c2475..ce7acc54 100644 --- a/simgear/scene/model/ModelRegistry.cxx +++ b/simgear/scene/model/ModelRegistry.cxx @@ -996,40 +996,6 @@ public: } }; -class AdjustLODVisitor : public osg::NodeVisitor -{ -public: - float _rangeFactor; - float _maxRange; - AdjustLODVisitor(float rangeFactor, float maxRange): osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) - { - _rangeFactor = rangeFactor; - _maxRange = maxRange; - } - - void apply(osg::PagedLOD& node) - { - if (node.getNumChildren() == 0) return; - - if (node.getNumFileNames() == 2) { - // We use internal knowledge of VPB to modify the LOD ranges. - // The first child is the current node. The second is the sub-tile at higher resolution. - // See VirtualPlanetBuild src/vpb/Destination.cpp CompositeDestination::createPagedLODScene() - // lines 3330-3333 - node.dirtyBound(); // At this point the bounds haven't been calculated, so we need to force this. - float maxRange = _maxRange + node.getBound().radius(); - float cutoff = std::min(node.getBound().radius() * _rangeFactor, maxRange); - SG_LOG(SG_TERRAIN, SG_DEBUG, "VPB PagedLOD range " << cutoff << " " << maxRange); - node.setRange(0, cutoff, maxRange); - node.setRange(1, 0, cutoff); - } else { - SG_LOG(SG_TERRAIN, SG_ALERT, "Unexpected PagedLOD type in LOD range update"); - } - - traverse(node); - } -}; - struct OSGOptimizePolicy : public OptimizeModelPolicy { @@ -1054,12 +1020,6 @@ struct OSGOptimizePolicy : public OptimizeModelPolicy { SGSceneFeatures* features = SGSceneFeatures::instance(); - // Adjust the LOD ranges as required. - double rangeFactor = features->getVPBRangeFactor(); - double maxRange = features->getVPBMaxRange(); - AdjustLODVisitor alv = AdjustLODVisitor(rangeFactor, maxRange); - optimized->accept(alv); - osg::ref_ptr terrain = findTopMostNodeOfType(optimized.get()); osg::ref_ptr terrainTile = findTopMostNodeOfType(optimized.get()); @@ -1067,7 +1027,7 @@ struct OSGOptimizePolicy : public OptimizeModelPolicy { // Top level. This is likely to have the default GeometryTechnique already assigned which we need to replace with our own terrain->setSampleRatio(features->getVPBSampleRatio()); terrain->setVerticalScale(features->getVPBVerticalScale()); - terrain->setTerrainTechniquePrototype(new VPBTechnique(sgopt)); + terrain->setTerrainTechniquePrototype(new VPBTechnique(sgopt)); if (terrainTile != NULL) { terrainTile->setTerrainTechnique(new VPBTechnique(sgopt)); terrainTile->setDirty(true); diff --git a/simgear/scene/util/SGSceneFeatures.hxx b/simgear/scene/util/SGSceneFeatures.hxx index 7b3a32bd..4a02efe9 100644 --- a/simgear/scene/util/SGSceneFeatures.hxx +++ b/simgear/scene/util/SGSceneFeatures.hxx @@ -64,12 +64,6 @@ public: bool getVPBActive() const { return _VPBActive; } void setVPBActive(const bool val) { _VPBActive = val; } - float getVPBRangeFactor() const { return _VPBRangeFactor; } - void setVPBRangeFactor(const float val) { _VPBRangeFactor = val; } - - float getVPBMaxRange() const { return _VPBMaxRange; } - void setVPBMaxRange(const float val) { _VPBMaxRange = val; } - float getVPBConstraintGap() const { return _VPBConstraintGap; } void setVPBConstraintGap(const float val) { _VPBConstraintGap = val; }