From 90afef26bb92e8493ac2f2cd8b870b83231f27a9 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 21 Jul 2011 09:19:45 +0000 Subject: [PATCH] Merged from svn/trunk, workaround to culling issues assocaited with text that is set to scale relative to screen coords or is rotated to the screen. --- src/osgText/TextBase.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/osgText/TextBase.cpp b/src/osgText/TextBase.cpp index 8b12808e9..090752d39 100644 --- a/src/osgText/TextBase.cpp +++ b/src/osgText/TextBase.cpp @@ -287,11 +287,17 @@ osg::BoundingBox TextBase::computeBound() const if (!bbox.valid()) { - // provide a fallback in cases where no bounding box has been been setup so far - if (_characterSizeMode!=OBJECT_COORDS || _autoRotateToScreen) + // Provide a fallback in cases where no bounding box has been been setup so far. + // Note, assume a scaling of 1.0 for _characterSizeMode!=OBJECT_COORDS as the + // for screen space coordinates size modes we don't know what scale will be used until + // the text is actually rendered, but we haven't to assume something otherwise the + // text label will be culled by view or small feature culling on first frame. + if (_autoRotateToScreen) { - // default to a zero size. - bbox.set(_position, _position); + // use bounding sphere encompassing the maximum size of the text centered on the _position + double radius = _textBB.radius(); + osg::Vec3 diagonal(radius, radius, radius); + bbox.set(_position-diagonal, _position+diagonal); } else {