Skip to content

Add Show Ground visualization toggle to the viewer#3626

Open
andrewkaufman wants to merge 3 commits into
newton-physics:mainfrom
andrewkaufman:viewer-show-ground
Open

Add Show Ground visualization toggle to the viewer#3626
andrewkaufman wants to merge 3 commits into
newton-physics:mainfrom
andrewkaufman:viewer-show-ground

Conversation

@andrewkaufman

@andrewkaufman andrewkaufman commented Jul 23, 2026

Copy link
Copy Markdown
Member

Description

Ground plane can get in the way of viewing certain assets. Most other things can be hidden in the viewer, so I figured the ground should be too.

Add a global "Show Ground" checkbox to the viewer visualization panel, backed by ViewerBase.show_ground (default on). When disabled, plane shapes (e.g. the ground plane) are hidden while all other geometry is unaffected.

The gate lives in _should_show_shape() so both the base render loop and the ViewerGL packed-instancer path honor it. Add a regression test.

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_viewer_show_ground.TestShowGroundToggle

Summary by CodeRabbit

  • New Features
    • Added a Show Ground visualization toggle, enabled by default.
    • Ground-plane visibility can now be controlled from the viewer’s Visualization settings.
    • The toggle updates ground rendering across supported viewer modes.

@andrewkaufman andrewkaufman self-assigned this Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1bcf4e30-3161-488a-b006-aa2aa4ed78a1

📥 Commits

Reviewing files that changed from the base of the PR and between 10337d8 and e5481f1.

📒 Files selected for processing (1)
  • newton/_src/viewer/viewer_rtx.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • newton/_src/viewer/viewer_rtx.py

📝 Walkthrough

Walkthrough

Adds a per-layer show_ground toggle, a GUI checkbox, geometry-aware visibility checks, and RTX plane-instance visibility updates. The toggle defaults to enabled and is reset when the RTX model is cleared.

Changes

Ground visibility toggle

Layer / File(s) Summary
Visibility state and rendering integration
newton/_src/viewer/viewer.py, newton/_src/viewer/viewer_gl.py, newton/_src/viewer/viewer_gui.py, CHANGELOG.md
Initializes show_ground as enabled, exposes it in the Visualization controls, passes geometry types into visibility checks, and hides plane shapes when disabled.
RTX visibility synchronization
newton/_src/viewer/viewer_rtx.py
Detects toggle changes, queues visibility updates for plane instances, and resets the cached toggle during model clearing.

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

Sequence Diagram(s)

sequenceDiagram
  participant ViewerGui
  participant ViewerBase
  participant ViewerGL
  participant ViewerRTX
  ViewerGui->>ViewerBase: update show_ground
  ViewerBase->>ViewerGL: evaluate geo_type-aware visibility
  ViewerBase->>ViewerRTX: expose updated toggle state
  ViewerRTX->>ViewerRTX: queue plane-instance visibility updates
Loading
🚥 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 and accurately summarizes the main change: adding a Show Ground visualization toggle to the viewer.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.
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.

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 31.25000% with 11 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
newton/_src/viewer/viewer_rtx.py 11.11% 8 Missing ⚠️
newton/_src/viewer/viewer.py 80.00% 1 Missing ⚠️
newton/_src/viewer/viewer_gl.py 0.00% 1 Missing ⚠️
newton/_src/viewer/viewer_gui.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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

🤖 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 `@newton/_src/viewer/viewer_rtx.py`:
- Around line 1298-1300: Update the show_ground change handling around
_pending_instance_visibility to check whether shapes.geo_type is present before
converting it to int and comparing with newton.GeoType.PLANE. Preserve the
existing visibility update for plane shapes while safely ignoring batches
without a geometry type, consistent with the canonical visibility helper.
- Around line 1298-1300: Update the show_ground_changed handling for plane
shapes in the viewer visibility flow to avoid assigning show_ground directly to
_pending_instance_visibility. Recompute the plane’s visibility using the same
predicate as the base render path, preserving show_visual, show_collision, and
static-shape visibility rules when planes are re-enabled.
🪄 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: 932275ab-77a3-4676-b5aa-18b0a9436406

📥 Commits

Reviewing files that changed from the base of the PR and between 54ef3a6 and 444be6b.

📒 Files selected for processing (1)
  • newton/_src/viewer/viewer_rtx.py

Comment thread newton/_src/viewer/viewer_rtx.py Outdated
andrewkaufman and others added 2 commits July 24, 2026 14:11
Add a global "Show Ground" checkbox to the viewer visualization panel,
backed by ViewerBase.show_ground (default on). When disabled, plane
shapes (e.g. the ground plane) are hidden while all other geometry is
unaffected.

The gate lives in _should_show_shape() so both the base render loop and
the ViewerGL packed-instancer path honor it. Add a regression test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The RTX viewer's render phase bypasses the _shape_instances loop that
drives _should_show_shape(), so plane visibility never updated when
show_ground was toggled.

Track _last_show_ground and push visibility updates for PLANE batches
into _pending_instance_visibility on change; end_frame() already flushes
these to OVRTX each frame.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Comment thread newton/tests/test_viewer_show_ground.py Outdated

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.

I don't think we need a separate test suite for just this feature? We can skip these kinds of mock tests altogether I think.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed in e5481f1 — agreed, the mock-style suite was not earning its keep.

Flagging the consequence so it is a deliberate choice rather than an accident: nothing else in newton/tests touches _should_show_shape or show_ground, so the toggle now has no direct test coverage. Happy to fold a case into an existing viewer suite if you would rather it not go fully uncovered.

@eric-heiden eric-heiden 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.

I think generally this is a useful feature, maybe later we can have something like a scene graph GUI or so to enable better control of toggling visibility for individual bodies/shapes. But in the meantime it should be good to have this.

Assigning show_ground straight into _pending_instance_visibility made
every plane batch visible when the toggle was switched back on, even
when show_visual, show_collision, static-shape, or layer rules should
still have hidden it. Re-derive through _should_show_shape(), the same
predicate the build path uses.

Drop the standalone show_ground test suite at review request. This
leaves the toggle without direct test coverage: nothing else in
newton/tests exercises _should_show_shape or show_ground.

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

Copy link
Copy Markdown
Member Author

Pushed e5481f1 addressing review:

  • Plane visibility — re-derive through _should_show_shape() instead of assigning show_ground straight into _pending_instance_visibility, so re-enabling the ground no longer overrides show_visual, show_collision, static-shape, or layer rules.
  • Test suite — removed test_viewer_show_ground.py per @eric-heiden. Noted in-thread that this leaves the toggle without direct coverage; happy to fold a case into an existing viewer suite instead if preferred.

Verified: uv run --extra dev -m newton.tests -k viewer (221 tests) and uvx pre-commit run -a clean.

@eric-heiden this should cover your review — re-requesting when you have a moment.

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.

2 participants