Docs/Modules/Editor

Components

ClassFileRole
EditorCamerainclude/MeshCraft/Editor/EditorCamera.hppOrbit / pan / zoom / focus camera model. Produces view + projection matrices.
SelectionManagerinclude/MeshCraft/Editor/SelectionManager.hppTracks the set of selected shared_ptr<Mc3Object>. Supports single and multi-select.
TransformGizmoinclude/MeshCraft/Editor/TransformGizmo.hppHolds the active gizmo mode (Move/Scale/Rotate) and per-axis drag state.
EditorToolinclude/MeshCraft/Editor/EditorTool.hppTool state helpers (currently minimal).
EditorViewportinclude/MeshCraft/Editor/EditorViewport.hppViewport rect calculation helpers.

EditorCamera

Uses a spherical orbit model: yaw (horizontal), pitch (vertical, clamped to ±85°), and distance from a target point.

Key Methods

MethodDescription
orbit(deltaYaw, deltaPitch)Rotate around the target. Called on middle-mouse drag.
pan(deltaX, deltaY)Translate the target point in camera space. Called on right-mouse drag.
zoom(delta)Change the distance to target. Clamped to [0.5, 2000]. Called on scroll wheel.
focusOn(x, y, z, radius)Move the target to a world position and adjust distance to fit. Called on F key.
reset()Reset to default yaw=0, pitch=0.4, distance=15.
viewMatrix()Returns the view matrix from the orbit model.
projectionMatrix(aspectRatio)Returns a perspective projection (60° FOV, near=0.1, far=2000).
screenRayDirection(ndcX, ndcY, aspect)Unprojects a screen NDC coordinate to a world-space ray direction. Used for AABB picking.

Object Picking

Ray-cast picking is implemented in MeshCraftApplication::handleMouseInput():

  1. On left-click in the 3D viewport, compute an NDC coordinate from the mouse position.
  2. Call EditorCamera::screenRayDirection(ndcX, ndcY, aspectRatio) to get a world-space ray.
  3. Recursively test each object's axis-aligned bounding box (AABB) — including nested children in groups, CSG nodes, and instances.
  4. Select the closest hit object. Ctrl+click toggles it in the selection set.

Selection

SelectionManager holds a std::set<std::shared_ptr<Mc3Object>>.

Transform Gizmo

Three modes, activated by keyboard shortcuts:

ModeKeyVisualDrag effect
MoveGColored axis arrows with cube tipsTranslates position along the dragged axis
ScaleSColored axis lines with flat-square tipsScales the object along the dragged axis
RotateRColored arcs in the three planesRotates the object around the dragged axis

For multi-selection, the gizmo applies the delta to all selected objects simultaneously.

Arrow key nudge (0.1 step with Shift, 1.0 without) applies to the active tool. PageUp/PageDown nudge along the Z axis.