From 03c52724db9438810e96363ffdc572f93a8c3fa4 Mon Sep 17 00:00:00 2001 From: Bruno Dilly Date: Thu, 25 Oct 2012 21:53:37 +0000 Subject: [PATCH] ephysics: apply perspective and back face culling on soft body SVN revision: 78478 --- legacy/ephysics/src/bin/test_flag.c | 2 ++ legacy/ephysics/src/lib/ephysics_body.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/legacy/ephysics/src/bin/test_flag.c b/legacy/ephysics/src/bin/test_flag.c index e6093f2..d5893bc 100644 --- a/legacy/ephysics/src/bin/test_flag.c +++ b/legacy/ephysics/src/bin/test_flag.c @@ -158,6 +158,8 @@ test_flag(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info _ ephysics_world_light_set(world, 300, 50, -200, 255, 255, 255, 0, 0, 0); ephysics_world_light_all_bodies_set(world, EINA_TRUE); + ephysics_camera_perspective_enabled_set(ephysics_world_camera_get(world), + EINA_TRUE); boundary = ephysics_body_bottom_boundary_add(test_data->world); ephysics_body_restitution_set(boundary, 0.65); diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp index f4f595e..73fa6c9 100644 --- a/legacy/ephysics/src/lib/ephysics_body.cpp +++ b/legacy/ephysics/src/lib/ephysics_body.cpp @@ -78,10 +78,14 @@ _ephysics_body_soft_body_slices_apply(void *data __UNUSED__, Evas *e __UNUSED__, int lr, lg, lb, ar, ag, ab; Evas_Coord lx, ly, lz; Eina_Bool light = EINA_FALSE; + EPhysics_Camera *camera; + int px, py, pz, foc; + Eina_Bool perspective = EINA_FALSE; soft_data = (EPhysics_Body_Soft_Body_Data *)evas_object_data_get(obj, SOFT_DATA); body = soft_data->body; + camera = ephysics_world_camera_get(body->world); rate = ephysics_world_rate_get(body->world); ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL, NULL, &wh, @@ -96,6 +100,12 @@ _ephysics_body_soft_body_slices_apply(void *data __UNUSED__, Evas *e __UNUSED__, light = EINA_TRUE; } + if (ephysics_camera_perspective_enabled_get(camera)) + { + ephysics_camera_perspective_get(camera, &px, &py, &pz, &foc); + perspective = EINA_TRUE; + } + EINA_LIST_FOREACH(soft_data->slices, l, list_data) { slice = (EPhysics_Body_Soft_Body_Slice *)list_data; @@ -131,6 +141,21 @@ _ephysics_body_soft_body_slices_apply(void *data __UNUSED__, Evas *e __UNUSED__, evas_map_point_coord_set(map, 2, x2, y2, z2); evas_map_point_coord_set(map, 3, x2, y2, z2); + if (perspective) + evas_map_util_3d_perspective(map, px, py, pz, foc); + + if (body->back_face_culling) + { + if (evas_map_util_clockwise_get(map)) + evas_object_show(slice->evas_obj); + else + { + evas_map_free(map); + evas_object_hide(slice->evas_obj); + continue; + } + } + if (light) evas_map_util_3d_lighting(map, lx, ly, lz, lr, lg, lb, ar, ag, ab); -- 2.7.4