Просмотр исходного кода

fixing two issues with physics and playground

The first is an Oimo bug. Used a different method.
The second should make things a bit faster.
Raanan Weber 9 лет назад
Родитель
Сommit
f3be1271e3

+ 10 - 2
src/Physics/Plugins/babylon.oimoJSPlugin.ts

@@ -277,8 +277,16 @@ module BABYLON {
             impostorJoint.joint.physicsJoint = new OIMO.Link(nativeJointData).joint//this.world.add(nativeJointData);
         }
 
-        public removeJoint(joint: PhysicsImpostorJoint) {
-            joint.joint.physicsJoint.dispose();
+        public removeJoint(impostorJoint: PhysicsImpostorJoint) {
+            //Bug in Oimo prevents us from disposing a joint in the playground
+            //joint.joint.physicsJoint.dispose();
+            //So we will bruteforce it!
+            try {
+                this.world.removeJoint(impostorJoint.joint.physicsJoint);
+            } catch(e) {
+                Tools.Warn(e);
+            }
+            
         }
 
         public isSupported(): boolean {

+ 1 - 0
src/Physics/babylon.physicsImpostor.ts

@@ -328,6 +328,7 @@ module BABYLON {
 
         //event and body object due to cannon's event-based architecture.
         public onCollide = (e: { body: any }) => {
+            if(!this._onPhysicsCollideCallbacks.length) return;
             var otherImpostor = this._physicsEngine.getImpostorWithPhysicsBody(e.body);
             if (otherImpostor) {
                 this._onPhysicsCollideCallbacks.filter((obj) => {