Skip to content

Commit

Permalink
Repaint always
Browse files Browse the repository at this point in the history
  • Loading branch information
Masterchef365 committed Jun 10, 2024
1 parent 9e4b2af commit db22bad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ impl eframe::App for DemoApp {

/// Called each time the UI needs repainting, which may be many times per second.
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
ctx.request_repaint();

self.sim.step(&self.cfg);

sweep_pointcloud(&mut self.pcld, self.sim.get_flow(), self.cfg.dt);
Expand Down Expand Up @@ -142,10 +144,10 @@ impl eframe::App for DemoApp {
*/

if self.draw_grid {
draw_n_grid(&self.grid, paint, Stroke::new(1., Color32::from_gray(40)));
draw_n_grid(&self.grid, paint, Stroke::new(1., Color32::from_gray(90)));
}

draw_pcld(&self.pcld, &self.proj, paint, 1., Color32::WHITE);
draw_pcld(&self.pcld, &self.proj, paint, 1., Color32::from_gray(180));
})
});
});
Expand Down
9 changes: 5 additions & 4 deletions src/visualization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ pub fn compute_n_grid(

for (idx, _) in arr.indexed_iter() {
let tl = idx.as_array_view().to_vec();
let b = proj.project(&tl.iter().map(|p| *p as f32).collect::<Vec<f32>>());

for dim in 0..arr.ndim() {
let mut pos = tl.clone();
pos[dim] += 1;
if arr.get(&*pos).is_some() {
//if arr.get(&*pos).is_some() {
let a = proj.project(&pos.iter().map(|p| *p as f32).collect::<Vec<f32>>());
let b = proj.project(&tl.iter().map(|p| *p as f32).collect::<Vec<f32>>());

out.push((a, b));
}
//}
}
}

Expand Down Expand Up @@ -58,6 +59,6 @@ pub fn random_pcld_uniform(n: usize, volume: &[usize]) -> PointCloud {
let margin = 0.5;

PointCloud(Array2::from_shape_fn((n, volume.len()), |(_, col)| {
rng.gen_range(margin..=volume[col] as f32 - 1.0 - margin)
rng.gen_range(margin..=volume[col] as f32 - margin)
}))
}

0 comments on commit db22bad

Please sign in to comment.