-
Notifications
You must be signed in to change notification settings - Fork 205
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
Add comments to BoolOps implementation. #1102
Conversation
Thanks @andriyDev ; the poor docs in this impl. is primarily my fault. We built this impl. incrementally, trying to fix up the floating point precision issues. I somewhat gave-up midway, as I couldn't figure how to provably fix the Martinez-Rueda family of algorithms to work with f64/f32. That said, the Assembly module, iirc, does not have floating point precision issues as it doesn't actually need to break any segments. In fact, I think, we can even get this module to work without using I'll do my best to review this in the next week or two. |
Hey no blame! The only way to make the code better is to work together :) As far floating point issues, I had been working on my own Martinez-Rueda implementation and had also been struggling heavily with floating point issues myself. I've got an idea for why those are happening so I'll create a separate issue. |
Wow these are tricky to explain the difference.
I rebased onto main, and I added more comments for the There are many changes we could make to simplify the code, but I think just documenting it is the first step. In addition, this isn't the whole story - the main thing that's missing now is documenting |
idx: usize, | ||
/// The region of this edge when the piece is going in the same direction as |
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.
I'm pretty sure this is wrong. I can sorta understand the intent, but it doesn't make sense to me exactly what the check below means.
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.
@rmanoka Can you shed any light on this?
@andriyDev This is still marked as draft. Is that intentional or is this ready for review? |
I'm happy to call this ready for review. More comments can always be another PR :) |
@@ -85,14 +98,15 @@ impl<T: GeoFloat> RegionAssembly<T> { | |||
parent_snake_idx = Some( | |||
iter.prev_active(d) | |||
.map(|(_, seg)| seg.snake_idx.get()) | |||
// TODO |
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.
Can you remove these TODOs?
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.
I can, but these TODOs really need an explanation. They make no sense to me. I tried to remove these defaults as well and tests started to fail, so clearly they are necessary but I don't have a logical reason how.
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.
@rmanoka Do you recall why this .unwrap_or(0)
is here?
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.
I don't think the number here matters. If the expression is not Some()
, then the "snake" will complete to an exterior ring, which doesn't need a parent idx. I tried verifying by setting random numbers inside .unwrap_or()
, and tests seem to pass.
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.
@andriyDev Are you OK with this explanation?
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.
Yes, sorry, I'd lost track of this. I will update the comment tonight.
As an aside, I'd much prefer this case to be handled another way (if the id is unused we shouldn't need to unwrap it). But that's not the point of this PR, that kind of change should be another PR.
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.
I've added the explanation to the comments. I believe this is ready to go then (unless there are other concerns). :)
I'd really like to see this merged in order to facilitate further investigation into |
I would be shocked if this code is "responsible" for the panic. The RegionAssembly is fairly straightforward. What's more likely in my mind is that bad data is coming in from Proc or Spec in boolean ops since those are much more complex IMO. But that's just my speculation haha. Regardless we (mostly I) should push this through to make progress on that. |
Either that or outright replacement with your Martinez-Rueda implementation, but that's all a separate discussion. |
To be clear, mine is also riddled with panics LMAO. Maybe one day I'll find the "smoking gun". |
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.
@andriyDev thank you so much for adding these comments!
CHANGES.md
if knowledge of this change could be valuable to users.This part of the code relies on a lot of assumptions that are not obviously until you really dig into the code, and have a lot of components that are not really clear (what's the difference between a
Ring
and aSnake
?).I've taken a stab at documenting these things and adding a few more inline comments to hopefully make it more clear to future readers.
There are a couple parts I still don't really understand, which I've marked as TODOs. Hopefully with a review, someone else might have more insight and we can document this even better. I will also likely expand the scope of comments as I make more progress (so far this is just
assembly.rs
, but I may try to capture more of the BoolOps).