I do not hurry you, just want to know: I continue to write under the current version of the procedure, or should wait for a new one.
"Tell me what you are missing..."
Without some procedures you can do if you know the description of the structures .But when some have additional parameters, it is not clear that there sent. I wanted to try a code, taken from the forum and could not implement it for lack of commands and mismatches.
Code:
// velocity of the two surfaces in relation to the collision normal at the collision point
static inline cpFloat
hit_velocity(cpBody *a, cpBody *b, cpVect p, cpVect n){
cpVect r1 = cpvsub(p, a->p);
cpVect r2 = cpvsub(p, b->p);
cpVect v1_sum = cpvadd(a->v, cpvmult(cpvperp(r1), a->w));
cpVect v2_sum = cpvadd(b->v, cpvmult(cpvperp(r2), b->w));
return cpvdot(cpvsub(v2_sum, v1_sum), n);
}
// This is a pre-solve callback
static bool
bumpSoundCallback(cpArbiter *arb, cpSpace *space, void *unused)
{
cpShape *a, *b; cpArbiterGetShapes(arb, &a, &b);
cpContact *contacts = arb->contacts;
const cpFloat min = 10.0f;
const cpFloat max = 300.0f;
cpFloat nspeed = cpfabs(hit_velocity(a->body, b->body, contacts[0].p, contacts[0].n));
if(nspeed > min){
ALfloat volume = fmax(fminf((nspeed - min)/(max - min), 1.0f), 0.0f);
playSound(bumpSound, volume, 1.0f);
}
return TRUE;
}
Here
cpvsub, cpvmult - need 3 parameters instead of 2. What are they?