void FHierarchicalLODUtilities::DestroyCluster(ALODActor* InActor) { // Find if it has a parent ALODActor AActor* Actor = CastChecked<AActor>(InActor); UWorld* World = Actor->GetWorld(); ALODActor* ParentLOD = GetParentLODActor(InActor); const FScopedTransaction Transaction(LOCTEXT("UndoAction_DeleteCluster", "Deleting a (invalid) Cluster")); Actor->Modify(); World->Modify(); if (ParentLOD != nullptr) { ParentLOD->Modify(); ParentLOD->RemoveSubActor(Actor); } // Clean out sub actors and update their LODParent while (InActor->SubActors.Num()) { AActor* SubActor = InActor->SubActors[0]; SubActor->Modify(); InActor->RemoveSubActor(SubActor); } // Also destroy the cluster's data DestroyClusterData(InActor); World->DestroyActor(InActor); if (ParentLOD != nullptr && !ParentLOD->HasValidSubActors()) { DestroyCluster(ParentLOD); } }
void FHierarchicalLODUtilities::DestroyLODActor(ALODActor* InActor) { const FScopedTransaction Transaction(LOCTEXT("UndoAction_DeleteLODActor", "Delete LOD Actor")); UWorld* World = InActor->GetWorld(); World->Modify(); InActor->Modify(); ALODActor* ParentActor = FHierarchicalLODUtilities::GetParentLODActor(InActor); FHierarchicalLODUtilities::DestroyCluster(InActor); World->DestroyActor(InActor); if (ParentActor && !ParentActor->HasValidSubActors()) { ParentActor->Modify(); FHierarchicalLODUtilities::DestroyLODActor(ParentActor); } }