diff --git a/collisions.cc b/collisions.cc index 3203099..747ce1e 100644 --- a/collisions.cc +++ b/collisions.cc @@ -43,21 +43,22 @@ static bool separating_axis( max_q = std::max(max_q, projection); } - if (max_p >= min_q && max_q >= min_p) { - double d; - if (max_q - min_p < max_p - min_q) { - d = max_q - min_p; - *impact_point = min_p_point; - } else { - d = max_p - min_q; - *impact_point = max_p_point; - } - // push a bit more than needed so the shapes do not overlap in future - // tests due to float precision - double d_over_o_squared = d / vec2d::dot(axis, axis) + 1e-10; - *pv = d_over_o_squared * axis; - return false; + if (max_p < min_q || max_q < min_p) + return true; + + double d; + if (max_q - min_p < max_p - min_q) { + d = max_q - min_p; + *impact_point = min_p_point; + } else { + d = max_p - min_q; + *impact_point = max_p_point; } + // push a bit more than needed so the shapes do not overlap in + // future tests due to float precision + double d_over_o_squared = d / vec2d::dot(axis, axis) + 1e-10; + *pv = d_over_o_squared * axis; + return false; return true; } diff --git a/game.h b/game.h index 892c843..d41456d 100644 --- a/game.h +++ b/game.h @@ -6,16 +6,16 @@ /* simulation/game framework */ -extern double delta; /* simulation time delta in seconds */ +extern double delta; /* simulation time delta in seconds */ #define DEFAULT_DELTA 0.01 -extern int width; /* game canvas width */ -extern int height; /* game canvas height */ +extern int width; /* game canvas width */ +extern int height; /* game canvas height */ #define DEFAULT_WIDTH 800 #define DEFAULT_HEIGHT 800 -extern GtkWidget * canvas; /* game canvas object */ +extern GtkWidget* canvas; /* game canvas object */ #endif