Navigation
API > API/Runtime > API/Runtime/GeometryCore > API/Runtime/GeometryCore/Spatial
Inheritance Hierarchy
- FSparseDynamicOctree3
- FDynamicMeshOctree3
References
| Module | GeometryCore |
| Header | /Engine/Source/Runtime/GeometryCore/Public/Spatial/SparseDynamicOctree3.h |
| Include | #include "Spatial/SparseDynamicOctree3.h" |
Syntax
class FSparseDynamicOctree3
Remarks
FSparseDynamicOctree3 sorts objects with axis-aligned bounding boxes into a dynamic sparse octree of axis-aligned uniform grid cells. At the top level we have an infinite grid of "root cells" of size RootDimension, which then contain 8 children, and so on. (So in fact each cell is a separate octree, and we have a uniform grid of octrees)
The objects and their bounding-boxes are not stored in the tree. You must have an integer identifier (ObjectID) for each object, and call Insert(ObjectID, BoundingBox). Some query functions will require you to provide a lambda/etc that can be called to retrieve the bounding box for a given ObjectID.
Objects are currently inserted at the maximum possible depth, ie smallest cell that will contain them, or MaxTreeDepth. The tree boxes are expanded by MaxExpandFactor to allow for deeper insertion. If MaxExpandFactor > 0 then the tree does not strictly partition space, IE adjacent cells overlap.
The octree is dynamic. Objects can be removed and re-inserted.
Variables
| Type | Name | Description | |
|---|---|---|---|
| FSmallListSet | CellObjectLists | ||
| FRefCountVector | CellRefCounts | Reference counts for Cells list. | |
| TDynamicVector< FSparseOctreeCell > | Cells | List of cells. Note that some cells may be unused, depending on CellRefCounts | |
| double | MaxExpandFactor | Fraction we expand the dimension of any cell, to allow extra space to fit objects. | |
| int | MaxTreeDepth | Objects will not be inserted more than this many levels deep from a Root cell | |
| TDynamicVector< uint32 > | ObjectIDToCellMap | ||
| TSparseGrid3< uint32 > | RootCells | RootCells are the top-level cells of the octree, of size RootDimension. | |
| double | RootDimension | Potential optimizations/improvements | |
| TSet< int32 > | SpillObjectSet | ||
| FDynamicFlagArray | ValidObjectIDs |
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | BranchRangeQuery
(
const FSparseOctreeCell* ParentCell, |
||
| bool | CanFit
(
const FSparseOctreeCell& Cell, |
||
| bool | CheckIfObjectNeedsReinsert
(
int32 ObjectID, |
Check if the object needs to be reinserted, if it has NewBounds. | |
| void | CheckValidity
(
TFunctionRef< bool(int)> IsValidObjectIDFunc, |
Check that the octree is internally valid | |
| void | ComputeStatistics
(
FStatistics& StatsOut |
Populate given FStatistics with info about the octree | |
| void | ContainmentQuery
(
const FVector3d& Point, |
Process ObjectIDs from all the cells with bounding boxes that contain query point | |
| bool | ContainmentQueryCancellable
(
const FVector3d& Point, |
Process ObjectIDs from all the cells with bounding boxes that contain query point | |
| bool | ContainsObject
(
int32 ObjectID |
Test if an object is stored in the tree | |
| FSparseOctreeCell | FindCurrentContainingCell
(
const FAxisAlignedBox3d& Bounds |
||
| int32 | FindNearestHitObject
(
const FRay3d& Ray, |
Find nearest ray-hit point with objects in tree | |
| double | FindNearestRayCellIntersection
(
const FSparseOctreeCell& Cell, |
||
| FAxisAlignedBox3d | |||
| FAxisAlignedBox3d | GetCellBox
(
const FSparseOctreeCell& Cell, |
||
| FVector3d | GetCellCenter
(
const FSparseOctreeCell& Cell |
||
| uint32 | GetCellForObject
(
int32 ObjectID |
||
| double | GetCellWidth
(
uint32 Level |
Calculate the base width of a cell at a given level | |
| int | |||
| void | Insert_NewChildCell
(
int32 ObjectID, |
||
| void | Insert_NewRoot
(
int32 ObjectID, |
||
| void | Insert_Spill
(
int32 ObjectID, |
||
| void | Insert_ToCell
(
int32 ObjectID, |
||
| void | InsertObject
(
int32 ObjectID, |
Insert ObjectID into the Octree | |
| void | ParallelRangeQuery
(
const FAxisAlignedBox3d& Bounds, |
Collect ObjectIDs from all the cells with bounding boxes that intersect Bounds. | |
| FVector3i | PointToIndex
(
uint32 Level, |
Warning: result here appears to be unstable (due to optimization?) if any of the position values are on the border of a cell (in testing, pragma-optimization-disabled code produced off-by-one result from calling this function) | |
| void | RangeQuery
(
const FAxisAlignedBox3d& Bounds, |
Process ObjectIDs from all the cells with bounding boxes that intersect Bounds | |
| void | RangeQuery
(
const FAxisAlignedBox3d& Bounds, |
Collect ObjectIDs from all the cells with bounding boxes that intersect Bounds | |
| bool | ReinsertObject
(
int32 ObjectID, |
Update the position of an object in the octree. This is more efficient than doing a remove+insert | |
| bool | RemoveObject
(
int32 ObjectID |
Remove an object from the octree | |
| void | SetMaxTreeDepth
(
int MaxTreeDepthIn |
Sets max tree depth w/ protection against setting beyond supported max | |
| int | ToChildCellIndex
(
const FSparseOctreeCell& Cell, |
Classes
| Type | Name | Description | |
|---|---|---|---|
| FStatistics | Statistics about internal structure of the octree |
Constants
| Name | Description |
|---|---|
| InvalidCellID | This identifier is used for unknown cells |
| MaxSupportedTreeDepth | |
| SpillCellID | If an object is in the spill cell, that means it didn't fit in the tree |