fix indexes

This commit is contained in:
Robin Appelman 2022-03-12 00:32:08 +01:00
commit 4876ccf0f4
4 changed files with 36 additions and 6 deletions

View file

@ -3,6 +3,7 @@ use arrayvec::ArrayString;
use binrw::{BinResult, ReadOptions};
use std::fmt;
use std::fmt::{Display, Formatter};
use std::ops::Add;
#[derive(Debug, Clone, Copy, BinRead)]
pub struct Vector {
@ -39,6 +40,18 @@ impl From<&Vector> for [f32; 3] {
}
}
impl Add<Vector> for Vector {
type Output = Vector;
fn add(self, rhs: Vector) -> Self::Output {
Vector {
x: self.x + rhs.x,
y: self.y + rhs.y,
z: self.z + rhs.z,
}
}
}
#[derive(Debug, Clone, BinRead)]
pub struct Quaternion {
pub x: f32,

View file

@ -214,6 +214,7 @@ impl Strip {
pub fn indices(&self) -> impl Iterator<Item = [usize; 3]> + 'static {
if self.flags.contains(StripFlags::IS_TRI_STRIP) {
dbg!("strip");
let offset = self.indices.start;
Either::Left((0..self.indices.len()).map(move |i| {
let cw = i & 1;

View file

@ -119,7 +119,7 @@ impl StripGroupHeader {
index_range(
self.vertex_offset,
self.vertex_count,
size_of::<u16>(), // Vertex index from .VVD's vertex array
size_of::<Vertex>(), // Vertex index from .VVD's vertex array
)
}