@@ -177,6 +177,17 @@ var Axes = require('../geometry/Axes');
177177 mass : options . mass || body . mass ,
178178 inertia : options . inertia || body . inertia
179179 } ) ;
180+
181+ if ( body . parts . length === 1 )
182+ {
183+ var w = ( body . bounds . max . x - body . bounds . min . x ) ;
184+ var h = ( body . bounds . max . y - body . bounds . min . y ) ;
185+
186+ body . centerOfMass . x = w / 2 ;
187+ body . centerOfMass . y = h / 2 ;
188+
189+ Vertices . calcOffset ( body . vertices , body . position ) ;
190+ }
180191 } ;
181192
182193 /**
@@ -196,8 +207,6 @@ var Axes = require('../geometry/Axes');
196207 settings [ property ] = value ;
197208 }
198209
199- var hasParts = false ;
200-
201210 for ( property in settings ) {
202211 if ( ! Object . prototype . hasOwnProperty . call ( settings , property ) )
203212 continue ;
@@ -237,7 +246,6 @@ var Axes = require('../geometry/Axes');
237246 break ;
238247 case 'parts' :
239248 Body . setParts ( body , value ) ;
240- hasParts = true ;
241249 break ;
242250 case 'centre' :
243251 Body . setCentre ( body , value ) ;
@@ -246,17 +254,6 @@ var Axes = require('../geometry/Axes');
246254 body [ property ] = value ;
247255 }
248256 }
249-
250- if ( ! hasParts )
251- {
252- // sum the properties of all compound parts of the parent body
253- var total = Body . _totalProperties ( body ) ;
254-
255- body . centerOfMass . x = total . centre . x ;
256- body . centerOfMass . y = total . centre . y ;
257-
258- Vertices . calcOffset ( body . vertices , body . position ) ;
259- }
260257 } ;
261258
262259 /**
0 commit comments