9template <
typename ElementType,
int32 NodeCapacity = 4>
27 template<
typename ElementAllocatorType>
32 template<
typename CallbackType>
75 return Ar << Node.Box << Node.Element;
86 template<
typename ElementAllocatorType>
90 template<
typename CallbackType>
94 bool RemoveNodeForElement(
const ElementType& Element);
97 void InsertElementRecursive(
const ElementType& Element,
const FBox2D&
Box,
const TCHAR* DebugContext);
109 TreeType* SubTrees[4] = {
nullptr};
118 float MinimumQuadSize;
127 Other.Duplicate(*
this);
142 bool SubTreeFlags[4] = { SubTrees[0] !=
nullptr, SubTrees[1] !=
nullptr, SubTrees[2] !=
nullptr, SubTrees[3] !=
nullptr };
145 for (
int32 Idx = 0; Idx < 4; ++Idx)
154 SubTrees[Idx]->Serialize(Ar);
163template <
typename ElementType,
int32 NodeCapacity>
170 SubTrees[0] = SubTrees[1] = SubTrees[2] = SubTrees[3] =
nullptr;
173template <
typename ElementType,
int32 NodeCapacity>
179template <
typename ElementType,
int32 NodeCapacity>
189template <
typename ElementType,
int32 NodeCapacity>
192 check(bInternal ==
false);
194 const FVector2D Extent = TreeBox.GetExtent();
228 for (
const FNode& Node : Nodes)
231 const int32 NumQuads = GetQuads(Node.Box, Quads);
236 Quads[0]->Nodes.Add(Node);
248template <
typename ElementType,
int32 NodeCapacity>
251#if !UE_BUILD_SHIPPING
252 if (!
Box.Intersect(TreeBox))
255 UE_LOG(
LogQuadTree,
Warning,
TEXT(
"[%s] Adding element (%s) that is outside the bounds of the quadtree root (%s). Consider resizing."), DebugContext ? DebugContext :
TEXT(
"Unknown Source"), *
Box.ToString(), *TreeBox.ToString());
259 InsertElementRecursive(Element,
Box, DebugContext);
262template <
typename ElementType,
int32 NodeCapacity>
266 const int32 NumQuads = GetQuads(
Box, Quads);
277 Nodes.Add(FNode(Element,
Box));
288 InsertElementRecursive(Element,
Box, DebugContext);
291 else if (NumQuads == 1)
296 Quads[0]->InsertElementRecursive(Element,
Box, DebugContext);
302 Nodes.Add(FNode(Element,
Box));
306template <
typename ElementType,
int32 NodeCapacity>
310 for (
int32 NodeIdx = 0, NumNodes = Nodes.Num(); NodeIdx < NumNodes; ++NodeIdx)
312 if (Nodes[NodeIdx].Element == Element)
328template <
typename ElementType,
int32 NodeCapacity>
334 const int32 NumQuads = GetQuads(
Box, Quads);
348template <
typename ElementType,
int32 NodeCapacity>
349template <
typename ElementAllocatorType>
353 const int32 NumQuads = GetQuads(
Box, Quads);
365template <
typename ElementType,
int32 NodeCapacity>
366template <
typename ElementAllocatorType>
370 for (
const FNode& Node : Nodes)
372 if (
Box.Intersect(Node.Box))
381template <
typename ElementType,
int32 NodeCapacity>
382template<
typename CallbackType>
386 const int32 NumQuads = GetQuads(
Box, Quads);
389 if (!GetIntersectingElements(
Box, Callback))
401template <
typename ElementType,
int32 NodeCapacity>
402template<
typename CallbackType>
405 for (
const FNode& Node : Nodes)
409 if (
Box.Intersect(Node.Box) && !Callback(Node.Element))
418template <
typename ElementType,
int32 NodeCapacity>
454template <
typename ElementType,
int32 NodeCapacity>
474template <
typename ElementType,
int32 NodeCapacity>
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define check(expr)
Definition AssertionMacros.h:314
@ INDEX_NONE
Definition CoreMiscDefines.h:150
void EnsureRetrievingVTablePtrDuringCtor(const TCHAR *CtorSignature)
Definition CoreMisc.cpp:436
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
FArchive & operator<<(FArchive &Ar, FEnvQueryDebugProfileData::FStep &Data)
Definition EnvQueryTypes.cpp:489
#define DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:361
#define UE_LOG(CategoryName, Verbosity, Format,...)
Definition LogMacros.h:270
UE::Math::TVector2< double > FVector2D
Definition MathFwd.h:48
UE::Math::TBox2< double > FBox2D
Definition MathFwd.h:56
#define Split(a, ahi, alo)
Definition Predicates.inl:204
Definition Archive.h:1208
UE_FORCEINLINE_HINT bool IsLoading() const
Definition Archive.h:236
Definition GenericQuadTree.h:11
void Duplicate(TreeType &OutDuplicate) const
Definition GenericQuadTree.h:455
void Insert(const ElementType &Element, const FBox2D &Box, const TCHAR *DebugContext=nullptr)
Definition GenericQuadTree.h:249
void Serialize(FArchive &Ar)
Definition GenericQuadTree.h:138
TQuadTree()
Definition GenericQuadTree.h:174
TQuadTree & operator=(const TQuadTree &Other)
Definition GenericQuadTree.h:131
void Empty()
Definition GenericQuadTree.h:475
const FBox2D & GetTreeBox() const
Definition GenericQuadTree.h:21
~TQuadTree()
Definition GenericQuadTree.h:180
TQuadTree(const FBox2D &InBox, float InMinimumQuadSize=100.f)
Definition GenericQuadTree.h:164
void GetElements(const FBox2D &Box, TArray< ElementType, ElementAllocatorType > &ElementsOut) const
Definition GenericQuadTree.h:350
TQuadTree(const TQuadTree &)
Definition GenericQuadTree.h:125
bool Remove(const ElementType &Instance, const FBox2D &Box)
Definition GenericQuadTree.h:329
void GetElements(const FBox2D &Box, CallbackType &&Callback) const
Definition GenericQuadTree.h:383
@ Box
Definition EnvQueryTypes.h:244
@ Element
Definition Visu.h:18
@ false
Definition radaudio_common.h:23
static constexpr UE_FORCEINLINE_HINT T Square(const T A)
Definition UnrealMathUtility.h:578
static UE_FORCEINLINE_HINT TVector2< T > Min(const TVector2< T > &A, const TVector2< T > &B)
Definition Vector2D.h:959
T Y
Definition Vector2D.h:52
static UE_FORCEINLINE_HINT TVector2< T > Max(const TVector2< T > &A, const TVector2< T > &B)
Definition Vector2D.h:953
T X
Definition Vector2D.h:49