From 3933474f3e6290a89f1fbf7577e4e626f45cdcd7 Mon Sep 17 00:00:00 2001 From: "jiaxin.lai" Date: Wed, 2 Sep 2020 15:32:48 +0800 Subject: [PATCH] change default mask value of collision matrix (#7277) --- cocos/physics/framework/physics-system.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cocos/physics/framework/physics-system.ts b/cocos/physics/framework/physics-system.ts index ac59380ac9..a4003b41b4 100644 --- a/cocos/physics/framework/physics-system.ts +++ b/cocos/physics/framework/physics-system.ts @@ -14,20 +14,18 @@ import { PhysicsRayResult } from './physics-ray-result'; import { EDITOR, DEBUG } from 'internal:constants'; import { IPhysicsConfig, ICollisionMatrix } from './physics-config'; -const PhysicsGroup = { - DEFAULT: 1, -}; +enum PhysicsGroup { + DEFAULT = 1, +} Enum(PhysicsGroup); legacyCC.internal.PhysicsGroup = PhysicsGroup; class CollisionMatrix { - updateArray: number[] = []; - constructor () { for (let i = 0; i < 32; i++) { const key = 1 << i; - this[`_${key}`] = 0xffffffff; + this[`_${key}`] = 0; Object.defineProperty(this, key, { 'get': function () { return this[`_${key}`] }, 'set': function (v: number) { @@ -41,6 +39,7 @@ class CollisionMatrix { } }) } + this[`_1`] = PhysicsGroup.DEFAULT; } } @@ -300,7 +299,7 @@ export class PhysicsSystem extends System { if (config.collisionMatrix) { for (const i in config.collisionMatrix) { const key = 1 << parseInt(i); - this.collisionMatrix[`_${key}`] = config.collisionMatrix[key]; + this.collisionMatrix[`_${key}`] = config.collisionMatrix[i]; } } } else {