Skip to content

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

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

feat: Lua REPL for interactive scripting in mesh viewers#5
mtao wants to merge 4 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 4 commits March 27, 2026 22:03
…te discovery

Replace MeshData's internal data buffers with a shared_ptr<quiver::MeshBase>.
All attributes from the mesh are now enumerable via DiscoveredAttribute and
assignable to visualization roles (positions, normals, scalar field) through
RoleBinding with automatic double-to-float conversion via CachedAttribute.

- MeshData holds shared_ptr<MeshBase>, discovers all attributes on set_mesh()
- RoleBinding provides raw_data() + component_count for GPU upload
- OBJ and MSH loading goes through quiver::io::read_mesh() pipeline
- VulkanMeshDrawable syncs from role bindings instead of raw arrays
- MeshBuffers supports variable component counts (1D/2D/3D positions)
- MeshPipelineManager generates correct VkFormat for component count
- ImGui mesh_controls_panel shows attribute selector combos per role
- Qt mesh_controls_widget has full attribute binding UI with filtering
- BVHData creates quiver::Mesh<1> edge meshes from role bindings
- All tests rewritten with quiver::Mesh<2> objects (65/65 passing)
Add VulkanTexture (RAII GPU texture with full/partial upload),
ImageData (CPU pixel buffer scene graph feature with dirty tracking),
ImagePipelineManager (descriptor sets, UBOs, fullscreen triangle pipeline),
VulkanImageDrawable (per-frame sync from ImageData to GPU texture),
ImageScene (orthographic 2D viewer with pan/zoom/fit-to-window),
image shaders (fullscreen triangle + HDR tone mapping fragment shader),
ImGui image controls panel (exposure/gamma/channel/zoom/pan),
PPM I/O (P6 binary reader/writer, RGB->RGBA expansion),
image_viewer_glfw standalone tool (CLI11, scroll-zoom, middle-drag pan),
and unit tests for ImageData and PPM I/O (15 new test cases).

This lays the foundation for ART ray tracer live preview and
the MultiscreenManga comic reader port.
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).
@mtao mtao force-pushed the feature/image-infrastructure branch from 42bb6eb to 70ab58d Compare April 13, 2026 22:31
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