-
-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct face orientation fixes #506 #628
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the pull request, @gabsi26!
First off, I found that switching to an opaque color made it way easier to figure out what's going on. Maybe we should switch the model colors back to something simple, and just have one transparent model for testing, but that has nothing to do with this pull request.
This pull request addressed only part of #506, by fixing the top and bottom faces. It does not address the side faces. See here:
(That's just the star model, except h
in line 59 was replaced with -h
.)
I'd be happy to merge a partial fix, but the commit message of your first commit contains the magic incantation that will make GitHub close the issue upon merging this. Could you please either remove the reference to the issue from the commit message (straight-forward to do using something like git rebase -i main
, in case you didn't know), or fix the side walls?
Well i tried getting rid of the reference but it doesn't seem to work. |
I know that Git can be hard to deal with. Luckily (for me), it gets easier after 10+ years 😄 I'll take care of it. I'll post the steps I'm taking here, in case you're interested. |
Yes please that would be great as a learning resource :D In the meantime I think i really fixed the issue^^ |
1be8e2d
to
a7bf716
Compare
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]>
Signed-off-by: gabsi26 <[email protected]>
a7bf716
to
b9384ab
Compare
Thanks a lot for this indepth explanation and cleaning up my mess. I hope I won't cause something like this again, but at least nowthere is a guide how to fix it :D |
You're welcome! And don't worry, it happens. Git can be gnarly, but most of these problems are relatively easy to fix, once you understand what's happening and know enough Git commands to clean it up. Just takes time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank again for this pull request, @gabsi26!
It looks good to me now. I've left some suggestions for improvements, but it's fine. Those things can be addressed at some later point. Feel free to submit a follow-up PR, if you're up for it, or just leave it, as you prefer.
Merging now.
@@ -124,11 +124,22 @@ pub fn sweep_shape( | |||
let top_edge = | |||
source_to_top.edges().get(&edge_source).unwrap().clone(); | |||
|
|||
let surface = | |||
let surface = if path.dot(&Vector::from([0., 0., 1.])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nicer, if that check happened only once, and the result was stored into a variable with a descriptive name (sweep_along_negative_direction
, or something like that).
With two separate checks, it becomes easy to miss one, once they need to change.
@@ -124,11 +124,22 @@ pub fn sweep_shape( | |||
let top_edge = | |||
source_to_top.edges().get(&edge_source).unwrap().clone(); | |||
|
|||
let surface = | |||
let surface = if path.dot(&Vector::from([0., 0., 1.])) | |||
>= fj_math::Scalar::from_f64(0.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that Scalar
has some short-hands for often-used values, in this case Scalar::ZERO
.
target.insert( | ||
Surface::SweptCurve(SweptCurve { | ||
curve: bottom_edge.get().curve(), | ||
path, | ||
}) | ||
.reverse(), //////////////////////////////////// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be a bit nicer to reduce some duplication here. Something like this:
let mut surface = Surface::SweptCurve(...);
if sweep_along_negative_direction {
surface = surface.reverse();
}
let surface = target.insert(surface)?;
This PR simply checks if the path of a sweep is pointing in a negative direction.
The change is quite minimal and might not be sufficient for all cases