From de39e0093a204a7e56672f5c3a12c5c1f092f9ec Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Sat, 8 Feb 2014 00:22:36 +0100 Subject: [PATCH] Canvas: Fix bounding box calculation for paths with subpaths. --- simgear/canvas/elements/CanvasPath.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/simgear/canvas/elements/CanvasPath.cxx b/simgear/canvas/elements/CanvasPath.cxx index 6d4d0bf5..27c847a7 100644 --- a/simgear/canvas/elements/CanvasPath.cxx +++ b/simgear/canvas/elements/CanvasPath.cxx @@ -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;