BSPParser
Simple and modern library for parsing the Valve BSP format
|
Functions | |
void | iterateModels (const Bsp &bsp, const std::function< void(const Structs::Model &model, const std::vector< PhysModel > &physicsModels)> &iteratee) |
void | iterateFaces (const Bsp &bsp, const Structs::Model &model, const std::function< void(const Structs::Face &face, const Structs::Plane &plane, const Structs::TexInfo &textureInfo, std::span< const int32_t > surfaceEdges)> &iteratee) |
size_t | getVertexCount (const Bsp &bsp, const Structs::Face &face, const std::span< const int32_t > surfaceEdges) |
size_t | getTriangleListIndexCount (const Bsp &bsp, const Structs::Face &face, const std::span< const int32_t > surfaceEdges) |
void | generateVertices (const Bsp &bsp, const Structs::Face &face, const Structs::Plane &plane, const Structs::TexInfo &textureInfo, const std::span< const int32_t > surfaceEdges, const std::function< void(const Vertex &vertex)> &iteratee) |
void | generateTriangleListIndices (const Bsp &bsp, const Structs::Face &face, const std::span< const int32_t > surfaceEdges, const std::function< void(uint32_t i0, uint32_t i1, uint32_t i2)> &iteratee) |
template<StaticPropIteratee Iteratee> | |
void | iterateStaticProps (const Bsp &bsp, Iteratee iteratee) |
void | iterateTextures (const Bsp &bsp, const std::function< void(const Structs::TexData &texture, const char *path)> &iteratee) |
Accessor helpers for iterating contents of the BSP.
A collection of helper functions to ease traversing the MDL, VTX and VVD structures together.
void BspParser::Accessors::generateTriangleListIndices | ( | const Bsp & | bsp, |
const Structs::Face & | face, | ||
std::span< const int32_t > | surfaceEdges, | ||
const std::function< void(uint32_t i0, uint32_t i1, uint32_t i2)> & | iteratee | ||
) |
Calls iteratee once for each triangle forming a mesh which triangulates the given face. Indices start from 0 and index into the vertices generated by generateFaceVertices.
bsp | BSP instance. |
face | Face to generate a triangle list for. |
surfaceEdges | Surface edge indices of the face. |
iteratee | Called with each triplet of indices defining a triangle with clockwise winding. |
std::runtime_error | Face cannot be triangulated (less than 3 edges). |
void BspParser::Accessors::generateVertices | ( | const Bsp & | bsp, |
const Structs::Face & | face, | ||
const Structs::Plane & | plane, | ||
const Structs::TexInfo & | textureInfo, | ||
std::span< const int32_t > | surfaceEdges, | ||
const std::function< void(const Vertex &vertex)> & | iteratee | ||
) |
Calls iteratee once for each unique vertex in the face's edges or displacement. Generates normals, tangents and UVs.
bsp | BSP instance. |
face | Face to generate vertices for. |
plane | Plane referenced by the face. |
textureInfo | Texture info referenced by the face. |
surfaceEdges | Surface edge indices of the face. |
iteratee | Function to call with each generated vertex. |
std::runtime_error | Face cannot be triangulated (less than 3 edges). |
size_t BspParser::Accessors::getTriangleListIndexCount | ( | const Bsp & | bsp, |
const Structs::Face & | face, | ||
std::span< const int32_t > | surfaceEdges | ||
) |
Returns the number of indices that will be generated by generateFaceTriangleList. Useful for precomputing the size of index buffer needed to reduce allocations.
bsp | BSP instance. |
face | Face to get the index count of. |
surfaceEdges | Surface edges of the face. |
std::runtime_error | Face cannot be triangulated (less than 3 edges). |
size_t BspParser::Accessors::getVertexCount | ( | const Bsp & | bsp, |
const Structs::Face & | face, | ||
std::span< const int32_t > | surfaceEdges | ||
) |
Returns the number of vertices that will be generated by generateFaceVertices. Useful for precomputing the size of vertex buffer needed to reduce allocations.
bsp | BSP instance. |
face | Face to get the vertex count of. |
surfaceEdges | Surface edge indices of the face. |
std::runtime_error | Face cannot be triangulated (less than 3 edges). |
void BspParser::Accessors::iterateFaces | ( | const Bsp & | bsp, |
const Structs::Model & | model, | ||
const std::function< void(const Structs::Face &face, const Structs::Plane &plane, const Structs::TexInfo &textureInfo, std::span< const int32_t > surfaceEdges)> & | iteratee | ||
) |
Calls the provided function for each face in the BSP's model, passing a reference to the Structs::Face along with its corresponding Structs::Plane, Structs::TexInfo and surface edge indices.
bsp | BSP instance. |
model | Model to iterate the faces of. |
iteratee | Function to be called. |
void BspParser::Accessors::iterateModels | ( | const Bsp & | bsp, |
const std::function< void(const Structs::Model &model, const std::vector< PhysModel > &physicsModels)> & | iteratee | ||
) |
Calls the provided function for each model in the BSP, passing a reference to the Structs::Model and its corresponding physics models.
bsp | BSP instance. |
iteratee | Function to be called. |
void BspParser::Accessors::iterateStaticProps | ( | const Bsp & | bsp, |
Iteratee | iteratee | ||
) |
Calls the provided visitor for each static prop in the given BSP.
Iteratee | Visitor type declaring an overload for each supported static prop version. |
bsp | BSP instance to iterate. |
iteratee | Instance of Iteratee. |
void BspParser::Accessors::iterateTextures | ( | const Bsp & | bsp, |
const std::function< void(const Structs::TexData &texture, const char *path)> & | iteratee | ||
) |
Calls the given function for each Structs::TexData in the BSP, along with its path.
bsp | BSP instance. |
iteratee | Function to be called. |