@@ -143,6 +143,9 @@ module Phaser.Physics.Advanced {
143143 // Shapes
144144 public shapes : IShape [ ] = [ ] ;
145145
146+ // Length of the shapes array
147+ public shapesLength : number ;
148+
146149 // Joints
147150 public joints : IJoint [ ] = [ ] ;
148151 public jointHash = { } ;
@@ -163,7 +166,7 @@ module Phaser.Physics.Advanced {
163166
164167 public duplicate ( ) {
165168
166- // console.log('body duplicate called');
169+ console . log ( 'body duplicate called' ) ;
167170
168171 //var body = new Body(this.type, this.transform.t, this.angle);
169172
@@ -274,6 +277,8 @@ module Phaser.Physics.Advanced {
274277
275278 this . shapes . push ( shape ) ;
276279
280+ this . shapesLength = this . shapes . length ;
281+
277282 return shape ;
278283
279284 }
@@ -288,8 +293,9 @@ module Phaser.Physics.Advanced {
288293 shape . body = undefined ;
289294 }
290295
291- }
296+ this . shapesLength = this . shapes . length ;
292297
298+ }
293299
294300 private setMass ( mass ) {
295301
@@ -307,8 +313,8 @@ module Phaser.Physics.Advanced {
307313
308314 public setTransform ( pos , angle ) {
309315
310- this . transform . setTo ( pos , angle ) ;
311316 // inject the transform into this.position
317+ this . transform . setTo ( pos , angle ) ;
312318 Manager . write ( 'setTransform: ' + this . position . toString ( ) ) ;
313319 Manager . write ( 'centroid: ' + this . centroid . toString ( ) ) ;
314320 Phaser . TransformUtils . transform ( this . transform , this . centroid , this . position ) ;
@@ -399,20 +405,14 @@ module Phaser.Physics.Advanced {
399405
400406 if ( ! this . fixedRotation )
401407 {
402- //this.setInertia(totalInertia - totalMass * vec2.dot(this.centroid, this.centroid));
403408 this . setInertia ( totalInertia - totalMass * Phaser . Vec2Utils . dot ( this . centroid , this . centroid ) ) ;
404409 }
405410
406- //console.log("mass = " + this.m + " inertia = " + this.i);
407-
408411 // Move center of mass
409412 var oldPosition : Phaser . Vec2 = Phaser . Vec2Utils . clone ( this . position ) ;
410- //this.position.copyFrom(this.transform.transform(this.centroid));
411413 Phaser . TransformUtils . transform ( this . transform , this . centroid , this . position ) ;
412414
413415 // Update center of mass velocity
414-
415- //this.velocity.mad(vec2.perp(vec2.sub(this.position, old_p)), this.angularVelocity);
416416 oldPosition . subtract ( this . position ) ;
417417 this . velocity . multiplyAddByScalar ( Phaser . Vec2Utils . perp ( oldPosition , oldPosition ) , this . angularVelocity ) ;
418418
@@ -462,7 +462,6 @@ module Phaser.Physics.Advanced {
462462
463463 public updateVelocity ( gravity , dt , damping ) {
464464
465- // this.velocity = vec2.mad(this.velocity, vec2.mad(gravity, this.force, this.massInverted), dt);
466465 Phaser . Vec2Utils . multiplyAdd ( gravity , this . force , this . massInverted , this . _tempVec2 ) ;
467466 Phaser . Vec2Utils . multiplyAdd ( this . velocity , this . _tempVec2 , dt , this . velocity ) ;
468467
@@ -513,17 +512,10 @@ module Phaser.Physics.Advanced {
513512 return v < min ? min : ( v > max ? max : v ) ;
514513 }
515514
516- public updatePosition ( dt ) {
517-
518- //console.log('body update pos', this.position.y);
519- //console.log('pre add temp', this._tempVec2.y);
515+ public updatePosition ( dt :number ) {
520516
521- //this.position.addself(vec2.scale(this.velocity, dt));
522517 this . position . add ( Phaser . Vec2Utils . scale ( this . velocity , dt , this . _tempVec2 ) ) ;
523518
524- //console.log('post add temp', this._tempVec2.y);
525- //console.log('post add', this.position.y);
526-
527519 this . angle += this . angularVelocity * dt ;
528520
529521 }
@@ -547,10 +539,8 @@ module Phaser.Physics.Advanced {
547539
548540 this . force . add ( force ) ;
549541
550- // this.f.addself(force);
551- // this.torque += vec2.cross(vec2.sub(p, this.p), force);
552-
553542 Phaser . Vec2Utils . subtract ( p , this . position , this . _tempVec2 ) ;
543+
554544 this . torque += Phaser . Vec2Utils . cross ( this . _tempVec2 , force ) ;
555545
556546 }
@@ -601,8 +591,6 @@ module Phaser.Physics.Advanced {
601591
602592 this . velocity . multiplyAddByScalar ( impulse , this . massInverted ) ;
603593
604- // this.angularVelocity += vec2.cross(vec2.sub(p, this.position), impulse) * this.inertiaInverted;
605-
606594 Phaser . Vec2Utils . subtract ( p , this . position , this . _tempVec2 ) ;
607595
608596 this . angularVelocity += Phaser . Vec2Utils . cross ( this . _tempVec2 , impulse ) * this . inertiaInverted ;
0 commit comments