aboutsummaryrefslogtreecommitdiff
path: root/stockton-render/src/draw/context.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-render/src/draw/context.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-render/src/draw/context.rs')
-rw-r--r--stockton-render/src/draw/context.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/stockton-render/src/draw/context.rs b/stockton-render/src/draw/context.rs
index 12f24ad..533cf08 100644
--- a/stockton-render/src/draw/context.rs
+++ b/stockton-render/src/draw/context.rs
@@ -33,10 +33,8 @@ use hal::{
window::SwapchainConfig
};
use stockton_types::{Vector2, Vector3};
-use stockton_bsp::{
- BSPFile,
- lumps::faces::FaceType
-};
+use stockton_levels::prelude::*;
+use stockton_levels::traits::faces::FaceType;
use crate::{
types::*,
@@ -853,19 +851,19 @@ impl<'a> RenderingContext<'a> {
/// Load all active faces into the vertex buffers for drawing
// TODO: This is just a POC, we need to restructure things a lot for actually texturing, etc
- pub fn set_active_faces(&mut self, faces: Vec<usize>, file: &BSPFile) {
+ pub fn set_active_faces<M: MinBSPFeatures>(&mut self, faces: Vec<u32>, file: &M) -> () {
let mut curr_vert_idx: usize = 0;
let mut curr_idx_idx: usize = 0;
- for face in faces.into_iter().map(|idx| &file.faces.faces[idx]) {
+ for face in faces.into_iter().map(|idx| file.get_face(idx)) {
if face.face_type == FaceType::Polygon || face.face_type == FaceType::Mesh {
- let base = face.vertices_idx.start as i32;
+ let base = face.vertices_idx.start;
for idx in face.meshverts_idx.clone().step_by(3) {
let start_idx: u16 = curr_vert_idx.try_into().unwrap();
- for mv in &file.meshverts.meshverts[idx..idx+3] {
- let vert = &file.vertices.vertices[(base + mv.offset) as usize];
+ for idx2 in idx..idx+3 {
+ let vert = &file.resolve_meshvert(idx2 as u32, base);
let uv = Vector2::new(vert.tex.u[0], vert.tex.v[0]);
let uvp = UVPoint (vert.position, uv, 0);