![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <HierarchicalHashGrid2D.h>
Classes | |
| struct | FCell |
| struct | FCellLocation |
| struct | FCellRect |
| struct | FCellRectIterator |
| struct | FItem |
Public Types | |
| typedef InItemIDType | ItemIDType |
Static Public Member Functions | |
| static int32 | LevelDown (int32 X) |
Static Public Attributes | |
| static const int32 | NumLevels = InNumLevels |
| static const int32 | LevelRatio = InLevelRatio |
Static Protected Member Functions | |
| static constexpr int32 | ClampInt32 (const int64 Value) |
Protected Attributes | |
| TStaticArray< float, NumLevels > | CellSize |
| TStaticArray< float, NumLevels > | InvCellSize |
| TStaticArray< int32, NumLevels > | LevelItemCount |
| TSet< FCell > | Cells |
| TSparseArray< FItem > | Items |
| int32 | SpillList = INDEX_NONE |
Hierarchical Hash Grid in 2D.
Items are added to the "infinite" grid at specific level based on their size. The grid size, and size ratio between levels are defined as the template parameter. This allows some computation to be optimized based on the values.
Items that cannot be fitted in the grid are added to a spill list, which contents are included in all queries. Each item is added to just one grid cell and thus can overlap some neighbour cells up to half cell size at that grid level. This is compensated during the query by expanding the query box.
Potential optimizations:
| typedef InItemIDType THierarchicalHashGrid2D< InNumLevels, InLevelRatio, InItemIDType >::ItemIDType |
|
inline |
Constructor, initializes the grid for specific cell size.
| InCellSize | - new finest level cell size of the grid |
|
inline |
Adds item to the grid.
| ID | - External ID used to identify the item. |
| Bounds | - Bounding box of the item. |
|
inline |
Adds item to the grid.
| ID | - External ID used to identify the item. |
| Location | - Cell location where the item should be added. |
|
inline |
Finds the world box from a cell. @params CellLocation - Cell location.
|
inline |
Finds grid level where the bounds fit inside a cell.
| Bounds | - Bounding box of the item. |
|
inline |
Calculates cell based query rectangle. The bounds are expanded by half grid cell size because the items are stored for only one cell based on their center and side. For that reason the items can overlap the neighbor cells by half the cell size.
| Bounds | - Query bounding box to quantize. |
| Level | - Which level of the tree the to calculate the bounds for |
|
inlinestaticconstexprprotected |
|
inline |
Returns a cell for specific location and level.
| X | - Cell X coordinate. |
| Y | - Cell Y coordinate. |
| Level | - Grid Level. |
|
inline |
Returns a cell for specific location and level.
| X | - Cell X coordinate. |
| Y | - Cell Y coordinate. |
| Level | - Grid Level. |
|
inline |
Returns a cell for specific location and level, creates new cell if it does not exist.
| X | - Cell X coordinate. |
| Y | - Cell Y coordinate. |
| Level | - Grid Level. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Resets and initializes the grid for specific cell size.
| InCellSize | - new finest level cell size of the grid |
|
inline |
Returns intersection of the two cell bounding rectangles.
| Left | - left hand side rectangle |
| Right | - right hand side rectangle |
|
inlinestatic |
Levels down a coordinate using floor rounding.
| X | - Coordinate to level down |
|
inline |
Moves item based on previous bounding box and new bounding box.
| ID | - External ID used to identify the item. |
| OldBounds | - The same bounding box the item was previously added or moved with. |
| NewBounds | - New bounds of the item |
|
inline |
Moves item based on previous cell location and new bounding box.
| ID | - External ID used to identify the item. |
| OldLocation | - The same cell location the item was previously added or moved with. |
| NewBounds | - New bounds of the item |
|
inline |
Returns items that potentially touch the bounds. Operates on grid level, can have false positives.
| Bounds | - Query bounding box. |
| OutResults | - Result of the query, IDs of potentially overlapping items. |
|
inline |
Returns items that potentially touch the bounds. Operates on grid level, can have false positives. This can be faster than Query() for small query box sizes (i.e. max dimension CellSize*4) due to simpler logic.
| Bounds | - Query bounding box. |
| OutResults | - Result of the query, IDs of potentially overlapping items. |
|
inline |
Removes item based on the bounding box it was added with.
| ID | - External ID used to identify the item. |
| OldBounds | - The same bounding box the item was previously added or moved with. |
|
inline |
Removes item based on the cell location it was added with.
| ID | - External ID used to identify the item. |
| OldLocation | - The same cell location the item was previously added or moved with. |
|
inline |
Reset the grid to empty.
|
protected |
Number items per level, can be used to skip certain levels.
|
protected |
|
protected |
Lowest level cell size
|
protected |
TSet uses hash buckets to locate items.
|
protected |
1 / CellSize
|
static |
Number of grid levels in the grid.
|
static |
|
protected |
TSparseArray uses freelist to recycled used items.