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

Allow overriding global wireframe setting. #7328

Merged
merged 1 commit into from
Oct 4, 2023

Conversation

Wcubed
Copy link
Contributor

@Wcubed Wcubed commented Jan 22, 2023

Objective

Allow the user to choose between "Add wireframes to these specific entities" or "Add wireframes to everything except these specific entities".
Fixes #7309

Solution

Make the Wireframe component act like an override to the global configuration.
Having global set to false, and adding a Wireframe with enable: true acts exactly as before.
But now the opposite is also possible: Set global to true and add a Wireframe with enable: false will draw wireframes for everything except that entity.

Updated the example to show how overriding the global config works.

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Jan 23, 2023
crates/bevy_pbr/src/wireframe.rs Outdated Show resolved Hide resolved
@tigregalis
Copy link
Contributor

tigregalis commented Jan 25, 2023

Setting wireframe.enable = true to disable displaying wireframes feels wrong to me.

I'd suggest changing the local per-entity Wireframe "policy" to be more explicit (bikeshed the names of the enum variants):

/// Local per-entity wireframe config.
// ... attributes ...
pub enum Wireframe { // or `WireframePolicy` or `LocalWireframeConfig` as a field of `struct Wireframe`
    /// Follow the global config, for example if `WireframeConfig { global: true }`, this entity will show a wireframe, but if `WireframeConfig { global: false }`, this entity won't show a wireframe
    UseGlobalConfig,
    /// Use the opposite of the global config, for example if `WireframeConfig { global: true }`, this entity won't show a wireframe, but if `WireframeConfig { global: false }`, this entity will show a wireframe
    InvertGlobalConfig,
    /// Ignore the global config, and show a wireframe
    Always,
    /// Ignore the global config, and don't show the wireframe
    Never,
}

These first two *GlobalConfig variants correspond to your Wireframe { enable: bool }.

These additional variants Always and Never means that for specific entities, you can know for certain that a specific entity shows or does not show a wireframe, without querying the WireframeConfig.

@Wcubed
Copy link
Contributor Author

Wcubed commented Jan 26, 2023

@tigregalis I think you misunderstood. It was wireframe.enable = false that would make it never show the wireframe, regardless of global config. Which did show to me that my implementation was probably not as clear as it could be 😃.

I changed the wireframe component to WireframeOverride::AlwaysRender and WireframeOverride::NeverRender, to make it clear that it will make the mesh not care about the global config.

@Wcubed Wcubed force-pushed the wireframe-override branch from 47085b0 to 167ec34 Compare January 26, 2023 19:55
@tigregalis
Copy link
Contributor

I've had a play with this and the new API makes sense to me. I've extended the example to show what toggling the global config does for entities with different local wireframe configs (red = never, yellow = no component, green = always); is this updated example something we want?

Bevy.App.2023-01-30.18-26-35.mp4

@Wcubed
Copy link
Contributor Author

Wcubed commented Jan 30, 2023

I like it. I hadn't even thought of doing that. Makes it very clear what effects each option has.

@Wcubed Wcubed force-pushed the wireframe-override branch from 167ec34 to 2b2584a Compare January 31, 2023 09:04
@github-actions
Copy link
Contributor

Example alien_cake_addict failed to run, please try running it locally and check the result.

@Wcubed Wcubed force-pushed the wireframe-override branch from 2b2584a to 8f171bf Compare March 12, 2023 14:46
Copy link
Contributor

@Shatur Shatur left a comment

Choose a reason for hiding this comment

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

I'm not sure if I like the new name WireframeOverride.
Maybe keep the original Wireframe name? It shorter and still makes sense since it works regardless of global config.

crates/bevy_pbr/src/wireframe.rs Outdated Show resolved Hide resolved
@Wcubed Wcubed force-pushed the wireframe-override branch from 8f171bf to fe08a66 Compare March 31, 2023 19:03
@Wcubed
Copy link
Contributor Author

Wcubed commented Mar 31, 2023

I'm not sure if I like the new name WireframeOverride. Maybe keep the original Wireframe name? It shorter and still makes sense since it works regardless of global config.

Good point. The AlwaysRender and NeverRender names already indicate it is an override, so the additional Override in the name is redundant 👍

