浏览代码

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++) {
                 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 {
             }
         }
     }
-}
+}