From 5efdd3654ad64666584bdeed65fdc867a946b223 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sun, 4 Feb 2024 20:54:52 -0800 Subject: [PATCH] updates for rbx_loader --- src/gameplay_attributes.rs | 3 +- src/gameplay_modes.rs | 2 +- src/model.rs | 94 ++++++++++++++++++++++++++++++++------ 3 files changed, 83 insertions(+), 16 deletions(-) diff --git a/src/gameplay_attributes.rs b/src/gameplay_attributes.rs index 92ee4dd..3fc1a4c 100644 --- a/src/gameplay_attributes.rs +++ b/src/gameplay_attributes.rs @@ -132,9 +132,10 @@ impl IntersectingAttributes{ self.water.is_some() } } +#[derive(Clone,Copy)] pub struct CollisionAttributesId(u32); impl CollisionAttributesId{ - pub fn new(id:u32)->Self{ + pub fn id(id:u32)->Self{ Self(id) } } diff --git a/src/gameplay_modes.rs b/src/gameplay_modes.rs index f3d98cf..923407a 100644 --- a/src/gameplay_modes.rs +++ b/src/gameplay_modes.rs @@ -33,7 +33,7 @@ pub enum StageElementBehaviour{ #[derive(Clone,Copy,Hash,Eq,PartialEq)] pub struct CheckpointId(usize); -#[derive(Clone,Hash,Eq,PartialEq,Ord,PartialOrd)] +#[derive(Clone,Copy,Hash,Eq,PartialEq,Ord,PartialOrd)] pub struct StageId(u32); impl StageId{ pub const fn id(id:u32)->Self{ diff --git a/src/model.rs b/src/model.rs index 36aa4f2..655aca5 100644 --- a/src/model.rs +++ b/src/model.rs @@ -5,31 +5,97 @@ use crate::updatable::Updatable; pub type TextureCoordinate=glam::Vec2; pub type Color4=glam::Vec4; +#[derive(Clone,Copy,Hash,PartialEq,Eq)] +pub struct PositionId(u32); +impl PositionId{ + pub const fn id(id:u32)->Self{ + Self(id) + } +} +#[derive(Clone,Copy,Hash,PartialEq,Eq)] +pub struct TextureCoordinateId(u32); +impl TextureCoordinateId{ + pub const fn id(id:u32)->Self{ + Self(id) + } +} +#[derive(Clone,Copy,Hash,PartialEq,Eq)] +pub struct NormalId(u32); +impl NormalId{ + pub const fn id(id:u32)->Self{ + Self(id) + } +} +#[derive(Clone,Copy,Hash,PartialEq,Eq)] +pub struct ColorId(u32); +impl ColorId{ + pub const fn id(id:u32)->Self{ + Self(id) + } +} #[derive(Clone,Hash,PartialEq,Eq)] pub struct IndexedVertex{ - pub pos:u32, - pub tex:u32, - pub normal:u32, - pub color:u32, + pub pos:PositionId, + pub tex:TextureCoordinateId, + pub normal:NormalId, + pub color:ColorId, } +#[derive(Clone,Copy,Hash,PartialEq,Eq)] pub struct VertexId(u32); +impl VertexId{ + pub const fn id(id:u32)->Self{ + Self(id) + } +} pub struct IndexedVertexList{ pub vertices:Vec, } -pub struct GroupId(u32); -pub enum IndexedGroup{ +#[derive(Clone,Copy,Hash,PartialEq,Eq)] +pub struct PolygonGroupId(u32); +impl PolygonGroupId{ + pub const fn id(id:u32)->Self{ + Self(id) + } +} +pub enum PolygonGroup{ PolygonList(Vec), //TriangleStrip(Vec), } -pub struct RenderId(u32); +/// Ah yes, a group of things to render at the same time +#[derive(Clone,Copy,Hash,Eq,PartialEq)] +pub struct RenderGroupId(u32); +impl RenderGroupId{ + pub const fn id(id:u32)->Self{ + Self(id) + } +} +#[derive(Clone,Copy,Hash,Eq,PartialEq)] +pub struct TextureId(u32); +impl TextureId{ + pub const fn id(id:u32)->Self{ + Self(id) + } +} +#[derive(Default)] +pub struct RenderConfig{ + texture:Option, +} +impl RenderConfig{ + pub const fn texture(texture:TextureId)->Self{ + Self{ + texture:Some(texture), + } + } +} pub struct IndexedGraphicsGroup{ //Render pattern material/texture/shader/flat color - pub render:RenderId, - pub groups:Vec, + pub render:RenderGroupId, + pub groups:Vec, } +#[derive(Default)] pub struct IndexedPhysicsGroup{ //the polygons in this group are guaranteed to make a closed convex shape - pub groups:Vec, + pub groups:Vec, } //This is a superset of PhysicsModel and GraphicsModel #[derive(Clone,Copy,Hash,Eq,PartialEq)] @@ -45,12 +111,12 @@ pub struct IndexedModel{ pub unique_tex:Vec, pub unique_color:Vec, pub unique_vertices:Vec, - //groups are constant texture AND convexity slices - pub groups:Vec, + //polygon groups are constant texture AND convexity slices + pub polygon_groups:Vec, //graphics indexed (by texture) - pub graphics_sets:Vec, + pub graphics_groups:Vec, //physics indexed (by convexity) - pub physics_sets:Vec, + pub physics_groups:Vec, } #[derive(Clone,Copy,Hash,Eq,PartialEq)]