Skip to content

Commit

Permalink
pointer fix (#7038)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeXXik authored Oct 15, 2024
1 parent 2f0b136 commit 67fdf4f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/framework/components/collision/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/framework/components/collision/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand Down

0 comments on commit 67fdf4f

Please sign in to comment.