2021-09-28 13:33:17 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "SmartObjectOctree.h"
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------//
|
|
|
|
|
// FSmartObjectOctreeElement
|
|
|
|
|
//----------------------------------------------------------------------//
|
2022-01-19 14:16:16 -05:00
|
|
|
FSmartObjectOctreeElement::FSmartObjectOctreeElement(const FBoxCenterAndExtent& InBounds, const FSmartObjectHandle& InSmartObjectHandle, const FSmartObjectOctreeIDSharedRef& InSharedOctreeID)
|
2021-09-28 13:33:17 -04:00
|
|
|
: Bounds(InBounds)
|
2022-01-19 14:16:16 -05:00
|
|
|
, SmartObjectHandle(InSmartObjectHandle)
|
2021-09-28 13:33:17 -04:00
|
|
|
, SharedOctreeID(InSharedOctreeID)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------//
|
|
|
|
|
// FSmartObjectOctree
|
|
|
|
|
//----------------------------------------------------------------------//
|
|
|
|
|
FSmartObjectOctree::FSmartObjectOctree()
|
|
|
|
|
: FSmartObjectOctree(FVector::ZeroVector, 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FSmartObjectOctree::FSmartObjectOctree(const FVector& Origin, float Radius)
|
|
|
|
|
: TOctree2<FSmartObjectOctreeElement, FSmartObjectOctreeSemantics>(Origin, Radius)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FSmartObjectOctree::~FSmartObjectOctree()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-19 14:16:16 -05:00
|
|
|
void FSmartObjectOctree::AddNode(const FBoxCenterAndExtent& Bounds, const FSmartObjectHandle& SmartObjectHandle, const FSmartObjectOctreeIDSharedRef& SharedOctreeID)
|
2021-09-28 13:33:17 -04:00
|
|
|
{
|
2022-01-19 14:16:16 -05:00
|
|
|
AddElement(FSmartObjectOctreeElement(Bounds, SmartObjectHandle, SharedOctreeID));
|
2021-09-28 13:33:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FSmartObjectOctree::UpdateNode(const FOctreeElementId2& Id, const FBox& NewBounds)
|
|
|
|
|
{
|
|
|
|
|
FSmartObjectOctreeElement ElementCopy = GetElementById(Id);
|
|
|
|
|
RemoveElement(Id);
|
|
|
|
|
ElementCopy.Bounds = NewBounds;
|
|
|
|
|
AddElement(ElementCopy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FSmartObjectOctree::RemoveNode(const FOctreeElementId2& Id)
|
|
|
|
|
{
|
|
|
|
|
RemoveElement(Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------//
|
|
|
|
|
// FSmartObjectOctreeSemantics
|
|
|
|
|
//----------------------------------------------------------------------//
|
|
|
|
|
void FSmartObjectOctreeSemantics::SetElementId(const FSmartObjectOctreeElement& Element, FOctreeElementId2 Id)
|
|
|
|
|
{
|
|
|
|
|
Element.SharedOctreeID->ID = Id;
|
|
|
|
|
}
|
|
|
|
|
|