Skip to content

Commit

Permalink
Fix text-2d. (#17674)
Browse files Browse the repository at this point in the history
# Objective

Fix text 2d. Fixes #17670

## Solution

Evidently there's a 1:N extraction going on here that requires using the
render entity rather than main entity.

## Testing

Text 2d example
  • Loading branch information
tychedelia authored Feb 4, 2025
1 parent 18c4050 commit 8c7f1b3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/bevy_sprite/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,9 @@ pub struct SpriteViewBindGroup {
}

#[derive(Resource, Deref, DerefMut, Default)]
pub struct SpriteBatches(HashMap<(RetainedViewEntity, MainEntity), SpriteBatch>);
pub struct SpriteBatches(HashMap<(RetainedViewEntity, Entity), SpriteBatch>);

#[derive(PartialEq, Eq, Clone)]
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct SpriteBatch {
image_handle_id: AssetId<Image>,
range: Range<u32>,
Expand Down Expand Up @@ -694,7 +694,7 @@ pub fn prepare_sprite_image_bind_groups(
});

batch_item_index = item_index;
current_batch = Some(batches.entry((*retained_view, item.main_entity())).insert(
current_batch = Some(batches.entry((*retained_view, item.entity())).insert(
SpriteBatch {
image_handle_id: batch_image_handle,
range: index..index,
Expand Down Expand Up @@ -846,7 +846,7 @@ impl<P: PhaseItem, const I: usize> RenderCommand<P> for SetSpriteTextureBindGrou
pass: &mut TrackedRenderPass<'w>,
) -> RenderCommandResult {
let image_bind_groups = image_bind_groups.into_inner();
let Some(batch) = batches.get(&(view.retained_view_entity, item.main_entity())) else {
let Some(batch) = batches.get(&(view.retained_view_entity, item.entity())) else {
return RenderCommandResult::Skip;
};

Expand Down Expand Up @@ -876,7 +876,7 @@ impl<P: PhaseItem> RenderCommand<P> for DrawSpriteBatch {
pass: &mut TrackedRenderPass<'w>,
) -> RenderCommandResult {
let sprite_meta = sprite_meta.into_inner();
let Some(batch) = batches.get(&(view.retained_view_entity, item.main_entity())) else {
let Some(batch) = batches.get(&(view.retained_view_entity, item.entity())) else {
return RenderCommandResult::Skip;
};

Expand Down

0 comments on commit 8c7f1b3

Please sign in to comment.