--- a/src/proto2/Physics.cc Sun Nov 23 18:19:53 2008 +0000
+++ b/src/proto2/Physics.cc Mon Nov 24 15:18:55 2008 +0000
@@ -168,13 +168,13 @@
//Engine::log(DEBUG, "physics.update_position") << unitVector-newPosition;
//Vector foo = position+unitVector*steps-newPosition;
//Engine::log(DEBUG, "PhysicsObject.updatePosition") << "Virhe: "<< foo;
-
+
for(int i = 0; i < steps; i++) {
tmpVector += unitVector;
float minVelocity = 10;
// Check if any of the four corners of the worm collide
- if(velocity.y > 0) {
+ /*if(velocity.y > 0) {
if(world.getType(tmpVector+shape[2])) {
reached = position + unitVector*(i-1);
collided = true;
@@ -224,28 +224,29 @@
}
break;
}
- }
+ }*/
// This col. det. doesn't let worms inside the ground, but on the other hand the worms get often stuck
- /*if(world.getType(tmpVector+shape[0]) != EMPTY || (world.getType(tmpVector+shape[2]))) {
+ if(world.getType(tmpVector+shape[0]) != EMPTY || (world.getType(tmpVector+shape[2]) != EMPTY)) {
reached = position + unitVector*(i-1);
collided = true;
this->velocity.y *= -0.3;
- if(this->velocity.x < 3 && (this->velocity.y < 3)) {
+ if(abs(this->velocity.x) < minVelocity && (abs(this->velocity.y) < minVelocity)) {
this->inAir = false;
this->velocity = Vector(0,0);
}
break;
- } else if(world.getType(tmpVector+shape[1]) != EMPTY || (world.getType(tmpVector+shape[3]))) {
+ }
+ if(world.getType(tmpVector+shape[1]) != EMPTY || (world.getType(tmpVector+shape[3]) != EMPTY)) {
reached = position + unitVector*(i-1);
collided = true;
this->velocity.x *= -0.6;
- if(this->velocity.x < 3 && (this->velocity.y < 3)) {
+ if(abs(this->velocity.x) < minVelocity && (abs(this->velocity.y) < minVelocity)) {
this->inAir = false;
this->velocity = Vector(0,0);
}
break;
- }*/
+ }
//Engine::log(DEBUG, "physics.update_position") << "didnt hit";
}
@@ -269,6 +270,18 @@
this->position = newPosition;
}
+/*
+int getDirectionIndex (Vector dir) {
+ int index = 0;
+ if(dir.x < -0.1 || (dir.y > 0.1 && dir.x < 0.1))
+ index += 4;
+ if((dir.x > 0.1 && dir.y
+}
+
+Vector PhysicsWorld::getNormal (Vector hitPoint, Vector prevPoint) {
+ // Search free points with bfs and put them to vector
+ std::vector<Vector> frees;
+*/
/*bool PhysicsWorld::collided (Vector oldPos, Vector newPos) {
return false;
--- a/src/proto2/Physics.hh Sun Nov 23 18:19:53 2008 +0000
+++ b/src/proto2/Physics.hh Mon Nov 24 15:18:55 2008 +0000
@@ -13,6 +13,9 @@
enum TerrainType {EMPTY, DIRT, ROCK};
+const Vector DIRECTIONS[] = { Vector(0,-1), Vector(1,-1), Vector(1,0), Vector(1,1),
+ Vector(0,1), Vector(-1,1), Vector(-1,0), Vector(-1,-1) };
+
// forward-declare
class PhysicsObject;
typedef Vector Force;