Repository navigation
first_light: reject non-finite OBJ vertex positions - #6768
Conversation
|
Tested 49fd57f merged with main 1cc6e3c on Linux/Python 3.12.16: pass. Ran (venv python, -I): tests/test_first_light.py: 47 tests OK (4 skipped). Negative control: tools/first_light.py from main, PR tests kept: 4 failures (4 skipped). |
shayderrr
left a comment
There was a problem hiding this comment.
Summary
tools/first_light.py::read_obj now validates each parsed vertex position with math.isfinite before appending it, raising SystemExit naming the OBJ path and quoting the offending line as "non-finite vertex coordinates." The --obj help text states the finite-position/UV requirement. tests/test_first_light.py adds coverage for nan, inf, -inf, and an overflowing 1e999 literal.
Why merge
A NaN or infinite vertex silently poisons bounds, centroid, and normalization math downstream, turning a bad export into a plausible-looking but corrupt preview. Failing at parse time with the path and line is far cheaper to diagnose than chasing undefined geometry later. The check sits beside the existing texture-coordinate validation, keeps the same error style, and adds no cost for valid files.
Verdict: Approve
Summary
Why mergeA NaN or infinite vertex silently poisons bounds, centroid, and normalization math downstream, turning a bad export into a plausible-looking but corrupt preview. Failing at parse time with the path and line is far cheaper to diagnose than chasing undefined geometry later. The check sits beside the existing texture-coordinate validation, keeps the same error style, and adds no cost for valid files. Verdict: Approve |
Claimed in the coordination issue as: #6603 (comment) (first_light)
What and why
The OBJ position reader accepted
nan, infinities and exponent overflow as vertex coordinates. Such positions can reach fitting/projection or be serialized as non-finite mesh values. Reject them at the position record with the source path, before building the mesh. The UV rule, triangulation, and finite-coordinate transformations are unchanged.Tested
v 0 0 nanreturned a vertex containing NaN. With this change the same reader refuses the file, naming the path and non-finite vertex record. Tests also exercise infinities, all three axes, and1e999.python3.12 -I tests/test_first_light.py: 43 passed, 4 skipped (optional integration prerequisites).git diff --checkandpython3.12 -I scripts/check_no_game_data.pyon both changed paths: passed. Linux x86-64, Python 3.12.13; CPU only, no GPU or driver used.AI-assisted: yes.
Checklist