From 7dc3ad4b5efe15205ae393dab2de1f336e6c3b72 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 18 Jun 2008 10:46:05 +0000 Subject: [PATCH] From David Callu, "fixed bounding box bug" --- include/osgText/Text3D | 3 +++ src/osgText/Text3D.cpp | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/osgText/Text3D b/include/osgText/Text3D index 7b445c7c8..ee43b8e62 100644 --- a/include/osgText/Text3D +++ b/include/osgText/Text3D @@ -126,6 +126,9 @@ public: // // forcefully unloaded. friend class Font3D; + virtual osg::BoundingBox computeBound() const; + + protected: virtual ~Text3D() {} diff --git a/src/osgText/Text3D.cpp b/src/osgText/Text3D.cpp index 81e031d20..5ba6c6b32 100644 --- a/src/osgText/Text3D.cpp +++ b/src/osgText/Text3D.cpp @@ -400,7 +400,24 @@ void Text3D::computeGlyphRepresentation() +osg::BoundingBox Text3D::computeBound() const +{ + osg::BoundingBox bbox; + if (_textBB.valid()) + { + for(unsigned int i=0;i<_autoTransformCache.size();++i) + { + osg::Matrix& matrix = _autoTransformCache[i]._matrix; + bbox.expandBy(osg::Vec3(_textBB.xMin(),_textBB.yMin(),_textBB.zMin())*matrix); +// bbox.expandBy(osg::Vec3(_textBB.xMax(),_textBB.yMin(),_textBB.zMin())*matrix); + bbox.expandBy(osg::Vec3(_textBB.xMax(),_textBB.yMax(),_textBB.zMax())*matrix); +// bbox.expandBy(osg::Vec3(_textBB.xMin(),_textBB.yMax(),_textBB.zMin())*matrix); + } + } + + return bbox; +}