Skip to content

Multi-Select with Ctrl + Mouse ClickΒ #155

Description

@Sebanisu

πŸ“‹ Summary

Currently, clicking on a tile selects all tile indexes under the mouse at that position (x, y). A single mouse_down is recorded, and tiles are transformed via ImGuizmo by tracking the difference between mouse_down and mouse_pos.

We want to extend this to support multi-selection using Ctrl + Mouse Click, allowing users to select and manipulate multiple tiles at once.

Related to: #113


Current Behavior

  • Mouse click at (x, y) loads all tile indexes at that location into a selection vector.
  • A single mouse_down is stored.
  • ImGuizmo is anchored at mouse_down.
  • Moving the mouse updates mouse_pos, which is used to compute the delta transform for selected tiles.
  • The tiles are live-updated by the delta between mouse_down and mouse_pos.
  • After each move, mouse_down is updated to the current mouse_pos.

Proposed Behavior

  • Ctrl + Mouse Click:
    • Appends the tile indexes at the clicked position to the selection vector.
    • Deduplicates and sorts the list to avoid overlapping transformations.
    • Tracks a list of mouse_down points corresponding to each Ctrl-clicked tile cluster.
    • Computes the centroid of all mouse_down points.
  • On Transform (via ImGuizmo):
    • Anchor the gizmo at the centroid.
    • On drag, compute delta between mouse_pos and the previous centroid.
    • Move all selected tiles by this delta.
    • Update centroid.
    • Shift all stored mouse_down points by the same delta.
      • This keeps them aligned with the tiles in case of additional Ctrl + clicks (i.e. adding to selection after moving).

πŸ”§ Implementation Notes

  • Add a multi_selection mode enabled by checking Ctrl key state during mouse click.
  • Use a std::vector<glm::uvec2> (or equivalent) to store multiple mouse_down points.
  • Selection vector stores tile indexes, sorted and deduplicated.
  • Add helper functions to:
    • Compute centroid of a list of points.
    • Apply transformation delta to all selected tiles.
    • Shift stored mouse_down points by delta after each move.
  • UI feedback: ImGuizmo appears at the centroid of selected tiles when multiple are selected.

Testing Considerations

  • Select multiple tiles by Ctrl + clicking at various positions.
  • Ensure ImGuizmo appears at the centroid and moves all selected tiles consistently.
  • Check that dragging continues to update the centroid and tile positions correctly.
  • Verify that stored mouse_down points are updated so that adding to the selection still works as expected after moving tiles.

Future Improvements

  • Support deselection via Ctrl + click on already-selected tiles.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions