forked from enlightenment/efl
evas-3d: T2226 (Evas Eet saver does out of range access) fixed.
Summary: texcoord now is 2D vector @fix Reviewers: cedric, Hermet, raster Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2233
This commit is contained in:
parent
bc8dfbb1ef
commit
f8f118f058
Binary file not shown.
|
@ -4,6 +4,7 @@
|
|||
|
||||
Evas_3D_File_Eet* eet_file;
|
||||
const char EVAS_3D_FILE_CACHE_FILE_ENTRY[] = "evas_3d file";
|
||||
Eet_Data_Descriptor *_vec2_descriptor;
|
||||
Eet_Data_Descriptor *_vec3_descriptor;
|
||||
Eet_Data_Descriptor *_vertex_descriptor;
|
||||
Eet_Data_Descriptor *_geometry_descriptor;
|
||||
|
@ -36,6 +37,8 @@ _evas_3d_eet_file_init(void)
|
|||
|
||||
/* initialization of bonding between structure units in eet file */
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_3D_Vec2_Eet);
|
||||
_vec2_descriptor = eet_data_descriptor_file_new(&eddc);
|
||||
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_3D_Vec3_Eet);
|
||||
_vec3_descriptor = eet_data_descriptor_file_new(&eddc);
|
||||
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_3D_Vertex_Eet);
|
||||
|
@ -55,6 +58,13 @@ _evas_3d_eet_file_init(void)
|
|||
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_3D_File_Eet);
|
||||
_file_descriptor = eet_data_descriptor_file_new(&eddc);
|
||||
|
||||
/* Vec_2 */
|
||||
#define ADD_BASIC(member, eet_type) EET_DATA_DESCRIPTOR_ADD_BASIC \
|
||||
(_vec2_descriptor, Evas_3D_Vec3_Eet, # member, member, eet_type);
|
||||
ADD_BASIC(x, EET_T_FLOAT);
|
||||
ADD_BASIC(y, EET_T_FLOAT);
|
||||
#undef ADD_BASIC
|
||||
|
||||
/* Vec_3 */
|
||||
#define ADD_BASIC(member, eet_type) EET_DATA_DESCRIPTOR_ADD_BASIC \
|
||||
(_vec3_descriptor, Evas_3D_Vec3_Eet, # member, member, eet_type);
|
||||
|
@ -69,7 +79,7 @@ _evas_3d_eet_file_init(void)
|
|||
EET_DATA_DESCRIPTOR_ADD_SUB_NESTED(_vertex_descriptor, Evas_3D_Vertex_Eet,
|
||||
"normal", normal, _vec3_descriptor);
|
||||
EET_DATA_DESCRIPTOR_ADD_SUB_NESTED(_vertex_descriptor, Evas_3D_Vertex_Eet,
|
||||
"texcoord", texcoord, _vec3_descriptor);
|
||||
"texcoord", texcoord, _vec2_descriptor);
|
||||
|
||||
/* Geometry */
|
||||
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_geometry_descriptor, Evas_3D_Geometry_Eet,
|
||||
|
@ -151,6 +161,7 @@ _evas_3d_eet_descriptor_shutdown(void)
|
|||
{
|
||||
eet_data_descriptor_free(_geometry_descriptor);
|
||||
eet_data_descriptor_free(_vertex_descriptor);
|
||||
eet_data_descriptor_free(_vec2_descriptor);
|
||||
eet_data_descriptor_free(_vec3_descriptor);
|
||||
eet_data_descriptor_free(_color_descriptor);
|
||||
eet_data_descriptor_free(_material_descriptor);
|
||||
|
|
|
@ -76,6 +76,7 @@ typedef struct _Evas_3D_Material Evas_3D_Material_Data;
|
|||
typedef struct _Evas_3D_Texture Evas_3D_Texture_Data;
|
||||
|
||||
/* Structs for mesh eet saver/loader */
|
||||
typedef struct _Evas_3D_Vec2_Eet Evas_3D_Vec2_Eet;
|
||||
typedef struct _Evas_3D_Vec3_Eet Evas_3D_Vec3_Eet;
|
||||
typedef struct _Evas_3D_Vertex_Eet Evas_3D_Vertex_Eet;
|
||||
typedef struct _Evas_3D_Geometry_Eet Evas_3D_Geometry_Eet;
|
||||
|
@ -86,6 +87,12 @@ typedef struct _Evas_3D_Mesh_Eet Evas_3D_Mesh_Eet;
|
|||
typedef struct _Evas_3D_Header_Eet Evas_3D_Header_Eet;
|
||||
typedef struct _Evas_3D_File_Eet Evas_3D_File_Eet;
|
||||
|
||||
struct _Evas_3D_Vec2_Eet
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
};
|
||||
|
||||
struct _Evas_3D_Vec3_Eet
|
||||
{
|
||||
float x;
|
||||
|
@ -97,7 +104,7 @@ struct _Evas_3D_Vertex_Eet
|
|||
{
|
||||
Evas_3D_Vec3_Eet position;
|
||||
Evas_3D_Vec3_Eet normal;
|
||||
Evas_3D_Vec3_Eet texcoord;
|
||||
Evas_3D_Vec2_Eet texcoord;
|
||||
};//one point of mesh
|
||||
|
||||
struct _Evas_3D_Geometry_Eet
|
||||
|
|
|
@ -40,7 +40,7 @@ _set_geometry_to_eet_file_from_mesh(Evas_3D_Mesh_Data *mesh,
|
|||
geometry->vertices_count = mesh->vertex_count;
|
||||
geometries[0] = mesh->vertex_count;
|
||||
|
||||
#define SAVE_GEOMETRICS(a, component)\
|
||||
#define SAVE_GEOMETRICS(a, component, command_for_z_component)\
|
||||
vb = &f->vertices[a];\
|
||||
if (vb->data == NULL)\
|
||||
{\
|
||||
|
@ -55,15 +55,13 @@ _set_geometry_to_eet_file_from_mesh(Evas_3D_Mesh_Data *mesh,
|
|||
{\
|
||||
vertices[i].component.x = src[0];\
|
||||
vertices[i].component.y = src[1];\
|
||||
vertices[i].component.z = src[2];\
|
||||
command_for_z_component\
|
||||
src += f->vertices[a].element_count;\
|
||||
}
|
||||
|
||||
geometry->vertices = vertices;
|
||||
SAVE_GEOMETRICS(EVAS_3D_VERTEX_POSITION, position)
|
||||
SAVE_GEOMETRICS(EVAS_3D_VERTEX_NORMAL, normal)
|
||||
SAVE_GEOMETRICS(EVAS_3D_VERTEX_TEXCOORD, texcoord)
|
||||
|
||||
SAVE_GEOMETRICS(EVAS_3D_VERTEX_POSITION, position, vertices[i].position.z = src[2];)
|
||||
SAVE_GEOMETRICS(EVAS_3D_VERTEX_NORMAL, normal, vertices[i].normal.z = src[2];)
|
||||
SAVE_GEOMETRICS(EVAS_3D_VERTEX_TEXCOORD, texcoord,)
|
||||
#undef SAVE_GEOMETRICS
|
||||
|
||||
eet_mesh->geometries = geometry;
|
||||
|
|
Loading…
Reference in New Issue