summaryrefslogtreecommitdiff
path: root/src/lib/evas/include/evas_3d_utils.h
diff options
context:
space:
mode:
authorperepelits.m <perepelits.m@samsung.com>2015-11-09 14:29:44 -0800
committerCedric BAIL <cedric@osg.samsung.com>2015-11-09 14:29:46 -0800
commit3031a4a5c6e7c57c3d40e1a65b3641961c30002a (patch)
tree544401d9f8579bc1a0b0dc7eba9a9143c270d0a3 /src/lib/evas/include/evas_3d_utils.h
parent0c1bb7d7b3d4e9a91ae33455ab761d7e9405c2df (diff)
evas: API for Convex Hull in Evas.Canvas3d
Summary: This API builds vertex and index data of convex hull around the given mesh. Reviewers: raster, perepelits.m, Hermet, cedric Reviewed By: cedric Subscribers: cedric, artem.popov Differential Revision: https://phab.enlightenment.org/D2799 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/lib/evas/include/evas_3d_utils.h')
-rw-r--r--src/lib/evas/include/evas_3d_utils.h28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/lib/evas/include/evas_3d_utils.h b/src/lib/evas/include/evas_3d_utils.h
index 413884a7b2..dfa0b3946b 100644
--- a/src/lib/evas/include/evas_3d_utils.h
+++ b/src/lib/evas/include/evas_3d_utils.h
@@ -2213,7 +2213,7 @@ tangent_new_basis(Evas_Vec3 *out, Evas_Triangle3 *triangle,
2213} 2213}
2214 2214
2215static inline void 2215static inline void
2216convex_hull_vertex_set(Evas_Triangle3 *el, int *vertex_count, float **vertex, 2216convex_hull_vertex_set(Evas_Triangle3 *el, unsigned short int *vertex_count, float **vertex,
2217 unsigned short int **index, unsigned int k, int *leader, int coord) 2217 unsigned short int **index, unsigned int k, int *leader, int coord)
2218{ 2218{
2219 int color_coords, normal_coords; 2219 int color_coords, normal_coords;
@@ -2404,8 +2404,8 @@ convex_hull_first_tr_get(float *data, int count, int stride)
2404} 2404}
2405 2405
2406static inline void 2406static inline void
2407evas_convex_hull_get(float *data, int count, int stride, float **vertex, 2407evas_convex_hull_get(float *data, int count, int stride, Eina_Inarray *vertex,
2408 unsigned short int **index, int *vertex_count, int *index_count) 2408 Eina_Inarray *index)
2409{ 2409{
2410 Evas_Triangle3 first_elem, second_elem, *third_elem = NULL, *el = NULL; 2410 Evas_Triangle3 first_elem, second_elem, *third_elem = NULL, *el = NULL;
2411 2411
@@ -2424,7 +2424,7 @@ evas_convex_hull_get(float *data, int count, int stride, float **vertex,
2424 int i = 0, j = 0, new_stride = 0, leader = 0; 2424 int i = 0, j = 0, new_stride = 0, leader = 0;
2425 int if_two = 0, first_exist_twice = 0, second_exist_twice = 0; 2425 int if_two = 0, first_exist_twice = 0, second_exist_twice = 0;
2426 unsigned int k = 0; 2426 unsigned int k = 0;
2427 unsigned short int *found_index = NULL; 2427 unsigned short int *found_index = NULL, index_count, vertex_count = 0;
2428 2428
2429 Eina_Bool exist1 = EINA_FALSE, pushed; 2429 Eina_Bool exist1 = EINA_FALSE, pushed;
2430 Eina_Bool equivalent_triangle = EINA_FALSE, triangle_chain = EINA_FALSE; 2430 Eina_Bool equivalent_triangle = EINA_FALSE, triangle_chain = EINA_FALSE;
@@ -2711,17 +2711,15 @@ evas_convex_hull_get(float *data, int count, int stride, float **vertex,
2711 free (new_elem1); 2711 free (new_elem1);
2712 } 2712 }
2713 2713
2714 2714 index_count = 3 * eina_array_count(&arr_ch);
2715 *vertex_count = 0;
2716 *index_count = 3 * eina_array_count(&arr_ch);
2717 2715
2718 found_vertex = (float*) malloc(10 * sizeof(float)); 2716 found_vertex = (float*) malloc(10 * sizeof(float));
2719 found_index = (unsigned short int*) malloc((*index_count) * sizeof(unsigned short int)); 2717 found_index = (unsigned short int*) malloc(index_count * sizeof(unsigned short int));
2720 j = 0; 2718 j = 0;
2721 2719
2722#define CHECK_AND_SET_VERTEX(coord) \ 2720#define CHECK_AND_SET_VERTEX(coord) \
2723 exist1 = EINA_FALSE; \ 2721 exist1 = EINA_FALSE; \
2724 for (i = 0, new_stride = 0; i < (*vertex_count) && !exist1; i++, new_stride += 10) \ 2722 for (i = 0, new_stride = 0; (i < vertex_count) && !exist1; i++, new_stride += 10) \
2725 { \ 2723 { \
2726 if ((k > 0) && (el->p##coord.x == found_vertex[new_stride]) && \ 2724 if ((k > 0) && (el->p##coord.x == found_vertex[new_stride]) && \
2727 (el->p##coord.y == found_vertex[new_stride + 1]) && \ 2725 (el->p##coord.y == found_vertex[new_stride + 1]) && \
@@ -2732,7 +2730,7 @@ evas_convex_hull_get(float *data, int count, int stride, float **vertex,
2732 } \ 2730 } \
2733 } \ 2731 } \
2734 if (!exist1) \ 2732 if (!exist1) \
2735 convex_hull_vertex_set(el, vertex_count, &found_vertex, \ 2733 convex_hull_vertex_set(el, &vertex_count, &found_vertex, \
2736 &found_index, k, &leader, coord); 2734 &found_index, k, &leader, coord);
2737 2735
2738 EINA_ARRAY_ITER_NEXT(&arr_ch, k, el, iterator) 2736 EINA_ARRAY_ITER_NEXT(&arr_ch, k, el, iterator)
@@ -2744,12 +2742,14 @@ evas_convex_hull_get(float *data, int count, int stride, float **vertex,
2744 j += 30; 2742 j += 30;
2745 } 2743 }
2746 2744
2747 *vertex = (float*) malloc((10 * (*vertex_count)) * sizeof(float)); 2745 for (i = 0; i < 10 * (vertex_count); i++)
2748 memcpy(*vertex, found_vertex, (10 * (*vertex_count)) * sizeof(float)); 2746 eina_inarray_push(vertex, &found_vertex[i]);
2747
2748 for (i = 0; i < index_count; i++)
2749 eina_inarray_push(index, &found_index[i]);
2750
2749 free(found_vertex); 2751 free(found_vertex);
2750 2752
2751 *index = (unsigned short int*) malloc((*index_count) * sizeof(unsigned short int));
2752 memcpy(*index, found_index, (*index_count) * sizeof(unsigned short int));
2753 free(found_index); 2753 free(found_index);
2754 2754
2755 EINA_ARRAY_ITER_NEXT(&arr_triangles, k, el, iterator) 2755 EINA_ARRAY_ITER_NEXT(&arr_triangles, k, el, iterator)