pub struct BspData {Show 18 fields
pub format: BspFormat,
pub entities: String,
pub planes: Vec<BspPlane>,
pub textures: Vec<Option<BspMipTexture>>,
pub vertices: Vec<Vec3>,
pub visibility: BspVisData,
pub nodes: Vec<BspNode>,
pub tex_info: Vec<BspTexInfo>,
pub faces: Vec<BspFace>,
pub lighting: Option<BspLighting>,
pub clip_nodes: Vec<BspClipNode>,
pub leaves: Vec<BspLeaf>,
pub mark_surfaces: Vec<UBspValue>,
pub edges: Vec<BspEdge>,
pub surface_edges: Vec<i32>,
pub models: Vec<BspModel>,
pub bspx: BspxData,
pub parse_ctx: BspParseContext,
}Expand description
A BSP files contents parsed into structures for easy access.
Fields§
§format: BspFormat§entities: StringEssentially an embedded .map file, the differences being:
- Brush data has been stripped.
- Brush entities have a
modelproperty indexing into themodelsfield of this struct.
planes: Vec<BspPlane>§textures: Vec<Option<BspMipTexture>>§vertices: Vec<Vec3>All vertex positions.
visibility: BspVisDataRLE encoded bit array. For BSP38, this is cluster-based. For BSP29, BSP2 and BSP30 this is leaf-based, and models will have their own indices into the visdata array.
Use potentially_visible_set_at() and related functions to query this data.
See the specification for more info.
nodes: Vec<BspNode>§tex_info: Vec<BspTexInfo>§faces: Vec<BspFace>§lighting: Option<BspLighting>§clip_nodes: Vec<BspClipNode>§leaves: Vec<BspLeaf>§mark_surfaces: Vec<UBspValue>Indices into the face list, pointed to by leaves.
edges: Vec<BspEdge>§surface_edges: Vec<i32>§models: Vec<BspModel>§bspx: BspxData§parse_ctx: BspParseContextAdditional information from the BSP parsed. For example, contains the BspFormat of the file.
Implementations§
Source§impl BspData
impl BspData
Sourcepub fn get_texture_name<'a>(
&'a self,
tex_info: &'a BspTexInfo,
) -> Option<&'a str>
pub fn get_texture_name<'a>( &'a self, tex_info: &'a BspTexInfo, ) -> Option<&'a str>
Helper function to get a texture name from a BspTexInfo without worrying about format.
Source§impl BspData
impl BspData
Sourcepub fn compute_lightmap_atlas<P: LightmapPacker>(
&self,
packer: P,
) -> Result<LightmapAtlasOutput<P>, ComputeLightmapAtlasError>
pub fn compute_lightmap_atlas<P: LightmapPacker>( &self, packer: P, ) -> Result<LightmapAtlasOutput<P>, ComputeLightmapAtlasError>
Packs every face’s lightmap together onto a single atlas for GPU rendering.
Source§impl BspData
impl BspData
Sourcepub fn mesh_model(
&self,
model_idx: usize,
lightmap_uvs: Option<&LightmapUvMap>,
) -> MeshModelOutput
pub fn mesh_model( &self, model_idx: usize, lightmap_uvs: Option<&LightmapUvMap>, ) -> MeshModelOutput
Meshes a model at the specified index. Returns one mesh for each texture used in the model.
Source§impl BspData
impl BspData
Sourcepub fn leaf_at_point(&self, model_idx: usize, point: Vec3) -> usize
pub fn leaf_at_point(&self, model_idx: usize, point: Vec3) -> usize
Returns the index of the BSP leaf point is in of model.
Sourcepub fn leaf_at_point_in_node(&self, node_ref: BspNodeRef, point: Vec3) -> usize
pub fn leaf_at_point_in_node(&self, node_ref: BspNodeRef, point: Vec3) -> usize
Returns the index of the BSP leaf point is in inside a specific node. Usually, you probably want Self::leaf_at_point.
Sourcepub fn potentially_visible_set(&self, leaf_idx: usize) -> Option<VisResult<'_>>
pub fn potentially_visible_set(&self, leaf_idx: usize) -> Option<VisResult<'_>>
Get the potentially visible set of the leaf with index leaf_idx. These are the maximum set of leaves
that could ever be visible from this leaf. Depending on format, this will either be expressed as a set
of leaf indices (VisdataRef::Offset), or a cluster (VisdataRef::Cluster). In the latter case, you
should check the visdata field of BspLeaf to work out which leaves
are visible.
If None, the leaf has no visdata - this usually means that the leaf represents an out-of-bounds
area. In this case, most BSP implementations consider all leaves visible.
Sourcepub fn potentially_visible_set_at(
&self,
model_idx: usize,
point: Vec3,
) -> Option<VisResult<'_>>
pub fn potentially_visible_set_at( &self, model_idx: usize, point: Vec3, ) -> Option<VisResult<'_>>
Get the potentially visible set at the point point in the model at the index model_idx. These are
the maximum set of leaves that could ever be visible from this leaf. Depending on format, this will
either be expressed as a set of leaf indices (VisdataRef::Offset), or a cluster (VisdataRef::Cluster).
In the latter case, you should check the visdata field of BspLeaf to
work out which leaves are visible.
If None, the leaf has no visdata - this usually means that the leaf represents an out-of-bounds
area. In this case, most BSP implementations consider all leaves visible.
Sourcepub fn potentially_audible_set(&self, leaf_idx: usize) -> Option<VisResult<'_>>
pub fn potentially_audible_set(&self, leaf_idx: usize) -> Option<VisResult<'_>>
Get the potentially audible set of the leaf with index leaf_idx.
If None, the leaf has no visdata - this usually means that the leaf represents an out-of-bounds
area. In this case, most BSP implementations consider all leaves audible.
Note: This will only potentially return something different for Quake 2. All other implementations have identical implementations for whether two points are potentially-visible vs potentially-audible. In most cases, you want
potentially_visible_set().
Sourcepub fn potentially_audible_set_at(
&self,
model_idx: usize,
point: Vec3,
) -> Option<VisResult<'_>>
pub fn potentially_audible_set_at( &self, model_idx: usize, point: Vec3, ) -> Option<VisResult<'_>>
Get the potentially audible set at the point point in the model at the index model_idx.
If None, the leaf has no visdata - this usually means that the leaf represents an out-of-bounds
area. In this case, most BSP implementations consider all leaves audible.
Sourcepub fn raycast(&self, model_idx: usize, from: Vec3, to: Vec3) -> RaycastResult
pub fn raycast(&self, model_idx: usize, from: Vec3, to: Vec3) -> RaycastResult
Implementation of Quake’s SV_RecursiveHullCheck function.
Traces a line through this data’s model at model_idx, returning information of the leaf it ends up at, and the first surface it hits if any.
TODO There are more numerically stable implementations, but i couldn’t get them to work. I guess if it works for Quake it works for me!
Source§impl BspData
impl BspData
Sourcepub fn parse(input: BspParseInput<'_>) -> BspResult<Self>
pub fn parse(input: BspParseInput<'_>) -> BspResult<Self>
Parses the data from BSP input.
Sourcepub fn parse_embedded_textures<'a, 'p: 'a>(
&'a self,
palette: &'p Palette,
) -> impl Iterator<Item = (&'a str, RgbImage)> + 'a
pub fn parse_embedded_textures<'a, 'p: 'a>( &'a self, palette: &'p Palette, ) -> impl Iterator<Item = (&'a str, RgbImage)> + 'a
Parses embedded textures using the provided palette. Use QUAKE_PALETTE for the default Quake palette.