Skip to main content

Module picking

Module picking 

Source
Expand description

Ray-cast object picking. Renderer-free CPU picking primitives.

These functions pick directly off caller-supplied data (a Scene, a slice of items, or a mesh_lookup), so they need no ViewportRenderer and cost nothing per frame. That makes them the right choice for tests, headless/CPU-only tools, and picking heavy or dynamic data at click time. They cover a subset of item types: surface meshes, light glyphs, point clouds, gaussian splats, ray-marched volumes, and transparent volume-mesh cells.

For the full set of item types (curves, implicit surfaces, marching cubes, overlays) and sub-element masks, use the unified ViewportRenderer::pick / pick_rect. Those read the renderer’s per-frame pick cache, which is off by default and enabled with set_cpu_pick_cache.

Uses parry3d 0.26’s glam-native API (no nalgebra required). All conversions are contained here at the picking boundary.

§Skinned meshes

The CPU picking entry points in this module test against whatever positions are passed in via mesh_lookup. On the GPU skinning path the vertex buffer is never rewritten, so the natural CPU view of a skinned mesh is the bind pose: clicks land on the bind-pose silhouette. See the module-level documentation on crate::PickAccelerator for the two supported strategies (bind-pose with padded AABBs, or per-frame refresh against deformed positions). GPU picking (crate::renderer::picking) reads the rasterised object-ID buffer and therefore picks the deformed silhouette automatically.

Structs§

GpuPickHit
Result of a GPU object-ID pick pass.
PickHit
Result of a successful ray-cast pick against a scene object.
ProbeBinding
Per-object attribute binding for probe-aware picking.
RectPickResult
Result of a rectangular (rubber-band) pick.

Functions§

nearest_vertex_on_hit
Find the triangle corner nearest to the ray-hit world position.
pick_gaussian_splat_cpu
Screen-space nearest-splat pick for a Gaussian splat object.
pick_gaussian_splat_rect
Rect-select splats from a Gaussian splat object.
pick_point_cloud_cpu
Pick the closest point in a crate::renderer::PointCloudItem to a screen-space click.
pick_scene_accelerated_with_probe_cpu
Like pick_scene_accelerated_cpu but also computes the scalar value at the hit point.
pick_scene_cpu
Cast a ray against all visible viewport objects. Returns a PickHit for the nearest hit, or None if nothing was hit.
pick_scene_nodes_cpu
Cast a ray against all visible scene nodes. Returns a PickHit for the nearest hit.
pick_scene_nodes_with_probe_cpu
Like pick_scene_nodes_cpu but also computes the scalar value at the hit point.
pick_scene_with_probe_cpu
Like [pick_scene] but also computes the scalar attribute value at the hit point via barycentric interpolation (vertex attributes) or direct lookup (cell attributes).
pick_transparent_volume_mesh_cpu
Ray-cast pick against a transparent volume mesh.
pick_transparent_volume_mesh_rect
Rect-select cells from a transparent volume mesh.
pick_volume_cpu
Ray-cast a single volume using Amanatides-Woo DDA traversal.
pick_volume_rect
Rect-select above-threshold voxels from a volume object.
screen_to_ray
Convert screen position (in viewport-local pixels) to a world-space ray.
voxel_world_aabb
Compute the world-space axis-aligned bounding box of a single voxel.