Method BuildIndex
- Namespace
- GeometryHelper.Geometry
- Assembly
- GeometryHelper.dll
BuildIndex()
Builds a spatial index over the surface of this body, for asking it many questions.
public GeoBvh3 BuildIndex()
Returns
- GeoBvh3
The hierarchy; it is a snapshot and holds no reference back to this shape.
Remarks
An index is worth building when the same shape is asked many questions. Building it costs a sort of the triangles, so it pays for itself over repeated queries and never on the first one; below a few dozen triangles the plain walk wins outright. Every shape here is immutable, so a tree stays valid for as long as the shape exists — build it once, keep it, throw it away with the shape.
It is Build and not Get because it does work. Calling it inside a loop is slower than
not having it at all, which is exactly the mistake the name is there to prevent.
The index is over triangles and the body is not. GetIntersections on the tree reports
one hit per triangle, so a ray landing on the diagonal two triangles share is named twice, while the
body names each place once. Ask the body where you want places; ask the tree where you want speed
and can keep clear of the edges — which is what Containment3 does by throwing its ray again
in another direction when a hit lands near one.
BuildIndex(Tolerance)
Builds a spatial index over the surface of this body, within a tolerance.
public GeoBvh3 BuildIndex(Tolerance tolerance)
Parameters
toleranceToleranceThe tolerance the triangulation works to.
Returns
- GeoBvh3
The hierarchy; it is a snapshot and holds no reference back to this shape.