Files
UnrealEngineUWP/Engine/Plugins/Runtime/SmartObjects/Source/SmartObjectsModule/Public/SmartObjectOctree.h
yoan stamant 04214fbc78 [SmartObject] allow custom definitions (FSmartObjectSlotDefinitionData) and transient state data (FSmartObjectSlotStateData) per slot using MassEntity
+ replaced all methods Describe by LexToString
+ unified naming from "*ID" to *Handle
#preflight 61e85d121000e8c59a78c886
#rb mikko.mononen

#ROBOMERGE-AUTHOR: yoan.stamant
#ROBOMERGE-SOURCE: CL 18662203 in //UE5/Release-5.0/... via CL 18662234 via CL 18662264
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v900-18638592)

[CL 18662291 by yoan stamant in ue5-main branch]
2022-01-19 14:16:16 -05:00

61 lines
2.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "SmartObjectTypes.h"
#include "Templates/SharedPointer.h"
#include "Math/GenericOctree.h"
typedef TSharedRef<struct FSmartObjectOctreeID, ESPMode::ThreadSafe> FSmartObjectOctreeIDSharedRef;
struct SMARTOBJECTSMODULE_API FSmartObjectOctreeID : public TSharedFromThis<FSmartObjectOctreeID, ESPMode::ThreadSafe>
{
FOctreeElementId2 ID;
};
struct SMARTOBJECTSMODULE_API FSmartObjectOctreeElement
{
FBoxCenterAndExtent Bounds;
FSmartObjectHandle SmartObjectHandle;
FSmartObjectOctreeIDSharedRef SharedOctreeID;
FSmartObjectOctreeElement(const FBoxCenterAndExtent& Bounds, const FSmartObjectHandle& SmartObjectHandle, const FSmartObjectOctreeIDSharedRef& SharedOctreeID);
};
struct FSmartObjectOctreeSemantics
{
enum { MaxElementsPerLeaf = 16 };
enum { MinInclusiveElementsPerNode = 7 };
enum { MaxNodeDepth = 12 };
typedef TInlineAllocator<MaxElementsPerLeaf> ElementAllocator;
FORCEINLINE static const FBoxCenterAndExtent& GetBoundingBox(const FSmartObjectOctreeElement& Element)
{
return Element.Bounds;
}
FORCEINLINE static bool AreElementsEqual(const FSmartObjectOctreeElement& A, const FSmartObjectOctreeElement& B)
{
return A.SmartObjectHandle == B.SmartObjectHandle;
}
static void SetElementId(const FSmartObjectOctreeElement& Element, FOctreeElementId2 Id);
};
class FSmartObjectOctree : public TOctree2<FSmartObjectOctreeElement, FSmartObjectOctreeSemantics>
{
public:
FSmartObjectOctree();
FSmartObjectOctree(const FVector& Origin, float Radius);
virtual ~FSmartObjectOctree();
/** Add new node and initialize using SmartObject runtime data */
void AddNode(const FBoxCenterAndExtent& Bounds, const FSmartObjectHandle& SmartObjectHandle, const FSmartObjectOctreeIDSharedRef& SharedOctreeID);
/** Updates element bounds remove/add operation */
void UpdateNode(const FOctreeElementId2& Id, const FBox& NewBounds);
/** Remove node */
void RemoveNode(const FOctreeElementId2& Id);
};