Section 5. rdProceduralActor

Section 5.1. rdProceduralActor – Settings

The rdProceduralActor just passes the data in a rdSpawnData structure through to the Population routine in rdInstBaseActor – check out those settings to get more information.

There is only one extra setting – an array of PhysicalMaterials that are passed through as an “ignore” list.

// [rdInst v1.35] List of Physical Materials to exclude spawning on
TArray<UPhysicalMaterial*>			ignorePhysicalMatsList;

Section 5.2. rdProceduralActor – Spawning

// [rdInst v1.35] Spawns the Objects described in the list of items
virtual void rdSpawn() override;

Section 5.3. rdProceduralActor – Baking

// [rdInst v1.35] Bakes the procedural items into lists ready to be spawned very quickly
virtual void rdBakeSpawnData(const FrdSpawnData& bakeData) override;

// [rdInst v1.35] Bakes the spawn items into lists ready to be spawned very quickly
virtual void rdBakeSpawnData() override;

Section 5.4. rdProceduralActor – DataAssets

// ObjectPlacement Structure
USTRUCT(BlueprintType,meta=(HasNativeBreak="/Script/rdInst.rdActor.BreakPlacementData",HasNativeMake="/Script/rdInst.rdActor.MakePlacementData"))
struct RDINST_PLUGIN_API FrdObjectPlacementData {
	GENERATED_BODY()
public:

	// The StaticMesh to spawn Instances from
	UPROPERTY(Category="rdPlacement|Source",EditAnywhere,meta=(ShowOnlyInnerProperties))
	FrdInstanceSetup mesh;

	// Actor Class for Spawning Actors
	UPROPERTY(Category="rdPlacement|Source",EditAnywhere)
	UClass*			actorClass=nullptr;

	// Property data for Spawning Actors (must have a valid Actor Class)
	UPROPERTY(Category="rdPlacement|Source",EditAnywhere)
	FString			strProps;

	// Niagara System to Spawn
	UPROPERTY(Category="rdPlacement|Source",EditAnywhere)
	UNiagaraSystem*	vfx=nullptr;

	// Density for spawning this Object (1.0=default)
	UPROPERTY(Category="rdPlacement|Positioning",EditAnywhere)
	float			density=1.0f;

	// X Offset into the spawn grid
	UPROPERTY(Category="rdPlacement|Positioning",EditAnywhere)
	float			gridOffsetX=0.0f;

	// Y Offset into the spawn grid
	UPROPERTY(Category="rdPlacement|Positioning",EditAnywhere)
	float			gridOffsetY=0.0f;

	// Grid X Variance within the spawn grid (1.0=whole grid width, 0.5=inner half)
	UPROPERTY(Category="rdPlacement|Positioning",EditAnywhere)
	float			gridVarianceW=0.8f;

	// Grid Y Variance within the spawn grid (1.0=whole grid height, 0.5=inner half)
	UPROPERTY(Category="rdPlacement|Positioning",EditAnywhere)
	float			gridVarianceH=0.8f;

	UPROPERTY(Category="rdPlacement|SpawnMode",EditAnywhere)
	TEnumAsByte<rdSpawnMode> spawnMode=rdSpawnMode::RDSPAWNMODE_DEFAULT;

