From e3fff76792aabd08da373c33d79e67d030ad6648 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Fri, 28 Mar 2025 10:22:28 -0400 Subject: [PATCH] Grid: inline deposit --- src/grid.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/grid.rs b/src/grid.rs index 419b418..2ee7a45 100644 --- a/src/grid.rs +++ b/src/grid.rs @@ -76,12 +76,6 @@ impl Grid { crate::util::index(self.width, self.height, x, y) } - /// Add a value to the grid data at a given position. - pub fn deposit(&mut self, x: f32, y: f32) { - let idx = self.index(x, y); - self.data[idx] += self.config.deposition_amount; - } - /// Diffuse grid data and apply a decay multiplier. pub fn diffuse(&mut self, radius: usize) { self.blur.run( @@ -119,9 +113,9 @@ impl Grid { } pub fn deposit_all(&mut self) { - let agent_list = self.agents.clone(); - for agent in agent_list.iter() { - self.deposit(agent.x, agent.y); + for agent in self.agents.iter() { + let idx = self.index(agent.x, agent.y); + self.data[idx] += self.config.deposition_amount; } } }