Commits

Anonymous committed 66e2c3a

Minor doc changes. Renamed body.angle_velocity to body.angular_velocity.

  • Participants
  • Parent commits b4e9074
  • Branches physics

Comments (0)

Files changed (6)

     body2.velocity = -2, 0
     body1.restitution = 1.0
     body1.rotation = 3
-    body1.angle_velocity = 1
+    body1.angular_velocity = 1
     body1.mass = 20*20
     w.add_body(body2)
     return w
     w.add_body(body2)
     
     joint1 = physics.DistanceJoint(body1,body,1)
-    #joint1.distance = 10
     joint1.anchor1 = 0, 0
     joint1.anchor2 = 0, 0
     w.add_joint(joint1)
     joint2 = physics.DistanceJoint(body1,body2,1)
-    #joint2.distance = 10
     joint2.anchor1 = 0, 0
     joint2.anchor2 = 0, 0
     w.add_joint(joint2)

include/pgBodyObject.h

 * @param global_p
 * @return
 */
-PyVector2 PyBodyObject_GetRelativePosFromGlobal(PyBodyObject* body, PyVector2* global_p);
+PyVector2 PyBodyObject_GetRelativePosFromGlobal(PyBodyObject* body,
+    PyVector2* global_p);
 
 /**
  * Translate vector from coordinate B to the body coordinates A

include/pgJointObject.h

 #ifndef _PHYSICS_JOINT_H_
 #define _PHYSICS_JOINT_H_
 
+/**
+ * TODO
+ *
+ * @param joint
+ * @param stepTime
+ */
 int JointObject_SolveConstraintVelocity (PyJointObject *joint, double stepTime);
+
+/**
+ * TODO
+ *
+ * @param joint
+ * @param stepTime
+ */
 int JointObject_SolveConstraintPosition (PyJointObject *joint, double stepTime);
 
 /**

include/pgShapeObject.h

 
 #include "pgphysics.h"
 
+/**
+ * TODO
+ *
+ * @param shape
+ * @param refbody
+ */
 int PyShapeObject_UpdateAABB (PyShapeObject *shape, PyBodyObject *refbody);
 
+/**
+ * TODO
+ *
+ * @param shape
+ * @param refbody
+ * @param incbody
+ * @param conactlist
+ */
 int PyShapeObject_Collision (PyShapeObject *shape, PyBodyObject *refbody,
     PyBodyObject *incbody, PyObject *contactlist);
 

src/pgBodyObject.c

       "Torque", NULL },
     { "restitution", (getter) _Body_getRestitution,
       (setter) _Body_setRestitution, "Restitution", NULL },
-    {"friction", (getter) _Body_getFriction, (setter) _Body_setFriction,
-     "Friction", NULL },
-
-    {"velocity",(getter)_Body_getVelocity,(setter)_Body_setVelocity,"velocity",NULL},
-	{"angle_velocity",(getter)_Body_getAngularVel,(setter)_Body_setAngularVel,"Angular Velocity",NULL},
-    {"position",(getter)_Body_getPosition,(setter)_Body_setPosition,"position",NULL},
-    {"force",(getter)_Body_getForce,(setter)_Body_setForce,"force",NULL},
-    {"static",(getter)_Body_getBStatic,(setter)_Body_setBStatic,"whether static",NULL},
+    { "friction", (getter) _Body_getFriction, (setter) _Body_setFriction,
+      "Friction", NULL },
+    { "velocity",(getter)_Body_getVelocity,(setter)_Body_setVelocity,
+      "velocity",NULL },
+    { "angular_velocity",(getter)_Body_getAngularVel,
+      (setter)_Body_setAngularVel,"Angular Velocity",NULL },
+    { "position",(getter)_Body_getPosition,(setter)_Body_setPosition,
+      "position",NULL },
+    { "force",(getter)_Body_getForce,(setter)_Body_setForce,"force",NULL },
+    { "static",(getter)_Body_getBStatic,(setter)_Body_setBStatic,
+      "whether static",NULL },
     { NULL, NULL, NULL, NULL, NULL}
 };
 
     0                           /* tp_del */
 };
 
+/**
+ * Internal body initialization. Fill the fields of the Body structure
+ * with the default values.
+ *
+ * @param body The PyBodyObject to initialize.
+ */
 static void _BodyInit(PyBodyObject* body)
 {
     body->fAngleVelocity = 0.0;
     PyVector2_Set(body->vecPosition,0.0,0.0);
 }
 
+/**
+ * Creates a new PyBodyObject.
+ */
 static PyObject* _BodyNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
     //TODO: parse args later on
     return op;
 }
 
+/**
+ * Deallocates the passed PyBodyObject.
+ *
+ * @param body The PyBodyObject to deallocate.
+ */
 static void _BodyDestroy(PyBodyObject* body)
 {
     /*
 //============================================================
 //getter and setter functions
 
-//velocity
+/**
+ * Getter for Body.velocity
+ */
 static PyObject* _Body_getVelocity(PyBodyObject* body,void* closure)
 {
     return Py_BuildValue ("(ff)", body->vecLinearVelocity.real,
         body->vecLinearVelocity.imag);
 }
 
+/**
+ * Setter for Body.velocity = (x, y)
+ */
 static int _Body_setVelocity(PyBodyObject* body,PyObject* value,void* closure)
 {
     PyObject *item;
     return 0;
 }
 
-//position
+/**
+ * Getter for Body.position
+ */
 static PyObject* _Body_getPosition(PyBodyObject* body,void* closure)
 {
     return Py_BuildValue ("(ff)", body->vecPosition.real,
         body->vecPosition.imag);
 }
 
+/**
+ * Setter for Body.position = (x, y)
+ */
 static int _Body_setPosition(PyBodyObject* body,PyObject* value,void* closure)
 {
     PyObject *item;
     return 0;
 }
 
-//force
+/**
+ * Getter for Body.force
+ */
 static PyObject* _Body_getForce(PyBodyObject* body,void* closure)
 {
     return Py_BuildValue ("(ff)", body->vecForce.real, body->vecForce.imag);
 }
 
+/**
+ * Setter for Body.force = (x, y)
+ */
 static int _Body_setForce(PyBodyObject* body,PyObject* value,void* closure)
 {
     PyObject *item;
 }
 
 /**
- * Getter for retrieving the mass of the passed body.
+ * Getter for Body.mass
  */
 static PyObject* _Body_getMass (PyBodyObject* body,void* closure)
 {
 }
 
 /**
- * Sets the mass of the passed body.
+ * Setter for Body.mass = x
  */
 static int _Body_setMass(PyBodyObject* body,PyObject* value,void* closure)
 {
 }
 
 /**
- * Getter for retrieving the rotation of the passed body.
+ * Getter for Body.rotation.
  */
 static PyObject* _Body_getRotation (PyBodyObject* body,void* closure)
 {
 }
 
 /**
- * Sets the rotation of the passed body.
+ * Setter for Body.rotation = x
  */
 static int _Body_setRotation(PyBodyObject* body,PyObject* value,void* closure)
 {
 }
 
 /**
-* Getter for retrieving the angular velocity of the passed body.
+* Getter for Body.angular_velocity
 */
 static PyObject* _Body_getAngularVel (PyBodyObject* body,void* closure)
 {
 	return PyFloat_FromDouble (body->fAngleVelocity);
 }
 
-
+/**
+ * Setter for Body.angular_velocity = x
+ */
 static int _Body_setAngularVel(PyBodyObject* body,PyObject* value,void* closure)
 {
-	if (PyNumber_Check (value))
-	{
-		PyObject *tmp = PyNumber_Float (value);
+    if (PyNumber_Check (value))
+    {
+        PyObject *tmp = PyNumber_Float (value);
 
-		if (tmp)
-		{
-			double fAngleVelocity = PyFloat_AsDouble (tmp);
-			Py_DECREF (tmp);
-			if (PyErr_Occurred ())
-				return -1;
-			body->fAngleVelocity = fAngleVelocity;
-			return 0;
-		}
-	}
-	PyErr_SetString (PyExc_TypeError, "rotation must be a float");
-	return -1;
+        if (tmp)
+        {
+            double fAngleVelocity = PyFloat_AsDouble (tmp);
+            Py_DECREF (tmp);
+            if (PyErr_Occurred ())
+                return -1;
+            body->fAngleVelocity = fAngleVelocity;
+            return 0;
+        }
+    }
+    PyErr_SetString (PyExc_TypeError, "rotation must be a float");
+    return -1;
 }
 
 /**
- * Getter for retrieving the torque of the passed body.
+ * Getter for Body.torque
  */
 static PyObject* _Body_getTorque (PyBodyObject* body,void* closure)
 {
 }
 
 /**
- * Sets the torque of the passed body.
+ * Setter for Body.torque = x
  */
 static int _Body_setTorque (PyBodyObject* body,PyObject* value,void* closure)
 {
 }
 
 /**
- * Getter for retrieving the restitution of the passed body.
+ * Getter for Body.restitution
  */
 static PyObject* _Body_getRestitution (PyBodyObject* body,void* closure)
 {
 }
 
 /**
- * Sets the restitution of the passed body.
+ * Setter for Body.restitution = x
  */
 static int _Body_setRestitution (PyBodyObject* body,PyObject* value,
     void* closure)
 }
 
 /**
- * Getter for retrieving the friction of the passed body.
+ * Getter for Body.friction
  */
 static PyObject* _Body_getFriction (PyBodyObject* body,void* closure)
 {
 }
 
 /**
- * Sets the friction of the passed body.
+ * Setter for Body.friction = x
  */
 static int _Body_setFriction (PyBodyObject* body,PyObject* value,void* closure)
 {
 }
 
 /**
- * Getter for retrieving the bStatic of the passed body.
+ * Setter for Body.static = x
  */
 static PyObject* _Body_getBStatic (PyBodyObject* body,void* closure)
 {
 }
 
 /**
- * Sets the bStatic of the passed body.
+ * Getter for Body.static
  */
 static int _Body_setBStatic (PyBodyObject* body,PyObject* value,void* closure)
 {
 }
 
 /**
- * Getter for retrieving the shape of the passed body.
+ * Getter for Body.shape
  */
 static PyObject* _Body_getShape (PyBodyObject* body,void* closure)
 {
 }
 
 /**
- * Sets the shape of the passed body.
+ * Setter for Body.shape = x
  */
 static int _Body_setShape(PyBodyObject* body,PyObject* value,void* closure)
 {
     return 0;
 }
 
