File tree Expand file tree Collapse file tree
v3/src/physics/matter-js/lib/body Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -671,16 +671,16 @@ var Axes = require('../geometry/Axes');
671671
672672 // sum the properties of all compound parts of the parent body
673673 for ( var i = body . parts . length === 1 ? 0 : 1 ; i < body . parts . length ; i ++ ) {
674- var part = body . parts [ i ] ;
674+ var part = body . parts [ i ] ,
675+ mass = part . mass !== Infinity ? part . mass : 1 ;
676+
675677 properties . mass += part . mass ;
676678 properties . area += part . area ;
677679 properties . inertia += part . inertia ;
678- properties . centre = Vector . add ( properties . centre ,
679- Vector . mult ( part . position , part . mass !== Infinity ? part . mass : 1 ) ) ;
680+ properties . centre = Vector . add ( properties . centre , Vector . mult ( part . position , mass ) ) ;
680681 }
681682
682- properties . centre = Vector . div ( properties . centre ,
683- properties . mass !== Infinity ? properties . mass : body . parts . length ) ;
683+ properties . centre = Vector . div ( properties . centre , properties . mass ) ;
684684
685685 return properties ;
686686 } ;
You can’t perform that action at this time.
0 commit comments