404 |
rebounds from any one (or even both) corners, because it changes |
rebounds from any one (or even both) corners, because it changes |
405 |
the direction of the marble quite unpredictably. |
the direction of the marble quite unpredictably. |
406 |
|
|
407 |
This function modified the contact information for two adjacent |
This function modifies the contact information for two adjacent |
408 |
stones in such a way that the two collisions are treated as a |
stones in such a way that the two collisions are treated as a |
409 |
single collision with a flat surface. |
single collision with a flat surface. |
410 |
*/ |
*/ |
414 |
double maxd = 4.0/32; // Max distance between joinable collisions |
double maxd = 4.0/32; // Max distance between joinable collisions |
415 |
|
|
416 |
if (a.stone && b.stone && (a.is_contact || b.is_contact) && |
if (a.stone && b.stone && (a.is_contact || b.is_contact) && |
417 |
|
a.is_collision && b.is_collision && |
418 |
a.response==STONE_REBOUND && b.response==STONE_REBOUND) // && |
a.response==STONE_REBOUND && b.response==STONE_REBOUND) // && |
419 |
// length(a.contact_point - b.contact_point) <= maxd) |
// length(a.contact_point - b.contact_point) <= maxd) |
420 |
{ |
{ |
445 |
{ |
{ |
446 |
ActorInfo &ai = *a->get_actorinfo(); |
ActorInfo &ai = *a->get_actorinfo(); |
447 |
px::Rect r(int(ai.pos[0]-0.5), int(ai.pos[1]-0.5), |
px::Rect r(int(ai.pos[0]-0.5), int(ai.pos[1]-0.5), |
448 |
int(ai.pos[0]+0.5), int(ai.pos[1]+0.5)); |
int(ai.pos[0]+0.5), int(ai.pos[1]+0.5)); |
449 |
r.w -= r.x; |
r.w -= r.x; |
450 |
r.h -= r.y; |
r.h -= r.y; |
451 |
|
|
452 |
StoneContact contacts[2][2]; |
StoneContact contacts[2][2]; |
453 |
|
|
454 |
// Test for collisions with the nearby stones |
// Test for collisions with the nearby stones |
455 |
for (int i=0; i<=r.w; i++) { |
for (int i=0; i<=r.w; i++) |
456 |
for (int j=0; j<=r.h; j++) { |
for (int j=0; j<=r.h; j++) |
457 |
find_contact_with_stone(a, contacts[i][j], r.x+i, r.y+j); |
find_contact_with_stone(a, contacts[i][j], r.x+i, r.y+j); |
458 |
} |
|
|
} |
|
|
#if 1 |
|
459 |
maybe_join_contacts (contacts[0][0], contacts[1][0]); |
maybe_join_contacts (contacts[0][0], contacts[1][0]); |
460 |
maybe_join_contacts (contacts[0][0], contacts[0][1]); |
maybe_join_contacts (contacts[0][0], contacts[0][1]); |
461 |
maybe_join_contacts (contacts[1][0], contacts[1][1]); |
maybe_join_contacts (contacts[1][0], contacts[1][1]); |
462 |
maybe_join_contacts (contacts[0][1], contacts[1][1]); |
maybe_join_contacts (contacts[0][1], contacts[1][1]); |
463 |
#endif |
|
464 |
for (int i=0; i<=r.w; i++) { |
for (int i=0; i<=r.w; i++) |
465 |
for (int j=0; j<=r.h; j++) { |
for (int j=0; j<=r.h; j++) |
466 |
if (contacts[i][j].is_contact) |
if (contacts[i][j].is_contact) |
467 |
cl.push_back(contacts[i][j]); |
cl.push_back(contacts[i][j]); |
|
} |
|
|
} |
|
468 |
} |
} |
469 |
|
|
470 |
static V3 |
static V3 |