UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Geometry::TPointHashGrid3< PointDataType, RealType > Class Template Reference

#include <PointHashGrid3.h>

Public Member Functions

 TPointHashGrid3 (RealType CellSize, PointDataType InvalidValue)
 
void Reserve (int32 Num)
 
void Reset (RealType NewCellSize)
 
PointDataType GetInvalidValue () const
 
void InsertPoint (const PointDataType &Value, const TVector< RealType > &Position)
 
void InsertPointUnsafe (const PointDataType &Value, const TVector< RealType > &Position)
 
bool RemovePoint (const PointDataType &Value, const TVector< RealType > &Position)
 
bool RemovePointUnsafe (const PointDataType &Value, const TVector< RealType > &Position)
 
bool IsCellEmpty (const TVector< RealType > &Position)
 
bool IsCellEmptyUnsafe (const TVector< RealType > &Position)
 
void UpdatePoint (const PointDataType &Value, const TVector< RealType > &OldPosition, const TVector< RealType > &NewPosition)
 
void UpdatePointUnsafe (const PointDataType &Value, const TVector< RealType > &OldPosition, const TVector< RealType > &NewPosition)
 
TPair< PointDataType, RealType > FindNearestInRadius (const TVector< RealType > &QueryPoint, RealType Radius, TFunctionRef< RealType(const PointDataType &)> DistanceSqFunc, TFunctionRef< bool(const PointDataType &)> IgnoreFunc) const
 
TPair< PointDataType, RealType > FindNearestInRadius (const TVector< RealType > &QueryPoint, RealType Radius, TFunctionRef< RealType(const PointDataType &)> DistanceSqFunc) const
 
TPair< PointDataType, RealType > FindAnyInRadius (const TVector< RealType > &QueryPoint, RealType Radius, TFunctionRef< RealType(const PointDataType &)> DistanceSqFunc, TFunctionRef< bool(const PointDataType &)> IgnoreFunc) const
 
TPair< PointDataType, RealType > FindAnyInRadius (const TVector< RealType > &QueryPoint, RealType Radius, TFunctionRef< RealType(const PointDataType &)> DistanceSqFunc) const
 
int FindPointsInBall (const TVector< RealType > &QueryPoint, RealType Radius, TFunctionRef< RealType(const PointDataType &)> DistanceSqFunc, TArray< PointDataType > &ResultsOut, TFunctionRef< bool(const PointDataType &)> IgnoreFunc=[](const PointDataType &data) { return false;}) const
 
void EnumeratePointsInBall (const TVector< RealType > &QueryPoint, RealType Radius, TFunctionRef< RealType(const PointDataType &)> DistanceSqFunc, TFunctionRef< bool(PointDataType, double)> ProcessPointFunc, TFunctionRef< bool(const PointDataType &)> IgnoreFunc=[](const PointDataType &data) { return false;}) const
 

Detailed Description

template<typename PointDataType, typename RealType>
class UE::Geometry::TPointHashGrid3< PointDataType, RealType >

Hash Grid for values associated with 3D points.

This class addresses the situation where you have a list of (point, point_data) and you would like to be able to do efficient proximity queries, i.e. find the nearest point_data for a given query point.

We don't store copies of the 3D points. You provide a point_data type. This could just be the integer index into your list for example, a pointer to something more complex, etc. Insert and Remove functions require you to pass in the 3D point for the point_data. To Update a point you need to know its old and new 3D coordinates.

Constructor & Destructor Documentation

◆ TPointHashGrid3()

template<typename PointDataType , typename RealType >
UE::Geometry::TPointHashGrid3< PointDataType, RealType >::TPointHashGrid3 ( RealType  CellSize,
PointDataType  InvalidValue 
)
inline

Construct 3D hash grid

Parameters
CellSizesize of grid cells. Clamped to at least a small tolerance size.
InvalidValuethis value will be returned by queries if no valid result is found (e.g. bounded-distance query)

Member Function Documentation

◆ EnumeratePointsInBall()

template<typename PointDataType , typename RealType >
void UE::Geometry::TPointHashGrid3< PointDataType, RealType >::EnumeratePointsInBall ( const TVector< RealType > &  QueryPoint,
RealType  Radius,
TFunctionRef< RealType(const PointDataType &)>  DistanceSqFunc,
TFunctionRef< bool(PointDataType, double)>  ProcessPointFunc,
TFunctionRef< bool(const PointDataType &)>  IgnoreFunc = [](const PointDataType& data) { return false; } 
) const
inline