	// Stream Distance - distance to stream this object in (-1 means use Actors default)
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="rdPlacement|Streaming")
	float streamDistance=-1;

	// The Radius to spawn actors from the player when using rdSpawnMode::Local
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="rdPlacement|SpawnMode")
	float localRadius=10000.0f;

	// The Distance to spawn actors within the View Frustum of the player when using rdSpawnMode::ViewFrustum
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="rdPlacement|SpawnMode")
	float viewFrustumDistance=50000.0f;

	// The Extended area around the View Frustum (in degrees) to spawn when using rdSpawnMode::ViewFrustum
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="rdPlacement|SpawnMode")
	float viewFrustumExtend=2.0f;

	// Option to Pool the Actor that is being Spawned
	UPROPERTY(Category="rdPlacement|Pooling",EditAnywhere)
	bool			pooled=false;

	// Number of Actors to Pool
	UPROPERTY(Category="rdPlacement|Pooling",EditAnywhere)
	int32			numToPool=20;

	// Offset to apply to the spawned Object from its generated location
	UPROPERTY(Category="rdPlacement|Randomization",EditAnywhere)
	FVector			offset=FVector(0,0,0);
	// Minimum Gap between Objects
	UPROPERTY(Category="rdPlacement|Randomization",EditAnywhere)
	float			minGap=0.0f;
	// When Ticked, Overall Scale for the Object is taken from the X scale
	UPROPERTY(Category="rdPlacement|Randomization",EditAnywhere)
	bool			bUniformScale=true;
	// Minimum Scale to Apply to the Object
	UPROPERTY(Category="rdPlacement|Randomization",EditAnywhere)
	FVector			minScale=FVector(0.8f,0.8f,0.8f);
	// Maximum Scale to Apply to the Object
	UPROPERTY(Category="rdPlacement|Randomization",EditAnywhere)
	FVector			maxScale=FVector(1.3f,1.3f,1.3f);

	// When true, The Yaw of the Object is Randomized
	UPROPERTY(Category="rdPlacement|Randomization",EditAnywhere)
	bool			bRandomYaw=true;
	// When true, the object is aligned to the normal of the Landscape or Mesh
	UPROPERTY(Category="rdPlacement|Randomization",EditAnywhere)
	bool			bAlignToNormal=false;
	// Angle defining the minimum slope from vertical to restrict to
	UPROPERTY(Category="rdPlacement|Randomization",EditAnywhere)
	float			minSlope=45.0f;
	// Scan to the ground and place on the Z location
	UPROPERTY(Category="rdPlacement|Randomization",EditAnywhere)
	bool			bPlaceOnGround=true;
	// Filter to only add where there is NavMesh
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="rdPlacement|Randomization")
	bool			bOnNavMesh=false;
	// Ensure the base of the Object is at the lowest Z location of the placement area
	UPROPERTY(Category="rdPlacement|Randomization",EditAnywhere)
	bool			bFixSlopePlacement=true;
	// Radius to scan around to fix the Z placement
	UPROPERTY(Category="rdPlacement|Randomization",EditAnywhere)
	float			slopedRadius=20.0f;

	// When true, the density value is set to the current splatmaps value
	UPROPERTY(Category="rdPlacement|Splatmap",EditAnywhere)
	bool			bUseSplatDensity=true;
	// Channel of the splatmap to use for the placement
	UPROPERTY(Category="rdPlacement|Splatmap",EditAnywhere)
	int8			splatChannel=0; // same splat time, same splat channel...
	// minimum splat color for including
	UPROPERTY(Category="rdPlacement|Splatmap",EditAnywhere)
	float			splatMinRange=0.333f;
	// maximum splat color for including
	UPROPERTY(Category="rdPlacement|Splatmap",EditAnywhere)
	float			splatMaxRange=1.0f;

	// When placing on ground, you can add a list of PhysicalMaterials to populate on
	UPROPERTY(Category="rdPlacement|Misc",EditAnywhere)
	TArray<UPhysicalMaterial*>	filterToPhysicalMatsList;

	// Proxy for this (StaticMesh) Object
	UPROPERTY(Category="rdPlacement|Misc",EditAnywhere)
	FrdProxySetup				proxy;

	// Movement class for this Placement type
	UPROPERTY(Category="rdPlacement|Misc",EditAnywhere)
	TObjectPtr<UrdEntityMovementBase>		movement=nullptr;

	// The DataAsset to use as the source of the Placement Data. If you want to customize, just set this to null
	UPROPERTY(Category="rdPlacement|System",EditAnywhere)
	FString	PlacementDataAsset;

	// The DataAsset Placement Item ID used as the source of the Placement Data. If you want to customize, just set this to null
	UPROPERTY(Category="rdPlacement|System",EditAnywhere)
	FString	PlacementDataAssetID;

	// The MultiDataAsset used as the source of the Placement Data. If you want to customize, just set this to null
	UPROPERTY(Category="rdPlacement|System",EditAnywhere)
	FString	MultiPlacementDataAsset;

	UPROPERTY(Category=rdHidden,BlueprintReadWrite)
	TArray<AActor*>				actorList;

	UPROPERTY(Category=rdHidden,BlueprintReadWrite)
	TArray<UStaticMeshComponent*> smcList;

	UPROPERTY(Category=rdHidden,BlueprintReadWrite)
	TArray<UNiagaraSystem*>		niagaraList;

	TArray<UNiagaraComponent*>	vfxList;

	FName						sid;

	UPROPERTY(Category="rdPlacement|System",EditAnywhere)
	TWeakObjectPtr<UInstancedStaticMeshComponent> ismc=nullptr;
};

// Placement DataAsset
UCLASS(BlueprintType)
class RDINST_PLUGIN_API UrdPlacementDataAsset : public UPrimaryDataAsset {
	GENERATED_BODY()
public:

	// Label that gets displayed in the Quick Settings Menu
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category=rdPlacement)
	FName label;

	// Tooltip that gets displayed in the Quick Settings Menu
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category=rdPlacement)
	FString tooltip;

	FPrimaryAssetId GetPrimaryAssetId() const override { return FPrimaryAssetId("rdInstPlacementAssets",GetFName()); }

	// Array of Placement DataAssets describing your objects to populate with
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category=rdMultiPlacement)
	TArray<FrdObjectPlacementData> Placements;
};

// MultiPlacement DataAsset
UCLASS(BlueprintType)
class RDINST_PLUGIN_API UrdMultiPlacementDataAsset : public UPrimaryDataAsset {
	GENERATED_BODY()
public:

	// Label that gets displayed in the Quick Settings Menu
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category=rdMultiPlacement)
	FName label;

	// Tooltip that gets displayed in the Quick Settings Menu
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category=rdMultiPlacement)
	FString tooltip;

	FPrimaryAssetId GetPrimaryAssetId() const override { return FPrimaryAssetId("rdInstMultiPlacementAssets",GetFName()); }

	// Array of Placement DataAssets describing your objects to populate with
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category=rdMultiPlacement)
	TArray<TSoftObjectPtr<UrdPlacementDataAsset>> PlacementDataAssets;
};