BVHTriangle

Inheritance diagram of rumba.BVHTriangle
class BVHTriangle

A bounding volume hierarchy to quickly intersect 3d triangles.

Variables

default_value (BVHTriangle) – Static. The default value.

Methods

__init__

Constructor(s)

closest(position, d, closest_pos, st)

Find the closest triangle.

intersect_closest(position, direction, ...)

Find the closest intersection of a ray against the triangles.

Properties

default_value

__init__()

Constructor(s)

BVHTriangle (v: Value)

Cast a Value object in BVHTriangle.

If v has not the good type, a default value is constructed.

BVHTriangle (mesh: Mesh)

Build a BVH using the mesh triangles.

Parameters
  • mesh (Mesh) - The mesh

closest(position: Imath.V3f, d: float, closest_pos: Imath.V3f, st: Imath.V2f) int

Find the closest triangle.

Return the triangle index if an intersection has been found. Returns -1 if no intersection has been found. If the function returns a positive value, d is filled with the distance to the closest triangle and if closest_pos is not null, *closest_pos is filled with the closest position. The function considers only the triangle closer than d.

The returned integer is a triangle index, and not a polygon index.

Parameters
  • position (Imath.V3f) – The position where to look for the closest triangle

  • d (float) – The maximum search distance. In return, d is filled with the closest triangle distance

  • closest_pos (Imath.V3f) – If not null and if a closest triangle has been found, closest_pos is filled with the closest triangle position.

  • st (Imath.V2f) – If not null and if a closest triangle has been found, st is filled with the closest triangle barycenric coordinates.

Return type

int

intersect_closest(position: Imath.V3f, direction: Imath.V3f, tnear: float, tfar: float, st: Imath.V2f) int

Find the closest intersection of a ray against the triangles.

Return the triangle index if an intersection has been found. Returns -1 if no intersection has been found. If the function returns a positive value, tfar is filled with the intersection parameter. The hit position is then position+direction*tfar. The function considers only the intersections with a t between [tnear, tfar[ .

Please note the returned integer is a triangle index, and not a polygon index.

Parameters
  • position (Imath.V3f) – The position from where the ray starts

  • direction (Imath.V3f) – The direction of the ray

  • tnear (float) – The near t parameter before which no intersection are tested

  • tfar (float) – The far t parameter after which no intersection are tested. If an intersection has been found, tfar get in return the t parameter of the closest hit.

  • st (Imath.V2f) – If not null and if a triangle has been hit, st is filled with the hit point triangle barycenric coordinates.

Return type

int