Class TriangleBvh
java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.gi.TriangleBvh
Bounding volume hierarchy over world-space triangles for fast ray queries.
Used by the global illumination system; deliberately separate from the
voxel octree (which serves voxel tracing and stays untouched).
Build: top-down median split along the longest AABB axis. Queries: nearest-hit for bounce rays, any-hit with early out for shadow rays. Intersection is Möller–Trumbore, two-sided (walls are single quads that must occlude from both sides). Not thread-safe to build, safe to query concurrently once published via a volatile/atomic reference.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classOne ray-traced triangle with cached data.static classNearest-hit query result. -
Constructor Summary
ConstructorsConstructorDescriptionTriangleBvh(List<TriangleBvh.Entry> entries) Builds the tree over the given triangle entries. -
Method Summary
Modifier and TypeMethodDescriptionbooleannearest(double ox, double oy, double oz, double dx, double dy, double dz, TriangleBvh.Hit hit) Finds the nearest triangle hit along the ray, or null.booleanoccluded(double ox, double oy, double oz, double dx, double dy, double dz, double maxT) Any-hit shadow query: is the segment from the origin tomaxTalong the direction blocked?
-
Constructor Details
-
TriangleBvh
Builds the tree over the given triangle entries.- Parameters:
entries- triangles to index (must not be empty)
-
-
Method Details
-
nearest
public boolean nearest(double ox, double oy, double oz, double dx, double dy, double dz, TriangleBvh.Hit hit) Finds the nearest triangle hit along the ray, or null.- Parameters:
hit- reusable result object, filled on hit- Returns:
- true on hit
-
occluded
public boolean occluded(double ox, double oy, double oz, double dx, double dy, double dz, double maxT) Any-hit shadow query: is the segment from the origin tomaxTalong the direction blocked?- Returns:
- true if any triangle intersects the segment
-