Skip to content

Commit

Permalink
Much better debugging tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Masterchef365 committed Jun 11, 2024
1 parent ad6a59a commit 331f2ef
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use flowfield_nd::{sweep_pointcloud, FlowField, FluidSolver, PointCloud, SolverC
use rand::Rng;
use threegui::Vec3;

use crate::{projection::{generate_axes, AxisProjection}, visualization::{compute_n_grid, draw_flowfield_interp, draw_n_grid, draw_pcld, random_pcld_uniform}};
use crate::{projection::{generate_axes, AxisProjection}, visualization::{compute_n_grid, draw_flowfield_interp, draw_flowfield_raw, draw_n_grid, draw_pcld, random_pcld_uniform}};

/// We derive Deserialize/Serialize so we can persist app state on shutdown.
//#[derive(serde::Deserialize, serde::Serialize)]
Expand Down Expand Up @@ -147,6 +147,7 @@ impl eframe::App for DemoApp {
}

draw_flowfield_interp(paint, &self.proj, self.sim.get_flow(), 3.);
draw_flowfield_raw(paint, &self.proj, self.sim.get_flow(), 3.);

draw_pcld(&self.pcld, &self.proj, paint, 1., Color32::from_gray(180));
})
Expand Down
24 changes: 24 additions & 0 deletions src/visualization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,30 @@ pub fn draw_flowfield_interp(
}
}

pub fn draw_flowfield_raw(
paint: &Painter3D,
proj: &dyn Projection,
ff: &FlowField,
scale: f32,
) {
for (dim, axis) in ff.get_axes().iter().enumerate() {
for (idx, value) in axis.indexed_iter() {
let mut pos: Vec<f32> = idx.as_array_view().iter().map(|c| *c as f32).collect();

pos.iter_mut().enumerate().for_each(|(idx, p)| if idx != dim { *p -= 0.5 });
let a = proj.project(&pos);

pos.iter_mut().enumerate().for_each(|(idx, p)| if idx == dim { *p += scale * *value });
let b = proj.project(&pos);

let color = Color32::LIGHT_BLUE;
paint.circle_filled(a, 2., color);
paint.line(a, b, Stroke::new(1., color));
}
}
}


pub fn draw_n_grid(
buf: &[(Vec3, Vec3)],
paint: &Painter3D,
Expand Down

0 comments on commit 331f2ef

Please sign in to comment.