Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ license = "Apache-2.0 OR MIT"
name = "tessellation"
path = "src/lib.rs"

[features]
default = ["wasm-bindgen"]
stdweb = ["instant/stdweb"]
wasm-bindgen = ["instant/wasm-bindgen"]

[dependencies]
alga = "0.9"
instant = "0.1"
nalgebra = "0.22"
rand = "0.7"
rayon = "1.2"
Expand Down
16 changes: 10 additions & 6 deletions src/manifold_dual_contouring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::{
use bbox::BoundingBox;
use nalgebra as na;
use num_traits::Float;
#[cfg(not(target_arch="wasm32"))]
use rayon::prelude::*;
use std::{
cell::{Cell, RefCell},
Expand Down Expand Up @@ -231,7 +232,7 @@ fn pow2roundup(x: usize) -> usize {
x |= x >> 4;
x |= x >> 8;
x |= x >> 16;
x |= x >> 32;
x |= x.wrapping_shr(32);
x + 1
}

Expand Down Expand Up @@ -397,17 +398,17 @@ fn subsample_octtree<S: RealField + Float + From<f32>>(base: &[Vertex<S>]) -> Ve
}

struct Timer {
t: std::time::Instant,
t: instant::Instant,
}

impl Timer {
fn new() -> Timer {
Timer {
t: std::time::Instant::now(),
t: instant::Instant::now(),
}
}
fn elapsed(&mut self) -> std::time::Duration {
let now = std::time::Instant::now();
let now = instant::Instant::now();
let result = now - self.t;
self.t = now;
result
Expand Down Expand Up @@ -607,8 +608,11 @@ impl<'a, S: From<f32> + RealField + Float + AsUSize> ManifoldDualContouring<'a,
fn compact_value_grid(&mut self) {
// Collect all indexes to remove.
let value_grid = &mut self.value_grid;
let keys_to_remove: Vec<_> = value_grid
.par_iter()
#[cfg(not(target_arch="wasm32"))]
let value_grid_iter = value_grid.par_iter();
#[cfg(target_arch="wasm32")]
let value_grid_iter = value_grid.iter();
let keys_to_remove: Vec<_> = value_grid_iter
.filter(|&(idx, &v)| {
if idx[0] == 0 || idx[1] == 0 || idx[2] == 0 {
// This grid cell does not have neighbors in some directions. Ignore.
Expand Down