ue-mcp-plugin-voxel-plugin 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/Voxel.md ADDED
@@ -0,0 +1,450 @@
1
+ # Voxel — API Reference
2
+
3
+ The gameplay-facing module. Everything users actually place into a level — voxel worlds, stamps, layers, materials, sculpt tools, scatter — lives here. This is by far the largest module by surface area; ~14 subfolders under `Public/` plus ~60 root headers.
4
+
5
+ Path: `Plugins/Voxel/Source/Voxel/Public/`. Loads at `PostConfigInit`. Depends on `VoxelGraph`, `Chaos`, `Renderer`, `PhysicsCore`, `Landscape`, `NavigationSystem`, `PCG`, `MeshDescription`.
6
+
7
+ Official knowledgebase covering usage (not API): <https://docs.voxelplugin.com/knowledgebase>. The KB sections on **Working with Stamps**, **Surface Types & Metadata**, and **Gameplay Systems & Blueprint API** are the natural companions to this page.
8
+
9
+ ## Top-level flow
10
+
11
+ ```
12
+ AVoxelWorld (actor)
13
+
14
+ ├── FVoxelConfig ← cached settings snapshot
15
+ ├── FVoxelRuntime ← ticker + state machine
16
+ │ └── FVoxelState ← immutable per-generation snapshot
17
+ │ ├── FVoxelStampManager ← layer → stamp registry
18
+ │ ├── FVoxelRenderSubsystem ← mesh proxies, Nanite
19
+ │ ├── FVoxelCollisionSubsystem
20
+ │ ├── FVoxelNavigationSubsystem
21
+ │ └── FVoxelScatterSubsystem
22
+
23
+ ├── UVoxelLayerStack ← what layers exist
24
+ └── UVoxelMegaMaterial ← surface-type catalogue + shader
25
+ ```
26
+
27
+ A user authors **stamps** (sculpt strokes, spline curves, heightmaps, graphs). Stamps go into **layers** (height or volume). At runtime, the **stamp manager** snapshots the layer contents into a **state**, and **subsystems** evaluate that state into render meshes, colliders, and navmesh.
28
+
29
+ ## World and runtime
30
+
31
+ ### `AVoxelWorld`
32
+
33
+ The actor users drop into a level. Configuration is Blueprint-exposed and small enough to enumerate:
34
+
35
+ | Property | Type | Notes |
36
+ |---|---|---|
37
+ | `VoxelSize` | `int32` (cm, ≥1) | Edge length of one voxel. |
38
+ | `LODQuality` | `FVoxelLODQuality` | Min/max quality tiers — mesh starts at min and refines up. |
39
+ | `QualityExponent` | `double` | LOD bias; higher → further chunks stay high-res. |
40
+ | `MegaMaterial` | `UVoxelMegaMaterial*` | Global material catalogue. |
41
+ | `LayerStack` | `UVoxelLayerStack*` | The layers this world reads. |
42
+ | `bEnableNanite` | `bool` | Switch between Nanite and traditional mesh components. |
43
+ | `bCreateRuntimeOnBeginPlay` | `bool` | If false, call `CreateRuntime` manually. |
44
+ | `bWaitOnBeginPlay` | `bool` | If true, `BeginPlay` blocks until the first generation pass completes. |
45
+ | `bWaitForPCG` | `bool` | If true, generation also waits on PCG completion. |
46
+ | `bLimitMaxLOD` / `MaxLOD` | `bool`/`int32` | Cap rendered LOD. |
47
+ | `MaxBackgroundTasks` | `int32` | Worker concurrency cap. |
48
+
49
+ Notable methods (paraphrased): `CreateRuntime()`, `DestroyRuntime()`, `IsVoxelWorldReady()`, `GetRuntime()`. The runtime also dispatches a dynamic `FOnVoxelWorldEvent` for ready-state transitions.
50
+
51
+ The world owns a `UVoxelWorldRootComponent` for transform/replication.
52
+
53
+ ### `FVoxelRuntime`
54
+
55
+ The ticker. Owns current/next `FVoxelState`s and the worker components (mesh, collision, nav). Adds/removes components dynamically as LOD shifts.
56
+
57
+ ```cpp
58
+ TSharedPtr<FVoxelState> GetState(); // currently rendered
59
+ TSharedPtr<FVoxelState> GetNewState(); // being computed
60
+ template<typename T> T* NewComponent(); // add a runtime component
61
+ void RemoveComponent(UActorComponent*);
62
+ FSimpleMulticastDelegate OnInvalidated;
63
+ ```
64
+
65
+ ### `FVoxelState`
66
+
67
+ Immutable per-generation snapshot — bundles `FVoxelConfig`, the resolved layers, the surface-type table, and the task context. Subsystems pin a `FVoxelState` for the duration of their work so concurrent re-generation doesn't mutate under them.
68
+
69
+ ```cpp
70
+ template<typename T> T& GetSubsystem(); // typed access to FVoxelSubsystem
71
+ bool IsReadyToRender();
72
+ bool IsRendered();
73
+ ```
74
+
75
+ ### `FVoxelConfig` / `VoxelSettings.h` / `VoxelComponentSettings.h` / `FVoxelLODQuality`
76
+
77
+ Configuration plumbing: world-level cached settings, per-component overrides, the project-settings panel, and the min/max LOD tier struct.
78
+
79
+ ### `FVoxelSubsystem` (`VoxelSubsystem.h`)
80
+
81
+ Virtual-struct base for everything pluggable (stamps, render, collision, nav, scatter). Lifecycle: `LoadFromPrevious(FVoxelSubsystem&)`, `Initialize(FVoxelState&)`, `Compute(FVoxelState&)`, `Render(FVoxelState&)`. `UVoxelSubsystemGCObject` is the small helper that keeps subsystem-held `UObject` refs alive across state transitions.
82
+
83
+ ### Misc world-level
84
+
85
+ - **`VoxelChunkKey.h`** — `FVoxelChunkKey`: `(LOD, IntVector position)`, with parent/child traversal.
86
+ - **`VoxelDebugActor.h`** — visualizer placeholder.
87
+ - **`VoxelCellGenerator.h`** — low-level cell iteration helper.
88
+ - **`VoxelBreadcrumbs.h`** — `FVoxelBreadcrumbs`: traces *which* stamps/layers contributed to a sampled voxel, for debugging "why is this terrain wrong?".
89
+ - **`VoxelValuesDump.h`** — dump value grids to disk for offline inspection.
90
+ - **`VoxelVersion.h`** — version tracking for asset migration.
91
+
92
+ ## Stamps
93
+
94
+ The central authoring primitive. A **stamp** is a piece of data (a sculpt brush stroke, a spline, a heightmap, a graph) that contributes to one or more layers. Stamps stack, blend, and prioritize.
95
+
96
+ KB: <https://docs.voxelplugin.com/knowledgebase/working-with-stamps/>.
97
+
98
+ ### `FVoxelStamp` (virtual struct base)
99
+
100
+ ```cpp
101
+ FTransform Transform;
102
+ EVoxelStampBehavior Behavior; // bitmask: AffectShape | AffectSurfaceType | AffectMetadata
103
+ int32 Priority; // higher = applied later
104
+ float Smoothness; // falloff radius
105
+ TInterval<int32> LODRange; // inclusive LODs this stamp affects
106
+ ```
107
+
108
+ Plus virtual `FixupProperties()` (normalize after deserialize), `GetAsset()`, `GetRequiredComponents()`.
109
+
110
+ ### Stamp categories
111
+
112
+ | Folder | Stamp class(es) | Source |
113
+ |---|---|---|
114
+ | `Shape/` | `FVoxelShapeStamp` wrapping `FVoxelCubeShape`, `FVoxelSphereShape`, `FVoxelPlaneShape` | Geometric primitives. KB: Shape Stamps. |
115
+ | `Spline/` | `FVoxelSplineStamp` (height + volume variants) | Curve-driven; pulls control points from `UVoxelSplineComponent`. `FVoxelSplineSegment` is the runtime baked segment. KB: Spline Stamps. |
116
+ | `Sculpt/Height/` | `FVoxelHeightSculptStamp` | Persistent painted/sculpted brush data. Saved as `UVoxelHeightSculptSaveAsset`. KB: Sculpt Stamps. |
117
+ | `Sculpt/Volume/` | `FVoxelVolumeSculptStamp` | Same for volumes. |
118
+ | `Heightmap/` | `FVoxelHeightmapStamp` | Heightmap texture → height layer. |
119
+ | `StaticMesh/` | `FVoxelMeshStamp` | Voxelizes a `UStaticMesh` into a layer. |
120
+ | `Graphs/` | `FVoxelHeightGraphStamp`, `FVoxelVolumeGraphStamp` | Executes a `UVoxelHeightGraph` / `UVoxelVolumeGraph` to produce values per-voxel. |
121
+
122
+ All concrete stamps derive from either `FVoxelHeightStamp` or `FVoxelVolumeStamp`:
123
+
124
+ ```cpp
125
+ struct FVoxelHeightStamp : FVoxelStamp
126
+ {
127
+ UVoxelHeightLayer* Layer;
128
+ EVoxelHeightBlendMode BlendMode; // Max/Min/Override/Add/Subtract/Multiply/Smooth/...
129
+ TArray<UVoxelHeightLayer*> AdditionalLayers;
130
+ };
131
+
132
+ struct FVoxelVolumeStamp : FVoxelStamp
133
+ {
134
+ UVoxelVolumeLayer* Layer;
135
+ EVoxelVolumeBlendMode BlendMode; // Additive/Subtractive/Intersect/ReplaceIfSmaller
136
+ };
137
+ ```
138
+
139
+ Blend-mode enums: `VoxelHeightBlendMode.h`, `VoxelVolumeBlendMode.h`. Blend logic: `VoxelBlendModeUtilities.h`. KB has a full page on blend mode semantics and override stamps.
140
+
141
+ ### Stamp refs
142
+
143
+ Stamps are stored polymorphically. The handle types in `VoxelStampRef.h` / `VoxelStampRefInner.h` / `VoxelWeakStampRef.h` provide type-safe shared/weak ownership:
144
+
145
+ ```cpp
146
+ FVoxelStampRef ref = ...;
147
+ FVoxelHeightStampRef heightRef = ref.CastTo<FVoxelHeightStamp>();
148
+ FVoxelStampRef copy = ref.MakeCopy();
149
+ TSharedPtr<FVoxelHeightStamp> ptr = heightRef.ToSharedPtr<FVoxelHeightStamp>();
150
+ ```
151
+
152
+ `GENERATED_VOXEL_STAMP_REF_BODY` (macro) auto-generates the typed wrappers for any concrete stamp type. `FVoxelStampDelta` carries before/after deltas for change detection.
153
+
154
+ `_K2` variants (`VoxelStamp_K2.h`, `VoxelHeightStamp_K2.h`, `VoxelVolumeStamp_K2.h`) wrap the structs for Blueprint reflection.
155
+
156
+ ### Actor / component tier
157
+
158
+ ```cpp
159
+ UVoxelStampComponentBase ← shared base
160
+ ├── UVoxelStampComponent single stamp; UPROPERTY split via SplitStampProperties
161
+ ├── UVoxelInstancedStampComponent TArray<FVoxelStampRef>; batch add/remove/update
162
+ └── UVoxelStampMeshPreviewComponent (editor gizmo)
163
+
164
+ AVoxelStampActor wraps a UVoxelStampComponent for standalone placement
165
+ ```
166
+
167
+ `UVoxelStampComponentInterface` is the contract anything implementing stamp-like behavior follows. `UVoxelStampBehavior` exposes the behavior bitmask to BP.
168
+
169
+ `UVoxelStampBlueprintFunctionLibrary` — `CastToStamp<T>()` and friends for BP.
170
+
171
+ ### Stamp manager and runtime
172
+
173
+ `FVoxelStampManager` (`VoxelStampManager.h`) is the world subsystem that:
174
+
175
+ 1. Holds a registry of all `FVoxelStampRef`s currently active, keyed by layer.
176
+ 2. Lazily resolves each `FVoxelStampRef` → `FVoxelStampIndex` → `FVoxelStampRuntime` (the serialized, applyable form).
177
+ 3. Fires `OnChanged` whenever the registry mutates so dependent subsystems can invalidate.
178
+
179
+ ```cpp
180
+ void RegisterStamps(layerId, refs);
181
+ void UnregisterStamps(layerId, refs);
182
+ void UpdateStamp(layerId, ref);
183
+ auto& FindOrAddLayer(layerId) -> FVoxelStampLayerManager&;
184
+ auto ResolveStampRuntime(FVoxelStampIndex) -> FVoxelStampRuntime*;
185
+ FSimpleMulticastDelegate OnChanged;
186
+ ```
187
+
188
+ Supporting headers: `VoxelStampIndex`, `VoxelStampQuery`, `VoxelStampQueryImpl.isph` (ISPC), `VoxelStampTransform`, `VoxelStampTransformImpl.isph`, `VoxelStampUtilities`, `VoxelStampRuntime`, `VoxelHeightStampRuntime` / `VoxelVolumeStampRuntime` (the per-type runtime), `VoxelInstancedStampComponent`.
189
+
190
+ ## Layers
191
+
192
+ KB context: stamps live *in* layers; layers stack in priority order on the world.
193
+
194
+ ### Definitions
195
+
196
+ - **`UVoxelLayer`** — abstract base. Identifies a conceptual channel.
197
+ - **`UVoxelHeightLayer`** — heightfield-style (one elevation per X/Y).
198
+ - **`UVoxelVolumeLayer`** — volumetric (signed-distance field).
199
+ - **`UVoxelLayerStack`** — ordered container:
200
+ ```cpp
201
+ TArray<UVoxelHeightLayer*> HeightLayers;
202
+ TArray<UVoxelVolumeLayer*> VolumeLayers;
203
+ float MaxDistance; // distance-field extent for height layers
204
+ FSimpleMulticastDelegate OnChanged;
205
+ ```
206
+ - **`FVoxelStackLayer`** / **`VoxelLayerStack.h`** — runtime wrapper holding a weak layer pointer plus owner-world reference. Used in `FVoxelQuery` and the no-clipping component.
207
+ - **`VoxelLayerBase.h`** — shared layer-side internals.
208
+ - **`VoxelLayers.h`** — internal layer-to-index registry inherited from `FVoxelSubsystem`.
209
+
210
+ ## Metadata
211
+
212
+ Per-voxel attributes layered on top of the geometric values.
213
+
214
+ | Header | Class | Inner type | Notes |
215
+ |---|---|---|---|
216
+ | `VoxelMetadata.h` | `UVoxelMetadata` | (abstract) | Asset declaring a metadata channel. |
217
+ | `VoxelFloatMetadata.h` | `UVoxelFloatMetadata` | `float` | Packing modes: 1-byte (0..1), 2-byte (fp16), 4-byte. |
218
+ | `VoxelLinearColorMetadata.h` | `UVoxelLinearColorMetadata` | `FLinearColor` | RGBA. |
219
+ | `VoxelNormalMetadata.h` | `UVoxelNormalMetadata` | `FVector` | Octahedral encoding. |
220
+
221
+ Each has a matching `*MetadataRef.h` (`FVoxelFloatMetadataRef`, etc.) — type-erased handles backed by buffer storage. `FVoxelMetadataRef` is the polymorphic base.
222
+
223
+ `VoxelMetadataMaterialType.h` — `EVoxelMetadataMaterialType` enum for the GPU packing strategy. `VoxelMetadataOverrides.h` — per-stamp metadata-value override map.
224
+
225
+ KB: <https://docs.voxelplugin.com/knowledgebase/materials/working-with-metadata.html>.
226
+
227
+ ## MegaMaterial
228
+
229
+ `UVoxelMegaMaterial` (`MegaMaterial/` subfolder) is a multi-surface material container that the world references via its `MegaMaterial` property.
230
+
231
+ Properties:
232
+
233
+ - `SurfaceTypes` (`TArray<UVoxelSurfaceTypeAsset*>`) — the catalogue.
234
+ - `bDetectNewSurfaces` — editor warning when a graph emits an unknown type.
235
+ - `CustomNonNaniteMaterial`, `CustomNaniteDisplacementMaterial` — override the generated material at either tier.
236
+ - `AttributePostProcess` — global material function applied after attribute resolution.
237
+ - `bEnableSmoothBlends`, `bGenerateMaskedMaterial`, `bSetHasPixelAnimation` — quality flags.
238
+
239
+ Companions:
240
+
241
+ - `UVoxelMegaMaterialProxy` / `UVoxelMegaMaterialCache` — runtime caching + compile pipeline.
242
+ - Material expressions for shader use: `MaterialExpressionGetVoxelMaterialInfo`, `MaterialExpressionGetVoxelMetadata`, `MaterialExpressionGetVoxelFlatNormal`, `MaterialExpressionGetVoxelRandom`, `MaterialExpressionVoxelLayer`.
243
+
244
+ KB: <https://docs.voxelplugin.com/knowledgebase/materials/working-with-materials/>.
245
+
246
+ ## Surface types
247
+
248
+ In `Surface/`:
249
+
250
+ | Type | Purpose |
251
+ |---|---|
252
+ | `FVoxelSurfaceType` | Lightweight `uint16` handle. Resolves to an asset or a smart-surface generator. API: `GetSurfaceTypeAsset()`, `GetSmartSurfaceType()`, `GetName()`, `GetDebugColor()`. Serialized into voxel metadata. |
253
+ | `UVoxelSurfaceTypeAsset` | Concrete surface (physical material, visual params). |
254
+ | `UVoxelSmartSurfaceType` | Procedural surface — derives its identity from inputs (slope, height, layer). KB: Smart Surface Types. |
255
+ | `UVoxelSurfaceTypeBlend` / `FVoxelSurfaceTypeBlendBuffer` | Runtime blend of multiple surface types with alpha weights; bulk-buffer form for queries. |
256
+ | `UVoxelSurfaceTypeTable` | Runtime registry holding ID ↔ asset mappings (lives on `FVoxelState`). |
257
+ | `UVoxelSmartSurfaceFunctionLibrary` | Blueprint surface queries and preview helpers. |
258
+
259
+ ## Render
260
+
261
+ In `Render/`:
262
+
263
+ - **`UVoxelMeshComponent`** (`UPrimitiveComponent`) — pure rendering, no physics. Holds a `TSharedPtr<FVoxelMeshRenderProxy>`. Updated via `SetRenderProxy()` / `ClearRenderProxy()` from the runtime. Scene proxy resolves materials through `FVoxelMaterialRef`.
264
+ - **`UVoxelRenderSubsystem`** — owns mesh generation pipeline, LOD selection, material dispatch.
265
+
266
+ `VoxelMesh.h` declares `FVoxelMesh` — a lightweight CPU-side mesh descriptor (vertices, indices, LOD).
267
+
268
+ ## Collision
269
+
270
+ In `Collision/`:
271
+
272
+ - **`UVoxelCollisionComponent`** — pure physics, no rendering. `SetCollider(TSharedRef<FVoxelCollider>)`. Geometry comes from a baked `UBodySetup`.
273
+ - **`UVoxelCollisionInvoker`** — invoker-pattern component: requests collision generation within a radius. Without invokers, no collision is generated.
274
+ - **`FVoxelCollisionBaker`** — distance-field → physics geometry conversion.
275
+ - **`UVoxelInvokerCollisionSubsystem`** — tracks invokers, schedules generation/destruction.
276
+ - **`VoxelCollisionChannels.h`** — channel/profile presets.
277
+
278
+ KB: <https://docs.voxelplugin.com/knowledgebase/blueprints/collision-navmesh-and-invokers.html>.
279
+
280
+ ## Navigation
281
+
282
+ In `Navigation/`:
283
+
284
+ - **`UVoxelNavigationComponent`** — exports custom navmesh geometry.
285
+ - **`UVoxelNavigationInvoker`** — invoker for on-demand navmesh generation.
286
+ - **`FVoxelNavigationMesh`** — per-LOD runtime navmesh.
287
+ - **`UVoxelNavigationSubsystem`** — manages caching, invoker tiling, `OnlineGraph` integration.
288
+
289
+ ## Nanite
290
+
291
+ In `Nanite/`:
292
+
293
+ - **`UVoxelNaniteComponent`** — alternative to `UVoxelMeshComponent` when `bEnableNanite` is true. GPU-driven rendering with displacement-fade and raytracing integration.
294
+
295
+ Tunables live on `FVoxelConfig`: `NaniteMaxTessellationLOD`, `bCompressNaniteVertices`, `NanitePositionPrecision`.
296
+
297
+ ## Sculpt
298
+
299
+ In `Sculpt/`:
300
+
301
+ - **`VoxelSculptActorBase.h`** — common actor base.
302
+ - **`VoxelChannel.h`** — `EVoxelChannel` (Height, Distance, …).
303
+ - **`VoxelTool.h`** / **`VoxelToolBrush.h`** — brush-shape and falloff parameter structs.
304
+ - **`VoxelSculptMode.h`** — `EVoxelSculptMode` (Sculpt, Flatten, Paint, Smooth, …).
305
+ - **`Sculpt/Height/`** — `AVoxelHeightSculptActor`, `FVoxelHeightSculptStamp`, the per-mode tool structs (`FVoxelSculptHeightTool`, `FVoxelFlattenHeightTool`, `FVoxelPaintHeightTool`, `FVoxelSmoothHeightTool`), `UVoxelHeightSculptBlueprintLibrary`, save asset (`UVoxelHeightSculptSaveAsset`).
306
+ - **`Sculpt/Volume/`** — analogous volume tools.
307
+
308
+ KB: <https://docs.voxelplugin.com/knowledgebase/blueprints/runtime-edits-and-sculpting.html>.
309
+
310
+ ## Shape
311
+
312
+ In `Shape/`:
313
+
314
+ - `FVoxelShape` (virtual struct) with `Sample()` for distance evaluation.
315
+ - Concrete: `FVoxelCubeShape`, `FVoxelSphereShape`, `FVoxelPlaneShape` (plus `_K2` variants).
316
+ - `FVoxelShapeStamp` wraps a shape with transform and blend properties.
317
+ - `UVoxelShapeFunctionLibrary` — Blueprint helpers.
318
+
319
+ ## Spline
320
+
321
+ In `Spline/`:
322
+
323
+ - `UVoxelSplineComponent` (extends `USplineComponent`) with extra per-control-point metadata and a runtime `TVoxelArray<FVoxelSplineSegment>` baked from the editor curve.
324
+ - `UVoxelSplineMetadata` — per-control-point custom metadata (float / vector channels).
325
+ - `UVoxelSplineGraphParameters` — exposes spline-driven parameters to voxel graphs.
326
+ - `FVoxelSplineStamp` (height + volume variants) — applies sampled values along the curve with interpolated blend properties.
327
+ - `FVoxelSplineStampFunctionLibrary` — Blueprint sampling.
328
+
329
+ ## StaticMesh
330
+
331
+ In `StaticMesh/`:
332
+
333
+ - `FVoxelMeshStamp` — voxelizes a `UStaticMesh` (or skeletal mesh) into a layer; rasterization method + detail level.
334
+ - `UVoxelStaticMesh` — cached, optimized mesh data ready for voxelization.
335
+ - `FVoxelMeshVoxelizer` — core mesh → SDF/density algorithm.
336
+ - `UVoxelStaticMeshFunctionLibrary` — Blueprint utilities.
337
+
338
+ ## Heightmap
339
+
340
+ In `Heightmap/`:
341
+
342
+ - `UVoxelHeightmap` — top-level asset bundling height + optional weight layers. `ScaleXY` (cm per texel).
343
+ - `UVoxelHeightmap_Height`, `UVoxelHeightmap_Weight` — sub-assets storing the raw pixel data.
344
+ - `FVoxelHeightmapStamp` — applies a heightmap as a stamp.
345
+ - `UVoxelHeightmapFunctionLibrary` — import/export.
346
+
347
+ ## Texture
348
+
349
+ In `Texture/`:
350
+
351
+ - `UVoxelTexture` — runtime texture asset (typically 3-D or RVT-backed).
352
+ - `UVoxelTextureFunctionLibrary` — sample voxel textures, write to RVT.
353
+ - `UVoxelTextureBlueprintLibrary` — higher-level query API.
354
+
355
+ ## Graphs (specialized)
356
+
357
+ In `Graphs/` — note this is the **runtime stamp-producing** graph types, *not* the `VoxelGraph` module that defines the asset and compile pipeline.
358
+
359
+ - **`UVoxelHeightGraph`** / **`UVoxelVolumeGraph`** — custom graphs that emit height/volume samples.
360
+ - **`FVoxelHeightGraphStamp`** / **`FVoxelVolumeGraphStamp`** — stamps that execute those graphs at runtime.
361
+ - Output nodes (`UVoxelOutputNode_OutputHeight`, `_OutputVolume`, `_OutputSurface`, `_OutputHeightSpline`, `_OutputVolumeSpline`) — the terminals graphs use to write into layers.
362
+ - `FVoxelSampleStampNodes`, `FVoxelSamplePreviousStampsNodes` — read what earlier stamps already wrote (the "previous nodes" feature that the KB calls out in Override Stamps).
363
+ - `UVoxelParameterBlueprintLibrary` — expose graph parameters to BP.
364
+
365
+ ## Scatter
366
+
367
+ In `Scatter/`:
368
+
369
+ - **`UVoxelScatterGraph`** — graph asset defining placement (position, rotation, scale, actor class).
370
+ - **`UVoxelScatterActor`** / **`UVoxelScatterActorRuntime`** — in-world scatter placement actor + runtime.
371
+ - `FVoxelScatterNodeRef` / `FVoxelScatterNodeRuntime` — instance handles and runtime execution.
372
+ - `UVoxelScatterManager` — manages spawned instances.
373
+ - `FVoxelScatterSubsystem` (`FVoxelSubsystem`) — caches node runtimes and triggers re-scattering on invalidation.
374
+ - `UVoxelScatterFunctionLibrary` — BP API for queries and filtering.
375
+
376
+ ## Query API
377
+
378
+ The CPU-side sampling interface.
379
+
380
+ ### `FVoxelQuery` (`VoxelQuery.h`)
381
+
382
+ ```cpp
383
+ int32 LOD;
384
+ FVoxelLayers& Layers;
385
+ FVoxelSurfaceTypeTable& SurfaceTypeTable;
386
+ FVoxelDependencyCollector* DependencyCollector; // optional
387
+
388
+ FVoxelFloatBuffer SampleHeightLayer(FVoxelWeakStackLayer, Positions, ...);
389
+ FVoxelFloatBuffer SampleVolumeLayer(FVoxelWeakStackLayer, Positions, ...);
390
+ bool HasStamps(layer, FVoxelBox bounds, EVoxelStampBehavior mask);
391
+ FVoxelWeakStackLayer GetFirstHeightLayer(layer);
392
+ ```
393
+
394
+ The `DependencyCollector` integration ties query results into the [VoxelCore dependency-tracking machinery](VoxelCore.md#dependency-tracking) — anything that calls `SampleHeightLayer` automatically subscribes to layer invalidation.
395
+
396
+ ### `UVoxelQueryBlueprintLibrary` / `..._K2.h`
397
+
398
+ Blueprint-facing wrappers:
399
+
400
+ - `FVoxelFloatQuery`, `FVoxelColorQuery`, `FVoxelQueryResult` — request/response structs.
401
+ - `SampleHeightTexture()`, `SampleVolumeTexture()` — render results into a `UTextureRenderTarget2D`. KB has a page on writing voxel data to render targets.
402
+
403
+ ### `UVoxelQueryDebugDrawer`
404
+
405
+ Editor visualizer for query geometry (bounds, points, traces).
406
+
407
+ KB: <https://docs.voxelplugin.com/knowledgebase/blueprints/querying-voxel-graphs.html>.
408
+
409
+ ## Character integration
410
+
411
+ - **`AVoxelCharacter`** — example `ACharacter` subclass with a corrected `SetBase()` that delegates to the root component for replication. Useful as a reference, even if your project rolls its own pawn.
412
+ - **`UVoxelNoClippingComponent`** — anti-tunneling for pawns on deforming terrain. Queries the configured layer; if the pawn ends up inside terrain, teleports to a safe location. Properties: `Layer` (`FVoxelStackLayer`), `bAutoAdjustPlayer`. Delegate: `OnTeleported`.
413
+
414
+ > `AVoxelCharacter` is a reference example, not a drop-in — and it derives from `ACharacter`. If your project's pawn is not an `ACharacter` subclass (e.g., a `Mover`-based `APawn`), you cannot inherit from `AVoxelCharacter`; reproduce the `SetBase()` fix on your own base instead. `UVoxelNoClippingComponent` works on any actor with a root component, regardless of pawn lineage.
415
+
416
+ ## Stamp type quick reference
417
+
418
+ | Stamp | Layer | Default blend | Use case |
419
+ |---|---|---|---|
420
+ | `FVoxelShapeStamp` | Height or Volume | inherited | Primitives (cube/sphere/plane). |
421
+ | `FVoxelSplineStamp` | Height or Volume | inherited | Roads, rivers, ridges. |
422
+ | `FVoxelHeightSculptStamp` | Height | Max | Hand-painted brush strokes. |
423
+ | `FVoxelVolumeSculptStamp` | Volume | inherited | Volumetric sculpt strokes. |
424
+ | `FVoxelHeightmapStamp` | Height | inherited | Heightmap texture import. |
425
+ | `FVoxelMeshStamp` | Height or Volume | inherited | Static-mesh voxelization. |
426
+ | `FVoxelHeightGraphStamp` | Height | from graph | Procedural height. |
427
+ | `FVoxelVolumeGraphStamp` | Volume | from graph | Procedural SDF. |
428
+
429
+ ## Blueprint function libraries (this module)
430
+
431
+ | Library | Surface |
432
+ |---|---|
433
+ | `UVoxelStampBlueprintFunctionLibrary` | Stamp casting and behavior helpers. |
434
+ | `UVoxelQueryBlueprintLibrary` | Height/volume sampling, RT texture writes. |
435
+ | `UVoxelShapeFunctionLibrary` | Shape construction + sampling. |
436
+ | `UVoxelSplineStampFunctionLibrary` | Spline-stamp sampling. |
437
+ | `UVoxelHeightSculptBlueprintLibrary` | Sculpt apply/save/load. |
438
+ | `UVoxelSmartSurfaceFunctionLibrary` | Smart-surface queries and previews. |
439
+ | `UVoxelStaticMeshFunctionLibrary` | Mesh voxelization. |
440
+ | `UVoxelHeightmapFunctionLibrary` | Heightmap I/O. |
441
+ | `UVoxelScatterFunctionLibrary` | Scatter placement and filtering. |
442
+ | `UVoxelTextureFunctionLibrary` / `UVoxelTextureBlueprintLibrary` | Texture sampling, RVT writes. |
443
+ | `UVoxelParameterBlueprintLibrary` | Graph-parameter access (lives in `Graphs/`). |
444
+
445
+ ## Cross-references
446
+
447
+ - The graph types referenced from stamps (`UVoxelHeightGraph`, `UVoxelVolumeGraph`) are implemented by [VoxelGraph](VoxelGraph.md).
448
+ - PCG bridge nodes for stamps/sampling: [VoxelPCG](VoxelPCG.md).
449
+ - K2 nodes for graph parameter get/set in Blueprints: [VoxelBlueprint](VoxelBlueprint.md).
450
+ - The foundational primitives (`FVoxelArray`, `FVoxelMaterialRef`, dependency tracking) come from [VoxelCore](VoxelCore.md).
@@ -0,0 +1,167 @@
1
+ # VoxelBlueprint — API Reference
2
+
3
+ Five K2 (Kismet) nodes that extend the Blueprint compiler so voxel graphs are first-class in Blueprint workflows. Specifically: typed get/set for voxel-graph parameters, and make/break for voxel pin values.
4
+
5
+ Path: `Plugins/Voxel/Source/VoxelBlueprint/Public/`. Module type: `UncookedOnly` — these classes exist for the editor's Kismet compiler and are never cooked into a packaged build.
6
+
7
+ Dependencies: `VoxelCoreEditor`, `Voxel`, `VoxelEditor`, `VoxelGraph`, `VoxelGraphEditor`, plus `BlueprintGraph` and `KismetCompiler`.
8
+
9
+ KB (usage angle): <https://docs.voxelplugin.com/knowledgebase/blueprints/setting-graph-parameters.html>.
10
+
11
+ ## What "K2 node" means
12
+
13
+ A `UK2Node` is a node Kismet draws and compiles. Unlike a normal `UFUNCTION`, a K2 node can:
14
+
15
+ - Change its pin shape based on connected types or referenced assets (wildcards).
16
+ - Expand into multiple native function calls at compile time (`ExpandNode`).
17
+ - Synthesize a context menu and palette presence on its own terms.
18
+
19
+ VoxelBlueprint uses this to:
20
+
21
+ 1. Resolve a graph-parameter name → typed pin at compile time, so Blueprints can `Get`/`Set` parameters without manual casting.
22
+ 2. Auto-generate Make/Break nodes for any struct implementing `FVoxelPinType`.
23
+
24
+ ## Base node
25
+
26
+ ### `UK2Node_VoxelBaseNode` (abstract, extends `UK2Node_CallFunction`)
27
+
28
+ The shared base for every Voxel K2 node. Provides the wildcard-pin / type-promotion plumbing used by both the parameter and make/break families.
29
+
30
+ ```cpp
31
+ class UK2Node_VoxelBaseNode : public UK2Node_CallFunction
32
+ {
33
+ // Pin types
34
+ virtual bool IsPinWildcard(UEdGraphPin*) const;
35
+
36
+ // When a pin's type changes (e.g., connection made), propagate to related pins
37
+ virtual void OnPinTypeChange(UEdGraphPin*);
38
+
39
+ // Right-click context: "Convert pin to <type>"
40
+ virtual void AddConvertPinContextAction(...);
41
+
42
+ // Compile-time expansion → native function calls
43
+ virtual void ExpandNode(...) override;
44
+ };
45
+ ```
46
+
47
+ The promotion logic keys off the Voxel-specific `FVoxelPinType` (declared in [VoxelGraph.md](VoxelGraph.md#runtime-values)), not Epic's `EPinType`. That's why a `Get Parameter` node can output `FVoxelFloatBuffer`, `FVoxelBox`, `UStaticMesh*`, etc., with the same node template.
48
+
49
+ ## Parameter access — Get / Set
50
+
51
+ ### `UK2Node_VoxelGraphParameterBase` (abstract)
52
+
53
+ Shared base for all parameter K2 nodes. Holds the cached parameter info and target graph type info.
54
+
55
+ ```cpp
56
+ struct FVoxelGraphBlueprintParameter
57
+ {
58
+ FGuid Guid;
59
+ FName Name;
60
+ FVoxelPinType Type;
61
+ };
62
+
63
+ class UK2Node_VoxelGraphParameterBase : public UK2Node_VoxelBaseNode
64
+ {
65
+ UPROPERTY()
66
+ FVoxelGraphBlueprintParameter CachedParameter;
67
+
68
+ UPROPERTY()
69
+ TWeakObjectPtr<UVoxelGraph> CachedGraph;
70
+
71
+ virtual UEdGraphPin* GetParameterNamePin();
72
+ virtual UClass* GetGraphClassType(); // UVoxelHeightGraph / UVoxelVolumeGraph / ...
73
+ virtual FName GetGraphPinName(); // "TargetHeightGraph", "TargetVolumeGraph", ...
74
+ };
75
+ ```
76
+
77
+ The `ParameterName` pin renders as a combo of parameters discovered on the connected graph. Once a parameter is selected, the value pin type is inferred from `CachedParameter.Type`. The actual runtime call dispatches to a guid-resolved function.
78
+
79
+ ### `UK2Node_GetVoxelGraphParameter`
80
+
81
+ Reads a parameter value from a target graph.
82
+
83
+ ```
84
+ ┌─────────────────────────────────┐
85
+ │ Get Voxel Graph Parameter │
86
+ ├─────────────────────────────────┤
87
+ │ ▶ Target Graph (UVoxelGraph*) │ ─► (wildcard) Value
88
+ │ Parameter Name (FName combo) │
89
+ └─────────────────────────────────┘
90
+ ```
91
+
92
+ There are concrete subclasses per graph type (`UK2Node_GetVoxel<Height|Volume|HeightSculpt|VolumeSculpt|...>GraphParameter`) — `GetGraphClassType()` returns the matching `UVoxelGraph` subclass so the picker only lists relevant parameters.
93
+
94
+ `ExpandNode()` resolves the parameter GUID into a runtime `UVoxelGraphParameterBlueprintLibrary` function call at compile time.
95
+
96
+ ### `UK2Node_SetVoxelGraphParameter`
97
+
98
+ Writes a parameter value and returns the modified graph.
99
+
100
+ ```
101
+ ┌─────────────────────────────────────┐
102
+ │ Set Voxel Graph Parameter │
103
+ ├─────────────────────────────────────┤
104
+ │ ▶ Target Graph (UVoxelGraph*) │ ─► Out Graph (UVoxelGraph*)
105
+ │ Parameter Name (FName combo) │
106
+ │ ▶ Value (wildcard, type inferred) │
107
+ └─────────────────────────────────────┘
108
+ ```
109
+
110
+ Compile expansion synthesizes both the get-current and assignment ops as native function calls.
111
+
112
+ ## Make / Break voxel pin values
113
+
114
+ These nodes synthesize struct-decomposition nodes for any type implementing `FVoxelPinType`. For example, you get a `Make FVoxelBox` node with `Min`/`Max` input pins for free, without writing per-type C++.
115
+
116
+ ### `UK2Node_MakeBreakVoxelPinValueBase` (abstract, extends `UK2Node_VoxelBaseNode`)
117
+
118
+ ```cpp
119
+ class UK2Node_MakeBreakVoxelPinValueBase : public UK2Node_VoxelBaseNode
120
+ {
121
+ UPROPERTY()
122
+ FVoxelPinType CachedType; // remember what we're making/breaking
123
+
124
+ virtual FName GetValuePinName();
125
+ };
126
+ ```
127
+
128
+ ### `UK2Node_MakeVoxelPinValueBase`
129
+
130
+ Assembles individual field pins into a Voxel compound struct.
131
+
132
+ ```
133
+ ┌─────────────────────────────┐
134
+ │ Make Voxel Box │
135
+ ├─────────────────────────────┤
136
+ │ ▶ Min (FVector) │ ─► Value (FVoxelBox)
137
+ │ ▶ Max (FVector) │
138
+ └─────────────────────────────┘
139
+ ```
140
+
141
+ ### `UK2Node_BreakVoxelPinValueBase`
142
+
143
+ Decomposes a Voxel compound struct into field pins.
144
+
145
+ ```
146
+ ┌─────────────────────────────┐
147
+ │ Break Voxel Box │
148
+ ├─────────────────────────────┤
149
+ │ ▶ Value (FVoxelBox) │ ─► Min (FVector)
150
+ │ │ ─► Max (FVector)
151
+ └─────────────────────────────┘
152
+ ```
153
+
154
+ Both expand at compile time into native field-access function calls. Because the type is wildcard-driven, **any** new `FVoxelPinType` automatically gets Make/Break support — no per-type editor work needed.
155
+
156
+ ## Workflow notes
157
+
158
+ - Get/Set nodes need a concrete graph class hooked to the target graph pin; the parameter dropdown is empty until the type is known.
159
+ - `Set` returns the modified graph as an output rather than mutating in place — this is consistent with Voxel's preference for value-style parameter overrides.
160
+ - Make/Break inherit type from the connected pin. If you start from an empty Make node, the right-click "Convert pin to…" menu (provided by `UK2Node_VoxelBaseNode::AddConvertPinContextAction`) lets you pick the target type explicitly.
161
+
162
+ ## Cross-references
163
+
164
+ - The parameter system is declared in [VoxelGraph.md](VoxelGraph.md#parameter-system).
165
+ - `FVoxelPinType` / `FVoxelPinValue` / `FVoxelRuntimePinValue` are documented under [VoxelGraph.md → Runtime values](VoxelGraph.md#runtime-values).
166
+ - The complementary BP-callable surface lives in `UVoxelParameterBlueprintLibrary` (in the `Voxel` module — see [Voxel.md](Voxel.md#graphs-specialized)).
167
+ - For graph-parameter access from PCG (instead of Blueprint), see [VoxelPCG.md → Drive-side](VoxelPCG.md#drive-side--call--configure-voxel-graphs).