X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fcollision.cpp;h=6ff22952bf3c6015d3881ed2b58f64a9c5741a23;hb=9355ee0bb2a3cee71f3f9216c937da587f475f61;hp=e9c25fb3866a53f966291da4ba1e1895650fd483;hpb=a113d3bd1feddd510e3b2852b0d42522735eee40;p=supertux.git diff --git a/src/collision.cpp b/src/collision.cpp index e9c25fb38..6ff22952b 100644 --- a/src/collision.cpp +++ b/src/collision.cpp @@ -57,11 +57,11 @@ namespace { 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; @@ -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,6 +146,7 @@ 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; @@ -157,7 +158,7 @@ bool rectangle_aatriangle(Constraints* constraints, const Rect& rect, } 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;