cpVect cpArbiterGetNormal(cpArbiter *arb, int i)Returns the collision normal for the i’th contact point, flipping it if necessary. Note: Currently due to how Chipmunk’s collision detection is implemented, the collision normals will be the same for all collision points. You can simply do cpArbiterGetNormal(arb, 0) and not have to check each contact point. Note: calling this function from the separate() callback is undefined.
This source snippet let use the cpArbiterGetNormal() on seperate() callback too. (Maybe another return value if the arb->contact = 0 is needed)
Code: Select all
static inline cpVect
cpArbiterGetNormal(const cpArbiter *arb, int i)
{
if ( arb->contacts )
{
cpVect n = arb->CP_PRIVATE(contacts)[i].CP_PRIVATE(n);
return arb->CP_PRIVATE(swappedColl) ? cpvneg(n) : n;
}
return cpv(-9999.9999f,-9999.9999f);
}