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/README.md +14 -5
- package/dist/tasks/GetWorldStatus.d.ts +27 -0
- package/dist/tasks/GetWorldStatus.js +57 -0
- package/dist/tasks/GetWorldStatus.js.map +1 -0
- package/docs/Modules.md +107 -0
- package/docs/README.md +47 -0
- package/docs/Tests.md +280 -0
- package/docs/Voxel.md +450 -0
- package/docs/VoxelBlueprint.md +167 -0
- package/docs/VoxelCore.md +128 -0
- package/docs/VoxelGraph.md +386 -0
- package/docs/VoxelPCG.md +288 -0
- package/package.json +3 -2
- package/ue-mcp.plugin.yml +11 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# VoxelCore — API Reference
|
|
2
|
+
|
|
3
|
+
The foundation module. No voxel concepts live here — `VoxelCore` provides containers, math/geometry helpers, a threading model, a typed message system, a dependency-tracking primitive, and a C++/ISPC bridge that every other Voxel module sits on top of.
|
|
4
|
+
|
|
5
|
+
Path: `Plugins/Voxel/Source/VoxelCore/Public/`
|
|
6
|
+
|
|
7
|
+
`VoxelCore` loads at `PostConfigInit` so `FVoxelMessageManager`, `FVoxelDeveloperSettings`, and the ISPC runtime are available before any other module initializes.
|
|
8
|
+
|
|
9
|
+
## Public umbrella headers
|
|
10
|
+
|
|
11
|
+
- **`VoxelMinimal.h`** — the catch-all include used everywhere; pulls in containers, primitives, utilities, the message system, and most of the dependency machinery in one shot.
|
|
12
|
+
- **`VoxelCoreMinimal.h`** — slimmer subset for code that only needs basic types.
|
|
13
|
+
- **`VoxelPCH.h`** — the runtime PCH used by every non-editor Voxel module.
|
|
14
|
+
|
|
15
|
+
## Primitives (`VoxelMinimal/`)
|
|
16
|
+
|
|
17
|
+
### Bounds and intervals
|
|
18
|
+
|
|
19
|
+
| Type | Notes |
|
|
20
|
+
|---|---|
|
|
21
|
+
| `FVoxelBox` / `FVoxelBox2D` | Double-precision, **inclusive** `Min`/`Max`. Diverges from UE's `FBox` (float, exclusive max). `Infinite` and `InvertedInfinite` constants; converts from int/float vectors; Blueprint-exposed. |
|
|
22
|
+
| `FVoxelIntBox` / `FVoxelIntBox2D` | Integer bounds with `[Min, Max)` (Max **exclusive**). Used for chunk-aligned queries — note the asymmetry with the double-precision boxes. |
|
|
23
|
+
| `FVoxelInterval` / `FVoxelIntInterval` | 1-D analogues. |
|
|
24
|
+
| `FVoxelFastBox` | Stripped-down hot-path box. |
|
|
25
|
+
|
|
26
|
+
### Async and threading
|
|
27
|
+
|
|
28
|
+
| Type | Notes |
|
|
29
|
+
|---|---|
|
|
30
|
+
| `FVoxelFuture` / `TVoxelFuture<T>` | Voxel's analogue of `TFuture`. Holds a `TSharedRef` internally for lifetime safety; converts from promises; integrates with the Voxel task context. `ExecuteSynchronously()` blocks until ready. **Not interchangeable with `TFuture` — different ownership semantics.** |
|
|
31
|
+
| `FVoxelCriticalSection` | Standard critical section wrapper. |
|
|
32
|
+
| `TVoxelAtomic<T>` / `TVoxelAtomicStorage` | Padded `std::atomic<T>` wrapper that adds cacheline padding to avoid false sharing. API: `Get/Set`, `Add`, `CompareExchange`, `Set_ReturnOld`. |
|
|
33
|
+
| `FVoxelShouldCancel` (in `Utilities/VoxelThreadingUtilities.h`) | Atomic flag with relaxed-load polling. Voxel uses **polling for cancellation, not callbacks** — long-running tasks check this flag at known yield points. |
|
|
34
|
+
|
|
35
|
+
### Reflection / polymorphism
|
|
36
|
+
|
|
37
|
+
| Type | Notes |
|
|
38
|
+
|---|---|
|
|
39
|
+
| `FVoxelInstancedStruct` | Runtime polymorphic struct (analogous to Epic's `TInstancedStruct`). Holds `UScriptStruct*` plus owned memory. Used wherever a struct subtree needs to be data-driven. |
|
|
40
|
+
| `FVoxelMaterialRef` / `FVoxelMaterialInstanceRef` | Weak+strong pair around `UMaterialInterface*` that detects recompilation by tracking a serial number. **Use this anywhere you cache a material across frames** — raw `UMaterialInterface*` cached pointers go stale on shader recompile. |
|
|
41
|
+
| `FVoxelArchive` / `FVoxelWriter` | Serialization wrappers. `FVoxelWriter` buffers to `TVoxelArray64<uint8>` and supports bulk POD serialization. |
|
|
42
|
+
| `FVoxelInternalGuid` (in `VoxelGuid.h`) | Compact GUID. |
|
|
43
|
+
| `FVoxelColor3` | RGB without alpha — used in render paths where alpha is a waste. |
|
|
44
|
+
|
|
45
|
+
### Dependency tracking
|
|
46
|
+
|
|
47
|
+
This is one of the more novel pieces of the module and is reused throughout the plugin.
|
|
48
|
+
|
|
49
|
+
- **`FVoxelDependency`** (in `VoxelDependency.h`) — shared, reference-counted base. Anything observable (an asset, a layer, a compiled graph) owns one.
|
|
50
|
+
- **`FVoxelDependencyTracker`** — held by anything that *depends* on something else. Subscribes to dependencies lazily and gets notified on invalidation.
|
|
51
|
+
- **`FVoxelDependencyCollector`** — builder used during a computation to record which dependencies were touched, so the resulting tracker can subscribe retroactively.
|
|
52
|
+
- **`FVoxelInvalidationQueue`** / **`FVoxelInvalidationCallstack`** — thread-safe deferred invalidation with optional editor callstack capture for diagnosing "why did this rebuild?"
|
|
53
|
+
|
|
54
|
+
Compare to UE's delegate model: this is the inverse direction — *dependents* track who they depend on, instead of *dependencies* maintaining a list of observers. The win is that an expensive computation just records what it reads while running; you don't pre-declare anything.
|
|
55
|
+
|
|
56
|
+
### Messages
|
|
57
|
+
|
|
58
|
+
- **`FVoxelMessage`** (`VoxelMessage.h`) — composes typed `FVoxelMessageToken` subtypes (text, group, object). Tokens hash and dedupe, so spamming the same warning collapses to one entry.
|
|
59
|
+
- **`FVoxelMessageManager`** (`VoxelMinimal/VoxelMessageManager.h`) — singleton that routes messages.
|
|
60
|
+
- **`FVoxelMessageFactory`** / **`VoxelMessageTokens.h`** — extension points for custom token types. `VoxelGraph` and `VoxelPCG` each register their own callstack token type so editor errors carry graph-aware context.
|
|
61
|
+
- Bridges to UE's `MessageLog` (`IMessageToken`) on the editor side.
|
|
62
|
+
|
|
63
|
+
## Containers (`VoxelMinimal/Containers/`)
|
|
64
|
+
|
|
65
|
+
The container library mostly mirrors UE's, but with stricter type checking and a few primitives UE doesn't ship.
|
|
66
|
+
|
|
67
|
+
| Container | Relationship to UE | Why use it |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| `TVoxelArray<T, Allocator>` | **Subclasses** `TArray`. | Adds `operator ReinterpretCast()` gated by the `CanCastMemory` trait. Lets you alias the same buffer as `TVoxelArray<float>` and `TVoxelArray<uint32>` without UB — useful for SoA buffers and ISPC interop. |
|
|
70
|
+
| `TVoxelArrayView` / `TVoxelArrayView64` | Like `TArrayView`. | Const and mutable non-owning views; zero-copy parameter passing. |
|
|
71
|
+
| `TVoxelBitArray` / `TVoxelBitArrayView` | Like `TBitArray`. | 64-bit words (vs UE's 32); supports moves. |
|
|
72
|
+
| `TVoxelChunkedArray<T, MaxBytesPerChunk>` | Like `TChunkedArray`. | Chunks default to ~16 KB, allocated separately. Used for very large arrays where contiguous allocation would fragment heap. Deferred destruction. |
|
|
73
|
+
| `TVoxelSparseArray<T>` | Like `TSparseArray`. | Uses a `union FValue { T Element; int32 NextFreeIndex; }` plus a bitset, not the linked-list approach. O(1) add/remove with stable indices. |
|
|
74
|
+
| `TVoxelChunkedSparseArray<T>` | Combination of the above. | Sparse storage that doesn't require contiguous allocation. |
|
|
75
|
+
| `TVoxelMap<Key, Value>` | Like `TMap`. | Tunes bucket padding to minimize struct-layout waste. |
|
|
76
|
+
| `TVoxelSet<T>` | Like `TSet`. | Backed by `TVoxelArray` plus `FVoxelSetIndex` (sentinel `-1` for invalid) for stable iteration. |
|
|
77
|
+
| `TVoxelStaticArray<T, Num>` | Like `TStaticArray`. | Constexpr-friendly; stack or inline. |
|
|
78
|
+
| `TVoxelStaticBitArray<NumBits>` | — | Stack-allocated bitset of fixed size. |
|
|
79
|
+
| `TVoxelLinkedArray<T>` | — | Doubly-linked list. |
|
|
80
|
+
|
|
81
|
+
## Utilities (`VoxelMinimal/Utilities/`)
|
|
82
|
+
|
|
83
|
+
Domain-specific helper headers. Most are obvious from name; the ones worth calling out:
|
|
84
|
+
|
|
85
|
+
- **`VoxelMathUtilities.h`** — `DivideFloor` / `DivideCeil` that handle negative operands correctly (UE's `DivideAndRoundDown` does not), `FloorLog2`, `DivideFloor_FastLog2`.
|
|
86
|
+
- **`VoxelThreadingUtilities.h`** — `FVoxelShouldCancel`, `FlushGameTasks()`, `ForceTick()`. Global task primitives.
|
|
87
|
+
- **`VoxelGeometryUtilities.h`** — non-trivial: `IsPolygonSelfIntersecting`, `IsPolygonConvex`, `IsInConvexPolygon`, `SegmentIntersectsPolygon`, `TriangulatePolygon`; ray-triangle intersection; closest-point routines.
|
|
88
|
+
- **`VoxelHashUtilities.h`** — `GetTypeHash` specializations, multi-value hash combining, Jenkins hash.
|
|
89
|
+
- **`VoxelTypeUtilities.h`** — `CanCastMemory` trait used by `TVoxelArray::operator ReinterpretCast()`, type-deduction helpers.
|
|
90
|
+
- **`VoxelDistanceFieldUtilities.h`** — distance-field generation primitives (used by graphs and the sculpt subsystem).
|
|
91
|
+
- **`VoxelInterpolationUtilities.h`** — Lerp, cubic, smoothstep variants.
|
|
92
|
+
- **`VoxelRenderUtilities.h`** — mesh LOD selection helpers, vertex factory glue.
|
|
93
|
+
|
|
94
|
+
Less-flashy utility headers: `VoxelArrayUtilities`, `VoxelObjectUtilities`, `VoxelStringUtilities`, `VoxelVectorUtilities`, `VoxelTextureUtilities`, `VoxelTransformUtilities`, `VoxelSystemUtilities`, `VoxelLambdaUtilities`, `VoxelIntPointUtilities`, `VoxelIntVectorUtilities`.
|
|
95
|
+
|
|
96
|
+
## Memory and buffer pools
|
|
97
|
+
|
|
98
|
+
- **`FVoxelAllocator`** — pool allocator with fixed-size pools, returns opaque `FVoxelAllocation` handles. Used internally for short-lived per-query allocations.
|
|
99
|
+
- **`FVoxelBufferPool`** — async-capable GPU/CPU pool returning weakly referenced `FVoxelBufferRef`. Exposes `IsOutOfMemory()`; integrates with `FVoxelFuture` for async uploads.
|
|
100
|
+
|
|
101
|
+
## Spatial structures
|
|
102
|
+
|
|
103
|
+
- **`FVoxelAABBTree`** / **`FVoxelAABBTree2D`** — AABB-tree spatial index. Stored as a struct-of-arrays (`FElementArray` with separate columns for payload + `MinX/Y/Z` + `MaxX/Y/Z`). Less fragmentation than per-element node structs.
|
|
104
|
+
- **`TVoxelFastOctree<T>`** — templated octree. `FNodeRef` exposes height, size, bounds (`FVoxelIntBox`), and center.
|
|
105
|
+
- **`TVoxelFastQuadtree<T>`** — 2-D analogue.
|
|
106
|
+
|
|
107
|
+
## ISPC bridge
|
|
108
|
+
|
|
109
|
+
- **`FVoxelISPC`** (`VoxelMinimal/VoxelISPC.h`) — exposes `ispc::float2/3/4`, `ispc::double2/3/4`, `ispc::int2/3/4`, matrices, and a re-declared `FColor`. C++ and ISPC share these as memory layouts so kernels can operate on UE data without marshaling.
|
|
110
|
+
- **`VoxelMacros.h`** — `INTELLISENSE_PARSER`, `VOXEL_DEBUG`, conditional debug logging. Includes IDE-detection so ReSharper/Rider doesn't choke on macros.
|
|
111
|
+
|
|
112
|
+
The build-system half of the ISPC story lives in `VoxelCore.Build.cs` — see [Modules.md](Modules.md#ispc-and-the-build-script) for the per-platform target matrix and how `.ispc` files are compiled into per-module static libraries.
|
|
113
|
+
|
|
114
|
+
## Editor-only
|
|
115
|
+
|
|
116
|
+
- **`FVoxelHeaderGenerator`** — C++ codegen helper used by editor tooling to emit `.generated.h`-style headers from plugin data (e.g., scaffolding for new function libraries).
|
|
117
|
+
- **`VoxelDeveloperSettings.h`** — base `UDeveloperSettings` plumbing the plugin's project-settings panels.
|
|
118
|
+
- **`VoxelHeightmapImporter.h`** — heightmap import (called from the editor heightmap workflow).
|
|
119
|
+
|
|
120
|
+
## Transvoxel data
|
|
121
|
+
|
|
122
|
+
- **`TransvoxelData.h`** / **`TransvoxelTransitionData.h`** — Lengyel's Transvoxel lookup tables (referenced by the meshing code in the `Voxel` module). The license requires attribution if you redistribute.
|
|
123
|
+
|
|
124
|
+
## Cross-references
|
|
125
|
+
|
|
126
|
+
- For *how* these primitives are wired into the wider plugin, see [Modules.md](Modules.md).
|
|
127
|
+
- The dependency-tracking primitives drive the [graph invalidation system](VoxelGraph.md#parameters-and-external-state) and the [stamp manager](Voxel.md#stamp-manager-and-runtime).
|
|
128
|
+
- Buffers in `VoxelGraph` build on `TVoxelArray` and the ISPC bridge — see [VoxelGraph.md](VoxelGraph.md#buffer-system).
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
# VoxelGraph — API Reference
|
|
2
|
+
|
|
3
|
+
The visual-graph authoring system. Defines the source asset (`UVoxelGraph`), a multi-pass compiler, a typed buffer-based data-flow model, the runtime evaluation context, and the node library (math, noise, gradient, control flow, function-library calls).
|
|
4
|
+
|
|
5
|
+
Path: `Plugins/Voxel/Source/VoxelGraph/Public/`. Loads at `Default` phase. Built on `VoxelCore` plus `Chaos`, `PhysicsCore`, `Json`, `TraceLog` (and `MessageLog` in editor).
|
|
6
|
+
|
|
7
|
+
Official KB on graph authoring (not API): <https://docs.voxelplugin.com/knowledgebase/working-with-graphs/>.
|
|
8
|
+
|
|
9
|
+
## High-level pipeline
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
UVoxelGraph (asset)
|
|
13
|
+
│
|
|
14
|
+
▼
|
|
15
|
+
Voxel::Graph::FGraph (mutable compilation IR — FVoxelCompilationGraph.h)
|
|
16
|
+
│
|
|
17
|
+
│ passes: template expansion, passthrough removal,
|
|
18
|
+
│ local-var elimination, range-node injection, validation
|
|
19
|
+
▼
|
|
20
|
+
FVoxelCompiledTerminalGraph (immutable per-terminal)
|
|
21
|
+
│
|
|
22
|
+
▼
|
|
23
|
+
FVoxelCompiledGraph (root container, guid → terminal)
|
|
24
|
+
│ cached on UVoxelGraph with dependency tracking
|
|
25
|
+
│
|
|
26
|
+
▼
|
|
27
|
+
Runtime evaluation:
|
|
28
|
+
FVoxelGraphContext (TLS-bound, arena allocator, task chain)
|
|
29
|
+
FVoxelGraphQuery (per-call parameters + buffer outputs)
|
|
30
|
+
FVoxelComputeNode (ISPC-compiled nodes) / FVoxelNode (pure C++)
|
|
31
|
+
│
|
|
32
|
+
▼
|
|
33
|
+
Typed buffers (FVoxelFloatBuffer, FVoxelVectorBuffer, …)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
A single voxel graph asset can contain multiple **terminal graphs** (an output graph plus subgraphs and function libraries). Each terminal compiles independently into a `FVoxelCompiledTerminalGraph`. At runtime, a query targets one terminal by guid.
|
|
37
|
+
|
|
38
|
+
## Source asset
|
|
39
|
+
|
|
40
|
+
**`VoxelGraph.h` — `UVoxelGraph`**
|
|
41
|
+
|
|
42
|
+
| Member | Purpose |
|
|
43
|
+
|---|---|
|
|
44
|
+
| Terminal graph map (guid → `UVoxelTerminalGraph*`) | Multi-output graphs. |
|
|
45
|
+
| `FVoxelParameter` array | Exposed parameters, keyed by guid. |
|
|
46
|
+
| Base graph chain | Inheritance chain for parameter/graph reuse. |
|
|
47
|
+
| Editor metadata | Category, display name, tags. |
|
|
48
|
+
| `GetCompiledGraph()` | Returns cached `FVoxelCompiledGraph`, recompiling on invalidation. |
|
|
49
|
+
|
|
50
|
+
**`VoxelTerminalGraph.h` — `UVoxelTerminalGraph`** holds function inputs/outputs, local variables, and the serialized node list. **`VoxelTerminalGraphRuntime.h` — `UVoxelTerminalGraphRuntime`** bridges editor → compiled form.
|
|
51
|
+
|
|
52
|
+
**`VoxelGraphMigration.h`** — versioning/upgrade plumbing for asset-format changes.
|
|
53
|
+
|
|
54
|
+
## Compilation pipeline
|
|
55
|
+
|
|
56
|
+
### `FVoxelCompilationGraph` — the IR
|
|
57
|
+
|
|
58
|
+
`VoxelCompilationGraph.h` defines `Voxel::Graph::{FGraph, FNode, FPin}` — the mutable working representation during compilation.
|
|
59
|
+
|
|
60
|
+
```cpp
|
|
61
|
+
namespace Voxel::Graph
|
|
62
|
+
{
|
|
63
|
+
class FGraph
|
|
64
|
+
{
|
|
65
|
+
FNode* NewNode(UStruct* nodeType);
|
|
66
|
+
// ... cloning, integrity checks
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
class FNode
|
|
70
|
+
{
|
|
71
|
+
FPin* FindInput(FName);
|
|
72
|
+
FPin* FindOutput(FName);
|
|
73
|
+
// errors queued here, not raised — lets us keep compiling
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
class FPin
|
|
77
|
+
{
|
|
78
|
+
void MakeLinkTo(FPin* Other);
|
|
79
|
+
FVoxelPinType Type;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Errors are queued on the offending node rather than aborting; an unused node with bad pins won't kill the whole compile.
|
|
85
|
+
|
|
86
|
+
### `FVoxelGraphCompiler` — passes
|
|
87
|
+
|
|
88
|
+
`VoxelGraphCompiler.h` orchestrates:
|
|
89
|
+
|
|
90
|
+
1. Load serialized graph into `FVoxelCompilationGraph`.
|
|
91
|
+
2. **Template expansion** — `FilterBuffer` / `NearlyEqual` template nodes specialize per concrete type.
|
|
92
|
+
3. **Passthrough removal** — `MakeStruct` followed by `BreakStruct`, or `MakeValue` then `Equal`, collapse.
|
|
93
|
+
4. **Local-variable elimination** — `VoxelLocalVariableNodes` get inlined.
|
|
94
|
+
5. **Range-node injection** — `RangeDebug` instruments paths used by editor previews.
|
|
95
|
+
6. **Validation** — cycle detection, parameter/type consistency, function I/O matching, guid uniqueness. Wildcard pins propagate errors instead of crashing.
|
|
96
|
+
|
|
97
|
+
`VoxelGraphCompileScope.h` provides RAII-style scoping for compile-time state (current compiler, error sink).
|
|
98
|
+
|
|
99
|
+
### `FVoxelCompiledTerminalGraph` — immutable output
|
|
100
|
+
|
|
101
|
+
`VoxelCompiledTerminalGraph.h` — readonly per-terminal compilation result. Stored as homogeneous arrays per concrete `FVoxelNode` struct type for cache-friendly iteration.
|
|
102
|
+
|
|
103
|
+
```cpp
|
|
104
|
+
template<typename TNode>
|
|
105
|
+
TVoxelArrayView<const TNode> GetNodes() const;
|
|
106
|
+
|
|
107
|
+
int32 NumNodes() const;
|
|
108
|
+
int32 NumPins() const;
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Ownership validation in debug to catch use-after-recompile.
|
|
112
|
+
|
|
113
|
+
### `FVoxelCompiledGraph` — root container
|
|
114
|
+
|
|
115
|
+
`VoxelCompiledGraph.h` — holds `FVoxelCompiledTerminalGraph`s keyed by terminal guid. Cached on `UVoxelGraph` and invalidated through the [VoxelCore dependency tracker](VoxelCore.md#dependency-tracking).
|
|
116
|
+
|
|
117
|
+
## Runtime evaluation
|
|
118
|
+
|
|
119
|
+
### `FVoxelGraphContext`
|
|
120
|
+
|
|
121
|
+
`VoxelGraphContext.h` is the per-evaluation execution container.
|
|
122
|
+
|
|
123
|
+
```cpp
|
|
124
|
+
class FVoxelGraphContext
|
|
125
|
+
{
|
|
126
|
+
static FVoxelGraphContext& Get(); // TLS — one per thread
|
|
127
|
+
// Task chain with inline lambda storage (256 bytes/task) avoiding heap thrash
|
|
128
|
+
// Arena allocator (16-byte pages, 16 KB/page) for query-scoped parameters
|
|
129
|
+
// Callstack tracking (editor only) for graph error context
|
|
130
|
+
// Auto-destructor invocation for allocated objects
|
|
131
|
+
};
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Bound to a thread via TLS — every node evaluation accesses the active context to allocate parameters, push subtasks, or report errors.
|
|
135
|
+
|
|
136
|
+
### `FVoxelGraphQuery`
|
|
137
|
+
|
|
138
|
+
`VoxelGraphQuery.h` is the per-call query wrapper.
|
|
139
|
+
|
|
140
|
+
```cpp
|
|
141
|
+
class FVoxelGraphQuery
|
|
142
|
+
{
|
|
143
|
+
// Uniform parameters indexed by type
|
|
144
|
+
template<typename T> const T& GetParameter() const;
|
|
145
|
+
|
|
146
|
+
// Buffer parameters (runtime buffers)
|
|
147
|
+
template<typename T> const T& GetBufferParameter() const;
|
|
148
|
+
|
|
149
|
+
// Pin-value storage (computed/uncomputed tracking)
|
|
150
|
+
template<typename T> T& GetPinValue(FPinRef pin);
|
|
151
|
+
bool IsNodeComputed(FVoxelGraphNodeRef) const;
|
|
152
|
+
|
|
153
|
+
// Sub-queries for function calls
|
|
154
|
+
FVoxelGraphQuery CreateChildQuery(...) const;
|
|
155
|
+
};
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
`FVoxelGraphQueryImpl` is the concrete implementation (the public `FVoxelGraphQuery` is a thin handle).
|
|
159
|
+
|
|
160
|
+
### `FVoxelGraphEnvironment`
|
|
161
|
+
|
|
162
|
+
`VoxelGraphEnvironment.h` packages the compiled root graph, parameter overrides, and world transform.
|
|
163
|
+
|
|
164
|
+
```cpp
|
|
165
|
+
static FVoxelGraphEnvironment Create(UVoxelGraph* Graph, ...);
|
|
166
|
+
static FVoxelGraphEnvironment CreatePreview(...); // marked as preview scene
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### `FVoxelGraphTracker`
|
|
170
|
+
|
|
171
|
+
`VoxelGraphTracker.h` — dependency-tracking helper specialized for graphs. Receives invalidation signals when the graph or its parameters change.
|
|
172
|
+
|
|
173
|
+
### `FVoxelGraphNodeRef`
|
|
174
|
+
|
|
175
|
+
`VoxelGraphNodeRef.h` — guid + type-safe lookup into a compiled terminal graph. The handle you use when you need to refer to a specific node from outside the graph (e.g., from a function library or an external parameter).
|
|
176
|
+
|
|
177
|
+
## Buffer system
|
|
178
|
+
|
|
179
|
+
The data currency between nodes. **Nodes consume and produce typed buffers** — arrays of values in struct-of-arrays (SoA) layout that pair well with ISPC.
|
|
180
|
+
|
|
181
|
+
### Base
|
|
182
|
+
|
|
183
|
+
**`VoxelBuffer.h` — `FVoxelBuffer`** (abstract):
|
|
184
|
+
|
|
185
|
+
```cpp
|
|
186
|
+
template<typename T> bool IsA() const;
|
|
187
|
+
template<typename T> const T& As() const;
|
|
188
|
+
|
|
189
|
+
static TSharedRef<FVoxelBuffer> MakeEmpty(UScriptStruct*);
|
|
190
|
+
static TSharedRef<FVoxelBuffer> MakeDefault(UScriptStruct*);
|
|
191
|
+
static TSharedRef<FVoxelBuffer> MakeConstant(const FVoxelRuntimePinValue&);
|
|
192
|
+
|
|
193
|
+
void Allocate(int32 Num);
|
|
194
|
+
void ShrinkTo(int32 Num);
|
|
195
|
+
|
|
196
|
+
void IndirectCopyFrom(const FVoxelBuffer&, TConstArrayView<int32> srcIndices);
|
|
197
|
+
void Gather(const FVoxelBuffer&, ...);
|
|
198
|
+
void Replicate(const FVoxelBuffer&, int32 count);
|
|
199
|
+
void Split(/* into N buffers */) const;
|
|
200
|
+
void Merge(/* from N buffers */);
|
|
201
|
+
|
|
202
|
+
void Serialize(FArchive&);
|
|
203
|
+
|
|
204
|
+
void SetGeneric(int32, FVoxelRuntimePinValue);
|
|
205
|
+
FVoxelRuntimePinValue GetGeneric(int32) const;
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Typed buffers (`Buffer/`)
|
|
209
|
+
|
|
210
|
+
| Header | Concrete types |
|
|
211
|
+
|---|---|
|
|
212
|
+
| `VoxelFloatBuffers.h` | `FVoxelFloatBuffer`, `FVoxelVector2DBuffer`, `FVoxelVectorBuffer` |
|
|
213
|
+
| `VoxelDoubleBuffers.h` | `FVoxelDoubleBuffer` |
|
|
214
|
+
| `VoxelIntegerBuffers.h` | `FVoxelInt32Buffer` |
|
|
215
|
+
| `VoxelNormalBuffer.h` | `FVoxelNormalBuffer` (octahedral-encoded) |
|
|
216
|
+
| `VoxelNameBuffer.h` | `FVoxelNameBuffer` |
|
|
217
|
+
| `VoxelClassBuffer.h` | `FVoxelClassBuffer` |
|
|
218
|
+
| `VoxelRangeBuffers.h` | `FVoxelRangeBuffer` |
|
|
219
|
+
| `VoxelSoftObjectPathBuffer.h` | `FVoxelSoftObjectPathBuffer` |
|
|
220
|
+
| `VoxelGraphStaticMeshBuffer.h` | Static-mesh-reference buffers |
|
|
221
|
+
| `VoxelBaseBuffers.h` | Shared base/utilities for the above |
|
|
222
|
+
|
|
223
|
+
`DECLARE_VOXEL_BUFFER(T, BufferType)` declares the bidirectional `T` ↔ buffer type relationship that the templating/conversion utilities key off of.
|
|
224
|
+
|
|
225
|
+
### Buffer support
|
|
226
|
+
|
|
227
|
+
- **`VoxelBufferAccessor.h`** — templated element accessor.
|
|
228
|
+
- **`VoxelBufferSplitter.h`** — splits compound buffers (e.g., vector → X/Y/Z floats).
|
|
229
|
+
- **`VoxelBufferStruct.h`** — base for structured buffers.
|
|
230
|
+
- **`VoxelGenericStructBuffer.h`** — runtime support for user-defined struct buffers.
|
|
231
|
+
|
|
232
|
+
### Buffer utilities (`Utilities/`)
|
|
233
|
+
|
|
234
|
+
- `VoxelBufferConversionUtilities.h` — type conversions.
|
|
235
|
+
- `VoxelBufferGradientUtilities.h` — numerical gradients (used by distance-field nodes).
|
|
236
|
+
- `VoxelBufferMathUtilities.h` — per-buffer arithmetic (add, multiply, normalize).
|
|
237
|
+
- `VoxelBufferTransformUtilities.h` — affine transforms applied to coordinate buffers.
|
|
238
|
+
|
|
239
|
+
## Parameter system
|
|
240
|
+
|
|
241
|
+
Parameters are the inputs a graph exposes for runtime override.
|
|
242
|
+
|
|
243
|
+
| Header | Type |
|
|
244
|
+
|---|---|
|
|
245
|
+
| `VoxelParameter.h` *(included via `VoxelGraph.h`)* | `FVoxelParameter` — name, type, default, guid. |
|
|
246
|
+
| `VoxelGraphParameters.h` | `FVoxelGraphParameters`, `FVoxelGraphParameterManager`. Splits into `FUniformParameter` (POD scalars) and `FBufferParameter` (array-backed). The manager indexes parameter types globally. |
|
|
247
|
+
| `VoxelGraphParametersView.h` | Immutable parameter snapshot passed to nodes. |
|
|
248
|
+
| `VoxelGraphParametersViewContext.h` | Allocation scope during query execution. |
|
|
249
|
+
| `VoxelGraphPositionParameter.h` | The implicit world-position input (X, Y, Z, LOD). |
|
|
250
|
+
| `VoxelExposedSeed.h` | Thread-safe random seed (`FVoxelGraphParameters::FSeed`). |
|
|
251
|
+
| `VoxelExternalParameter.h` | Bridge for BP / C++ to override parameters at runtime. |
|
|
252
|
+
|
|
253
|
+
## Runtime values
|
|
254
|
+
|
|
255
|
+
| Header | Type |
|
|
256
|
+
|---|---|
|
|
257
|
+
| `VoxelPinType.h` | `FVoxelPinType` — type descriptor; distinguishes a buffer type (`FVoxelFloatBuffer`) from its inner scalar type (`float`). |
|
|
258
|
+
| `VoxelPinValue.h` | `FVoxelPinValue` — editor-side default values (serializable). |
|
|
259
|
+
| `VoxelRuntimePinValue.h` | `FVoxelRuntimePinValue` — compact 40-byte union (bool/int/float/double/name/class/struct), buffer values via `FSharedVoidPtr`. |
|
|
260
|
+
| `VoxelPin.h` | `FVoxelPin`, `FVoxelPinMetadata` — pin name, sort order, flags (template/variadic/hide/array/position/no-cache/no-default), display name, category, tooltip. |
|
|
261
|
+
| `VoxelRuntimeStruct.h` | Runtime struct-pin wrapper. |
|
|
262
|
+
|
|
263
|
+
## Node system
|
|
264
|
+
|
|
265
|
+
### Base
|
|
266
|
+
|
|
267
|
+
`VoxelNode.h` defines `FVoxelNode` — node base inheriting `FVoxelVirtualStruct`. Pin declarations use macros:
|
|
268
|
+
|
|
269
|
+
```cpp
|
|
270
|
+
VOXEL_INPUT_PIN(float, Radius, 1.0f);
|
|
271
|
+
VOXEL_OUTPUT_PIN(FVoxelFloatBuffer, Density);
|
|
272
|
+
VOXEL_TEMPLATE_INPUT_PIN(T, Value);
|
|
273
|
+
VOXEL_VARIADIC_INPUT_PIN(FVoxelPointSet, Inputs);
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Typed pin references — `FPinRef_Input<T>`, `FPinRef_Output<T>` — give compile-time safety when reading/writing values from inside `Compute()`:
|
|
277
|
+
|
|
278
|
+
```cpp
|
|
279
|
+
virtual void Compute(FVoxelGraphQuery Query) const override
|
|
280
|
+
{
|
|
281
|
+
const float R = Query.GetPinValue(RadiusPin);
|
|
282
|
+
FVoxelFloatBuffer& Out = Query.GetPinValue(DensityPin);
|
|
283
|
+
// ...
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Methods to override: `IsPureNode()`, `CanBeQueried()`, `CanBeDuplicated()`, `Compute()`.
|
|
288
|
+
|
|
289
|
+
### `FVoxelComputeNode`
|
|
290
|
+
|
|
291
|
+
`VoxelComputeNode.h` extends `FVoxelNode` for ISPC-compiled nodes. `VoxelComputeNodeImpl.h` provides the implementation glue.
|
|
292
|
+
|
|
293
|
+
```cpp
|
|
294
|
+
virtual FString GenerateCode() const override; // ISPC/C++ snippet
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Cached function pointers wire compiled ISPC kernels to the node at runtime.
|
|
298
|
+
|
|
299
|
+
### `VoxelNodeDefinition.h` (editor)
|
|
300
|
+
|
|
301
|
+
Hierarchical pin/parameter definition for the node-tree UI. Supports categories, variadic pins, nesting.
|
|
302
|
+
|
|
303
|
+
### Node families (`Nodes/`)
|
|
304
|
+
|
|
305
|
+
| Family | Headers | Notes |
|
|
306
|
+
|---|---|---|
|
|
307
|
+
| **Math** | `VoxelMathNodes.h`, `VoxelTemplatedMathNodes.h`, `VoxelMathConvertNodes.h`, `VoxelOperatorNodes.h` | Trig, sqrt, abs, sign, min/max, pow, log, exp, lerp, float↔int conversions, infix operators. |
|
|
308
|
+
| **Clamp/lerp** | `VoxelClampNodes.h`, `VoxelLerpNodes.h`, `VoxelInterpolationNodes.h` | Clamp, lerp, inverse-lerp, cubic, Catmull-Rom, smoothstep. |
|
|
309
|
+
| **Comparison/logic** | `VoxelCompareNodes.h`, `VoxelBoolNodes.h` | `==`/`<`/etc., AND/OR/NOT/Select. |
|
|
310
|
+
| **Noise** | `VoxelNoiseNodes.h`, `VoxelAdvancedNoiseNodes.h`, `VoxelDomainWarpNodes.h`, `VoxelGradientNodes.h` | Perlin/Worley/Simplex/value; fBm + ridged multifractal; domain warp; gradient. |
|
|
311
|
+
| **Vector** | `VoxelVectorNodes.h`, `VoxelRandomNodes.h` | Vector ops, random vector. |
|
|
312
|
+
| **Array** | `VoxelArrayNodes.h` | Array construction/decomposition. |
|
|
313
|
+
| **Random** | `VoxelRandomNodes.h`, `VoxelNode_RandomSelect.h` | Random scalar + random element. |
|
|
314
|
+
| **Control flow** | `VoxelNode_Select.h`, `VoxelNode_Equal.h`, `VoxelNode_HeightSplitter.h`, `VoxelTemplateNode_FilterBuffer.h`, `VoxelTemplateNode_NearlyEqual.h` | Conditional outputs, splitters, templated filters. |
|
|
315
|
+
| **Struct** | `VoxelNode_MakeStruct.h`, `VoxelNode_BreakStruct.h`, `VoxelNode_MakeValue.h` | Compose/decompose typed structs; constant value. |
|
|
316
|
+
| **Parameter** | `VoxelNode_Parameter.h`, `VoxelNode_CustomizeParameter.h` | Graph parameter reference + per-use metadata override. |
|
|
317
|
+
| **Function** | `VoxelNode_FunctionInput.h`, `VoxelNode_FunctionOutput.h`, `VoxelCallFunctionNodes.h`, `VoxelNode_UFunction.h` | Subgraph boundaries; calls to other graphs and native `UFUNCTION`s. |
|
|
318
|
+
| **Local variable** | `VoxelLocalVariableNodes.h` | Inlined by the compiler. |
|
|
319
|
+
| **Position** | `VoxelNode_OverrideDownstreamPosition.h` | Modify position passed downstream. |
|
|
320
|
+
| **Debug** | `VoxelNode_RaiseError.h`, `VoxelNode_RangeDebug.h`, `VoxelNode_ValueDebug.h`, `VoxelNode_AppendNames.h` | Compile-time error emission, editor preview tags. |
|
|
321
|
+
|
|
322
|
+
## Function libraries
|
|
323
|
+
|
|
324
|
+
### Library framework
|
|
325
|
+
|
|
326
|
+
| Header | Type |
|
|
327
|
+
|---|---|
|
|
328
|
+
| `VoxelFunctionLibrary.h` | `UVoxelFunctionLibrary` — library registry. `RegisterFunction()` caches signature and exec pointer; `Call()` marshals buffer args. |
|
|
329
|
+
| `VoxelFunctionLibraryAsset.h` | `UVoxelFunctionLibraryAsset` — Blueprint-editable user library. |
|
|
330
|
+
|
|
331
|
+
The [VoxelUHT extension](Modules.md#uht-extension) is what makes adding a new function-library node a one-`UFUNCTION` job — it generates the graph-side glue at build time.
|
|
332
|
+
|
|
333
|
+
### Built-in libraries (`FunctionLibrary/`)
|
|
334
|
+
|
|
335
|
+
| Library | Surface |
|
|
336
|
+
|---|---|
|
|
337
|
+
| `UVoxelBasicFunctionLibrary` | Abs, Min, Max, Clamp, Lerp, Frac. |
|
|
338
|
+
| `UVoxelBoxFunctionLibrary` | Box collision/SDF queries. |
|
|
339
|
+
| `UVoxelCurveFunctionLibrary` | `UCurveFloat` / `UCurveVector` evaluation. |
|
|
340
|
+
| `UVoxelMathFunctionLibrary` | Vector/matrix ops, smoothstep, normalize, dot, cross. |
|
|
341
|
+
| `UVoxelPositionFunctionLibrary` | Position transforms, distance, direction. |
|
|
342
|
+
| `UVoxelAutocastFunctionLibrary` | Type promotions (float→double, etc.). |
|
|
343
|
+
|
|
344
|
+
## Preview handlers
|
|
345
|
+
|
|
346
|
+
Editor-time visualization of intermediate values.
|
|
347
|
+
|
|
348
|
+
`VoxelPreviewHandler.h` — `FVoxelPreviewHandler` base. `Initialize()` and `GetColors()` rasterize the value; `Compute()` returns an async colored image for the editor viewport. Mouse position tracking enables per-pixel inspection in the graph editor.
|
|
349
|
+
|
|
350
|
+
`Preview/` subfolder:
|
|
351
|
+
|
|
352
|
+
| Header | Type |
|
|
353
|
+
|---|---|
|
|
354
|
+
| `VoxelBoolPreviewHandler.h` | Black/white. |
|
|
355
|
+
| `VoxelFloatPreviewHandlers.h` | Single (grayscale) and triple (RGB). |
|
|
356
|
+
| `VoxelDoublePreviewHandlers.h` | Double-precision. |
|
|
357
|
+
| `VoxelIntegerPreviewHandlers.h` | Integer visualization. |
|
|
358
|
+
| `VoxelScalarPreviewHandler.h` | Generic scalar. |
|
|
359
|
+
| `VoxelEnumPreviewHandler.h` | Enum colormapping. |
|
|
360
|
+
| `VoxelDistanceFieldPreviewHandlers.h` | Distance field with isosurface. |
|
|
361
|
+
| `VoxelGenericPreviewHandler.h` | Fallback. |
|
|
362
|
+
|
|
363
|
+
`VoxelNode_Preview.h` — drop-in node that captures a debug snapshot for the preview pane.
|
|
364
|
+
|
|
365
|
+
KB: <https://docs.voxelplugin.com/knowledgebase/working-with-graphs/debugging-graphs.html>.
|
|
366
|
+
|
|
367
|
+
## ISPC integration
|
|
368
|
+
|
|
369
|
+
`VoxelISPCNodeHelpers.h` — binds compiled ISPC kernels to `FVoxelComputeNode`. The kernel side uses the layout structs declared in [`VoxelCore`'s `VoxelISPC.h`](VoxelCore.md#ispc-bridge). The build system (`Source/VoxelCore/Private/BuildISPC-windows.txt` / `BuildISPC-linux.txt`) is described in [Modules.md](Modules.md#ispc-and-the-build-script).
|
|
370
|
+
|
|
371
|
+
## Message tokens
|
|
372
|
+
|
|
373
|
+
`VoxelGraphMessageTokens.h`, `VoxelMessageToken_GraphCallstack.h` — custom message tokens that attach a graph callstack to errors, so editor diagnostics point at the offending node + call path.
|
|
374
|
+
|
|
375
|
+
## Default node definition
|
|
376
|
+
|
|
377
|
+
`VoxelDefaultNodeDefinition.h` — automatic pin/parameter extraction from struct properties. The reason a `VOXEL_INPUT_PIN` declaration is enough for the editor to lay out a node without writing custom UI code.
|
|
378
|
+
|
|
379
|
+
`VoxelOutputNode.h` — terminal output node base; subclassed in the [`Voxel/Graphs/`](Voxel.md#graphs-specialized) folder by `UVoxelOutputNode_OutputHeight`, `_OutputVolume`, etc.
|
|
380
|
+
|
|
381
|
+
## Cross-references
|
|
382
|
+
|
|
383
|
+
- The `Voxel/Graphs/` subfolder defines the concrete graph types (`UVoxelHeightGraph`, `UVoxelVolumeGraph`) — see [Voxel.md](Voxel.md#graphs-specialized).
|
|
384
|
+
- PCG nodes that drive graphs (`PCGCallVoxelGraph`, parameter-override settings) live in [VoxelPCG.md](VoxelPCG.md#drive-side-call--configure-voxel-graphs).
|
|
385
|
+
- K2 nodes for getting/setting graph parameters from Blueprints are in [VoxelBlueprint.md](VoxelBlueprint.md).
|
|
386
|
+
- The buffer/container substrate (`TVoxelArray`, ISPC bridge) comes from [VoxelCore.md](VoxelCore.md).
|