updates for rbx_loader

This commit is contained in:
Quaternions 2024-02-04 20:54:52 -08:00
parent 37fb390465
commit 5efdd3654a
3 changed files with 83 additions and 16 deletions

View File

@ -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)
}
}

View File

@ -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{

View File

@ -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<VertexId>,
}
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<IndexedVertexList>),
//TriangleStrip(Vec<IndexedVertexList>),
}
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<TextureId>,
}
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<GroupId>,
pub render:RenderGroupId,
pub groups:Vec<PolygonGroupId>,
}
#[derive(Default)]
pub struct IndexedPhysicsGroup{
//the polygons in this group are guaranteed to make a closed convex shape
pub groups:Vec<GroupId>,
pub groups:Vec<PolygonGroupId>,
}
//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<TextureCoordinate>,
pub unique_color:Vec<Color4>,
pub unique_vertices:Vec<IndexedVertex>,
//groups are constant texture AND convexity slices
pub groups:Vec<IndexedGroup>,
//polygon groups are constant texture AND convexity slices
pub polygon_groups:Vec<PolygonGroup>,
//graphics indexed (by texture)
pub graphics_sets:Vec<IndexedGraphicsGroup>,
pub graphics_groups:Vec<IndexedGraphicsGroup>,
//physics indexed (by convexity)
pub physics_sets:Vec<IndexedPhysicsGroup>,
pub physics_groups:Vec<IndexedPhysicsGroup>,
}
#[derive(Clone,Copy,Hash,Eq,PartialEq)]