Re: userData in Discriminator callback
Randall Barker (barker++at++kahuna.cs.nps.navy.mil)
Mon, 24 Jul 1995 17:25:53 -0700 (PDT)
> I'm not sure if you mean user data or callback data.
> If your multiprocessing, be sure to allocate the callback
> data from an arena. Otherwise, there are no special tricks
> I'm aware of. The following example uses both:
>
> >From APP:
>
> node_data = (Node_Data*)pfMalloc(sizeof(Node_Data), pfGetSharedArena());
> if (!node_data)
> return 0;
> pfNodeTravFuncs(pfgroup, PFTRAV_CULL, pre_node_cull, NULL);
> pfNodeTravData(pfgroup, PFTRAV_CULL, (void*)node_data);
> pfUserData(pfgroup, node_data);
>
>
> Also from APP:
>
> node_data = (Node_Data*)pfGetUserData(pfnode);
> if (pfSphereIsectFrust(&pfsphere, eschannel->pfchan) == PFIS_FALSE)
> {
> culled = 1;
> return;
> }
> node_data->culled = 0;
>
>
> >From CULL:
>
> long pre_node_cull(pfTraverser *trav, void *data)
> {
> trav = trav; // Suppress compiler warning
>
> if ( ((unsigned char*)data)[0] )
> {
> pfCullResult(PFIS_MAYBE | PFIS_TRUE | PFIS_ALL_IN);
> return PFTRAV_CONT;
> }
>
> pfCullResult(PFIS_FALSE);
> return PFTRAV_PRUNE;
> }
>
>
I guess I could have been a little more verbose. I am allocating
from an arena, and I am trying to pass this into the pfSegsIsectNode
discriminator callback as follows:
live_veh = (int *)pfMalloc(sizeof(int),pfGetSharedArena());
(*live_veh) = -1;
the_aim.userData = (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;
return TRUE;
}
However, when pfGetUserData is invoked in target_lock, the discrimnator
call back, it returns a NULL pointer.
This archive was generated by hypermail 2.0b2
on Mon Aug 10 1998 - 17:51:42 PDT