Skip to content

Add $vpr/$vpt/$vpd viewport special variables (v3.5 deferred item)#74

Open
particlesector wants to merge 1 commit into
mainfrom
claude/openscad-v3.5-deferred-osst06
Open

Add $vpr/$vpt/$vpd viewport special variables (v3.5 deferred item)#74
particlesector wants to merge 1 commit into
mainfrom
claude/openscad-v3.5-deferred-osst06

Conversation

@particlesector

Copy link
Copy Markdown
Owner

Summary

  • Picks up the first of the two items explicitly deferred at the end of the v3.5 pass: $vpr/$vpt/$vpd viewport special variables (the second — making cube/sphere/translate/etc. ordinary identifiers instead of reserved keywords — is a genuine grammar/semantics refactor and stays deferred; see docs/roadmap.md).
  • Interpreter gains a setViewport() setter and $vpr/$vpt/$vpd lookups, mirroring the existing $preview/$t VarRef-fallback pattern, with defaults matching OpenSCAD's own ($vpr=[55,0,25], $vpt=[0,0,0], $vpd=140) so headless/test evaluation returns real numbers instead of undef.
  • MeshBuilder::requestBuild() now takes a ViewportState snapshot, threaded through a pre-populated Interpreter into CsgEvaluator's existing evaluate(result, interp) overload — the same wiring pattern already used for fileTable.
  • Application::currentViewport() derives that snapshot from the render camera's pitch/yaw/target/distance at each requestBuild() call site (7 sites updated).

Test plan

  • Built a standalone copy of the project's full non-GPU test suite (the same source set as the chiselcad_tests CMake target — Lexer/Parser/Interpreter/SourceLoader/CsgEvaluator/importers) using apt-installed glm/spdlog/Catch2 in place of vcpkg (no Vulkan SDK needed for this target). 2877 assertions across 533 test cases pass, including new tests for the $vpr/$vpt/$vpd defaults, setViewport(), and user-assignment shadowing.
  • Syntax-checked MeshBuilder.cpp against stubbed manifold/VMA headers — caught and fixed a real GCC quirk (a nested aggregate used as a default argument of its own enclosing class's member function).
  • Application.cpp's diff (7 mechanical call-site argument additions plus one small accessor) could not be compiled in this sandbox — the full GLFW/ImGui/Vulkan stack isn't available here — so it was reviewed by hand against Camera's verified public API instead of compiled. CI's full Windows/Linux builds will cover it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MEXUhKnGAnmaLJ4R8PEg7r


Generated by Claude Code

Picks up the first of the two items deferred at the end of the v3.5 pass.
Interpreter gains a setViewport() setter (mirroring the $preview/$t
VarRef-fallback pattern) with OpenSCAD-matching defaults so headless
evaluation still returns sane numbers instead of undef. MeshBuilder's
requestBuild() now takes a ViewportState snapshot, threaded through a
pre-populated Interpreter into CsgEvaluator's full evaluate() overload
(the same pattern already used for fileTable). Application derives that
snapshot from the render camera's pitch/yaw/target/distance at each
requestBuild() call site.

Verified via a standalone build of the full non-GPU test suite (glm/
spdlog/Catch2 from apt, no vcpkg/Vulkan SDK needed for that target) —
2877 assertions across 533 test cases pass, including new coverage for
the defaults, setViewport(), and user-assignment shadowing. MeshBuilder.cpp
was independently syntax-checked against a stubbed manifold/VMA — this
caught a real GCC quirk (a nested aggregate used as a default argument of
its own enclosing class hits "default member initializer required before
the end of its enclosing class"), fixed by keeping ViewportState at
namespace scope. Application.cpp's own diff is mechanical (7 call-site
argument additions plus one small accessor) and could not be compiled in
this sandbox (full GLFW/ImGui/Vulkan stack unavailable) but was reviewed
by hand against Camera's verified public API.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MEXUhKnGAnmaLJ4R8PEg7r

Copy link
Copy Markdown
Owner Author

Reviewed. The wiring checks out: MeshBuilder::buildOne's manual Interpreter/loadAssignments/loadFunctions/evaluate(ast, interp) sequence is an exact match for what CsgEvaluator::evaluate(ast)'s convenience overload already does internally, so setViewport() is the only added behavior — no regression risk there. All 7 requestBuild() call sites in Application.cpp are updated, Camera::pitch()/yaw()/target()/distance() exist with the signatures currentViewport() assumes, and the $vpr/$vpt/$vpd VarRef fallback correctly matches the existing $preview/$t pattern (env lookup first, so user assignments still shadow). No issues found.


Generated by Claude Code

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