Skip to content

Viewer: Home and End move the near clip, to see through without moving the camera - #370

Merged
rmrsk merged 2 commits into
mainfrom
near-clip
Nov 22, 2026
Merged

rmrsk merged 2 commits into
mainfrom
near-clip

Conversation

@rmrsk

@rmrsk rmrsk commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #258

Background

The renderer's camera has a near clip (Camera::m_nearClip: every camera ray starts that far from the eye), but no viewer key set it, so the only way to see through the front of a model without moving the camera was to cut it with the section plane or to see through picked surfaces one at a time. #258's last comment asks for keys for it.

Solution

Viewer keys only, on the existing camera field; no API change.

Key Action
Home / End Push the near clip away from the eye / bring it back, by 1/20 of the camera's distance to its target
Shift + Home / End The same by 1/100
Alt + wheel By 1/50 a wheel step; rolled up pushes it away, as the wheel zooms in
Ctrl + Home / End Take it away (0)
  • The camera and its target stay put, so orbiting keeps turning around the same point.
  • The step is ViewerDetail::steppedNearClip() (outside the SDL-only part of EBGeometry_ViewerImplem.hpp, a template, so it compiles into no other translation unit): never below 0, and snapping to 0 within a thousandth of a step, so stepping forward and back (or zooming in between) returns to no clip exactly.
  • The camera menu's line shows the near clip while it is on (it was only in the details, D). R puts back the camera the window opened with, near clip included.
  • It works with the section plane, peeling, the see-through surfaces and the exploded view, since the renderer and picking already start every ray at the near clip. The slice view (Z) shows only the plane, which a near clip could only hide: entering it sets the near clip to 0, leaving gives it back, and the keys do nothing there.
  • A near-clip change ends Shift + wheel stepping (as zooming does), since its crossings were found from the old near clip.
  • Docs: the key table and a "Near clip" item under "Picking and looking inside" in Viewer.rst; the TestRender row of TestingLocally.rst.

Side-effects

None for programs: no signature or settings change. Home, End and Alt + wheel were unbound in the viewer and in ebgstudio.

Alternative solutions

Performance

Host receipt green, Performance/receipts/near-clip-a2c485fc.md: every probe compiled to the same code on both sides (332 cases, none run), as the change is viewer-only (the window code compiles only with SDL2, and the new helper is a template no probe instantiates). No device section: no code a device runs changed.

Where to look

  • Source/EBGeometry_ViewerImplem.hpp: steppedNearClip(), the SDLK_HOME/SDLK_END case, the Alt branch of the wheel handler, the slice view's entry (Z), the camera menu line.
  • Verified: ctest --preset debug (822 tests) with the SDL2 viewer compiled; TestRender under debug-san and under release-test with both precisions; the Sphinx HTML build and the Doxygen hook.
  • Not verified: the keys in a running window (no display on the agent's machine), so the key and wheel wiring, the slice view's save and restore and R are checked only by reading. Alt + wheel may be taken by some Linux window managers; Home and End do the same.

Reviewer checklist (to be completed by a human)

  • The test suite compiles and runs to completion without warnings or errors.
  • All relevant new features are documented in the user documentation (Sphinx).
  • This contribution does not break existing sections in the user documentation.
  • All relevant APIs are documented in the doxygen documentation.
  • Appropriate labels have been assigned to this PR.
  • New or revised proper licensing and copyright information is in place.
  • A PR review has been run using @claude review.
  • The continuous integration and testing hooks at GitHub run to completion.
  • The performance receipt is current (CI's Performance-receipt passes), and every regression in it is explained.

🤖 Generated with Claude Code

https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk

… without moving the camera

Home pushes the camera's near clip away from the eye by a twentieth of its distance to the
target, End brings it back (a hundredth with Shift), Alt + wheel steps it by a fiftieth, and
Ctrl + Home or End takes it away. The camera and its target stay put. The slice view shows the
plane without the near clip and gives it back on leaving. The camera menu shows the near clip
while it is on. The step is ViewerDetail::steppedNearClip(), never below 0 and snapping to 0
within a thousandth of a step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
@rmrsk rmrsk added enhancement New feature or request rendering Affects rendering functionality labels Nov 22, 2026
@rmrsk

rmrsk commented Nov 22, 2026

Copy link
Copy Markdown
Owner Author

@claude review

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Claude finished @rmrsk's task in 29s —— View job


Review of #370: Viewer near-clip keys

No blocking findings. I read the diff and the surrounding handler code. I did not build or run anything, and there is no display here, so the keys in a window are untested.

Checked and correct

  • steppedNearClip() (Source/EBGeometry_ViewerImplem.hpp) clamps at 0 and snaps to 0 within a thousandth of a step. It is a template in ViewerDetail, so it adds no new translation unit.
  • Slice view: beforeSlice = camera is saved before m_nearClip is set to 0, so Z (leaving) restores the near clip. R restores m_home or a_camera, which include the near clip.
  • Home/End in the slice view sets changed = pending, the same no-op pattern the neighboring keys use. In the other branches changed stays at its default of true.
  • endStepping(false) is called after a near-clip change, consistent with the zoom handling.
  • Docs: the Viewer.rst key table, the "Near clip" item and the TestingLocally.rst row are updated, with no history or test references. The spelling is American English.
  • Test: the TestRender case is a TEMPLATE_TEST_CASE with tightMargin. It compares against hand-computed values, not the code run a second way.

Nits and questions (non-blocking)

  1. Alt + wheel on Linux. Many window managers grab Alt + wheel or Alt + drag. The Home/End keys cover the same function, so this is only a documentation concern. You could note it in Viewer.rst if you have seen it in practice.
  2. Alt and Ctrl together. Ctrl + Alt + wheel falls through to whichever branch comes first. Ctrl, Shift and the exploded view are tested before the new Alt branch, but I did not trace the plain Ctrl + wheel (section plane) branch. Confirm it runs before Alt, so that Ctrl + Alt + wheel does not step the near clip.
  3. Test coverage. The test covers only the step helper. The key and wheel wiring, the slice-view save and restore, and R are untested. This is probably acceptable, since the viewer is SDL-only and has no display in CI. Say so in Where to look, as you already do for the keys.
  4. Near clip past the target. Nothing caps the near clip at the camera's distance to its target. Pushing it past the target shows an empty frame. That is the expected CAD behavior, but the docs could say End or Ctrl + Home recovers.

Per CLAUDE.md, before hand-over

  • The Performance section is still "To be filled". The receipt is due after the review rounds converge. The change is viewer-only, so the receipt may have nothing library-side to compare.
  • Run TestRender in both precisions and the Doxygen and Sphinx checks. I did not run them.
    · branch near-clip

…e same code)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
@rmrsk
rmrsk marked this pull request as ready for review November 22, 2026 14:01
@rmrsk
rmrsk merged commit 0a4fbcc into main Nov 22, 2026
45 of 56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request rendering Affects rendering functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Viewer: turn parts of the geometry on and off (recompile the tape from the Expr)

1 participant