One function
raytrace_box in facelessuser/coloraide
The author described this change as “Ray trace gamut mapping fix”. It counts as a record because the check below fails on the code as it stood at a9bdbd0ef and passes on 6d7ae0948, with nothing else changed between the two runs.
Projectfacelessuser/coloraide
Fix saved2026-01-28
Sharing licenceMIT · LICENSE.md
Change size+4 −7
What the code was meant to do, written into the code itself as a docstring
Return the intersection of an axis aligned box using slab method. https://en.wikipedia.org/wiki/Slab_method
The change
| 23 | 23 | ||
| 24 | 24 | # Non parallel case | |
| 25 | 25 | if d: | |
| 26 | - | inv_d = 1 / d | |
| 26 | + | inv_d = 1.0 / d | |
| 27 | 27 | t1 = (bn - a) * inv_d | |
| 28 | 28 | t2 = (bx - a) * inv_d | |
| 29 | 29 | tnear = max(min(t1, t2), tnear) | |
| ⋯ | |||
| 38 | 38 | return [] | |
| 39 | 39 | ||
| 40 | 40 | # Favor the intersection first in the direction start -> end | |
| 41 | - | if tnear < 0: | |
| 41 | + | if tnear < 0.0: | |
| 42 | 42 | tnear = tfar | |
| 43 | 43 | ||
| 44 | - | # An infinitesimally small point was used, not a ray. | |
| 45 | - | # The origin is the intersection. Our use case will | |
| 46 | - | # discard such scenarios, but others may wish to set | |
| 47 | - | # intersection to origin. | |
| 48 | - | if math.isinf(tnear): | |
| 44 | + | # Point is very close to the surface, so `tnear` could be very large. | |
| 45 | + | if tnear > 10.0: | |
| 49 | 46 | return [] | |
| 50 | 47 | ||
| 51 | 48 | # Calculate intersection interpolation. | |
The check that tells the two apart
fail→pass·tests/test_gamut.py::TestRayTrace::test_ray_trace_very_close_to_gamut
Check file tests/test_gamut.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before ita9bdbd0ef3ec1eb730428fb81ee681223f35ec3b
Broken version dated2026-01-28
Modulecoloraide.gamut.fit_raytrace
Units changedraytrace_box
Fingerprint4230d3494a74646a
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.