Call ProcessPointFunc on all points in grid within a given sphere, or until the function returns false Note: Not thread-safe to update, remove or insert points during enumeration.

Parameters
QueryPointthe center of the query sphere
Radiusthe radius of the query sphere
DistanceSqFuncFunction you provide which measures the squared distance between QueryPoint and a Value
ProcessPointFuncFunction you provide to process each found point. Takes point data and the distance squared; returns true to continue iteration, or false to stop.
IgnoreFuncoptional Function you may provide which will result in a Value being ignored if IgnoreFunc(Value) returns true

◆ FindAnyInRadius() [1/2]

template<typename PointDataType , typename RealType >
TPair< PointDataType, RealType > UE::Geometry::TPointHashGrid3< PointDataType, RealType >::FindAnyInRadius ( const TVector< RealType > &  QueryPoint,
RealType  Radius,
TFunctionRef< RealType(const PointDataType &)>  DistanceSqFunc 
) const
inline

◆ FindAnyInRadius() [2/2]

template<typename PointDataType , typename RealType >
TPair< PointDataType, RealType > UE::Geometry::TPointHashGrid3< PointDataType, RealType >::FindAnyInRadius ( const TVector< RealType > &  QueryPoint,
RealType  Radius,
TFunctionRef< RealType(const PointDataType &)>  DistanceSqFunc,
TFunctionRef< bool(const PointDataType &)>  IgnoreFunc 
) const
inline

Find any point within radius. Note: Not thread-safe to update, remove or insert points during this query.

Parameters
QueryPointthe center of the query sphere
Radiusthe radius of the query sphere
DistanceSqFuncFunction you provide which measures the squared distance between QueryPoint and a Value
IgnoreFuncoptional Function you may provide which will result in a Value being ignored if IgnoreFunc(Value) returns true
Returns
the found pair (Value,DistanceSqFunc(Value)), or (InvalidValue,MaxDouble) if not found

◆ FindNearestInRadius() [1/2]

template<typename PointDataType , typename RealType >
TPair< PointDataType, RealType > UE::Geometry::TPointHashGrid3< PointDataType, RealType >::FindNearestInRadius ( const TVector< RealType > &  QueryPoint,
RealType  Radius,
TFunctionRef< RealType(const PointDataType &)>  DistanceSqFunc 
) const
inline

◆ FindNearestInRadius() [2/2]

template<typename PointDataType , typename RealType >
TPair< PointDataType, RealType > UE::Geometry::TPointHashGrid3< PointDataType, RealType >::FindNearestInRadius ( const TVector< RealType > &  QueryPoint,
RealType  Radius,
TFunctionRef< RealType(const PointDataType &)>  DistanceSqFunc,
TFunctionRef< bool(const PointDataType &)>  IgnoreFunc 
) const
inline

Find nearest point within radius. Note: Not thread-safe to update, remove or insert points during this query.

Parameters
QueryPointthe center of the query sphere
Radiusthe radius of the query sphere
DistanceSqFuncFunction you provide which measures the squared distance between QueryPoint and a Value
IgnoreFuncoptional Function you may provide which will result in a Value being ignored if IgnoreFunc(Value) returns true
Returns
the found pair (Value,DistanceSqFunc(Value)), or (InvalidValue,MaxDouble) if not found

◆ FindPointsInBall()

template<typename PointDataType , typename RealType >
int UE::Geometry::TPointHashGrid3< PointDataType, RealType >::FindPointsInBall ( const TVector< RealType > &  QueryPoint,
RealType  Radius,
TFunctionRef< RealType(const PointDataType &)>  DistanceSqFunc,
TArray< PointDataType > &  ResultsOut,
TFunctionRef< bool(const PointDataType &)>  IgnoreFunc = [](const PointDataType& data) { return false; } 
) const
inline

Find all points in grid within a given sphere. Note: Not thread-safe to update, remove or insert points during this query.

Parameters
QueryPointthe center of the query sphere
Radiusthe radius of the query sphere
DistanceSqFuncFunction you provide which measures the squared distance between QueryPoint and a Value
ResultsOutArray that points in sphere will be added to
IgnoreFuncoptional Function you may provide which will result in a Value being ignored if IgnoreFunc(Value) returns true
Returns
the number of found points

