Skip to content

Commit

Permalink
Update flowfield
Browse files Browse the repository at this point in the history
  • Loading branch information
Masterchef365 committed Aug 21, 2024
1 parent 0b7d36a commit ef2f7d3
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 17 deletions.
52 changes: 49 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ threegui = { git = "https://github.com/Masterchef365/threegui.git", rev = "ceda1
rand = "0.8"
getrandom = { version = "0.2", features = ["js"] }
#flowfield-nd = { path = "../flowfield-nd" }
flowfield-nd = { git = "https://github.com/Masterchef365/flowfield-nd.git", rev = "81a5c4a" }
flowfield-nd = { git = "https://github.com/Masterchef365/flowfield-nd.git", branch = "main" }
ndarray = "0.15.6"

# You only need serde if you want app persistence:
Expand All @@ -39,12 +39,7 @@ wasm-bindgen-futures = "0.4"


[profile.release]
opt-level = 2 # fast and small wasm

# Optimize all dependencies even in debug builds:
[profile.dev.package."*"]
opt-level = 2

debug = true

[patch.crates-io]

Expand Down
15 changes: 8 additions & 7 deletions src/visualization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,16 @@ pub fn draw_flowfield_interp_centers(
let mut pos: Vec<f32> = cell.iter().map(|c| *c as f32).collect();

pos.iter_mut().for_each(|p| *p += 0.5);
let interp = ff.n_linear_interp(&pos, flowfield_nd::Boundary::Zero).unwrap();
let a = proj.project(&pos);
if let Some(interp) = ff.n_linear_interp(&pos) {
let a = proj.project(&pos);

pos.iter_mut().zip(interp).for_each(|(p, i)| *p += i * scale);
let b = proj.project(&pos);
pos.iter_mut().zip(interp).for_each(|(p, i)| *p += i * scale);
let b = proj.project(&pos);

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

Expand Down

0 comments on commit ef2f7d3

Please sign in to comment.