Skip to content

Instantly share code, notes, and snippets.

@olegknyazev
Last active October 28, 2018 17:07
Show Gist options
  • Save olegknyazev/8c692bb06f018942a51a2c91f684afb9 to your computer and use it in GitHub Desktop.
Save olegknyazev/8c692bb06f018942a51a2c91f684afb9 to your computer and use it in GitHub Desktop.
About Formatting: A highly 'professional' style
void AActor::GetAttachedActors(TArray<class AActor*>& OutActors) const
{
OutActors.Reset();
if (RootComponent != nullptr)
{
// Current set of components to check
TInlineComponentArray<USceneComponent*> CompsToCheck;
// Set of all components we have checked
TInlineComponentArray<USceneComponent*> CheckedComps;
CompsToCheck.Push(RootComponent);
// While still work left to do
while(CompsToCheck.Num() > 0)
{
// Get the next off the queue
const bool bAllowShrinking = false;
USceneComponent* SceneComp = CompsToCheck.Pop(bAllowShrinking);
// Add it to the 'checked' set, should not already be there!
if (!CheckedComps.Contains(SceneComp))
{
CheckedComps.Add(SceneComp);
AActor* CompOwner = SceneComp->GetOwner();
if (CompOwner != nullptr)
{
...
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment