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

feat: allow controlling when a fixture is rendered #1648

Merged
merged 10 commits into from Jun 6, 2022

Conversation

alestiago
Copy link
Contributor

@alestiago alestiago commented May 22, 2022

Description

Changes _renderFixtures to renderFixture. This keeps the consistency with the other public render methods in BodyComponent.

Introduces new functionalities:

  • Allow listening when a given fixture is rendered
  • Allows modifying the rendering logic for a given (one or more) fixtures.

For example, avoiding a fixture to be rendered:

class MyBodyComponent extends BodyComponent {
...
void renderFixture(Canvas canvas, Fixture fixture) {
 final avoidRendering = condition; // Any condition here.
  if (avoidRendering) return;
  super.renderFixture(canvas, fixture);
}
...
}

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • I have read the Contributor Guide and followed the process outlined for submitting PRs.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples.

Breaking Change

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

Related Issues

@alestiago alestiago marked this pull request as draft May 22, 2022 16:02
@spydon
Copy link
Member

spydon commented May 22, 2022

I don't think we should rely on userdata for this (preferably we shouldn't rely on userdata for anything, it is a way too fragile pattern).

@alestiago
Copy link
Contributor Author

alestiago commented May 22, 2022

(cc: @spydon )

This PR is an initial proposal to filter the rendering of some fixtures. Once settled, I'll update tests, examples and docs.

@alestiago
Copy link
Contributor Author

alestiago commented May 22, 2022

I don't think we should rely on userdata for this (preferably we shouldn't rely on userdata for anything, it is a way too fragile pattern).

Thanks @spydon for having a look. One doesn't need to rely on userData, as pointed out in the description, one can store those fixtures that would be skipped during rendering and check against that list.

Is up to the developer how they wish to filter the fixtures. For example, if they don't want to render edge sapes, they can check for it.

I've updated the example, since using userData is discouraged.

@alestiago alestiago changed the title feat: allow rendering some Fixtures feat: allow controlling when a fixture is rendered May 22, 2022
@alestiago alestiago changed the title feat: allow controlling when a fixture is rendered feat(flame_forge2d): allow controlling when a fixture is rendered May 22, 2022
@alestiago
Copy link
Contributor Author

alestiago commented Jun 1, 2022

Sorry for the delay on this open PR. Been busy, I will like to prioritise it this weekend.

@alestiago alestiago marked this pull request as ready for review June 5, 2022 14:12
Copy link
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

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

Great with some goldens here too :)
You don't have to put flame_forge2d in the scope that is already derived from what files that are changes, the scope is more if you have a bigger epic that you're working on for example.

Copy link
Member

@luanpotter luanpotter left a comment

Choose a reason for hiding this comment

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

LGTM with one comment. Nice tests!

@spydon spydon enabled auto-merge (squash) June 6, 2022 08:55
@spydon spydon disabled auto-merge June 6, 2022 08:56
@spydon spydon enabled auto-merge (squash) June 6, 2022 08:56
@spydon spydon disabled auto-merge June 6, 2022 08:56
@spydon spydon enabled auto-merge (squash) June 6, 2022 08:56
@spydon spydon changed the title feat(flame_forge2d): allow controlling when a fixture is rendered feat: allow controlling when a fixture is rendered Jun 6, 2022
@spydon spydon merged commit 1b59d80 into flame-engine:main Jun 6, 2022
@alestiago alestiago deleted the feat/rendering-fixtures-public branch June 6, 2022 09:50
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.

None yet

4 participants