From d50f2e3add0c8ae40562a36db47df5fe26057c53 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 13 Mar 2006 21:20:07 +0000 Subject: [PATCH] From Andrew Sampson, "The terravista terrain generation tool can insert references to external model files into a terrapage tile. It unfortunately does not update the bounding sphere of that tile to include the extents of the external model. This means that if a large model (such as an airfield model) is attached to a tile, the model will disappear when the tile is off-screen (outside the view volume), even though the model is on-screen." --- src/osgPlugins/txp/TXPPagedLOD.cpp | 15 +++++++++++++++ src/osgPlugins/txp/TXPPagedLOD.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/osgPlugins/txp/TXPPagedLOD.cpp b/src/osgPlugins/txp/TXPPagedLOD.cpp index 2eb1d1aae..e15a0f012 100644 --- a/src/osgPlugins/txp/TXPPagedLOD.cpp +++ b/src/osgPlugins/txp/TXPPagedLOD.cpp @@ -100,3 +100,18 @@ void TXPPagedLOD::traverse(osg::NodeVisitor& nv) } } +osg::BoundingSphere TXPPagedLOD::computeBound() const +{ + // Force calculation of entire bounding sphere; this will include any + // externally-referenced models which are attached to the tile. + // If this is not done, then externally referenced models will disappear + // when the tile they are attached to leaves the view volume. + osg::BoundingSphere result = osg::Group::computeBound(); + + if (_centerMode==USER_DEFINED_CENTER && _radius>=0.0f) + { + float tempRadius = std::max( _radius, result.radius() ); + result = osg::BoundingSphere(_userDefinedCenter,tempRadius); + } + return result; +} diff --git a/src/osgPlugins/txp/TXPPagedLOD.h b/src/osgPlugins/txp/TXPPagedLOD.h index 3440f5c43..031700641 100644 --- a/src/osgPlugins/txp/TXPPagedLOD.h +++ b/src/osgPlugins/txp/TXPPagedLOD.h @@ -58,6 +58,7 @@ namespace txp TileIdentifier _tileIdentifier; + virtual osg::BoundingSphere computeBound() const; protected: virtual ~TXPPagedLOD();