From Colin McDonald, "The bounding box returned by getBound() for Text which is not

auto-rotated (e.g. HUD text) is not always correct, because it
doesn't take account of the base line offsets added by the
various alignment options such as CENTER_TOP, CENTER_BOTTOM etc.

The attached src/osgText/TextBase.cpp fixes the problem."
This commit is contained in:
Robert Osfield
2012-02-09 15:08:30 +00:00
parent 359fc46757
commit 0a78919807

View File

@@ -302,8 +302,9 @@ osg::BoundingBox TextBase::computeBound() const
else
{
osg::Matrix matrix;
matrix.makeTranslate(_position);
matrix.preMultRotate(_rotation);
matrix.makeTranslate(-_offset);
matrix.postMultRotate(_rotation);
matrix.postMultTranslate(_position);
bbox.expandBy(osg::Vec3(_textBB.xMin(),_textBB.yMin(),_textBB.zMin())*matrix);
bbox.expandBy(osg::Vec3(_textBB.xMax(),_textBB.yMax(),_textBB.zMax())*matrix);
}