Table of Contents

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

parameter OctreeBuildParameter

Fields

OctantSize

public const int OctantSize = 8

Field Value

int

Properties

Bound

public BoundingBox Bound { get; }

Property Value

BoundingBox

HitPathBoundingBoxes

public IList<BoundingBox> HitPathBoundingBoxes { get; }

Property Value

IList<BoundingBox>

MIN_SIZE

The minumum size for enclosing region is a 1x1x1 cube.

public float MIN_SIZE { get; }

Property Value

float

Objects

protected T[]? Objects { get; }

Property Value

T[]

OctantArraySize

Internal octant array size.

public int OctantArraySize { get; }

Property Value

int

Parameter

Octree parameter

public OctreeBuildParameter Parameter { get; }

Property Value

OctreeBuildParameter

TreeBuilt

public bool TreeBuilt { get; protected set; }

Property Value

bool

Methods

BoxContainsBox(ref BoundingBox, ref BoundingBox)

protected static bool BoxContainsBox(ref BoundingBox source, ref BoundingBox target)

Parameters

source BoundingBox
target BoundingBox

Returns

bool

BoxDisjointSphere(BoundingBox, ref BoundingSphere)

protected static bool BoxDisjointSphere(BoundingBox box, ref BoundingSphere sphere)

Parameters

box BoundingBox
sphere BoundingSphere

Returns

bool

BuildSubTree(int)

Build sub tree nodes

protected void BuildSubTree(int index)

Parameters

index int

BuildTree()

Call to build the tree

public void BuildTree()

CheckDimension(ref BoundingBox)

public bool CheckDimension(ref BoundingBox bound)

Parameters

bound BoundingBox

Returns

bool

CreateOctants(ref BoundingBox, float)

Create child octant bounding boxes for current parent bounding box

public static BoundingBox[] CreateOctants(ref BoundingBox box, float minSize)

Parameters

box BoundingBox
minSize float

Returns

BoundingBox[]

CreateOctreeLineModel()

public LineGeometry3D CreateOctreeLineModel()

Returns

LineGeometry3D

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

index int

Returns

BoundingBox

FindNearestPointByPointAndSearchRadius(HitTestContext?, ref Vector3, float, ref List<HitTestResult>)

public bool FindNearestPointByPointAndSearchRadius(HitTestContext? context, ref Vector3 point, float radius, ref List<HitTestResult> result)

Parameters

context HitTestContext
point Vector3
radius float
result List<HitTestResult>

Returns

bool

FindNearestPointBySphere(HitTestContext?, ref BoundingSphere, ref List<HitTestResult>)

public virtual bool FindNearestPointBySphere(HitTestContext? context, ref BoundingSphere sphere, ref List<HitTestResult> points)

Parameters

context HitTestContext
sphere BoundingSphere
points List<HitTestResult>

Returns

bool

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

octant StaticOctree<T>.Octant
context HitTestContext
sphere BoundingSphere
points List<HitTestResult>
isIntersect bool

Returns

bool

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

context HitTestContext
point Vector3
results List<HitTestResult>
heuristicSearchFactor float

Returns

bool

GetBoundingBoxFromItem(ref T)

protected abstract BoundingBox GetBoundingBoxFromItem(ref T item)

Parameters

item T

Returns

BoundingBox

GetMaxBound()

Get the max bounding box of the octree

protected abstract BoundingBox GetMaxBound()

Returns

BoundingBox

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

context HitTestContext
model object
geometry Geometry3D
modelMatrix Matrix4x4
returnMultiple bool
hits List<HitTestResult>

Returns

bool

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

context HitTestContext
model object
geometry Geometry3D
modelMatrix Matrix4x4
returnMultiple bool
hits List<HitTestResult>
hitThickness float

Returns

bool

HitTest(HitTestContext?, object?, Geometry3D?, Matrix4x4, ref List<HitTestResult>)

public bool HitTest(HitTestContext? context, object? model, Geometry3D? geometry, Matrix4x4 modelMatrix, ref List<HitTestResult> hits)

Parameters

context HitTestContext
model object
geometry Geometry3D
modelMatrix Matrix4x4
hits List<HitTestResult>

Returns

bool

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

context HitTestContext

The context.

model object

The model.

geometry Geometry3D

The geometry.

modelMatrix Matrix4x4

The model matrix.

hits List<HitTestResult>

The hits.

hitThickness float

The hit thickness.

Returns

bool

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

octant StaticOctree<T>.Octant
context HitTestContext
model object
geometry Geometry3D
modelMatrix Matrix4x4
rayModel Ray
returnMultiple bool

Return multiple hit results or only the closest one

hits List<HitTestResult>
isIntersect bool
hitThickness float

Returns

bool

IsContains(ref BoundingBox, BoundingBox, ref T)

protected virtual bool IsContains(ref BoundingBox source, BoundingBox target, ref T targetObj)

Parameters

source BoundingBox
target BoundingBox
targetObj T

Returns

bool

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

stack Stack<KeyValuePair<int, int>>
process Action<int>
canVisitChildren Func<int, bool>

Events

Hit

public event EventHandler<EventArgs>? Hit

Event Type

EventHandler<EventArgs>