I have a static callback function like so:
void Coin3dScene::flythruCB(void *data, SoSensor *s)
{
MyFlythruData *locData = (MyFlythruData *)data;
//etc...
}
void Coin3dScene::flythruCB(void *data, SoSensor *s)
{
MyFlythruData *locData = (MyFlythruData *)data;
//etc...
}
To copy to clipboard, switch view to plain text mode
The "data" I pass to the function is a struct that references variables I need to access in the callback:
typedef struct
{
float *flyTimeLen;
bool *flyLoop;
} MyFlythruData;
typedef struct
{
float *flyTimeLen;
bool *flyLoop;
} MyFlythruData;
To copy to clipboard, switch view to plain text mode
set-up like so:
MyFlythruData *myflydata = new MyFlyData;
myflydata->flyTimeLen = &FlyTime;
myflydata->flyLoop = &FlyLoop;
MyFlythruData *myflydata = new MyFlyData;
myflydata->flyTimeLen = &FlyTime;
myflydata->flyLoop = &FlyLoop;
To copy to clipboard, switch view to plain text mode
My question: is it necessary to use pointers in the struct as I've done? The callback function is called 50 times/second; by passing pointers to variables rather than the variable itself, the function should operate more smoothly with less overhead, right?
But on the other hand, since the callback receives a pointer to data rather than just "data"... it's unnecesary to use pointers for the variables inside the struct... if I don't otherwise need to. right?
Bookmarks