Section 9. Misc

Section 9.1. Actor and Component Pooling

Section 9.1.1. Introduction

rdInst can efficiently pool your actors and components for fast instantiation at runtime. You can choose how many to Pool, if they should be created initially or on-demand, if they should recycle the oldest pooled items when needed and whether or not to perform things like disabling physics on them when pooled.

You use the rdBase/rdInstSubsystem function rdPoolActor to pool actors and the rdActor function rdPoolComponent for components.

The Nodes described below:

rdPoolActor

Actor Class: The class of actor to pool – this can be any type of actor
Num to Pool: The number of actors to reserve ready to be used from the pool
Premake: When ticked, creates the actors and hides them on BeginPlay
DoTick: When ticked, enables the actors tick when used from the pool
Reuse: When ticked, the oldest item is used when all actors from the pool are used.
Simple Pool: When ticked, doesn’t perform things like disabling/enabling physics when pooling or using.


rdPoolComponent

Component Class: The class of component to pool – this can be any type of component
Num to Pool: The number of components to reserve ready to be used from the pool
Premake: When ticked, creates the components and hides them on BeginPlay


Section 9.1.2. Actor Pooling from rdActor

rdActor itself does not contain routines for pooling actors as it makes more sense to do that from the singleton.

It does have events that get fired when an actor is Pooled or Depooled, and you can override them in the rdActor to do any setup and reset work you require.


Section 9.1.3. Component Pooling from rdActor

You can Pool any type and any amount of components using the rdInst Component Pooling routines.

Check out Tutorial 14 for an example of Component Pooling, and check the rdActor Pooling section of the Reference Manual.


Section 9.1.4. Actor Pooling from the BaseActor or Subsystem

Use these routines to Pool your Actors in the most efficient way.

Check out the tutorials below for examples on how to use it, and check the rdInstBase Pooling section of the Reference Manual.


Section 9.1.5. Pooling Tutorials

To find out how to implement Actor and Component Pooling you can read these tutorials:

Tutorial 14 – Component Pooling

Tutorial 13 – Actor Pooling

Tutorial 17 – Pooled Actor Movement

Tutorial 19 – Pooling Projectile Actors

Tutorial 20 – Any Actor Pools

Tutorial 25 – Multiplayer Pooling


Section 9.2. Distributed Transactions

Section 9.2.1. Introduction

When adding a lot of actors to your level it can leave a very noticeable lag, so a good way to get rid of that is by splitting up the creation over multiple frames.

The rdInst Distributed Transactions system gives a fast and easy to use way to do this.

If you’re using the rdSpawnActors, they have options to automatically spawn using the Distributed Actors – it’s probably the easiest way to use them.

To find out how to distribute your creation transactions you can follow the tutorial below, or check the rdInstBase Distributed Transactions section in the Reference Manual.


Section 9.2.2. Tutorials

Tutorial 16 – Distributed Transactions


Section 9.3. Spline Tools

Section 9.3.1. Introduction

rdInst contains functions to Split, Join, Trim, Populate and Manipulate splines – both while Editing and during run-time.

During runtime, the Spline Population routines recycle the SplineMeshComponents and doesn’t change any that haven’t moved – so it can provide some impressive speeds.

During Editing, there are still speed improvements over Blueprint population and it provides an easy-to-use function to quickly get your splines populated.


Section 9.3.2. How to use

There’s 3 main categories for the Spline editing, covered below:

Section 9.3.2.1. Populating Splines

There are two methods of populating splines with SplineMeshComponents.

  1. The first simply populates the spline with the specified mesh:

You can specify a start and end distance to populate – leaving the end at 0 populates the entire spline.

Specify a Material to override the default meshes material.

The Return value is the number of SplineMeshComponents created.

2. The second function uses a list of “rdSplinePopulateData” to choose the correct Mesh and details to use for the SplineMeshComponent at the time.

If you tick “Random”, a random item from the list is selected each time – otherwise they are sequentially added, looping if needed.

Section 9.3.2.2. Splitting/Joining Splines

You can split a spline into multiple sub-splines – each with their own actor attached to us. This can be done at runtime or during editing.

Ticking “Call BPFunctions” calls the Split event for the SplineBlueprint from where you can update anything regarding the split.

The function returns an array of SubSplines, the first spline in that list is our own spline.

You can Manipulate the Spline now as a whole (rdInst works out which subspline to manipulate) or directly on a subspline.

