graphics rewrite (one error left)

This commit is contained in:
Quaternions 2024-02-07 19:44:39 -08:00
parent 2049e2dd2c
commit 96085a3076
8 changed files with 493 additions and 529 deletions

3
Cargo.lock generated
View File

@ -1304,9 +1304,10 @@ dependencies = [
[[package]] [[package]]
name = "strafesnet_common" name = "strafesnet_common"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.itzana.me/StrafesNET/common?rev=434ca29aef7e3015c9ca1ed45de8fef42e33fdfb#434ca29aef7e3015c9ca1ed45de8fef42e33fdfb" source = "git+https://git.itzana.me/StrafesNET/common?rev=a1fa2c278174dabbb56db1d814340611dab67575#a1fa2c278174dabbb56db1d814340611dab67575"
dependencies = [ dependencies = [
"glam", "glam",
"id",
] ]
[[package]] [[package]]

View File

@ -13,7 +13,7 @@ glam = "0.25.0"
id = { git = "https://git.itzana.me/Quaternions/id", rev = "1f710976cc786c8853dab73d6e1cee53158deeb0" } id = { git = "https://git.itzana.me/Quaternions/id", rev = "1f710976cc786c8853dab73d6e1cee53158deeb0" }
parking_lot = "0.12.1" parking_lot = "0.12.1"
pollster = "0.3.0" pollster = "0.3.0"
strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "434ca29aef7e3015c9ca1ed45de8fef42e33fdfb" } strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "a1fa2c278174dabbb56db1d814340611dab67575" }
strafesnet_snf = { git = "https://git.itzana.me/StrafesNET/snf", rev = "dea408daeef576cff8ffa61356c89a9d03d95f6b" } strafesnet_snf = { git = "https://git.itzana.me/StrafesNET/snf", rev = "dea408daeef576cff8ffa61356c89a9d03d95f6b" }
wgpu = "0.19.0" wgpu = "0.19.0"
winit = "0.29.2" winit = "0.29.2"

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@ pub enum Instruction{
Render(crate::physics::PhysicsOutputState,integer::Time,glam::IVec2), Render(crate::physics::PhysicsOutputState,integer::Time,glam::IVec2),
//UpdateModel(crate::graphics::GraphicsModelUpdate), //UpdateModel(crate::graphics::GraphicsModelUpdate),
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings), Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
GenerateModels(strafesnet_common::map::Map), GenerateModels(strafesnet_common::map::CompleteMap),
ClearModels, ClearModels,
} }

View File

