From Farshid Lashkari,

"I noticed that Text3D objects would change there z alignment depending on the alignment mode. I'm not sure if this was intentional or just a simple mistake. My expectation was that the front of the object would always stay aligned to the 0 z-plane, regardless of the alignment mode. I've attached an updated version that retains a consistent z-alignment."
"I just now noticed another issue with Text3D objects. It was not properly computing the bounding box when non-axis aligned rotations were being applied. In this case all corners of the bounding box need to be transformed in order to get the correct containing box. I've attached the updated file."
"The incorrect bounding box problem also applies to regular Text objects. I've attached the fix for that as well as the original Text3D fix."


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14296 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2014-06-26 10:53:18 +00:00
parent 138ea0e0c7
commit febcb25cb6
2 changed files with 33 additions and 21 deletions

View File

@@ -279,8 +279,14 @@ osg::BoundingBox TextBase::computeBoundingBox() const
if (_autoTransformCache[i]._traversalNumber>=0)
{
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);
bbox.expandBy(_textBB.corner(0)*matrix);
bbox.expandBy(_textBB.corner(1)*matrix);
bbox.expandBy(_textBB.corner(2)*matrix);
bbox.expandBy(_textBB.corner(3)*matrix);
bbox.expandBy(_textBB.corner(4)*matrix);
bbox.expandBy(_textBB.corner(5)*matrix);
bbox.expandBy(_textBB.corner(6)*matrix);
bbox.expandBy(_textBB.corner(7)*matrix);
}
}
@@ -305,14 +311,14 @@ osg::BoundingBox TextBase::computeBoundingBox() const
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.yMin(),_textBB.zMin())*matrix);
bbox.expandBy(osg::Vec3(_textBB.xMin(),_textBB.yMax(),_textBB.zMin())*matrix);
bbox.expandBy(osg::Vec3(_textBB.xMax(),_textBB.yMax(),_textBB.zMin())*matrix);
bbox.expandBy(osg::Vec3(_textBB.xMin(),_textBB.yMin(),_textBB.zMax())*matrix);
bbox.expandBy(osg::Vec3(_textBB.xMax(),_textBB.yMin(),_textBB.zMax())*matrix);
bbox.expandBy(osg::Vec3(_textBB.xMin(),_textBB.yMax(),_textBB.zMax())*matrix);
bbox.expandBy(osg::Vec3(_textBB.xMax(),_textBB.yMax(),_textBB.zMax())*matrix);
bbox.expandBy(_textBB.corner(0)*matrix);
bbox.expandBy(_textBB.corner(1)*matrix);
bbox.expandBy(_textBB.corner(2)*matrix);
bbox.expandBy(_textBB.corner(3)*matrix);
bbox.expandBy(_textBB.corner(4)*matrix);
bbox.expandBy(_textBB.corner(5)*matrix);
bbox.expandBy(_textBB.corner(6)*matrix);
bbox.expandBy(_textBB.corner(7)*matrix);
}
}
}