forked from enlightenment/efl
parent
5c32157f04
commit
1ef5ae1a2d
|
@ -31,6 +31,7 @@ test_growing_balls.c \
|
|||
test_jumping_balls.c \
|
||||
test_no_gravity.c \
|
||||
test_rotate.c \
|
||||
test_rotating_forever.c \
|
||||
test_velocity.c \
|
||||
test_shapes.c \
|
||||
test_sleeping_threshold.c \
|
||||
|
|
|
@ -30,6 +30,7 @@ void test_growing_balls(void *data, Evas_Object *obj, void *event_info);
|
|||
void test_jumping_balls(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_no_gravity(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_rotate(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_rotating_forever(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_velocity(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_shapes(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_sleeping(void *data, Evas_Object *obj, void *event_info);
|
||||
|
@ -52,6 +53,7 @@ static const EPhysics_Test tests[] = {
|
|||
{"Jumping Balls", test_jumping_balls},
|
||||
{"No Gravity", test_no_gravity},
|
||||
{"Rotate", test_rotate},
|
||||
{"Rotating Forever", test_rotating_forever},
|
||||
{"Velocity", test_velocity},
|
||||
{"Shapes", test_shapes},
|
||||
{"Sleeping Threshold", test_sleeping},
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "ephysics_test.h"
|
||||
|
||||
|
||||
static void
|
||||
_update_object_cb(void *data __UNUSED__, EPhysics_Body *body, void *event_info __UNUSED__)
|
||||
{
|
||||
double rot, vrot;
|
||||
|
||||
rot = ephysics_body_rotation_get(body);
|
||||
vrot = ephysics_body_angular_velocity_get(body);
|
||||
ephysics_body_evas_object_update(body);
|
||||
|
||||
DBG("rot: %lf, vrot :%lf", rot, vrot);
|
||||
}
|
||||
|
||||
static void
|
||||
_world_populate(Test_Data *test_data)
|
||||
{
|
||||
EPhysics_Body *body;
|
||||
Evas_Object *cube;
|
||||
|
||||
cube = elm_image_add(test_data->win);
|
||||
elm_image_file_set(
|
||||
cube, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "blue-cube");
|
||||
evas_object_move(cube, WIDTH / 3, HEIGHT / 2 - 30);
|
||||
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_torque_impulse_apply(body, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
||||
{
|
||||
Test_Data *test_data = data;
|
||||
|
||||
DBG("Restart pressed");
|
||||
test_clean(test_data);
|
||||
_world_populate(test_data);
|
||||
}
|
||||
|
||||
void
|
||||
test_rotating_forever(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
EPhysics_World *world;
|
||||
Test_Data *test_data;
|
||||
|
||||
if (!ephysics_init())
|
||||
return;
|
||||
|
||||
test_data = test_data_new();
|
||||
test_win_add(test_data, "Rotating Forever", EINA_TRUE);
|
||||
elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
|
||||
elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
|
||||
_restart, test_data);
|
||||
|
||||
world = ephysics_world_new();
|
||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
||||
test_data->world = world;
|
||||
ephysics_world_gravity_set(world, 0, 0);
|
||||
|
||||
_world_populate(test_data);
|
||||
}
|
|
@ -2152,6 +2152,10 @@ EAPI void ephysics_body_central_impulse_apply(EPhysics_Body *body, double x, dou
|
|||
* Apply a torque impulse over a body.
|
||||
*
|
||||
* An impulse will be applied over the body to make it rotate around Z axis.
|
||||
* Impulse is the product of the force over the time this force is applied.
|
||||
* In ephysics case, it would be the time of a tick, so it behaves just
|
||||
* summing current angular velocity to the result of a calculation involving
|
||||
* torque impulse and body's inertia.
|
||||
*
|
||||
* @param body The physics body that will receive the impulse.
|
||||
* @param roll Impulse to rotate body around Z axis (rotate on x - y plane).
|
||||
|
|
|
@ -1272,7 +1272,7 @@ ephysics_body_torque_impulse_apply(EPhysics_Body *body, double roll)
|
|||
}
|
||||
|
||||
body->rigid_body->activate(1);
|
||||
body->rigid_body->applyTorqueImpulse(btVector3(0, 0, roll));
|
||||
body->rigid_body->applyTorqueImpulse(btVector3(0, 0, -roll));
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
|
Loading…
Reference in New Issue