@@ -373,28 +373,25 @@ pub fn prepare_sprites(
373
373
// Impossible starting values that will be replaced on the first iteration
374
374
let mut current_batch_handle = HandleId :: Id ( Uuid :: nil ( ) , u64:: MAX ) ;
375
375
let mut current_image_size = Vec2 :: ZERO ;
376
- let mut current_z_order = 0.0 ;
376
+ let mut z_order = 0.0 ;
377
377
378
378
// Vertex buffer indices
379
379
let mut index_start = 0 ;
380
380
let mut index_end = 0 ;
381
381
382
382
for extracted_sprite in sprites {
383
- if extracted_sprite. image_handle_id != current_batch_handle
384
- || extracted_sprite. transform . translation . z != current_z_order
385
- {
383
+ if extracted_sprite. image_handle_id != current_batch_handle {
386
384
if let Some ( gpu_image) =
387
385
gpu_images. get ( & Handle :: weak ( extracted_sprite. image_handle_id ) )
388
386
{
389
387
current_image_size = gpu_image. size ;
390
388
current_batch_handle = extracted_sprite. image_handle_id ;
391
- current_z_order = extracted_sprite. transform . translation . z ;
392
389
if index_start != index_end {
393
390
commands. spawn ( ) . insert ( SpriteBatch {
394
391
range : index_start..index_end,
395
392
image_handle_id : current_batch_handle,
396
393
colored,
397
- z_order : current_z_order ,
394
+ z_order,
398
395
} ) ;
399
396
index_start = index_end;
400
397
}
@@ -454,6 +451,16 @@ pub fn prepare_sprites(
454
451
}
455
452
}
456
453
index_end += QUAD_INDICES . len ( ) as u32 ;
454
+ z_order = extracted_sprite. transform . translation . z ;
455
+ }
456
+ // if start != end, there is one last batch to process
457
+ if index_start != index_end {
458
+ commands. spawn ( ) . insert ( SpriteBatch {
459
+ range : index_start..index_end,
460
+ image_handle_id : current_batch_handle,
461
+ colored,
462
+ z_order,
463
+ } ) ;
457
464
}
458
465
}
459
466
sprite_meta
0 commit comments