File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
Extensions/Physics3DBehavior Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -1470,11 +1470,11 @@ namespace gdjs {
1470
1470
const deltaX = towardX - body . GetPosition ( ) . GetX ( ) ;
1471
1471
const deltaY = towardY - body . GetPosition ( ) . GetY ( ) ;
1472
1472
const deltaZ = towardZ - body . GetPosition ( ) . GetZ ( ) ;
1473
- const distance = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ ;
1474
- if ( distance === 0 ) {
1473
+ const distanceSq = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ ;
1474
+ if ( distanceSq === 0 ) {
1475
1475
return ;
1476
1476
}
1477
- const ratio = length / distance ;
1477
+ const ratio = length / Math . sqrt ( distanceSq ) ;
1478
1478
1479
1479
this . _sharedData . bodyInterface . AddForce (
1480
1480
body . GetID ( ) ,
@@ -1540,11 +1540,11 @@ namespace gdjs {
1540
1540
const deltaX = towardX - originX ;
1541
1541
const deltaY = towardY - originY ;
1542
1542
const deltaZ = towardZ - originZ ;
1543
- const distance = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ ;
1544
- if ( distance === 0 ) {
1543
+ const distanceSq = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ ;
1544
+ if ( distanceSq === 0 ) {
1545
1545
return ;
1546
1546
}
1547
- const ratio = length / distance ;
1547
+ const ratio = length / Math . sqrt ( distanceSq ) ;
1548
1548
1549
1549
this . _sharedData . bodyInterface . AddImpulse (
1550
1550
body . GetID ( ) ,
You can’t perform that action at this time.
0 commit comments