Improved the handling of unitialized bounding box
This commit is contained in:
parent
36f755670b
commit
c70e7bda86
@ -276,27 +276,33 @@ osg::BoundingBox TextBase::computeBound() const
|
||||
{
|
||||
for(unsigned int i=0;i<_autoTransformCache.size();++i)
|
||||
{
|
||||
if (_autoTransformCache[i]._traversalNumber<0 && (_characterSizeMode!=OBJECT_COORDS || _autoRotateToScreen))
|
||||
if (_autoTransformCache[i]._traversalNumber>=0)
|
||||
{
|
||||
// _autoTransformCache is not valid so don't take it into accoumt when compute bounding volume.
|
||||
#if 1
|
||||
// so fallback to estimating the bounding box size by assuming a scale of 1
|
||||
// but might cause problems due to small feature culling...
|
||||
osg::Matrix matrix;
|
||||
matrix.makeTranslate(_position);
|
||||
bbox.expandBy(osg::Vec3(_textBB.xMin(),_textBB.yMin(),_textBB.zMin())*matrix);
|
||||
bbox.expandBy(osg::Vec3(_textBB.xMax(),_textBB.yMax(),_textBB.zMax())*matrix);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::Matrix& matrix = _autoTransformCache[i]._matrix;
|
||||
bbox.expandBy(osg::Vec3(_textBB.xMin(),_textBB.yMin(),_textBB.zMin())*matrix);
|
||||
bbox.expandBy(osg::Vec3(_textBB.xMax(),_textBB.yMax(),_textBB.zMax())*matrix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!bbox.valid())
|
||||
{
|
||||
// provide a fallback in cases where no bounding box has been been setup so far
|
||||
if (_characterSizeMode!=OBJECT_COORDS || _autoRotateToScreen)
|
||||
{
|
||||
// default to a zero size.
|
||||
bbox.set(_position, _position);
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::Matrix matrix;
|
||||
matrix.makeTranslate(_position);
|
||||
bbox.expandBy(osg::Vec3(_textBB.xMin(),_textBB.yMin(),_textBB.zMin())*matrix);
|
||||
bbox.expandBy(osg::Vec3(_textBB.xMax(),_textBB.yMax(),_textBB.zMax())*matrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return bbox;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user