Class BoundingVolumeHeirarchy
java.lang.Object
com.marginallyclever.ro3.apps.pathtracer.spatialaccelerationstructure.BoundingVolumeHeirarchy
- All Implemented Interfaces:
SpatialAccelerationStructure
A BoundingVolumeHeirarchy uses AABBs and Surface Area Heuristics (SAH)
to organize PathTriangles for fast intersection testing by classes like the PathTracer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublestatic final doublestatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled after all triangles are inserted.booleaninsert(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:
insertin 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:
finishInsertsin interfaceSpatialAccelerationStructure
-
intersect
Finds the first intersecting triangle for a given ray within the spatial acceleration structure.- Specified by:
intersectin interfaceSpatialAccelerationStructure- Parameters:
ray- the ray to test for intersection with the triangles in the structure- Returns:
- the first intersecting
PathTriangle, ornullif no intersection is found
-