Fix bounds for empty text nodes

_lineCount can be 0, so we get underflow if the alignment is one of
the *_BOTTOM_BASE_LINE.
This commit is contained in:
Calum Robinson 2021-04-13 13:25:12 +01:00 committed by Robert Osfield
parent 78cb12b531
commit 2695f29be0

View File

@ -484,6 +484,14 @@ void TextBase::computePositions()
void TextBase::computePositionsImplementation()
{
_normal = osg::Vec3(0.0f,0.0f,1.0f);
if (_text.empty())
{
_offset = Vec3();
return;
}
switch(_alignment)
{
case LEFT_TOP: _offset.set(_textBB.xMin(),_textBB.yMax(),_textBB.zMin()); break;
@ -506,8 +514,6 @@ void TextBase::computePositionsImplementation()
case CENTER_BOTTOM_BASE_LINE: _offset.set((_textBB.xMax()+_textBB.xMin())*0.5f,-_characterHeight*(1.0 + _lineSpacing)*(_lineCount-1),0.0f); break;
case RIGHT_BOTTOM_BASE_LINE: _offset.set(_textBB.xMax(),-_characterHeight*(1.0 + _lineSpacing)*(_lineCount-1),0.0f); break;
}
_normal = osg::Vec3(0.0f,0.0f,1.0f);
}
bool TextBase::computeMatrix(osg::Matrix& matrix, osg::State* state) const