|
|
|
@ -296,6 +296,22 @@ bool sat_collision_check(Body *one, Body *two, Vect *translation) {
@@ -296,6 +296,22 @@ bool sat_collision_check(Body *one, Body *two, Vect *translation) {
|
|
|
|
|
double left = proj_one[1] < proj_two[1] ? proj_one[1] : proj_two[1]; |
|
|
|
|
double right = proj_one[0] > proj_two[0] ? proj_one[0] : proj_two[0]; |
|
|
|
|
overlap = left - right; |
|
|
|
|
|
|
|
|
|
// one of the shapes is contained
|
|
|
|
|
if ((overlap > (proj_one[1] - proj_one[0]) |
|
|
|
|
|| (overlap > (proj_two[1] - proj_two[0])))) { |
|
|
|
|
printf("COntained"); |
|
|
|
|
|
|
|
|
|
double min = proj_one[0] - proj_two[0]; |
|
|
|
|
double max = proj_one[1] - proj_two[1]; |
|
|
|
|
|
|
|
|
|
min = min < 0 ? -min : min; |
|
|
|
|
max = max < 0 ? -max : max; |
|
|
|
|
|
|
|
|
|
overlap += min < max ? min : max; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
printf("OVERLAP : %e\n", overlap); |
|
|
|
|
if (overlap < min_overlap && overlap > 0) { |
|
|
|
|
min_overlap = overlap; |
|
|
|
@ -501,7 +517,7 @@ int process_collisions(Body *thing, Vect *trans) {
@@ -501,7 +517,7 @@ int process_collisions(Body *thing, Vect *trans) {
|
|
|
|
|
} else if (world[k].kind == FLOOR) { |
|
|
|
|
for (int i = 0; i < world[k].floor->numPolys; i++) { |
|
|
|
|
if ((world[k].floor->polys[i].physics->position.x - viewport_pos.x) > (2 *width)
|
|
|
|
|
|| (world[k].floor->polys[i].physics->position.x - viewport_pos.x) < 0) {
|
|
|
|
|
|| (world[k].floor->polys[i].physics->position.x - viewport_pos.x) < -width) {
|
|
|
|
|
continue; |
|
|
|
|
} else { |
|
|
|
|
num++; |
|
|
|
@ -586,7 +602,6 @@ void advance_thing(Body * thing) {
@@ -586,7 +602,6 @@ void advance_thing(Body * thing) {
|
|
|
|
|
/*rest.y = sin(vect_dir(translation)) * impulse;*/ |
|
|
|
|
/*accel_thing(thing, rest.x, rest.y);*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint32_t now = SDL_GetTicks(); |
|
|
|
|