CFOWMaker
Overview
UCFOWMaker is the core fog of war builder. It manages two render targets (line-of-sight and revealed areas), a UDynamicMeshComponent plane sized to the current room cluster, and dynamic material instances for both the fog mesh and an optional post-process volume. It implements ICCell and ICPlayerControllerBoundable to react to perspective changes.
Properties
| Name | Description |
|---|---|
| fogMakerStruct | Copy of the FCFOWMakerStruct configuration |
| renderTarget2D | Render target for current line-of-sight painting |
| renderTarget2DRevealed | Render target for previously revealed areas |
| fogDynamicMaterial | Dynamic material instance applied to the fog mesh plane |
| dynamicMeshComponent | Dynamic mesh component representing the fog plane |
| postProcessFogDynamicMaterial | Optional dynamic material instance for post-process fog compositing |
| currentFogOfWar | Pointer to the current cluster FCRectangle being fogged |
| topView | True when the camera is in first-person perspective (fog disabled) |
| built | True once the fog maker has been fully initialized |
Functions
| Name | Description |
|---|---|
| instanciate | Static factory that creates the fog maker, render targets, materials and mesh |
| buildASync | Async entry point called each tick: checks if fog needs redrawing, enqueues commands |
| wantDraw | Returns true if the fog should be recomputed (rooms built, not in top view, queue empty) |
| drawFog | Async: finds the closest cluster and enqueues a cluster change or mesh clear |
| updateFog_sync | Game thread: dequeues commands, clears render targets, rebuilds the mesh plane |
| setMinimapZDistance | Updates the minimap distance parameter on the fog material |
| isBuilt | Returns true if the fog maker is initialized |
| clean | Unbinds from the player controller events |
| onPerspectiveTypeChange | Reacts to camera perspective changes (disables fog in first person) |
// instanciate creates the fog maker with all its resources:
UCFOWMaker::instanciate(sceneComponent, fowMaker, stream, fowMakerStruct, postProcessVolume);
// buildASync is called each tick by the spawner:
fowMaker->buildASync(singleDoRun, pawnX, pawnY);
// Internally, buildASync runs drawFog asynchronously:
// - drawFog finds the closest cluster via RoomUtility::closestCluster
// - If the cluster changed, enqueues FCFOWDataQueue(newCluster)
// - If the pawn left all clusters, enqueues FCFOWDataQueue(true) to clear
// updateFog_sync runs on the game thread:
// - Clears both render targets
// - Rebuilds the dynamic mesh plane to match the cluster bounds
// - Adjusts material scale parameters for non-square clusters
// Perspective change handling:
// FIRT_VIEW -> topView = true, clears the mesh immediately
// TOP_VIEW -> topView = false, fog resumes on next tick