mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
add add_velocity_source helper to WindSim
This commit is contained in:
parent
766897ce65
commit
91f96a57f5
@ -55,13 +55,17 @@ impl WindSim {
|
||||
cell_vel.map2(self.blocks_per_cell, |vi, si| vi * si as f32)
|
||||
}
|
||||
|
||||
// Abstraction for running the simulation
|
||||
pub fn tick(&mut self, sources: Vec<(Pos, Vel)>, dt: &DeltaTime) {
|
||||
for (pos, vel) in sources {
|
||||
pub fn add_velocity_source(&mut self, pos: Pos, vel: Vel) {
|
||||
let cell_pos = self.world_to_grid(pos).unwrap_or(DEFAULT_POS);
|
||||
let cell_vel = vel.0.map2(self.blocks_per_cell, |vi, si| vi / si as f32);
|
||||
self.grid.add_velocity_source(cell_pos, cell_vel)
|
||||
}
|
||||
|
||||
// Abstraction for running the simulation
|
||||
pub fn tick(&mut self, sources: Vec<(Pos, Vel)>, dt: &DeltaTime) {
|
||||
for (pos, vel) in sources {
|
||||
self.add_velocity_source(pos, vel);
|
||||
}
|
||||
step_fluid(
|
||||
&mut self.grid.density,
|
||||
&mut self.grid.x_vel,
|
||||
|
Loading…
Reference in New Issue
Block a user