evas-3d: fix primitives
authorperepelits.m <perepelits.m@samsung.com>
Sun, 4 Oct 2015 14:37:17 +0000 (16:37 +0200)
committerCedric BAIL <cedric@osg.samsung.com>
Sun, 4 Oct 2015 14:37:28 +0000 (16:37 +0200)
Summary:
There were warnings after adding primitive in the same frame more then once, the check was added to avoid it

@fix

Reviewers: cedric, raster, Hermet

Subscribers: cedric, artem.popov

Differential Revision: https://phab.enlightenment.org/D3090

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/lib/evas/canvas/evas_canvas3d_mesh.c
src/lib/evas/canvas/evas_canvas3d_mesh.eo
src/lib/evas/common3d/primitives/primitive_common.h

index 892ecd1..e7bc091 100644 (file)
@@ -306,6 +306,17 @@ _evas_canvas3d_mesh_vertex_count_get(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Dat
    return pd->vertex_count;
 }
 
+EOLIAN static Eina_Bool
+_evas_canvas3d_mesh_frame_exist(Eo *obj EINA_UNUSED, Evas_Canvas3D_Mesh_Data *pd, int frame)
+{
+   Evas_Canvas3D_Mesh_Frame *f = evas_canvas3d_mesh_frame_find(pd, frame);
+
+   if (f)
+     return EINA_TRUE;
+
+   return EINA_FALSE;
+}
+
 EOLIAN static void
 _evas_canvas3d_mesh_frame_add(Eo *obj, Evas_Canvas3D_Mesh_Data *pd, int frame)
 {
index aa1a23e..df01a85 100644 (file)
@@ -156,6 +156,14 @@ class Evas.Canvas3D.Mesh (Evas.Canvas3D.Object, Evas.Common_Interface, Efl.File)
          ]]
       }
 
+      frame_exist {
+         [[Returns EINA_TRUE if frame was added and EINA_FALSE in other case.]]
+         params {
+            @in frame: int; [[Frame number.]]
+         }
+         return: Eina_Bool;
+      }
+
       frame_add {
          [[Add a key frame to the given mesh.
 
index 7f4e39d..50092d7 100644 (file)
    unsigned short *indices = malloc(sizeof(short) * icount);
 
 #define SET_VERTEX_DATA(frame)                                                     \
+   Eina_Bool frame_exist; \
+   eo_do(mesh, \
+         frame_exist = evas_canvas3d_mesh_frame_exist(frame)); \
+   if (!frame_exist) \
+   eo_do(mesh, \
+         evas_canvas3d_mesh_frame_add(frame)); \
    eo_do(mesh,                                                                     \
          evas_canvas3d_mesh_vertex_count_set(vcount),                                    \
-         evas_canvas3d_mesh_frame_add(frame),                                            \
          evas_canvas3d_mesh_index_data_copy_set(EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT,     \
                                           icount, &indices[0]));                   \
    _set_vec3_vertex_data(mesh, frame, vcount, vertices, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION);  \
    free(indices);
 
 #define SET_VERTEX_DATA_FROM_ARRAY(mesh, frame, varray, vcount, indices, icount) \
+   Eina_Bool frame_exist; \
+   eo_do(mesh, \
+         frame_exist = evas_canvas3d_mesh_frame_exist(frame)); \
+   if (!frame_exist) \
+   eo_do(mesh, \
+         evas_canvas3d_mesh_frame_add(frame)); \
    eo_do(mesh, \
          evas_canvas3d_mesh_vertex_count_set(vcount), \
-         evas_canvas3d_mesh_frame_add(frame), \
          evas_canvas3d_mesh_index_data_copy_set(EVAS_CANVAS3D_INDEX_FORMAT_UNSIGNED_SHORT, \
                                           icount, &indices[0])); \
    _set_vertex_data_from_array(mesh, frame, varray, EVAS_CANVAS3D_VERTEX_ATTRIB_POSITION, \