CARLA
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
APropActorFactory Class Reference

#include <PropActorFactory.h>

+ Inheritance diagram for APropActorFactory:

Public Member Functions

bool PostProcessProp (AActor *SpawnedActor, const FActorDescription &PropParams)
 
- Public Member Functions inherited from ACarlaActorFactory
 ACarlaActorFactory (const FObjectInitializer &ObjectInitializer)
 

Static Public Member Functions

static void LoadPropParametersArrayFromFile (const FString &FileName, TArray< FPropParameters > &OutPropParamsArray)
 
static void SavePropParametersArrayToFile (const TArray< FPropParameters > &PropParamsArray, const FString &FileName)
 
- Static Public Member Functions inherited from ACarlaActorFactory
static bool DefinitionReferencesPath (const FActorDefinition &Definition, const FString &MountPoint)
 True when the definition's class or any attribute/variation value points at content under MountPoint.
 

Protected Attributes

TArray< FActorDefinition > Definitions
 
TArray< FPropParameters > PropsParams
 

Private Member Functions

virtual TArray< FActorDefinition > GetDefinitions () override
 Retrieve the definitions of the static mesh actor.
 
virtual void ReleaseContentPack (const FString &MountPoint) override
 Drop every cached definition, parameter and loaded asset that refers to content under MountPoint ("/<Pack>/"), so a content pack can be unmounted; the dropped blueprints are gone until the next episode.
 
virtual FActorSpawnResult SpawnActor (const FTransform &SpawnAtTransform, const FActorDescription &ActorDescription) override
 Spawn an actor based on ActorDescription and Transform.
 

Static Private Member Functions

static FString FPropParametersArrayToJson (const TArray< FPropParameters > &PropParamsArray)
 
static TSharedPtr< FJsonObject > FPropParametersToJsonObject (const FPropParameters &PropParams)
 
static bool JsonToFPropParameters (const TSharedPtr< FJsonObject > JsonObject, FPropParameters &OutPropParams)
 
static bool JsonToFPropParametersArray (const FString &JsonString, TArray< FPropParameters > &OutPropParamsArray)
 

Private Attributes

TMap< FString, TObjectPtr< UStaticMesh > > MeshCacheByPath
 Mesh cache keyed by mesh path (same string stored in ActorDescription.Variations["mesh_path"]).
 

Detailed Description

Definition at line 21 of file PropActorFactory.h.

Member Function Documentation

◆ FPropParametersArrayToJson()

FString APropActorFactory::FPropParametersArrayToJson ( const TArray< FPropParameters > &  PropParamsArray)
staticprivate

Definition at line 220 of file PropActorFactory.cpp.

References FPropParametersToJsonObject().

Referenced by SavePropParametersArrayToFile().

◆ FPropParametersToJsonObject()

TSharedPtr< FJsonObject > APropActorFactory::FPropParametersToJsonObject ( const FPropParameters &  PropParams)
staticprivate

◆ GetDefinitions()

TArray< FActorDefinition > APropActorFactory::GetDefinitions ( )
overrideprivatevirtual

◆ JsonToFPropParameters()

bool APropActorFactory::JsonToFPropParameters ( const TSharedPtr< FJsonObject >  JsonObject,
FPropParameters &  OutPropParams 
)
staticprivate

◆ JsonToFPropParametersArray()

bool APropActorFactory::JsonToFPropParametersArray ( const FString &  JsonString,
TArray< FPropParameters > &  OutPropParamsArray 
)
staticprivate

Definition at line 308 of file PropActorFactory.cpp.

References JsonToFPropParameters().

Referenced by LoadPropParametersArrayFromFile().

◆ LoadPropParametersArrayFromFile()

void APropActorFactory::LoadPropParametersArrayFromFile ( const FString &  FileName,
TArray< FPropParameters > &  OutPropParamsArray 
)
static

Definition at line 341 of file PropActorFactory.cpp.

References JsonToFPropParametersArray().

Referenced by GetDefinitions().

◆ PostProcessProp()

bool APropActorFactory::PostProcessProp ( AActor *  SpawnedActor,
const FActorDescription &  PropParams 
)

Referenced by SpawnActor().

◆ ReleaseContentPack()

void APropActorFactory::ReleaseContentPack ( const FString &  MountPoint)
overrideprivatevirtual

Drop every cached definition, parameter and loaded asset that refers to content under MountPoint ("/<Pack>/"), so a content pack can be unmounted; the dropped blueprints are gone until the next episode.

Reimplemented from ACarlaActorFactory.

Definition at line 169 of file PropActorFactory.cpp.

References ACarlaActorFactory::DefinitionReferencesPath(), Definitions, FPropParameters::Mesh, MeshCacheByPath, and PropsParams.

◆ SavePropParametersArrayToFile()

void APropActorFactory::SavePropParametersArrayToFile ( const TArray< FPropParameters > &  PropParamsArray,
const FString &  FileName 
)
static

Definition at line 243 of file PropActorFactory.cpp.

References FPropParametersArrayToJson().

◆ SpawnActor()

FActorSpawnResult APropActorFactory::SpawnActor ( const FTransform &  SpawnAtTransform,
const FActorDescription &  ActorDescription 
)
overrideprivatevirtual

Spawn an actor based on ActorDescription and Transform.

Precondition
ActorDescription is expected to be derived from one of the definitions retrieved with GetDefinitions.

Reimplemented from ACarlaActorFactory.

Definition at line 68 of file PropActorFactory.cpp.

References FActorSpawnResult::Actor, UActorBlueprintFunctionLibrary::ActorAttributeToString(), FActorDescription::Class, FActorDescription::Id, IsValid(), MeshCacheByPath, PostProcessProp(), FActorSpawnResult::Status, and FActorDescription::Variations.

Member Data Documentation

◆ Definitions

TArray<FActorDefinition> APropActorFactory::Definitions
protected

Definition at line 53 of file PropActorFactory.h.

Referenced by GetDefinitions(), and ReleaseContentPack().

◆ MeshCacheByPath

TMap<FString, TObjectPtr<UStaticMesh> > APropActorFactory::MeshCacheByPath
private

Mesh cache keyed by mesh path (same string stored in ActorDescription.Variations["mesh_path"]).

Populated from PropsParams in GetDefinitions() so that SpawnActor() avoids the per-spawn synchronous LoadObject on the game thread. Cache-miss fall back to LoadObject with a warning log.

Definition at line 64 of file PropActorFactory.h.

Referenced by GetDefinitions(), ReleaseContentPack(), and SpawnActor().

◆ PropsParams

TArray<FPropParameters> APropActorFactory::PropsParams
protected

Definition at line 55 of file PropActorFactory.h.

Referenced by GetDefinitions(), and ReleaseContentPack().


The documentation for this class was generated from the following files: