Section 3. rdInstBaseActor

This Class is for a singular level actor, one is automatically created the first time it’s needed. It Manages the Instances for all Static Meshes, every ArdActor holds a pointer to it. This actor is hidden from the Editor and is not saved with the level.

// Adds an Instance of the passed in StaticMesh to the level using the passed in Transform
int32 rdAddInstance(const AActor* instOwner,UStaticMesh* mesh,const FTransform& transform);

// Finds and returns the UHierarchicalInstancedStaticMeshComponent assigned to the StaticMesh
UHierarchicalInstancedStaticMeshComponent* rdGetInstanceGen(UStaticMesh* mesh);

// Adds an Instance of the StaticMesh from the passed HISMC to the level using the passed in Transform
int32 rdAddInstanceFast(UHierarchicalInstancedStaticMeshComponent* instGen,const FTransform& transform);

// Changes the Transform of the Instance
void rdChangeInstanceTransformsForOwner(const AActor* instOwner,const FTransform& transform,bool worldSpace,bool markDirty,bool teleport);

// Returns the rdActor that owns the Instance or a nullptr if the passed in component is not a HISMC or index not valid
ArdActor* rdGetrdActorFromInstanceIndex(UPrimitiveComponent* comp,int32 index);

// Returns the last index created of the passed in StaticMesh. If none exist, -1 is returned
int32 rdGetLastInstanceIndex(const AActor* instOwner,UStaticMesh* mesh);

// Removes the ISM for the UStaticMesh and Index
void rdRemoveInstance(UStaticMesh* mesh,int32 index);

// Removes all ISMs that belong to the passed in Actor
void rdRemInstancesForOwner(const AActor* instOwner);

// Removes all ISMs and HISMCs in this BaseActor
void rdRemAllInstances();

// Goes through and Counts all Instances of all StaticMeshes in this BaseActor
void rdCalcInstanceCounts();

// Recreates all the ISMs and HISMCs in this BaseActor
void rdRecreateInstances();

// Contains the return from Counting the ISMs
int32 numInstances;

// Map of StaticMesh Keys with Arrays of Instances as the Values
TMap<const UStaticMesh*,FrdInstList> instList;

// Finds the Attached HISMC for the StaticMesh (referenced by Name)
UHierarchicalInstancedStaticMeshComponent* FindISMCforMesh(const FName& name);

// Sets the Instance Settings (eg shadows) contained in the StaticMesh in the HISMC
void SetHISMCdata(UStaticMesh* mesh,UHierarchicalInstancedStaticMeshComponent* hismc);
New for Version 1.10 (Actor Pooling)
// Allocates "numToPool" number of the actorClass for rapid reuse
void rdPoolActor(UClass* actorClass,int32 numToPool,bool premake);

// ReAllocates "numToPool" number of the actorClass
bool rdSetActorPoolSize(UClass* actorClass,int32 numToPool,bool premake);

// Removes the Pool of Actors for the actorClass
void rdRemoveActorPool(UClass* actorClass);

// Gets the next free actorClass in the Actor Pool, returns nullptr if no free
AActor* rdGetActorFromPool(UClass* actorClass,const FTransform& tran);

// Removes an allocated Actor from the Actor Pool
void rdRemoveActorFromPool(AActor* actor);
New for Version 1.20
// Adds Instances of the StaticMesh from the passed HISMC to the level using the passed in Transform Array
int32 rdAddInstancesFast(UHierarchicalInstancedStaticMeshComponent* instGen,const TArray<FTransform>& transforms);

// Adds the array of Instances of the StaticMesh from the passed HISMC to the level using the passed in Transforms
int32 rdAddInstancesFastOwned(const AActor* instOwner,UHierarchicalInstancedStaticMeshComponent* instGen,const TArray<FTransform>& transforms);

// Adds the array of Instances of the StaticMesh distributed to "transactionsPerTick" each tick. Returns immediately
bool rdAddDistributedInstances(UStaticMesh* mesh,const TArray<FTransform>& transforms,int32 transactionsPerTick);

// Sets the rdActor to use to handle Pooled and Depooled events
void rdSetPoolListener(ArdActor* actor);

New for version 1.24
// Gets a reference to the Per-Instance CustomData for the mesh
TArray<float>& rdGetCustomDataPtr(UStaticMesh* mesh,int32& numData);

// Sets a value to the Per-Instance CustomData for the mesh
void rdSetCustomData(UStaticMesh* mesh,int32 instanceIndex,int32 dataIndex,float value);

// Updates the Per-Instance CustomData for the mesh
void rdUpdateCustomData(UStaticMesh* mesh);

// Returns the number of assets compiling or waiting for compile
int32 rdGetNumAssetsCompiling();

// waits for all assets to finish compiling
void rdWaitForCompiling();

// Submits all materials for compile
void rdSubmitMaterialsForCompile();

// Is Editor
bool rdIsEditor();
New for version 1.30
// Procedurally places the meshes over the volume
int32 rdProceduralGenerate(const TArray<FrdObjectPlacementData>& objects,const FTransform& originTransform,const TArray<FrdObjectPlacementScaleData>& placeData,int seed=0,float gridOffsetX=0,float gridOffsetY=0);

// return the z position of the landscape at x,y - optionally fixing slope z offsets
float getLandscapeZ(float x,float y,float radius,FHitResult& hit,bool fixSlopes=false);

// Returns the number of assets compiling or waiting for compile
int32 rdGetNumAssetsCompiling();

// waits for all assets to finish compiling
void rdWaitForCompiling();

// Submits all materials for compile
void rdSubmitMaterialsForCompile();

// Is Editor
bool rdIsEditor();

// Get Landscape Bounds (Editor only)
FBox rdGetLandscapeBounds(ALandscape* landscape);

// Get Current average Scalabity (0-4) (UE5.0 up)
rdScalabilityScale rdGetCurrentScalability();

// Get Current Scalabity for specified area (0-4) (UE5.0 up)
rdScalabilityScale rdGetCurrentScalabilityFor(rdScalabilityType stype);

// Get Current Resolution Scale (0-100) (UE5.0 up)
float rdResolutionScale();

// Get Scalability Benchmark Results for CPU and GPU (UE5.0 up)
bool rdGetScalabilityBenchmarks(float& bmCpu,float& bmGpu);

// Bool to use HISMs rather than ISMs - defaults to True
bool bUseHISMs=true;

// Add PhysicalMaterials to this Ignore List (for the procedural population)
TArray<UPhysicalMaterial*> ignorePMaps;