-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fix rendering of sprites, text, and meshlets after #12582. #12945
Fix rendering of sprites, text, and meshlets after #12582. #12945
Conversation
`Sprite`, `Text`, and `Handle<MeshletMesh>` were types of renderable entities that the new segregated visible entity system didn't handle, so they didn't appear. Because `bevy_text` depends on `bevy_sprite`, and the visibility computation of text happens in the latter crate, I had to introduce a new marker component, `SpriteSource`. `SpriteSource` marks entities that aren't themselves sprites but become sprites during rendering. I added this component to `Text2dBundle`. Unfortunately, this is technically a breaking change, although I suspect it won't break anybody in practice except perhaps editors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a thorough review but looks ok. Nothing controversial in my opinion. Noting this in case others get to it more thoroughly before me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It fixes the bug for me.
It'd be nice if there was a way to collapse this into a 1 or 2 liner somehow, but not essential.
check_visibility::<WithMeshletMesh>
.in_set(VisibilitySystems::CheckVisibility)
.after(VisibilitySystems::CalculateBounds)
.after(VisibilitySystems::UpdateOrthographicFrusta)
.after(VisibilitySystems::UpdatePerspectiveFrusta)
.after(VisibilitySystems::UpdateProjectionFrusta)
.after(VisibilitySystems::VisibilityPropagate)
.after(TransformSystem::TransformPropagate),
/// Right now, this is used for `Text`. | ||
#[derive(Component, Reflect, Clone, Copy, Debug, Default)] | ||
#[reflect(Component, Default)] | ||
pub struct SpriteSource; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand why we need this, but I also couldn't get this working with just Text
so I assume it's necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, actually I think I came up with a way to make that no longer necessary. I'll try it tonight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, never mind, it'd be uglier than the current solution.
The problem is that Text
uses the sprite visibility checking system. But that system can't name Text
as it's an upstream crate. So we need some marker component that the sprite visibility checker can name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, the idea I had was to introduce a "label" type that's different from the component type. That way Sprite
and Text
would have the same label. But then you'd need two check_visibility
systems, one for each component, that together populate the same VisibleEntities
list. I think that's uglier than just using SpriteSource
.
Sprite
,Text
, andHandle<MeshletMesh>
were types of renderable entities that the new segregated visible entity system didn't handle, so they didn't appear.Because
bevy_text
depends onbevy_sprite
, and the visibility computation of text happens in the latter crate, I had to introduce a new marker component,SpriteSource
.SpriteSource
marks entities that aren't themselves sprites but become sprites during rendering. I added this component toText2dBundle
. Unfortunately, this is technically a breaking change, although I suspect it won't break anybody in practice except perhaps editors.Fixes #12935.
Changelog
Changed
Text2dBundle
now includes a new marker component,SpriteSource
. Bevy uses this internally to optimize visibility calculation.Migration Guide
Text
now requires aSpriteSource
marker component in order to appear. This component has been added toText2dBundle
.