a few more opengles changes
[supertux.git] / src / collision.cpp
index 8ae5e91..6ff2295 100644 (file)
@@ -52,16 +52,16 @@ namespace {
   {
     n = Vector(p2.y-p1.y, p1.x-p2.x);
     c = -(p2 * n);
-    float nval = n.norm();             
+    float nval = n.norm();
     n /= nval;
     c /= nval;
   }
 
-  static const float DELTA = .0001;
+  static const float DELTA = .0001f;
 }
 
 bool rectangle_aatriangle(Constraints* constraints, const Rect& rect,
-    const AATriangle& triangle)
+    const AATriangle& triangle, const Vector& addl_ground_movement)
 {
   if(!intersects(rect, (const Rect&) triangle))
     return false;
@@ -93,8 +93,8 @@ bool rectangle_aatriangle(Constraints* constraints, const Rect& rect,
       break;
     default:
       assert(false);
-  } 
-  
+  }
+
   switch(triangle.dir & AATriangle::DIRECTION_MASK) {
     case AATriangle::SOUTHWEST:
       p1 = Vector(rect.p1.x, rect.p2.y);
@@ -128,7 +128,7 @@ bool rectangle_aatriangle(Constraints* constraints, const Rect& rect,
   std::cout << "Norm: " << normal << " Depth: " << depth << "\n";
 #endif
 
-  Vector outvec = normal * (depth + 0.2);
+  Vector outvec = normal * (depth + 0.2f);
 
   const float RDELTA = 3;
   if(p1.x < area.p1.x - RDELTA || p1.x > area.p2.x + RDELTA
@@ -146,18 +146,19 @@ bool rectangle_aatriangle(Constraints* constraints, const Rect& rect,
     if(outvec.y < 0) {
       constraints->bottom = rect.get_bottom() + outvec.y;
       constraints->hit.bottom = true;
+      constraints->ground_movement += addl_ground_movement;
     } else {
       constraints->top = rect.get_top() + outvec.y;
       constraints->hit.top = true;
     }
     constraints->hit.slope_normal = normal;
   }
-  
+
   return true;
 }
 
 void set_rectangle_rectangle_constraints(Constraints* constraints,
-        const Rect& r1, const Rect& r2)
+        const Rect& r1, const Rect& r2, const Vector& addl_ground_movement)
 {
   float itop = r1.get_bottom() - r2.get_top();
   float ibottom = r2.get_bottom() - r1.get_top();
@@ -170,6 +171,7 @@ void set_rectangle_rectangle_constraints(Constraints* constraints,
     if(itop < ibottom) {
       constraints->bottom = std::min(constraints->bottom, r2.get_top());
       constraints->hit.bottom = true;
+      constraints->ground_movement += addl_ground_movement;
     } else {
       constraints->top = std::max(constraints->top, r2.get_bottom());
       constraints->hit.top = true;