@@ -671,22 +671,18 @@ Body.prototype.updateInertiaWorld = function(force){
671
671
* Apply force to a world point. This could for example be a point on the Body surface. Applying force this way will add to Body.force and Body.torque.
672
672
* @method applyForce
673
673
* @param {Vec3 } force The amount of force to add.
674
- * @param {Vec3 } worldPoint A world point to apply the force on.
674
+ * @param {Vec3 } relativePoint A point relative to the center of mass to apply the force on.
675
675
*/
676
676
var Body_applyForce_r = new Vec3 ( ) ;
677
677
var Body_applyForce_rotForce = new Vec3 ( ) ;
678
- Body . prototype . applyForce = function ( force , worldPoint ) {
679
- if ( this . type !== Body . DYNAMIC ) {
678
+ Body . prototype . applyForce = function ( force , relativePoint ) {
679
+ if ( this . type !== Body . DYNAMIC ) { // Needed?
680
680
return ;
681
681
}
682
682
683
- // Compute point position relative to the body center
684
- var r = Body_applyForce_r ;
685
- worldPoint . vsub ( this . position , r ) ;
686
-
687
683
// Compute produced rotational force
688
684
var rotForce = Body_applyForce_rotForce ;
689
- r . cross ( force , rotForce ) ;
685
+ relativePoint . cross ( force , rotForce ) ;
690
686
691
687
// Add linear force
692
688
this . force . vadd ( force , this . force ) ;
@@ -702,39 +698,38 @@ Body.prototype.applyForce = function(force,worldPoint){
702
698
* @param {Vec3 } localPoint A local point in the body to apply the force on.
703
699
*/
704
700
var Body_applyLocalForce_worldForce = new Vec3 ( ) ;
705
- var Body_applyLocalForce_worldPoint = new Vec3 ( ) ;
701
+ var Body_applyLocalForce_relativePointWorld = new Vec3 ( ) ;
706
702
Body . prototype . applyLocalForce = function ( localForce , localPoint ) {
707
703
if ( this . type !== Body . DYNAMIC ) {
708
704
return ;
709
705
}
710
706
711
707
var worldForce = Body_applyLocalForce_worldForce ;
712
- var worldPoint = Body_applyLocalForce_worldPoint ;
708
+ var relativePointWorld = Body_applyLocalForce_relativePointWorld ;
713
709
714
710
// Transform the force vector to world space
715
711
this . vectorToWorldFrame ( localForce , worldForce ) ;
716
- this . pointToWorldFrame ( localPoint , worldPoint ) ;
712
+ this . vectorToWorldFrame ( localPoint , relativePointWorld ) ;
717
713
718
- this . applyForce ( worldForce , worldPoint ) ;
714
+ this . applyForce ( worldForce , relativePointWorld ) ;
719
715
} ;
720
716
721
717
/**
722
718
* Apply impulse to a world point. This could for example be a point on the Body surface. An impulse is a force added to a body during a short period of time (impulse = force * time). Impulses will be added to Body.velocity and Body.angularVelocity.
723
719
* @method applyImpulse
724
720
* @param {Vec3 } impulse The amount of impulse to add.
725
- * @param {Vec3 } worldPoint A world point to apply the force on.
721
+ * @param {Vec3 } relativePoint A point relative to the center of mass to apply the force on.
726
722
*/
727
723
var Body_applyImpulse_r = new Vec3 ( ) ;
728
724
var Body_applyImpulse_velo = new Vec3 ( ) ;
729
725
var Body_applyImpulse_rotVelo = new Vec3 ( ) ;
730
- Body . prototype . applyImpulse = function ( impulse , worldPoint ) {
726
+ Body . prototype . applyImpulse = function ( impulse , relativePoint ) {
731
727
if ( this . type !== Body . DYNAMIC ) {
732
728
return ;
733
729
}
734
730
735
731
// Compute point position relative to the body center
736
- var r = Body_applyImpulse_r ;
737
- worldPoint . vsub ( this . position , r ) ;
732
+ var r = relativePoint ;
738
733
739
734
// Compute produced central impulse velocity
740
735
var velo = Body_applyImpulse_velo ;
@@ -766,20 +761,20 @@ Body.prototype.applyImpulse = function(impulse, worldPoint){
766
761
* @param {Vec3 } localPoint A local point in the body to apply the force on.
767
762
*/
768
763
var Body_applyLocalImpulse_worldImpulse = new Vec3 ( ) ;
769
- var Body_applyLocalImpulse_worldPoint = new Vec3 ( ) ;
764
+ var Body_applyLocalImpulse_relativePoint = new Vec3 ( ) ;
770
765
Body . prototype . applyLocalImpulse = function ( localImpulse , localPoint ) {
771
766
if ( this . type !== Body . DYNAMIC ) {
772
767
return ;
773
768
}
774
769
775
770
var worldImpulse = Body_applyLocalImpulse_worldImpulse ;
776
- var worldPoint = Body_applyLocalImpulse_worldPoint ;
771
+ var relativePointWorld = Body_applyLocalImpulse_relativePoint ;
777
772
778
773
// Transform the force vector to world space
779
774
this . vectorToWorldFrame ( localImpulse , worldImpulse ) ;
780
- this . pointToWorldFrame ( localPoint , worldPoint ) ;
775
+ this . vectorToWorldFrame ( localPoint , relativePointWorld ) ;
781
776
782
- this . applyImpulse ( worldImpulse , worldPoint ) ;
777
+ this . applyImpulse ( worldImpulse , relativePointWorld ) ;
783
778
} ;
784
779
785
780
var Body_updateMassProperties_halfExtents = new Vec3 ( ) ;
0 commit comments