--- a/src/proto2/Physics.hh Thu Nov 20 21:22:03 2008 +0000
+++ b/src/proto2/Physics.hh Thu Nov 20 21:25:09 2008 +0000
@@ -4,6 +4,7 @@
#include "Vector.hh"
#include <vector>
+#include <queue>
#include <ClanLib/core.h>
typedef uint16_t TimeMS;
@@ -14,6 +15,8 @@
// forward-declare
class PhysicsObject;
+class Force;
+struct Derivative;
class PhysicsWorld {
friend class PhysicsObject;
@@ -45,13 +48,19 @@
class PhysicsObject {
protected:
PhysicsWorld &world;
+
float mass;
Vector position;
Vector velocity;
// Whether the object (worms mainly) is in the air
// or firmly on the ground. Affects to physics.
bool inAir;
-
+
+ // Force queue that is emptied on every tick
+ std::queue<Force> forceq;
+ Vector posAfterTick;
+ Vector velAfterTick;
+
PhysicsObject (PhysicsWorld &world, float mass, Vector position, Vector velocity);
virtual void applyForce (Vector force, TimeMS dt);
@@ -64,11 +73,29 @@
* Use RK4 to integrate the effects of force over a time intervall.
*/
void integrate(Vector force, TimeMS dt);
-
+ Derivative evaluate(Vector force, TimeMS dt, Derivative &d);
+ Vector acceleration(const Vector &force);
+
public:
Vector getPosition (void);
void tick (void);
};
+class Force {
+public:
+ Vector force;
+ TimeMS dt;
+
+ Force() {}
+ Force(Vector force, TimeMS dt) : force(force), dt(dt) {}
+};
+
+struct Derivative {
+ Vector dx; // Velocity
+ Vector dv; // Acceleration
+};
+
+
+
#endif