Expand description
Ray-based hit testing (“picking”) against a Model, for interactive
selection in a viewer: cast a ray from the camera through the cursor,
ask for the nearest vertex/edge/face/solid it hits, and get back its
id — which a caller turns into the entity’s stable name to put into a
program step.
Built entirely on a RasterizedModel the caller passes in — the same
sampled points/polylines/triangles its viewer draws — rather than
re-deriving triangulation or curve sampling here, so a pick can never
disagree with what the viewer actually shows. Sketches likewise, through
SketchTargets. Rasterizing once per build and picking against that
also makes a pick cheap enough to run on every pointer move, to show
what a click would pick.
Generic over the model’s own Scalar, using the crate’s existing
Vector3 linear algebra (add/sub/prod_dot/prod_cross/norm)
throughout rather than a second, ad hoc vector-math implementation.
tolerance (how close a click has to land to count, for
PickFilter::Vertex/PickFilter::Edge) is the one deliberate
exception, staying a plain f64: it is a UI fuzziness knob derived from
screen pixels, not a geometric quantity the kernel reasons about, so it
is compared against Scalar::to_f64 rather than folded into interval
arithmetic.
Structs§
- PickHit
- Ray
- A pickable ray, in world space.
dirneed not be unit length;tinPickHitis in units ofdir, i.e. the hit point isorigin + dir * t. - Sketch
Hit - A sketch a ray hit, where it hit its plane.
- Sketch
Target - One sketch as something to click on and to draw: its plane, the outlines of its closed regions, and every curve as a polyline — all in sketch coordinates.
- Sketch
Targets - Every sketch of a part, outlined once — finding a sketch’s regions is
the expensive part of picking it — for picking with
pick_sketchand for drawing.
Enums§
- Pick
Filter - What a pick query is looking for.
- Pick
Kind - Which kind of entity a pick found (or was asked to look for).
Functions§
- pick
- Cast
rayagainstmodel, asrasterizedsamples it, and return the nearest entity matchingfilterwithintolerance(world-space distance; only meaningful forPickFilter::Vertex/PickFilter::Edge— face/solid hits are exact ray/triangle intersections and ignore it). - pick_
sketch - The sketch nearest along
raythat it hits (see [hit_sketch]), withtolerancethe world-space distance within which a click counts as on a curve. - solid_
of_ face - The solid that owns
face_id, if it can be found (a face is always part of exactly one shell, and a shell of exactly one solid).