MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / visible

Function visible

tools/bloom-reference/src/main.rs:1692–1701  ·  view source on GitHub ↗

Test whether a point can see a given direction without being occluded. Returns true if no triangle blocks the ray from `origin` going toward `direction_to_light` within `max_distance`. The origin should already be offset along the surface normal to avoid self-intersection.

(ray_origin: Vec3, direction_to_light: Vec3, max_distance: f32, scene: &Scene, bvh: &Bvh)

Source from the content-addressed store, hash-verified

1690/// The origin should already be offset along the surface normal to
1691/// avoid self-intersection.
1692fn visible(ray_origin: Vec3, direction_to_light: Vec3, max_distance: f32, scene: &Scene, bvh: &Bvh) -> bool {
1693 let ray = Ray::new(ray_origin, direction_to_light);
1694 // We only need to know if ANY triangle is hit before max_distance;
1695 // a specialized "any-hit" traversal would be faster than
1696 // closest-hit, but the closest-hit cost is acceptable for Phase 3.
1697 match intersect_bvh(&ray, scene, bvh) {
1698 Some(hit) => hit.t >= max_distance,
1699 None => true,
1700 }
1701}
1702
1703// ============================================================
1704// Path tracer

Callers 1

trace_pathFunction · 0.85

Calls 1

intersect_bvhFunction · 0.85

Tested by

no test coverage detected