X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fcollision.hpp;h=a31878c88e8553dd808796598401d49b7005c093;hb=c75799590ba936c673bea467b65518c3c2c2e284;hp=cc5bcd0cc32dfa6f81d94bd2535b03b48adc33f6;hpb=2892ebda09d24c977547159e34abf0244884b89e;p=supertux.git diff --git a/src/collision.hpp b/src/collision.hpp index cc5bcd0cc..a31878c88 100644 --- a/src/collision.hpp +++ b/src/collision.hpp @@ -22,6 +22,7 @@ #include #include "collision_hit.hpp" +#include class Vector; class Rect; @@ -34,15 +35,17 @@ class Constraints { public: Constraints() { - left = -INFINITY; - right = INFINITY; - top = -INFINITY; - bottom = INFINITY; + float infinity = (std::numeric_limits::has_infinity ? std::numeric_limits::infinity() : std::numeric_limits::max()); + left = -infinity; + right = infinity; + top = -infinity; + bottom = infinity; } bool has_constraints() const { - return left > -INFINITY || right < INFINITY - || top > -INFINITY || bottom < INFINITY; + float infinity = (std::numeric_limits::has_infinity ? std::numeric_limits::infinity() : std::numeric_limits::max()); + return left > -infinity || right < infinity + || top > -infinity || bottom < infinity; } float left; @@ -55,17 +58,16 @@ public: /** checks if 2 rectangle intersect each other */ bool intersects(const Rect& r1, const Rect& r2); - + /** does collision detection between a rectangle and an axis aligned triangle * Returns true in case of a collision and fills in the hit structure then. - */ + */ bool rectangle_aatriangle(Constraints* constraints, const Rect& rect, - const AATriangle& triangle); + const AATriangle& triangle, const Vector& addl_ground_movement = Vector(0,0)); void set_rectangle_rectangle_constraints(Constraints* constraints, - const Rect& r1, const Rect& r2); + const Rect& r1, const Rect& r2, const Vector& addl_ground_movement = Vector(0,0)); } #endif -