Re: pfNodeTravFuncs question

New Message Reply Date view Thread view Subject view Author view

John Rohlf (jrohlf++at++tubes)
Wed, 20 Oct 93 09:30:16 -0700


>I'm having a problem getting a performer object to respond
>correctly to its pre and post callbacks. My objective is
>to have this object be drawn depending on some boolean
>value. Actually, I think my problem is more with
>pfNodeTravMask than pfNodeTravFuncs. Here's what it
>looks like:
>
>{
>pfGeode *obj;
>
>pfNodeTravFuncs (obj, PFTRAV_DRAW, PreObjCallback, PostObjCallback);
>}
>
>
>long
>PreObjCallback (pfTraverser *trav, void *data)
>{
> if (!obj_on)
> {
> pfNodeTravMask (obj, PFTRAV_DRAW, 0x0, PFTRAV_SELF, PF_SET);
> return PFTRAV_PRUNE;
> }
> else
> {
> pfNodeTravMask (obj, PFTRAV_DRAW, 0xffffffff, PFTRAV_SELF, PF_SET);
> return PFTRAV_CONT;
> }
>}
>
>long
>PostObjCallback (pfTraverser *trav, void *data)
>{
> return PFTRAV_CONT;
>}
>
>Two questions: First, when I replace obj with trav in the callbacks,
>it core dumps. Shouldn't they be the same?
>Also, do I have to do anything in the post callback? What is the
>purpose of the return value?
>What happens now is that the boolean flag is initially false and
>even when it changes to true, the object is never drawn.

        We kind of lie when we say the draw is a traversal. What
really happens is that the cull traverses the node hierarchy and flattens
it into a very efficient linear display list which the draw "traverses".
So in the draw process there isn't really a concept of a node
hierarchy. Consequently, draw callbacks are primarily for tweaking
GL.

        If you just want to "turn off" a node then you should
do so further upstream, say in the cull or even the app process.
If the boolean is available in the application, then just
call pfNodeTravMask there. Otherwise you can use a cull callback
to prune the traversal:

pfNodeTravFuncs (obj, PFTRAV_CULL, PreCullObjCallback, NULL);

long
PreCullObjCallback (pfTraverser *trav, void *data)
{
  if (!obj_on)
    return PFTRAV_PRUNE;
  else
    return PFTRAV_CONT;
}
         

>Two questions: First, when I replace obj with trav in the callbacks,
>it core dumps. Shouldn't they be the same?

'obj' is a node while 'trav' is a pfTraverser. These are totally different
beasts. Instead of 'obj' you should use pfGetTravNode(trav) which
returns the node that owns the callback.

>Also, do I have to do anything in the post callback?

        No. This may be NULL.

>What is the purpose of the return value?

        To prune, terminate or continue traversal.

>What happens now is that the boolean flag is initially false and
>even when it changes to true, the object is never drawn.

        When multiprocessing the flag may not be visible to all
processes and may always stay false.


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:04 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.