Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IPhysicsScene.removeColliderShape not cleaned up eventMap #2008

Merged
merged 3 commits into from
Feb 26, 2024

Conversation

cptbtptpbcptdtptp
Copy link
Collaborator

No description provided.

@cptbtptpbcptdtptp cptbtptpbcptdtptp added physics Engine's physical system high priority High priority issue labels Feb 22, 2024
@cptbtptpbcptdtptp cptbtptpbcptdtptp self-assigned this Feb 22, 2024
Copy link
Contributor

@luzhuang luzhuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

eventPool.push(event);
}
}
delete this._eventMap[shapeID];
delete eventMap[shapeID];
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write this to save map access performance and strengthen logical rigor

/**
   * {@inheritDoc IPhysicsManager.removeColliderShape }
   */
  removeColliderShape(colliderShape: LiteColliderShape): void {
    const { _eventPool: eventPool, _currentEvents: currentEvents, _eventMap: eventMap } = this;
    const { _id: shapeID } = colliderShape;
    for (let i = currentEvents.length - 1; i >= 0; i--) {
      const event = currentEvents.get(i);
      
      const isShape2 = event.index2 == shapeID;
      if (isShape2 || event.index1 == shapeID) {
        currentEvents.deleteByIndex(i);
        eventPool.push(event);

        // If the shape is big index, should clear from the small index shape subMap
        isShape2 && (eventMap[event.index1][event.index2] = undefined);
      }
    }
    delete eventMap[shapeID];
  }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@GuoLei1990
Copy link
Member

GuoLei1990 commented Feb 23, 2024

Bad news: @luzhuang

  • StaticCollider and StaticCollider shouldn't have trigger event or collision event, unit test logic is wrong
  • The collider shape not set isTrigger = true, but trigger event fired
    image

@GuoLei1990 GuoLei1990 merged commit 809ddf2 into galacean:main Feb 26, 2024
6 checks passed
GuoLei1990 added a commit that referenced this pull request Feb 29, 2024
* main:
  Fix gltf accessor's bufferView could be undefined (#2013)
  Fix `IPhysicsScene.removeColliderShape` not cleaned up `eventMap` (#2008)
@GuoLei1990 GuoLei1990 added the bug Something isn't working label Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority High priority issue physics Engine's physical system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants