feat(physics): add UsdPhysics schema reader#65
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new physics module to openusd-rs that decodes the UsdPhysics schema family from a composed Stage, along with an integration-test fixture that exercises the full reader surface.
Changes:
- Introduces
openusd::physicsmodule with tokens, decoded types, and reader functions (including a one-passfind_physics_primsstage walk). - Adds a comprehensive USDA fixture scene covering scenes, rigid bodies, mass, collision/material binding, all joint kinds, multi-apply limits/drives, collision groups, and filtered pairs.
- Adds integration tests validating reader behavior against the fixture.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/lib.rs |
Exposes the new physics module from the crate root. |
src/physics/mod.rs |
Defines the module’s public surface and re-exports readers/types/tokens. |
src/physics/tokens.rs |
Adds canonical UsdPhysics token constants (schema names, attr/rel names, instance tokens). |
src/physics/types.rs |
Adds decoded enums/structs returned by the reader API. |
src/physics/read.rs |
Implements schema reader functions and stage-walk discovery helper. |
fixtures/usdPhysics_scene.usda |
Adds a purpose-built integration-test fixture scene covering all supported readers. |
tests/physics_reader.rs |
Adds integration tests validating each reader against the fixture. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dbca7aa to
00fa116
Compare
0f63672 to
d27398b
Compare
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
d27398b to
b5bf6f8
Compare
Replace manual field("apiSchemas") / field("typeName") calls and the
local read_api_schemas wrapper with stage.api_schemas(), has_api_schema(),
and type_name(). Removes read_api_schemas from the public API since
stage.api_schemas() is now the canonical entry point.
Adds a `physics` Cargo feature that controls compilation of the physics schema reader. The integration test requires the feature via required-features so it is excluded from default builds and included automatically when running cargo test --all-features (which CI already does).
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.
Been carrying this code in bevy_openusd (a Bevy plugin that loads USD scenes) for a while as a separate
usd_schemascrate. Realised the right home for the schema layer is here in openusd-rs — keeping it inside a Bevy-side crate doesn't make sense when it's pure schema decoding that any consumer would want. So I'm moving it over, starting withphysicssince it's the most polished. Happy to do follow-up PRs for the other schema families I have lying around (geom, shade, lux, skel, render, ui, media) if you think they're useful.What's in:
material:binding:physicswith fallback to plainmaterial:bindingfind_physics_prims(&Stage)that walks once and returns categorised path lists, so callers don't re-walk per familyModule shape mirrors the C++ surface in
pxr/usd/usdPhysics/:I went with
physics(single-word, nousd_prefix) to match the brevity ofsdf/pcp/ar/stage. Future schema modules would follow the same shape —geom,shade,lux, etc. The "Usd" is implicit in the crate name. Open to renaming if you'd prefer something else.Conventions followed by the readers (called out in the module docs):
metersPerUnit/kilogramsPerUnit)(w, x, y, z)order — both as USD authors themlower > upperon any limit means a locked DOFNonewhen a schema isn't applied / the prim isn't of the expected typeTests:
fixtures/usdPhysics_scene.usda— small scene exercising every reader (gravity, all 6 joint kinds incl. multi-apply limits + drives, material binding, collision group, filtered pairs)tests/physics_reader.rs— 15 integration tests, all greenusdPhysics_schema.usdafixture (used bytext_writer_roundtrip) is the schema definition file — fine for parser tests, but not a populated scene, hence the new fixtureNot in this PR (called out in the module + struct docs):
&mut sdf::Datadirectly if that's preferredcollection:colliders:includestarget list, adequate for the common authoring patternThe reader has been load-tested against the Agilebot GBT-C5A robot (Isaac Sim USDC asset, ~165 prims, 7 rigid bodies, 1 articulation root, 6 revolute + 1 fixed joints) — every schema decodes cleanly.