If you want, you can join the splines back together with the rdJoinSpline function.

Section 9.3.2.3. Manipulating Splines

rdInst provides routines for changing spline points in similar ways as a normal spline – but also provides a layer above to handle subsplines.

For details on the various routines, check the Spline Reference.


Section 9.3.3. Tutorials

Tutorial 30 – Real-time Spline Splitting and Joining

Tutorial 32 – Populating Splines


Section 9.4. Landscape Paint and Deform Tools

Section 9.4.1. Introduction


Section 9.4.2. How to use


Section 9.4.3. Tutorials


Section 9.5. Useful Editor and Runtime Utility Nodes/Functions

Section 9.5.1. Introduction

rdInst has many useful utility functions, both for run-time and for the editor – I’ll try and cover the most useful ones here in two sections:

Section 9.5.1.1 – Editor Utilities
  1. Probably the most used by me is the “rdDirty()” function – It can be very useful when you want to spawn and build from the constructor during editing, but not have all the hassle of not knowing what’s already constructed, the issues with attached actors – and of course, the 100 million times the constructor gets called when dragging etc. If you’re using the rdActor with managed instances or one of the standard build types, just call it and it will take care of it. If you want custom control, just derive rdBuild and add your code there – it happens after your actor as been created, and filters out multiple calls so only gets called once at the end.
  2. Another useful couple are “rdIsEditor()” – you can execute code only if in the editor, or visa-versa. Also “rdIsRealWorld()” can be used to execute code only in the level, not in Blueprint Editor viewports.
  3. This one is really useful too – “rdAddToTickHookList()” and “rdRemFromTickHookList()” – when in the Editor, you can receive ticks on your actor at any time.
  4. ReseatMeshInstances()” can be very useful if you change the pivot on a mesh – this allows you to offset the mesh in the prefab by any amount.
  5. There’s no easy way to set an Actors label! That’s where “rdSetActorLabel()” comes in.
  6. A useful function to find the current editor camera position: “rdGetEditorCameraPos()”.
Section 9.5.1.2 – Run-time Utilities
  1. rdGetCurrentScalability()” is an easy way to grab the current scalability.
  2. rdBakeVolumeTransformsForProxies()” is a realtime system that harvests the locations of objects in volumes such as PCG and builds fast scan data for swapping them to proxies.
  3. rdGetFunctionCycles()” is an easy to use way to time functions.
  4. rdTestForActorChange()” can be used to signal rdInst that instance transforms need to be updated.
  5. rdGetControlledPawn()” returns the currently controlled pawn (useful for multiplayer). Returns null if in a lobby or waiting to connect.
  6. rdDrawLine()” draws a debug line from 2 points, color and duration

Section 9.5.2. Tutorials


Section 9.6. PCG rdInst Spawner Nodes

Version 1.43 introduces support for spawning rdInst instances from within PCG scripts. You can spawn rdInstances with their indexes in an int32 attribute in the PointData.

These instances can then be manipulated in the same way as normal rdInst Instances.

The spawned instances are controlled with a PCG Managed Component class, so you’re able to use the PCG Components CleanUp() function at any time to remove the instances from the volume.

As rdInst instances are Recycled rather than removed. One good application is when you’re wanting to spawn and clear PCG volumes at runtime. If you clear a further volume before spawning the closer one – the instances don’t have to be created, saving a significant amount of time.

Another thing it can prove to useful for is when using Proxies with the instances.

To find out more about these nodes, you can see the tutorial below.


Section 9.6.1. Tutorials

Tutorial 43: PCG Custom Nodes


Section 9.7. Version History

Version 1.52

* Fixed: Adding a LongDistance Actor Proxy was crashing
* Fixed: camera icon showing in rdActor prefabs (untick Recurse Visibility)

Version 1.51

