2024-01-30 06:37:05 +00:00
|
|
|
use bytemuck::{Pod,Zeroable};
|
|
|
|
use strafesnet_common::model::{IndexedVertex,PolygonGroup,RenderConfigId};
|
|
|
|
#[derive(Clone,Copy,Pod,Zeroable)]
|
2023-09-27 09:12:20 +00:00
|
|
|
#[repr(C)]
|
2024-01-30 06:37:05 +00:00
|
|
|
pub struct GraphicsVertex{
|
|
|
|
pub pos:[f32;3],
|
|
|
|
pub tex:[f32;2],
|
|
|
|
pub normal:[f32;3],
|
|
|
|
pub color:[f32;4],
|
|
|
|
}
|
|
|
|
#[derive(Clone,Copy,id::Id)]
|
|
|
|
pub struct IndexedGraphicsMeshOwnedRenderConfigId(u32);
|
|
|
|
pub struct IndexedGraphicsMeshOwnedRenderConfig{
|
|
|
|
pub unique_pos:Vec<[f32;3]>,
|
|
|
|
pub unique_tex:Vec<[f32;2]>,
|
|
|
|
pub unique_normal:Vec<[f32;3]>,
|
|
|
|
pub unique_color:Vec<[f32;4]>,
|
2023-09-27 09:12:20 +00:00
|
|
|
pub unique_vertices:Vec<IndexedVertex>,
|
2024-01-30 06:37:05 +00:00
|
|
|
pub render_config:RenderConfigId,
|
|
|
|
pub polys:PolygonGroup,
|
|
|
|
pub instances:Vec<GraphicsModelOwned>,
|
2023-09-27 09:12:20 +00:00
|
|
|
}
|
2024-01-30 06:37:05 +00:00
|
|
|
pub enum Indices{
|
|
|
|
U32(Vec<u32>),
|
|
|
|
U16(Vec<u16>),
|
2023-10-30 23:31:17 +00:00
|
|
|
}
|
2024-01-30 06:37:05 +00:00
|
|
|
pub struct GraphicsMeshOwnedRenderConfig{
|
2023-10-30 23:31:17 +00:00
|
|
|
pub vertices:Vec<GraphicsVertex>,
|
2024-01-30 06:37:05 +00:00
|
|
|
pub indices:Indices,
|
|
|
|
pub render_config:RenderConfigId,
|
|
|
|
pub instances:Vec<GraphicsModelOwned>,
|
2023-09-27 09:12:20 +00:00
|
|
|
}
|
2024-01-30 06:37:05 +00:00
|
|
|
#[derive(Clone,Copy,PartialEq,id::Id)]
|
2023-10-26 02:51:24 +00:00
|
|
|
pub struct GraphicsModelColor4(glam::Vec4);
|
|
|
|
impl std::hash::Hash for GraphicsModelColor4{
|
2024-01-30 06:37:05 +00:00
|
|
|
fn hash<H:std::hash::Hasher>(&self,state:&mut H) {
|
2023-10-06 22:46:02 +00:00
|
|
|
for &f in self.0.as_ref(){
|
|
|
|
bytemuck::cast::<f32,u32>(f).hash(state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-10-26 02:51:24 +00:00
|
|
|
impl Eq for GraphicsModelColor4{}
|
2023-09-27 09:12:20 +00:00
|
|
|
#[derive(Clone)]
|
2024-01-30 06:37:05 +00:00
|
|
|
pub struct GraphicsModelOwned{
|
2023-09-27 09:12:20 +00:00
|
|
|
pub transform:glam::Mat4,
|
|
|
|
pub normal_transform:glam::Mat3,
|
2023-10-26 02:51:24 +00:00
|
|
|
pub color:GraphicsModelColor4,
|
|
|
|
}
|