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

#include <PointHashGrid2.h>

Public Member Functions

 TPointHashGrid2 (RealType cellSize, PointDataType InvalidValue)
 
void Reserve (int32 Num)
 
PointDataType GetInvalidValue () const
 
void InsertPoint (const PointDataType &Value, const TVector2< RealType > &Position)
 
void InsertPointUnsafe (const PointDataType &Value, const TVector2< RealType > &Position)
 
bool RemovePoint (const PointDataType &Value, const TVector2< RealType > &Position)
 
bool RemovePointUnsafe (const PointDataType &Value, const TVector2< RealType > &Position)
 
void UpdatePoint (const PointDataType &Value, const TVector2< RealType > &OldPosition, const TVector2< RealType > &NewPosition)
 
void UpdatePointUnsafe (const PointDataType &Value, const TVector2< RealType > &OldPosition, const TVector2< RealType > &NewPosition)
 
TPair< PointDataType, RealType > FindNearestInRadius (const TVector2< RealType > &QueryPoint, RealType Radius, TFunctionRef< RealType(const PointDataType &)> DistanceSqFunc, TFunctionRef< bool(const PointDataType &)> IgnoreFunc=[](const PointDataType &data) { return false;}) const
 

Detailed Description

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

Hash Grid for values associated with 2D 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 2D 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 2D point for the point_data. To Update a point you need to know its old and new 2D coordinates.

Constructor & Destructor Documentation

◆ TPointHashGrid2()

template<typename PointDataType , typename RealType >
UE::Geometry::TPointHashGrid2< PointDataType, RealType >::TPointHashGrid2 ( RealType  cellSize,
PointDataType  InvalidValue 
)
inline

Construct 2D hash grid

Parameters
cellSizesize of grid cells
InvalidValuethis value will be returned by queries if no valid result is found (e.g. bounded-distance query)

Member Function Documentation

◆ FindNearestInRadius()

template<typename PointDataType , typename RealType >
TPair< PointDataType, RealType > UE::Geometry::TPointHashGrid2< PointDataType, RealType >::FindNearestInRadius ( const TVector2< RealType > &  QueryPoint,
RealType  Radius,
TFunctionRef< RealType(const PointDataType &)>  DistanceSqFunc,
TFunctionRef< bool(const PointDataType &)>  IgnoreFunc = [](const PointDataType& data) { return false; } 
) const
inline

Find nearest point in grid, within a given sphere, without locking / thread-safety.

Parameters
QueryPointthe center of the query sphere
Radiusthe radius of the query sphere
DistanceFuncFunction you provide which measures the 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,DistanceFunc(Value)), or (InvalidValue,MaxDouble) if not found

◆ GetInvalidValue()

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

Invalid grid value

◆ InsertPoint()

template<typename PointDataType , typename RealType >
void UE::Geometry::TPointHashGrid2< PointDataType, RealType >::InsertPoint ( const PointDataType Value,
const TVector2< 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::TPointHashGrid2< PointDataType, RealType >::InsertPointUnsafe ( const PointDataType Value,
const TVector2< RealType > &  Position 
)
inline

Insert at given position, without locking / thread-safety

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

◆ RemovePoint()

template<typename PointDataType , typename RealType >
bool UE::Geometry::TPointHashGrid2< PointDataType, RealType >::RemovePoint ( const PointDataType Value,
const TVector2< 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::TPointHashGrid2< PointDataType, RealType >::RemovePointUnsafe ( const PointDataType Value,
const TVector2< 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::TPointHashGrid2< PointDataType, RealType >::Reserve ( int32  Num)
inline

Reserve space in the underlying hash map

Parameters
Numamount of elements to reserve

◆ UpdatePoint()

template<typename PointDataType , typename RealType >
void UE::Geometry::TPointHashGrid2< PointDataType, RealType >::UpdatePoint ( const PointDataType Value,
const TVector2< RealType > &  OldPosition,
const TVector2< 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::TPointHashGrid2< PointDataType, RealType >::UpdatePointUnsafe ( const PointDataType Value,
const TVector2< RealType > &  OldPosition,
const TVector2< 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: