Skip to content

Viewport Selection: Vertex and Face Picking #60

Description

@juanchuletas

Labels: interaction raycasting
Estimate: 1 week

Context

Editing is useless without selection. This issue adds raycasting from the camera through the mouse cursor to identify the closest vertex or face in the active primitive.

Tasks

  • Implement Ray { origin, direction } and Camera::generateRay(mouseX, mouseY, vpW, vpH) using inverse VP matrix
  • Implement Primitive::raycastVertex(ray, threshold) - returns index of closest vertex within screen-space threshold
  • Implement Primitive::raycastFace(ray) - Moller-Trumbore intersection, returns hit face index
  • Add SelectionManager class: current mode (VERTEX / FACE), active primitive pointer, handleClick(ray) dispatcher
  • Support additive selection (Shift+click) vs replace (plain click)
  • Draw selected vertices as GL_POINTS overlay with highlight color
  • Draw selected faces with a highlight color pass after main draw

Acceptance Criteria

  • Clicking a vertex selects it, confirmed by visual highlight
  • Clicking a face in face mode selects it
  • Shift+click adds to selection without clearing existing
  • Clicking empty space clears selection
  • Selection works correctly after camera movement

Files

src/Modeling/SelectionManager.hpp  (new)
src/Modeling/SelectionManager.cpp  (new)
src/Camera/camera.hpp / .cpp
src/Geometries/primitives.hpp / .cpp
src/Shaders/selection.vert / .frag  (new)

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions