Explorar o código

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 %!s(int64=11) %!d(string=hai) anos
pai
achega
1b083330d1
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  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++) {
                 var registeredMesh = this._registeredMeshes[index];
                 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;
                 }
             }
@@ -345,4 +348,4 @@ module BABYLON {
             }
         }
     }
-}
+}