Skip to content

Invert CTRL behavior with Settings; Reload notification; Lasso Cut Tool; Global Undo/Redo (CDC)#1638

Closed
Z3roCo0l wants to merge 10 commits intocnr-isti-vclab:develfrom
DynartInteractive:main
Closed

Invert CTRL behavior with Settings; Reload notification; Lasso Cut Tool; Global Undo/Redo (CDC)#1638
Z3roCo0l wants to merge 10 commits intocnr-isti-vclab:develfrom
DynartInteractive:main

Conversation

@Z3roCo0l
Copy link

@Z3roCo0l Z3roCo0l commented Feb 10, 2026

New Features

Inverted CTRL Selection Behavior

The default MeshLab selection workflow requires holding CTRL to add to an existing selection, while a bare drag replaces the selection. This fork inverts that behavior:

  • Drag now adds to the current selection by default
  • CTRL + Drag starts a new selection (clearing the previous one)
  • This is configurable via a global parameter (Invert CTRL Behavior) accessible in MeshLab settings, so you can switch back to the original behavior at any time

This change applies to all rectangle-based selection tools: Select Faces, Select Vertices, Select Connected Components, and Select Faces/Vertices inside polyline area.

Global Parameter System for Edit Plugins

Edit plugins now support persistent global parameters through the MeshLab settings system. This allows edit tools to expose user-configurable options that are saved across sessions. The EditPlugin base class provides initGlobalParameterList and setCurrentGlobalParamSet for any plugin to register its own settings.

Lasso Cut Tool (edit_cut)

