Skip to content

usdPhysics: add UsdPhysicsRigidBodyAPI::GetCollisionPrims - #7

Closed
andrewkaufman wants to merge 2 commits into
devfrom
add-collision-prims-api
Closed

andrewkaufman wants to merge 2 commits into
devfrom
add-collision-prims-api

Conversation

@andrewkaufman

Copy link
Copy Markdown
Owner

Description of Change(s)

Adds a public method UsdPhysicsRigidBodyAPI::GetCollisionPrims() that returns the collider prims belonging to a rigid body — the same traversal ComputeMassProperties() uses internally to decide which colliders' mass is accumulated into the body.

Starting at the rigid body's prim, the subtree is traversed (including instance proxies) and every prim with UsdPhysicsCollisionAPI applied is collected, with two exceptions:

  • a collider whose physics:collisionEnabled resolves to false is skipped, since a disabled collider takes no part in simulation; and
  • the subtree rooted at a nested prim with UsdPhysicsRigidBodyAPI is pruned, since those colliders belong to that other rigid body rather than to this one.

ComputeMassProperties() is refactored to call GetCollisionPrims(), so the body-ownership and enabled-collider semantics live in exactly one place.

Motivation: downstream physics engines consuming USD currently have to re-implement this exact traversal (subtree ownership + nested-body pruning + enabled-collider filtering) to determine which colliders belong to a body. Exposing it as a public method lets them reuse the canonical logic instead of duplicating it.

Includes a Python wrapping (returns a list of collider prims) and a regression test covering the enabled / disabled / nested-body-pruned cases.

Dependency

This stacks on top of the disabled-collider mass fix (PixarAnimationStudios#4164). Draft until that lands; the enabled-collider filter in GetCollisionPrims() shares that behavior.

Link to proposal

N/A — additive public API, no schema change.

Checklist

  • I have created this PR based on the dev branch
  • I have followed the coding conventions
  • I have added unit tests that exercise this functionality
  • I have verified that all unit tests pass with the proposed changes

UsdPhysicsRigidBodyAPI::ComputeMassProperties gathered every descendant
prim with PhysicsCollisionAPI applied, regardless of whether the collider
was enabled. A collider with physics:collisionEnabled = false was still
contributing its mass, center of mass, and inertia to the body.

physics:collisionEnabled determines whether the PhysicsCollisionAPI is
enabled; a collider whose collision is disabled takes no part in
simulation and so should not contribute to a body's aggregated mass
properties. Skip colliders whose resolved physics:collisionEnabled is
false when gathering shapes for the mass computer.

Also clarifies in the PhysicsMassAPI documentation and the usdPhysics
overview that a disabled collider or disabled rigid body takes no part in
simulation, so it is excluded from mass computation and any MassAPI
applied to it has no effect.

Adds a regression test: a rigid body with one enabled unit cube and one
disabled cube offset along z now reports the mass, center of mass, and
inertia of the single enabled cube only.
Comment thread pxr/usd/usdPhysics/rigidBodyAPI.cpp
Comment thread pxr/usd/usdPhysics/rigidBodyAPI.cpp
Comment thread pxr/usd/usdPhysics/rigidBodyAPI.cpp
Comment thread pxr/usd/usdPhysics/rigidBodyAPI.h Outdated
Comment thread pxr/usd/usdPhysics/rigidBodyAPI.h Outdated
Comment thread pxr/usd/usdPhysics/rigidBodyAPI.cpp
Comment thread pxr/usd/usdPhysics/rigidBodyAPI.cpp
Comment thread pxr/usd/usdPhysics/rigidBodyAPI.cpp
Comment thread pxr/usd/usdPhysics/rigidBodyAPI.h Outdated
Comment thread pxr/usd/usdPhysics/rigidBodyAPI.h Outdated
Comment thread pxr/usd/usdPhysics/rigidBodyAPI.h Outdated
Exposes the traversal that ComputeMassProperties uses to gather the
colliders belonging to a rigid body as a public method. Starting at the
body prim, the subtree is traversed (including instance proxies) and
every enabled UsdPhysicsCollisionAPI prim is collected; subtrees rooted
at nested rigid bodies are pruned since those colliders belong to a
different body, and colliders whose physics:collisionEnabled is false are
skipped.

ComputeMassProperties is refactored to call GetCollisionPrims so the
body-ownership and enabled-collider semantics live in one place, and
clients (e.g. physics engines consuming USD) can reproduce them without
re-implementing the traversal.

Adds a Python wrapping returning the list of collider prims and a
regression test covering the enabled/disabled/nested-body cases.
@andrewkaufman
andrewkaufman force-pushed the add-collision-prims-api branch from 9216f81 to 7e7a9ff Compare July 22, 2026 23:15
@andrewkaufman

Copy link
Copy Markdown
Owner Author

Superseded by upstream PR PixarAnimationStudios#4165 (squashed, on top of PixarAnimationStudios#4164).

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.

1 participant