From ea8023e51f17d2213d4f61548a91eb403e322656 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Wed, 9 Jan 2013 12:11:19 +0100 Subject: [PATCH] Canvas: Provide sane default bounding box (For Image & Text) --- simgear/canvas/elements/CanvasElement.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/simgear/canvas/elements/CanvasElement.cxx b/simgear/canvas/elements/CanvasElement.cxx index b0f84d55..e11e563b 100644 --- a/simgear/canvas/elements/CanvasElement.cxx +++ b/simgear/canvas/elements/CanvasElement.cxx @@ -405,7 +405,15 @@ namespace canvas //---------------------------------------------------------------------------- osg::BoundingBox Element::getTransformedBounds(const osg::Matrix& m) const { - return osg::BoundingBox(); + if( !_drawable ) + return osg::BoundingBox(); + + osg::BoundingBox transformed; + const osg::BoundingBox& bb = _drawable->getBound(); + for(int i = 0; i < 4; ++i) + transformed.expandBy( m * bb.corner(i) ); + + return transformed; } //----------------------------------------------------------------------------