Class BoundingVolumeHeirarchy
java.lang.Object
com.marginallyclever.ro3.apps.pathtracer.spatialaccelerationstructure.BoundingVolumeHeirarchy
- All Implemented Interfaces:
SpatialAccelerationStructure
A BoundingVolumeHeirarchy
uses AABB
s and Surface Area Heuristics (SAH)
to organize PathTriangle
s for fast intersection testing by classes like the PathTracer
.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final double
static final double
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Called after all triangles are inserted.boolean
insert
(PathTriangle triangle) Add a new triangle to the SASFinds the first intersecting triangle for a given ray within the spatial acceleration structure.
-
Field Details
-
MAX_TRIANGLES_PER_LEAF
public static final int MAX_TRIANGLES_PER_LEAF- See Also:
-
C_TRAV
public static final double C_TRAV- See Also:
-
C_INT
public static final double C_INT- See Also:
-
-
Constructor Details
-
BoundingVolumeHeirarchy
public BoundingVolumeHeirarchy()
-
-
Method Details
-
insert
Add a new triangle to the SAS- Specified by:
insert
in interfaceSpatialAccelerationStructure
- Parameters:
triangle
- the triangle to add.- Returns:
- true if it was added.
-
finishInserts
public void finishInserts()Called after all triangles are inserted. Good for final step optimizing.- Specified by:
finishInserts
in interfaceSpatialAccelerationStructure
-
intersect
Finds the first intersecting triangle for a given ray within the spatial acceleration structure.- Specified by:
intersect
in interfaceSpatialAccelerationStructure
- Parameters:
ray
- the ray to test for intersection with the triangles in the structure- Returns:
- the first intersecting
PathTriangle
, ornull
if no intersection is found
-