File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -373,25 +373,30 @@ var World = new Class({
373373
374374 for ( var i = 0 ; i < bodies . length ; i ++ )
375375 {
376- var body = bodies [ i ] ;
377-
378- if ( ! body . render . visible )
376+ if ( ! bodies [ i ] . render . visible )
379377 {
380- continue ;
378+ return ;
381379 }
382380
383- var vertices = body . vertices ;
381+ // Handle drawing both single bodies and compound bodies. If compound, draw both the
382+ // convex hull (first part) and the rest of the bodies.
383+ for ( var j = 0 ; j < bodies [ i ] . parts . length ; j ++ )
384+ {
385+ var body = bodies [ i ] . parts [ j ] ;
384386
385- graphics . moveTo ( vertices [ 0 ] . x , vertices [ 0 ] . y ) ;
387+ var vertices = body . vertices ;
386388
387- for ( var j = 1 ; j < vertices . length ; j ++ )
388- {
389- graphics . lineTo ( vertices [ j ] . x , vertices [ j ] . y ) ;
390- }
389+ graphics . moveTo ( vertices [ 0 ] . x , vertices [ 0 ] . y ) ;
390+
391+ for ( var k = 1 ; k < vertices . length ; k ++ )
392+ {
393+ graphics . lineTo ( vertices [ k ] . x , vertices [ k ] . y ) ;
394+ }
391395
392- graphics . lineTo ( vertices [ 0 ] . x , vertices [ 0 ] . y ) ;
396+ graphics . lineTo ( vertices [ 0 ] . x , vertices [ 0 ] . y ) ;
393397
394- graphics . strokePath ( ) ;
398+ graphics . strokePath ( ) ;
399+ }
395400 }
396401 } ,
397402
You can’t perform that action at this time.
0 commit comments