Skip to content

first_light: reject non-finite OBJ vertex positions - #6768

Merged
shayderrr merged 1 commit into
ItsNotRexed:mainfrom
Solthodox:fix/first-light-finite-positions
Nov 23, 2026
Merged

shayderrr merged 1 commit into
ItsNotRexed:mainfrom
Solthodox:fix/first-light-finite-positions

Conversation

@Solthodox

Copy link
Copy Markdown
Contributor

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

AI-assisted: yes.

Checklist

  • No game data, keys or decryption, including in logs and fixtures.
  • Translator contract table: not applicable; no translator rule change.

@kapitche

Copy link
Copy Markdown
Contributor

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).
tests/test_docs_*.py: all OK.

Negative control: tools/first_light.py from main, PR tests kept: 4 failures (4 skipped).
Not run: native Windows. The 4 skips are in both runs; I did not look into why.

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@shayderrr

Copy link
Copy Markdown
Collaborator

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

@shayderrr
shayderrr merged commit 4155c23 into ItsNotRexed:main Nov 23, 2026
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants