CMapMaker
Overview
UCMapMaker is the core object responsible for building the minimap. It computes a hexagonal tile grid scaled down from the world room layout, creates an UInstancedStaticMeshComponent with one instance per hex tile, and encodes cluster/room identity into per-instance custom data for material-driven rendering.
The build pipeline is asynchronous: drawMap runs off the game thread, enqueues results, and updateMap_sync dequeues and creates ISM instances on the game thread.
Instantiation
| Name | Description |
|---|---|
| instantiate | Static factory. Creates the UCMapMaker singleton, stores scene component, stream, config, and creates a UCSplinator for spline borders |
// Called by ACMapSpawner::init():
UCMapMaker::instantiate(GetRootComponent(), mapMaker, stream, mapMakerStruct);
// Internally creates the maker via createObjectSingletonAtRuntime
// and initializes a UCSplinator for optional spline border rendering.
Build Pipeline
| Name | Description |
|---|---|
| buildASync | Entry point called by the spawner. Runs drawMap async then updateMap_sync on game thread |
| wantDraw | Guards against redundant draws: returns false if queue is not empty or map is already built |
| drawMap | Enqueues map data for processing (currently a placeholder for future expansion) |
| updateMap_sync | Dequeues data, computes hex grid from room layout, creates ISM instances |
// buildASync is called each tick by ACMapSpawner:
mapMaker->buildASync(singleDoRun);
// Internally:
// 1. wantDraw() checks if a new draw pass is needed
// 2. drawMap() enqueues FCMapDataQueue batches (async)
// 3. updateMap_sync() dequeues and builds the ISM hex grid (game thread)
Hex Grid Generation
The updateMap_sync method performs the following steps:
- Scales the root cluster rectangle by
mapScale(0.125) - Iterates all cluster rooms via
RoomUtility::iterateOnClusterRoom, building a location map of room centers - Converts the cluster bounding box to axial hex coordinates using
FCTile::pixelToHexCoord - Creates or clears an
UInstancedStaticMeshComponentwith the configuredtileMesh - Iterates the hex grid row by row, converting each axial coordinate back to pixel space via
FCTile::hexCoordToPixel - For each tile, finds the closest room and writes
clusterId * 0.03 + roomId * 0.07as custom data for material use
// The hex grid uses FCTile utilities from CCOREUMODULE:
FVector2D axialStart = FCTile::pixelToHexCoord(rootCluster.bb.X, rootCluster.bb.Y, tileMeshSize);
FVector2D axialEnd = FCTile::pixelToHexCoord(rootCluster.aa.X, rootCluster.aa.Y, tileMeshSize);
// Each ISM instance gets 1 custom data float (NumCustomDataFloats = 1)
// encoding cluster/room identity for the material shader.