Fix incorrect comparison in CairoMakie line projections #4631
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4627
Fixes a
<=
that should be a<
. Also removes some redundant > that could create similar issues.More detail: After projections and truncating to Float32,
p[5], p[6]
both have an x value of 1, i.e. they are exactly on the clipping edge. (In clip space the x value range is always -1..1.) Clipping is checked using the distance to clip planes, effectivelyd = 1 - x
, so for our pointsd = 0f0
.For the
p[4] -- p[5]
segment it does not detect them as both outside withd <= 0
(correct), and then also not as one outside withd < 0
(fine). In other words it detects both as inside. Neither point needs to be adjusted, and only the first is pushed. Ifp[5]
were outside,p[5]
would get translated towardsp[4]
until it is inside and then get pushed to finish the segment.For the next segment
p[5] -- p[6]
it does detect them both as outside withd <= 0
, which is an invalid state. Both points being outside implies thatp[4] -- p[5]
detectedp[5]
as outside, which would have pushed an adjusted point between the two. So this iteration believes the previous segment to be finished and pushesNaN
to cut the line instead. And thus the inside -> edge segment disappears.Type of change
Checklist