2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef HEADER_SUPERTUX_SUPERTUX_COLLISION_HPP
18 #define HEADER_SUPERTUX_SUPERTUX_COLLISION_HPP
20 #include "supertux/collision_hit.hpp"
33 float infinity = (std::numeric_limits<float>::has_infinity ?
34 std::numeric_limits<float>::infinity() :
35 std::numeric_limits<float>::max());
42 bool has_constraints() const {
43 float infinity = (std::numeric_limits<float>::has_infinity ?
44 std::numeric_limits<float>::infinity() :
45 std::numeric_limits<float>::max());
46 return left > -infinity || right < infinity
47 || top > -infinity || bottom < infinity;
54 Vector ground_movement;
58 /** checks if 2 rectangle intersect each other */
59 bool intersects(const Rect& r1, const Rect& r2);
61 /** does collision detection between a rectangle and an axis aligned triangle
62 * Returns true in case of a collision and fills in the hit structure then.
64 bool rectangle_aatriangle(Constraints* constraints, const Rect& rect,
65 const AATriangle& triangle, const Vector& addl_ground_movement = Vector(0,0));
67 void set_rectangle_rectangle_constraints(Constraints* constraints,
68 const Rect& r1, const Rect& r2, const Vector& addl_ground_movement = Vector(0,0));
70 } // namespace collision