Skip to content

Keep guide-purpose colliders off the visual toggle - #3650

Closed
andrewkaufman wants to merge 1 commit into
newton-physics:mainfrom
andrewkaufman:usd-collider-visibility
Closed

Keep guide-purpose colliders off the visual toggle#3650
andrewkaufman wants to merge 1 commit into
newton-physics:mainfrom
andrewkaufman:usd-collider-visibility

Conversation

@andrewkaufman

@andrewkaufman andrewkaufman commented Jul 25, 2026

Copy link
Copy Markdown
Member

Description

A collider with a bound render material was given the VISIBLE flag regardless of its
purpose. Viewers draw a shape when (COLLIDE and show_collision) or (VISIBLE and show_visual), so such a collider was drawn by the visual toggle and could not be
hidden by the collision toggle — it occluded the very visual shapes it sat beside.

guide is the conventional purpose for authored collision geometry (the MuJoCo USD
exporter emits it), so honour it: purpose now gates only whether a collider inherits
visibility from its bound render material. force_show_colliders is checked
independently and still reveals guide colliders, which is what the previous
behaviour was protecting — that concern is preserved, it was just conflated with
material-inherited visibility.

Note for reviewers: this changes behaviour for existing assets. A guide-purpose
collider with a render material used to render and now does not, unless
force_show_colliders=True. Filed under Fixed since the old behaviour made the
viewer's collision toggle inoperative on such assets, but it is worth a second
opinion if anyone is relying on it.

Checklist

  • New or existing tests cover these changes
  • The documentation is up to date with these changes
  • CHANGELOG.md has been updated (if user-facing change)

Test plan

uv run --extra dev -m unittest newton.tests.test_import_usd -k guide_purpose_collider_with_material
uv run --extra dev -m unittest newton.tests.test_import_usd   # 282 tests
uv run --extra dev -m newton.tests -k viewer                  # 221 tests
uvx pre-commit run -a

Verified the new test fails without the fix (AssertionError: 1 is not false) and
passes with it.

Bug fix

Steps to reproduce:

  1. Author a rigid body with a visual mesh and a separate collision mesh.
  2. Give the collision mesh uniform token purpose = "guide" and bind a render
    material to it.
  3. Import with ModelBuilder.add_usd() and inspect the collider's shape flags, or
    view it with show_visual=True, show_collision=False.
  4. The collider carries VISIBLE, so it is drawn by the visual toggle and the
    collision toggle cannot hide it.

Minimal reproduction:

import newton
from newton import ShapeFlags

builder = newton.ModelBuilder()
shape = builder.add_usd(stage)["path_shape_map"]["/Body/CollisionMesh"]

# Before: True  (guide-purpose collider drawn by the visual toggle)
# After:  False (collision toggle owns it; force_show_colliders still reveals it)
print(bool(builder.shape_flags[shape] & ShapeFlags.VISIBLE))

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Fixed visibility handling for guide-purpose colliders with bound render materials.
    • These colliders now follow collision display settings instead of being shown automatically.
    • The force-show-colliders option continues to display them when enabled.
  • Tests

    • Added regression coverage for collider visibility and force-show behavior.

A collider with a bound render material was given the VISIBLE flag
regardless of its purpose. Viewers draw a shape when (COLLIDE and
show_collision) or (VISIBLE and show_visual), so such a collider was
drawn by the visual toggle and could not be hidden by the collision
toggle -- it occluded the very visual shapes it sat next to.

"guide" is the conventional purpose for authored collision geometry,
so honour it: purpose now gates only whether a collider inherits
visibility from its render material. force_show_colliders is checked
independently and still reveals guide colliders, which is what the
previous behaviour was protecting.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The USD importer now requires mesh colliders to be viewport-drawn before bound materials mark them visible. Guide-purpose colliders remain collision shapes without VISIBLE by default, while force_show_colliders still reveals them. A regression test and changelog entry document the behavior.

Changes

USD collider visibility

Layer / File(s) Summary
Guide collider visibility logic
newton/_src/utils/import_usd.py
Mesh collider material visibility now also depends on _is_viewport_drawn(prim), keeping guide-purpose collider display policy separate.
Visibility regression coverage and changelog
newton/tests/test_import_usd.py, CHANGELOG.md
Adds coverage for default and forced guide-collider visibility and records the corrected behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: jumyungc

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: guide-purpose colliders no longer inherit visual visibility from materials.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CHANGELOG.md`:
- Line 81: Update the CHANGELOG entry describing ModelBuilder.add_usd() so it
documents material-inherited VISIBLE removal for both guide- and render-purpose
mesh colliders, while preserving the existing note about force_show_colliders.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8b0ad439-6a66-4590-a702-096ef5dae1d2

📥 Commits

Reviewing files that changed from the base of the PR and between 9db21eb and 8fa0c79.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • newton/_src/utils/import_usd.py
  • newton/tests/test_import_usd.py

Comment thread CHANGELOG.md

### Fixed

- Fix `ModelBuilder.add_usd()` marking a `guide`-purpose collider visible when it has a bound render material. Such a collider is not viewport geometry, and the extra `VISIBLE` flag left it drawn by the viewer's visual toggle instead of its collision toggle. `force_show_colliders` still reveals it.

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document the render-purpose behavior too.

The new gate in newton/_src/utils/import_usd.py removes material-inherited VISIBLE for both guide and render mesh colliders, but this entry mentions only guide. Update the entry to cover both purposes, or narrow the code if render was not intended to change.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CHANGELOG.md` at line 81, Update the CHANGELOG entry describing
ModelBuilder.add_usd() so it documents material-inherited VISIBLE removal for
both guide- and render-purpose mesh colliders, while preserving the existing
note about force_show_colliders.

Source: Path instructions

@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@andrewkaufman

Copy link
Copy Markdown
Member Author

Closing in favour of a single consolidated PR.

@eric-heiden asked for the visual/collider visibility work to land together rather than piecemeal, and while investigating this it became clear the guide-purpose fix here is one facet of a broader issue: whether a collider is drawn should follow USD purpose and visibility, not whether a render material happens to be bound to it. That same question governs approximated colliders (which currently discard their authored render mesh) and interacts with #3694.

Rolling this commit, the approximation fix, and the remaining drawability work into a fix-shape-loading branch. Will open that once it accounts for #3694.

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