Fix text2d view-visibility#10100
Conversation
superdump
left a comment
There was a problem hiding this comment.
Assuming this works, I prefer this PR to the other one.
|
Don’t want to muddy the waters but since the new sprites are only created for visible entities could we just have a force_visible bool that gets set to true on the new ones? Not sure if there’s other value to tracking the original entity edit: why don’t we not extract invisible sprites and omit the check entirely? |
My understanding is that entities that are definitely not visible in any view are not extracted, but the visibility check in |
|
I re-did the benchmarks on power / without a sneaky bevy ant simulator running in the background / actually averaging all 1500 framerate samples (oops). |
# Objective Fixes bevyengine#9676 Possible alternative to bevyengine#9708 `Text2dBundles` are not currently drawn because the render-world-only entities for glyphs that are created in `extract_text2d_sprite` are not tracked by the per-view `VisibleEntities`. ## Solution Add an `Option<Entity>` to `ExtractedSprite` that keeps track of the original entity that caused a "glyph entity" to be created. Use that in `queue_sprites` if it exists when checking view visibility. ## Benchmarks Quick benchmarks. Average FPS over 1500 frames. | bench | before fps | after fps | diff | |-|-|-|-| |many_sprites|884.93|879.00|🟡 -0.7%| |bevymark -- --benchmark --waves 100 --per-wave 1000 --mode sprite|75.99|75.93|🟡 -0.1%| |bevymark -- --benchmark --waves 50 --per-wave 1000 --mode mesh2d|32.85|32.58|🟡 -0.8%|
# Objective Fixes bevyengine#9676 Possible alternative to bevyengine#9708 `Text2dBundles` are not currently drawn because the render-world-only entities for glyphs that are created in `extract_text2d_sprite` are not tracked by the per-view `VisibleEntities`. ## Solution Add an `Option<Entity>` to `ExtractedSprite` that keeps track of the original entity that caused a "glyph entity" to be created. Use that in `queue_sprites` if it exists when checking view visibility. ## Benchmarks Quick benchmarks. Average FPS over 1500 frames. | bench | before fps | after fps | diff | |-|-|-|-| |many_sprites|884.93|879.00|🟡 -0.7%| |bevymark -- --benchmark --waves 100 --per-wave 1000 --mode sprite|75.99|75.93|🟡 -0.1%| |bevymark -- --benchmark --waves 50 --per-wave 1000 --mode mesh2d|32.85|32.58|🟡 -0.8%|
Objective
Fixes #9676
Possible alternative to #9708
Text2dBundlesare not currently drawn because the render-world-only entities for glyphs that are created inextract_text2d_spriteare not tracked by the per-viewVisibleEntities.Solution
Add an
Option<Entity>toExtractedSpritethat keeps track of the original entity that caused a "glyph entity" to be created.Use that in
queue_spritesif it exists when checking view visibility.Benchmarks
Quick benchmarks. Average FPS over 1500 frames.