Skip to content

Commit

Permalink
Only sample 3 points
Browse files Browse the repository at this point in the history
Simplify code to only sample 3 points, since that is enough for
cicrcles and lines.
  • Loading branch information
A-Walrus committed Mar 20, 2023
1 parent 285c86f commit 2977ab5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 0 additions & 8 deletions crates/fj-kernel/src/validate/mod.rs
Expand Up @@ -75,11 +75,6 @@ pub struct ValidationConfig {
/// that distance is less than the one defined in this field, can not be
/// considered identical.
pub identical_max_distance: Scalar,

/// How often to sample edges when checking if they coincide. This
/// represents the number of points we check on each Edge.
/// The higher this is the more precise our validation is, and the slower it is.
pub sample_count: usize,
}

impl Default for ValidationConfig {
Expand All @@ -92,9 +87,6 @@ impl Default for ValidationConfig {
// false positives due to floating-point accuracy issues), we can
// adjust it.
identical_max_distance: Scalar::from_f64(5e-14),

// This value is completely arbitrary, but seems good enough for now.
sample_count: 16,
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions crates/fj-kernel/src/validate/shell.rs
Expand Up @@ -63,8 +63,12 @@ fn are_coincident(
.distance_to(&sample(0.0, (&edge2, surface2)))
> config.identical_max_distance;

for i in 0..config.sample_count {
let percent = i as f64 * (1.0 / config.sample_count as f64);
// Three samples (start, middle, end), are enough to detect weather lines
// and circles match. If we were to add more complicated curves, this might
// need to change.
let sample_count = 3;
for i in 0..sample_count {
let percent = i as f64 * (1.0 / sample_count as f64);
let sample1 = sample(percent, (&edge1, surface1));
let sample2 = sample(
if flip { 1.0 - percent } else { percent },
Expand Down

0 comments on commit 2977ab5

Please sign in to comment.