Graphics Reference
In-Depth Information
Appending to, rather than overwriting, the array allows the caller more flexi-
bility. If the caller requires overwrite behavior, then it can simply clear the array
itself before invoking the query. Some tasks in which overwriting is undesirable
are accumulating the results of several queries, and applying the same query to
primitive sets stored in different data structures.
We assume getBallIntersection returns only primitives that overlap the
ball. The primitives stored in the data structure may contain additional informa-
tion that is unnecessary for the intersection computation, such as reflectivity data
for rendering or a network connection for a distributed application like a multi-
player game. They may also present different geometry to different subsystems.
Thus, while a data structure may make conservative approximations for efficiency,
it must ultimately query the primitive to determine exact intersections. Querying
the primitives may be relatively expensive compared to the conservative approx-
imations. An alternative interface to the ball intersection routine would return a
conservative result of primitives that may overlap the ball, using only the conser-
vative tests. This is useful, for example, if the caller intends to perform additional
intersection tests on the result anyway.
Method getAABoxIntersection ,
void getAABoxIntersection( const AABox& box, std::vector< Value * >& result) const ;
is similar to getBallIntersection . It finds all primitives in the data structure
that overlap the interior of the axis-aligned box named box . Overlap tests against
an axis-aligned box are often significantly faster than those performed against an
arbitrarily oriented box, and the box itself can be represented very compactly.
The use of axis-aligned boxes is important for more than primitive intersec-
tions. For data structures such as the k d-tree and grid that contain spatial partitions
aligned with the axes, the axis-aligned box intersection against internal nodes in a
data structure may be particularly efficient and implemented with only one or two
comparisons per axis.
Method firstRayIntersection ,
bool firstRayIntersection( const Ray & ray, Value * & value, float & distance) const ;
tests for intersections between the primitive set and a ray (Figure 37.5). There are
three possible results.
1. There is no intersection. The method returns false and the referenced
parameters are unmodified.
2. The intersection closest to the ray origin is at distance r and r
distance .
The method returns false and the referenced parameters are unmodified.
Q
Q
I
=
Q B
F
B
B
Geometric intersection
“First” intersection
Figure 37.5: (Left) The geometric intersection I of a 2D query ray Q with box B. (Right)
The point F that we call the first intersection between the ray and box, that is, the point on
the geometric intersection that is closest to the ray origin.
 
Search WWH ::




Custom Search