Overview
TheFaceSource class is a decompiling module that writes brushes from the LUMP_FACES lump in BSP files. Unlike BrushSource which reconstructs brushes from brush/brushside data, this module creates thin face brushes from face geometry, including support for displacements, areaportals, and occluders.
This module is based on several face building methods from Vmex.
Package: info.ata4.bspsrc.decompiler.modules.geom
Constructor
BSP file reader for accessing BSP data
VMF writer for outputting face brushes
Configuration settings for decompilation
Texture source module for material handling
VMF metadata handler for UIDs and visgroups
Factory for creating winding geometry from faces
Occluder reallocation data
Public Methods
writeFaces
writeOrigFaces
writeOrigFacesPlus
- Creates face mapping between original and split faces
- Detects undersized original faces (where split face area > original face area)
- Writes split faces for undersized originals to avoid gaps
writeDispFaces
dispInfo != -1). Used for extracting displacement geometry.
writeFace
Face index (in faces or origFaces lump, depending on
orig parameter)If
true, use original faces lump; if false, use split faces lumpOrigin offset to apply to face geometry
Rotation angles to apply to face geometry
- Skips faces with less than 2 edges
- Creates front side from face winding
- Creates back sides (prismatic for displacements, pyramidal otherwise)
- Writes displacement data if present and
config.writeDispis enabled
writeModel
Model index in the BSP model lump
Origin offset for model faces
Rotation angles for model faces
writeAreaportal
Portal key identifying the areaportal
Areaportal data structure
- Creates winding from areaportal vertices
- Writes as extruded polygon with
tools/toolsareaportaltexture
writeOccluder
Occluder key/index
Occluder data structure
- Writes all polygons associated with the occluder
- Uses
tools/toolsoccluderfor front face,tools/toolsnodrawfor back faces - Extrudes by 1 unit
writePolygon
Winding (polygon vertices) to create brush from
Texture string for all brush sides
Texture string for front brush side
Texture string for back brush sides
If
true, use prismatic back sides; if false, use pyramidal back sidesExtrusion depth for back sides (defaults to
config.backfaceDepth)writeDisplacement
Displacement info index
- Writes displacement vertex normals, distances, and alphas
- Writes triangle tags and allowed vertices
- Writes multiblend data if present in BSP
- Maps displacement vertices to VMF row format
Configuration Options
This module respects the following configuration options fromBspSourceConfig:
- writeDisp - Enable writing displacement data
- faceTexture - Override texture string for front faces
- backfaceTexture - Override texture string for back faces
- backfaceDepth - Depth to extrude back sides (default varies)
- debug - Write debugging metadata to VMF output
Usage Example
Implementation Details
Face Types
The module handles three types of faces:- Split Faces - Faces after BSP compilation splits them
- Original Faces - Pre-split faces stored in
LUMP_ORIGINALFACES - Displacement Faces - Faces with displacement geometry data
Back Side Generation
Faces are written as thin brushes with two back side generation strategies: Pyramidal: Creates a pyramid with apex at face center displaced by depth- Used for regular faces
- Results in fewer brush sides
- Can create non-planar geometry
- Used for displacement faces
- Maintains face shape
- Creates surrounding side faces
Face Mapping
ThecreateFaceMapping() method builds relationships between original and split faces:
- Maps each split face to its original face
- Calculates original face areas
- Detects undersized original faces (split area > original area + epsilon)
Displacement Data
Displacement data includes:- Vertex normals and offsets
- Alpha values for blending
- Triangle subdivision tags
- Allowed vertices for editing
- Multiblend channels (if present)
Related Modules
- BrushSource - Alternative brush writing using brush/brushside lumps
- EntitySource - Entity decompilation that uses FaceSource
- TextureSource - Texture handling for faces