use bytemuck::{Pod, Zeroable};
#[repr(C)]
#[derive(Debug, Clone, Copy, Zeroable, Pod)]
pub(crate) struct VolumeUniforms {
pub mvp: [[f32; 4]; 4],
pub inv_mvp: [[f32; 4]; 4],
pub world_to_volume: [[f32; 4]; 4],
pub volume_to_world: [[f32; 4]; 4],
pub dimensions: [f32; 4],
pub spacing: [f32; 4],
pub scalar_range: [f32; 4],
pub step_size: f32,
pub opacity_correction: f32,
pub blend_mode: u32,
pub shading_enabled: u32,
pub ambient: f32,
pub diffuse: f32,
pub specular: f32,
pub specular_power: f32,
pub light_position: [f32; 4],
pub camera_position: [f32; 4],
pub window_center: f32,
pub window_width: f32,
pub num_clip_planes: u32,
pub _pad0: u32,
pub clip_planes: [[f32; 4]; 6],
pub background: [f32; 4],
}
pub mod blend_mode {
pub const COMPOSITE: u32 = 0;
pub const MAXIMUM_INTENSITY: u32 = 1;
pub const MINIMUM_INTENSITY: u32 = 2;
pub const AVERAGE_INTENSITY: u32 = 3;
pub const ADDITIVE: u32 = 4;
pub const ISOSURFACE: u32 = 5;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn uniforms_are_pod() {
let u = VolumeUniforms::zeroed();
let _bytes: &[u8] = bytemuck::bytes_of(&u);
}
#[test]
fn uniforms_size_is_multiple_of_16() {
assert_eq!(std::mem::size_of::<VolumeUniforms>() % 16, 0);
}
}