* Added: Tools to convert Prefabs data between the Fast Tables (don’t evaluate in the Editor Outliner) and Arrays
* Added: New routines for building the visibility in for actors and folders
* Added: Builds soft-reference array for sids to package and migrate correctly
* Changed: Class Picker now has a “None” option.
* Changed: rdSetActorVisibility and rdSetFolderVisibility now use fast hiding/showing rather than rebuilding
* Changed: Prefab Proxies are now generically Actor Proxies (any StaticMeshActor in the level can have a proxy)
* Fixed: Proxies not swapping back to instances when outside of radius
* Fixed: UE5.6 was rendering dragged in prefabs and causing collision issues
* Fixed: Removed doubled up long distance scan value
* Fixed: Show Probability was not working in prefabs
* Fixed: Playing level with nested prefabs was not randomizing them (was setting seed all the same)
* Fixed: Creating Prefab from old style mesh (non-X) wasn’t working
* Fixed: Show Probability for ChildActorComponents was not working
* Fixed: Nested-Nested prefabs were not getting their locations correct
* Fixed: Nested-Nested prefabs were not always hiding/showing correctly
* Fixed: Text in TextActor in SpawnActors not being saved correctly
* Fixed: Having 2 spawnactors with the same dataasset messing up pickups and TextActors
* Fixed: Pickup from SpawnActor picking up same object twice
* Fixed: Dragging a spawndata asset into the level is getting the z position wrong
* Fixed: PCGSpawnMeshWithIndices crash with index out of bounds (line 513) (fixed by adding check)
* Fixed: TextRenderActor/Actors with SpawnActor disappearing when playing

Version 1.50

* Added: rdBaseActor now fully supports override materials and reverse culling
* Added: rdActor now fully supports override materials and reverse culling
* Added: Placement structure now has an override material list and tickbox for reverse culling
* Added: Auto Pickup and Highlight system
* Added: PCG node options to add directly to rdSpawnActor Volumes
* Added: More stats to CalcInstanceCounts (num comps, recycle counts etc)
* Added: More Auto-Inst filtering
* Added: AutoInstance filter for physics enabled objects
* Added: Minimum num SMs before instancing setting for auto-instancing
* Added: Function in rdSpawnActor to return the indices used by a mesh
* Added: Randomization Settings Window
* Added: CreateSpawnActor window and tool
* Added: Proxy Settings Window
* Added: Procedural Actor can now spawn on static meshes
* Added: Auto-grow to the pooling
* Added: DebugHUD for instance stats and graphs
* Added: Delegates for Proxy swapping In and Out
* Added: Over-all max cull distance
* Added: Exposed proxy scan instance and actor results as public
* Added: Reseat BaseActor for very large worlds
* Added: Recyling and growth to the component pooling
* Added: Support for MegaLights swapping shadow rendering to VSM in proximity
* Added: Functions to Add/Remove/Change instances, recording and saving to rdActor and rdSpawnActor for BakedData
* Added: Added DataAssets for Placement Data Objects, Proxies, Instance Settings and Randomization
* Added: SpawnActors can now spawn relative to their location/rotation
* Added: Runtime Harvest actors into prefab in rdActor
* Added: Added Spawn and Procedural actors to the “Add Actors” panel and menu
* Added: Function to return size of pools
* Added: Function rdGrowActorPoolBy(x)
* Added: Dragged in DataAssets Populates their contents to the rdSpawn/rdProcedural Actors
* Changed: Categorized the base and subsystem methods
* Changed: Made swapout proxy distance slightly larger
* Changed: Moved auto-instancing over to base actor instances
* Changed: Impact Proxies now pass on their CollisionHit to the newly spawned ProxyActors
* Fixed: CalcInstanceCounts not including spawner instances
* Fixed: Converting level to WorldPartition would fail with error about casting rdInstBaseActor to MetaData
* Fixed: Building HLODs in a WorldPartition would fail with error about casting rdInstBaseActor to MetaData
* Fixed: Crash when re-loading level with populate actor
* Fixed: Instance Index passed into LoadProxyState Event was incorrect for all-mesh proxies
* Fixed: Pickup Interact Msg Remove was not being called when moving away from object but still looking at it
* Fixed: Pressing Interact would pick up objects already picked up
* Fixed: Proxies and Highlighted PickUps are refreshed after a proxy or instance/actor change

Version 1.44

* Added: Added auto grow to Pooling

Version 1.43

* Added: Add option to “Spawn on Server” for proxy swapping
* Added: Now turns on collision and scan interval when a proxy is added and it’s not already set
* Added: Option to use CullDistanceVolume Cull Settings for AutoInstancing
* Added: New functions to find instance index from location
* Added: Option to call ProxyLoad/Save events even without a SavedState object
* Added: PCG Custom Nodes to Spawn rdInst Instances
* Added: Option to pin proxyActor to level with rdRemoveProxyByProxy
* Added: New functions to get number of free isms in the recycle lists
* Added: Added Instance settings window
* Added: Added About window
* Added: Make functions for each proxy type
* Added: Pointer to the meshes ISMC/HISMC for proxies in rdActor and rdLoadProxyState Event
* Changed: Use the currently possessed pawn for proxy distance scanning
* Changed: ProxySetup structures now get passed with defaults in functions
* Fixed: rdSpawnActors weren’t initially spawning in packaged builds

