Class TriangleBvh

java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.gi.TriangleBvh

public class TriangleBvh extends Object
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 Classes
    Modifier and Type
    Class
    Description
    static class 
    One ray-traced triangle with cached data.
    static class 
    Nearest-hit query result.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Builds the tree over the given triangle entries.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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 to maxT along the direction blocked?

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TriangleBvh

      public TriangleBvh(List<TriangleBvh.Entry> entries)
      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 to maxT along the direction blocked?
      Returns:
      true if any triangle intersects the segment