pub struct PreparedProjector3D { /* private fields */ }Expand description
Validated world-to-clip transform and cached clip-to-world inverse.
Perspective and orthographic finite-far matrices are supported, including
reversed depth and either handedness. Preparation checks all eight NDC box
corners for positive inverse W and representable world coordinates. Because
inverse W is affine, positive corner values exclude infinity throughout the
closed box in the cached transform. This cannot certify original camera
intent after matrix rounding: callers must declare FarPlane truthfully.
The inverse has f32 coefficients and the same conditioning/underflow limits
as Mat4::checked_inverse. Degenerate rays after endpoint rounding remain
query errors. No implicit matrix normalization changes the W-sign policy.
See the complete module recipe for construction, queries and failed updates.
Implementations§
Source§impl PreparedProjector3D
impl PreparedProjector3D
Sourcepub fn try_new(
view_projection: Mat4,
viewport: Viewport,
y_axis: ScreenYAxis,
depth: NdcDepth,
far_plane: FarPlane,
) -> Result<PreparedProjector3D, ProjectionError>
pub fn try_new( view_projection: Mat4, viewport: Viewport, y_axis: ScreenYAxis, depth: NdcDepth, far_plane: FarPlane, ) -> Result<PreparedProjector3D, ProjectionError>
Prepares a finite-far camera. See the module recipe.
Validation order: viewport, explicit far intent, checked inverse, then clip-volume corners. No inverse is recomputed during point/ray queries.
Sourcepub fn try_update(
&mut self,
view_projection: Mat4,
viewport: Viewport,
y_axis: ScreenYAxis,
depth: NdcDepth,
far_plane: FarPlane,
) -> Result<(), ProjectionError>
pub fn try_update( &mut self, view_projection: Mat4, viewport: Viewport, y_axis: ScreenYAxis, depth: NdcDepth, far_plane: FarPlane, ) -> Result<(), ProjectionError>
Replaces all prepared state only after successful validation. Any error retains the prior camera, inverse and viewport; see the module recipe.
Sourcepub fn project(&self, world: Vec3) -> Result<ProjectedPoint, ProjectionError>
pub fn project(&self, world: Vec3) -> Result<ProjectedPoint, ProjectionError>
Projects a world point without clipping XY/depth. Returns separate
membership flags; rejects nonfinite points, zero/negative W, and range
failures. Tiny positive W is allowed with no arbitrary epsilon.
Finite negative-W points return BehindCamera before perspective division;
nonfinite inputs and zero W retain their checked matrix diagnostics.
See the module HUD recipe.
Sourcepub fn unproject(
&self,
screen: Vec2,
ndc_depth: f32,
) -> Result<Vec3, ProjectionError>
pub fn unproject( &self, screen: Vec2, ndc_depth: f32, ) -> Result<Vec3, ProjectionError>
Unprojects an inclusive viewport position and inclusive NDC depth through the cached inverse. Rejects nonfinite inputs, then outside XY, then outside depth. No extrapolation/clamping or window-depth conversion is performed. See the module round-trip recipe.
Sourcepub fn pick_ray(&self, screen: Vec2) -> Result<PickingRay3D, ProjectionError>
pub fn pick_ray(&self, screen: Vec2) -> Result<PickingRay3D, ProjectionError>
Near-plane-origin ray toward the physical finite far endpoint. Orthographic rays are parallel with distinct origins; perspective rays diverge from near-plane origins. Never guesses an eye or substitutes a finite far value. Endpoint subtraction/normalization uses f64 so extreme finite endpoints need not have a representable f32 difference. See the module picking recipe.
Trait Implementations§
Source§impl Clone for PreparedProjector3D
impl Clone for PreparedProjector3D
Source§fn clone(&self) -> PreparedProjector3D
fn clone(&self) -> PreparedProjector3D
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more