浏览代码

Merge pull request #8028 from CedricGuillemet/ammoCollisionFilter

Ammo.js collision group and mask supported by impostor parameters
sebavan 5 年之前
父节点
当前提交
c26ba48aad
共有 2 个文件被更改,包括 8 次插入1 次删除
  1. 1 0
      dist/preview release/what's new.md
  2. 7 1
      src/Physics/Plugins/ammoJSPlugin.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -50,6 +50,7 @@
 ### Physics
 
 - Fixed time steps or delta time with sub time step for Oimo.js and Cannon.js ([cedricguillemet](https://github.com/cedricguillemet))
+- Ammo.js collision group and mask supported by impostor parameters ([cedricguillemet](https://github.com/cedricguillemet))
 - Ammo.js IDL exposed property update and raycast vehicle stablization support ([MackeyK24](https://github.com/MackeyK24))
 - Recast.js plugin nav mesh and crowd agent to ref performance optimizations. ([MackeyK24](https://github.com/MackeyK24))
 - Added `scene.physicsEnabled` boolean ([Deltakosh](https://github.com/deltakosh))

+ 7 - 1
src/Physics/Plugins/ammoJSPlugin.ts

@@ -447,7 +447,13 @@ export class AmmoJSPlugin implements IPhysicsEnginePlugin {
                     body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
                 }
 
-                this.world.addRigidBody(body);
+                let group = impostor.getParam("group");
+                let mask = impostor.getParam("mask");
+                if (group && mask) {
+                    this.world.addRigidBody(body, group, mask);
+                } else {
+                    this.world.addRigidBody(body);
+                }
                 impostor.physicsBody = body;
                 impostor._pluginData.toDispose = impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
             }