mirror of
https://codeberg.org/icewind/vbsp.git
synced 2026-06-03 18:54:05 +02:00
more validation
This commit is contained in:
parent
26a606db55
commit
aeb8c1011d
4 changed files with 72 additions and 27 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue