dhart.raytracer.IntersectOccluded

dhart.raytracer.IntersectOccluded(bvh: EmbreeBVH, origins: Iterable[Tuple[float, float, float]] | Tuple[float, float, float], directions: Iterable[Tuple[float, float, float]] | Tuple[float, float, float], max_distance: float = -1) List[bool] | bool

Cast one or more occlusion rays in C++

Occlusion rays are faster than standard rays, however can only return whether or not they hit anything.

Returns:

an ordered list of booleans where true indicates a

hit, and false indicates a miss. If a single element is passed, only bool is returned.

Return type:

List[bool] or bool

Parameters:
  • origins – A list of origin points, or a single origin point

  • directions – A list of directions or a single direction

  • max_distance – Maximum distance that a ray can travel. Any hits beyond this point are not counted

Raises:

TypeError – BVH is not a valid EmbreeBVH

Example

Casting multiple rays from a single origin in multiple directions

>>> from dhart.geometry import LoadOBJ, CommonRotations, ConstructPlane
>>> from dhart.raytracer import EmbreeBVH, IntersectOccluded
>>> loaded_obj = ConstructPlane()
>>> loaded_obj.Rotate(CommonRotations.Yup_to_Zup)
>>> bvh = EmbreeBVH(loaded_obj)
>>> directions = [(0,0,-1), (0,1,0), (1,0,0)]
>>> hit_point = IntersectOccluded(bvh, (0,0,1), directions)
>>> print(hit_point)
[True, False, False]