feat: attempt to implement math library

Adds many files, but the next thing is to implement the MeshRegistry properly.
This commit is contained in:
alphafetus committed 2026-05-08 08:02:38 -04:00
1 parent 9e4f531bd4
commit e7659ba387
18 files changed
+1232 -136

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
use vulkano::buffer::BufferContents;
use vulkano::pipeline::graphics::vertex_input::Vertex;
use crate::common::instance::MeshInstance;
/// A transformation matrix for a mesh that can be passed into the shaders.
#[derive(BufferContents, Vertex)]
#[repr(C)]
pub struct GpuInstance {
#[format(R32G32B32A32_SFLOAT)]
pub transform_col1: [f32; 4],
#[format(R32G32B32A32_SFLOAT)]
pub transform_col2: [f32; 4],
#[format(R32G32B32A32_SFLOAT)]
pub transform_col3: [f32; 4],
#[format(R32G32B32A32_SFLOAT)]
pub transform_col4: [f32; 4],
}
impl Into<GpuInstance> for MeshInstance {
fn into(self) -> GpuInstance {
let m = self.transform_matrix();
GpuInstance {
transform_col1: m.column(0).into(),
transform_col2: m.column(1).into(),
transform_col3: m.column(2).into(),
transform_col4: m.column(3).into(),
}
}
}
+2
View File
@@ -0,0 +1,2 @@
pub mod vertex3;
pub mod instance;
+15
View File
@@ -0,0 +1,15 @@
use vulkano::buffer::BufferContents;
use vulkano::pipeline::graphics::vertex_input::Vertex;
#[derive(Debug, BufferContents, Vertex)]
#[repr(C)]
pub struct Vertex3 {
#[format(R32G32B32_SFLOAT)]
pub(crate) position: [f32; 3],
}
impl From<&[f32; 3]> for Vertex3 {
fn from(v: &[f32; 3]) -> Self {
Self { position: v.clone() }
}
}