Class StaticOctree<T>
- Namespace
- HelixToolkit.SharpDX.Utilities
- Assembly
- HelixToolkit.SharpDX.dll
Base class for array based static octree.
public abstract class StaticOctree<T> : IOctreeBasic where T : unmanaged
Type Parameters
T
- Inheritance
-
StaticOctree<T>
- Implements
- Derived
- Inherited Members
Constructors
StaticOctree(OctreeBuildParameter)
public StaticOctree(OctreeBuildParameter parameter)
Parameters
parameterOctreeBuildParameter
Fields
OctantSize
public const int OctantSize = 8
Field Value
Properties
Bound
public BoundingBox Bound { get; }
Property Value
HitPathBoundingBoxes
public IList<BoundingBox> HitPathBoundingBoxes { get; }
Property Value
MIN_SIZE
The minumum size for enclosing region is a 1x1x1 cube.
public float MIN_SIZE { get; }
Property Value
Objects
protected T[]? Objects { get; }
Property Value
- T[]
OctantArraySize
Internal octant array size.
public int OctantArraySize { get; }
Property Value
Parameter
Octree parameter
public OctreeBuildParameter Parameter { get; }
Property Value
TreeBuilt
public bool TreeBuilt { get; protected set; }
Property Value
Methods
BoxContainsBox(ref BoundingBox, ref BoundingBox)
protected static bool BoxContainsBox(ref BoundingBox source, ref BoundingBox target)
Parameters
sourceBoundingBoxtargetBoundingBox
Returns
BoxDisjointSphere(BoundingBox, ref BoundingSphere)
protected static bool BoxDisjointSphere(BoundingBox box, ref BoundingSphere sphere)
Parameters
boxBoundingBoxsphereBoundingSphere
Returns
BuildSubTree(int)
Build sub tree nodes
protected void BuildSubTree(int index)
Parameters
indexint
BuildTree()
Call to build the tree
public void BuildTree()
CheckDimension(ref BoundingBox)
public bool CheckDimension(ref BoundingBox bound)
Parameters
boundBoundingBox
Returns
CreateOctants(ref BoundingBox, float)
Create child octant bounding boxes for current parent bounding box
public static BoundingBox[] CreateOctants(ref BoundingBox box, float minSize)
Parameters
boxBoundingBoxminSizefloat
Returns
CreateOctreeLineModel()
public LineGeometry3D CreateOctreeLineModel()
Returns
FindEnclosingBox(int)
This finds the dimensions of the bounding box necessary to tightly enclose all items in the object list.
protected BoundingBox FindEnclosingBox(int index)
Parameters
indexint
Returns
FindNearestPointByPointAndSearchRadius(HitTestContext?, ref Vector3, float, ref List<HitTestResult>)
public bool FindNearestPointByPointAndSearchRadius(HitTestContext? context, ref Vector3 point, float radius, ref List<HitTestResult> result)
Parameters
contextHitTestContextpointVector3radiusfloatresultList<HitTestResult>
Returns
FindNearestPointBySphere(HitTestContext?, ref BoundingSphere, ref List<HitTestResult>)
public virtual bool FindNearestPointBySphere(HitTestContext? context, ref BoundingSphere sphere, ref List<HitTestResult> points)
Parameters
contextHitTestContextsphereBoundingSpherepointsList<HitTestResult>
Returns
FindNearestPointBySphereExcludeChild(ref Octant, HitTestContext?, ref BoundingSphere, ref List<HitTestResult>, ref bool)
Find nearest point by sphere on current node only.
protected abstract bool FindNearestPointBySphereExcludeChild(ref StaticOctree<T>.Octant octant, HitTestContext? context, ref BoundingSphere sphere, ref List<HitTestResult> points, ref bool isIntersect)
Parameters
octantStaticOctree<T>.OctantcontextHitTestContextsphereBoundingSpherepointsList<HitTestResult>isIntersectbool
Returns
FindNearestPointFromPoint(HitTestContext?, ref Vector3, ref List<HitTestResult>?, float)
public virtual bool FindNearestPointFromPoint(HitTestContext? context, ref Vector3 point, ref List<HitTestResult>? results, float heuristicSearchFactor = 1)
Parameters
contextHitTestContextpointVector3resultsList<HitTestResult>heuristicSearchFactorfloat
Returns
GetBoundingBoxFromItem(ref T)
protected abstract BoundingBox GetBoundingBoxFromItem(ref T item)
Parameters
itemT
Returns
GetMaxBound()
Get the max bounding box of the octree
protected abstract BoundingBox GetMaxBound()
Returns
GetObjects()
protected abstract T[] GetObjects()
Returns
- T[]
HitTest(HitTestContext?, object?, Geometry3D?, Matrix4x4, bool, ref List<HitTestResult>)
public bool HitTest(HitTestContext? context, object? model, Geometry3D? geometry, Matrix4x4 modelMatrix, bool returnMultiple, ref List<HitTestResult> hits)
Parameters
contextHitTestContextmodelobjectgeometryGeometry3DmodelMatrixMatrix4x4returnMultipleboolhitsList<HitTestResult>
Returns
HitTest(HitTestContext?, object?, Geometry3D?, Matrix4x4, bool, ref List<HitTestResult>, float)
public virtual bool HitTest(HitTestContext? context, object? model, Geometry3D? geometry, Matrix4x4 modelMatrix, bool returnMultiple, ref List<HitTestResult> hits, float hitThickness)
Parameters
contextHitTestContextmodelobjectgeometryGeometry3DmodelMatrixMatrix4x4returnMultipleboolhitsList<HitTestResult>hitThicknessfloat
Returns
HitTest(HitTestContext?, object?, Geometry3D?, Matrix4x4, ref List<HitTestResult>)
public bool HitTest(HitTestContext? context, object? model, Geometry3D? geometry, Matrix4x4 modelMatrix, ref List<HitTestResult> hits)
Parameters
contextHitTestContextmodelobjectgeometryGeometry3DmodelMatrixMatrix4x4hitsList<HitTestResult>
Returns
HitTest(HitTestContext?, object?, Geometry3D?, Matrix4x4, ref List<HitTestResult>, float)
Hits the test.
public virtual bool HitTest(HitTestContext? context, object? model, Geometry3D? geometry, Matrix4x4 modelMatrix, ref List<HitTestResult> hits, float hitThickness)
Parameters
contextHitTestContextThe context.
modelobjectThe model.
geometryGeometry3DThe geometry.
modelMatrixMatrix4x4The model matrix.
hitsList<HitTestResult>The hits.
hitThicknessfloatThe hit thickness.
Returns
HitTestCurrentNodeExcludeChild(ref Octant, HitTestContext?, object?, Geometry3D?, Matrix4x4, ref Ray, bool, ref List<HitTestResult>, ref bool, float)
Hit test for current node.
protected abstract bool HitTestCurrentNodeExcludeChild(ref StaticOctree<T>.Octant octant, HitTestContext? context, object? model, Geometry3D? geometry, Matrix4x4 modelMatrix, ref Ray rayModel, bool returnMultiple, ref List<HitTestResult> hits, ref bool isIntersect, float hitThickness)
Parameters
octantStaticOctree<T>.OctantcontextHitTestContextmodelobjectgeometryGeometry3DmodelMatrixMatrix4x4rayModelRayreturnMultipleboolReturn multiple hit results or only the closest one
hitsList<HitTestResult>isIntersectboolhitThicknessfloat
Returns
IsContains(ref BoundingBox, BoundingBox, ref T)
protected virtual bool IsContains(ref BoundingBox source, BoundingBox target, ref T targetObj)
Parameters
sourceBoundingBoxtargetBoundingBoxtargetObjT
Returns
TreeTraversal(Stack<KeyValuePair<int, int>>, Action<int>, Func<int, bool>?)
Common function to traverse the tree
public void TreeTraversal(Stack<KeyValuePair<int, int>> stack, Action<int> process, Func<int, bool>? canVisitChildren = null)
Parameters
Events
Hit
public event EventHandler<EventArgs>? Hit