12#include "AssetRegistry/AssetRegistryModule.h"
13#include "Components/SkeletalMeshComponent.h"
14#include "Components/StaticMeshComponent.h"
15#include "Engine/SkeletalMesh.h"
16#include "Engine/StaticMesh.h"
17#include "Engine/World.h"
18#include "Kismet/GameplayStatics.h"
19#include "TimerManager.h"
23 PrimaryActorTick.bCanEverTick =
false;
35 UWorld* World = GetWorld();
42 LabelMap = UEnumUtilities::CreateStringEnumMap<ELabels>(
"/Script/Agrarsense.ELabels");
48 World->GetTimerManager().SetTimer(Handle, FTimerDelegate::CreateLambda([
this]
56 Super::EndPlay(EndPlayReason);
63 TArray<AActor*> Actors;
64 UGameplayStatics::GetAllActorsOfClass(GetWorld(), AActor::StaticClass(), Actors);
66 for (AActor* Actor : Actors)
103 TArray<UStaticMeshComponent*> StaticMeshComponents;
104 Actor.GetComponents<UStaticMeshComponent>(StaticMeshComponents);
105 for (UStaticMeshComponent* Component : StaticMeshComponents)
115 TArray<USkeletalMeshComponent*> SkeletalMeshComponents;
116 Actor.GetComponents<USkeletalMeshComponent>(SkeletalMeshComponents);
117 for (USkeletalMeshComponent* Component : SkeletalMeshComponents)
130 Component.SetRenderCustomDepth(SetRenderCustomDepth && (Label !=
ELabels::None));
131 Component.SetCustomDepthStencilValue(
static_cast<int>(Label) + 1);
144 UE_LOG(LogTemp, Warning, TEXT(
"Tagger.cpp: Missing Label: %s"), *String);
154 if (!StaticMeshComponentPtr)
165 UStaticMesh* MeshPtr = StaticMeshComponentPtr->GetStaticMesh();
173 StaticMeshComponentPtr->ComponentTags.Insert(FName(Name), 0);
184 if (!USkeletalMeshComponentPtr)
195 USkeletalMesh* PhysicsAsset = USkeletalMeshComponentPtr->GetSkeletalMeshAsset();
203 USkeletalMeshComponentPtr->ComponentTags.Insert(FName(Name), 0);
217 if (!Path.Contains(
"Models"))
222 TArray<FString> StringArray;
223 Path.ParseIntoArray(StringArray, TEXT(
"/"),
false);
225 FolderName = StringArray[StringArray.Num() - 2];
bool IsCustomDepthSetup() const
virtual void BeginPlay() override
TMap< FString, ELabels > LabelMap
ELabels GetLabelFromPath(const FString &Path, FString &FolderName)
ELabels GetLabelFromStaticComponent(UStaticMeshComponent *StaticMeshComponentPtr)
void OnActorSpawned(AActor *Actor)
ELabels GetLabelFromTag(const T *Object)
void SetStencilValue(UPrimitiveComponent &Component, const ELabels &Label, const bool SetRenderCustomDepth)
FDelegateHandle ActorSpawnedDelegateHandle
ELabels GetLabelFromSkeletalMeshComponent(USkeletalMeshComponent *USkeletalMeshComponentPtr)
void TagActor(AActor &Actor, bool TagForSemanticSegmentation)
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override
ELabels GetLabelFromString(const FString &String)
static bool IsPlayingInMainMenu()