Need help on a Trigger class and Contact callbacks

User avatar
lazalong
Posts: 10
Joined: Fri Mar 06, 2009 6:55 am
Location: Australia - Canberra

Need help on a Trigger class and Contact callbacks

Post by lazalong »

Hello

1) I have some difficulties to implement correctly a Trigger class were callbacks are called when entering a zone, leaving or being inside it.

Do someone have such a generalised Trigger class that he can share or point to?

The documentation on trigger and callbacks seems to suggest to use only GhostObjects for trigger. Am I right?


2) Also can Contact callbacks (gContactAddedCallback, ...) be set at the Object level?
If not does it mean you need to keep a list of all objects in your code and use a big switch ?

Code: Select all

static bool CustomContactAddedCallback(btManifoldPoint& cp,	const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
{
    if (colObj0 == trigger1)
        trigger1->callback( colObj1 );
    else if (colObj1 == trigger1)
        trigger1->callback( colObjO );
    else if (colObj0 == trigger2)
        trigger2->callback( colObj1 );
    else if (colObj1 == trigger2)
        trigger2->callback( colObjO );
    else if (colObj0 == trigger3)
        trigger3->callback( colObj1 );
    etc
    
    return false;
}
I must be missing something because this seems totally dumb for me.

Thanks for any help