1---2name: ue5-pcg-building3description: UE5.6-UE5.8 PCG building generation workflow for modular buildings, blockouts, facade rules, and runtime generation. Use when requests involve Procedural Content Generation (PCG), Shape Grammar, lot-based building spawn, deterministic random seeds, density/filter pipelines, or converting designer constraints into reusable PCG graphs.4---56# Quick Start7- Define generation target: blockout towers, modular facades, or lot-based building sets.8- Define deterministic inputs: lot splines/points, district tags, style preset, and seed.9- Define runtime mode: static bake, on-demand, or runtime scheduled generation.10- Define output mode: Static Mesh instances first, Spawn Actor only for interactive/stateful parts.1112# API Anchors (UE5.6-UE5.8)13- Runtime trigger and radii live on `UPCGComponent`:14 - `EPCGComponentGenerationTrigger::GenerateAtRuntime`15 - `bOverrideGenerationRadii`, `GenerationRadii`, `SchedulingPolicyClass`, `SchedulingPolicy`16 - `GenerateLocal(...)`, `Cleanup(...)`17- Runtime scheduler refresh lives on `UPCGSubsystem`:18 - UE5.6/UE5.7: `RefreshRuntimeGenComponent(...)`, `RefreshAllRuntimeGenComponents(...)`19 - UE5.8: `RefreshRuntimeGenExecutionSource(...)`, `RefreshAllRuntimeGenExecutionSources(...)`20 - UE5.8 deferred refresh: `DirtyRuntimeGenExecutionSources(...)`21 - Shared cleanup API: `CleanupLocalComponentsImmediate(...)`22- Output selection anchor classes:23 - `UPCGStaticMeshSpawnerSettings` for high-count rendering24 - `UPCGSpawnActorSettings` for interactive/stateful outputs25- Shape Grammar anchor classes:26 - `UPCGSubdivisionBaseSettings::GrammarSelection`27 - Do not rely on deprecated grammar fields (`bGrammarAsAttribute_DEPRECATED`, `Grammar_DEPRECATED`)2829# Graph Stage Contract30- Every stage must explicitly declare:31 - Input data type (`EPCGDataType` or asset source)32 - Core node/classes (minimum two)33 - Required parameters (seed, tags, ranges, radii, or style keys)34 - Output data type35 - Debug method (node-level checks, debug node, or log/assert path)36- If a stage cannot satisfy these five items, treat the graph design as incomplete.3738# Workflow39## 1) Input40- Input data type: actor/spline/point sources.41- Core node/classes: `UPCGDataFromActorSettings`, `UPCGGetActorPropertySettings`, `UPCGCreatePointsSettings`.42- Required parameters: lot tag filters, district/style tags, seed source, source bounds.43- Output: normalized lot point or spline data with stable ordering.44- Debug method: run `UPCGDebugSettings` after input stage and verify point count and bounds.4546## 2) Filter47- Input data type: point/spline data from Input stage.48- Core node/classes: `UPCGAttributeFilteringSettings`, `UPCGDensityFilterSettings`, `UPCGFilterByTagSettings`.49- Required parameters: slope range, exclusion tags, min lot area/width, occupancy constraints.50- Output: only buildable lots/candidates.51- Debug method: compare candidate count before/after filter and inspect rejected tag distribution.5253## 3) Transform54- Input data type: filtered buildable candidates.55- Core node/classes: `UPCGCopyPointsSettings`, `UPCGCreateSplineSettings`, `UPCGApplyScaleToBoundsSettings`.56- Required parameters: floor height, pivot convention, facade orientation basis, local axes.57- Output: footprint transforms and per-floor transforms.58- Debug method: inspect transform axes and floor index attributes on output points.5960## 4) Grammar61- Input data type: segment/spline/point data from Transform stage.62- Core node/classes: `UPCGSubdivideSplineSettings`, `UPCGSubdivideSegmentSettings`, `UPCGSelectGrammarSettings`.63- Required parameters: `GrammarSelection`, module size limits, style-based grammar key mapping.64- Output: grammar-resolved module placements/attributes.65- Debug method: use `UPCGPrintGrammarSettings` for grammar parse and token validation.66- Rule: use `GrammarSelection` only; avoid deprecated grammar fields.6768## 5) Output69- Input data type: grammar-resolved placements.70- Core node/classes: `UPCGStaticMeshSpawnerSettings`, `UPCGSpawnActorSettings`, `UPCGCreateTargetActor`.71- Required parameters:72 - Static path: mesh selector, instance packer, ISM/HISM policy.73 - Actor path: actor class, spawn attributes, state/interaction requirements.74- Output: rendered buildings and optional interactive building elements.75- Debug method: split output by layer/tag and validate per-layer counts.76- Default policy: prefer Static Mesh Spawner; use Spawn Actor only when stateful behavior is required.7778## 6) Validate79- Input data type: final spawned result and runtime generation state.80- Core node/classes: `UPCGDebugSettings`, `UPCGComponent`, `UPCGSubsystem`.81- Required parameters: expected cell bounds, max per-update spawn budget, nav/collision expectations.82- Output: pass/fail signals and fix actions.83- Debug method: run staged checks for overlap, navigation impact, per-cell generation time, and deterministic replay.8485# Constraints86- Keep the main pipeline compatible with UE5.6-UE5.8 unless a version-specific note is required.87- Runtime generation must explicitly set:88 - `GenerationTrigger = GenerateAtRuntime`89 - explicit `GenerationRadii` (do not rely on implicit defaults)90 - explicit `SchedulingPolicyClass` for predictable scheduler behavior91- Prefer ISM/HISM style output for large counts; avoid spawning heavyweight actors for each small part.92- Keep runtime generation bounds explicit to avoid uncontrolled world-wide regeneration.93- Avoid hidden dependency on editor-only data when runtime generation is expected.94- Treat World Partition boundaries as hard constraints for runtime scopes.9596# Failure Handling97- Symptom: no buildings spawn.98 - Locate: Input stage output count, source bounds, lot tags.99 - Fix: verify source actor/spline ingestion and lot filter tags; confirm non-empty candidate set.100- Symptom: output exists in editor preview but not runtime.101 - Locate: `GenerationTrigger` and runtime radii/scheduling settings.102 - Fix: set `GenerateAtRuntime`, radii override, and valid scheduling policy.103- Symptom: runtime update regenerates too wide an area.104 - Locate: runtime radii and generation source movement.105 - Fix: reduce generation/cleanup radii and tighten source bounds.106- Symptom: stale generated pieces remain after rules shrink.107 - Locate: cleanup path and local component lifecycle.108 - Fix: trigger cleanup with remove-components behavior and force local cleanup when needed.109- Symptom: heavy hitching during runtime generation.110 - Locate: points-per-cell, actor spawn count, per-update workload.111 - Fix: reduce per-cell complexity, cap actor spawns, move non-interactive parts to static mesh instances.112- Symptom: deterministic replay mismatch with same seed.113 - Locate: unstable upstream point ordering or non-seeded random branch.114 - Fix: normalize ordering before random selection and bind every stochastic path to explicit seed inputs.115- Symptom: facade grammar fails or produces empty modules.116 - Locate: grammar parse logs and module token mapping.117 - Fix: validate grammar string, module dictionary, and segment size constraints.118- Symptom: overlap and collision issues.119 - Locate: filter thresholds and final placement constraints.120 - Fix: add clearance/slope filters and occupancy rejection before output stage.121- Symptom: navmesh degradation around generated buildings.122 - Locate: collision profile and nav-affecting flags on spawned outputs.123 - Fix: split nav-affecting vs non-nav-affecting outputs and rebuild nav only where required.124- Symptom: runtime changes do not apply after parameter edits.125 - Locate: scheduler refresh flow.126 - Fix: request runtime scheduler refresh for the modified component or all runtime components.127128# Runtime Scheduler Ops129- Use component refresh when one runtime component changed style/radii/scheduling inputs.130- Use global refresh when style/global rules changed for many runtime components.131- Use immediate local cleanup when bounds shrink or partition ownership changed.132- After cleanup, trigger local regeneration only for affected runtime scope.133134# UE5.6-UE5.8 Compatibility Notes135- Core runtime trigger and grammar APIs above are stable in UE5.6-UE5.8.136- UE5.8 adds non-destructive manual editing and complex metadata attribute values; treat these as optional 5.8 capabilities rather than requirements for cross-version graphs.137- Header path difference for subsystem:138 - UE5.6 commonly uses `Public/PCGSubsystem.h`139 - UE5.7/UE5.8 use `Public/Subsystems/PCGSubsystem.h` and include `Subsystems/PCGSubsystem.h`140- UE5.8 deprecates component-named scheduler refresh calls. Use the `IPCGGraphExecutionSource`-based APIs in 5.8 code; retain the component-based calls only for 5.6/5.7 branches.141142# Escalation143- Escalate when architecture requires custom C++ PCG elements or engine plugin extension.144- Escalate when city-scale generation must be integrated with World Partition streaming policy.145- Escalate when generated layout must be synchronized with save/load or multiplayer authority rules.