summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_mesh.c17
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_mesh.eo14
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_node.c22
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_node.eo13
-rw-r--r--src/lib/evas/canvas/evas_canvas3d_scene.c1
-rw-r--r--src/lib/evas/canvas/evas_types.eot3
-rw-r--r--src/lib/evas/include/evas_private.h6
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_3d.c21
8 files changed, 91 insertions, 6 deletions
diff --git a/src/lib/evas/canvas/evas_canvas3d_mesh.c b/src/lib/evas/canvas/evas_canvas3d_mesh.c
index d19a1fc..606d399 100644
--- a/src/lib/evas/canvas/evas_canvas3d_mesh.c
+++ b/src/lib/evas/canvas/evas_canvas3d_mesh.c
@@ -133,6 +133,8 @@ _mesh_init(Evas_Canvas3D_Mesh_Data *pd)
133 pd->shadows_edges_filtering_level = 4; 133 pd->shadows_edges_filtering_level = 4;
134 pd->shadows_edges_size = 300.0; 134 pd->shadows_edges_size = 300.0;
135 pd->shadows_constant_bias = 0.00015; 135 pd->shadows_constant_bias = 0.00015;
136 pd->near_lod_boundary = 0.0;
137 pd->far_lod_boundary = 0.0;
136} 138}
137 139
138static inline void 140static inline void
@@ -1151,4 +1153,19 @@ _evas_canvas3d_mesh_convex_hull_data_get(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh
1151 return; 1153 return;
1152} 1154}
1153 1155
1156EOLIAN static void
1157_evas_canvas3d_mesh_lod_boundary_set(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd,
1158 Evas_Real near, Evas_Real far)
1159{
1160 pd->near_lod_boundary = near;
1161 pd->far_lod_boundary = far;
1162}
1163
1164EOLIAN static void
1165_evas_canvas3d_mesh_lod_boundary_get(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd,
1166 Evas_Real *near, Evas_Real *far)
1167{
1168 *near = pd->near_lod_boundary;
1169 *far = pd->far_lod_boundary;
1170}
1154#include "canvas/evas_canvas3d_mesh.eo.c" 1171#include "canvas/evas_canvas3d_mesh.eo.c"
diff --git a/src/lib/evas/canvas/evas_canvas3d_mesh.eo b/src/lib/evas/canvas/evas_canvas3d_mesh.eo
index d41b910..3cbae53 100644
--- a/src/lib/evas/canvas/evas_canvas3d_mesh.eo
+++ b/src/lib/evas/canvas/evas_canvas3d_mesh.eo
@@ -405,6 +405,20 @@ class Evas.Canvas3D.Mesh (Evas.Canvas3D.Object, Evas.Common_Interface, Efl.File)
405 bias: Evas.Real; [[Offset.]] 405 bias: Evas.Real; [[Offset.]]
406 } 406 }
407 } 407 }
408 @property lod_boundary {
409 set {
410 [[Set LOD boundary distances.]]
411 }
412 get {
413 [[Get LOD boundary distances.
414
415 See also @Evas.Canvas3D.Mesh.lod_boundary.set.]]
416 }
417 values {
418 near: Evas.Real; [[up boundary]]
419 far: Evas.Real; [[down boundary]]
420 }
421 }
408 } 422 }
409 implements { 423 implements {
410 Eo.Base.constructor; 424 Eo.Base.constructor;
diff --git a/src/lib/evas/canvas/evas_canvas3d_node.c b/src/lib/evas/canvas/evas_canvas3d_node.c
index 54f4f07..ec7633d 100644
--- a/src/lib/evas/canvas/evas_canvas3d_node.c
+++ b/src/lib/evas/canvas/evas_canvas3d_node.c
@@ -892,7 +892,12 @@ evas_canvas3d_node_mesh_collect(Evas_Canvas3D_Node *node, void *data)
892 if (pd->type == EVAS_CANVAS3D_NODE_TYPE_MESH) 892 if (pd->type == EVAS_CANVAS3D_NODE_TYPE_MESH)
893 { 893 {
894 scene_data->mesh_nodes = eina_list_append(scene_data->mesh_nodes, node); 894 scene_data->mesh_nodes = eina_list_append(scene_data->mesh_nodes, node);
895 895 /*In case LOD calculate distance to the camera node*/
896 if (pd->lod)
897 {
898 Evas_Canvas3D_Node_Data *pd_camera = eo_data_scope_get(scene_data->camera_node, MY_CLASS);
899 scene_data->lod_distance = eina_vector3_distance_get(&pd_camera->position, &pd->position_world);
900 }
896 /* calculation of tangent space for all meshes */ 901 /* calculation of tangent space for all meshes */
897 list_meshes = (Eina_List *)evas_canvas3d_node_mesh_list_get(node); 902 list_meshes = (Eina_List *)evas_canvas3d_node_mesh_list_get(node);
898 EINA_LIST_FOREACH(list_meshes, l, mesh) 903 EINA_LIST_FOREACH(list_meshes, l, mesh)
@@ -1034,6 +1039,7 @@ _evas_canvas3d_node_constructor(Eo *obj, Evas_Canvas3D_Node_Data *pd, Evas_Canva
1034 pd->scale_inherit = EINA_TRUE; 1039 pd->scale_inherit = EINA_TRUE;
1035 pd->data.mesh.node_meshes = 0; 1040 pd->data.mesh.node_meshes = 0;
1036 pd->billboard_target = NULL; 1041 pd->billboard_target = NULL;
1042 pd->lod = EINA_FALSE;
1037 1043
1038 evas_box3_set(&pd->aabb, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); 1044 evas_box3_set(&pd->aabb, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
1039 1045
@@ -1652,4 +1658,18 @@ _evas_canvas3d_node_billboard_target_get(Eo *obj EINA_UNUSED, Evas_Canvas3D_Node
1652{ 1658{
1653 return pd->billboard_target; 1659 return pd->billboard_target;
1654} 1660}
1661
1662EOLIAN static void
1663_evas_canvas3d_node_lod_enable_set(Eo *obj, Evas_Canvas3D_Node_Data *pd,
1664 Eina_Bool enable)
1665{
1666 pd->lod = enable;
1667 evas_canvas3d_object_change(obj, EVAS_CANVAS3D_STATE_NODE_LOD, NULL);
1668}
1669
1670EOLIAN static Eina_Bool
1671_evas_canvas3d_node_lod_enable_get(Eo *obj EINA_UNUSED, Evas_Canvas3D_Node_Data *pd)
1672{
1673 return pd->lod;
1674}
1655#include "canvas/evas_canvas3d_node.eo.c" 1675#include "canvas/evas_canvas3d_node.eo.c"
diff --git a/src/lib/evas/canvas/evas_canvas3d_node.eo b/src/lib/evas/canvas/evas_canvas3d_node.eo
index 2ae271a..bded324 100644
--- a/src/lib/evas/canvas/evas_canvas3d_node.eo
+++ b/src/lib/evas/canvas/evas_canvas3d_node.eo
@@ -368,6 +368,19 @@ class Evas.Canvas3D.Node (Evas.Canvas3D.Object, Evas.Common_Interface)
368 or $null if there're none.]] 368 or $null if there're none.]]
369 } 369 }
370 } 370 }
371 @property lod_enable {
372 set {
373 [[Enable behavior of node like LOD object.]]
374 }
375 get {
376 [[Get(check) status of node does node is LOD object.
377
378 See also @Evas.Canvas3D.Node.lod_enable.set.]]
379 }
380 values {
381 enable: bool; [[status property (true/false)]]
382 }
383 }
371 } 384 }
372 implements { 385 implements {
373 Eo.Base.destructor; 386 Eo.Base.destructor;
diff --git a/src/lib/evas/canvas/evas_canvas3d_scene.c b/src/lib/evas/canvas/evas_canvas3d_scene.c
index cb7ffc3..a8cc117 100644
--- a/src/lib/evas/canvas/evas_canvas3d_scene.c
+++ b/src/lib/evas/canvas/evas_canvas3d_scene.c
@@ -12,6 +12,7 @@ evas_canvas3d_scene_data_init(Evas_Canvas3D_Scene_Public_Data *data)
12 data->node_mesh_colors = NULL; 12 data->node_mesh_colors = NULL;
13 data->colors_node_mesh = NULL; 13 data->colors_node_mesh = NULL;
14 data->render_to_texture = EINA_FALSE; 14 data->render_to_texture = EINA_FALSE;
15 data->lod_distance = 0;
15} 16}
16 17
17void 18void
diff --git a/src/lib/evas/canvas/evas_types.eot b/src/lib/evas/canvas/evas_types.eot
index 6f37537..27a2830 100644
--- a/src/lib/evas/canvas/evas_types.eot
+++ b/src/lib/evas/canvas/evas_types.eot
@@ -346,7 +346,8 @@ enum Evas.Canvas3D.State
346 node_parent_orientation, 346 node_parent_orientation,
347 node_parent_scale, 347 node_parent_scale,
348 node_member, 348 node_member,
349 node_parent_billboard [[@since 1.14]] 349 node_parent_billboard, [[@since 1.14]]
350 node_lod [[@since 1.18]]
350} 351}
351 352
352enum Evas.Canvas3D.Space 353enum Evas.Canvas3D.Space
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index 525ff1d..ceee4a7 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -289,6 +289,7 @@ struct _Evas_Canvas3D_Node
289 Eina_Bool position_inherit : 1; 289 Eina_Bool position_inherit : 1;
290 Eina_Bool orientation_inherit : 1; 290 Eina_Bool orientation_inherit : 1;
291 Eina_Bool scale_inherit : 1; 291 Eina_Bool scale_inherit : 1;
292 Eina_Bool lod : 1;
292}; 293};
293 294
294struct _Evas_Canvas3D_Camera 295struct _Evas_Canvas3D_Camera
@@ -387,6 +388,8 @@ struct _Evas_Canvas3D_Mesh
387 int shadows_edges_filtering_level; 388 int shadows_edges_filtering_level;
388 Evas_Real shadows_edges_size; 389 Evas_Real shadows_edges_size;
389 Evas_Real shadows_constant_bias; 390 Evas_Real shadows_constant_bias;
391 Evas_Real near_lod_boundary;
392 Evas_Real far_lod_boundary;
390}; 393};
391 394
392struct _Evas_Canvas3D_Texture 395struct _Evas_Canvas3D_Texture
@@ -437,7 +440,6 @@ struct _Evas_Canvas3D_Scene_Public_Data
437 Eina_List *mesh_nodes; 440 Eina_List *mesh_nodes;
438 Eina_Bool shadows_enabled :1; 441 Eina_Bool shadows_enabled :1;
439 Eina_Bool color_pick_enabled :1; 442 Eina_Bool color_pick_enabled :1;
440
441 Eina_Hash *node_mesh_colors; 443 Eina_Hash *node_mesh_colors;
442 Eina_Hash *colors_node_mesh; 444 Eina_Hash *colors_node_mesh;
443 445
@@ -445,6 +447,8 @@ struct _Evas_Canvas3D_Scene_Public_Data
445 Evas_Real depth_offset; 447 Evas_Real depth_offset;
446 Evas_Real depth_constant; 448 Evas_Real depth_constant;
447 Eina_Bool render_to_texture; 449 Eina_Bool render_to_texture;
450
451 unsigned int lod_distance;
448}; 452};
449 453
450struct _Evas_Canvas3D_Pick_Data 454struct _Evas_Canvas3D_Pick_Data
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 fd3e264..5ca627f 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_3d.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_3d.c
@@ -1,6 +1,16 @@
1#include "evas_gl_private.h" 1#include "evas_gl_private.h"
2#include "evas_gl_3d_private.h" 2#include "evas_gl_3d_private.h"
3 3
4#define CHECK_LOD_DISTANCE \
5 if (pd_mesh_node->lod) \
6 { \
7 if (pdmesh->near_lod_boundary > data->lod_distance) \
8 continue; \
9 else if ((pdmesh->near_lod_boundary < data->lod_distance) && \
10 (pdmesh->far_lod_boundary < data->lod_distance)) \
11 continue; \
12 }
13
4#define RENDER_MESH_NODE_ITERATE_BEGIN(param) \ 14#define RENDER_MESH_NODE_ITERATE_BEGIN(param) \
5 Eina_Matrix4 matrix_mv; \ 15 Eina_Matrix4 matrix_mv; \
6 Eina_Matrix4 matrix_mvp; \ 16 Eina_Matrix4 matrix_mvp; \
@@ -11,8 +21,9 @@
11 it = eina_hash_iterator_data_new(pd_mesh_node->data.mesh.node_meshes); \ 21 it = eina_hash_iterator_data_new(pd_mesh_node->data.mesh.node_meshes); \
12 while (eina_iterator_next(it, &ptr)) \ 22 while (eina_iterator_next(it, &ptr)) \
13 { \ 23 { \
14 Evas_Canvas3D_Node_Mesh *nm = (Evas_Canvas3D_Node_Mesh *)ptr; \ 24 Evas_Canvas3D_Node_Mesh *nm = (Evas_Canvas3D_Node_Mesh *)ptr; \
15 Evas_Canvas3D_Mesh_Data *pdmesh = eo_data_scope_get(nm->mesh, EVAS_CANVAS3D_MESH_CLASS); 25 Evas_Canvas3D_Mesh_Data *pdmesh = eo_data_scope_get(nm->mesh, EVAS_CANVAS3D_MESH_CLASS); \
26 CHECK_LOD_DISTANCE
16 27
17#define RENDER_MESH_NODE_ITERATE_END \ 28#define RENDER_MESH_NODE_ITERATE_END \
18 } \ 29 } \
@@ -1282,6 +1293,10 @@ _scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_Canvas3D_Scen
1282 { 1293 {
1283 Evas_Canvas3D_Node_Mesh *nm = (Evas_Canvas3D_Node_Mesh *)ptr; 1294 Evas_Canvas3D_Node_Mesh *nm = (Evas_Canvas3D_Node_Mesh *)ptr;
1284 Evas_Canvas3D_Mesh_Data *pdmesh = eo_data_scope_get(nm->mesh, EVAS_CANVAS3D_MESH_CLASS); 1295 Evas_Canvas3D_Mesh_Data *pdmesh = eo_data_scope_get(nm->mesh, EVAS_CANVAS3D_MESH_CLASS);
1296 /*In case LOD enable pass in render only LOD meshes in dependences of the
1297 distance to the camera node:
1298 near_boundary <= distance <= far_boundary*/
1299 CHECK_LOD_DISTANCE
1285 if (data->shadows_enabled) 1300 if (data->shadows_enabled)
1286 { 1301 {
1287 pdmesh->shadowed = EINA_TRUE; 1302 pdmesh->shadowed = EINA_TRUE;
@@ -1399,6 +1414,6 @@ e3d_drawable_texture_pixel_color_get(GLuint tex EINA_UNUSED, int x, int y,
1399 1414
1400 glBindFramebuffer(GL_FRAMEBUFFER, d->fbo); 1415 glBindFramebuffer(GL_FRAMEBUFFER, d->fbo);
1401} 1416}
1402 1417#undef CHECK_LOD_DISTANCE
1403#undef RENDER_MESH_NODE_ITERATE_BEGIN 1418#undef RENDER_MESH_NODE_ITERATE_BEGIN
1404#undef RENDER_MESH_NODE_ITERATE_END 1419#undef RENDER_MESH_NODE_ITERATE_END