userData in discriminator callbacks (again)

New Message Reply Date view Thread view Subject view Author view

Randall Barker (barker++at++kahuna.cs.nps.navy.mil)
Tue, 25 Jul 1995 09:14:16 -0700


Here is what was said previously on info-performer:

> ->Is there a way to pass user data to a discriminator funtion? I'm using
> ->pfSegsIsectNode() which has a userData pointer in the pfSegSet structure
> ->but no way that I can tell to retrieve it from the discFunc. Is there
> ->another way? I'm using performer 1.2. Thanks!
>
> You get a pointer to a pfHit structure in your discriminator function and
> it's userData field should have the user data passed in
> with your SegSet.
>
> src.
>
> --
> -----{-----{---++at++ -----{----{---++at++ -----{----{---++at++ -----{----{---++at++
> Sharon Rose Clay (Fischler) - Silicon Graphics, Advanced Graphics Dev.
> src++at++sgi.com (415) 390 - 1002 FAX: (415) 965 - 2658 MS 8U-590
> -----{-----{---++at++ -----{----{---++at++ -----{----{---++at++ -----{----{---++at++
>

What I would like to know is if some one has done what is described above.
I spent most of yesterday trying to get it to work, however, when I
use pfGetUserData on the pfHit structure in the call back, it returns a
NULL pointer. Once again, here is the relevant code segments:

...
  live_veh = (int *)pfMalloc(sizeof(int),pfGetSharedArena());
   (*live_veh) = -1;
   the_aim.userData = (void *)live_veh;
   //pfUserData ( &the_aim, (void *)live_veh);
   the_aim.mode = PFTRAV_IS_GEODE;
   the_aim.activeMask = 0x01; // 0x1F;
   the_aim.isectMask = ENTITY_MASK;
   the_aim.bound = NULL; // &the_barrel;
   the_aim.discFunc = target_lock;

   if ( (pfSegsIsectNode(G_moving, &the_aim, aim_hits)) > 0 ) {
      cout << "The aim live_veh: " << (*(int *)(the_aim.userData))<< endl;
      live_veh = (int *)pfGetUserData(aim_hits);
      cout << (*live_veh) << endl;
      G_vehlist[G_dynamic_data->target].vehptr->bbox(TRUE);
      return TRUE;
   }
   else {
      return FALSE;
   }
...

/**************************************************************************/

long target_lock (pfHit *result)
{
   long target_mask;
   pfHit *temp;
   int *live_veh;
   temp = result;

#ifdef DATALOCK
   pfDPoolLock ( (void *) G_dynamic_data );
#endif
   
   live_veh = (int *)((pfHit *)result->userData);
   if (live_veh != NULL) {
      cout << "Live veh: " << (*live_veh) << endl;
      (*live_veh) = L_veh_node;
      pfUserData(result,(void *)live_veh);
   }
   else {
     cout << "NULL pointer." << endl;
   }
...

Sorry to clutter everyones mailbox with this, but I am stumped.

-rb

--
Randall E. Barker
Naval Postgraduate School               e-mail: barker++at++cs.nps.navy.mil
Computer Science, Code CS/Barker        Phone:  408.656.2251
Monterey, California 93943
Spanagel Hall, Room 525

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:51:42 PDT

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