aboutsummaryrefslogtreecommitdiff
path: root/stockton-levels/src/traits/vertices.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-25 17:44:20 +0100
committertcmal <me@aria.rip>2024-08-25 17:44:20 +0100
commit51168c753286eeee64410ab19dc9f78a4ea479e4 (patch)
treed384093c6fd11b36b189013b663f3500b18ec2a4 /stockton-levels/src/traits/vertices.rs
parentd076d3a6fd484e298915cd85609ba9706abacc87 (diff)
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
Diffstat (limited to 'stockton-levels/src/traits/vertices.rs')
-rw-r--r--stockton-levels/src/traits/vertices.rs21
1 files changed, 10 insertions, 11 deletions
diff --git a/stockton-levels/src/traits/vertices.rs b/stockton-levels/src/traits/vertices.rs
index cb06b3a..2afa802 100644
--- a/stockton-levels/src/traits/vertices.rs
+++ b/stockton-levels/src/traits/vertices.rs
@@ -18,7 +18,6 @@
use crate::helpers::{slice_to_f32};
use crate::types::RGBA;
use na::Vector3;
-use std::convert::TryInto;
/// A vertex, used to describe a face.
@@ -49,22 +48,22 @@ impl TexCoord {
}
/// A vertex offset, used to describe generalised triangle meshes
-pub type MeshVert = i32;
+pub type MeshVert = u32;
-pub trait HasVertices<'a> {
- type VerticesIter: Iterator<Item = &'a Vertex>;
+pub trait HasVertices {
+ type VerticesIter<'a>: Iterator<Item = &'a Vertex>;
- fn vertices_iter(&'a self) -> Self::VerticesIter;
- fn get_vertex(&'a self, index: u32) -> &'a Vertex;
+ fn vertices_iter<'a>(&'a self) -> Self::VerticesIter<'a>;
+ fn get_vertex<'a>(&'a self, index: u32) -> &'a Vertex;
}
-pub trait HasMeshVerts<'a>: HasVertices<'a> {
- type MeshVertsIter: Iterator<Item = &'a MeshVert>;
+pub trait HasMeshVerts: HasVertices {
+ type MeshVertsIter<'a>: Iterator<Item = &'a MeshVert>;
- fn meshverts_iter(&'a self) -> Self::MeshVertsIter;
+ fn meshverts_iter<'a>(&'a self) -> Self::MeshVertsIter<'a>;
fn get_meshvert(&self, index: u32) -> MeshVert;
- fn resolve_meshvert(&'a self, index: u32) -> &'a Vertex {
- self.get_vertex(self.get_meshvert(index).try_into().unwrap())
+ fn resolve_meshvert<'a>(&'a self, index: u32, base: u32) -> &'a Vertex {
+ self.get_vertex(self.get_meshvert(index) + base)
}
} \ No newline at end of file