1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-20 03:37:47 +00:00

Model: Make vertex declarations and enums public

This commit is contained in:
Joshua Goins 2024-11-03 11:00:33 -05:00
parent 16e4db2a00
commit f6c2b98b80
2 changed files with 25 additions and 1 deletions

View file

@ -108,7 +108,7 @@ mod sha1;
mod model_file_operations; mod model_file_operations;
#[cfg(feature = "visual_data")] #[cfg(feature = "visual_data")]
mod model_vertex_declarations; pub mod model_vertex_declarations;
#[cfg(feature = "visual_data")] #[cfg(feature = "visual_data")]
pub mod lgb; pub mod lgb;

View file

@ -11,6 +11,7 @@ const END_OF_STREAM: u8 = 0xFF;
/// The format of the vertex stream. /// The format of the vertex stream.
#[binrw] #[binrw]
#[brw(repr = u8)] #[brw(repr = u8)]
#[repr(C)]
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq)]
pub enum VertexType { pub enum VertexType {
/// 1 32-bit float /// 1 32-bit float
@ -49,9 +50,31 @@ pub enum VertexType {
UnsignedShort4 = 17, UnsignedShort4 = 17,
} }
/// In bytes
pub fn get_vertex_type_size(vertex_type: VertexType) -> usize {
// TODO: Most of these are wrong
match vertex_type {
VertexType::Single1 => 4,
VertexType::Single2 => 8,
VertexType::Single3 => 12,
VertexType::Single4 => 16,
VertexType::Byte4 => 4,
VertexType::Short2 => 4,
VertexType::Short4 => 8,
VertexType::ByteFloat4 => 4,
VertexType::Short2n => 4,
VertexType::Short4n => 4,
VertexType::Half2 => 4,
VertexType::Half4 => 8,
VertexType::UnsignedShort2 => 4,
VertexType::UnsignedShort4 => 8,
}
}
/// What the vertex stream is used for. /// What the vertex stream is used for.
#[binrw] #[binrw]
#[brw(repr = u8)] #[brw(repr = u8)]
#[repr(C)]
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq)]
pub enum VertexUsage { pub enum VertexUsage {
Position = 0, Position = 0,
@ -68,6 +91,7 @@ pub enum VertexUsage {
#[binrw] #[binrw]
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq)]
#[allow(dead_code)] #[allow(dead_code)]
#[repr(C)]
#[brw(little)] #[brw(little)]
pub struct VertexElement { pub struct VertexElement {
pub stream: u8, pub stream: u8,