Struct PreparedProjector3D

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> PreparedProjector3D

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PreparedProjector3D

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PreparedProjector3D

Source§

fn eq(&self, other: &PreparedProjector3D) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for PreparedProjector3D

Source§

impl StructuralPartialEq for PreparedProjector3D

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.