mirror of
https://codeberg.org/icewind/vbsp.git
synced 2026-06-03 18:54:05 +02:00
solid is an enum
This commit is contained in:
parent
15c1c4e6eb
commit
243d2039c3
2 changed files with 26 additions and 4 deletions
|
|
@ -119,7 +119,7 @@ pub struct StaticPropLump {
|
||||||
pub prop_type: u16,
|
pub prop_type: u16,
|
||||||
pub first_leaf: u16,
|
pub first_leaf: u16,
|
||||||
pub leaf_count: u16,
|
pub leaf_count: u16,
|
||||||
pub solid: u8,
|
pub solid: SolidType,
|
||||||
pub skin: i32,
|
pub skin: i32,
|
||||||
pub fade_min_distance: f32,
|
pub fade_min_distance: f32,
|
||||||
pub fade_max_distance: f32,
|
pub fade_max_distance: f32,
|
||||||
|
|
@ -170,6 +170,20 @@ bitflags! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(u8)]
|
||||||
|
#[derive(BinRead, Debug, Copy, Clone)]
|
||||||
|
#[br(repr = u8)]
|
||||||
|
pub enum SolidType {
|
||||||
|
None = 0,
|
||||||
|
Bsp,
|
||||||
|
Bbox,
|
||||||
|
Obb,
|
||||||
|
ObbYaw,
|
||||||
|
Custom,
|
||||||
|
Physics,
|
||||||
|
Last,
|
||||||
|
}
|
||||||
|
|
||||||
impl From<StaticPropLumpFlagsV6> for StaticPropLumpFlags {
|
impl From<StaticPropLumpFlagsV6> for StaticPropLumpFlags {
|
||||||
fn from(v6: StaticPropLumpFlagsV6) -> Self {
|
fn from(v6: StaticPropLumpFlagsV6) -> Self {
|
||||||
StaticPropLumpFlags::from_bits_truncate(v6.bits().into())
|
StaticPropLumpFlags::from_bits_truncate(v6.bits().into())
|
||||||
|
|
@ -183,7 +197,7 @@ struct StaticPropLumpV6 {
|
||||||
pub prop_type: u16,
|
pub prop_type: u16,
|
||||||
pub first_leaf: u16,
|
pub first_leaf: u16,
|
||||||
pub leaf_count: u16,
|
pub leaf_count: u16,
|
||||||
pub solid: u8,
|
pub solid: SolidType,
|
||||||
pub flags: StaticPropLumpFlagsV6,
|
pub flags: StaticPropLumpFlagsV6,
|
||||||
pub skin: i32,
|
pub skin: i32,
|
||||||
pub fade_min_distance: f32,
|
pub fade_min_distance: f32,
|
||||||
|
|
@ -223,7 +237,7 @@ struct StaticPropLumpV10 {
|
||||||
pub leaf_count: u16,
|
pub leaf_count: u16,
|
||||||
// pad, not align
|
// pad, not align
|
||||||
#[br(pad_after = 1)]
|
#[br(pad_after = 1)]
|
||||||
pub solid: u8,
|
pub solid: SolidType,
|
||||||
pub skin: i32,
|
pub skin: i32,
|
||||||
pub fade_min_distance: f32,
|
pub fade_min_distance: f32,
|
||||||
pub fade_max_distance: f32,
|
pub fade_max_distance: f32,
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,26 @@ mod game;
|
||||||
|
|
||||||
use crate::data::*;
|
use crate::data::*;
|
||||||
use crate::Bsp;
|
use crate::Bsp;
|
||||||
|
use std::fmt::{Debug, Formatter};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
/// A handle represents a data structure in the bsp file and the bsp file containing it.
|
/// A handle represents a data structure in the bsp file and the bsp file containing it.
|
||||||
///
|
///
|
||||||
/// Keeping a reference of the bsp file with the data is required since a lot of data types
|
/// Keeping a reference of the bsp file with the data is required since a lot of data types
|
||||||
/// reference parts from other structures in the bsp file
|
/// reference parts from other structures in the bsp file
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Handle<'a, T> {
|
pub struct Handle<'a, T> {
|
||||||
bsp: &'a Bsp,
|
bsp: &'a Bsp,
|
||||||
data: &'a T,
|
data: &'a T,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: Debug> Debug for Handle<'_, T> {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("Handle")
|
||||||
|
.field("data", self.data)
|
||||||
|
.finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> Clone for Handle<'_, T> {
|
impl<T> Clone for Handle<'_, T> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Handle { ..*self }
|
Handle { ..*self }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue