No nyt se toimii v?h?n paremmin. Koodia pit?? kyll? viel? siisti? aika huolella.
authorsaiam
Thu, 20 Nov 2008 21:35:17 +0000
changeset 84 3cb862028a24
parent 83 cbba9729e92b
child 85 351cb6b69c04
No nyt se toimii v?h?n paremmin. Koodia pit?? kyll? viel? siisti? aika huolella.
src/proto2/Physics.cc
--- a/src/proto2/Physics.cc	Thu Nov 20 21:25:09 2008 +0000
+++ b/src/proto2/Physics.cc	Thu Nov 20 21:35:17 2008 +0000
@@ -43,22 +43,24 @@
     // TODO: It might be possible to optimize by adding forces together
     std::queue<Force> newfq;
     Force tmpf;
+    Force total;
     posAfterTick = position;
     velAfterTick = velocity;
     while (!forceq.empty()) {
         tmpf = forceq.front();
         if (tmpf.dt <= PHYSICS_TICK_MS) { // Force affects only one tick
-            integrate(tmpf.force, tmpf.dt);
+            total.force += tmpf.force;
         } else { // Add remaining time to next tick
             newfq.push(Force(tmpf.force, tmpf.dt - PHYSICS_TICK_MS));
-            integrate(tmpf.force, PHYSICS_TICK_MS);
+            total.force += tmpf.force;
         }
         forceq.pop();
         //        Engine::log(DEBUG, "PhysicsObject.updatePosition") << "Current position: " << posAfterTick;
     }
+    integrate(total.force, PHYSICS_TICK_MS);
     forceq = newfq;
 
-    Vector newPosition = posAfterTick + (velAfterTick * PHYSICS_TICK_MS)/1000;
+    Vector newPosition = posAfterTick /*+ (velAfterTick * PHYSICS_TICK_MS)/1000*/;
     this->velocity = velAfterTick;
     Engine::log(DEBUG, "PhysicsObject.updatePosition") << "Nopeus: "<<this->velocity;
     /*