]> git.mxchange.org Git - simgear.git/commitdiff
CanvasGroup: return empty bounding box without children.
authorThomas Geymayer <tomgey@gmail.com>
Wed, 19 Mar 2014 15:31:17 +0000 (16:31 +0100)
committerThomas Geymayer <tomgey@gmail.com>
Wed, 19 Mar 2014 15:31:17 +0000 (16:31 +0100)
Return an invalid bounding box can lead to problems
if used unchecked. Just returning an empty bounding
box (size 0x0 and position at the origin of the
element) is much safer.

simgear/canvas/elements/CanvasGroup.cxx

index 51523f426f2391afe196401b201e3847fc3ea6e3..3e284f122c505a9b84b055a2220010ff39a40b77 100644 (file)
@@ -220,7 +220,10 @@ namespace canvas
   //----------------------------------------------------------------------------
   osg::BoundingBox Group::getTransformedBounds(const osg::Matrix& m) const
   {
-    osg::BoundingBox bb;
+    // Default to a bounding box with size 0x0 and the origin defined by the
+    // matrix.
+    osg::BoundingBox bb(m.getTrans(), m.getTrans());
+
     if( !_transform.valid() )
     {
       warnTransformExpired("getTransformedBounds");