Skip to content

Load visual-only shapes from USD#473

Merged
eric-heiden merged 6 commits into
newton-physics:mainfrom
eric-heiden:usd-load-visual-prims
Jul 25, 2025
Merged

Load visual-only shapes from USD#473
eric-heiden merged 6 commits into
newton-physics:mainfrom
eric-heiden:usd-load-visual-prims

Conversation

@eric-heiden

@eric-heiden eric-heiden commented Jul 25, 2025

Copy link
Copy Markdown
Member

Description

  • Prims that have no UsdPhysics schema applied are now loaded as visual-only shapes if the flag load_non_physics_prims provided to parse_usd is True
  • Removed only_load_warp_scene argument and filtering by special "warp" attributes

Newton Migration Guide

Please ensure the migration guide for warp.sim users is up-to-date with the changes made in this MR.

  • The migration guide in docs/migration.rst is up-to date

Before your PR is "Ready for review"

  • All commits are signed-off to indicate that your contribution adheres to the Developer Certificate of Origin requirements
  • Necessary tests have been added and new examples are tested (see newton/tests/test_examples.py)
  • Documentation is up-to-date
  • Code passes formatting and linting checks with pre-commit run -a

Summary by CodeRabbit

  • New Features

    • Added support for loading non-physics objects as visual shapes attached to rigid bodies when importing scenes.
    • Introduced an option to disable loading of non-physics visuals for streamlined imports.
  • Improvements

    • Enhanced imported scene completeness by including visual shapes for non-physics elements.
    • Improved verbose output to display articulation body details when enabled.
    • Fixed shape classification to correctly add cylinders instead of capsules.
    • Avoided duplicate shapes during import for cleaner scene representation.
  • Removed

    • Removed filtering based on Warp simulation scenes, ensuring all relevant bodies and shapes are imported.
  • Tests

    • Added comprehensive tests validating import behavior with and without non-physics visuals.

Signed-off-by: Eric Heiden <eric-heiden@outlook.com>
@coderabbitai

coderabbitai Bot commented Jul 25, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The parse_usd function in newton/utils/import_usd.py was refactored to remove Warp scene filtering and introduce a new mechanism for loading non-physics prims as visual shapes under rigid bodies. New helper functions were added to encapsulate visual shape loading, and function signatures were updated accordingly. Tests were enhanced to verify these changes and added a new test for disabling non-physics prim loading.

Changes

File(s) Change Summary
newton/utils/import_usd.py Removed Warp scene filtering logic; added load_non_physics_prims parameter to parse_usd; introduced load_visual_shapes and add_body helpers; updated body and articulation parsing to support visual shapes for non-physics prims; fixed shape handling bugs; improved verbosity.
newton/tests/test_import_usd.py Enhanced test_import_articulation with additional assertions on shapes, bodies, joints, and collisions; added test_import_articulation_no_visuals to test import with visual shapes disabled.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant parse_usd
    participant add_body
    participant load_visual_shapes
    participant builder

    User->>parse_usd: Call with load_non_physics_prims=True
    parse_usd->>add_body: For each body prim
    add_body->>builder: Add body
    add_body->>load_visual_shapes: If load_non_physics_prims, load visual shapes for children
    load_visual_shapes->>builder: Add visual shape (zero density, no collision)
    parse_usd->>add_body: For each articulation body prim
    add_body->>builder: Add articulation body
    add_body->>load_visual_shapes: Load visual shapes for articulation children
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Suggested reviewers

  • Milad-Rakhsha-NV

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9c9a895 and 07a0efa.