@Wcubed Wcubed requested a review from james7132 June 18, 2023 12:24
examples/3d/wireframe.rs Outdated Show resolved Hide resolved
@Wcubed Wcubed force-pushed the wireframe-override branch from fe08a66 to 6703d88 Compare July 15, 2023 15:50
@Wcubed
Copy link
Contributor Author

Wcubed commented Jul 15, 2023

Brought up to date with 0.11, and fixed typo pointed out by shatur

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

This is a better strategy, and the docs and code quality seem good.

@Shatur
Copy link
Contributor

Shatur commented Sep 30, 2023

@Wcubed could you resolve conflicts?

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Sep 30, 2023
@Wcubed Wcubed force-pushed the wireframe-override branch from 6703d88 to ea78a22 Compare October 3, 2023 17:30
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Oct 4, 2023
Merged via the queue into bevyengine:main with commit f9e50e7 Oct 4, 2023
21 checks passed
@IceSentry
Copy link
Contributor

So, I wasn't aware of this PR and I think the merged api should have been different. I'd like to suggest it here first to see what people think and see if there's agreement.

I believe the api should have used 2 separate components Wireframe and NoWireframe (or maybe NoGlobalWireframe, NeverRenderWireframe, naming isn't really the point)

I think this is better for a few reasons:

  • Easier to migrate since it doesn't change the old behaviour. Essentially nothing to migrate. Right now this PR is a breaking change but I don't think it has to be.
  • It's similar to other "per mesh" rendering features like NotShadowCaster/NotShadowReceiver
  • It doesn't force new users to also think about global vs not global if all they want is to render a wireframe
  • This would also let you filter at the query definition level instead of filtering when running the query

@IceSentry
Copy link
Contributor

IceSentry commented Oct 4, 2023

If we decide to keep this api, please consider adding a migration guide section to the PR description.

@IceSentry IceSentry added the M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Oct 4, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2023

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Could you add some context on what users should update when this change get released in a new version of Bevy?
It will be used to help writing the migration guide for the version. Putting it after a ## Migration Guide will help it get automatically picked up by our tooling.

@mockersf
Copy link
Member

mockersf commented Oct 4, 2023

it seems this PR broke rendering wireframes on windows / DX12
4a70c28683d006612a308b440640b77d41660816281512fad182519013d51071

@IceSentry
Copy link
Contributor

IceSentry commented Oct 4, 2023

I don't think this was caused by this PR. It's also broken when using DX12 on the commit before this PR. The issue seems to be be with the DX12 backend.

Here's a screenshot from before this PR
image

@mockersf
Copy link
Member

mockersf commented Oct 4, 2023

@IceSentry two PRs that were merged at the same time, this one and #9895. I assumed wireframe being broken was due to the PR changing wireframes. It worked before those two, could you check the commit before (375af64)?

@IceSentry
Copy link
Contributor

IceSentry commented Oct 4, 2023

I went back to #9796 and it's still broken when using DX12 for me.

Back to f69e923 and it still doesn't work correctly.

@IceSentry
Copy link
Contributor

I created this PR with my proposed changes to make the API non breaking while keeping the override feature #10023

@Wcubed Wcubed deleted the wireframe-override branch October 5, 2023 07:36
github-merge-queue bot pushed a commit that referenced this pull request Oct 5, 2023
# Objective

#7328 introduced an API to
override the global wireframe config. I believe it is flawed for a few
reasons.

This PR uses a non-breaking API. Instead of making the `Wireframe` an
enum I introduced the `NeverRenderWireframe` component. Here's the
reason why I think this is better:
- Easier to migrate since it doesn't change the old behaviour.
Essentially nothing to migrate. Right now this PR is a breaking change
but I don't think it has to be.
- It's similar to other "per mesh" rendering features like
NotShadowCaster/NotShadowReceiver
- It doesn't force new users to also think about global vs not global if
all they want is to render a wireframe
- This would also let you filter at the query definition level instead
of filtering when running the query

## Solution

- Introduce a `NeverRenderWireframe` component that ignores the global
config

---

## Changelog

- Added a `NeverRenderWireframe` component that ignores the global
`WireframeConfig`
@cart cart mentioned this pull request Oct 13, 2023
43 tasks
regnarock pushed a commit to regnarock/bevy that referenced this pull request Oct 13, 2023
# Objective

Allow the user to choose between "Add wireframes to these specific
entities" or "Add wireframes to everything _except_ these specific
entities".
Fixes bevyengine#7309

# Solution
Make the `Wireframe` component act like an override to the global
configuration.
Having `global` set to `false`, and adding a `Wireframe` with `enable:
true` acts exactly as before.
But now the opposite is also possible: Set `global` to `true` and add a
`Wireframe` with `enable: false` will draw wireframes for everything
_except_ that entity.

Updated the example to show how overriding the global config works.
regnarock pushed a commit to regnarock/bevy that referenced this pull request Oct 13, 2023
# Objective

bevyengine#7328 introduced an API to
override the global wireframe config. I believe it is flawed for a few
reasons.

This PR uses a non-breaking API. Instead of making the `Wireframe` an
enum I introduced the `NeverRenderWireframe` component. Here's the
reason why I think this is better:
- Easier to migrate since it doesn't change the old behaviour.
Essentially nothing to migrate. Right now this PR is a breaking change
but I don't think it has to be.
- It's similar to other "per mesh" rendering features like
NotShadowCaster/NotShadowReceiver
- It doesn't force new users to also think about global vs not global if
all they want is to render a wireframe
- This would also let you filter at the query definition level instead
of filtering when running the query

## Solution

- Introduce a `NeverRenderWireframe` component that ignores the global
config

---

## Changelog

- Added a `NeverRenderWireframe` component that ignores the global
`WireframeConfig`
ameknite pushed a commit to ameknite/bevy that referenced this pull request Nov 6, 2023
# Objective

Allow the user to choose between "Add wireframes to these specific
entities" or "Add wireframes to everything _except_ these specific
entities".
Fixes bevyengine#7309

# Solution
Make the `Wireframe` component act like an override to the global
configuration.
Having `global` set to `false`, and adding a `Wireframe` with `enable:
true` acts exactly as before.
But now the opposite is also possible: Set `global` to `true` and add a
`Wireframe` with `enable: false` will draw wireframes for everything
_except_ that entity.

Updated the example to show how overriding the global config works.
ameknite pushed a commit to ameknite/bevy that referenced this pull request Nov 6, 2023
# Objective

bevyengine#7328 introduced an API to
override the global wireframe config. I believe it is flawed for a few
reasons.

This PR uses a non-breaking API. Instead of making the `Wireframe` an
enum I introduced the `NeverRenderWireframe` component. Here's the
reason why I think this is better:
- Easier to migrate since it doesn't change the old behaviour.
Essentially nothing to migrate. Right now this PR is a breaking change
but I don't think it has to be.
- It's similar to other "per mesh" rendering features like
NotShadowCaster/NotShadowReceiver
- It doesn't force new users to also think about global vs not global if
all they want is to render a wireframe
- This would also let you filter at the query definition level instead
of filtering when running the query

## Solution

- Introduce a `NeverRenderWireframe` component that ignores the global
config

---

## Changelog

- Added a `NeverRenderWireframe` component that ignores the global
`WireframeConfig`
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

Allow the user to choose between "Add wireframes to these specific
entities" or "Add wireframes to everything _except_ these specific
entities".
Fixes bevyengine#7309

# Solution
Make the `Wireframe` component act like an override to the global
configuration.
Having `global` set to `false`, and adding a `Wireframe` with `enable:
true` acts exactly as before.
But now the opposite is also possible: Set `global` to `true` and add a
`Wireframe` with `enable: false` will draw wireframes for everything
_except_ that entity.

Updated the example to show how overriding the global config works.
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

bevyengine#7328 introduced an API to
override the global wireframe config. I believe it is flawed for a few
reasons.

This PR uses a non-breaking API. Instead of making the `Wireframe` an
enum I introduced the `NeverRenderWireframe` component. Here's the
reason why I think this is better:
- Easier to migrate since it doesn't change the old behaviour.
Essentially nothing to migrate. Right now this PR is a breaking change
but I don't think it has to be.
- It's similar to other "per mesh" rendering features like
NotShadowCaster/NotShadowReceiver
- It doesn't force new users to also think about global vs not global if
all they want is to render a wireframe
- This would also let you filter at the query definition level instead
of filtering when running the query

## Solution

- Introduce a `NeverRenderWireframe` component that ignores the global
config

---

## Changelog

- Added a `NeverRenderWireframe` component that ignores the global
`WireframeConfig`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wireframe configuration
7 participants