Skip to main content

Module picking

Module picking 

Source
Expand description

Click-to-select in the viewport.

Casts the cursor ray against every entity’s world-space bounding box and returns the nearest hit. Bounding boxes, not triangles: an editor pick has to feel instant and forgiving, and a box is both — clicking slightly off a thin object still selects it, which is what people expect from a viewport.

Everything here runs on click, never per frame, so computing a mesh’s bounds from its vertex positions on the spot is cheap enough not to need a cache. If picking ever moves to hover-highlighting, that changes and the bounds want caching against the mesh handle.

Constants§

GIZMO_PICK_HALF_EXTENT 🔒
Half-extent of the clickable box given to entities that have no mesh.

Functions§

entity_matrix 🔒
World matrix for entity, preferring the propagated GlobalTransform so a child is picked where it is actually drawn rather than where its local transform alone would put it.
local_bounds 🔒
Local-space bounds for entity: the mesh’s own extent when it has one, a small box otherwise.
pick_entity
The nearest entity whose bounds the ray enters, if any.