use eframe::egui;
use sophus_autodiff::linalg::VecF64;
use sophus_image::ArcImage4U8;
use crate::{
offscreen_renderer::OffscreenRenderer,
renderables::Color,
textures::DepthImage,
};
pub struct RenderResult {
pub rgba_image: Option<ArcImage4U8>,
pub rgba_egui_tex_id: egui::TextureId,
pub depth_image: DepthImage,
pub depth_egui_tex_id: egui::TextureId,
}
pub trait HasAspectRatio {
fn aspect_ratio(&self) -> f32;
}
impl HasAspectRatio for OffscreenRenderer {
fn aspect_ratio(&self) -> f32 {
self.camera_properties
.intrinsics
.image_size()
.aspect_ratio()
}
}
#[repr(C)]
#[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
pub(crate) struct Zoom2dPod {
pub(crate) translation_x: f32,
pub(crate) translation_y: f32,
pub(crate) scaling_x: f32,
pub(crate) scaling_y: f32,
}
impl Default for Zoom2dPod {
fn default() -> Self {
Zoom2dPod {
translation_x: 0.0,
translation_y: 0.0,
scaling_x: 1.0,
scaling_y: 1.0,
}
}
}
#[derive(Clone, Copy, Debug)]
pub struct TranslationAndScaling {
pub translation: VecF64<2>,
pub scaling: VecF64<2>,
}
impl TranslationAndScaling {
pub fn identity() -> Self {
TranslationAndScaling {
translation: VecF64::<2>::zeros(),
scaling: VecF64::<2>::new(1.0, 1.0),
}
}
pub fn apply(&self, xy: VecF64<2>) -> VecF64<2> {
VecF64::<2>::new(
xy[0] * self.scaling[0] + self.translation[0],
xy[1] * self.scaling[1] + self.translation[1],
)
}
}
pub struct SceneFocusMarker {
pub color: Color,
pub u: f32,
pub v: f32,
pub ndc_z: f32,
}
pub const DOG_MULTISAMPLE_COUNT: u32 = 4;