Navigation
API > API/Plugins > API/Plugins/PCG
Rundown for utilizing the Time Slice Element and Context:
Create a struct to contain the state data for the element that will contain "per-execution" state data to be calculated only once Create a struct to contain the state data for the element that will contain "per-iteration" state data for each item (usually validated inputs) to iterate through Note: Either struct is optional and can be substituted with an empty struct if that aspect of the element is stateless Override the element type with TTimeSlicedPCGElement with two template arguments, the first being the static struct,and the second being the "per-iteration" Pass a function or lambda matching the correct signature to InitializePerExecutionState and initialize the static struct within Do the same for InitializePerIterationStates, but also pass the number of iterations. This will iterate through a state initialization for each iteration [Optional] If needed, mark UObjects with TrackObject or TrackObjectByName if you need to retrieve it later and to prevent their garbage collection. DataIsPrepared SHOULD BE used to verify initialization was successful, such as in the ExecuteInternal if data was previously initialized in PrepareDataInternal Call ExecuteSlice with an execution function or lambda that returns a boolean that is true once the full execution is completed, or false otherwise
Note: See PCGSurfaceSampler.h/.cpp as an example.
A PCG Element that will utilize a Time Slice Context.
| Name | TPCGTimeSlicedElementBase |
| Type | class |
| Header File | /Engine/Plugins/PCG/Source/PCG/Public/Elements/PCGTimeSlicedElementBase.h |
| Include Path | #include "Elements/PCGTimeSlicedElementBase.h" |
Syntax
template<typename PerExecutionStateT, typename PerIterationStateT, typename BaseContext>
class TPCGTimeSlicedElementBase : public IPCGElement
Implements Interfaces
Derived Classes
TPCGTimeSlicedElementBase derived class hierarchy
- FPCGApplyHierarchyElement
- FPCGPointOperationElementBase
- FPCGAttractElement
- FPCGMetadataElementBase
- FPCGBlurElement
- FPCGClusterElement
- FPCGCollapsePointsElement
- FPCGMatchAndSetAttributesElement
- FPCGPathfindingElement
- FPCGSelfPruningElement
- FPCGSpawnSplineMeshElement
- FPCGSurfaceSamplerElement
- FPCGVolumeSamplerElement
- FPCGWorldRaycastElement
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| ContextType | TPCGTimeSlicedContext< ExecStateType, IterStateType, BaseContext > | Elements/PCGTimeSlicedElementBase.h | |
| ExecSignature | bool(ContextType *Context, const PerExecutionStateT &PerExecutionState, PerIterationStateT &PerIterationState, const uint32 IterationIndex) | Elements/PCGTimeSlicedElementBase.h | |
| ExecStateType | PerExecutionStateT | Aliases, for ease of use with the template. | Elements/PCGTimeSlicedElementBase.h |
| IterStateType | PerIterationStateT | Elements/PCGTimeSlicedElementBase.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
bool ExecuteSlice
(
ContextType* Context, |
Executes the delegate for every iteration. | Elements/PCGTimeSlicedElementBase.h |
Overridden from IPCGElement
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual FPCGContext * CreateContext() |
Let each element optionally act as a concrete factory for its own context | Elements/PCGTimeSlicedElementBase.h |