Re: ->setTravFuncs

New Message Reply Date view Thread view Subject view Author view

Jean-Luc Dery (dery++at++Discreet.COM)
Tue, 13 May 1997 20:51:46 -0400


On Apr 18, 10:22am, Garrett Williams wrote:
> Subject: ->setTravFuncs
> I am trying to set up a callback within a class.
>
> I am calling this in the constructor of the class..
>
> mv_body->setTravFuncs(PFTRAV_CULL,(pfNodeTravFuncType)walk,NULL);
>
> or
>
> mv_body->setTravFuncs(PFTRAV_CULL,(pfNodeTravFuncType)people::walk,NULL);
>
> both compile BUT::: neither works....
> It seams that it will call the function (walk) properly but the function
> fails to get the proper value from a protected: varable. I have tried
> changing the varable to public and private but I recive a core when ran.
>
> I recive the warning:
>
> warning(3676): pointer-to-member-function cast to pointer
> to function
>
> mv_body->setTravFuncs(PFTRAV_CULL,(pfNodeTravFuncType)walk,NULL);
>
> maby I am missing somthing in C++ or in the proper use of
> ->setTravFuncs..
>
> all help would be liked:::Thanks for the help...
>
> Garrett

Hy Garret,

It would of been usefull to see how you actually declared the walk function in
your class; but I suspect the member function walk( pfTraverser*, void* ) was
not declared static. Is that correct ??

The function passed to the setTravFuncs arguments should be static or global
functions and not member functions. You will be able to get the current node
pointer from the traverser. Most probably, Performer converters the member
function to a global function pointer and you thus loose access to your class
data member.

If this is the case, you could try something like this:

class people
{
...

public:
   type yourVariable;

   static int preCull( pfTraverser*, void* );
};

int people::preCull( pfTraverser* trav, void* )
{
   people* body = (people*) trav->getNode();

   blablabla
   ...

   return PFTRAV_...;
}

Hope this helps,

Jean-Luc

-- 
_____________________________________________________________________________

Jean-Luc Dery Discreet Logic System Engineer 5505 boul. St-Laurent, bureau 5200 3-D Graphics Technology Montreal (Quebec), Canada, H2T 1S6 Tel: (514) 272-0525 #394 Email: dery++at++discreet.com Fax: (514) 272-0585 _____________________________________________________________________________ ======================================================================= List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/ Submissions: info-performer++at++sgi.com Admin. requests: info-performer-request++at++sgi.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:55:13 PDT

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