Skip to content

Commit

Permalink
Fix example defaults, doc comment
Browse files Browse the repository at this point in the history
  • Loading branch information
aevyrie committed Dec 24, 2024
1 parent 50c7d74 commit 7870275
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
17 changes: 5 additions & 12 deletions examples/spatial_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ fn main() {
.run();
}

const N_ENTITIES: usize = 1_000_000;
// Try bumping this up to really stress test. I'm able to push a million entities with an M3 Max.
const N_ENTITIES: usize = 100_000;
const HALF_WIDTH: f32 = 40.0;
const CELL_WIDTH: f32 = 10.0;
// How fast the entities should move, causing them to move into neighboring cells.
const MOVEMENT_SPEED: f32 = 5e6;
const MOVEMENT_SPEED: f32 = 5.0;
const PERCENT_STATIC: f32 = 0.9;

#[derive(Component)]
Expand Down Expand Up @@ -137,15 +138,7 @@ fn draw_partitions(
fn move_player(
time: Res<Time>,
mut _gizmos: Gizmos,
mut player: Query<
(
&mut Transform,
&mut GridCell<i32>,
&Parent,
&GridHash<i32>,
),
With<Player>,
>,
mut player: Query<(&mut Transform, &mut GridCell<i32>, &Parent, &GridHash<i32>), With<Player>>,
mut non_player: Query<
(&mut Transform, &mut GridCell<i32>, &Parent),
(Without<Player>, With<NonPlayer>),
Expand All @@ -166,7 +159,7 @@ fn move_player(
}

let t = time.elapsed_secs() * 1.0;
let scale = MOVEMENT_SPEED / (N_ENTITIES as f32 * HALF_WIDTH);
let scale = MOVEMENT_SPEED / HALF_WIDTH;
if scale.abs() > 0.0 {
// Avoid change detection
for (i, (mut transform, _, _)) in non_player.iter_mut().enumerate() {
Expand Down
3 changes: 1 addition & 2 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ impl<'a, P: GridPrecision> GridCommands<'a, P> {
}
}

/// Spawn a grid as a child of the current grid. The first argument in the closure is the
/// paren't grid.
/// Spawn a grid as a child of the current grid.
pub fn spawn_grid_default(&mut self, bundle: impl Bundle) -> GridCommands<P> {
self.spawn_grid(Grid::default(), bundle)
}
Expand Down

0 comments on commit 7870275

Please sign in to comment.