Skip to content

feat: Lua REPL for interactive scripting in mesh viewers#5

Open
mtao wants to merge 2 commits intofeature/image-infrastructurefrom
feature/lua-repl
Open

feat: Lua REPL for interactive scripting in mesh viewers#5
mtao wants to merge 2 commits intofeature/image-infrastructurefrom
feature/lua-repl

Conversation

@mtao
Copy link
Copy Markdown
Owner

@mtao mtao commented Mar 28, 2026

Summary

  • Adds a 3-layer Lua REPL system: core engine (LuaRepl with sol2), geometry bindings (BoundingBox3, read_obj, bounding_box), and visualization frontends (ImGui panel + Qt widget)
  • Wires both GLFW and Qt mesh viewers to create a Lua console with post-execute callbacks that refresh MeshData attributes after script modifications
  • Introduces MeshData::rediscover_attributes() for syncing attribute lists when Lua scripts modify mesh data

Architecture

Layer Location Purpose
Engine core/ LuaRepl class: sol::state via pimpl, execute/history/output buffer, print capture
Bindings geometry/ load_bindings(): BoundingBox3 usertype, bounding_box(mesh), read_obj(path)
UI (ImGui) visualization/ draw_lua_repl() free function with scrollable output + history navigation
UI (Qt) visualization/ LuaReplWidget with QPlainTextEdit output + QLineEdit input
Scene glue visualization/tools/ Post-execute callback traverses scene graph, calls rediscover_attributes()

Build

Gated behind -Dlua=true meson option (default: false). Depends on sol2 and lua subprojects (redirect wraps to quiver's subprojects).

Testing

All 65 tests pass. No new test suite yet — the REPL is an interactive tool best validated manually by loading a mesh and running Lua commands.

mtao added 2 commits March 28, 2026 02:09
Implements a 3-layer Lua REPL system:

Layer 1 - Core engine (LuaRepl): sol::state via pimpl, execute/history/
output buffer, print() capture, expression-then-statement evaluation,
post-execute callback hook, and lua_state() accessor.

Layer 2 - Geometry bindings: load_bindings(sol::state_view) registering
BoundingBox3 usertype, bounding_box(mesh), and read_obj(path) that
constructs quiver::Mesh<2> with vertex_positions/vertex_normals attributes.

Layer 3 - Visualization frontends + scene glue:
- ImGui panel: draw_lua_repl() free function with scrollable output,
  history navigation (up/down), and input field.
- Qt widget: LuaReplWidget with QPlainTextEdit output + QLineEdit input,
  command_executed signal, and history navigation.
- Scene wiring: both GLFW and Qt viewers create LuaRepl, load quiver +
  geometry bindings, set post-execute callback that calls
  MeshData::rediscover_attributes() on all scene meshes.

Also adds MeshData::rediscover_attributes() for refreshing attribute
lists after Lua scripts modify mesh data.

Build-gated behind -Dlua=true meson option (default: false).
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