8#include "SceneCullingDefinitions.h"
17#define USE_STATIC_HASH_TABLE 0
19#if USE_STATIC_HASH_TABLE
20template <
typename InKeyType,
typename InValueType>
54 Elements.Reserve(
Num);
57 inline FElementId FindIdByHash(
uint16 Hash,
const KeyType& Location)
const
61 if (Hasher::Matches(Elements[
Index].Key, Location))
69 inline FElementId FindId(
const KeyType& Location)
const
72 return FindIdByHash(
Hash, Location);
75 inline FElementId FindOrAddId(
const KeyType& Location,
const ValueType&
Value)
78 FElementId
Id = FindIdByHash(
Hash, Location);
81 int32 NewIndex = Elements.Num();
82 Elements.Add(FElement{ Location,
Value });
83 HashTable.Add(
Hash, NewIndex);
84 Id = FElementId{ NewIndex };
89 inline int32 GetMaxIndex()
const {
return Elements.Num(); }
90 inline int32 Num()
const {
return Elements.Num(); }
92 inline FElement& GetByElementId(FElementId
Id) {
return Elements[
Id.Index]; }
93 inline const FElement& GetByElementId(FElementId
Id)
const {
return Elements[
Id.Index]; }
95 class FConstIteratorType
116 inline bool operator ==(
const FConstIteratorType& Rhs)
const
118 return Index == Rhs.Index;
121 inline bool operator !=(
const FConstIteratorType& Rhs)
const
123 return Index != Rhs.Index;
131 inline FConstIteratorType& operator++()
137 inline FElementId GetElementId()
const
139 return FElementId{
Index };
143 inline FConstIteratorType begin()
const
145 return FConstIteratorType(*
this,
true);
148 inline FConstIteratorType end()
const
150 return FConstIteratorType(*
this,
false);
166template <
typename BlockTraitsType>
184 template <
typename ScalarType>
189 template <
typename LambdaType>
309 return RecCellSizes[Level];
316 Result.Level = Level;
325 Footprint.
Level = Level;
346 Level = FMath::Max(FirstLevel, Level);
351 Footprint.
Level = Level;
362 Level = FMath::Max(FirstLevel, Level);
372 Level = FMath::Max(FirstLevel, Level);
379 return Level >= FirstLevel && Level <= LastLevel;
384 return LastLevelCellSize;
389 return MaxCullingDistance;
442#if USE_STATIC_HASH_TABLE
445 using FBlockId =
typename FSpatialHashMap::FElementId;
452 return Key.GetHash();
475 double LastLevelCellSize;
476 double MaxCullingDistance;
#define check(expr)
Definition AssertionMacros.h:314
UE_FORCEINLINE_HINT FLinearColor operator*(float Scalar, const FLinearColor &Color)
Definition Color.h:473
@ INDEX_NONE
Definition CoreMiscDefines.h:150
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define WORLD_MAX
Definition EngineDefines.h:53
FInt64Vector FloorToInt64Vector(const FVector &Vector)
Definition HierarchicalSpatialHashGrid.h:161
#define FVector
Definition IOSSystemIncludes.h:8
UE_FORCEINLINE_HINT bool operator!=(const FIndexedPointer &Other) const
Definition LockFreeList.h:76
FInt64Vector3 FInt64Vector
Definition MathFwd.h:101
uint32 Size
Definition VulkanMemory.cpp:4034
Definition RobinHoodHashTable.h:72
IndexType GetMaxIndex() const
Definition RobinHoodHashTable.h:852
void Empty()
Definition RobinHoodHashTable.h:1059
ElementType & GetByElementId(FHashElementId Id)
Definition RobinHoodHashTable.h:857
Definition ScenePrimitiveUpdates.h:129
Definition ScenePrimitiveUpdates.h:116
Definition HierarchicalSpatialHashGrid.h:168
FFootprint64 CalcFootprintSphere(int32 Level, const FVector &Origin, double Radius) const
Definition HierarchicalSpatialHashGrid.h:321
const FCellBlock & GetBlockById(const FBlockId &BlockId) const
Definition HierarchicalSpatialHashGrid.h:464
FFootprint64 CalcLevelAndFootprint(const FBoxSphereBounds &BoxSphereBounds) const
Definition HierarchicalSpatialHashGrid.h:340
static constexpr uint32 LocalCellCoordMask
Definition HierarchicalSpatialHashGrid.h:176
double GetMaxCullingDistance() const
Definition HierarchicalSpatialHashGrid.h:387
int32 GetMaxNumBlocks() const
Definition HierarchicalSpatialHashGrid.h:290
static constexpr int32 NumCellsPerBlockLog2
Definition HierarchicalSpatialHashGrid.h:174
int32 GetFirstLevel() const
Definition HierarchicalSpatialHashGrid.h:440
static double GetCellSize(int32 Level)
Definition HierarchicalSpatialHashGrid.h:302
int32 NumLevels() const
Definition HierarchicalSpatialHashGrid.h:391
THierarchicalSpatialHashGrid()=default
static constexpr int32 CellBlockDimLog2
Definition HierarchicalSpatialHashGrid.h:172
Experimental::TRobinHoodHashMap< FBlockLoc, FCellBlock, FHasher > FSpatialHashMap
Definition HierarchicalSpatialHashGrid.h:456
FLocation64 CalcLevelAndLocation(const FBoxSphereBounds &BoxSphereBounds) const
Definition HierarchicalSpatialHashGrid.h:357
FLocation64 ToCellLoc(int32 Level, const FVector &WorldPos) const
Definition HierarchicalSpatialHashGrid.h:312
const FSpatialHashMap & GetHashMap() const
Definition HierarchicalSpatialHashGrid.h:468
double GetLastLevelCellSize() const
Definition HierarchicalSpatialHashGrid.h:382
FBox CalcCellBounds(const FLocation64 &CellLoc) const
Definition HierarchicalSpatialHashGrid.h:394
FCellBlock & GetBlockById(const FBlockId &BlockId)
Definition HierarchicalSpatialHashGrid.h:463
FVector3d CalcBlockWorldPosition(const FLocation64 &BlockLoc) const
Definition HierarchicalSpatialHashGrid.h:427
Experimental::FHashElementId FBlockId
Definition HierarchicalSpatialHashGrid.h:457
double GetRecCellSize(int32 Level) const
Definition HierarchicalSpatialHashGrid.h:307
void Empty()
Definition HierarchicalSpatialHashGrid.h:285
static FFootprint64 CalcCellBlockFootprint(const FFootprint64 &Footprint)
Definition HierarchicalSpatialHashGrid.h:331
Experimental::FHashElementId FHashElementId
Definition HierarchicalSpatialHashGrid.h:458
THierarchicalSpatialHashGrid(double MinCellSize, double MaxCellSize)
Definition HierarchicalSpatialHashGrid.h:266
static constexpr int32 CellBlockSize
Definition HierarchicalSpatialHashGrid.h:177
FBlockLoc GetBlockLocById(const FBlockId &BlockId) const
Definition HierarchicalSpatialHashGrid.h:466
static constexpr int32 CellBlockDim
Definition HierarchicalSpatialHashGrid.h:175
bool IsValidLevel(int32 Level) const
Definition HierarchicalSpatialHashGrid.h:377
FVector3d CalcBlockWorldPosition(const FBlockLoc &BlockLoc) const
Definition HierarchicalSpatialHashGrid.h:435
static int32 CalcLevelFromRadius(float Radius)
Definition HierarchicalSpatialHashGrid.h:297
static constexpr int32 kMaxLevel
Definition HierarchicalSpatialHashGrid.h:173
FBox CalcBlockBounds(const FLocation64 &BlockLoc) const
Definition HierarchicalSpatialHashGrid.h:409
static int32 CalcLevel(float Size)
Definition HierarchicalSpatialHashGrid.h:292
typename BlockTraitsType::FBlockLoc FBlockLoc
Definition HierarchicalSpatialHashGrid.h:170
FLocation64 CalcLevelAndLocation(const FVector4d &Sphere) const
Definition HierarchicalSpatialHashGrid.h:367
FSpatialHashMap & GetHashMap()
Definition HierarchicalSpatialHashGrid.h:469
Definition HashTable.h:94
FVector3d CalcWorldPosition(const FLocation64 &Loc)
Definition RenderingSpatialHash.h:139
int32 CalcLevel(double Size)
Definition RenderingSpatialHash.h:79
double GetCellSize(int32 Level)
Definition RenderingSpatialHash.h:96
U16 Index
Definition radfft.cpp:71
Definition RenderingSpatialHash.h:17
FIntVector3 Coord
Definition RenderingSpatialHash.h:19
int32 Level
Definition RenderingSpatialHash.h:20
Definition HierarchicalSpatialHashGrid.h:217
static uint32 constexpr CoarseCellMaskDimLog2
Definition HierarchicalSpatialHashGrid.h:218
uint64 CoarseCellMask
Definition HierarchicalSpatialHashGrid.h:258
int32 NumItemChunks
Definition HierarchicalSpatialHashGrid.h:260
static uint32 constexpr CoarseCellMaskDim
Definition HierarchicalSpatialHashGrid.h:219
int32 GridOffset
Definition HierarchicalSpatialHashGrid.h:259
static uint32 CalcCellMaskOffset(const FInt8Vector3 &MaskLoc)
Definition HierarchicalSpatialHashGrid.h:231
static uint64 CalcCellMask(const FInt8Vector3 &Loc)
Definition HierarchicalSpatialHashGrid.h:236
static uint32 constexpr CoarseCellMaskCoordMask
Definition HierarchicalSpatialHashGrid.h:220
static int32 CalcCellOffset(const FInt8Vector3 &Loc)
Definition HierarchicalSpatialHashGrid.h:222
int32 GetCellGridOffset(const FInt8Vector3 &Loc) const
Definition HierarchicalSpatialHashGrid.h:227
static uint64 BuildFootPrintMask(const FFootprint8 &FootprintInBlock)
Definition HierarchicalSpatialHashGrid.h:242
Definition HierarchicalSpatialHashGrid.h:449
static FORCEINLINE uint32 GetKeyHash(const FBlockLoc &Key)
Definition HierarchicalSpatialHashGrid.h:450
Definition BoxSphereBounds.h:25
Definition IntVector.h:22
IntType Y
Definition IntVector.h:34
IntType X
Definition IntVector.h:31
IntType Z
Definition IntVector.h:37