bevy/crates/bevy_gizmos/src
Alice Cecile 5860e01432
Use LinearRgba in bevy_gizmos internals (#12128)
# Objective

This PR arose as part of the migration process for `bevy_color`: see
#12056.

While examining how `bevy_gizmos` stores color types internally, I found
that rather than storing a `Color` internally, it actually stores a
`[f32;4]` for a linear RGB, type aliased to a `ColorItem`.

While we don't *have* to clean this up to complete the migration, now
that we have explicit strong typing for linear color types we should use
them rather than replicating this idea throughout the codebase.

## Solution

- Added `LinearRgba::NAN`, for when you want to do cursed rendering
things.
- Replaced the internal color representation in `bevy_gizmo`: this was
`ColorItem`, but is now `LinearRgba`.
- `LinearRgba` is now `Pod`, enabling us to use the same fast `bytemuck`
bit twiddling tricks that we were using before. This requires:

1. Forcing `LinearRgba` to be `repr(C)`
2. Implementing `Zeroable`, and unsafe trait which defines what the
struct looks like when all values are zero.
3. Implementing `Pod`, a marker trait with stringent safety requirements
that is required for "plain old data".

---------

Co-authored-by: Alice Cecile <alice.i.cecil@gmail.com>
2024-02-26 23:50:33 +00:00
..
primitives Add Direction3dA and move direction types out of primitives (#12018) 2024-02-26 13:57:49 +00:00
aabb.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
arcs.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
arrows.rs Rename bevy_render::Color to LegacyColor (#12069) 2024-02-24 21:35:32 +00:00
circles.rs Add Direction3dA and move direction types out of primitives (#12018) 2024-02-26 13:57:49 +00:00
config.rs Reflect GizmoConfigStore (#12104) 2024-02-25 01:57:44 +00:00
gizmos.rs Use LinearRgba in bevy_gizmos internals (#12128) 2024-02-26 23:50:33 +00:00
lib.rs Use LinearRgba in bevy_gizmos internals (#12128) 2024-02-26 23:50:33 +00:00
lines.wgsl Fix float precision issue in the gizmo shader (#10408) 2023-11-14 22:36:02 +00:00
pipeline_2d.rs Multiple Configurations for Gizmos (#10342) 2024-01-18 15:52:50 +00:00
pipeline_3d.rs Multiple Configurations for Gizmos (#10342) 2024-01-18 15:52:50 +00:00