You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
* Created Default SmartObjectOctree * Created Default SmartObjectHashGrid * Type of space partition to use can be set in the smartobject config file: [/Script/SmartObjectsModule.SmartObjectSubsystem] SpacePartitionClassName=<ClassPath> * Created DebugSceneProxy and RenderingComponent to share functionalities between susbystem and testing actor rendering components #rnx #rb mieszko.zielinski #preflight 620fb51dec6f84cdfa3b2772 #ROBOMERGE-OWNER: yoan.stamant #ROBOMERGE-AUTHOR: yoan.stamant #ROBOMERGE-SOURCE: CL 19050433 via CL 19050556 via CL 19050564 via CL 19057424 #ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v918-19018356) [CL 19066037 by yoan stamant in ue5-main branch]
92 lines
3.1 KiB
C++
92 lines
3.1 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SmartObjectOctree.h"
|
|
|
|
//----------------------------------------------------------------------//
|
|
// FSmartObjectOctreeElement
|
|
//----------------------------------------------------------------------//
|
|
FSmartObjectOctreeElement::FSmartObjectOctreeElement(const FBoxCenterAndExtent& InBounds, const FSmartObjectHandle& InSmartObjectHandle, const FSmartObjectOctreeIDSharedRef& InSharedOctreeID)
|
|
: Bounds(InBounds)
|
|
, SmartObjectHandle(InSmartObjectHandle)
|
|
, SharedOctreeID(InSharedOctreeID)
|
|
{
|
|
}
|
|
|
|
//----------------------------------------------------------------------//
|
|
// FSmartObjectOctree
|
|
//----------------------------------------------------------------------//
|
|
FSmartObjectOctree::FSmartObjectOctree()
|
|
: FSmartObjectOctree(FVector::ZeroVector, 0)
|
|
{
|
|
|
|
}
|
|
|
|
FSmartObjectOctree::FSmartObjectOctree(const FVector& Origin, float Radius)
|
|
: TOctree2<FSmartObjectOctreeElement, FSmartObjectOctreeSemantics>(Origin, Radius)
|
|
{
|
|
}
|
|
|
|
FSmartObjectOctree::~FSmartObjectOctree()
|
|
{
|
|
}
|
|
|
|
void FSmartObjectOctree::AddNode(const FBoxCenterAndExtent& Bounds, const FSmartObjectHandle& SmartObjectHandle, const FSmartObjectOctreeIDSharedRef& SharedOctreeID)
|
|
{
|
|
AddElement(FSmartObjectOctreeElement(Bounds, SmartObjectHandle, SharedOctreeID));
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
//----------------------------------------------------------------------//
|
|
// USmartObjectOctree
|
|
//----------------------------------------------------------------------//
|
|
void USmartObjectOctree::SetBounds(const FBox& Bounds)
|
|
{
|
|
new(&SmartObjectOctree) FSmartObjectOctree(Bounds.GetCenter(), Bounds.GetExtent().Size2D());
|
|
}
|
|
|
|
FInstancedStruct USmartObjectOctree::Add(const FSmartObjectHandle& Handle, const FBox& Bounds)
|
|
{
|
|
const FSmartObjectOctreeEntryData EntryData;
|
|
SmartObjectOctree.AddNode(Bounds, Handle, EntryData.SharedOctreeID);
|
|
return FInstancedStruct::Make(EntryData);
|
|
}
|
|
|
|
void USmartObjectOctree::Remove(const FSmartObjectHandle& Handle, const FStructView& EntryData)
|
|
{
|
|
const FSmartObjectOctreeEntryData& OctreeEntryData = EntryData.GetMutable<FSmartObjectOctreeEntryData>();
|
|
FSmartObjectOctreeID& SharedOctreeID = OctreeEntryData.SharedOctreeID.Get();
|
|
if (SharedOctreeID.ID.IsValidId())
|
|
{
|
|
SmartObjectOctree.RemoveNode(SharedOctreeID.ID);
|
|
SharedOctreeID.ID = {};
|
|
}
|
|
}
|
|
|
|
void USmartObjectOctree::Find(const FBox& QueryBox, TArray<FSmartObjectHandle>& OutResults)
|
|
{
|
|
SmartObjectOctree.FindElementsWithBoundsTest(QueryBox,
|
|
[&OutResults](const FSmartObjectOctreeElement& Element)
|
|
{
|
|
OutResults.Add(Element.SmartObjectHandle);
|
|
});
|
|
} |