Преглед изворни кода

Force used to applyImpulse is now scaled with mass

In Oimo, the mass is not directly set. The force used to move this object should be scaled by the mass of the object.
Temechon пре 11 година
родитељ
комит
1b083330d1
1 измењених фајлова са 5 додато и 2 уклоњено
  1. 5 2
      Babylon/Physics/Plugins/babylon.oimoJSPlugin.ts

+ 5 - 2
Babylon/Physics/Plugins/babylon.oimoJSPlugin.ts

@@ -229,7 +229,10 @@ module BABYLON {
             for (var index = 0; index < this._registeredMeshes.length; index++) {
             for (var index = 0; index < this._registeredMeshes.length; index++) {
                 var registeredMesh = this._registeredMeshes[index];
                 var registeredMesh = this._registeredMeshes[index];
                 if (registeredMesh.mesh === mesh || registeredMesh.mesh === mesh.parent) {
                 if (registeredMesh.mesh === mesh || registeredMesh.mesh === mesh.parent) {
-                    registeredMesh.body.body.applyImpulse(contactPoint.scale(OIMO.INV_SCALE), force.scale(OIMO.INV_SCALE));
+                    // Get object mass to have a behaviour similar to cannon.js
+                    var mass = registeredMesh.body.body.massInfo.mass;
+                    // The force is scaled with the mass of object
+                    registeredMesh.body.body.applyImpulse(contactPoint.scale(OIMO.INV_SCALE), force.scale(OIMO.INV_SCALE*mass));
                     return;
                     return;
                 }
                 }
             }
             }
@@ -345,4 +348,4 @@ module BABYLON {
             }
             }
         }
         }
     }
     }
-}
+}