소스 검색

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