Graphics Reference
In-Depth Information
r
P
P
C
C
d
(a)
(b)
Figure 13.8 (a) Sphere with center C and radius r for which all contained geometry is cached.
A smaller sphere with the same center and a radius of d is also maintained. (b) When the player
leaves the smaller sphere at some point P , the amortized caching of all geometry contained
in the sphere centered at P with radius r begins. This caching must be guaranteed complete
within the time it takes to travel the distance r d to ensure that the new set of geometry
can be made current when the outer sphere of the initial sphere pair is exited by the player.
To reduce the cost of linearizing the collision primitives within the sphere into the
cache, this computation can be amortized. When the player has moved some distance
away from the origin of the currently cached spherical volume, a new caching query is
initiated from the current player position and completed by computing it in parts over
a few frames (Figure 13.8). When the second set of cached data is fully computed,
whichever set corresponding to the sphere whose center the player is closest to is
made the current collision set, and the other set is cleared and recomputed in the
same manner when the player again has moved some specific distance away from
the new sphere origin.
This approach is best for applications in which the player character travels with
moderate speed. It might not be suitable if instant teleportation from one location to
another is possible.
13.6 Aliasing
In both C and C++ it is not uncommon to have two pointers pointing to the same
location in memory. When two pointers point to the same memory location they are
said to alias each other. For example, in following code the pointers p1 and p2 are
both aliases to the memory of the integer variable n :
int n;
int *p1 = &n;
// *p1 references the location of n
int *p2 = &n;
// *p2 also references the location of n
 
Search WWH ::




Custom Search