supertux/collision.[ch]pp: Use "contrain_*" rather than "min_*" and "max_*".
authorFlorian Forster <supertux@octo.it>
Mon, 1 Feb 2010 13:28:38 +0000 (13:28 +0000)
committerFlorian Forster <supertux@octo.it>
Mon, 1 Feb 2010 13:28:38 +0000 (13:28 +0000)
See Matt's comments on bug #456.

SVN-Revision: 6304

src/supertux/collision.cpp
src/supertux/collision.hpp
src/supertux/sector.cpp

index 8ac4820..c1a6e18 100644 (file)
@@ -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;
     }
   }
index 14d15b0..01f3317 100644 (file)
@@ -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;
index 611f36d..7e8f470 100644 (file)
@@ -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;
     }
   }