FleX
FleX copied to clipboard
Multiple callbacks for same stage
I'd like to register two solver callbacks at update end, but it seems that the second callback deletes the first one. Is it not possible to use multiple callbacks at the same stage?
Sorry, no, you can only register one callback per-stage. But of course your callback can call the functions itself.
Cheers, Miles
Thanks Miles.
I managed to solve it by chaining the calls using the data returned by NvFlexRegisterSolverCallback
.
It works if there's a callback registered before mine, but I'm not sure how to detect if there's no callback. What does NvFlexRegisterSolverCallback
returns then? I was expecting that NvFlexSolverCallback
userData
and/or function
is NULL
, but it does not seem to work.
void NvFlexSetMyForces( NvFlexMyCallback *c, ... )
{
...
NvFlexSolverCallback callback;
callback.function = applyMyCallback;
callback.userData = c;
c->mPreviousCallback = NvFlexRegisterSolverCallback( c->mSolver, callback,
eNvFlexStageUpdateEnd );
}
void applyMyCallback( NvFlexSolverCallbackParams params )
{
NvFlexMyCallback *c = (NvFlexMyCallback *)params.userData;
...
if ( c->mPreviousCallback.function != NULL )
{
params.userData = c->mPreviousCallback.userData;
c->mPreviousCallback.function( params );
}
}