-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
abc6f98
commit 5860e01
Showing
5 changed files
with
58 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters