projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added chinese fonts and translation from Liu Sizhuang <oldherl@gmail.com>
[supertux.git]
/
src
/
collision.cpp
diff --git
a/src/collision.cpp
b/src/collision.cpp
index
6e98940
..
715d02e
100644
(file)
--- a/
src/collision.cpp
+++ b/
src/collision.cpp
@@
-23,9
+23,9
@@
#include <algorithm>
#include <iostream>
#include <algorithm>
#include <iostream>
-#include <
cstdio
>
-#include <
cfloat
>
-#include <
cmat
h>
+#include <
stdio.h
>
+#include <
float.h
>
+#include <
math.
h>
#include "math/vector.hpp"
#include "math/aatriangle.hpp"
#include "math/rect.hpp"
#include "math/vector.hpp"
#include "math/aatriangle.hpp"
#include "math/rect.hpp"
@@
-57,11
+57,10
@@
namespace {
c /= nval;
}
c /= nval;
}
- static const float DELTA = .0001f;
}
bool rectangle_aatriangle(Constraints* constraints, const Rect& rect,
}
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;
{
if(!intersects(rect, (const Rect&) triangle))
return false;
@@
-146,6
+145,7
@@
bool rectangle_aatriangle(Constraints* constraints, const Rect& rect,
if(outvec.y < 0) {
constraints->bottom = rect.get_bottom() + outvec.y;
constraints->hit.bottom = true;
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;
} else {
constraints->top = rect.get_top() + outvec.y;
constraints->hit.top = true;
@@
-157,7
+157,7
@@
bool rectangle_aatriangle(Constraints* constraints, const Rect& rect,
}
void set_rectangle_rectangle_constraints(Constraints* constraints,
}
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();
{
float itop = r1.get_bottom() - r2.get_top();
float ibottom = r2.get_bottom() - r1.get_top();
@@
-170,6
+170,7
@@
void set_rectangle_rectangle_constraints(Constraints* constraints,
if(itop < ibottom) {
constraints->bottom = std::min(constraints->bottom, r2.get_top());
constraints->hit.bottom = true;
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;
} else {
constraints->top = std::max(constraints->top, r2.get_bottom());
constraints->hit.top = true;