summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorOleksandr Shcherbina <o.shcherbina@samsung.com>2016-03-15 12:49:33 -0700
committerCedric Bail <cedric@osg.samsung.com>2016-03-15 12:49:39 -0700
commit296e8c22b039fd5669ad95375733bf214b23d71e (patch)
tree1aee03de378e591cbe0039bbaaa1c4f4788a8459 /src/lib
parentcdb72864853d5c3d81148c7a5846f39300eb46dc (diff)
evas.canvas3d: support static LOD technic
Summary: Main flow: add several meshes(with different number of polygons) in one node, enable LOD for node, set boundary distances to choose need mesh depend on distance to the camera node, render only need mesh. Add API's enable lod in evas_canvas3d_node module and set boundary distance to module evas_canvas3d_mesh module Refactored function evas_canvas3d_node_mesh_collect to calculate distance. Refactored _scene_render to have possibility pass to the render only need LOD mesh. Reviewers: cedric, Hermet, raster Subscribers: jpeg Differential Revision: https://phab.enlightenment.org/D3731 Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
Diffstat (limited to 'src/lib')
-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
7 files changed, 73 insertions, 3 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