From: Cedric BAIL Date: Thu, 19 Mar 2015 16:34:46 +0000 (+0100) Subject: evas: use switch instead of a serie of if for cleaner example. X-Git-Tag: v1.14.0-alpha1~163 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4935582355d240ba5600ffb9354bb4185575afb3;p=platform%2Fupstream%2Fefl.git evas: use switch instead of a serie of if for cleaner example. --- diff --git a/src/examples/evas/evas-3d-frustum.c b/src/examples/evas/evas-3d-frustum.c index 462159a..efeb8b3 100644 --- a/src/examples/evas/evas-3d-frustum.c +++ b/src/examples/evas/evas-3d-frustum.c @@ -106,42 +106,52 @@ _redraw_bounding_object(void *data) eo_do(scene->mesh_node, evas_3d_node_mesh_del(current_mesh)); } - if (key == EVAS_3D_FRUSTUM_MODE_BSPHERE) + switch (key) { - eo_do(scene->mesh_node_model, - evas_3d_node_bounding_sphere_get(&x0, &y0, &z0, &radius)); - current_mesh = scene->mesh_sphere; - px = x0; - py = y0; - pz = z0; - sx = sy = sz = 2.0 * radius; - } - else if (key == EVAS_3D_FRUSTUM_MODE_AABB) - { - eo_do(scene->mesh_node_model, evas_3d_node_bounding_box_get(&x0, &y0, &z0, - &x1, &y1, &z1)); - current_mesh = scene->mesh_aabb; - px = (x1 + x0) / 2; - py = (y1 + y0) / 2; - pz = (z1 + z0) / 2; - sx = x1 - x0; - sy = y1 - y0; - sz = z1 - z0; - } - else if (key == EVAS_3D_FRUSTUM_MODE_CENTRAL_POINT) - { - eo_do(scene->mesh_node_model, - evas_3d_node_bounding_sphere_get(&x0, &y0, &z0, &radius)); - current_mesh = scene->mesh_sphere; - px = x0; - py = y0; - pz = z0; - sx = sy = sz = 0.1 * radius; + case EVAS_3D_FRUSTUM_MODE_BSPHERE: + { + eo_do(scene->mesh_node_model, + evas_3d_node_bounding_sphere_get(&x0, &y0, &z0, &radius)); + current_mesh = scene->mesh_sphere; + px = x0; + py = y0; + pz = z0; + sx = sy = sz = 2.0 * radius; + break; + } + case EVAS_3D_FRUSTUM_MODE_AABB: + { + eo_do(scene->mesh_node_model, + evas_3d_node_bounding_box_get(&x0, &y0, &z0, + &x1, &y1, &z1)); + current_mesh = scene->mesh_aabb; + px = (x1 + x0) / 2; + py = (y1 + y0) / 2; + pz = (z1 + z0) / 2; + sx = x1 - x0; + sy = y1 - y0; + sz = z1 - z0; + break; + } + case EVAS_3D_FRUSTUM_MODE_CENTRAL_POINT: + { + eo_do(scene->mesh_node_model, + evas_3d_node_bounding_sphere_get(&x0, &y0, &z0, &radius)); + current_mesh = scene->mesh_sphere; + px = x0; + py = y0; + pz = z0; + sx = sy = sz = 0.1 * radius; + break; + } + default: + return ECORE_CALLBACK_RENEW; } - eo_do(scene->mesh_node, evas_3d_node_mesh_add(current_mesh), - evas_3d_node_position_set(px, py, pz), - evas_3d_node_scale_set(sx, sy, sz)); + eo_do(scene->mesh_node, + evas_3d_node_mesh_add(current_mesh), + evas_3d_node_position_set(px, py, pz), + evas_3d_node_scale_set(sx, sy, sz)); return ECORE_CALLBACK_RENEW; }