1
0
Fork 0
mirror of https://codeberg.org/icewind/vbsp.git synced 2026-06-03 10:44:07 +02:00

more object convert work

This commit is contained in:
Robin Appelman 2020-06-28 15:04:23 +02:00
commit bdaa8fe6bc
3 changed files with 56 additions and 44 deletions

View file

@ -9,7 +9,7 @@ use std::fmt;
use std::io::{Error, ErrorKind};
use std::iter::once;
use std::mem::size_of;
use std::ops::Index;
use std::ops::{Add, Index};
#[derive(Clone)]
pub struct Directories {
@ -216,7 +216,7 @@ impl BinRead for Name {
}
}
#[derive(Debug, Clone, BinRead)]
#[derive(Debug, Clone, Copy, BinRead)]
pub struct Vector {
pub x: f32,
pub y: f32,
@ -229,6 +229,18 @@ impl Vector {
}
}
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,
}
}
}
impl From<Vector> for [f32; 3] {
fn from(vector: Vector) -> Self {
[vector.x, vector.y, vector.z]

View file

@ -1,5 +1,5 @@
mod bspfile;
mod data;
pub mod data;
mod reader;
use crate::bspfile::LumpType;
@ -371,6 +371,25 @@ impl<'a> Handle<'a, Face> {
EdgeDirection::LastToFirst => edge.end_index,
})
}
pub fn is_visible(&self) -> bool {
self.texture()
.map(|texture| {
!texture.flags.intersects(
TextureFlags::LIGHT
| TextureFlags::SKY2D
| TextureFlags::SKY
| TextureFlags::WARP
| TextureFlags::TRANS
| TextureFlags::TRIGGER
| TextureFlags::HINT
| TextureFlags::SKIP
| TextureFlags::NODRAW
| TextureFlags::HITBOX,
)
})
.unwrap_or_default()
}
}
impl Handle<'_, Node> {