ephysics: add front and back boundaries
Use it on test "Bouncing 3D" SVN revision: 78015
This commit is contained in:
parent
9447db42d8
commit
c2b0c76b74
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#define WIDTH (512)
|
#define WIDTH (512)
|
||||||
#define HEIGHT (384)
|
#define HEIGHT (384)
|
||||||
|
#define DEPTH (100)
|
||||||
#define FLOOR_Y (HEIGHT - 80)
|
#define FLOOR_Y (HEIGHT - 80)
|
||||||
#define SH_THRESHOLD (250)
|
#define SH_THRESHOLD (250)
|
||||||
#define SH_OFFSET_X (- 16)
|
#define SH_OFFSET_X (- 16)
|
||||||
|
@ -214,7 +215,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__)
|
||||||
evas_object_show(bg);
|
evas_object_show(bg);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 0, 0, WIDTH, HEIGHT);
|
ephysics_world_render_geometry_set(world, 0, 0, -50, WIDTH, HEIGHT, DEPTH);
|
||||||
|
|
||||||
ground_body = ephysics_body_box_add(world);
|
ground_body = ephysics_body_box_add(world);
|
||||||
ephysics_body_mass_set(ground_body, EPHYSICS_BODY_MASS_STATIC);
|
ephysics_body_mass_set(ground_body, EPHYSICS_BODY_MASS_STATIC);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#define SANDBOX_THEME "ephysics_sandbox"
|
#define SANDBOX_THEME "ephysics_sandbox"
|
||||||
#define WIDTH (1280)
|
#define WIDTH (1280)
|
||||||
#define HEIGHT (720)
|
#define HEIGHT (720)
|
||||||
|
#define DEPTH (100)
|
||||||
|
|
||||||
typedef struct _Sandie_Data {
|
typedef struct _Sandie_Data {
|
||||||
Evas_Object *win;
|
Evas_Object *win;
|
||||||
|
@ -844,8 +845,9 @@ _sandie_world_add(Evas_Object *win)
|
||||||
EPhysics_World *world;
|
EPhysics_World *world;
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 80, 80, (int) WIDTH * 0.7 - 160,
|
ephysics_world_render_geometry_set(world, 80, 80, -50,
|
||||||
HEIGHT - 160);
|
(int) WIDTH * 0.7 - 160, HEIGHT - 160,
|
||||||
|
DEPTH);
|
||||||
evas_object_data_set(win, "top", ephysics_body_top_boundary_add(world));
|
evas_object_data_set(win, "top", ephysics_body_top_boundary_add(world));
|
||||||
evas_object_data_set(win, "bottom",
|
evas_object_data_set(win, "bottom",
|
||||||
ephysics_body_bottom_boundary_add(world));
|
ephysics_body_bottom_boundary_add(world));
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#define EPHYSICS_TEST_THEME "ephysics_test"
|
#define EPHYSICS_TEST_THEME "ephysics_test"
|
||||||
#define WIDTH (512)
|
#define WIDTH (512)
|
||||||
#define HEIGHT (384)
|
#define HEIGHT (384)
|
||||||
|
#define DEPTH (100)
|
||||||
#define SHADOW_ALPHA_ID (1)
|
#define SHADOW_ALPHA_ID (1)
|
||||||
#define FLOOR_Y (344)
|
#define FLOOR_Y (344)
|
||||||
#define FLOOR_WIDTH (750)
|
#define FLOOR_WIDTH (750)
|
||||||
|
|
|
@ -122,7 +122,8 @@ test_bouncing_3d(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event
|
||||||
elm_object_signal_emit(test_data->layout, "controls,show", "ephysics_test");
|
elm_object_signal_emit(test_data->layout, "controls,show", "ephysics_test");
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
@ -137,6 +138,14 @@ test_bouncing_3d(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event
|
||||||
ephysics_body_restitution_set(boundary, 0.4);
|
ephysics_body_restitution_set(boundary, 0.4);
|
||||||
ephysics_body_friction_set(boundary, 3);
|
ephysics_body_friction_set(boundary, 3);
|
||||||
|
|
||||||
|
boundary = ephysics_body_front_boundary_add(test_data->world);
|
||||||
|
ephysics_body_restitution_set(boundary, 0.4);
|
||||||
|
ephysics_body_friction_set(boundary, 3);
|
||||||
|
|
||||||
|
boundary = ephysics_body_back_boundary_add(test_data->world);
|
||||||
|
ephysics_body_restitution_set(boundary, 0.4);
|
||||||
|
ephysics_body_friction_set(boundary, 3);
|
||||||
|
|
||||||
ephysics_body_top_boundary_add(test_data->world);
|
ephysics_body_top_boundary_add(test_data->world);
|
||||||
|
|
||||||
_world_populate(test_data);
|
_world_populate(test_data);
|
||||||
|
|
|
@ -88,7 +88,8 @@ test_bouncing_ball(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *eve
|
||||||
elm_object_signal_emit(test_data->layout, "arrows,show", "ephysics_test");
|
elm_object_signal_emit(test_data->layout, "arrows,show", "ephysics_test");
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -55,7 +55,8 @@ test_bouncing_text(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *eve
|
||||||
_restart, test_data);
|
_restart, test_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, 100);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -53,7 +53,7 @@ _camera_move_cb(void *data)
|
||||||
int x, y, w;
|
int x, y, w;
|
||||||
|
|
||||||
ephysics_world_render_geometry_get(camera_data->base.world,
|
ephysics_world_render_geometry_get(camera_data->base.world,
|
||||||
NULL, NULL, &w, NULL);
|
NULL, NULL, NULL, &w, NULL, NULL);
|
||||||
|
|
||||||
camera = ephysics_world_camera_get(camera_data->base.world);
|
camera = ephysics_world_camera_get(camera_data->base.world);
|
||||||
ephysics_camera_position_get(camera, &x, &y);
|
ephysics_camera_position_get(camera, &x, &y);
|
||||||
|
@ -219,7 +219,8 @@ test_camera(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
evas_object_data_set(camera_data->base.layout, "floor2", floor_obj);
|
evas_object_data_set(camera_data->base.layout, "floor2", floor_obj);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
ephysics_world_event_callback_add(world,
|
ephysics_world_event_callback_add(world,
|
||||||
EPHYSICS_CALLBACK_WORLD_CAMERA_MOVED,
|
EPHYSICS_CALLBACK_WORLD_CAMERA_MOVED,
|
||||||
_camera_moved_cb, camera_data);
|
_camera_moved_cb, camera_data);
|
||||||
|
|
|
@ -230,7 +230,8 @@ test_camera_track(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *even
|
||||||
evas_object_data_set(track_data->base.layout, "floor2", floor_obj);
|
evas_object_data_set(track_data->base.layout, "floor2", floor_obj);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
track_data->base.world = world;
|
track_data->base.world = world;
|
||||||
ephysics_world_event_callback_add(world,
|
ephysics_world_event_callback_add(world,
|
||||||
EPHYSICS_CALLBACK_WORLD_CAMERA_MOVED,
|
EPHYSICS_CALLBACK_WORLD_CAMERA_MOVED,
|
||||||
|
|
|
@ -74,7 +74,8 @@ test_colliding_balls(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *e
|
||||||
_restart, test_data);
|
_restart, test_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -165,7 +165,8 @@ test_collision(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i
|
||||||
"test-theme", _restart, collision_data);
|
"test-theme", _restart, collision_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
collision_data->base.world = world;
|
collision_data->base.world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(collision_data->base.world);
|
boundary = ephysics_body_bottom_boundary_add(collision_data->base.world);
|
||||||
|
|
|
@ -67,7 +67,8 @@ test_collision_filter(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *
|
||||||
_restart, test_data);
|
_restart, test_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 60, 40, WIDTH - 120, FLOOR_Y - 32);
|
ephysics_world_render_geometry_set(world, 60, 40, -50,
|
||||||
|
WIDTH - 120, FLOOR_Y - 32, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -126,7 +126,8 @@ test_collision_speed(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *e
|
||||||
speed_data->sp = sp;
|
speed_data->sp = sp;
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
ephysics_world_simulation_set(world, 1/260.f, 5);
|
ephysics_world_simulation_set(world, 1/260.f, 5);
|
||||||
speed_data->base.world = world;
|
speed_data->base.world = world;
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,8 @@ test_constraint(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_
|
||||||
_restart, test_data);
|
_restart, test_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -173,7 +173,8 @@ test_delete(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
"test-theme", _restart, collision_data);
|
"test-theme", _restart, collision_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
collision_data->base.world = world;
|
collision_data->base.world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(collision_data->base.world);
|
boundary = ephysics_body_bottom_boundary_add(collision_data->base.world);
|
||||||
|
|
|
@ -64,7 +64,8 @@ test_falling_letters(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *e
|
||||||
_restart, test_data);
|
_restart, test_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -74,7 +74,8 @@ test_flag(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info _
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_simulation_set(world, 1/160.f, 10);
|
ephysics_world_simulation_set(world, 1/160.f, 10);
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -88,7 +88,8 @@ test_forces(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
_restart, test_data);
|
_restart, test_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -153,7 +153,8 @@ test_grab(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info _
|
||||||
elm_object_signal_emit(test_data->layout, "grab,show", "ephysics_test");
|
elm_object_signal_emit(test_data->layout, "grab,show", "ephysics_test");
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -104,7 +104,8 @@ test_growing_balls(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *eve
|
||||||
_restart, test_data);
|
_restart, test_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -59,7 +59,8 @@ test_heavy(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
"ephysics_test");
|
"ephysics_test");
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -118,7 +118,8 @@ test_jumping_balls(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *eve
|
||||||
_restart, test_data);
|
_restart, test_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
bt = elm_button_add(test_data->win);
|
bt = elm_button_add(test_data->win);
|
||||||
|
|
|
@ -67,7 +67,8 @@ test_light(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
|
elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -111,7 +111,8 @@ test_material(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
|
||||||
test_data->data = sp;
|
test_data->data = sp;
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -108,7 +108,8 @@ test_no_gravity(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_
|
||||||
evas_object_smart_callback_add(bt, "clicked", _stop, test_data);
|
evas_object_smart_callback_add(bt, "clicked", _stop, test_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -87,7 +87,8 @@ test_rotate(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
_restart, test_data);
|
_restart, test_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -191,7 +191,8 @@ test_rotating_forever(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *
|
||||||
_restart, test_data);
|
_restart, test_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
ephysics_world_gravity_set(world, 0, 0, 0);
|
ephysics_world_gravity_set(world, 0, 0, 0);
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,8 @@ test_shapes(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
_restart, test_data);
|
_restart, test_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -100,7 +100,8 @@ test_sleeping(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
|
||||||
"test-theme", _restart, test_data);
|
"test-theme", _restart, test_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
ephysics_world_max_sleeping_time_set(world, 0.3);
|
ephysics_world_max_sleeping_time_set(world, 0.3);
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,8 @@ test_slider(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
_restart, test_data);
|
_restart, test_data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -143,7 +143,8 @@ test_soft_body(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_simulation_set(world, 1/150.f, 5);
|
ephysics_world_simulation_set(world, 1/150.f, 5);
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -181,7 +181,8 @@ test_velocity(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
|
||||||
"ephysics_test");
|
"ephysics_test");
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
velocity_data->base.world = world;
|
velocity_data->base.world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(velocity_data->base.world);
|
boundary = ephysics_body_bottom_boundary_add(velocity_data->base.world);
|
||||||
|
|
|
@ -51,8 +51,10 @@ _win_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_inf
|
||||||
evas_object_resize(test_data->layout, ww, wh);
|
evas_object_resize(test_data->layout, ww, wh);
|
||||||
ephysics_world_rate_set(test_data->world, 30 * rateh);
|
ephysics_world_rate_set(test_data->world, 30 * rateh);
|
||||||
ephysics_world_render_geometry_set(test_data->world, 50 * ratew, 40 *rateh,
|
ephysics_world_render_geometry_set(test_data->world, 50 * ratew, 40 *rateh,
|
||||||
|
-50,
|
||||||
(WIDTH - 100) * ratew,
|
(WIDTH - 100) * ratew,
|
||||||
(FLOOR_Y - 40) * rateh);
|
(FLOOR_Y - 40) * rateh,
|
||||||
|
DEPTH);
|
||||||
|
|
||||||
old_rate = test_data->data;
|
old_rate = test_data->data;
|
||||||
if (!old_rate) return;
|
if (!old_rate) return;
|
||||||
|
@ -179,7 +181,8 @@ test_win_resize(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_
|
||||||
_win_del, test_data->data);
|
_win_del, test_data->data);
|
||||||
|
|
||||||
world = ephysics_world_new();
|
world = ephysics_world_new();
|
||||||
ephysics_world_render_geometry_set(world, 50, 40, WIDTH - 100, FLOOR_Y - 40);
|
ephysics_world_render_geometry_set(world, 50, 40, -50,
|
||||||
|
WIDTH - 100, FLOOR_Y - 40, DEPTH);
|
||||||
test_data->world = world;
|
test_data->world = world;
|
||||||
|
|
||||||
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
boundary = ephysics_body_bottom_boundary_add(test_data->world);
|
||||||
|
|
|
@ -559,13 +559,17 @@ EAPI EPhysics_World *ephysics_world_new(void);
|
||||||
* @li @ref ephysics_body_top_boundary_add(),
|
* @li @ref ephysics_body_top_boundary_add(),
|
||||||
* @li @ref ephysics_body_bottom_boundary_add(),
|
* @li @ref ephysics_body_bottom_boundary_add(),
|
||||||
* @li @ref ephysics_body_left_boundary_add(),
|
* @li @ref ephysics_body_left_boundary_add(),
|
||||||
* @li @ref ephysics_body_right_boundary_add().
|
* @li @ref ephysics_body_right_boundary_add(),
|
||||||
|
* @li @ref ephysics_body_front_boundary_add(),
|
||||||
|
* @li @ref ephysics_body_back_boundary_add().
|
||||||
*
|
*
|
||||||
* @param world the world to be configured.
|
* @param world the world to be configured.
|
||||||
* @param x Coordinate x of the top left point of rendered area, in pixels.
|
* @param x Coordinate x of the top left point of rendered area, in pixels.
|
||||||
* @param y Coordinate y of the top left point of rendered area, in pixels.
|
* @param y Coordinate y of the top left point of rendered area, in pixels.
|
||||||
|
* @param z Coordinate z of the rendered area, in pixels.
|
||||||
* @param w rendered area width, in pixels.
|
* @param w rendered area width, in pixels.
|
||||||
* @param h rendered area height, in pixels.
|
* @param h rendered area height, in pixels.
|
||||||
|
* @param d rendered area depth, in pixels.
|
||||||
*
|
*
|
||||||
* @note The unit used for geometry is Evas coordinates.
|
* @note The unit used for geometry is Evas coordinates.
|
||||||
*
|
*
|
||||||
|
@ -575,7 +579,7 @@ EAPI EPhysics_World *ephysics_world_new(void);
|
||||||
*
|
*
|
||||||
* @ingroup EPhysics_World
|
* @ingroup EPhysics_World
|
||||||
*/
|
*/
|
||||||
EAPI void ephysics_world_render_geometry_set(EPhysics_World *world, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
|
EAPI void ephysics_world_render_geometry_set(EPhysics_World *world, Evas_Coord x, Evas_Coord y, Evas_Coord z, Evas_Coord w, Evas_Coord h, Evas_Coord d);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
|
@ -584,14 +588,16 @@ EAPI void ephysics_world_render_geometry_set(EPhysics_World *world, Evas_Coord x
|
||||||
* @param world the world to be configured.
|
* @param world the world to be configured.
|
||||||
* @param x Coordinate x of the top left point of rendered area, in pixels.
|
* @param x Coordinate x of the top left point of rendered area, in pixels.
|
||||||
* @param y Coordinate y of the top left point of rendered area, in pixels.
|
* @param y Coordinate y of the top left point of rendered area, in pixels.
|
||||||
|
* @param z Coordinate z of the rendered area, in pixels.
|
||||||
* @param w rendered area width, in pixels.
|
* @param w rendered area width, in pixels.
|
||||||
* @param h rendered area height, in pixels.
|
* @param h rendered area height, in pixels.
|
||||||
|
* @param d rendered area depth, in pixels.
|
||||||
*
|
*
|
||||||
* @see ephysics_world_render_geometry_set() for more information.
|
* @see ephysics_world_render_geometry_set() for more information.
|
||||||
*
|
*
|
||||||
* @ingroup EPhysics_World
|
* @ingroup EPhysics_World
|
||||||
*/
|
*/
|
||||||
EAPI void ephysics_world_render_geometry_get(const EPhysics_World *world, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
|
EAPI void ephysics_world_render_geometry_get(const EPhysics_World *world, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z, Evas_Coord *w, Evas_Coord *h, Evas_Coord *d);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
|
@ -1963,6 +1969,40 @@ EAPI EPhysics_Body *ephysics_body_left_boundary_add(EPhysics_World *world);
|
||||||
*/
|
*/
|
||||||
EAPI EPhysics_Body *ephysics_body_right_boundary_add(EPhysics_World *world);
|
EAPI EPhysics_Body *ephysics_body_right_boundary_add(EPhysics_World *world);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* Create a physic front boundary.
|
||||||
|
*
|
||||||
|
* A physic front boundary will limit the bodies area and placed on the
|
||||||
|
* front of worlds render geometry - defined with
|
||||||
|
* @ref ephysics_world_render_geometry_set().
|
||||||
|
* It is placed on x-y plane, from x to x + width, from y to y + height.
|
||||||
|
*
|
||||||
|
* @param world The world this body will belong to.
|
||||||
|
* @return a new body or @c NULL, on erros.
|
||||||
|
* @see ephysics_world_render_geometry_set()
|
||||||
|
*
|
||||||
|
* @ingroup EPhysics_Body
|
||||||
|
*/
|
||||||
|
EAPI EPhysics_Body *ephysics_body_front_boundary_add(EPhysics_World *world);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* Create a physic back boundary.
|
||||||
|
*
|
||||||
|
* A physic front boundary will limit the bodies area and placed on the
|
||||||
|
* back of worlds render geometry - defined with
|
||||||
|
* @ref ephysics_world_render_geometry_set().
|
||||||
|
* It is placed on x-y plane, from x to x + width, from y to y + height.
|
||||||
|
*
|
||||||
|
* @param world The world this body will belong to.
|
||||||
|
* @return a new body or @c NULL, on erros.
|
||||||
|
* @see ephysics_world_render_geometry_set()
|
||||||
|
*
|
||||||
|
* @ingroup EPhysics_Body
|
||||||
|
*/
|
||||||
|
EAPI EPhysics_Body *ephysics_body_back_boundary_add(EPhysics_World *world);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
* Delete a physics body.
|
* Delete a physics body.
|
||||||
|
|
|
@ -99,7 +99,8 @@ _ephysics_body_soft_body_slices_apply(Evas_Object *obj)
|
||||||
EPHYSICS_BODY_SOFT_BODY_SMART_DATA_GET(obj, smart_data);
|
EPHYSICS_BODY_SOFT_BODY_SMART_DATA_GET(obj, smart_data);
|
||||||
body = smart_data->body;
|
body = smart_data->body;
|
||||||
rate = ephysics_world_rate_get(body->world);
|
rate = ephysics_world_rate_get(body->world);
|
||||||
ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL, &wh);
|
ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL,
|
||||||
|
NULL, &wh, NULL);
|
||||||
EINA_LIST_FOREACH(smart_data->slices, l, data)
|
EINA_LIST_FOREACH(smart_data->slices, l, data)
|
||||||
{
|
{
|
||||||
slice = (EPhysics_Body_Soft_Body_Slice *)data;
|
slice = (EPhysics_Body_Soft_Body_Slice *)data;
|
||||||
|
@ -189,7 +190,8 @@ _ephysics_body_soft_body_slices_init(EPhysics_Body *body, Evas_Object *obj)
|
||||||
|
|
||||||
evas = evas_object_evas_get(body->evas_obj);
|
evas = evas_object_evas_get(body->evas_obj);
|
||||||
EPHYSICS_BODY_SOFT_BODY_SMART_DATA_GET(obj, smart_data);
|
EPHYSICS_BODY_SOFT_BODY_SMART_DATA_GET(obj, smart_data);
|
||||||
ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL, &wh);
|
ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL, NULL,
|
||||||
|
&wh, NULL);
|
||||||
rate = ephysics_world_rate_get(body->world);
|
rate = ephysics_world_rate_get(body->world);
|
||||||
|
|
||||||
for (int i = 0; i < body->slices; i++)
|
for (int i = 0; i < body->slices; i++)
|
||||||
|
@ -874,7 +876,8 @@ _ephysics_body_move(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord
|
||||||
btVector3 body_scale;
|
btVector3 body_scale;
|
||||||
|
|
||||||
rate = ephysics_world_rate_get(body->world);
|
rate = ephysics_world_rate_get(body->world);
|
||||||
ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL, &height);
|
ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL,
|
||||||
|
NULL, &height, NULL);
|
||||||
height += wy;
|
height += wy;
|
||||||
|
|
||||||
mx = (x + body->w * body->cm.x) / rate;
|
mx = (x + body->w * body->cm.x) / rate;
|
||||||
|
@ -899,7 +902,8 @@ _ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Eva
|
||||||
int wy, height;
|
int wy, height;
|
||||||
btVector3 body_scale;
|
btVector3 body_scale;
|
||||||
|
|
||||||
ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL, &height);
|
ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL,
|
||||||
|
NULL, &height, NULL);
|
||||||
height += wy;
|
height += wy;
|
||||||
|
|
||||||
mx = (x + w * body->cm.x) / rate;
|
mx = (x + w * body->cm.x) / rate;
|
||||||
|
@ -1015,7 +1019,8 @@ _ephysics_body_evas_object_default_update(EPhysics_Body *body)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
trans = _ephysics_body_transform_get(body);
|
trans = _ephysics_body_transform_get(body);
|
||||||
ephysics_world_render_geometry_get(body->world, &wx, &wy, NULL, &wh);
|
ephysics_world_render_geometry_get(body->world, &wx, &wy, NULL,
|
||||||
|
NULL, &wh, NULL);
|
||||||
camera = ephysics_world_camera_get(body->world);
|
camera = ephysics_world_camera_get(body->world);
|
||||||
ephysics_camera_position_get(camera, &cx, &cy);
|
ephysics_camera_position_get(camera, &cx, &cy);
|
||||||
cx -= wx;
|
cx -= wx;
|
||||||
|
@ -1068,7 +1073,8 @@ _ephysics_body_outside_render_area_check(EPhysics_Body *body)
|
||||||
{
|
{
|
||||||
int wx, wy, ww, wh, bx, by, bw, bh;
|
int wx, wy, ww, wh, bx, by, bw, bh;
|
||||||
|
|
||||||
ephysics_world_render_geometry_get(body->world, &wx, &wy, &ww, &wh);
|
ephysics_world_render_geometry_get(body->world, &wx, &wy, NULL,
|
||||||
|
&ww, &wh, NULL);
|
||||||
ephysics_body_geometry_get(body, &bx, &by, NULL, &bw, &bh, NULL);
|
ephysics_body_geometry_get(body, &bx, &by, NULL, &bw, &bh, NULL);
|
||||||
|
|
||||||
// FIXME: check what should be done regarding rotated bodies
|
// FIXME: check what should be done regarding rotated bodies
|
||||||
|
@ -1186,7 +1192,7 @@ ephysics_body_contact_processed(EPhysics_Body *body, EPhysics_Body *contact_body
|
||||||
}
|
}
|
||||||
|
|
||||||
world = contact_body->world;
|
world = contact_body->world;
|
||||||
ephysics_world_render_geometry_get(world, NULL, &wy, NULL, &wh);
|
ephysics_world_render_geometry_get(world, NULL, &wy, NULL, NULL, &wh, NULL);
|
||||||
rate = ephysics_world_rate_get(world);
|
rate = ephysics_world_rate_get(world);
|
||||||
|
|
||||||
collision->contact_body = contact_body;
|
collision->contact_body = contact_body;
|
||||||
|
@ -1761,30 +1767,38 @@ ephysics_body_shape_add(EPhysics_World *world, EPhysics_Shape *shape)
|
||||||
void
|
void
|
||||||
ephysics_body_world_boundaries_resize(EPhysics_World *world)
|
ephysics_body_world_boundaries_resize(EPhysics_World *world)
|
||||||
{
|
{
|
||||||
Evas_Coord x, y, width, height;
|
Evas_Coord x, y, z, w, h, d;
|
||||||
EPhysics_Body *bottom, *top, *left, *right;
|
EPhysics_Body *bound;
|
||||||
|
|
||||||
ephysics_world_render_geometry_get(world, &x, &y, &width, &height);
|
ephysics_world_render_geometry_get(world, &x, &y, &z, &w, &h, &d);
|
||||||
|
|
||||||
bottom = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_BOTTOM);
|
bound = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_BOTTOM);
|
||||||
if (bottom)
|
if (bound)
|
||||||
ephysics_body_geometry_set(bottom, x, y + height, -5, width, 10, 10);
|
ephysics_body_geometry_set(bound, x, y + h, z, w, 10, d);
|
||||||
|
|
||||||
right = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_RIGHT);
|
bound = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_RIGHT);
|
||||||
if (right)
|
if (bound)
|
||||||
ephysics_body_geometry_set(right, x + width, y, -5, 10, height, 10);
|
ephysics_body_geometry_set(bound, x + w, y, z, 10, h, d);
|
||||||
|
|
||||||
left = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_LEFT);
|
bound = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_LEFT);
|
||||||
if (left)
|
if (bound)
|
||||||
ephysics_body_geometry_set(left, x - 10, y, -5, 10, height, 10);
|
ephysics_body_geometry_set(bound, x - 10, y, z, 10, h, d);
|
||||||
|
|
||||||
top = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_TOP);
|
bound = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_TOP);
|
||||||
if (top)
|
if (bound)
|
||||||
ephysics_body_geometry_set(top, x, y - 10, -5, width, 10, 10);
|
ephysics_body_geometry_set(bound, x, y - 10, z, w, 10, d);
|
||||||
|
|
||||||
|
bound = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_FRONT);
|
||||||
|
if (bound)
|
||||||
|
ephysics_body_geometry_set(bound, x, y, z - 10, w, h, 10);
|
||||||
|
|
||||||
|
bound = ephysics_world_boundary_get(world, EPHYSICS_WORLD_BOUNDARY_BACK);
|
||||||
|
if (bound)
|
||||||
|
ephysics_body_geometry_set(bound, x, y, z + d, w, h, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
static EPhysics_Body *
|
static EPhysics_Body *
|
||||||
_ephysics_body_boundary_add(EPhysics_World *world, EPhysics_World_Boundary boundary, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
_ephysics_body_boundary_add(EPhysics_World *world, EPhysics_World_Boundary boundary, Evas_Coord x, Evas_Coord y, Evas_Coord z, Evas_Coord w, Evas_Coord h, Evas_Coord d)
|
||||||
{
|
{
|
||||||
EPhysics_Body *body;
|
EPhysics_Body *body;
|
||||||
|
|
||||||
|
@ -1804,7 +1818,7 @@ _ephysics_body_boundary_add(EPhysics_World *world, EPhysics_World_Boundary bound
|
||||||
|
|
||||||
ephysics_body_mass_set(body, 0);
|
ephysics_body_mass_set(body, 0);
|
||||||
ephysics_world_boundary_set(world, boundary, body);
|
ephysics_world_boundary_set(world, boundary, body);
|
||||||
ephysics_body_geometry_set(body, x, y, -5, w, h, 10);
|
ephysics_body_geometry_set(body, x, y, z, w, h, d);
|
||||||
|
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
@ -1812,48 +1826,72 @@ _ephysics_body_boundary_add(EPhysics_World *world, EPhysics_World_Boundary bound
|
||||||
EAPI EPhysics_Body *
|
EAPI EPhysics_Body *
|
||||||
ephysics_body_top_boundary_add(EPhysics_World *world)
|
ephysics_body_top_boundary_add(EPhysics_World *world)
|
||||||
{
|
{
|
||||||
|
Evas_Coord x, y, z, w, d;
|
||||||
EPhysics_Body *body;
|
EPhysics_Body *body;
|
||||||
Evas_Coord x, y, w;
|
|
||||||
|
|
||||||
ephysics_world_render_geometry_get(world, &x, &y, &w, NULL);
|
ephysics_world_render_geometry_get(world, &x, &y, &z, &w, NULL, &d);
|
||||||
body = _ephysics_body_boundary_add(world, EPHYSICS_WORLD_BOUNDARY_TOP,
|
body = _ephysics_body_boundary_add(world, EPHYSICS_WORLD_BOUNDARY_TOP,
|
||||||
x, y - 10, w, 10);
|
x, y - 10, z, w, 10, d);
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI EPhysics_Body *
|
EAPI EPhysics_Body *
|
||||||
ephysics_body_bottom_boundary_add(EPhysics_World *world)
|
ephysics_body_bottom_boundary_add(EPhysics_World *world)
|
||||||
{
|
{
|
||||||
Evas_Coord x, y, w, h;
|
Evas_Coord x, y, z, w, h, d;
|
||||||
EPhysics_Body *body;
|
EPhysics_Body *body;
|
||||||
|
|
||||||
ephysics_world_render_geometry_get(world, &x, &y, &w, &h);
|
ephysics_world_render_geometry_get(world, &x, &y, &z, &w, &h, &d);
|
||||||
body = _ephysics_body_boundary_add(world, EPHYSICS_WORLD_BOUNDARY_BOTTOM,
|
body = _ephysics_body_boundary_add(world, EPHYSICS_WORLD_BOUNDARY_BOTTOM,
|
||||||
x, y + h, w, 10);
|
x, y + h, z, w, 10, d);
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI EPhysics_Body *
|
EAPI EPhysics_Body *
|
||||||
ephysics_body_left_boundary_add(EPhysics_World *world)
|
ephysics_body_left_boundary_add(EPhysics_World *world)
|
||||||
{
|
{
|
||||||
|
Evas_Coord x, y, z, h, d;
|
||||||
EPhysics_Body *body;
|
EPhysics_Body *body;
|
||||||
Evas_Coord x, y, h;
|
|
||||||
|
|
||||||
ephysics_world_render_geometry_get(world, &x, &y, NULL, &h);
|
ephysics_world_render_geometry_get(world, &x, &y, &z, NULL, &h, &d);
|
||||||
body = _ephysics_body_boundary_add(world, EPHYSICS_WORLD_BOUNDARY_LEFT,
|
body = _ephysics_body_boundary_add(world, EPHYSICS_WORLD_BOUNDARY_LEFT,
|
||||||
x - 10, y, 10, h);
|
x - 10, y, z, 10, h, d);
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI EPhysics_Body *
|
EAPI EPhysics_Body *
|
||||||
ephysics_body_right_boundary_add(EPhysics_World *world)
|
ephysics_body_right_boundary_add(EPhysics_World *world)
|
||||||
{
|
{
|
||||||
Evas_Coord x, y, w, h;
|
Evas_Coord x, y, z, w, h, d;
|
||||||
EPhysics_Body *body;
|
EPhysics_Body *body;
|
||||||
|
|
||||||
ephysics_world_render_geometry_get(world, &x, &y, &w, &h);
|
ephysics_world_render_geometry_get(world, &x, &y, &z, &w, &h, &d);
|
||||||
body = _ephysics_body_boundary_add(world, EPHYSICS_WORLD_BOUNDARY_RIGHT,
|
body = _ephysics_body_boundary_add(world, EPHYSICS_WORLD_BOUNDARY_RIGHT,
|
||||||
x + w, y, 10, h);
|
x + w, y, z, 10, h, d);
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI EPhysics_Body *
|
||||||
|
ephysics_body_front_boundary_add(EPhysics_World *world)
|
||||||
|
{
|
||||||
|
Evas_Coord x, y, z, w, h;
|
||||||
|
EPhysics_Body *body;
|
||||||
|
|
||||||
|
ephysics_world_render_geometry_get(world, &x, &y, &z, &w, &h, NULL);
|
||||||
|
body = _ephysics_body_boundary_add(world, EPHYSICS_WORLD_BOUNDARY_FRONT,
|
||||||
|
x, y, z - 10, w, h, 10);
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI EPhysics_Body *
|
||||||
|
ephysics_body_back_boundary_add(EPhysics_World *world)
|
||||||
|
{
|
||||||
|
Evas_Coord x, y, z, w, h, d;
|
||||||
|
EPhysics_Body *body;
|
||||||
|
|
||||||
|
ephysics_world_render_geometry_get(world, &x, &y, &z, &w, &h, &d);
|
||||||
|
body = _ephysics_body_boundary_add(world, EPHYSICS_WORLD_BOUNDARY_BACK,
|
||||||
|
x, y, z + d, w, h, 10);
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2059,7 +2097,8 @@ ephysics_body_geometry_get(const EPhysics_Body *body, Evas_Coord *x, Evas_Coord
|
||||||
scale = _ephysics_body_scale_get(body);
|
scale = _ephysics_body_scale_get(body);
|
||||||
|
|
||||||
rate = ephysics_world_rate_get(body->world);
|
rate = ephysics_world_rate_get(body->world);
|
||||||
ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL, &height);
|
ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL,
|
||||||
|
NULL, &height, NULL);
|
||||||
height += wy;
|
height += wy;
|
||||||
|
|
||||||
if (x) *x = round((trans.getOrigin().getX() - scale.x() / 2) * rate);
|
if (x) *x = round((trans.getOrigin().getX() - scale.x() / 2) * rate);
|
||||||
|
|
|
@ -37,7 +37,8 @@ ephysics_camera_target_moved(EPhysics_Camera *camera, EPhysics_Body *body)
|
||||||
int x, y, w, h, ww, wh, new_x, new_y;
|
int x, y, w, h, ww, wh, new_x, new_y;
|
||||||
|
|
||||||
ephysics_body_geometry_get(body, &x, &y, NULL, &w, &h, NULL);
|
ephysics_body_geometry_get(body, &x, &y, NULL, &w, &h, NULL);
|
||||||
ephysics_world_render_geometry_get(camera->world, NULL, NULL, &ww, &wh);
|
ephysics_world_render_geometry_get(camera->world, NULL, NULL, NULL,
|
||||||
|
&ww, &wh, NULL);
|
||||||
|
|
||||||
if (camera->track_horizontal)
|
if (camera->track_horizontal)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,6 +56,8 @@ typedef enum _EPhysics_World_Boundary
|
||||||
EPHYSICS_WORLD_BOUNDARY_BOTTOM,
|
EPHYSICS_WORLD_BOUNDARY_BOTTOM,
|
||||||
EPHYSICS_WORLD_BOUNDARY_LEFT,
|
EPHYSICS_WORLD_BOUNDARY_LEFT,
|
||||||
EPHYSICS_WORLD_BOUNDARY_RIGHT,
|
EPHYSICS_WORLD_BOUNDARY_RIGHT,
|
||||||
|
EPHYSICS_WORLD_BOUNDARY_FRONT,
|
||||||
|
EPHYSICS_WORLD_BOUNDARY_BACK,
|
||||||
EPHYSICS_WORLD_BOUNDARY_LAST
|
EPHYSICS_WORLD_BOUNDARY_LAST
|
||||||
} EPhysics_World_Boundary;
|
} EPhysics_World_Boundary;
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,16 @@ struct _EPhysics_Light {
|
||||||
|
|
||||||
struct _EPhysics_World {
|
struct _EPhysics_World {
|
||||||
EINA_INLIST;
|
EINA_INLIST;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
Evas_Coord x;
|
||||||
|
Evas_Coord y;
|
||||||
|
Evas_Coord z;
|
||||||
|
Evas_Coord w;
|
||||||
|
Evas_Coord h;
|
||||||
|
Evas_Coord d;
|
||||||
|
} geometry;
|
||||||
|
|
||||||
btBroadphaseInterface *broadphase;
|
btBroadphaseInterface *broadphase;
|
||||||
btDefaultCollisionConfiguration *collision;
|
btDefaultCollisionConfiguration *collision;
|
||||||
btCollisionDispatcher *dispatcher;
|
btCollisionDispatcher *dispatcher;
|
||||||
|
@ -58,10 +68,9 @@ struct _EPhysics_World {
|
||||||
btSoftBodySolver *soft_solver;
|
btSoftBodySolver *soft_solver;
|
||||||
btOverlapFilterCallback *filter_cb;
|
btOverlapFilterCallback *filter_cb;
|
||||||
|
|
||||||
EPhysics_Body *boundaries[4];
|
EPhysics_Body *boundaries[6];
|
||||||
EPhysics_Camera *camera;
|
EPhysics_Camera *camera;
|
||||||
EPhysics_Light *light;
|
EPhysics_Light *light;
|
||||||
Evas_Coord x, y, w, h;
|
|
||||||
Eina_Inlist *callbacks;
|
Eina_Inlist *callbacks;
|
||||||
Eina_Inlist *bodies;
|
Eina_Inlist *bodies;
|
||||||
Eina_List *to_delete;
|
Eina_List *to_delete;
|
||||||
|
@ -1196,7 +1205,7 @@ ephysics_world_bodies_get(const EPhysics_World *world)
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
ephysics_world_render_geometry_set(EPhysics_World *world, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
|
ephysics_world_render_geometry_set(EPhysics_World *world, Evas_Coord x, Evas_Coord y, Evas_Coord z, Evas_Coord w, Evas_Coord h, Evas_Coord d)
|
||||||
{
|
{
|
||||||
if (!world)
|
if (!world)
|
||||||
{
|
{
|
||||||
|
@ -1204,23 +1213,25 @@ ephysics_world_render_geometry_set(EPhysics_World *world, Evas_Coord x, Evas_Coo
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((w <= 0) || (h <= 0))
|
if ((w <= 0) || (h <= 0) || (d <= 0))
|
||||||
{
|
{
|
||||||
ERR("Invalid width or height sizes. They must to be positive values.");
|
ERR("Invalid width or height sizes. They must to be positive values.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
world->x = x;
|
world->geometry.x = x;
|
||||||
world->y = y;
|
world->geometry.y = y;
|
||||||
world->w = w;
|
world->geometry.z = z;
|
||||||
world->h = h;
|
world->geometry.w = w;
|
||||||
|
world->geometry.h = h;
|
||||||
|
world->geometry.d = d;
|
||||||
|
|
||||||
ephysics_body_world_boundaries_resize(world);
|
ephysics_body_world_boundaries_resize(world);
|
||||||
ephysics_camera_position_set(world->camera, x, y);
|
ephysics_camera_position_set(world->camera, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
ephysics_world_render_geometry_get(const EPhysics_World *world, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
|
ephysics_world_render_geometry_get(const EPhysics_World *world, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z, Evas_Coord *w, Evas_Coord *h, Evas_Coord *d)
|
||||||
{
|
{
|
||||||
if (!world)
|
if (!world)
|
||||||
{
|
{
|
||||||
|
@ -1228,10 +1239,12 @@ ephysics_world_render_geometry_get(const EPhysics_World *world, Evas_Coord *x, E
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x) *x = world->x;
|
if (x) *x = world->geometry.x;
|
||||||
if (y) *y = world->y;
|
if (y) *y = world->geometry.y;
|
||||||
if (w) *w = world->w;
|
if (z) *z = world->geometry.z;
|
||||||
if (h) *h = world->h;
|
if (w) *w = world->geometry.w;
|
||||||
|
if (h) *h = world->geometry.h;
|
||||||
|
if (d) *d = world->geometry.d;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
|
|
Loading…
Reference in New Issue