소스 검색

Merge pull request #6408 from MackeyK24/master

AmmoJSPlugin Update
David Catuhe 6 년 전
부모
커밋
f23c76abae
2개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 0
      dist/preview release/what's new.md
  2. 3 2
      src/Physics/Plugins/ammoJSPlugin.ts

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

@@ -41,6 +41,7 @@
 
 ### Physics
 - Update Ammo.js library to support global collision contact callbacks ([MackeyK24](https://github.com/MackeyK24/))
+- Update AmmoJSPlugin to allow your own broadphase overlapping pair cache ([MackeyK24](https://github.com/MackeyK24/))
 
 ## Bug fixes
 - Added support for `AnimationGroup` serialization ([Drigax](https://github.com/drigax/))

+ 3 - 2
src/Physics/Plugins/ammoJSPlugin.ts

@@ -63,8 +63,9 @@ export class AmmoJSPlugin implements IPhysicsEnginePlugin {
      * Initializes the ammoJS plugin
      * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
      * @param ammoInjection can be used to inject your own ammo reference
+     * @param overlappingPairCache can be used to specify your own overlapping pair cache
      */
-    public constructor(private _useDeltaForWorldStep: boolean = true, ammoInjection: any = Ammo) {
+    public constructor(private _useDeltaForWorldStep: boolean = true, ammoInjection: any = Ammo, overlappingPairCache: any = null) {
         if (typeof ammoInjection === "function") {
             ammoInjection(this.bjsAMMO);
         } else {
@@ -79,7 +80,7 @@ export class AmmoJSPlugin implements IPhysicsEnginePlugin {
         // Initialize the physics world
         this._collisionConfiguration = new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration();
         this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
-        this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
+        this._overlappingPairCache = overlappingPairCache || new this.bjsAMMO.btDbvtBroadphase();
         this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
         this._softBodySolver = new this.bjsAMMO.btDefaultSoftBodySolver();
         this.world = new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration, this._softBodySolver);