Skip to content

Commit

Permalink
Invert surface for negative sweep path fixes hannobraun#506
Browse files Browse the repository at this point in the history
Checks if the path points in negative z-direction
and flips surface normal accordingly

this is sufficient as long as sketches are always drawn in the xy-plane
if this ever changes this has to be revisited

Signed-off-by: gabsi26 <[email protected]>
  • Loading branch information
gabsi26 committed May 24, 2022
1 parent 565f21a commit 7843bf7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions crates/fj-kernel/src/algorithms/sweep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ pub fn sweep_shape(
let translation = Transform::translation(path);

let (mut bottom, source_to_bottom) = source.clone_shape();
bottom
.update()
.update_all(|surface: &mut Surface| *surface = surface.reverse())
.validate()?;

let (mut top, source_to_top) = source.clone_shape();

if path.dot(&Vector::from([1., 1., 1.])) >= fj_math::Scalar::from_f64(0.) {
bottom
.update()
.update_all(|surface: &mut Surface| *surface = surface.reverse())
.validate()?;
} else {
top.update()
.update_all(|surface: &mut Surface| *surface = surface.reverse())
.validate()?;
}
transform_shape(&mut top, &translation);

let mut target = Shape::new();
Expand Down

0 comments on commit 7843bf7

Please sign in to comment.