From 51168c753286eeee64410ab19dc9f78a4ea479e4 Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 25 Aug 2024 17:44:20 +0100 Subject: refactor(all): use new traits-based levels everywhere else. unfortunately this also starts using an unstable feature - generic_associated_types see rust-lang/rust#44265 --- stockton-levels/src/traits/faces.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'stockton-levels/src/traits/faces.rs') diff --git a/stockton-levels/src/traits/faces.rs b/stockton-levels/src/traits/faces.rs index ff73c73..cb97877 100644 --- a/stockton-levels/src/traits/faces.rs +++ b/stockton-levels/src/traits/faces.rs @@ -15,9 +15,10 @@ // You should have received a copy of the GNU General Public License // along with stockton-bsp. If not, see . +use std::ops::Range; use na::{Vector2, Vector3}; -use std::ops::Range; +use super::{HasEffects, HasTextures, HasLightMaps, HasMeshVerts}; #[derive(Debug, Clone, Copy, PartialEq)] #[repr(i32)] @@ -31,24 +32,25 @@ pub enum FaceType { #[derive(Debug, Clone, PartialEq)] pub struct Face { pub face_type: FaceType, - pub texture_idx: usize, - pub effect_idx: Option, - pub lightmap_idx: Option, - pub vertices_idx: Range, - pub meshverts_idx: Range, + pub texture_idx: u32, + pub effect_idx: Option, + pub lightmap_idx: Option, + pub vertices_idx: Range, + pub meshverts_idx: Range, - pub map_start: Vector2, - pub map_size: Vector2, + pub map_start: Vector2, + pub map_size: Vector2, pub map_origin: Vector3, pub map_vecs: [Vector3; 2], pub normal: Vector3, - pub size: Vector2, + pub size: Vector2, } -pub trait HasFaces<'a> { - type FacesIter: Iterator; +pub trait HasFaces: HasTextures + HasEffects + HasLightMaps + HasMeshVerts { + type FacesIter<'a>: Iterator; - fn faces_iter(&'a self) -> Self::FacesIter; - fn get_face(&'a self, index: u32) -> &'a Face; + fn faces_iter<'a>(&'a self) -> Self::FacesIter<'a>; + fn faces_len(&self) -> u32; + fn get_face<'a>(&'a self, index: u32) -> &'a Face; } -- cgit v1.2.3