A new editing tool that draws a closed polyline to cut through mesh triangles and select the inside region:

  • Click to add polyline points
  • Q — cut edges along the polyline and add inside faces to selection
  • W — subtract inside faces from selection
  • D / A / I — deselect all / select all / invert selection
  • Delete — delete selected faces (uses MeshLab's standard filter with full undo/redo support)
  • C — clear polyline, Backspace — undo last point, Escape — clear polyline

The tool appears in its own Dynart Tools toolbar section, separate from the standard Edit toolbar.

Global Undo/Redo (Ctrl+Z / Ctrl+Y)

MeshLab has no built-in undo system. This adds a full undo/redo stack that works across all filters and edit tools:

  • Ctrl+Z — undo the last mesh-modifying operation
  • Ctrl+Y — redo the last undone operation
  • Available in the Edit menu as Undo/Redo entries
  • Supports up to 50 undo levels
  • Covers all filter operations (delete, remesh, smooth, clean, etc.) and the Lasso Cut tool
  • CDC (Content-Defined Chunking) deduplication — only changed mesh regions are stored, reducing memory usage by ~80-90% compared to full mesh copies

How the CDC Undo System Works

Instead of storing full mesh copies (tri::Append::MeshCopy), the undo system now:

  1. Serializes the mesh into a deterministic byte buffer (vertex coords, face indices, OCF attributes — no pointers)
  2. Chunks the buffer using Gear hash rolling function (content-defined ~4KB boundaries)
  3. Deduplicates chunks in a shared reference-counted ChunkStore (FNV-1a hash identity)
  4. Each undo entry is just a list of chunk hashes (tiny metadata)

Memory savings (1M vertex / 2M face mesh):

Old (full copy) CDC (dedup)
10 undo levels ~920 MB ~93 MB
50 undo levels N/A ~130 MB

The public API (pushUndo, undo, redo, canUndo, canRedo, clear) is unchanged — all changes are internal to mesh_undo_stack.h.

Reload Confirmation Dialogs

Added confirmation prompts before reloading meshes (Reload and Reload All) to prevent accidental loss of unsaved work.

Files Changed

  • src/meshlab/mesh_undo_stack.h — CDC undo stack (serialize → chunk → dedup pipeline)
  • src/meshlab/mainwindow.h — Undo stack member, undo/redo actions and slots
  • src/meshlab/mainwindow_Init.cpp — Ctrl+Z/Y actions, Edit menu entries, Dynart toolbar
  • src/meshlab/mainwindow_RunTime.cpp — Undo/redo implementation, filter execution hook
  • src/meshlab/glarea.h / glarea.cpp — Selection UI changes
  • src/meshlabplugins/edit_cut/ — New lasso cut plugin
  • src/meshlabplugins/edit_select/ — Inverted CTRL behavior
  • src/common/plugins/interfaces/edit_plugin.h — Global parameter support

Z3roCo0l and others added 3 commits February 10, 2026 23:04
Introduce a new edit plugin implementation and update selection/GUI behavior across the app. Added src/common/plugins/interfaces/edit_plugin.cpp and updated its header to expose the edit plugin interface; connected global parameters to the edit-select plugin and modified edit_select sources and factory files. MainWindow Init/RunTime updated to add dialog/security checks for new/reload project, wrap dialog text in tr(), and implement CTRL-modifier selection behavior and modifier pointer/info updates. Also adjusted various edit_* plugin factory headers and updated src/common/CMakeLists.txt to reflect these changes. (Minor fixes for polyline crash and selection-related behavior included.)
Rebrand title and add New Features showcase section covering
inverted CTRL selection behavior, global parameter system for
edit plugins, and reload confirmation dialogs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
New edit plugin that lets users draw a polyline on screen and cut through
mesh triangles along the path. Splits edges at polyline intersections,
re-triangulates affected faces, then selects/deletes faces inside the
polyline boundary.

Features:
- Polyline drawing with mouse clicks
- Edge splitting at polyline-mesh intersections using SplitTab
- Centroid-based face selection for clean boundary cuts
- Two-phase workflow: Q to select (preview), Enter to delete
- Full edit_select-style keybindings (Q/W/D/A/I)
- GPU buffer refresh after mesh modification

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Z3roCo0l Z3roCo0l changed the title New feature Invert CTRL behavior with Settings; Reload notification to prevent loss of unsaved work. Feb 11, 2026
Z3roCo0l and others added 2 commits February 11, 2026 21:32
Remove deleteSelectedFaces from edit_cut and let filter_select's
standard Delete shortcut handle deletion (proper undo/redo support).
Preserve selection across endEdit/Escape so the shortcut works.
Move edit_cut button from Edit toolbar to new Dynart Tools toolbar.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Z3roCo0l Z3roCo0l changed the title Invert CTRL behavior with Settings; Reload notification to prevent loss of unsaved work. Invert CTRL behavior with Settings; Reload notification to prevent loss of unsaved work. New Tool Edit_Cut_Lasso Feb 11, 2026
Z3roCo0l and others added 2 commits February 11, 2026 23:27
Strip cutLog/cutLogQ calls, LOG_PATH, and windows.h/cstdio includes.
Clean production code ready for release.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Full-mesh snapshot undo stack covering all filters and edit_cut.
Uses tri::Append::MeshCopy for deep copies, 10 undo levels max.
Edit menu entries with standard keyboard shortcuts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Z3roCo0l Z3roCo0l changed the title Invert CTRL behavior with Settings; Reload notification to prevent loss of unsaved work. New Tool Edit_Cut_Lasso Invert CTRL behavior with Settings; Reload notification; Lasso Cut Tool; Global Undo/Redo Feb 11, 2026
Z3roCo0l and others added 2 commits February 12, 2026 07:46
The undo system now serializes meshes to byte buffers, chunks them
using content-defined boundaries (Gear hash), and deduplicates chunks
in a shared reference-counted store. This reduces memory usage by
~80-90% for typical local edits. Undo limit increased from 10 to 50.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Z3roCo0l Z3roCo0l changed the title Invert CTRL behavior with Settings; Reload notification; Lasso Cut Tool; Global Undo/Redo Invert CTRL behavior with Settings; Reload notification; Lasso Cut Tool; Global Undo/Redo (CDC) Feb 12, 2026
@alemuntoni
Copy link
Member

Hi, thanks for the PR!

I won't be able to do a proper code review for at least a week, but I have some initial feedback:

  • Target Branch: Since this appears to be a new feature, please change the target branch to devel. As mentioned in the PR template, we keep main strictly for bugfixes to the current version.
  • Selection Tool: Please do not change the default behavior of the selection tool. It is fine to add an option to switch controls, but changing the default workflow would disrupt many existing MeshLab users.
  • Undo/Redo: This feature has never been introduced because it requires a massive refactoring of the entire software architecture (see [Usability] Make it possible to Undo #376). I have to be direct: did you rely on AI tools to generate this code? I need to ensure you fully understand the deep architectural changes required here, as a surface-level implementation will likely break the application state.

Keep standard MeshLab selection workflow as default. The inverted
behavior is still available as an opt-in setting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Z3roCo0l Z3roCo0l changed the base branch from main to devel February 12, 2026 09:20
@Z3roCo0l
Copy link
Author

Z3roCo0l commented Feb 12, 2026 via email

@Z3roCo0l
Copy link
Author

As discussed, I've split this PR into three independent PRs for easier review:

  1. Add global parameter system for edit plugins, optional CTRL invert selection #1639 — Global parameter system for edit plugins + optional CTRL invert selection + reload confirmations
  2. Add Lasso Cut Tool (edit_cut plugin) #1640 — Lasso Cut Tool (edit_cut plugin)
  3. Add global undo/redo system with CDC deduplication (Ctrl+Z / Ctrl+Y) #1641 — Global undo/redo with CDC deduplication (Ctrl+Z / Ctrl+Y)

Each PR targets devel and can be reviewed independently. Closing this one in favor of the split PRs.

@Z3roCo0l Z3roCo0l closed this Feb 12, 2026
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