From 3f9b5beb5ced09879d720331af72577e024ae03d Mon Sep 17 00:00:00 2001 From: Ling Zhan Date: Fri, 8 Jul 2022 12:55:58 +0800 Subject: [PATCH] fix: PhysX collision filter needs unsigned int (32bit)(#12970) (#11892) --- cocos/physics/physx/physx-shared-body.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cocos/physics/physx/physx-shared-body.ts b/cocos/physics/physx/physx-shared-body.ts index 8dca8fb10a..3c9ec0a9c2 100644 --- a/cocos/physics/physx/physx-shared-body.ts +++ b/cocos/physics/physx/physx-shared-body.ts @@ -339,6 +339,7 @@ export class PhysXSharedBody { } setGroup (v: number): void { + v >>>= 0; //convert to unsigned int(32bit) for physx this._filterData.word0 = v; this.updateFilterData(); } @@ -348,17 +349,19 @@ export class PhysXSharedBody { } addGroup (v: number): void { + v >>>= 0; //convert to unsigned int(32bit) for physx this._filterData.word0 |= v; this.updateFilterData(); } removeGroup (v: number): void { + v >>>= 0; //convert to unsigned int(32bit) for physx this._filterData.word0 &= ~v; this.updateFilterData(); } setMask (v: number): void { - if (v === -1) v = 0xffffffff; + v >>>= 0; //convert to unsigned int(32bit) for physx this._filterData.word1 = v; this.updateFilterData(); } @@ -368,11 +371,13 @@ export class PhysXSharedBody { } addMask (v: number): void { + v >>>= 0; //convert to unsigned int(32bit) for physx this._filterData.word1 |= v; this.updateFilterData(); } removeMask (v: number): void { + v >>>= 0; //convert to unsigned int(32bit) for physx this._filterData.word1 &= ~v; this.updateFilterData(); }