Skip to content

OptimizeFor: invert vertex-color All/Any check to match C++#20

Merged
ousnius merged 2 commits intoousnius:mainfrom
MANOLOV02:fix/optimizefor-vertex-color-removal-logic
Apr 25, 2026
Merged

OptimizeFor: invert vertex-color All/Any check to match C++#20
ousnius merged 2 commits intoousnius:mainfrom
MANOLOV02:fix/optimizefor-vertex-color-removal-logic

Conversation

@MANOLOV02
Copy link
Copy Markdown
Contributor

Both OptimizeFor toSSE and toLE compute withoutVertexColors as Any(c => c != white), which sets the flag whenever any color is non-white. The intent (and the C++ behavior) is the opposite: vertex colors should be removable only when all colors are white/neutral.

Net effect of the bug: vertex colors get stripped from shapes that have any non-white color and preserved on shapes that are all white — exactly backwards.

C++ reference: nifly/NifFile.cpp:1544-1552 uses std::all_of(... == white).

Fix: replace Any(c => c != white) with All(c => c == white) in both toSSE and toLE.

Maps to issue #15 item A1.

MANOLOV02 and others added 2 commits April 25, 2026 17:46
Both the toSSE and toLE branches gated vertex-color removal with
`colors.Any(c => c != white)` — which evaluates true when at least
one color is NOT white. That is the opposite of what the comment says
("remove if all are white/neutral") and the opposite of the C++
implementation in NifFile.cpp:1544-1549, which starts with
`removeVertexColors = true` and flips it to false on the first
non-white color found (`std::all_of`-style semantics).

Net effect before the fix: vertex colors were stripped on shapes
that had any non-white color and preserved on shapes that were all
white — exactly backwards.
@ousnius ousnius merged commit 7679790 into ousnius:main Apr 25, 2026
1 check passed
@MANOLOV02 MANOLOV02 deleted the fix/optimizefor-vertex-color-removal-logic branch April 25, 2026 23:42
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.

2 participants