Return sm names

This commit is contained in:
Blyron 2024-10-18 13:34:01 +02:00 committed by Blyron
parent 359f723d20
commit 95728ec9a0
2 changed files with 7 additions and 2 deletions

View File

@ -239,8 +239,9 @@ void UMapGenFunctionLibrary::CleanupGEngine(){
#endif
}
void UMapGenFunctionLibrary::ChangeStaticMeshesInTheLevelForInstancedStaticMeshes(UWorld* World, TArray<UStaticMesh*> Filter, int MinNumOfInstancesToBeChanged)
TArray<AInstancedStaticMeshActor*> UMapGenFunctionLibrary::ChangeStaticMeshesInTheLevelForInstancedStaticMeshes(UWorld* World, TArray<UStaticMesh*> Filter, int MinNumOfInstancesToBeChanged)
{
TArray<AInstancedStaticMeshActor*> Result;
TArray<AActor*> FoundActors;
UGameplayStatics::GetAllActorsOfClass(World, AStaticMeshActor::StaticClass(), FoundActors);
TMap<UStaticMesh*, TArray<AStaticMeshActor*>> ActorsToCheckIfReplacedMap;
@ -272,9 +273,13 @@ void UMapGenFunctionLibrary::ChangeStaticMeshesInTheLevelForInstancedStaticMeshe
{
InstancedStaticMeshActor->GetInstancedStaticMeshComponent()->SetStaticMesh(CurrentPair.Key);
InstancedStaticMeshActor->GetInstancedStaticMeshComponent()->AddInstances(TransformsToBeInstanced, false, true);
InstancedStaticMeshActor->Rename(*(CurrentPair.Key->GetName()));
Result.Add(InstancedStaticMeshActor);
}
}
}
return Result;
}
void UMapGenFunctionLibrary::RevertStaticMeshesInTheLevelForInstancedStaticMeshes(UWorld* World, TArray<UStaticMesh*> Filter)

View File

@ -55,7 +55,7 @@ public:
// This function will count instances of each static mesh in the level, if there are > MinNumOfInstancesToBeChanged they will be changed by instanced static meshes
// to reduce draw calls
UFUNCTION(BlueprintCallable)
static void ChangeStaticMeshesInTheLevelForInstancedStaticMeshes(UWorld* World, TArray<UStaticMesh*> Filter, int MinNumOfInstancesToBeChanged = 20);
static TArray<class AInstancedStaticMeshActor*> ChangeStaticMeshesInTheLevelForInstancedStaticMeshes(UWorld* World, TArray<UStaticMesh*> Filter, int MinNumOfInstancesToBeChanged = 20);
// This function will removed instanced static meshes in the level and place static mesh actors instead
UFUNCTION(BlueprintCallable)