OptimizeFor toLE: report against bsOptShape after ReplaceBlock#24
Merged
ousnius merged 2 commits intoousnius:mainfrom Apr 25, 2026
Merged
Conversation
The toLE branch fired result reports (ShapesNormalsRemoved, ShapesParallaxRemoved, ShapesVertexColorsRemoved, ShapesTangentsAdded, ShapesPartitionsTriangulated) referencing `shape` BEFORE calling `ReplaceBlock(shape, bsOptShape)`. Once the replace runs, those references point to an orphaned block that is no longer part of the header. Three issues addressed together: 1. Invert the normals-removed condition: was `if (normals.Count == 0)` which reports only when there are no normals (nothing to remove). Matches C++ NifFile.cpp:1823 `if (!normals->empty())`. 2. Capture each "did X" outcome in a local bool before the replace; fire the reports against `bsOptShape` afterwards. 3. The toSSE branch and the C++ implementation (NifFile.cpp:1773, 1960) already use this "report after replace" ordering. Bring toLE in line.
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.
The toLE branch of
OptimizeForaddsshapeto severalresult.ShapesXxxlists, then callsReplaceBlock(shape, bsOptShape)which orphans the original. Callers that read the result lists end up with references to the now-detached shape.Five sites affected:
ShapesVColorsRemoved,ShapesNormalsRemoved(which also had its own condition inverted —normals.Count == 0should be> 0),ShapesTangentsAdded,ShapesParallaxRemoved, and the post-replace bookkeeping spot.The toSSE branch already uses the "report after replace" ordering. This brings toLE in line.
C++ reference:
nifly/NifFile.cpp:1823—!normals.empty()for the normals condition.Maps to issue #15 items A3 and A4.