X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=lib%2Fspecial%2Fcollision.cpp;h=d391ce581428c0d28468b2b39e6dec474e03d081;hb=036093249d30159bdbca628a8c12dad390d938fd;hp=1589a6e4712b4a63e4f144fdf4fe8d02003d9cc9;hpb=e4d4375bf4b6802321d956f5f3886320b7275cf0;p=supertux.git diff --git a/lib/special/collision.cpp b/lib/special/collision.cpp index 1589a6e47..d391ce581 100644 --- a/lib/special/collision.cpp +++ b/lib/special/collision.cpp @@ -108,11 +108,15 @@ Collision::rectangle_aatriangle(CollisionHit& hit, const Rectangle& rect, break; } - float depth = -(normal * p1) - c; + float n_p1 = -(normal * p1); + float depth = n_p1 - c; if(depth < 0) return false; - if(depth < hit.depth) { + float time = depth / -(normal * movement); + if(time < hit.time) { + printf("Time: %f.\n", time); hit.depth = depth; + hit.time = time; hit.normal = normal; }