From 3804a911e11b5306a43aae6d3eb6a16c8dde7048 Mon Sep 17 00:00:00 2001 From: Bruno Dilly Date: Thu, 25 Oct 2012 21:53:23 +0000 Subject: [PATCH] ephysics: support light on soft bodies SVN revision: 78476 --- legacy/ephysics/src/bin/test_flag.c | 3 +++ legacy/ephysics/src/lib/ephysics_body.cpp | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/legacy/ephysics/src/bin/test_flag.c b/legacy/ephysics/src/bin/test_flag.c index 909404d911..e6093f2f95 100644 --- a/legacy/ephysics/src/bin/test_flag.c +++ b/legacy/ephysics/src/bin/test_flag.c @@ -156,6 +156,9 @@ test_flag(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info _ WIDTH - 100, FLOOR_Y - 40, DEPTH); test_data->world = world; + ephysics_world_light_set(world, 300, 50, -200, 255, 255, 255, 0, 0, 0); + ephysics_world_light_all_bodies_set(world, EINA_TRUE); + boundary = ephysics_body_bottom_boundary_add(test_data->world); ephysics_body_restitution_set(boundary, 0.65); ephysics_body_friction_set(boundary, 4); diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp index ebb4e1f4c1..115589933c 100644 --- a/legacy/ephysics/src/lib/ephysics_body.cpp +++ b/legacy/ephysics/src/lib/ephysics_body.cpp @@ -75,6 +75,9 @@ _ephysics_body_soft_body_slices_apply(void *data __UNUSED__, Evas *e __UNUSED__, EPhysics_Body_Soft_Body_Data *soft_data; EPhysics_Body *body; btVector3 b0, b1; + int lr, lg, lb, ar, ag, ab; + Evas_Coord lx, ly, lz; + Eina_Bool light = EINA_FALSE; soft_data = (EPhysics_Body_Soft_Body_Data *)evas_object_data_get(obj, SOFT_DATA); @@ -83,6 +86,16 @@ _ephysics_body_soft_body_slices_apply(void *data __UNUSED__, Evas *e __UNUSED__, ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL, NULL, &wh, NULL); + + if ((body->light_apply) || + (ephysics_world_light_all_bodies_get(body->world))) + { + + if (ephysics_world_light_get(body->world, &lx, &ly, &lz, + &lr, &lg, &lb, &ar, &ag, &ab)) + light = EINA_TRUE; + } + EINA_LIST_FOREACH(soft_data->slices, l, list_data) { slice = (EPhysics_Body_Soft_Body_Slice *)list_data; @@ -118,6 +131,9 @@ _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 (light) + evas_map_util_3d_lighting(map, lx, ly, lz, lr, lg, lb, ar, ag, ab); + evas_object_map_set(slice->evas_obj, map); evas_object_map_enable_set(slice->evas_obj, EINA_TRUE); evas_map_free(map);