Grid: inline deposit
This commit is contained in:
parent
ff769df97b
commit
e3fff76792
12
src/grid.rs
12
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user