fix(safety,openxr,dvr,config): harden RC/firmware failsafes, OpenXR lifecycle, DVR StreamCopy, relay & persistent config

This commit is contained in:
bleack committed 2026-11-25 22:42:25 +01:00
1 parent 8028680f07
commit d82a65d9e6
24 files changed
+2246 -638

No files matched your search

+31 -11
View File
@@ -41,30 +41,50 @@ pub struct DomeWarpLut {
impl DomeWarpLut {
pub fn new(width: u32, height: u32, fov_deg: f32, k1: f32, k2: f32) -> Self {
let enabled = k1.abs() > 1e-4 || k2.abs() > 1e-4;
let total_pixels = (width * height) as usize;
let enabled = width > 0 && height > 0 && (k1.abs() > 1e-4 || k2.abs() > 1e-4);
if !enabled {
return Self {
width,
height,
fov_deg,
k1,
k2,
src_pixel_offsets: Vec::new(),
enabled: false,
};
}
let total_pixels = (width as usize).saturating_mul(height as usize);
let mut src_pixel_offsets = Vec::with_capacity(total_pixels);
let aspect = width as f32 / height as f32;
let half_fov_rad = (fov_deg.to_radians() * 0.5).max(0.1);
let max_tan = (half_fov_rad * 0.65).tan().max(0.1);
// Normalisation douce liée au FOV : à 140° le facteur de référence vaut 1.0
// (évite le recadrage/étirement des bords lorsque fov_deg < 140°).
let fov_scale = (fov_deg.clamp(60.0, 180.0) / 140.0).clamp(0.75, 1.15);
for y in 0..height {
let ny = ((y as f32 + 0.5) / height as f32) * 2.0 - 1.0;
for x in 0..width {
let nx = ((x as f32 + 0.5) / width as f32) * 2.0 - 1.0;
let rx = nx * aspect;
let ry = ny;
let r2 = rx * rx + ry * ry;
// Rayon normalisé dans [0..1] aux bords pour éviter tout repliement polynomial
// même avec k1 = -0.50 dans les coins 16:9.
let rx = nx * (aspect / aspect.max(1.0));
let ry = ny / aspect.max(1.0);
let r2 = (rx * rx + ry * ry).min(1.5);
let r4 = r2 * r2;
let factor = (1.0 + k1 * r2 + k2 * r4) / max_tan.min(1.15);
let poly = (1.0 + k1 * r2 + k2 * r4).clamp(0.25, 2.5);
let factor = poly / fov_scale;
let src_nx = (nx * factor + 1.0) * 0.5;
let src_ny = (ny * factor + 1.0) * 0.5;
let sx = (src_nx * (width as f32 - 1.0)).round().clamp(0.0, (width - 1) as f32) as u32;
let sy = (src_ny * (height as f32 - 1.0)).round().clamp(0.0, (height - 1) as f32) as u32;
let sx = (src_nx * (width as f32 - 1.0))
.round()
.clamp(0.0, (width - 1) as f32) as u32;
let sy = (src_ny * (height as f32 - 1.0))
.round()
.clamp(0.0, (height - 1) as f32) as u32;
let pixel_offset = sy * width + sx;
src_pixel_offsets.push(pixel_offset);
@@ -78,7 +98,7 @@ impl DomeWarpLut {
k1,
k2,
src_pixel_offsets,
enabled,
enabled: true,
}
}