Question about tasks

Hello,
i am trying to use a task to check for collisions but it seems i am not doing it right. I wrote the task this way

AsyncTask::DoneStatus TravCol( GenericAsyncTask* task, CollisionTraverser traverser, WindowFramework* &window, void* data )
{
	traverser.traverse( window->get_render() );
	return AsyncTask::DS_cont;
}

and call it like this

task3 = new GenericAsyncTask( "TravCol", &TravCol( [what to write here ?], traverser, window, (void*) NULL ), (void*) NULL );
	taskMgr->add(task3);

.
And i don’t know what to write for the first argument of type GenericAsyncTask for TravCol. As i saw in the manual, it could be deffined just like that

task3 = new GenericAsyncTask("TravCol", &TravCol, (void*) NULL);

but that is valid only if i am not using additional arguments(as far as i uderstand it). But when i put additional arguments i have to supply a GenericAsyncTask type and it has to be a static one, which i didn’t find in the reference list for those type tasks(GenericAsyncTask). And at the moment i am confused about what to do. I would appreciate if someone could give me a tip what to do in this situation.

You don’t supply additional arguments, since you’re not calling the function in the GenericAsyncTask constructor, you’re only making passing a reference to the function to Panda so that Panda can call it later.

To do this, though, Panda uses a fixed function prototype that you must adhere to. So, you must remove the CollisionTraverser and WindowFramework arguments, and instead store them in some sort of struct that you pass a pointer to through the extra “void* data” argument.

There are several mistakes in your code, and function pointers are not an uncommon C++ feature. I would advise you to get better acquainted with C++ before you try and use it with Panda3D, or you’ll run into these types of issues again and again.

Thank you for the reply.
I’ll do my best to polish my C++ skills. About the task function i made it work, i defined CollisionTraverser traverser and WindowFramework* window as global “variables” and wrote the task func like this

AsyncTask:: DoneStatus TravCol( GenericAsyncTask* task, void* data )
{
	traverser.traverse( window->get_render() );
	if( queue->get_num_entries() == 1 )
	{
		pandaPace->pause();
	}
	return AsyncTask::DS_cont;
}