Simple triangle class including a collection of routines for analysis and transformation. More...
#include <mitsuba/core/triangle.h>
Public Member Functions | |
AABB | getAABB (const Point *positions) const |
Construct an axis-aligned box, which contains the triangle. More... | |
AABB | getClippedAABB (const Point *positions, const AABB &aabb) const |
Returns the axis-aligned bounding box of a triangle after it has clipped to the extends of another given AABB. More... | |
BSphere | getBSphere (const Point *positions) const |
Point | sample (const Point *positions, const Normal *normals, const Point2 *texCoords, Normal &n, Point2 &uv, const Point2 &seed) const |
Uniformly sample a point on the triangle and return its normal and UV coordinates. More... | |
Float | surfaceArea (const Point *positions) const |
Calculate the surface area of this triangle. More... | |
FINLINE bool | rayIntersect (const Point *positions, const Ray &ray, Float &u, Float &v, Float &t) const |
Ray-triangle intersection test. More... | |
Static Public Member Functions | |
static FINLINE bool | rayIntersect (const Point &p0, const Point &p1, const Point &p2, const Ray &ray, Float &u, Float &v, Float &t) |
Ray-triangle intersection test. More... | |
Public Attributes | |
uint32_t | idx [3] |
Indices into a vertex buffer. More... | |
Simple triangle class including a collection of routines for analysis and transformation.
Triangles are stored as indices into a vertex array
Construct an axis-aligned box, which contains the triangle.
Returns the axis-aligned bounding box of a triangle after it has clipped to the extends of another given AABB.
This function uses the Sutherland-Hodgman algorithm to calculate the convex polygon that is created when applying all 6 AABB splitting planes to the triangle. Afterwards, the AABB of the newly created convex polygon is returned. This function is an important component for efficiently creating 'Perfect Split' KD-trees. For more detail, see "On building fast kd-Trees for Ray Tracing, and on doing that in O(N log N)" by Ingo Wald and Vlastimil Havran
|
inlinestatic |
Ray-triangle intersection test.
Uses the algorithm by Moeller and Trumbore discussed at http://www.acm.org/jgt/papers/MollerTrumbore97/code.html
.
p0 | Position of the first vertex |
p1 | Position of the second vertex |
p2 | Position of the third vertex |
ray | The ray segment to be used for the intersection query |
t | Upon success, t contains the distance from the ray origin to the intersection point, |
u | Upon success, u will contain the 'U' component of the intersection in barycentric coordinates |
v | Upon success, v will contain the 'V' component of the intersection in barycentric coordinates |
true
if an intersection has been detected
|
inline |
Ray-triangle intersection test.
Uses the algorithm by Moeller and Trumbore discussed at http://www.acm.org/jgt/papers/MollerTrumbore97/code.html
.
positions | Pointer to the vertex positions of the underlying triangle mesh |
index | Index of the triangle that should be intersected |
ray | The ray segment to be used for the intersection query |
t | Upon success, t contains the distance from the ray origin to the intersection point, |
u | Upon success, u will contain the 'U' component of the intersection in barycentric coordinates |
v | Upon success, v will contain the 'V' component of the intersection in barycentric coordinates |
true
if an intersection has been detected Point mitsuba::Triangle::sample | ( | const Point * | positions, |
const Normal * | normals, | ||
const Point2 * | texCoords, | ||
Normal & | n, | ||
Point2 & | uv, | ||
const Point2 & | seed | ||
) | const |
Uniformly sample a point on the triangle and return its normal and UV coordinates.
Calculate the surface area of this triangle.
uint32_t mitsuba::Triangle::idx[3] |
Indices into a vertex buffer.