From 7d5ac7d42f73d3fd6b60cf87534656ed80a52de3 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 1 Feb 2010 13:28:38 +0000 Subject: [PATCH] supertux/collision.[ch]pp: Use "contrain_*" rather than "min_*" and "max_*". See Matt's comments on bug #456. SVN-Revision: 6304 --- src/supertux/collision.cpp | 16 ++++++++-------- src/supertux/collision.hpp | 8 ++++---- src/supertux/sector.cpp | 16 ++++++++-------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/supertux/collision.cpp b/src/supertux/collision.cpp index 8ac482057..c1a6e1822 100644 --- a/src/supertux/collision.cpp +++ b/src/supertux/collision.cpp @@ -123,17 +123,17 @@ bool rectangle_aatriangle(Constraints* constraints, const Rectf& rect, set_rectangle_rectangle_constraints(constraints, rect, area); } else { if(outvec.x < 0) { - constraints->min_right(rect.get_right() + outvec.x); + constraints->constrain_right(rect.get_right() + outvec.x); } else { - constraints->max_left(rect.get_left() + outvec.x); + constraints->constrain_left(rect.get_left() + outvec.x); } if(outvec.y < 0) { - constraints->min_bottom(rect.get_bottom() + outvec.y); + constraints->constrain_bottom(rect.get_bottom() + outvec.y); constraints->hit.bottom = true; constraints->ground_movement += addl_ground_movement; } else { - constraints->max_top(rect.get_top() + outvec.y); + constraints->constrain_top(rect.get_top() + outvec.y); constraints->hit.top = true; } constraints->hit.slope_normal = normal; @@ -154,19 +154,19 @@ void set_rectangle_rectangle_constraints(Constraints* constraints, float horiz_penetration = std::min(ileft, iright); if(vert_penetration < horiz_penetration) { if(itop < ibottom) { - constraints->min_bottom(r2.get_top()); + constraints->constrain_bottom(r2.get_top()); constraints->hit.bottom = true; constraints->ground_movement += addl_ground_movement; } else { - constraints->max_top(r2.get_bottom()); + constraints->constrain_top(r2.get_bottom()); constraints->hit.top = true; } } else { if(ileft < iright) { - constraints->min_right(r2.get_left()); + constraints->constrain_right(r2.get_left()); constraints->hit.right = true; } else { - constraints->max_left(r2.get_right()); + constraints->constrain_left(r2.get_right()); constraints->hit.left = true; } } diff --git a/src/supertux/collision.hpp b/src/supertux/collision.hpp index 14d15b0dc..01f3317c8 100644 --- a/src/supertux/collision.hpp +++ b/src/supertux/collision.hpp @@ -65,10 +65,10 @@ public: float top; float bottom; - void max_left (float left2 ) { left = std::max(left , left2 ); } - void min_right (float right2 ) { right = std::min(right , right2 ); } - void max_top (float top2 ) { top = std::max(top , top2 ); } - void min_bottom(float bottom2) { bottom = std::min(bottom, bottom2); } + void constrain_left (float left2 ) { left = std::max(left , left2 ); } + void constrain_right (float right2 ) { right = std::min(right , right2 ); } + void constrain_top (float top2 ) { top = std::max(top , top2 ); } + void constrain_bottom(float bottom2) { bottom = std::min(bottom, bottom2); } Vector ground_movement; CollisionHit hit; diff --git a/src/supertux/sector.cpp b/src/supertux/sector.cpp index 611f36d86..7e8f4700b 100644 --- a/src/supertux/sector.cpp +++ b/src/supertux/sector.cpp @@ -907,19 +907,19 @@ void check_collisions(collision::Constraints* constraints, if(fabsf(movement.y) > fabsf(movement.x)) { if(ileft < SHIFT_DELTA) { - constraints->min_right(r2.get_left()); + constraints->constrain_right(r2.get_left()); return; } else if(iright < SHIFT_DELTA) { - constraints->max_left(r2.get_right()); + constraints->constrain_left(r2.get_right()); return; } } else { // shiftout bottom/top if(itop < SHIFT_DELTA) { - constraints->min_bottom(r2.get_top()); + constraints->constrain_bottom(r2.get_top()); return; } else if(ibottom < SHIFT_DELTA) { - constraints->max_top(r2.get_bottom()); + constraints->constrain_top(r2.get_bottom()); return; } } @@ -940,18 +940,18 @@ void check_collisions(collision::Constraints* constraints, float horiz_penetration = std::min(ileft, iright); if(vert_penetration < horiz_penetration) { if(itop < ibottom) { - constraints->min_bottom(r2.get_top()); + constraints->constrain_bottom(r2.get_top()); constraints->hit.bottom = true; } else { - constraints->max_top(r2.get_bottom()); + constraints->constrain_top(r2.get_bottom()); constraints->hit.top = true; } } else { if(ileft < iright) { - constraints->min_right(r2.get_left()); + constraints->constrain_right(r2.get_left()); constraints->hit.right = true; } else { - constraints->max_left(r2.get_right()); + constraints->constrain_left(r2.get_right()); constraints->hit.left = true; } } -- 2.11.0