It results in central and torque impulses.
SVN revision: 75474
vrot = ephysics_body_angular_velocity_get(body);
ephysics_body_evas_object_update(body);
- DBG("rot: %lf, vrot :%lf", rot, vrot);
+ DBG("body: %p, rot: %lf, vrot :%lf", body, rot, vrot);
}
static void
_update_object_cb, NULL);
ephysics_body_torque_impulse_apply(body, 1);
+
+ cube = elm_image_add(test_data->win);
+ elm_image_file_set(
+ cube, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "purple-cube");
+ evas_object_move(cube, WIDTH / 3, FLOOR_Y - 70);
+ evas_object_resize(cube, 70, 70);
+ evas_object_show(cube);
+ test_data->evas_objs = eina_list_append(test_data->evas_objs, cube);
+
+ body = ephysics_body_box_add(test_data->world);
+ ephysics_body_evas_object_set(body, cube, EINA_TRUE);
+ test_data->bodies = eina_list_append(test_data->bodies, body);
+ ephysics_body_event_callback_add(body,
+ EPHYSICS_CALLBACK_BODY_UPDATE,
+ _update_object_cb, NULL);
+
+ ephysics_body_impulse_apply(body, 30, 0, 0, -10);
}
static void
* @param x The axis x component of impulse.
* @param y The axis y component of impulse.
*
+ * @see ephysics_body_torque_impulse_apply().
+ * @see ephysics_body_impulse_apply().
+ *
* @ingroup EPhysics_Body
*/
EAPI void ephysics_body_central_impulse_apply(EPhysics_Body *body, double x, double y);
* Negative values will impulse body on anti clock rotation.
*
* @see ephysics_body_central_impulse_apply().
+ * @see ephysics_body_impulse_apply().
*
* @ingroup EPhysics_Body
*/
/**
* @brief
+ * Apply an impulse over a body.
+ *
+ * An impulse will be applied over the body to make it move and rotate around
+ * Z axis.
+ *
+ * Impulse is the product of the force over the time this force is applied.
+ * It can be applied in the center of the body, avoiding rotating it,
+ * with @ref ephysics_body_central_impulse_apply(), it can be applied only
+ * to make a body rotate, with @ref ephysics_body_torque_impulse_apply(),
+ * or can be used to lead to both behaviors with
+ * @ref ephysics_body_impulse_apply().
+ *
+ * It will resulte in a central impulse with impulse (@p x, @p y) and a
+ * torque impulse that will be calculated as a cross product on impulse
+ * and relative position.
+ *
+ * @param body The physics body that will receive the impulse.
+ * @param x The axis x component of impulse.
+ * @param y The axis y component of impulse.
+ * @param pos_x The axis x component of the relative position to apply impulse.
+ * @param pos_y The axis y component of the relative position to apply impulse.
+ *
+ * @note Impulse is measured in kg * p / s and position in pixels
+ * (Evas coordinates).
+ *
+ * @see ephysics_body_central_impulse_apply().
+ * @see ephysics_body_torque_impulse_apply().
+ *
+ * @ingroup EPhysics_Body
+ */
+EAPI void ephysics_body_impulse_apply(EPhysics_Body *body, double x, double y, Evas_Coord pos_x, Evas_Coord pos_y);
+
+/**
+ * @brief
* Enable or disable body's rotation on z axis.
*
* Enabled by default.
}
EAPI void
+ephysics_body_impulse_apply(EPhysics_Body *body, double x, double y, Evas_Coord pos_x, Evas_Coord pos_y)
+{
+ double rate;
+
+ if (!body)
+ {
+ ERR("Can't apply impulse to a null body.");
+ return;
+ }
+
+ rate = ephysics_world_rate_get(body->world);
+
+ body->rigid_body->activate(1);
+ body->rigid_body->applyImpulse(btVector3(x / rate, y / rate, 0),
+ btVector3((double) pos_x / rate,
+ (double) pos_y / rate, 0));
+}
+
+EAPI void
ephysics_body_linear_movement_enable_set(EPhysics_Body *body, Eina_Bool enable_x, Eina_Bool enable_y)
{
if (!body)