bevy/crates/bevy_render/src
ickk a0448eca2f enum Visibility component (#6320)
Consolidation of all the feedback about #6271 as well as the addition of an "unconditionally visible" mode.

# Objective

The current implementation of the `Visibility` struct simply wraps a boolean.. which seems like an odd pattern when rust has such nice enums that allow for more expression using pattern-matching. 

Additionally as it stands Bevy only has two settings for visibility of an entity: 
- "unconditionally hidden" `Visibility { is_visible: false }`, 
- "inherit visibility from parent" `Visibility { is_visible: true }`
   where a root level entity set to "inherit" is visible. 

Note that given the behaviour, the current naming of the inner field is a little deceptive or unclear.

Using an enum for `Visibility` opens the door for adding an extra behaviour mode. This PR adds a new "unconditionally visible" mode, which causes an entity to be visible even if its Parent entity is hidden. There should not really be any performance cost to the addition of this new mode.

--
The recently added `toggle` method is removed in this PR, as its semantics could be confusing with 3 variants.

## Solution

Change the Visibility component into
```rust
enum Visibility {
  Hidden,    // unconditionally hidden
  Visible,   // unconditionally visible
  Inherited, // inherit visibility from parent
}
```

---

## Changelog

### Changed

`Visibility` is now an enum

## Migration Guide

- evaluation of the `visibility.is_visible` field should now check for `visibility == Visibility::Inherited`.
- setting the `visibility.is_visible` field should now directly set the value: `*visibility = Visibility::Inherited`.
- usage of `Visibility::VISIBLE` or `Visibility::INVISIBLE` should now use `Visibility::Inherited` or `Visibility::Hidden` respectively.
- `ComputedVisibility::INVISIBLE` and `SpatialBundle::VISIBLE_IDENTITY` have been renamed to `ComputedVisibility::HIDDEN` and `SpatialBundle::INHERITED_IDENTITY` respectively.






Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2022-12-25 00:39:29 +00:00
..
camera bevy_reflect: Register missing reflected types for bevy_render (#6725) 2022-11-23 00:41:21 +00:00
color Add with_a and friends to Color (#6899) 2022-12-11 18:34:16 +00:00
mesh Fix clippy lints and failed test with Rust 1.66 (#6945) 2022-12-15 18:05:15 +00:00
primitives
render_graph Replace UUID based IDs with a atomic-counted ones (#6988) 2022-12-25 00:23:15 +00:00
render_phase Shrink DrawFunctionId (#6944) 2022-12-20 15:40:42 +00:00
render_resource Replace UUID based IDs with a atomic-counted ones (#6988) 2022-12-25 00:23:15 +00:00
renderer Add try_* to add_slot_edge, add_node_edge (#6720) 2022-11-21 21:58:39 +00:00
texture Fix alpha channel in RGB32F image texture format conversion (#6914) 2022-12-11 18:46:47 +00:00
view enum Visibility component (#6320) 2022-12-25 00:39:29 +00:00
extract_component.rs ExtractComponent output optional associated type (#6699) 2022-11-21 13:19:44 +00:00
extract_param.rs Simplify trait hierarchy for SystemParam (#6865) 2022-12-11 18:34:14 +00:00
extract_resource.rs Prepare for upcoming rustlang by fixing upcoming clippy warnings (#6376) 2022-10-26 19:15:15 +00:00
globals.rs bevy_reflect: Register missing reflected types for bevy_render (#6725) 2022-11-23 00:41:21 +00:00
lib.rs Move 'startup' Resource WgpuSettings into the RenderPlugin (#6946) 2022-12-20 16:17:11 +00:00
rangefinder.rs
render_asset.rs Fix clippy::iter_with_drain (#6485) 2022-11-06 01:42:15 +00:00
settings.rs Move 'startup' Resource WgpuSettings into the RenderPlugin (#6946) 2022-12-20 16:17:11 +00:00
spatial_bundle.rs enum Visibility component (#6320) 2022-12-25 00:39:29 +00:00