projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added missing time calculation to slopes
[supertux.git]
/
lib
/
special
/
collision.cpp
diff --git
a/lib/special/collision.cpp
b/lib/special/collision.cpp
index
1589a6e
..
d391ce5
100644
(file)
--- a/
lib/special/collision.cpp
+++ b/
lib/special/collision.cpp
@@
-108,11
+108,15
@@
Collision::rectangle_aatriangle(CollisionHit& hit, const Rectangle& rect,
break;
}
break;
}
- float depth = -(normal * p1) - c;
+ float n_p1 = -(normal * p1);
+ float depth = n_p1 - c;
if(depth < 0)
return false;
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.depth = depth;
+ hit.time = time;
hit.normal = normal;
}
hit.normal = normal;
}