pfIsectFunc(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages
NAME
pfIsectFunc, pfGetIsectFunc, pfAllocIsectData, pfGetIsectData,
pfPassIsectData - Set intersection callback, allocate and pass
intersection data.
FUNCTION SPECIFICATION
#include <Performer/pf.h>
void pfIsectFunc(pfIsectFuncType func);
pfIsectFuncType pfGetIsectFunc(void);
void * pfAllocIsectData(int bytes);
void * pfGetIsectData(void);
void pfPassIsectData(void);
typedef void (*pfIsectFuncType)(void *userData);
DESCRIPTION
The func argument to pfIsectFunc specifies the intersection callback
function. This function will be invoked by pfFrame and will be passed a
pointer to a data buffer allocated by pfAllocIsectData. If a separate
process is allocated for intersections by the PFMP_FORK_ISECT mode to
pfMultiprocess, then pfFrame will cause func to be called in the separate
process. pfGetIsectFunc returns the intersection callback or NULL if
none is set.
Within the intersection callback, the user may further multiprocess
intersection queries through any IRIX multiprocessing mechanism such as
fork, sproc, or m_fork. All of these processes may call pfNode::isect in
parallel.
When the intersection function is in a separate process, it will run
asynchronously with the rest of the rendering pipeline. Specifically, if
the intersection function takes more than a frame time, the rendering
pipeline will not be affected and the next invocation of the intersection
function will be delayed until triggered by the next pfFrame. Changes to
the scene graph made by the application process are only propagated to
the intersection process after the intersection function returns.
Any modifications made to the scene graph by a forked intersection
function will not be reflected in the scene graph that is seen by any
other OpenGL Performer functions. To be safe, only pfNode::isect (which
does not modify the scene graph) should be called from within the
intersection function.
pfAllocIsectData returns a pointer to a chunk of shared memory of bytes
Page 1
pfIsectFunc(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages
bytes. This memory buffer may be used to communicate information between
the intersection function and application. Intersection data should only
be allocated once. pfGetIsectData returns the previously allocated
intersection data.
When the intersection function is forked, pfPassIsectData should be used
to copy the intersection data into internal OpenGL Performer memory when
the next pfFrame is called. Once pfFrame is called, the application may
modify data in the intersection data buffer without fear of colliding
with the forked intersection function.
Example 1: Multiprocessed intersections.
typedef struct
{
int frameCount; /* For frame stamping collisions */
pfNode *collidee; /* pfNode to collide with */
int numCollisions; /* Number of collision vectors */
pfSeg *collisionVecs[MAXCOLLISIONS];
} IsectStuff;
void
isectFunc(void *data)
{
IsectStuff istuff = (IsectStuff*) data;
istuff->collidee->isect(etc...);
}
:
pfMultiprocess(PFMP_FORK_ISECT | PFMP_APP_CULL_DRAW);
pfConfig();
:
pfIsectFunc(isectFunc);
isectData = (IsectStuff*) pfAllocIsectData(sizeof(IsectStuff));
isectData->collidee = (pfNode*) scene;
while (!done)
{
pfSync(); /* Sleep until next frame boundary */
update_view(); /* Set view for frame N */
isectData->frameCount = pfGetFrameCount();
pfPassIsectData(); /* Pass intersection data to */
/* intersection process */
pfFrame(); /* Trigger cull, intersection for frame N */
app_funcs(); /* Perform application-specific functions */
update_positions(); /* Update moving models for frame N + 1 */
Page 2
pfIsectFunc(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages
/*
* Act on result of previous collisions and set up isectData
* for more collisions.
*/
update_collisions(isectData);
}
If pfIsectFunc is called before pfConfig and the multiprocessing mode is
PFMP_DEFAULT, then pfConfig will fork the intersection process if there
are enough processors. Otherwise, you must explicitly fork the
intersection process by setting the PFMP_FORK_ISECT bit in the argument
passed to pfMultiprocess.
SEE ALSO
pfConfig, pfMultiprocess, pfNode
Page 3