Graphics Reference
In-Depth Information
timeStack.push(tmax);
tmax = t;
} else nearIndex = 1 nearIndex; // 0 <= t < tmin, visit far side
}
}
node = node- > child[nearIndex];
} else {
// Now at a leaf. If it is solid, there's a hit at time tmin, so exit
if (node->IsSolid()) {
*thit = tmin;
return 1;
}
// Exit if no more subtrees to visit, else pop off a node and continue
if (nodeStack.empty()) break;
tmin = tmax;
node = nodeStack.top(); nodeStack.pop();
tmax = timeStack.top(); timeStack.pop();
}
}
// No hit
return 0;
}
Computing the intersection time t of the ray with a plane determines the sidedness
of P with respect to the plane as a subcomputation. This information can be reused
when determining which side(s) of the plane the ray should be sent down. It turns
out that there are four cases that must be handled when considering the active section
(
[
t min , t max ]
) of the ray against a dividing plane (illustrated in Figure 8.16). In the cases
in which t
t max , respectively, only the near side of the plane (where P
lies) should be traversed. When 0
<
0 and t
>
t
<
t min , only the far side should be traversed.
In the last case, where t min
t
t max , the near side should be traversed with the ray
interval
.
To turn this into a test against thick planes, an epsilon term should be added to
the plane comparisons to ensure that both sides are visited when the ray touches the
thick plane. It is important that this epsilon term be larger than the thickness term
used during construction of the tree.
If the ray is intersected against a leaf-storing tree rather than a solid-leaf tree, care
must be taken when polygons have been sent down both sides of a dividing plane
instead of being clipped to the plane. In this case, the same problem as when tracing
a ray through a grid occurs: the ray might intersect a polygon at a point that lies
outside the volume of the current leaf. Any intersection points outside the current
leaf must be detected, allowing processing to continue unhindered.
[
t min , t
]
and the far side with the interval
[
t , t max ]
 
Search WWH ::




Custom Search