◆ GetInvalidValue()

template<typename PointDataType , typename RealType >
PointDataType UE::Geometry::TPointHashGrid3< PointDataType, RealType >::GetInvalidValue ( ) const
inline

Invalid grid value

◆ InsertPoint()

template<typename PointDataType , typename RealType >
void UE::Geometry::TPointHashGrid3< PointDataType, RealType >::InsertPoint ( const PointDataType Value,
const TVector< RealType > &  Position 
)
inline

Insert at given position. This function is thread-safe.

Parameters
Valuethe point/value to insert
Positionthe position associated with this value

◆ InsertPointUnsafe()

template<typename PointDataType , typename RealType >
void UE::Geometry::TPointHashGrid3< PointDataType, RealType >::InsertPointUnsafe ( const PointDataType Value,
const TVector< RealType > &  Position 
)
inline

Insert at given position, without locking / thread-safety

Parameters
Valuethe point/value to insert
Positionthe position associated with this value

◆ IsCellEmpty()

template<typename PointDataType , typename RealType >
bool UE::Geometry::TPointHashGrid3< PointDataType, RealType >::IsCellEmpty ( const TVector< RealType > &  Position)
inline

Test if the cell containing Position is empty. This function is thread-safe. Can be used to skip a more expensive range search, in some cases.

Returns
true if the cell containing Position is empty

◆ IsCellEmptyUnsafe()

template<typename PointDataType , typename RealType >
bool UE::Geometry::TPointHashGrid3< PointDataType, RealType >::IsCellEmptyUnsafe ( const TVector< RealType > &  Position)
inline

Test if the whole cell containing Position is empty, without locking / thread-safety Can be used to skip a more expensive range search, in some cases.

Returns
true if the cell containing Position is empty

◆ RemovePoint()

template<typename PointDataType , typename RealType >
bool UE::Geometry::TPointHashGrid3< PointDataType, RealType >::RemovePoint ( const PointDataType Value,
const TVector< RealType > &  Position 
)
inline

Remove at given position. This function is thread-safe.

Parameters
Valuethe point/value to remove
Positionthe position associated with this value
Returns
true if the value existed at this position

◆ RemovePointUnsafe()

template<typename PointDataType , typename RealType >
bool UE::Geometry::TPointHashGrid3< PointDataType, RealType >::RemovePointUnsafe ( const PointDataType Value,
const TVector< RealType > &  Position 
)
inline

Remove at given position, without locking / thread-safety

Parameters
Valuethe point/value to remove
Positionthe position associated with this value
Returns
true if the value existed at this position

◆ Reserve()

template<typename PointDataType , typename RealType >
void UE::Geometry::TPointHashGrid3< PointDataType, RealType >::Reserve ( int32  Num)
inline

Reserve space in the underlying hash map

Parameters
Numamount of elements to reserve

◆ Reset()

template<typename PointDataType , typename RealType >
void UE::Geometry::TPointHashGrid3< PointDataType, RealType >::Reset ( RealType  NewCellSize)
inline

Remove all entries in the underlying hash map, without resizing or releasing any allocations, and reset the cell size.

Parameters
NewCellSizeThe size of grid cells. Clamped to at least a small tolerance size.

◆ UpdatePoint()

template<typename PointDataType , typename RealType >
void UE::Geometry::TPointHashGrid3< PointDataType, RealType >::UpdatePoint ( const PointDataType Value,
const TVector< RealType > &  OldPosition,
const TVector< RealType > &  NewPosition 
)
inline

Move value from old to new position. This function is thread-safe.

Parameters
Valuethe point/value to update
OldPositionthe current position associated with this value
NewPositionthe new position for this value

◆ UpdatePointUnsafe()

template<typename PointDataType , typename RealType >
void UE::Geometry::TPointHashGrid3< PointDataType, RealType >::UpdatePointUnsafe ( const PointDataType Value,
const TVector< RealType > &  OldPosition,
const TVector< RealType > &  NewPosition 
)
inline

Move value from old to new position, without locking / thread-safety

Parameters
Valuethe point/value to update
OldPositionthe current position associated with this value
NewPositionthe new position for this value

The documentation for this class was generated from the following file: