Octree.kl

Types

Octree (object)

The Octree type implements an octree spatial partition structure, which is equivalent of a “3D sort” of objects enabling fast searches among multiple objects in space.

The Octree subdivides the space in a sparse hierarchy of cells, in order to quickly isolate empty space. This then enables to perform queries such as raycast by testing only a portion of the objects.

This Octree implementation tries to provide a good balance between speed, memory usage and the ability to update incrementally. The ability to update incrementally implies that the octree has the ability to update only objects that changed. Additionally, octree’s construction can be done only partially while maintaining its valid state, which allows for a balance between construction and query time.

Because Octree.raycast and Octree.getClosest need to be more precise than simple bounding volume intersection, these require specialized object intersections for the actual geometry (polygon, edge, geometry) to be implemented through the RaycastResult and ClosestResult interfaces.

All query (read) methods are thread-safe as long as the Octree is not modified (Octree.updateObjectVolume, Octree.removeObject and Octree.prepare).

Methods

  Octree ( in Octree other )
  Octree ( in UInt8 maxDepth, in Boolean keepSubCellObjectList, in Scalar smallestWorldCellSize )
  Octree ()
Octree clone ? ()
  getClosest ? ( in Vec3 position, in Vec3 scaling, in Scalar maxUnscaledDistance, io SpatialQueryData data, io Ref<ClosestResult> result )
  getLineIntersectedObjects ? ( in Vec3 start, in Vec3 end, in UInt8 intersectionLineTypeEnum, io SpatialQueryData data )
Box3 getObjectBBox ? ( in Size index )
  getObjectBSphere ? ( in Size index, io Vec3 center, io Scalar radius )
Size getObjectCount ? ()
  getObjectsInBBox ? ( in Vec3 min, in Vec3 max, io SpatialQueryData data )
  getObjectsInBSphere ? ( in Vec3 center, in Scalar radius, io SpatialQueryData data )
Box3 getWorldBBox ! ()
  incrementalUpdateObjectCount ! ( in Size objectCount )
  localBVolQuery ? ( in Mat44 transform, in LocalBoundingVolume localBVol, out IndexSet result )
  localBVolQuery ? ( in Mat44 transform, in LocalBoundingVolume localBVol, out IndexSet result, in BitVector objectMask )
Boolean prepare ! ( in Size approximateNumberOfQueries )
  raycast ? ( in Ray ray, in Boolean doubleSided, in Scalar maxDistance, io SpatialQueryData data, io Ref<RaycastResult> result )
  removeObject ! ( in UInt32 index )
  updateObjectVolume ! ( in UInt32 index, in Mat44 transform, in LocalBoundingVolume localBVol )
Boolean updateObjectVolume ! ( in UInt32 index, in Vec3 center, in Scalar radius )
  updateObjectVolume ! ( in UInt32 index, in Vec3 min, in Vec3 max )