@@ -415,7 +415,7 @@ fn update_lazy_tile_sprites(
415
415
tiles_query : Query < ( Entity , & TileSprite ) > ,
416
416
) {
417
417
// チャンクごとに更新すべきインデックス列を保持
418
- let mut tile_spawning_indices: HashMap < String , Vec < ( i32 , i32 ) > > = HashMap :: new ( ) ;
418
+ let mut tile_spawning_indices: HashMap < String , Vec < i32 > > = HashMap :: new ( ) ;
419
419
420
420
// ハッシュマップにチャンクごとVecを生成
421
421
for chunk in & world. chunks {
@@ -428,32 +428,25 @@ fn update_lazy_tile_sprites(
428
428
let indiceis_to_spawn = tile_spawning_indices. get_mut ( & chunk. level . 0 ) . unwrap ( ) ;
429
429
430
430
// loading_index の続きを一部更新
431
- for _ in 0 ..50 {
432
- if chunk. tiles . len ( ) <= chunk. loading_index {
433
- break ;
434
- }
435
-
436
- let w = chunk. bounds . max_x - chunk. bounds . min_x ;
437
- let lx = chunk. loading_index as i32 % w;
438
- let ly = chunk. loading_index as i32 / w;
439
- let x = chunk. bounds . min_x + lx as i32 ;
440
- let y = chunk. bounds . min_y + ly as i32 ;
441
- indiceis_to_spawn. push ( ( x, y) ) ;
442
-
443
- // todo これが重い?
444
- // clear_tiles_by_bounds(
445
- // &mut commands,
446
- // &tiles_query,
447
- // Bounds {
448
- // min_x: x,
449
- // max_x: x + 1,
450
- // min_y: y,
451
- // max_y: y + 1,
452
- // },
453
- // );
454
-
455
- chunk. loading_index += 1 ;
431
+ if chunk. height ( ) <= chunk. loading_index {
432
+ continue ;
456
433
}
434
+
435
+ indiceis_to_spawn. push ( chunk. bounds . min_y + chunk. loading_index ) ;
436
+
437
+ // todo これが重い?
438
+ clear_tiles_by_bounds (
439
+ & mut commands,
440
+ & tiles_query,
441
+ Bounds {
442
+ min_x : chunk. bounds . min_x ,
443
+ max_x : chunk. bounds . max_x ,
444
+ min_y : chunk. bounds . min_y + chunk. loading_index ,
445
+ max_y : chunk. bounds . min_y + chunk. loading_index + 1 ,
446
+ } ,
447
+ ) ;
448
+
449
+ chunk. loading_index += 1 ;
457
450
}
458
451
459
452
// 予約されたインデックスに応じてスプライトを生成
@@ -466,8 +459,10 @@ fn update_lazy_tile_sprites(
466
459
. unwrap ( ) ;
467
460
468
461
// スプライトを再生成
469
- for ( x, y) in indices. iter ( ) {
470
- spawn_world_tile ( & mut commands, & registry, & world, & chunk, * x, * y) ;
462
+ for y in indices. iter ( ) {
463
+ for x in chunk. bounds . min_x ..chunk. bounds . max_x {
464
+ spawn_world_tile ( & mut commands, & registry, & world, & chunk, x, * y) ;
465
+ }
471
466
}
472
467
}
473
468
}
0 commit comments