From c48b54f3fb7bbe9046915eb99eca02fa84dc55c9 Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 25 Aug 2024 17:44:22 +0100 Subject: feat(render): multithreaded texture loading also a bunch of supporting changes --- stockton-levels/src/traits/light_maps.rs | 4 ++-- stockton-levels/src/traits/light_vols.rs | 6 +++--- stockton-levels/src/traits/mod.rs | 2 +- stockton-levels/src/traits/textures.rs | 2 +- stockton-levels/src/traits/tree.rs | 16 ++++++++-------- stockton-levels/src/traits/vertices.rs | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) (limited to 'stockton-levels/src/traits') diff --git a/stockton-levels/src/traits/light_maps.rs b/stockton-levels/src/traits/light_maps.rs index 50ec84d..cc7fa70 100644 --- a/stockton-levels/src/traits/light_maps.rs +++ b/stockton-levels/src/traits/light_maps.rs @@ -17,12 +17,12 @@ use std::fmt; -use crate::types::RGB; +use crate::types::Rgb; /// Stores light map textures that help make surface lighting more realistic #[derive(Clone)] pub struct LightMap { - pub map: [[RGB; 128]; 128], + pub map: [[Rgb; 128]; 128], } impl PartialEq for LightMap { diff --git a/stockton-levels/src/traits/light_vols.rs b/stockton-levels/src/traits/light_vols.rs index 48972ef..016ddab 100644 --- a/stockton-levels/src/traits/light_vols.rs +++ b/stockton-levels/src/traits/light_vols.rs @@ -15,12 +15,12 @@ * with this program. If not, see . */ -use crate::types::RGB; +use crate::types::Rgb; #[derive(Debug, Clone, Copy)] pub struct LightVol { - pub ambient: RGB, - pub directional: RGB, + pub ambient: Rgb, + pub directional: Rgb, pub dir: [u8; 2], } diff --git a/stockton-levels/src/traits/mod.rs b/stockton-levels/src/traits/mod.rs index c65cde8..00d129f 100644 --- a/stockton-levels/src/traits/mod.rs +++ b/stockton-levels/src/traits/mod.rs @@ -39,6 +39,6 @@ pub use self::light_vols::HasLightVols; pub use self::models::HasModels; pub use self::planes::HasPlanes; pub use self::textures::HasTextures; -pub use self::tree::HasBSPTree; +pub use self::tree::HasBspTree; pub use self::vertices::{HasMeshVerts, HasVertices}; pub use self::visdata::HasVisData; diff --git a/stockton-levels/src/traits/textures.rs b/stockton-levels/src/traits/textures.rs index 4477fba..66c120c 100644 --- a/stockton-levels/src/traits/textures.rs +++ b/stockton-levels/src/traits/textures.rs @@ -160,5 +160,5 @@ pub trait HasTextures { type TexturesIter<'a>: Iterator; fn textures_iter(&self) -> Self::TexturesIter<'_>; - fn get_texture(&self, idx: u32) -> &Texture; + fn get_texture(&self, idx: u32) -> Option<&Texture>; } diff --git a/stockton-levels/src/traits/tree.rs b/stockton-levels/src/traits/tree.rs index 253ae1b..5ca0d59 100644 --- a/stockton-levels/src/traits/tree.rs +++ b/stockton-levels/src/traits/tree.rs @@ -24,29 +24,29 @@ use na::Vector3; /// A node in a BSP tree. /// Either has two children *or* a leaf entry. #[derive(Debug, Clone)] -pub struct BSPNode { +pub struct BspNode { pub plane_idx: u32, pub min: Vector3, pub max: Vector3, - pub value: BSPNodeValue, + pub value: BspNodeValue, } #[derive(Debug, Clone)] -pub enum BSPNodeValue { - Leaf(BSPLeaf), - Children(Box, Box), +pub enum BspNodeValue { + Leaf(BspLeaf), + Children(Box, Box), } /// A leaf in a BSP tree. /// Will be under a `BSPNode`, min and max values are stored there. #[derive(Debug, Clone)] -pub struct BSPLeaf { +pub struct BspLeaf { pub cluster_id: u32, pub area: i32, pub faces_idx: Box<[u32]>, pub brushes_idx: Box<[u32]>, } -pub trait HasBSPTree: HasFaces + HasBrushes + HasVisData { - fn get_bsp_root(&self) -> &BSPNode; +pub trait HasBspTree: HasFaces + HasBrushes + HasVisData { + fn get_bsp_root(&self) -> &BspNode; } diff --git a/stockton-levels/src/traits/vertices.rs b/stockton-levels/src/traits/vertices.rs index ff23785..44c3000 100644 --- a/stockton-levels/src/traits/vertices.rs +++ b/stockton-levels/src/traits/vertices.rs @@ -17,7 +17,7 @@ use crate::coords::CoordSystem; use crate::helpers::slice_to_f32; -use crate::types::RGBA; +use crate::types::Rgba; use na::Vector3; /// A vertex, used to describe a face. @@ -26,7 +26,7 @@ pub struct Vertex { pub position: Vector3, pub tex: TexCoord, pub normal: Vector3, - pub color: RGBA, + pub color: Rgba, } /// Represents a TexCoord. 0 = surface, 1= lightmap. -- cgit v1.2.3