OptimizeFor: invert vertex-color All/Any check to match C++#20
Merged
ousnius merged 2 commits intoousnius:mainfrom Apr 25, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Both
OptimizeFortoSSE and toLE computewithoutVertexColorsasAny(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-1552usesstd::all_of(... == white).Fix: replace
Any(c => c != white)withAll(c => c == white)in both toSSE and toLE.Maps to issue #15 item A1.