summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmytro Dadyka <d.dadyka@samsung.com>2014-12-03 09:48:55 +0100
committerCedric BAIL <cedric@osg.samsung.com>2014-12-03 09:58:02 +0100
commit720a3726e988d5a2293836a816a1c10254246c89 (patch)
tree77a227c887f7fe94763d575b352382c4ab23595e
parent682d7fab54f763212cd40c0ad0b24dba1717ce7f (diff)
Evas: Evas_3D - Add check of visibilty node.
If the node is not visible, it is not rendered, which improves performance. @feature. Reviewers: raster, Hermet, cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1722 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_3d.c88
1 files changed, 51 insertions, 37 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_3d.c b/src/modules/evas/engines/gl_common/evas_gl_3d.c
index 7b19939..ac17007 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_3d.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_3d.c
@@ -1239,6 +1239,7 @@ void _shadowmap_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3D_S
1239 Evas_3D_Node *n; 1239 Evas_3D_Node *n;
1240 Evas_3D_Shade_Mode shade_mode; 1240 Evas_3D_Shade_Mode shade_mode;
1241 Evas_Color c = {1.0, 1.0, 1.0}; 1241 Evas_Color c = {1.0, 1.0, 1.0};
1242 Evas_Mat4 matrix_vp;
1242 1243
1243 glEnable(GL_POLYGON_OFFSET_FILL); 1244 glEnable(GL_POLYGON_OFFSET_FILL);
1244 glPolygonOffset(4.0, 10000.0); 1245 glPolygonOffset(4.0, 10000.0);
@@ -1249,6 +1250,10 @@ void _shadowmap_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3D_S
1249 Evas_3D_Node_Data *pd_light_node = eo_data_scope_get(light, EVAS_3D_NODE_CLASS); 1250 Evas_3D_Node_Data *pd_light_node = eo_data_scope_get(light, EVAS_3D_NODE_CLASS);
1250 Evas_3D_Light_Data *pd = eo_data_scope_get(pd_light_node->data.light.light, EVAS_3D_LIGHT_CLASS); 1251 Evas_3D_Light_Data *pd = eo_data_scope_get(pd_light_node->data.light.light, EVAS_3D_LIGHT_CLASS);
1251 1252
1253 Evas_Vec4 planes[6];
1254 evas_mat4_multiply(&matrix_vp, &pd->projection, matrix_light_eye);
1255 evas_frustum_calculate(planes, &matrix_vp);
1256
1252 EINA_LIST_FOREACH(data->mesh_nodes, l, n) 1257 EINA_LIST_FOREACH(data->mesh_nodes, l, n)
1253 { 1258 {
1254 Evas_Mat4 matrix_mv; 1259 Evas_Mat4 matrix_mv;
@@ -1257,23 +1262,27 @@ void _shadowmap_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3D_S
1257 void *ptr; 1262 void *ptr;
1258 1263
1259 Evas_3D_Node_Data *pd_mesh_node = eo_data_scope_get(n, EVAS_3D_NODE_CLASS); 1264 Evas_3D_Node_Data *pd_mesh_node = eo_data_scope_get(n, EVAS_3D_NODE_CLASS);
1260 evas_mat4_multiply(&matrix_mv, matrix_light_eye, &pd_mesh_node->data.mesh.matrix_local_to_world); 1265
1261 evas_mat4_multiply(&matrix_mvp, &pd->projection, 1266 if (evas_is_sphere_in_frustum(&pd_mesh_node->bsphere, planes))
1267 {
1268
1269 evas_mat4_multiply(&matrix_mv, matrix_light_eye, &pd_mesh_node->data.mesh.matrix_local_to_world);
1270 evas_mat4_multiply(&matrix_mvp, &pd->projection,
1262 &matrix_mv); 1271 &matrix_mv);
1263 1272
1264 it = eina_hash_iterator_data_new(pd_mesh_node->data.mesh.node_meshes); 1273 it = eina_hash_iterator_data_new(pd_mesh_node->data.mesh.node_meshes);
1265 1274
1266 while (eina_iterator_next(it, &ptr)) 1275 while (eina_iterator_next(it, &ptr))
1267 { 1276 {
1268 Evas_3D_Node_Mesh *nm = (Evas_3D_Node_Mesh *)ptr; 1277 Evas_3D_Node_Mesh *nm = (Evas_3D_Node_Mesh *)ptr;
1269 Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(nm->mesh, EVAS_3D_MESH_CLASS); 1278 Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(nm->mesh, EVAS_3D_MESH_CLASS);
1270 shade_mode = pdmesh->shade_mode; 1279 shade_mode = pdmesh->shade_mode;
1271 pdmesh->shade_mode = EVAS_3D_SHADE_MODE_SHADOW_MAP_RENDER; 1280 pdmesh->shade_mode = EVAS_3D_SHADE_MODE_SHADOW_MAP_RENDER;
1272 _mesh_draw(renderer, nm->mesh, nm->frame, light, matrix_light_eye, &matrix_mv, &matrix_mvp, &matrix_mvp); 1281 _mesh_draw(renderer, nm->mesh, nm->frame, light, matrix_light_eye, &matrix_mv, &matrix_mvp, &matrix_mvp);
1273 pdmesh->shade_mode = shade_mode; 1282 pdmesh->shade_mode = shade_mode;
1283 }
1284 eina_iterator_free(it);
1274 } 1285 }
1275
1276 eina_iterator_free(it);
1277 } 1286 }
1278 1287
1279 glDisable(GL_POLYGON_OFFSET_FILL); 1288 glDisable(GL_POLYGON_OFFSET_FILL);
@@ -1287,9 +1296,10 @@ e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3
1287 Evas_3D_Node *n; 1296 Evas_3D_Node *n;
1288 const Evas_Mat4 *matrix_eye; 1297 const Evas_Mat4 *matrix_eye;
1289 Evas_3D_Node *light; 1298 Evas_3D_Node *light;
1290 Evas_Mat4 matrix_light_eye; 1299 Evas_Mat4 matrix_light_eye, matrix_vp;;
1291 Evas_3D_Light_Data *ld = NULL; 1300 Evas_3D_Light_Data *ld = NULL;
1292 Evas_3D_Node_Data *pd_light_node; 1301 Evas_3D_Node_Data *pd_light_node;
1302 Evas_Vec4 planes[6];
1293 1303
1294 /* Get eye matrix. */ 1304 /* Get eye matrix. */
1295 Evas_3D_Node_Data *pd_camera_node = eo_data_scope_get(data->camera_node, EVAS_3D_NODE_CLASS); 1305 Evas_3D_Node_Data *pd_camera_node = eo_data_scope_get(data->camera_node, EVAS_3D_NODE_CLASS);
@@ -1311,6 +1321,9 @@ e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3
1311 /* Set up render target. */ 1321 /* Set up render target. */
1312 e3d_renderer_target_set(renderer, drawable); 1322 e3d_renderer_target_set(renderer, drawable);
1313 e3d_renderer_clear(renderer, &data->bg_color); 1323 e3d_renderer_clear(renderer, &data->bg_color);
1324
1325 evas_mat4_multiply(&matrix_vp, &pd->projection, matrix_eye);
1326 evas_frustum_calculate(planes, &matrix_vp);
1314 EINA_LIST_FOREACH(data->mesh_nodes, l, n) 1327 EINA_LIST_FOREACH(data->mesh_nodes, l, n)
1315 { 1328 {
1316 Evas_Mat4 matrix_mv; 1329 Evas_Mat4 matrix_mv;
@@ -1320,36 +1333,37 @@ e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3
1320 void *ptr; 1333 void *ptr;
1321 Evas_3D_Node_Data *pd_mesh_node = eo_data_scope_get(n, EVAS_3D_NODE_CLASS); 1334 Evas_3D_Node_Data *pd_mesh_node = eo_data_scope_get(n, EVAS_3D_NODE_CLASS);
1322 1335
1323 if (data->shadows_enabled) 1336 // TODO Add other frustum shapes
1337 if (evas_is_sphere_in_frustum(&pd_mesh_node->bsphere, planes))
1324 { 1338 {
1325 evas_mat4_multiply(&matrix_mv, &matrix_light_eye,
1326 &pd_mesh_node->data.mesh.matrix_local_to_world);
1327 if (ld)
1328 evas_mat4_multiply(&matrix_light, &ld->projection,
1329 &matrix_mv);
1330 }
1331 1339
1332 evas_mat4_multiply(&matrix_mv, matrix_eye, &pd_mesh_node->data.mesh.matrix_local_to_world); 1340 if (data->shadows_enabled)
1333 evas_mat4_multiply(&matrix_mvp, &pd->projection, 1341 {
1334 &matrix_mv); 1342 evas_mat4_multiply(&matrix_mv, &matrix_light_eye,
1343 &pd_mesh_node->data.mesh.matrix_local_to_world);
1344 evas_mat4_multiply(&matrix_light, &ld->projection,
1345 &matrix_mv);
1346 }
1335 1347
1336 it = eina_hash_iterator_data_new(pd_mesh_node->data.mesh.node_meshes); 1348 evas_mat4_multiply(&matrix_mv, matrix_eye, &pd_mesh_node->data.mesh.matrix_local_to_world);
1349 evas_mat4_multiply(&matrix_mvp, &pd->projection,
1350 &matrix_mv);
1337 1351
1338 while (eina_iterator_next(it, &ptr)) 1352 it = eina_hash_iterator_data_new(pd_mesh_node->data.mesh.node_meshes);
1339 { 1353 while (eina_iterator_next(it, &ptr))
1340 Evas_3D_Node_Mesh *nm = (Evas_3D_Node_Mesh *)ptr;
1341 Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(nm->mesh, EVAS_3D_MESH_CLASS);
1342 if (data->shadows_enabled)
1343 { 1354 {
1344 pdmesh->shadowed = EINA_TRUE; 1355 Evas_3D_Node_Mesh *nm = (Evas_3D_Node_Mesh *)ptr;
1345 _mesh_draw(renderer, nm->mesh, nm->frame, light, matrix_eye, &matrix_mv, &matrix_mvp, &matrix_light); 1356 Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(nm->mesh, EVAS_3D_MESH_CLASS);
1346 pdmesh->shadowed = EINA_FALSE; 1357 if (data->shadows_enabled)
1358 {
1359 pdmesh->shadowed = EINA_TRUE;
1360 _mesh_draw(renderer, nm->mesh, nm->frame, light, matrix_eye, &matrix_mv, &matrix_mvp, &matrix_light);
1361 pdmesh->shadowed = EINA_FALSE;
1362 }
1363 else _mesh_draw(renderer, nm->mesh, nm->frame, light, matrix_eye, &matrix_mv, &matrix_mvp, NULL);
1347 } 1364 }
1348 else _mesh_draw(renderer, nm->mesh, nm->frame, light, matrix_eye, &matrix_mv, &matrix_mvp, NULL); 1365 eina_iterator_free(it);
1349 } 1366 }
1350
1351 eina_iterator_free(it);
1352 } 1367 }
1353
1354 e3d_renderer_flush(renderer); 1368 e3d_renderer_flush(renderer);
1355} 1369}