Skip to main content

pixel_ray

Function pixel_ray 

Source
pub fn pixel_ray(
    cs: &CameraState,
    settings: &OpticastSettings,
    px: u32,
    py: u32,
) -> ([f32; 3], [f32; 3])
Expand description

World-space ray for screen pixel (px, py) under opticast’s pinhole: origin is the camera position, direction is (px - hx)·right + (py - hy)·down + hz·forward.

This is the exact ray camera_math::derive bakes into its corner vectors (corn[0] is pixel (0, 0)’s direction), so the DDA renderer samples the same rays the voxlap path’s frustum is built from. The direction is not normalised — callers that need a unit ray (and a true Euclidean distance) normalise themselves; DDA.1 will track perpendicular distance via the forward-projection instead, matching the engine’s z-buffer convention.