Skip to content

feat(shade): ComputeBoundMaterial resolution#94

Merged
mxpv merged 5 commits into
mxpv:mainfrom
bresilla:feat/shade-bound-material
May 31, 2026
Merged

feat(shade): ComputeBoundMaterial resolution#94
mxpv merged 5 commits into
mxpv:mainfrom
bresilla:feat/shade-bound-material

Conversation

@bresilla
Copy link
Copy Markdown
Contributor

Adds compute_bound_material to the shade MaterialBindingAPI - resolving which material actually binds to a prim, on top of the existing per-relationship read/author.

Walks the prim and its ancestors (spec §15 / UsdShadeMaterialBindingAPI::ComputeBoundMaterial): a closer binding wins unless an ancestor is strongerThanDescendants; at each prim a collection binding whose collection includes the prim beats the direct binding, collection bindings resolve in native property order, and a restricted purpose is preferred over all-purpose. Collection membership uses the merged UsdCollectionAPI (#92), with a per-collection query cache across the walk.

Two commits - direct resolution, then collection-aware on top. 10 binding tests covering inheritance, the strength override, purpose fallback, collection-beats-direct, and native ordering.

Copilot AI review requested due to automatic review settings May 31, 2026 22:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a compute_bound_material resolver for the UsdShade MaterialBindingAPI that walks a prim's namespace ancestry to determine the bound material, honoring binding strength, purpose fallback, and collection-vs-direct precedence (mirroring UsdShadeMaterialBindingAPI::ComputeBoundMaterial).

Changes:

  • Implements compute_bound_material plus helpers (winning_binding_at, collection_bindings_on, is_collection_member, purpose_fallbacks) with a per-walk membership-query cache.
  • Re-exports compute_bound_material from schemas::shade.
  • Adds unit tests covering inheritance, strongerThanDescendants override, purpose fallback, and collection-vs-direct precedence; updates roadmap notes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/schemas/shade/binding.rs New resolver, helpers, and tests for compute_bound_material.
src/schemas/shade/mod.rs Re-exports compute_bound_material.
ROADMAP.md Documents the new resolver under UsdShade.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/schemas/shade/binding.rs Outdated
Comment thread src/schemas/shade/binding.rs
Comment thread src/schemas/shade/binding.rs
mxpv added 2 commits May 31, 2026 16:17
compute_bound_material resolved the purpose fallback per-prim, so a
closer all-purpose binding wrongly beat a restricted-purpose binding on
an ancestor. Hoist the purpose loop above the ancestor walk (matching
C++ ComputeBoundMaterial): a restricted binding anywhere in the chain
now outranks an all-purpose binding on a closer prim. Add a test
covering the ancestor-restricted case and shorten the bound-material
test names.
Classify a collection binding's purpose by token count, matching C++
_GetMaterialPurpose: a deeper-namespaced name resolves to all-purpose
rather than a bogus restricted purpose. Cache collection membership
through the Entry API and store None for non-collection paths so they
are not re-parsed on each ancestor visit. Assert the concrete winner in
the native-order test so an ordering regression is actually caught.
@mxpv mxpv merged commit 251d17e into mxpv:main May 31, 2026
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