Skip to content

Applying a material override merges the local textures it tracks into the render material - #451

Merged
RyeMutt merged 1 commit into
developfrom
rye/gltf-override-local-tex
Oct 12, 2026
Merged

RyeMutt merged 1 commit into
developfrom
rye/gltf-override-local-tex

Conversation

@RyeMutt

@RyeMutt RyeMutt commented Oct 12, 2026

Copy link
Copy Markdown
Member

LLGLTFMaterial::applyOverride was meant to merge the override's local texture tracking map into the render material's, but it passed one iterator as both ends of the range:

auto it = override_mat.mTrackingIdToLocalTexture.begin();
mTrackingIdToLocalTexture.insert(it, it);

std::map takes that as an empty range, so nothing was merged. This dates from upstream's SL-20523, where the line was insert(begin(), begin()); the later hashing rework shortened it and kept the empty range.

As a result, a local texture set on a material override was never tracked on the render material. updateTextureTracking never linked the render material to that local bitmap, so the object didn't update when the file changed, and the local texture digest included in the material's hash left it out.

Keep or overwrite

Where the base and the override both track a local texture, the override's entry now wins (insert_or_assign). That matches the rest of applyOverride, where the override's texture ids replace the base's, and every other write to the map already overwrites. In practice the two values almost never differ: LLLocalBitmap::updateGLTFMaterials updates every registered material before reapplying overrides, and on an LLFetchedGLTFMaterial, updateTextureTracking resets each entry to the bitmap's current world id anyway.

Test

llgltfmaterial_test.cpp gets a new TUT test<13>:

  • An override carrying a tracked local texture is applied to a render material that tracks its own. The render material keeps its own entry and gains the override's, updateTextureTracking (seen through a small subclass) finds both, and the digest covers both.
  • When both track the same id, the override's world id wins.

Checked:

  • Fails without the fix (12 of 13, on "render material tracks the override's local texture")
  • With a plain range insert (keep), only the both-track check fails, so it locks in the overwrite choice
  • All five llprimitive tests pass with the fix (ninja-os, -DAL_BUILD_TESTS=ON, RelWithDebInfo, macOS)

Whichever of this and #449 merges second will need to convert test<13> to Catch2.

🤖 Generated with Claude Code

… the render material

applyOverride meant to merge the override's tracking map into the render
material's, but passed one iterator as both ends of the range, so std::map
inserted an empty range and merged nothing. It has been that way since local
texture tracking came in with upstream's SL-20523 (begin() as both ends
then; the hashing rework later shortened it to the same iterator twice). A
local texture set on an override was never tracked on the render material:
updateTextureTracking never associated it with its local bitmap, so the
object did not follow changes to the file, and the local texture digest the
hash carries left it out.

Where both track a local texture, the override's entry now wins, as its
texture ids do and as every other write to the map assigns. On an
LLFetchedGLTFMaterial the choice is brief anyway: updateTextureTracking
associates each tracking id with its bitmap, which resets the entry to the
bitmap's current world id.

The test applies an override carrying a tracked local texture and checks
that the render material keeps its own entry, gains the override's, finds
both in updateTextureTracking and digests both; and that the override's
entry wins a tracking id both hold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 47 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8799eef7-810f-470c-afeb-55467c1d3059

📥 Commits

Reviewing files that changed from the base of the PR and between a78b91f and c1453f9.


📒 Files selected for processing (2)
  • indra/llprimitive/llgltfmaterial.cpp
  • indra/llprimitive/tests/llgltfmaterial_test.cpp

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@RyeMutt
RyeMutt merged commit 03716b2 into develop Oct 12, 2026
13 of 15 checks passed
@RyeMutt
RyeMutt deleted the rye/gltf-override-local-tex branch October 12, 2026 09:23
RyeMutt added a commit that referenced this pull request Oct 12, 2026
Two pull requests merged into develop on the same morning. #451 added
a TUT test<13> to llgltfmaterial_test.cpp, which #449 had converted to
Catch2, so llprimitive's tests no longer compiled anywhere:
llgltfmaterial_object_t no longer exists.

Its two parts are now two TEST_CASEs, as the rest of the file is
written. Each finding of a tracked texture is a REQUIRE before the
entry is read; the rest are CHECKs. What they check is unchanged: the
override's local texture tracked beside the material's own, both
found by updateTextureTracking and covered by the digest, and the
override's world id winning where both track the same texture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant