1---2name: ue5-pcg-building3description: UE5.6/UE5.7 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# UE5.7 API Anchors13- 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 - `RefreshRuntimeGenComponent(...)`19 - `RefreshAllRuntimeGenComponents(...)`20 - `CleanupLocalComponentsImmediate(...)`21- Output selection anchor classes:22 - `UPCGStaticMeshSpawnerSettings` for high-count rendering23 - `UPCGSpawnActorSettings` for interactive/stateful outputs24- Shape Grammar anchor classes:25 - `UPCGSubdivisionBaseSettings::GrammarSelection`26 - Do not rely on deprecated grammar fields (`bGrammarAsAttribute_DEPRECATED`, `Grammar_DEPRECATED`)2728# Graph Stage Contract29- Every stage must explicitly declare:30 - Input data type (`EPCGDataType` or asset source)31 - Core node/classes (minimum two)32 - Required parameters (seed, tags, ranges, radii, or style keys)33 - Output data type34 - Debug method (node-level checks, debug node, or log/assert path)35- If a stage cannot satisfy these five items, treat the graph design as incomplete.3637# Workflow38## 1) Input39- Input data type: actor/spline/point sources.40- Core node/classes: `UPCGDataFromActorSettings`, `UPCGGetActorPropertySettings`, `UPCGCreatePointsSettings`.41- Required parameters: lot tag filters, district/style tags, seed source, source bounds.42- Output: normalized lot point or spline data with stable ordering.43- Debug method: run `UPCGDebugSettings` after input stage and verify point count and bounds.4445## 2) Filter46- Input data type: point/spline data from Input stage.47- Core node/classes: `UPCGAttributeFilteringSettings`, `UPCGDensityFilterSettings`, `UPCGFilterByTagSettings`.48- Required parameters: slope range, exclusion tags, min lot area/width, occupancy constraints.49- Output: only buildable lots/candidates.50- Debug method: compare candidate count before/after filter and inspect rejected tag distribution.5152## 3) Transform53- Input data type: filtered buildable candidates.54- Core node/classes: `UPCGCopyPointsSettings`, `UPCGCreateSplineSettings`, `UPCGApplyScaleToBoundsSettings`.55- Required parameters: floor height, pivot convention, facade orientation basis, local axes.56- Output: footprint transforms and per-floor transforms.57- Debug method: inspect transform axes and floor index attributes on output points.5859## 4) Grammar60- Input data type: segment/spline/point data from Transform stage.61- Core node/classes: `UPCGSubdivideSplineSettings`, `UPCGSubdivideSegmentSettings`, `UPCGSelectGrammarSettings`.62- Required parameters: `GrammarSelection`, module size limits, style-based grammar key mapping.63- Output: grammar-resolved module placements/attributes.64- Debug method: use `UPCGPrintGrammarSettings` for grammar parse and token validation.65- Rule: use `GrammarSelection` only; avoid deprecated grammar fields.6667## 5) Output68- Input data type: grammar-resolved placements.69- Core node/classes: `UPCGStaticMeshSpawnerSettings`, `UPCGSpawnActorSettings`, `UPCGCreateTargetActor`.70- Required parameters:71 - Static path: mesh selector, instance packer, ISM/HISM policy.72 - Actor path: actor class, spawn attributes, state/interaction requirements.73- Output: rendered buildings and optional interactive building elements.74- Debug method: split output by layer/tag and validate per-layer counts.75- Default policy: prefer Static Mesh Spawner; use Spawn Actor only when stateful behavior is required.7677## 6) Validate78- Input data type: final spawned result and runtime generation state.79- Core node/classes: `UPCGDebugSettings`, `UPCGComponent`, `UPCGSubsystem`.80- Required parameters: expected cell bounds, max per-update spawn budget, nav/collision expectations.81- Output: pass/fail signals and fix actions.82- Debug method: run staged checks for overlap, navigation impact, per-cell generation time, and deterministic replay.8384# Constraints85- Keep the main pipeline compatible with both UE5.6 and UE5.7 unless a version-specific note is required.86- Runtime generation must explicitly set:87 - `GenerationTrigger = GenerateAtRuntime`88 - explicit `GenerationRadii` (do not rely on implicit defaults)89 - explicit `SchedulingPolicyClass` for predictable scheduler behavior90- Prefer ISM/HISM style output for large counts; avoid spawning heavyweight actors for each small part.91- Keep runtime generation bounds explicit to avoid uncontrolled world-wide regeneration.92- Avoid hidden dependency on editor-only data when runtime generation is expected.93- Treat World Partition boundaries as hard constraints for runtime scopes.9495# Failure Handling96- Symptom: no buildings spawn.97 - Locate: Input stage output count, source bounds, lot tags.98 - Fix: verify source actor/spline ingestion and lot filter tags; confirm non-empty candidate set.99- Symptom: output exists in editor preview but not runtime.100 - Locate: `GenerationTrigger` and runtime radii/scheduling settings.101 - Fix: set `GenerateAtRuntime`, radii override, and valid scheduling policy.102- Symptom: runtime update regenerates too wide an area.103 - Locate: runtime radii and generation source movement.104 - Fix: reduce generation/cleanup radii and tighten source bounds.105- Symptom: stale generated pieces remain after rules shrink.106 - Locate: cleanup path and local component lifecycle.107 - Fix: trigger cleanup with remove-components behavior and force local cleanup when needed.108- Symptom: heavy hitching during runtime generation.109 - Locate: points-per-cell, actor spawn count, per-update workload.110 - Fix: reduce per-cell complexity, cap actor spawns, move non-interactive parts to static mesh instances.111- Symptom: deterministic replay mismatch with same seed.112 - Locate: unstable upstream point ordering or non-seeded random branch.113 - Fix: normalize ordering before random selection and bind every stochastic path to explicit seed inputs.114- Symptom: facade grammar fails or produces empty modules.115 - Locate: grammar parse logs and module token mapping.116 - Fix: validate grammar string, module dictionary, and segment size constraints.117- Symptom: overlap and collision issues.118 - Locate: filter thresholds and final placement constraints.119 - Fix: add clearance/slope filters and occupancy rejection before output stage.120- Symptom: navmesh degradation around generated buildings.121 - Locate: collision profile and nav-affecting flags on spawned outputs.122 - Fix: split nav-affecting vs non-nav-affecting outputs and rebuild nav only where required.123- Symptom: runtime changes do not apply after parameter edits.124 - Locate: scheduler refresh flow.125 - Fix: request runtime scheduler refresh for the modified component or all runtime components.126127# Runtime Scheduler Ops128- Use component refresh when one runtime component changed style/radii/scheduling inputs.129- Use global refresh when style/global rules changed for many runtime components.130- Use immediate local cleanup when bounds shrink or partition ownership changed.131- After cleanup, trigger local regeneration only for affected runtime scope.132133# UE5.6 / UE5.7 Compatibility Notes134- Core runtime trigger and grammar APIs above are stable in UE5.6 and UE5.7.135- Header path difference for subsystem:136 - UE5.6 commonly uses `Public/PCGSubsystem.h`137 - UE5.7 commonly uses `Public/Subsystems/PCGSubsystem.h`138139# Escalation140- Escalate when architecture requires custom C++ PCG elements or engine plugin extension.141- Escalate when city-scale generation must be integrated with World Partition streaming policy.142- Escalate when generated layout must be synchronized with save/load or multiplayer authority rules.