Explorar o código

Merge pull request #1090 from RaananW/physics-fixes

fixing two issues with physics and playground
David Catuhe %!s(int64=9) %!d(string=hai) anos
pai
achega
8e9b1b7fee

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