1
0
Fork 0
mirror of https://codeberg.org/icewind/vbsp.git synced 2026-06-03 18:54:05 +02:00

more validation

This commit is contained in:
Robin Appelman 2022-02-21 22:33:24 +01:00
commit aeb8c1011d
4 changed files with 72 additions and 27 deletions

View file

@ -3,7 +3,7 @@ use crate::data::*;
impl<'a> Handle<'a, Face> {
/// Get the texture of the face
pub fn texture(&self) -> Option<Handle<TextureInfo>> {
pub fn texture(&self) -> Handle<TextureInfo> {
self.bsp
.textures_info
.get(self.texture_info as usize)
@ -11,6 +11,7 @@ impl<'a> Handle<'a, Face> {
bsp: self.bsp,
data: texture_info,
})
.unwrap()
}
/// Get all vertices making up the face
@ -44,21 +45,18 @@ impl<'a> Handle<'a, Face> {
/// Check if the face is flagged as visible
pub fn is_visible(&self) -> bool {
self.texture()
.map(|texture| {
!texture.flags.intersects(
TextureFlags::LIGHT
| TextureFlags::SKY2D
| TextureFlags::SKY
| TextureFlags::WARP
| TextureFlags::TRIGGER
| TextureFlags::HINT
| TextureFlags::SKIP
| TextureFlags::NODRAW
| TextureFlags::HITBOX,
)
})
.unwrap_or_default()
let texture = self.texture();
!texture.flags.intersects(
TextureFlags::LIGHT
| TextureFlags::SKY2D
| TextureFlags::SKY
| TextureFlags::WARP
| TextureFlags::TRIGGER
| TextureFlags::HINT
| TextureFlags::SKIP
| TextureFlags::NODRAW
| TextureFlags::HITBOX,
)
}
/// Triangulate the face

View file

@ -56,17 +56,20 @@ impl<'a> Handle<'a, Model> {
impl<'a> Handle<'a, TextureInfo> {
/// Get the texture data references by the texture
pub fn texture(&self) -> Option<&TextureData> {
self.bsp
pub fn texture(&self) -> Handle<'a, TextureData> {
let texture = self
.bsp
.textures_data
.get(self.data.texture_data_index as usize)
.unwrap();
Handle::new(self.bsp, texture)
}
}
impl Handle<'_, Node> {
/// Get the plane splitting this node
pub fn plane(&self) -> Option<Handle<'_, Plane>> {
self.bsp.plane(self.plane_index as _)
pub fn plane(&self) -> Handle<'_, Plane> {
self.bsp.plane(self.plane_index as _).unwrap()
}
}