Skip to content

Commit

Permalink
Remove mesh fixup (#79)
Browse files Browse the repository at this point in the history
Mesh fixup doesn't actually guarantee manifold models [1], so the extra
complexity isn't worth it.

[1] https://www.mattkeeter.com/blog/2023-04-23-adversarial
  • Loading branch information
mkeeter authored Apr 12, 2024
1 parent 078aafc commit 3d29e1d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 564 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
- Removed `threads` parameter from various `Settings` objects when targeting
`wasm32`, so that it's harder to accidentally spawn threads (which would
panic).
- Removed `min_depth` / `max_depth` distinction in meshing; this doesn't
actually guarantee manifold models
(see [this scale-invariant adversarial model](https://www.mattkeeter.com/blog/2023-04-23-adversarial/)),
so the extra complexity isn't worth it.

# 0.2.4
The highlight of this release is a refactoring of how shapes are handled in Rhai
Expand Down
9 changes: 2 additions & 7 deletions demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,10 @@ struct ImageSettings {

#[derive(Parser)]
struct MeshSettings {
/// Minimum octree depth
/// Octree depth
#[clap(short, long)]
depth: u8,

/// Maximum octree depth
#[clap(long)]
max_depth: Option<u8>,

/// Name of a `.stl` file to write
#[clap(short, long)]
out: Option<PathBuf>,
Expand Down Expand Up @@ -251,8 +247,7 @@ fn run_mesh<S: fidget::eval::Shape>(
for _ in 0..settings.n {
let settings = fidget::mesh::Settings {
threads: settings.threads,
min_depth: settings.depth,
max_depth: settings.max_depth.unwrap_or(settings.depth),
depth: settings.depth,
..Default::default()
};
let octree = fidget::mesh::Octree::build(&shape, settings);
Expand Down
6 changes: 2 additions & 4 deletions fidget/benches/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ pub fn colonnade_octree_thread_sweep(c: &mut Criterion) {
c.benchmark_group("speed vs threads (colonnade, octree) (depth 6)");
for threads in [1, 4, 8] {
let cfg = &fidget::mesh::Settings {
min_depth: 6,
max_depth: 6,
depth: 6,
threads: threads.try_into().unwrap(),
..Default::default()
};
Expand All @@ -40,8 +39,7 @@ pub fn colonnade_mesh(c: &mut Criterion) {
let (ctx, root) = fidget::Context::from_text(COLONNADE.as_bytes()).unwrap();
let shape_vm = &fidget::vm::VmShape::new(&ctx, root).unwrap();
let cfg = fidget::mesh::Settings {
min_depth: 8,
max_depth: 8,
depth: 8,
..Default::default()
};
let octree = &fidget::mesh::Octree::build(shape_vm, cfg);
Expand Down
209 changes: 0 additions & 209 deletions fidget/src/mesh/fixup.rs

This file was deleted.

20 changes: 4 additions & 16 deletions fidget/src/mesh/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
//! let tree = fidget::rhai::eval("sphere(0, 0, 0, 0.6)")?;
//! let shape = VmShape::from_tree(&tree);
//! let settings = Settings {
//! min_depth: 4,
//! max_depth: 4,
//! depth: 4,
//! ..Default::default()
//! };
//! let o = Octree::build(&shape, settings);
Expand All @@ -46,7 +45,6 @@ use crate::shape::Bounds;
mod builder;
mod cell;
mod dc;
mod fixup;
mod frame;
mod gen;
mod octree;
Expand Down Expand Up @@ -83,17 +81,8 @@ impl Mesh {
/// Settings when building an octree and mesh
#[derive(Copy, Clone, Debug)]
pub struct Settings {
/// Minimum depth to recurse in the octree
pub min_depth: u8,

/// Maximum depth to recurse in the octree
///
/// If this is `> min_depth`, then after the octree is initially built
/// (recursing to `min_depth`), cells with escaped vertices are subdivided
/// recursively up to a limit of `max_depth`.
///
/// This is **much slower**.
pub max_depth: u8,
/// Depth to recurse in the octree
pub depth: u8,

/// Bounds for meshing
pub bounds: Bounds<3>,
Expand All @@ -109,8 +98,7 @@ pub struct Settings {
impl Default for Settings {
fn default() -> Self {
Self {
min_depth: 3,
max_depth: 3,
depth: 3,
bounds: Default::default(),

#[cfg(not(target_arch = "wasm32"))]
Expand Down
Loading

0 comments on commit 3d29e1d

Please sign in to comment.