From 67fdf4f65b436bda961efd97c47b47826f4ef381 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 15 Oct 2024 15:37:59 +0300 Subject: [PATCH] pointer fix (#7038) --- src/framework/components/collision/component.js | 4 ++-- src/framework/components/collision/system.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/framework/components/collision/component.js b/src/framework/components/collision/component.js index 34c681606d7..c1361d0e339 100644 --- a/src/framework/components/collision/component.js +++ b/src/framework/components/collision/component.js @@ -626,13 +626,13 @@ class CollisionComponent extends Component { * @returns {number|null} The shape's index in the child array of the compound shape. * @private */ - _getCompoundChildShapeIndex(shape) { + getCompoundChildShapeIndex(shape) { const compound = this.data.shape; const shapes = compound.getNumChildShapes(); for (let i = 0; i < shapes; i++) { const childShape = compound.getChildShape(i); - if (childShape.ptr === shape.ptr) { + if (Ammo.getPointer(childShape) === Ammo.getPointer(shape)) { return i; } } diff --git a/src/framework/components/collision/system.js b/src/framework/components/collision/system.js index bd8ef217672..ec69b67cef4 100644 --- a/src/framework/components/collision/system.js +++ b/src/framework/components/collision/system.js @@ -818,7 +818,7 @@ class CollisionComponentSystem extends ComponentSystem { if (entity.enabled && entity.collision.enabled && (entity._dirtyLocal || forceUpdate)) { const transform = this._getNodeTransform(entity, parentComponent.entity); - const idx = parentComponent._getCompoundChildShapeIndex(entity.collision.shape); + const idx = parentComponent.getCompoundChildShapeIndex(entity.collision.shape); if (idx === null) { parentComponent.shape.addChildShape(transform, entity.collision.data.shape); } else { @@ -836,7 +836,7 @@ class CollisionComponentSystem extends ComponentSystem { if (collision.shape.removeChildShape) { collision.shape.removeChildShape(shape); } else { - const ind = collision._getCompoundChildShapeIndex(shape); + const ind = collision.getCompoundChildShapeIndex(shape); if (ind !== null) { collision.shape.removeChildShapeByIndex(ind); }