瀏覽代碼

Merge pull request #873 from RaananW/collisionData_to_physics_collision

Adding Contact Data to physics collisions
Raanan Weber 9 年之前
父節點
當前提交
850d8a5073

+ 1 - 1
src/Mesh/babylon.abstractMesh.ts

@@ -74,7 +74,7 @@
         public _physicsMass: number;
         public _physicsFriction: number;
         public _physicRestitution: number;
-        public onPhysicsCollide: (collidedMesh: AbstractMesh) => void; 
+        public onPhysicsCollide: (collidedMesh: AbstractMesh, contact: any) => void; 
 
         // Collisions
         private _checkCollisions = false;

+ 1 - 1
src/Physics/Plugins/babylon.cannonJSPlugin.ts

@@ -57,7 +57,7 @@
                             //find the mesh that collided with the registered mesh
                             for (var idx = 0; idx < this._registeredMeshes.length; idx++) {
                                 if (this._registeredMeshes[idx].body == e.body) {
-                                    registeredMesh.mesh.onPhysicsCollide(this._registeredMeshes[idx].mesh);
+                                    registeredMesh.mesh.onPhysicsCollide(this._registeredMeshes[idx].mesh, e.contact);
                                 }
                             }
                         }

+ 1 - 1
src/Physics/Plugins/babylon.oimoJSPlugin.ts

@@ -402,7 +402,7 @@ module BABYLON {
                             //get the mesh and execute the callback
                             var otherMesh = mesh.getScene().getMeshByUniqueID(otherUniqueId);
                             if (otherMesh)
-                                mesh.onPhysicsCollide(otherMesh);
+                                mesh.onPhysicsCollide(otherMesh, contact);
                         }
                         contact = contact.next;
                     }