Files
UnrealEngineUWP/Engine/Source/Editor/UnrealEd/Private/HierarchicalLODVolume.cpp
Sebastien Lussier 64071198b6 Fixed issue with non axis aligned HLOD volumes
* Brushes or rotated volumes were including more actors than they should have
#rb jeanfrancois.dube
#jira none
#preflight 62824c41734d06577025f099

[CL 20222727 by Sebastien Lussier in ue5-main branch]
2022-05-16 09:21:37 -04:00

49 lines
1.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "HierarchicalLODVolume.h"
#include "Engine/CollisionProfile.h"
#include "Components/BrushComponent.h"
#include "Algo/AllOf.h"
AHierarchicalLODVolume::AHierarchicalLODVolume(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
, bIncludeOverlappingActors(false)
{
if (UBrushComponent* MyBrushComponent = GetBrushComponent())
{
MyBrushComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision);
MyBrushComponent->SetCanEverAffectNavigation(false);
MyBrushComponent->SetGenerateOverlapEvents(false);
}
bNotForClientOrServer = true;
bIsEditorOnlyActor = true;
bColored = true;
BrushColor.R = 255;
BrushColor.G = 100;
BrushColor.B = 255;
BrushColor.A = 255;
}
bool AHierarchicalLODVolume::AppliesToHLODLevel(int32 LODIdx) const
{
return ApplyOnlyToSpecificHLODLevels.Num() == 0 ||
ApplyOnlyToSpecificHLODLevels.Contains(LODIdx);
}
bool AHierarchicalLODVolume::IsActorIncluded(const AActor* InActor) const
{
FBox ActorBoundingBox = InActor->GetComponentsBoundingBox(true);
if (bIncludeOverlappingActors)
{
return EncompassesPoint(ActorBoundingBox.GetCenter(), ActorBoundingBox.GetExtent().Size());
}
else
{
FVector Vertices[8];
ActorBoundingBox.GetVertices(Vertices);
return Algo::AllOf(Vertices, [this](const FVector& Vertex) { return EncompassesPoint(Vertex); });
}
}