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:
@@ -418,8 +418,14 @@ osg::BoundingBox Text3D::computeBoundingBox() const
|
||||
for(unsigned int i=0;i<_autoTransformCache.size();++i)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,17 +438,17 @@ void Text3D::computePositions(unsigned int contextID) const
|
||||
|
||||
switch(_alignment)
|
||||
{
|
||||
case LEFT_TOP: _offset.set(_textBB.xMin(),_textBB.yMax(),_textBB.zMin()); break;
|
||||
case LEFT_CENTER: _offset.set(_textBB.xMin(),(_textBB.yMax()+_textBB.yMin())*0.5f,_textBB.zMin()); break;
|
||||
case LEFT_BOTTOM: _offset.set(_textBB.xMin(),_textBB.yMin(),_textBB.zMin()); break;
|
||||
case LEFT_TOP: _offset.set(_textBB.xMin(),_textBB.yMax(),0.0f); break;
|
||||
case LEFT_CENTER: _offset.set(_textBB.xMin(),(_textBB.yMax()+_textBB.yMin())*0.5f,0.0f); break;
|
||||
case LEFT_BOTTOM: _offset.set(_textBB.xMin(),_textBB.yMin(),0.0f); break;
|
||||
|
||||
case CENTER_TOP: _offset.set((_textBB.xMax()+_textBB.xMin())*0.5f,_textBB.yMax(),_textBB.zMin()); break;
|
||||
case CENTER_CENTER: _offset.set((_textBB.xMax()+_textBB.xMin())*0.5f,(_textBB.yMax()+_textBB.yMin())*0.5f,_textBB.zMin()); break;
|
||||
case CENTER_BOTTOM: _offset.set((_textBB.xMax()+_textBB.xMin())*0.5f,_textBB.yMin(),_textBB.zMin()); break;
|
||||
case CENTER_TOP: _offset.set((_textBB.xMax()+_textBB.xMin())*0.5f,_textBB.yMax(),0.0f); break;
|
||||
case CENTER_CENTER: _offset.set((_textBB.xMax()+_textBB.xMin())*0.5f,(_textBB.yMax()+_textBB.yMin())*0.5f,0.0f); break;
|
||||
case CENTER_BOTTOM: _offset.set((_textBB.xMax()+_textBB.xMin())*0.5f,_textBB.yMin(),0.0f); break;
|
||||
|
||||
case RIGHT_TOP: _offset.set(_textBB.xMax(),_textBB.yMax(),_textBB.zMin()); break;
|
||||
case RIGHT_CENTER: _offset.set(_textBB.xMax(),(_textBB.yMax()+_textBB.yMin())*0.5f,_textBB.zMin()); break;
|
||||
case RIGHT_BOTTOM: _offset.set(_textBB.xMax(),_textBB.yMin(),_textBB.zMin()); break;
|
||||
case RIGHT_TOP: _offset.set(_textBB.xMax(),_textBB.yMax(),0.0f); break;
|
||||
case RIGHT_CENTER: _offset.set(_textBB.xMax(),(_textBB.yMax()+_textBB.yMin())*0.5f,0.0f); break;
|
||||
case RIGHT_BOTTOM: _offset.set(_textBB.xMax(),_textBB.yMin(),0.0f); break;
|
||||
|
||||
case LEFT_BASE_LINE: _offset.set(0.0f,0.0f,0.0f); break;
|
||||
case CENTER_BASE_LINE: _offset.set((_textBB.xMax()+_textBB.xMin())*0.5f,0.0f,0.0f); break;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user