Skip to content

Commit f84072c

Browse files
committed
Fix bounds for empty text nodes
_lineCount can be 0, so we get underflow if the alignment is one of the *_BOTTOM_BASE_LINE.
1 parent 60f0dd7 commit f84072c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/osgText/TextBase.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,14 @@ void TextBase::computePositions()
484484

485485
void TextBase::computePositionsImplementation()
486486
{
487+
_normal = osg::Vec3(0.0f,0.0f,1.0f);
488+
489+
if (_text.empty())
490+
{
491+
_offset = Vec3();
492+
return;
493+
}
494+
487495
switch(_alignment)
488496
{
489497
case LEFT_TOP: _offset.set(_textBB.xMin(),_textBB.yMax(),_textBB.zMin()); break;
@@ -506,8 +514,6 @@ void TextBase::computePositionsImplementation()
506514
case CENTER_BOTTOM_BASE_LINE: _offset.set((_textBB.xMax()+_textBB.xMin())*0.5f,-_characterHeight*(1.0 + _lineSpacing)*(_lineCount-1),0.0f); break;
507515
case RIGHT_BOTTOM_BASE_LINE: _offset.set(_textBB.xMax(),-_characterHeight*(1.0 + _lineSpacing)*(_lineCount-1),0.0f); break;
508516
}
509-
510-
_normal = osg::Vec3(0.0f,0.0f,1.0f);
511517
}
512518

513519
bool TextBase::computeMatrix(osg::Matrix& matrix, osg::State* state) const

0 commit comments

Comments
 (0)