#[derive(Debug, Clone, Copy)]
pub struct OpticastSettings {
pub xres: u32,
pub yres: u32,
pub y_start: u32,
pub y_end: u32,
pub x_start: u32,
pub x_end: u32,
pub hx: f32,
pub hy: f32,
pub hz: f32,
pub anginc: f32,
pub mip_levels: u32,
pub mip_scan_dist: i32,
pub max_scan_dist: i32,
}
impl OpticastSettings {
#[allow(clippy::cast_precision_loss)]
#[must_use]
pub fn for_oracle_framebuffer(width: u32, height: u32) -> Self {
let half_w = (width as f32) * 0.5;
let half_h = (height as f32) * 0.5;
Self {
xres: width,
yres: height,
y_start: 0,
y_end: height,
x_start: 0,
x_end: width,
hx: half_w,
hy: half_h,
hz: half_w,
anginc: 1.0,
mip_levels: 1,
mip_scan_dist: 4,
max_scan_dist: 1024,
}
}
#[must_use]
pub fn with_fov_y(mut self, fov_y_rad: f32) -> Self {
#[allow(clippy::cast_precision_loss)]
let half_h = (self.yres as f32) * 0.5;
self.hz = half_h / (fov_y_rad * 0.5).tan();
self
}
#[must_use]
pub fn with_y_range(mut self, y_start: u32, y_end: u32) -> Self {
self.y_start = y_start;
self.y_end = y_end;
self
}
#[must_use]
pub fn with_x_range(mut self, x_start: u32, x_end: u32) -> Self {
self.x_start = x_start;
self.x_end = x_end;
self
}
}