Version 1.42

* Added: Agnostic function to return rdInst version number
* Added: Add support for swapping in/out data layers from WP levels for proxies
* Added: Add support for swapping in/out SM Instances for proxies
* Added: Add support for Collision Profile name for ISMs
* Added: Add support for Collision Profile name for SpawnActor place-on-ground
* Added: Add Sphere/Box trace through list of ISMCs and change CustomData on overlaps
* Added: Selection highlight around selected prefabs
* Fixed: Undo was loosing the instances
* Fixed: OnlyOne mode was not hiding instances from within childactors
* Fixed: Hide/Show from editor not hiding/showing the prefabs
* Fixed: Auto Instancing was broken
* Fixed: Add path to SM name references

Version 1.41

* Added: Support for SaveStates in non rdActors
* Added: Timeout for physics based proxies
* Fixed: Proxies with States would loose some of their data in certain situations

Version 1.40

* Added: Tool to convert all actors into ISMs at BeginPlay
* Added: Methods/Nodes to set/update custom data for ISMCs
* Added: New simplified pool system for tricky components
* Added: Flag to SetCustomData to Batch
* Added: CustomData routines/nodes to set customdata for unmanaged instance components
* Added: Routines to set all CustomData from Array
* Added: Flag to recycle pooled items when alloted objects maxed out
* Added: Flag to use ISMCs rather than HISMCs for Nanite meshes
* Added: Fast rdFillCustomData routines
* Changed: The rdInstBase is now visible in Outliner and contains all settings for rdInst
* Changed: Using rdAddInstanceLong now turns off bCreateFromArrays if it’s true
* Changed: Made the SetHarvest flag default to False in the function
* Fixed: bCreateFromArrays was defaulting to true by mistake
* Fixed: Added constructors with FObjectInitializer objects
* Fixed: Reseating meshes with scale and rotation was broken
* Fixed: Proxies were not swapping for baked spawn data
* Fixed: Baked Proxy data was not saving with the level

Version 1.37

  • Blueprint/C++ Profiling
  • New Function to return reference of PerInstanceCustomData
  • New Function to update PerInstanceCustomData (works with 4.25 up)
  • Actor Pooling (1.21 also introduces events for Pooled/Depooled)
  • Component Pooling
  • Version 1.20 introduces Distributed Transaction Spawning
  • Version 1.23 adds functions for getting and setting InstancedStaticMesh Custom data
  • Version 1.24 adds some utility functions for harvesting and assimilating
  • Version 1.24 adds Blueprint Nodes for:
    • IsEditor
    • Utility Nodes to query the Compilation status and wait for it to finish
    • Utility Nodes to “Mirror” objects in blueprints, and “Place on Ground”
  • Version 1.30 adds a scalable fast runtime Procedural Population system
  • Version 1.30 adds a Subsystem to use rdInst from any actor
  • Version 1.30 adds a new system for manually adding mesh instances to rdActors
  • Version 1.30 morphs return types for actor spawning and pooling
  • Version 1.35 Spline Manipulation and Population
  • Version 1.35 Proxy Actors
  • Version 1.35 rdSpawnActor
  • Version 1.35 rdPopulateActor

Version 1.36

  • Added: Official support for Android
  • Added: Made baking transforms for Volumes optional and added a return list of created FrdBakedSpawnItems
  • Added: Function to rdSpawnActor for tracing to landscape
  • Added: Offset Vector to spline population
  • Added: Gap value for spline population
  • Added: Offset Transform for destroyed proxy
  • Added: Routine to switch to destroyed mesh or prefab
  • Added: Implemented the “On NavMesh” option
  • Added: Ability to edit individual instance transforms
  • Added: Function to test is playing
  • Added: Routine to rdActor to get all instances for mesh in actor
  • Added: Routines to rdActor to set Per-Instance data for instances in the rdActor
  • Changed: Moved the IgnorePhysicalActors from rdProcedural to rdSpawn
  • Fixed: Remove proxies was not working for volumes
  • Fixed: Baking now bakes all scalability levels
  • Fixed: Slopes weren’t getting the line trace exact for the lower trace location
  • Fixed: Hiding PCG instances was not working
  • Fixed: Removed Python warning message when packaging project with rdInst