feat(shade): ComputeBoundMaterial resolution#94
Merged
Conversation
There was a problem hiding this comment.
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_materialplus helpers (winning_binding_at,collection_bindings_on,is_collection_member,purpose_fallbacks) with a per-walk membership-query cache. - Re-exports
compute_bound_materialfromschemas::shade. - Adds unit tests covering inheritance,
strongerThanDescendantsoverride, 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.
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.
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.
Adds
compute_bound_materialto the shadeMaterialBindingAPI- 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 isstrongerThanDescendants; 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 mergedUsdCollectionAPI(#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.