--- a/src/proto2/Physics.hh Fri Nov 28 22:26:23 2008 +0000
+++ b/src/proto2/Physics.hh Fri Nov 28 22:40:11 2008 +0000
@@ -124,20 +124,18 @@
bool facingRight; // Player facing
bool inAir; // Is the object "on the ground"
- // Shape of the object. We use a polygon with 4 edges
- // to make easy to draw with Clanlib. The coordinates
- // are relative to the center point.
+ // Shape of the object. The vector contains the polygon edge
+ // points relative to the object location.
std::vector<Vector> shape;
// Force queue that is emptied on every tick
std::queue<Force> forceq;
+ // Helper variables for integration (TODO: should these be
+ // somewhere else?)
Vector posAfterTick;
Vector velAfterTick;
- /**
- * @param shape Corners of the four sided polygon.
- */
- PhysicsObject (PhysicsWorld &world, float mass, Vector position, Vector velocity);
+ PhysicsObject (PhysicsWorld &world, float mass, Vector position, Vector velocity);
~PhysicsObject() {}
/**
@@ -146,19 +144,22 @@
* function is only used to handle in air movement.
*
* @param force Force vector.
- * @param dt The time the force is applied.
*/
virtual void applyForce (Force force);
/**
* Changes player aim
+ *
+ * @param da Aim angle change
*/
void changeAim(float da);
/**
* Set player facing.
+ *
+ * @param facingRight True if player is facing right.
*/
- void setFacing(bool right);
+ void setFacing(bool facingRight);
/**
* Called on network clients to sync state from server
@@ -168,6 +169,7 @@
/**
* Handle ground movement
*
+ * @param right Boolean describing the movement direction.
* @return new position
*/
Vector walk (bool right);
@@ -179,30 +181,91 @@
/**
* Handle ground-bounce
+ *
+ * @param normal Normal vector relative to which to bounce
*/
void bounce (Vector normal);
private:
+ /**
+ * Handle player movement and applying forces.
+ */
void updatePosition (void);
- bool possibleLocation (Vector loc);
+
+ /*
+ * TODO: Documentation
+ */
+ bool possibleLocation (Vector loc);
/**
* Use RK4 to integrate the effects of force over a time intervall.
+ *
+ * @param force Force to integrate
+ * @param dt Time intervall
*/
void integrate(Force force, TimeMS dt);
+
+ /**
+ * Evaluate the value of the derivative at given time
+ *
+ * @param force Force
+ * @param dt Time
+ * @param d Last derivative
+ */
Derivative evaluate(Force force, TimeMS dt, Derivative &d);
+
+ /**
+ * Return object acceleration with given force.
+ *
+ * @param force Force
+ * @return acceleration
+ */
Vector acceleration(const Force &force);
+ /*
+ * Handle collision. TODO: This is not used. It probably should be?
+ */
virtual void onCollision() {}
public:
+ /**
+ * Get current object position.
+
+ * @return position vector
+ */
Vector getPosition (void);
+
+ /**
+ * Return object shape.
+ *
+ * @return Polygon points
+ */
std::vector<Vector>& getShape(void);
+
+ /**
+ * Set object shape.
+ *
+ * @param shape Vector containing polygon points
+ */
void setShape (std::vector<Vector> shape);
+ /**
+ * Return object facing.
+ *
+ * @return Object facing (true if facing is right)
+ */
bool getFacing(void);
+
+ /**
+ * Return object aim angle.
+ *
+ * @return Object aim angle
+ */
float getAim(void);
+ /**
+ * Update object in physics simulation.
+ */
void tick (void);
};