use ash::vk;
use crate::util::to_vk::IntoVulkanType;
#[derive(Copy, Clone)]
#[repr(transparent)]
pub struct TransformMatrix(vk::TransformMatrixKHR);
impl TransformMatrix {
pub fn identity() -> Self {
Self(vk::TransformMatrixKHR {
matrix: [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0],
})
}
pub fn from_elements(elements: &[f32; 12]) -> Self {
Self(vk::TransformMatrixKHR {
matrix: *elements,
})
}
pub fn from_rows(rows: &[[f32; 4]; 3]) -> Self {
Self(vk::TransformMatrixKHR {
matrix: [
rows[0][0], rows[0][1], rows[0][2], rows[0][3], rows[1][0], rows[1][1], rows[1][2],
rows[1][3], rows[2][0], rows[2][1], rows[2][2], rows[2][3],
],
})
}
}
impl Default for TransformMatrix {
fn default() -> Self {
Self {
0: vk::TransformMatrixKHR {
matrix: [0.0; 12],
},
}
}
}
impl IntoVulkanType for TransformMatrix {
type Output = vk::TransformMatrixKHR;
fn into_vulkan(self) -> Self::Output {
self.0
}
}