--- a/src/proto2/Config.hh Mon Dec 01 12:14:39 2008 +0000
+++ b/src/proto2/Config.hh Mon Dec 01 15:33:49 2008 +0000
@@ -19,7 +19,7 @@
// Constants affecting physics
const float MAP_GRAVITY = 1200.0;
-const float COLLISION_ELASTICITY = 0.7; // TODO: This could be
+const float COLLISION_ELASTICITY = 0.3; // TODO: This could be
// different for different
// objects
--- a/src/proto2/Physics.cc Mon Dec 01 12:14:39 2008 +0000
+++ b/src/proto2/Physics.cc Mon Dec 01 15:33:49 2008 +0000
@@ -246,7 +246,7 @@
//TODO: it shouldn't just stop on collision
}
this->position = newPosition;
- Engine::log(DEBUG, "PhysicsObject.updatePosition") << "Pos: " << this->position;
+// Engine::log(DEBUG, "PhysicsObject.updatePosition") << "Pos: " << this->position;
}
/**
--- a/src/proto2/Terrain.cc Mon Dec 01 12:14:39 2008 +0000
+++ b/src/proto2/Terrain.cc Mon Dec 01 15:33:49 2008 +0000
@@ -133,7 +133,8 @@
* Gets the index of the given coordinate direction
* referring to the DIRECTIONS table in Physics.hh
*/
-int getDirectionIndex (Vector dir) {
+int getDirectionIndex (Vector direction) {
+ Vector dir = direction.roundToInt();
if(dir.x == 0 && dir.y == -1) {
return 0;
} else if(dir.x == 1 && dir.y == -1) {
@@ -151,7 +152,7 @@
} else if(dir.x == -1 && dir.y == -1) {
return 7;
}
- Engine::log(DEBUG, "physics.getDirectionIndex ") << "invalid direction: " << dir;
+ Engine::log(DEBUG, "Terrain.getDirectionIndex ") << "invalid direction: " << direction;
return 0;
}
@@ -163,9 +164,15 @@
Vector Terrain::getNormal(Vector point, Vector prevPoint) const {
Vector p = getPixelLocation(point);
+ assert(point != prevPoint);
+
Vector normal(0,0);
+ // These two must be rounded separately
int dirIdx = getDirectionIndex(prevPoint.roundToInt() - point.roundToInt());
+// dirIdx = (dirIdx+4)%8;
+
+ std::cout << (prevPoint.roundToInt()) - (point.roundToInt()) << prevPoint-point << std::endl;
normal += DIRECTIONS[dirIdx];
for(int i = 1; i <= 2; i++) {
@@ -178,6 +185,12 @@
normal += DIRECTIONS[(dirIdx-i+8)%8];
}
}
+
+ Engine::log(DEBUG, "Physics.getNormal ") << "normal: " << normal << " dirIdx: " << dirIdx;
+
+ if(getType(point) == EMPTY || getType(prevPoint) != EMPTY) {
+ Engine::log(DEBUG, "Physics.getNormal ") << "logic ground error";
+ }
// for (int i = 0; i < 8; i++) {
--- a/src/proto2/Vector.hh Mon Dec 01 12:14:39 2008 +0000
+++ b/src/proto2/Vector.hh Mon Dec 01 15:33:49 2008 +0000
@@ -71,7 +71,7 @@
return sqrt((this->x * this->x) + (this->y * this->y));
}
_Vector roundToInt() const {
- return _Vector(round(x), round(y));
+ return _Vector((int)(x), (int)(y));
}
};