📒 Files selected for processing (2)
  • newton/tests/test_import_usd.py (2 hunks)
  • newton/utils/import_usd.py (11 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
newton/utils/import_usd.py (2)

303-450: Consider performance impact and add tests.

The recursive traversal in load_visual_shapes could impact loading performance for complex USD scenes. Consider:

  1. Adding performance metrics or warnings for scenes with many non-physics prims
  2. Documenting the performance implications in the function docstring
  3. Adding unit tests to verify visual shape loading behavior

52-52: Ensure migration guide is updated.

As mentioned in the PR objectives, the migration guide for warp.sim users should be updated to reflect the removal of only_load_warp_scene parameter and the addition of load_non_physics_prims.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67a17ff and 9c9a895.

📒 Files selected for processing (1)
  • newton/utils/import_usd.py (6 hunks)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run GPU Unit Tests on AWS EC2 (Pull Request)
🔇 Additional comments (6)
newton/utils/import_usd.py (6)

52-52: Function signature change looks good.

The addition of load_non_physics_prims parameter with a default value of True maintains backward compatibility while providing the new functionality to load visual-only shapes.

Also applies to: 78-78


297-301: Visual shape configuration is appropriate.

The configuration correctly sets up shapes with zero density and disabled collisions, ensuring they serve only as visual elements without affecting physics simulation.


410-434: Mesh loading implementation is correct.

The code properly handles mesh triangulation and is consistent with the existing mesh handling patterns in the file.


481-481: Parse body refactoring is correct.

The changes properly integrate the new add_body helper and maintain compatibility with the deferred body creation pattern.

Also applies to: 484-487


814-818: Verbose logging enhancement is helpful.

The additional logging for articulation bodies improves debugging capabilities when verbose mode is enabled.


877-877: Articulation body creation properly uses the new helper.

The changes correctly use the add_body helper to ensure visual shapes are loaded for articulation bodies when load_non_physics_prims is enabled.

Also applies to: 882-882

Comment thread newton/utils/import_usd.py
Comment thread newton/utils/import_usd.py Outdated
Comment thread newton/utils/import_usd.py Outdated
@Milad-Rakhsha-NV

Copy link
Copy Markdown
Member

Thanks Eric! Works great!
Probably not super high priority, but does it make sense to create these shapes on the mjmodel side as well to keep the mujoco viewer happy too?

@Milad-Rakhsha-NV Milad-Rakhsha-NV self-requested a review July 25, 2025 05:09

@adenzler-nvidia adenzler-nvidia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, just one question. And this needs some testing.

Comment thread newton/utils/import_usd.py
@eric-heiden eric-heiden linked an issue Jul 25, 2025 that may be closed by this pull request
Signed-off-by: Eric Heiden <eric-heiden@outlook.com>
Signed-off-by: Eric Heiden <eric-heiden@outlook.com>
Signed-off-by: Eric Heiden <eric-heiden@outlook.com>
Signed-off-by: Eric Heiden <eric-heiden@outlook.com>
@eric-heiden

Copy link
Copy Markdown
Member Author

Probably not super high priority, but does it make sense to create these shapes on the mjmodel side as well to keep the mujoco viewer happy too?

This is not needed for simulation and may slow down MuJoCo so I don't think we should do this. The Newton visualizer should be enough to debug the simulation eventually so we should not expect the MuJoCo visualizer to have everything in it, even things that are unrelated to the simulation.

@eric-heiden eric-heiden enabled auto-merge (squash) July 25, 2025 22:09
@eric-heiden eric-heiden merged commit debe21d into newton-physics:main Jul 25, 2025
9 of 10 checks passed
@adenzler-nvidia

Copy link
Copy Markdown
Member

Do we have a ticket for the tests?

@coderabbitai coderabbitai Bot mentioned this pull request Jan 13, 2026
4 tasks
eric-heiden added a commit to eric-heiden/newton that referenced this pull request Jan 28, 2026
Signed-off-by: Eric Heiden <eric-heiden@outlook.com>
mmacklin pushed a commit to mmacklin/newton that referenced this pull request Apr 7, 2026
Signed-off-by: Eric Heiden <eric-heiden@outlook.com>
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.

Parse visual-only shapes in USD importer

3 participants