]> git.mxchange.org Git - simgear.git/commitdiff
Canvas: Fix bounding box calculation for paths with subpaths.
authorThomas Geymayer <tomgey@gmail.com>
Fri, 7 Feb 2014 23:22:36 +0000 (00:22 +0100)
committerThomas Geymayer <tomgey@gmail.com>
Fri, 7 Feb 2014 23:22:36 +0000 (00:22 +0100)
simgear/canvas/elements/CanvasPath.cxx

index 6d4d0bf56846d135c714e1c2aefa367d4fd9efcd..27c847a7ef9b328cfaebe07f548099ebcee90a11 100644 (file)
@@ -277,7 +277,8 @@ namespace canvas
       {
         osg::BoundingBox bb;
 
-        osg::Vec2f cur; // VG "Current point" (in local coordinates)
+        osg::Vec2f cur(0, 0), // VG "Current point" (in local coordinates)
+                   sub(0, 0); // beginning of current sub path
         VGubyte cmd_index = 0;
         for( size_t i = 0,              ci = 0;
                     i < _cmds.size() && ci < _coords.size();
@@ -297,6 +298,7 @@ namespace canvas
           switch( cmd )
           {
             case VG_CLOSE_PATH:
+              cur = sub;
               break;
             case VG_MOVE_TO:
             case VG_LINE_TO:
@@ -352,7 +354,12 @@ namespace canvas
           }
 
           if( num_coords > 0 )
+          {
             cur = points[ num_coords - 1 ];
+
+            if( cmd == VG_MOVE_TO )
+              sub = cur;
+          }
         }
 
         return bb;