Skip to content

[fix] physics-2d contact disable not working #15149 (#15158) #15224

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

Merged
merged 5 commits into from
May 31, 2023

Conversation

lealzhan
Copy link
Contributor

Re: #

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

* [fix] physics-2d contact disable not working cocos#15149

* tweaks and add docs
@lealzhan lealzhan requested a review from SantyWang May 30, 2023 05:52
@@ -87,17 +95,26 @@ export class PhysicsContactListener extends b2.ContactListener {
public finalizeContactEvent () {
PhysicsContactListener._contactMap.forEach((contact: PhysicsContact, key: string) => {
//console.log('forEach', key, collision);

// emit collision event
if (!contact.disabled || contact.status === Contact2DType.BEGIN_CONTACT) { //BEGIN_CONTACT always emits
Copy link
Contributor

Choose a reason for hiding this comment

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

Why always emit event when begin contact.

Copy link
Contributor Author

@lealzhan lealzhan May 30, 2023

Choose a reason for hiding this comment

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

Why always emit event when begin contact.

PhysicsContact is destroyed when ref decreases to 0, and not recycled. User can never get a PhysicsConact before BeginContact to disable it. However this check seems redundant, which I think can be removed.

Choose a reason for hiding this comment

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

It is still not fixed contact.disable in cocos creator 3.7.4 still not working @lealzhan

@lealzhan lealzhan merged commit 9d6527b into cocos:v3.7.4 May 31, 2023
cocos-robot pushed a commit to cocos-robot/engine that referenced this pull request May 31, 2023
minggo pushed a commit that referenced this pull request Jun 1, 2023
…15249)

Co-authored-by: cocos-robot <cocos-robot@cocos.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants