From 5acea3c3edcf01c17efc7fc990df67e6c0032147 Mon Sep 17 00:00:00 2001 From: songbo Date: Fri, 26 Jul 2024 14:37:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Fixed=20the=20problem=20of=20reuse=20of?= =?UTF-8?q?=20physical=20component=20collider.=20=E4=BF=AE=E5=A4=8D:=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=89=A9=E7=90=86=E7=BB=84=E4=BB=B6collider?= =?UTF-8?q?=E5=A4=8D=E7=94=A8=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layaAir/laya/Physics3D/Bullet/btPhysicsManager.ts | 8 ++++++-- src/layaAir/laya/Physics3D/PhysX/pxPhysicsManager.ts | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/layaAir/laya/Physics3D/Bullet/btPhysicsManager.ts b/src/layaAir/laya/Physics3D/Bullet/btPhysicsManager.ts index 3cc3243761..88662fc8f2 100644 --- a/src/layaAir/laya/Physics3D/Bullet/btPhysicsManager.ts +++ b/src/layaAir/laya/Physics3D/Bullet/btPhysicsManager.ts @@ -272,14 +272,18 @@ export class btPhysicsManager implements IPhysicsManager { bt.btGImpactCollisionAlgorithm_RegisterAlgorithm(this._btDispatcher);//注册算法 this.initPhysicsCapable(); // 初始化物理能力 } - setActiveCollider(collider: ICollider, value: boolean): void { + setActiveCollider(collider: btCollider, value: boolean): void { collider.active = value; + if (value) { + collider._physicsManager = this; + } else { + collider._physicsManager = null; + } } sphereQuery?(pos: Vector3, radius: number, result: ICollider[], collisionmask: number): void { throw new Error("Method not implemented."); } - /** * @internal diff --git a/src/layaAir/laya/Physics3D/PhysX/pxPhysicsManager.ts b/src/layaAir/laya/Physics3D/PhysX/pxPhysicsManager.ts index f27b429af1..22174b8bc9 100644 --- a/src/layaAir/laya/Physics3D/PhysX/pxPhysicsManager.ts +++ b/src/layaAir/laya/Physics3D/PhysX/pxPhysicsManager.ts @@ -130,8 +130,13 @@ export class pxPhysicsManager implements IPhysicsManager { } this.fixedTime = physicsSettings.fixedTimeStep; } - setActiveCollider(collider: ICollider, value: boolean): void { + setActiveCollider(collider: pxCollider, value: boolean): void { collider.active = value; + if (value) { + collider._physicsManager = this; + } else { + collider._physicsManager = null; + } } enableDebugDrawer?(value: boolean): void { throw new Error("Method not implemented.");