Skip to main content

Module spatial

Module spatial 

Source
Expand description

GPU-independent rays, axis-aligned bounds and conservative frustum queries.

Constructors validate finite data. Queries use metres with a right-handed +Y-up world; frusta use the renderer’s DirectX/wgpu depth range of 0..1.

use kvas_engine::spatial::{Aabb, Ray};
use glam::Vec3;
let bounds = Aabb::new(-Vec3::ONE, Vec3::ONE).unwrap();
let ray = Ray::new(Vec3::new(0.0, 0.0, 5.0), Vec3::NEG_Z).unwrap();
assert_eq!(bounds.ray_distance(ray, 10.0), Some(4.0));
assert!(bounds.contains(Vec3::ZERO));

Structs§

Aabb
Finite axis-aligned closed box. Degenerate extents (planes/points) are allowed.
Frustum
Six inward-facing clip planes for a finite 0..1-depth view/projection matrix.
Ray
Finite world/local ray with a unit direction.