how does pfGetTravNode() work?

New Message Reply Date view Thread view Subject view Author view

Fred Clyne (fred++at++octave.cambridge.com)
Wed, 22 Feb 1995 23:20:07 GMT


I am looking for an explanation as to why this does not work.
I created a preCull and postCull callback routine and assigned
them to all my nodes (in a test program). Their function is
to echo the node's name during the preCull and to print the cull
result on postCull. The pre works fine. The post does not seem
to understand the node it is in. It always prints the the last
node in the tree. Is the node returned by pfGetTravNode() not
valid during a post cull process?

/********************************************/
long EchoNodeName /* preCull callback */
        (
        pfTraverser *trav,
        void *userData
        )
/********************************************/
{
char *buf;
long myID;
pfNode *node;
/* - - - - - - - - -- - - - - - - - - - - - - - */
node = pfGetTravNode(trav);
buf = (char *)pfGetNodeName(node);
myID = pfGetId(pfGetTravNode(trav));
fprintf(stderr,"in node: %s (0x%x--%d)\n",buf,node,myID);
return(PFTRAV_CONT);
} /* eof EchoNodeName() */

/********************************************/
long EchoCullResult /* posCull callback */
        (
        pfTraverser *trav,
        void *userData
        )
/********************************************/
{
char *buf;
long myID;
long cullVal;
pfNode *node;
char *msg1="";
char *msg2="";
char *msg3="";
char *msg4="";
/* - - - - - - - - - - - - - - - - - - - - - - - - - */
cullVal = pfGetCullResult();
if (cullVal bitand PFIS_FALSE) msg1 = "FALSE";
if (cullVal bitand PFIS_MAYBE) msg2 = "MAYBE";
if (cullVal bitand PFIS_TRUE) msg3 = "TRUE";
if (cullVal bitand PFIS_ALL_IN) msg4 = "ALL_IN";
node = pfGetTravNode(trav);
buf = (char *)pfGetNodeName(node);
myID = pfGetId(pfGetTravNode(trav));
fprintf(stderr,"%s (0x%x--%d) cull result = %s %s %s %s\n",
        buf,node,myID,msg1,msg2,msg3,msg4);
} /* eof EchoCullResult() */

assign the functions to each node:
pfNodeTravFuncs(mynode,PFTRAV_CULL,EchoNodeName,EchoCullResult);

typical output:

Draw frame 49.
in node: scene.root (0x76c400--8)
in node: lelevZero.LOD (0x76a950--1)
in node: lelevZero.GROUP (0x76b0b0--3)
in node: levelOne.SCS (0x76c2f0--7)
in node: levelOne.LOD (0x76b300--4)
in node: levelOne.GEODE (0x76b550--5)
levelOne.GEODE (0x76b550--5) cull result = MAYBE TRUE ALL_IN
levelOne.GEODE (0x76b550--5) cull result = MAYBE TRUE ALL_IN
levelOne.GEODE (0x76b550--5) cull result = MAYBE TRUE ALL_IN
levelOne.GEODE (0x76b550--5) cull result = MAYBE TRUE ALL_IN
levelOne.GEODE (0x76b550--5) cull result = MAYBE TRUE ALL_IN
levelOne.GEODE (0x76b550--5) cull result = MAYBE TRUE ALL_IN
Draw frame 50.
etc.

I expected to see:

Draw frame 49.
in node: scene.root (0x76c400--8)
in node: lelevZero.LOD (0x76a950--1)
in node: lelevZero.GROUP (0x76b0b0--3)
in node: levelOne.SCS (0x76c2f0--7)
in node: levelOne.LOD (0x76b300--4)
in node: levelOne.GEODE (0x76b550--5)
levelOne.GEODE (0x76b550--5) cull result = MAYBE TRUE ALL_IN
levelOne.LOD (0x76b300--4) cull result = MAYBE TRUE ALL_IN
levelOne.SCS (0x76c2f0--7) cull result = MAYBE TRUE ALL_IN
lelevZero.GROUP (0x76b0b0--3) cull result = MAYBE TRUE ALL_IN
lelevZero.LOD (0x76a950--1) cull result = MAYBE TRUE ALL_IN
scene.root (0x76c400--8) cull result = MAYBE TRUE ALL_IN
Draw frame 50.
etc.

Thank you,

Fred Clyne ( fred++at++cambridge.com )


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:59 PDT

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