Fix rendering of sprites, text, and meshlets after #12582.#12945
Fix rendering of sprites, text, and meshlets after #12582.#12945alice-i-cecile merged 3 commits intobevyengine:mainfrom
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.
superdump
left a comment
There was a problem hiding this comment.
Not a thorough review but looks ok. Nothing controversial in my opinion. Noting this in case others get to it more thoroughly before me.
Elabajaba
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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_textdepends onbevy_sprite, and the visibility computation of text happens in the latter crate, I had to introduce a new marker component,SpriteSource.SpriteSourcemarks 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
Text2dBundlenow includes a new marker component,SpriteSource. Bevy uses this internally to optimize visibility calculation.Migration Guide
Textnow requires aSpriteSourcemarker component in order to appear. This component has been added toText2dBundle.