@ -1,5 +1,5 @@
use bytemuck::{Pod, Zeroable}; use bytemuck::{Pod,Zeroable};
use strafesnet_common::model::{IndexedVertex,PolygonGroup}; use strafesnet_common::model::{IndexedVertex,PolygonGroup,RenderConfigId,TextureId};
#[derive(Clone,Copy,Pod,Zeroable)] #[derive(Clone,Copy,Pod,Zeroable)]
#[repr(C)] #[repr(C)]
pub struct GraphicsVertex{ pub struct GraphicsVertex{
@ -8,43 +8,32 @@ pub struct GraphicsVertex{
pub normal:[f32;3], pub normal:[f32;3],
pub color:[f32;4], pub color:[f32;4],
} }
pub struct IndexedGroupFixedTexture{ #[derive(id::Id)]
pub polys:Vec<PolygonGroup>, pub struct IndexedGraphicsMeshOwnedRenderConfigId(u32);
} pub struct IndexedGraphicsMeshOwnedRenderConfig{
pub struct IndexedGraphicsModelSingleTexture{
pub unique_pos:Vec<[f32;3]>, pub unique_pos:Vec<[f32;3]>,
pub unique_tex:Vec<[f32;2]>, pub unique_tex:Vec<[f32;2]>,
pub unique_normal:Vec<[f32;3]>, pub unique_normal:Vec<[f32;3]>,
pub unique_color:Vec<[f32;4]>, pub unique_color:Vec<[f32;4]>,
pub unique_vertices:Vec<IndexedVertex>, pub unique_vertices:Vec<IndexedVertex>,
pub texture:Option<u32>,//RenderPattern? material/texture/shader/flat color pub render_config:RenderConfigId,
pub groups:Vec<IndexedGroupFixedTexture>, pub polys:PolygonGroup,
pub instances:Vec<GraphicsModelInstance>, pub instances:Vec<GraphicsModelOwned>,
} }
pub enum Entities{ pub enum Indices{
U32(Vec<Vec<u32>>), U32(Vec<u32>),
U16(Vec<Vec<u16>>), U16(Vec<u16>),
} }
pub struct GraphicsModelSingleTexture{ pub struct GraphicsMeshOwnedRenderConfig{
pub instances:Vec<GraphicsModelInstance>,
pub vertices:Vec<GraphicsVertex>, pub vertices:Vec<GraphicsVertex>,
pub entities:Entities, pub indices:Indices,
pub texture:Option<u32>, pub render_config:RenderConfigId,
pub instances:Vec<GraphicsModelOwned>,
} }
#[derive(Clone,PartialEq)] #[derive(Clone,PartialEq,id::Id)]
pub struct GraphicsModelColor4(glam::Vec4); pub struct GraphicsModelColor4(glam::Vec4);
impl GraphicsModelColor4{
pub const fn get(&self)->glam::Vec4{
self.0
}
}
impl From<glam::Vec4> for GraphicsModelColor4{
fn from(value:glam::Vec4)->Self{
Self(value)
}
}
impl std::hash::Hash for GraphicsModelColor4{ impl std::hash::Hash for GraphicsModelColor4{
fn hash<H: std::hash::Hasher>(&self,state:&mut H) { fn hash<H:std::hash::Hasher>(&self,state:&mut H) {
for &f in self.0.as_ref(){ for &f in self.0.as_ref(){
bytemuck::cast::<f32,u32>(f).hash(state); bytemuck::cast::<f32,u32>(f).hash(state);
} }
@ -52,7 +41,7 @@ impl std::hash::Hash for GraphicsModelColor4{
} }
impl Eq for GraphicsModelColor4{} impl Eq for GraphicsModelColor4{}
#[derive(Clone)] #[derive(Clone)]
pub struct GraphicsModelInstance{ pub struct GraphicsModelOwned{
pub transform:glam::Mat4, pub transform:glam::Mat4,
pub normal_transform:glam::Mat3, pub normal_transform:glam::Mat3,
pub color:GraphicsModelColor4, pub color:GraphicsModelColor4,

View File

@ -261,8 +261,8 @@ impl EdgePool{
(&mut unsafe{self.edge_guys.get_unchecked_mut(edge_id)}.1,SubmeshEdgeId::new(edge_id as u32)) (&mut unsafe{self.edge_guys.get_unchecked_mut(edge_id)}.1,SubmeshEdgeId::new(edge_id as u32))
} }
} }
impl From<&model::IndexedModel> for PhysicsMesh{ impl From<&model::Mesh> for PhysicsMesh{
fn from(indexed_model:&model::IndexedModel)->Self{ fn from(indexed_model:&model::Mesh)->Self{
assert!(indexed_model.unique_pos.len()!=0,"Mesh cannot have 0 vertices"); assert!(indexed_model.unique_pos.len()!=0,"Mesh cannot have 0 vertices");
let verts=indexed_model.unique_pos.iter().map(|v|Vert(v.clone())).collect(); let verts=indexed_model.unique_pos.iter().map(|v|Vert(v.clone())).collect();
let mut vert_ref_guys=vec![VertRefGuy::default();indexed_model.unique_pos.len()]; let mut vert_ref_guys=vec![VertRefGuy::default();indexed_model.unique_pos.len()];

View File

@ -925,11 +925,11 @@ impl PhysicsContext{
}); });
} }
pub fn generate_models(&mut self,map:&map::Map){ pub fn generate_models(&mut self,map:&map::CompleteMap){
let mut starts=Vec::new(); let mut starts=Vec::new();
let mut spawns=Vec::new(); let mut spawns=Vec::new();
let mut attr_hash=HashMap::new(); let mut attr_hash=HashMap::new();
for (&model_id,model) in &map.models{ for model in &map.models{
let mesh_id=self.data.models.meshes.len(); let mesh_id=self.data.models.meshes.len();
let mut make_mesh=false; let mut make_mesh=false;
for model_instance in &model.instances{ for model_instance in &model.instances{

View File

@ -18,7 +18,7 @@ pub enum Instruction{
Input(InputInstruction), Input(InputInstruction),
Render, Render,
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings), Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
GenerateModels(strafesnet_common::map::Map), GenerateModels(strafesnet_common::map::CompleteMap),
ClearModels, ClearModels,
//Graphics(crate::graphics_worker::Instruction), //Graphics(crate::graphics_worker::Instruction),
} }