You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Moved bounds computation from the component to the SmartObject definition #rb trivial #preflight 61d88fa24c252480ca3a0927 #ROBOMERGE-AUTHOR: yoan.stamant #ROBOMERGE-SOURCE: CL 18549211 in //UE5/Release-5.0/... via CL 18549240 #ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v899-18417669) [CL 18549270 by yoan stamant in ue5-release-engine-test branch]
105 lines
2.2 KiB
C++
105 lines
2.2 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SmartObjectComponent.h"
|
|
#include "GameFramework/Actor.h"
|
|
#include "SmartObjectSubsystem.h"
|
|
#include "VisualLogger/VisualLogger.h"
|
|
|
|
#if WITH_EDITOR
|
|
#include "Engine/World.h"
|
|
#endif
|
|
|
|
|
|
USmartObjectComponent::USmartObjectComponent(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
|
|
}
|
|
|
|
void USmartObjectComponent::OnRegister()
|
|
{
|
|
Super::OnRegister();
|
|
|
|
const UWorld* World = GetWorld();
|
|
if (World == nullptr)
|
|
{
|
|
return;
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
// Do not process any component registered to preview world
|
|
if (World->WorldType == EWorldType::EditorPreview)
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
|
|
if (HasAnyFlags(RF_ClassDefaultObject))
|
|
{
|
|
return;
|
|
}
|
|
|
|
/** Do not register components that don't have a valid definition */
|
|
if (!IsValid(DefinitionAsset))
|
|
{
|
|
return;
|
|
}
|
|
|
|
// Note: we don't report error or ensure on missing subsystem since it might happen
|
|
// in various scenarios (e.g. inactive world)
|
|
if (USmartObjectSubsystem* Subsystem = USmartObjectSubsystem::GetCurrent(World))
|
|
{
|
|
Subsystem->RegisterSmartObject(*this);
|
|
}
|
|
}
|
|
|
|
void USmartObjectComponent::OnUnregister()
|
|
{
|
|
Super::OnUnregister();
|
|
|
|
const UWorld* World = GetWorld();
|
|
if (World == nullptr)
|
|
{
|
|
return;
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
// Do not process any component registered to preview world
|
|
if (World->WorldType == EWorldType::EditorPreview)
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
|
|
if (HasAnyFlags(RF_ClassDefaultObject))
|
|
{
|
|
return;
|
|
}
|
|
|
|
/** Do not register components that don't have a valid definition */
|
|
if (!IsValid(DefinitionAsset))
|
|
{
|
|
return;
|
|
}
|
|
|
|
// Note: we don't report error or ensure on missing subsystem since it might happen
|
|
// in various scenarios (e.g. inactive world, AI system is cleaned up before the components gets unregistered, etc.)
|
|
if (USmartObjectSubsystem* Subsystem = USmartObjectSubsystem::GetCurrent(World))
|
|
{
|
|
Subsystem->UnregisterSmartObject(*this);
|
|
}
|
|
}
|
|
|
|
FBox USmartObjectComponent::GetSmartObjectBounds() const
|
|
{
|
|
FBox BoundingBox(ForceInitToZero);
|
|
|
|
const AActor* Owner = GetOwner();
|
|
if (Owner != nullptr && DefinitionAsset != nullptr)
|
|
{
|
|
BoundingBox = DefinitionAsset->GetBounds().TransformBy(Owner->GetTransform());
|
|
}
|
|
|
|
return BoundingBox;
|
|
}
|