![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <SegmentTree3.h>
Classes | |
| struct | FBoxesSet |
| struct | FRayNearestSegmentInfo |
| struct | FSegment |
| struct | FTreeBox |
Public Types | |
| using | GetSplitAxisFunc = TUniqueFunction< int(int Depth, const FAxisAlignedBox3d &Box)> |
Public Member Functions | |
| template<typename SegmentIDEnumerable , typename GetSegmentFunc > | |
| void | Build (SegmentIDEnumerable Enumerable, GetSegmentFunc GetSegmentForID, int32 NumSegmentsHint=0) |
| void | Build (const TArray< FSegment3d > &Segments) |
| bool | FindNearestSegment (const FVector3d &P, FSegment &NearestSegmentOut, const IMeshSpatial::FQueryOptions &Options=IMeshSpatial::FQueryOptions()) const |
| bool | FindNearestVisibleSegmentHitByRay (const FRay3d &Ray, TFunctionRef< bool(int32, const FVector3d &, const FVector3d &)> WithinToleranceCheck, FSegment &NearestHitSegmentOut, FRayNearestSegmentInfo &NearestInfo, const IMeshSpatial::FQueryOptions &Options=IMeshSpatial::FQueryOptions()) const |
| void | SetTolerance (double Tolerance) |
Protected Member Functions | |
| void | BuildTopDown (TArray< int > &SegmentIndices, TArray< FVector3d > &SegmentCenters, int32 NumSegments) |
| int | SplitSegmentSetMidpoints (TArray< int > &SegmentIndices, TArray< FVector3d > &SegmentCenters, int StartIdx, int Count, int Depth, int MinSegmentCount, FBoxesSet &SegmentBoxes, FBoxesSet &Nodes, FAxisAlignedBox3d &Box) |
| double | GetBoxDistanceSqr (int BoxIndex, const FVector3d &V) const |
| double | GetRayBoxIntersectionParam (int BoxIndex, const FRay3d &Ray, double Radius=0) const |
| void | FindNearestSegmentInternal (int BoxIndex, const FVector3d &P, double &NearestDistSqr, int &NearSegmentIdx, const IMeshSpatial::FQueryOptions &Options) const |
| void | FindNearestVisibleSegmentHitByRayInternal (int BoxIndex, const FRay3d &Ray, TFunctionRef< bool(int32, const FVector3d &, const FVector3d &)> WithinToleranceCheck, int &NearSegmentIdx, FRayNearestSegmentInfo &NearestInfo, const IMeshSpatial::FQueryOptions &Options) const |
Static Protected Member Functions | |
| static GetSplitAxisFunc | MakeDefaultSplitAxisFunc () |
Protected Attributes | |
| int | TopDownLeafMaxSegmentCount = 8 |
| GetSplitAxisFunc | GetSplitAxis = MakeDefaultSplitAxisFunc() |
| TArray< FSegment > | SegmentList |
| TArray< FTreeBox > | TreeBoxes |
| TArray< int > | IndexList |
| int | SegmentsEnd = -1 |
| int | RootBoxIndex = -1 |
| double | BoxEps = FMathd::ZeroTolerance |
FSegmentTree3 is a spatial data structure for a set of 3D line segments. The line segments are provided externally, and each segment can have an arbitrary ID. The line segment geometry (ie endpoints) are stored directly by FSegmentTree3, so the class does not hold onto any reference to the source geometry (ie unlike FMeshAABBTree3).
Available queries:
| using UE::Geometry::FSegmentTree3::GetSplitAxisFunc = TUniqueFunction<int(int Depth, const FAxisAlignedBox3d& Box)> |
|
inline |
|
inline |
Build the segment tree based on the given Enumerable (ie something that supports a range-based for loop over a set of integer IDs) and a function GetSegmentForID that returns the 3D line segment for a given ID. Gaps/etc are allowed but all enumerated IDs must be valid.
|
inlineprotected |
|
inline |
Find the nearest segment to query point P, and return it in NearestSegmentOut
|
inlineprotected |
|
inline |
Find the segment that is hit by a 3D ray under a function WithinToleranceCheck, which will be called with the Ray and Segment points. For example if this is a 3D distance check against a fixed radius, this function essentially raycasts against 3D capsules.
The function compares potential hits (ie that pass the tolerance) with a sort of "distance" metric that tries to balance distance from the ray origin (ie "close to eye") and distance from the hit segment (ie "on the line"). There is no correct way to do this, currently the code uses a metric based on the opening angle between ray and segment points.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlinestaticprotected |
Sets the box intersection tolerance TODO: move into the IMeshSpatial::FQueryOptions and delete this function
|
inlineprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |