summaryrefslogtreecommitdiff
path: root/src/lib/edje/edje_calc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/edje/edje_calc.c')
-rw-r--r--src/lib/edje/edje_calc.c112
1 files changed, 60 insertions, 52 deletions
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index e5f022d..66b1cee 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -3357,7 +3357,8 @@ static Eina_Bool
3357_edje_physics_world_geometry_check(EPhysics_World *world) 3357_edje_physics_world_geometry_check(EPhysics_World *world)
3358{ 3358{
3359 Evas_Coord w, h, d; 3359 Evas_Coord w, h, d;
3360 ephysics_world_render_geometry_get(world, NULL, NULL, NULL, &w, &h, &d); 3360 if (!EPH_LOAD()) return EINA_FALSE;
3361 EPH_CALL(ephysics_world_render_geometry_get)(world, NULL, NULL, NULL, &w, &h, &d);
3361 return w && h && d; 3362 return w && h && d;
3362} 3363}
3363 3364
@@ -3365,14 +3366,17 @@ static void
3365_edje_physics_body_props_update(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *pf, 3366_edje_physics_body_props_update(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *pf,
3366 Eina_Bool pos_update) 3367 Eina_Bool pos_update)
3367{ 3368{
3368 ephysics_body_linear_movement_enable_set(ep->body, 3369 if (!EPH_LOAD()) return;
3369 pf->physics->mov_freedom.lin.x, 3370 EPH_CALL(ephysics_body_linear_movement_enable_set)
3370 pf->physics->mov_freedom.lin.y, 3371 (ep->body,
3371 pf->physics->mov_freedom.lin.z); 3372 pf->physics->mov_freedom.lin.x,
3372 ephysics_body_angular_movement_enable_set(ep->body, 3373 pf->physics->mov_freedom.lin.y,
3373 pf->physics->mov_freedom.ang.x, 3374 pf->physics->mov_freedom.lin.z);
3374 pf->physics->mov_freedom.ang.y, 3375 EPH_CALL(ephysics_body_angular_movement_enable_set)
3375 pf->physics->mov_freedom.ang.z); 3376 (ep->body,
3377 pf->physics->mov_freedom.ang.x,
3378 pf->physics->mov_freedom.ang.y,
3379 pf->physics->mov_freedom.ang.z);
3376 3380
3377 /* Boundaries geometry and mass shouldn't be changed */ 3381 /* Boundaries geometry and mass shouldn't be changed */
3378 if (ep->part->physics_body < EDJE_PART_PHYSICS_BODY_BOUNDARY_TOP) 3382 if (ep->part->physics_body < EDJE_PART_PHYSICS_BODY_BOUNDARY_TOP)
@@ -3381,62 +3385,65 @@ _edje_physics_body_props_update(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *
3381 3385
3382 if (pos_update) 3386 if (pos_update)
3383 { 3387 {
3384 ephysics_body_move(ep->body, 3388 EPH_CALL(ephysics_body_move)
3385 ed->x + pf->final.x, 3389 (ep->body,
3386 ed->y + pf->final.y, 3390 ed->x + pf->final.x,
3387 pf->physics->z); 3391 ed->y + pf->final.y,
3392 pf->physics->z);
3388 ep->x = pf->final.x; 3393 ep->x = pf->final.x;
3389 ep->y = pf->final.y; 3394 ep->y = pf->final.y;
3390 ep->w = pf->final.w; 3395 ep->w = pf->final.w;
3391 ep->h = pf->final.h; 3396 ep->h = pf->final.h;
3392 } 3397 }
3393 3398
3394 ephysics_body_geometry_get(ep->body, &x, &y, &z, &w, &h, &d); 3399 EPH_CALL(ephysics_body_geometry_get)(ep->body, &x, &y, &z, &w, &h, &d);
3395 if ((d) && (d != pf->physics->depth)) 3400 if ((d) && (d != pf->physics->depth))
3396 ephysics_body_resize(ep->body, w, h, pf->physics->depth); 3401 EPH_CALL(ephysics_body_resize)(ep->body, w, h, pf->physics->depth);
3397 if (z != pf->physics->z) 3402 if (z != pf->physics->z)
3398 ephysics_body_move(ep->body, x, y, pf->physics->z); 3403 EPH_CALL(ephysics_body_move)(ep->body, x, y, pf->physics->z);
3399 3404
3400 ephysics_body_material_set(ep->body, pf->physics->material); 3405 EPH_CALL(ephysics_body_material_set)(ep->body, pf->physics->material);
3401 if (!pf->physics->material) 3406 if (!pf->physics->material)
3402 { 3407 {
3403 if (pf->physics->density) 3408 if (pf->physics->density)
3404 ephysics_body_density_set(ep->body, pf->physics->density); 3409 EPH_CALL(ephysics_body_density_set)(ep->body, pf->physics->density);
3405 else 3410 else
3406 ephysics_body_mass_set(ep->body, pf->physics->mass); 3411 EPH_CALL(ephysics_body_mass_set)(ep->body, pf->physics->mass);
3407 } 3412 }
3408 3413
3409 if ((ep->part->physics_body == EDJE_PART_PHYSICS_BODY_SOFT_BOX) || 3414 if ((ep->part->physics_body == EDJE_PART_PHYSICS_BODY_SOFT_BOX) ||
3410 (ep->part->physics_body == EDJE_PART_PHYSICS_BODY_SOFT_SPHERE) || 3415 (ep->part->physics_body == EDJE_PART_PHYSICS_BODY_SOFT_SPHERE) ||
3411 (ep->part->physics_body == EDJE_PART_PHYSICS_BODY_SOFT_CYLINDER) || 3416 (ep->part->physics_body == EDJE_PART_PHYSICS_BODY_SOFT_CYLINDER) ||
3412 (ep->part->physics_body == EDJE_PART_PHYSICS_BODY_CLOTH)) 3417 (ep->part->physics_body == EDJE_PART_PHYSICS_BODY_CLOTH))
3413 ephysics_body_soft_body_hardness_set(ep->body, 3418 EPH_CALL(ephysics_body_soft_body_hardness_set)
3414 pf->physics->hardness * 100); 3419 (ep->body, pf->physics->hardness * 100);
3415 } 3420 }
3416 3421
3417 if (!pf->physics->material) 3422 if (!pf->physics->material)
3418 { 3423 {
3419 ephysics_body_restitution_set(ep->body, pf->physics->restitution); 3424 EPH_CALL(ephysics_body_restitution_set)(ep->body, pf->physics->restitution);
3420 ephysics_body_friction_set(ep->body, pf->physics->friction); 3425 EPH_CALL(ephysics_body_friction_set)(ep->body, pf->physics->friction);
3421 } 3426 }
3422 3427
3423 ephysics_body_damping_set(ep->body, pf->physics->damping.linear, 3428 EPH_CALL(ephysics_body_damping_set)(ep->body, pf->physics->damping.linear,
3424 pf->physics->damping.angular); 3429 pf->physics->damping.angular);
3425 ephysics_body_sleeping_threshold_set(ep->body, pf->physics->sleep.linear, 3430 EPH_CALL(ephysics_body_sleeping_threshold_set)(ep->body, pf->physics->sleep.linear,
3426 pf->physics->sleep.angular); 3431 pf->physics->sleep.angular);
3427 ephysics_body_light_set(ep->body, pf->physics->light_on); 3432 EPH_CALL(ephysics_body_light_set)(ep->body, pf->physics->light_on);
3428 ephysics_body_back_face_culling_set(ep->body, pf->physics->backcull); 3433 EPH_CALL(ephysics_body_back_face_culling_set)(ep->body, pf->physics->backcull);
3429} 3434}
3430 3435
3431static void 3436static void
3432_edje_physics_body_update_cb(void *data, EPhysics_Body *body, void *event_info EINA_UNUSED) 3437_edje_physics_body_update_cb(void *data, EPhysics_Body *body, void *event_info EINA_UNUSED)
3433{ 3438{
3434 Edje_Real_Part *rp = data; 3439 Edje_Real_Part *rp = data;
3435 Edje *ed = ephysics_body_data_get(body); 3440 Edje *ed;
3436 3441
3437 ephysics_body_geometry_get(body, &(rp->x), &(rp->y), NULL, 3442 if (!EPH_LOAD()) return;
3438 &(rp->w), &(rp->h), NULL); 3443 ed = EPH_CALL(ephysics_body_data_get(body));
3439 ephysics_body_evas_object_update(body); 3444 EPH_CALL(ephysics_body_geometry_get)(body, &(rp->x), &(rp->y), NULL,
3445 &(rp->w), &(rp->h), NULL);
3446 EPH_CALL(ephysics_body_evas_object_update)(body);
3440 ed->dirty = EINA_TRUE; 3447 ed->dirty = EINA_TRUE;
3441} 3448}
3442 3449
@@ -3447,63 +3454,64 @@ _edje_physics_body_add(Edje *ed, Edje_Real_Part *rp, EPhysics_World *world)
3447 Edje_Physics_Face *pface; 3454 Edje_Physics_Face *pface;
3448 Eina_List *l; 3455 Eina_List *l;
3449 3456
3457 if (!EPH_LOAD()) return;
3450 switch (rp->part->physics_body) 3458 switch (rp->part->physics_body)
3451 { 3459 {
3452 case EDJE_PART_PHYSICS_BODY_RIGID_BOX: 3460 case EDJE_PART_PHYSICS_BODY_RIGID_BOX:
3453 rp->body = ephysics_body_box_add(world); 3461 rp->body = EPH_CALL(ephysics_body_box_add)(world);
3454 break; 3462 break;
3455 3463
3456 case EDJE_PART_PHYSICS_BODY_RIGID_SPHERE: 3464 case EDJE_PART_PHYSICS_BODY_RIGID_SPHERE:
3457 rp->body = ephysics_body_sphere_add(world); 3465 rp->body = EPH_CALL(ephysics_body_sphere_add)(world);
3458 break; 3466 break;
3459 3467
3460 case EDJE_PART_PHYSICS_BODY_RIGID_CYLINDER: 3468 case EDJE_PART_PHYSICS_BODY_RIGID_CYLINDER:
3461 rp->body = ephysics_body_cylinder_add(world); 3469 rp->body = EPH_CALL(ephysics_body_cylinder_add)(world);
3462 break; 3470 break;
3463 3471
3464 case EDJE_PART_PHYSICS_BODY_SOFT_BOX: 3472 case EDJE_PART_PHYSICS_BODY_SOFT_BOX:
3465 rp->body = ephysics_body_soft_box_add(world); 3473 rp->body = EPH_CALL(ephysics_body_soft_box_add)(world);
3466 break; 3474 break;
3467 3475
3468 case EDJE_PART_PHYSICS_BODY_SOFT_SPHERE: 3476 case EDJE_PART_PHYSICS_BODY_SOFT_SPHERE:
3469 rp->body = ephysics_body_soft_sphere_add(world, 0); 3477 rp->body = EPH_CALL(ephysics_body_soft_sphere_add)(world, 0);
3470 break; 3478 break;
3471 3479
3472 case EDJE_PART_PHYSICS_BODY_SOFT_CYLINDER: 3480 case EDJE_PART_PHYSICS_BODY_SOFT_CYLINDER:
3473 rp->body = ephysics_body_soft_cylinder_add(world); 3481 rp->body = EPH_CALL(ephysics_body_soft_cylinder_add)(world);
3474 break; 3482 break;
3475 3483
3476 case EDJE_PART_PHYSICS_BODY_CLOTH: 3484 case EDJE_PART_PHYSICS_BODY_CLOTH:
3477 rp->body = ephysics_body_cloth_add(world, 0, 0); 3485 rp->body = EPH_CALL(ephysics_body_cloth_add)(world, 0, 0);
3478 break; 3486 break;
3479 3487
3480 case EDJE_PART_PHYSICS_BODY_BOUNDARY_TOP: 3488 case EDJE_PART_PHYSICS_BODY_BOUNDARY_TOP:
3481 rp->body = ephysics_body_top_boundary_add(world); 3489 rp->body = EPH_CALL(ephysics_body_top_boundary_add)(world);
3482 resize = EINA_FALSE; 3490 resize = EINA_FALSE;
3483 break; 3491 break;
3484 3492
3485 case EDJE_PART_PHYSICS_BODY_BOUNDARY_BOTTOM: 3493 case EDJE_PART_PHYSICS_BODY_BOUNDARY_BOTTOM:
3486 rp->body = ephysics_body_bottom_boundary_add(world); 3494 rp->body = EPH_CALL(ephysics_body_bottom_boundary_add)(world);
3487 resize = EINA_FALSE; 3495 resize = EINA_FALSE;
3488 break; 3496 break;
3489 3497
3490 case EDJE_PART_PHYSICS_BODY_BOUNDARY_RIGHT: 3498 case EDJE_PART_PHYSICS_BODY_BOUNDARY_RIGHT:
3491 rp->body = ephysics_body_right_boundary_add(world); 3499 rp->body = EPH_CALL(ephysics_body_right_boundary_add)(world);
3492 resize = EINA_FALSE; 3500 resize = EINA_FALSE;
3493 break; 3501 break;
3494 3502
3495 case EDJE_PART_PHYSICS_BODY_BOUNDARY_LEFT: 3503 case EDJE_PART_PHYSICS_BODY_BOUNDARY_LEFT:
3496 rp->body = ephysics_body_left_boundary_add(world); 3504 rp->body = EPH_CALL(ephysics_body_left_boundary_add)(world);
3497 resize = EINA_FALSE; 3505 resize = EINA_FALSE;
3498 break; 3506 break;
3499 3507
3500 case EDJE_PART_PHYSICS_BODY_BOUNDARY_FRONT: 3508 case EDJE_PART_PHYSICS_BODY_BOUNDARY_FRONT:
3501 rp->body = ephysics_body_front_boundary_add(world); 3509 rp->body = EPH_CALL(ephysics_body_front_boundary_add)(world);
3502 resize = EINA_FALSE; 3510 resize = EINA_FALSE;
3503 break; 3511 break;
3504 3512
3505 case EDJE_PART_PHYSICS_BODY_BOUNDARY_BACK: 3513 case EDJE_PART_PHYSICS_BODY_BOUNDARY_BACK:
3506 rp->body = ephysics_body_back_boundary_add(world); 3514 rp->body = EPH_CALL(ephysics_body_back_boundary_add)(world);
3507 resize = EINA_FALSE; 3515 resize = EINA_FALSE;
3508 break; 3516 break;
3509 3517
@@ -3525,15 +3533,15 @@ _edje_physics_body_add(Edje *ed, Edje_Real_Part *rp, EPhysics_World *world)
3525 3533
3526 edje_object_file_set(edje_obj, ed->path, pface->source); 3534 edje_object_file_set(edje_obj, ed->path, pface->source);
3527 evas_object_resize(edje_obj, 1, 1); 3535 evas_object_resize(edje_obj, 1, 1);
3528 ephysics_body_face_evas_object_set(rp->body, pface->type, 3536 EPH_CALL(ephysics_body_face_evas_object_set)(rp->body, pface->type,
3529 edje_obj, EINA_FALSE); 3537 edje_obj, EINA_FALSE);
3530 rp->body_faces = eina_list_append(rp->body_faces, edje_obj); 3538 rp->body_faces = eina_list_append(rp->body_faces, edje_obj);
3531 } 3539 }
3532 3540
3533 ephysics_body_evas_object_set(rp->body, rp->object, resize); 3541 EPH_CALL(ephysics_body_evas_object_set)(rp->body, rp->object, resize);
3534 ephysics_body_event_callback_add(rp->body, EPHYSICS_CALLBACK_BODY_UPDATE, 3542 EPH_CALL(ephysics_body_event_callback_add)(rp->body, EPHYSICS_CALLBACK_BODY_UPDATE,
3535 _edje_physics_body_update_cb, rp); 3543 _edje_physics_body_update_cb, rp);
3536 ephysics_body_data_set(rp->body, ed); 3544 EPH_CALL(ephysics_body_data_set)(rp->body, ed);
3537} 3545}
3538 3546
3539#endif 3547#endif