--- a/src/PhysicsObject.cc Sun Dec 07 19:40:40 2008 +0000
+++ b/src/PhysicsObject.cc Sun Dec 07 19:52:12 2008 +0000
@@ -126,8 +126,6 @@
forceq.push(direction);
}
}
-
- // Go trough every force in the queue
Force total;
while (!forceq.empty()) {
total += forceq.front();
@@ -175,26 +173,25 @@
integrate(total, dt, newPosition, velAfterTick);
this->velocity = velAfterTick;
-
// Collision detection
bool collided = false;
+ Vector collisionPoint;
const Vector diffVec = newPosition-position;
const Vector unitVector = diffVec / diffVec.length();
Vector reached = position;
- Engine::log(DEBUG, "physics.update_position") << "unitVector=" << unitVector;
-
while ((position-reached).sqrLength() < diffVec.sqrLength()) {
reached += unitVector;
// Check if any of the shapes points collide
for (uint64_t i = 0; i < shape.size(); i++) {
if (world.collides(reached+shape[i])) { // Collision
+
+ collisionPoint = reached+shape[i];
+
if (inAir) {
- // Engine::log(DEBUG, "Here");
this->bounce(world.getNormal(reached+shape[i],
reached-unitVector+shape[i]));
- //this->velocity *= COLLISION_ELASTICITY;
}
reached = reached - unitVector; // Return to last point
collided = true;
@@ -228,7 +225,7 @@
this->position = newPosition;
// the following may delete this object, so it must be the last thing called
- onCollision();
+ onCollision(collisionPoint);
return;
}