+
+/* Body methods */
+
+/**
+ * Body.get_points ()
+ */
 static PyObject *_Body_getPointList(PyObject *self, PyObject *args)
 {
     PyBodyObject* body = (PyBodyObject*)self;
     return list;
 }
 
+/* Internally used Body functions */
+
 void PyBodyObject_FreeUpdateVel(PyBodyObject* body, PyVector2 gravity,
     double dt)
 {
         PyVector2_MultiplyWithReal(totalF, dt/body->fMass));
     k1 = PG_Clamp(1-dt*body->fLinearVelDamping,0.0,1.0);
     k2 = PG_Clamp(1-dt*body->fAngleVelDamping,0.0,1.0);
-    body->vecLinearVelocity = PyVector2_MultiplyWithReal(body->vecLinearVelocity,k1);
+    body->vecLinearVelocity =
+        PyVector2_MultiplyWithReal(body->vecLinearVelocity,k1);
     body->fAngleVelocity *= k2;
 }
 
     return ans;
 }
 
-PyVector2 PyBodyObject_GetRelativePosFromGlobal(PyBodyObject* body, PyVector2* global_p)
+PyVector2 PyBodyObject_GetRelativePosFromGlobal(PyBodyObject* body,
+    PyVector2* global_p)
 {
 	PyVector2 ans = c_diff(*global_p,body->vecPosition);