Use a separate accelertion struct for HE_vert.
Don't use so long parameter lists, introduce obj_items
data structure.
This commit is contained in:
hasufell 2014-05-17 14:07:34 +02:00
parent 9c35ee0159
commit 2f52351cbf
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
2 changed files with 261 additions and 190 deletions

View File

@ -84,21 +84,63 @@
} }
typedef struct obj_items obj_items;
/**
* 2d array which can hold the vertices
* as they are in the .obj file,
*/
typedef double** VERTICES; typedef double** VERTICES;
typedef struct FACES FACES; typedef struct FACES FACES;
/**
* 2d array which can hold the vertices texture
* coordinates as they are in the .obj file,
*/
typedef double** V_TEXTURES; typedef double** V_TEXTURES;
typedef struct HE_edge HE_edge; typedef struct HE_edge HE_edge;
typedef struct HE_vert HE_vert; typedef struct HE_vert HE_vert;
typedef struct HE_vert_acc HE_vert_acc;
typedef struct HE_face HE_face; typedef struct HE_face HE_face;
typedef struct HE_obj HE_obj; typedef struct HE_obj HE_obj;
typedef struct color color; typedef struct color color;
struct FACES { /**
uint32_t **v; * This will hold all supported items,
uint32_t **vt; * such as "v" (for vertice), "f" (for face)
* or "vt" (for vertex texture) as they are
* in the .obj file, not converted to anything.
*/
struct obj_items {
/**
* Raw vertices array.
*/
VERTICES v;
/**
* Raw faces array.
*/
FACES *f;
/**
* Raw texture coordinates array.
*/
V_TEXTURES vt;
}; };
/**
* Represents the raw faces as they are in the .obj
* file with their references to vertices etc.
*/
struct FACES {
/**
* References to the vertices which
* will form the face.
*/
uint32_t **v;
/**
* Reference to the texture coordinates
* which will form the polygon texture.
*/
uint32_t **vt;
};
/** /**
* Represents a half-edge. * Represents a half-edge.
@ -134,14 +176,24 @@ struct HE_vert {
* to the coordinates of the vertex. * to the coordinates of the vertex.
*/ */
vector *vec; vector *vec;
/** /**
* One of the half-edges emanating from the vertex. * One of the half-edges emanating from the vertex.
* It is made sure that this is never a border edge, * It is made sure that this is never a border edge,
* unless there are only border edges. * unless there are only border edges.
*/ */
HE_edge *edge; HE_edge *edge;
/**
* Color of the vertex.
*/
color *col;
/**
* The acceleration structure, used to speed up
* assembling the half-edge structures.
*/
HE_vert_acc *acc;
};
struct HE_vert_acc {
/** /**
* Acceleration structure which saves all potential * Acceleration structure which saves all potential
* pair edges that point TO this vertex. It is used * pair edges that point TO this vertex. It is used
@ -152,28 +204,20 @@ struct HE_vert {
* don't qualify for pairs anyway). * don't qualify for pairs anyway).
*/ */
HE_edge **edge_array; HE_edge **edge_array;
/** /**
* Similar as the edge_array acceleration structure, * Similar as the edge_array acceleration structure,
* except that it is used for connecting the * except that it is used for connecting the
* dummy edges. * dummy edges.
*/ */
HE_edge **dummys; HE_edge **dummys;
/** /**
* Element count of the edge_array. * Element count of the edge_array.
*/ */
uint32_t eac; uint32_t eac;
/** /**
* Element count of dummys. * Element count of dummys.
*/ */
uint32_t dc; uint32_t dc;
/**
* Color of the vertex.
*/
color *col;
}; };
/** /**
@ -216,6 +260,14 @@ struct HE_obj {
* Count of faces. * Count of faces.
*/ */
uint32_t fc; uint32_t fc;
/**
* Count of the vertex texture coordinates.
*/
uint32_t vtc;
/**
* Count of dummy edges.
*/
uint32_t dec;
}; };
/** /**

View File

@ -34,27 +34,22 @@
#include <string.h> #include <string.h>
/*
* static function declaration
*/
static bool assemble_obj_arrays(char const * const obj_string, static bool assemble_obj_arrays(char const * const obj_string,
VERTICES *obj_v_out, obj_items *raw_obj,
V_TEXTURES *obj_vt_out, HE_obj *he_obj);
FACES **obj_f_out, static void assemble_HE_stage1(obj_items const * const raw_obj,
uint32_t *vc_out, HE_obj *he_obj);
uint32_t *fc_out, static void assemble_HE_stage2(obj_items const * const raw_obj,
uint32_t *ec_out, HE_obj *he_obj);
uint32_t *vtc_out); static void assemble_HE_stage3(HE_obj *he_obj);
static void assemble_HE_stage1(VERTICES obj_v, static void delete_accel_struct(HE_obj *he_obj);
HE_vert *vertices, static void delete_raw_object(obj_items *raw_obj,
uint32_t *vc, uint32_t fc,
uint32_t *fc); uint32_t vc,
static void assemble_HE_stage2(FACES *obj_f, uint32_t vt);
HE_vert *vertices,
HE_face *faces,
HE_edge *edges,
uint32_t *fc,
uint32_t *ec);
static void assemble_HE_stage3(HE_edge *edges,
uint32_t *ec,
uint32_t *dec);
/** /**
@ -66,30 +61,16 @@ static void assemble_HE_stage3(HE_edge *edges,
* once. * once.
* *
* @param obj_string the string that is in obj format * @param obj_string the string that is in obj format
* @param obj_v_out where to save the vertices, the rear * @param raw_obj contains arrays of the items as they are in the .obj
* dimension will always have 3 elements for x,y,z [out] * file; members v, f and vt are set [out]
* @param obj_vt_out where to save the texture coordinates [out] * @param he_obj the half-edge object containing array-pointers
* @param obj_f_out where to save the faces, the rear dimension * to all the HE_* structures; members ec, fc, vc and vtc are set [out]
* will be terminated with a "0" [out]
* @param vc_out pointer to save vertice count [out]
* @param fc_out pointer to save face count [out]
* @param ec_out pointer to save edge count [out]
* @param vtc_out pointer to save texture coordinates count [out]
* @return true/false for success/failure * @return true/false for success/failure
*/ */
static bool assemble_obj_arrays(char const * const obj_string, static bool assemble_obj_arrays(char const * const obj_string,
VERTICES *obj_v_out, obj_items *raw_obj,
V_TEXTURES *obj_vt_out, HE_obj *he_obj)
FACES **obj_f_out,
uint32_t *vc_out,
uint32_t *fc_out,
uint32_t *ec_out,
uint32_t *vtc_out)
{ {
uint32_t vc = 0,
fc = 0,
ec = 0,
vtc = 0;
char *string; char *string;
/* for strtok_r */ /* for strtok_r */
@ -98,13 +79,15 @@ static bool assemble_obj_arrays(char const * const obj_string,
*str_ptr_slash = NULL, *str_ptr_slash = NULL,
*str_tmp_ptr = NULL; *str_tmp_ptr = NULL;
/* these will be assigned later to the out structs */
uint32_t vc = 0, fc = 0, ec = 0, vtc = 0;
VERTICES obj_v = NULL; VERTICES obj_v = NULL;
FACES *obj_f = malloc(sizeof(*obj_f)); FACES *obj_f = malloc(sizeof(*obj_f));
uint32_t **obj_f_v = NULL; uint32_t **obj_f_v = NULL; /* tmp v member of obj_f */
uint32_t **obj_f_vt = NULL; uint32_t **obj_f_vt = NULL; /* tmp vt member of obj_f */
V_TEXTURES obj_vt = NULL; V_TEXTURES obj_vt = NULL;
if (!obj_string || !obj_v_out || !obj_f_out) if (!obj_string || !raw_obj)
return false; return false;
/* avoid side effects */ /* avoid side effects */
@ -208,16 +191,16 @@ static bool assemble_obj_arrays(char const * const obj_string,
str_tmp_ptr = strtok_r(NULL, "\n", &str_ptr_newline); str_tmp_ptr = strtok_r(NULL, "\n", &str_ptr_newline);
} }
/* set all out-variables */ /* assign the out variables */
*obj_v_out = obj_v; he_obj->ec = ec;
*obj_vt_out = obj_vt; he_obj->fc = fc;
he_obj->vc = vc;
he_obj->vtc = vtc;
raw_obj->v = obj_v;
obj_f->v = obj_f_v; obj_f->v = obj_f_v;
obj_f->vt = obj_f_vt; obj_f->vt = obj_f_vt;
*obj_f_out = obj_f; raw_obj->f = obj_f;
*vc_out = vc; raw_obj->vt = obj_vt;
*fc_out = fc;
*ec_out = ec;
*vtc_out = vtc;
/* cleanup */ /* cleanup */
free(string); free(string);
@ -233,49 +216,51 @@ static bool assemble_obj_arrays(char const * const obj_string,
* NULL. This function isn't really modular, but makes * NULL. This function isn't really modular, but makes
* reading parse_obj() a bit less painful. * reading parse_obj() a bit less painful.
* *
* @param obj_v the vertices in the raw form after they are * @param raw_obj contains arrays of the items as they are in the .obj
* parsed from the obj file * file
* @param vertices pointer the actual half-edge vertices * @param he_obj the half-edge object containing array-pointers
* @param vc pointer to the vertice count * to all the HE_* structures; member vertices is set [out]
* @param fc pointer to the face count
*/ */
static void assemble_HE_stage1(VERTICES obj_v, static void assemble_HE_stage1(obj_items const * const raw_obj,
HE_vert *vertices, HE_obj *he_obj)
uint32_t *vc,
uint32_t *fc)
{ {
uint32_t vc = 0;
uint8_t const xpos = 0; uint8_t const xpos = 0;
uint8_t const ypos = 1; uint8_t const ypos = 1;
uint8_t const zpos = 2; uint8_t const zpos = 2;
int8_t default_color = -1; int8_t default_color = -1;
HE_vert *vertices = he_obj->vertices;
*vc = 0; while (raw_obj->v[vc]) {
while (obj_v[*vc]) {
vector *tmp_vec; vector *tmp_vec;
tmp_vec = malloc(sizeof(vector)); tmp_vec = malloc(sizeof(vector));
CHECK_PTR_VAL(tmp_vec); CHECK_PTR_VAL(tmp_vec);
tmp_vec->x = obj_v[*vc][xpos]; tmp_vec->x = raw_obj->v[vc][xpos];
tmp_vec->y = obj_v[*vc][ypos]; tmp_vec->y = raw_obj->v[vc][ypos];
tmp_vec->z = obj_v[*vc][zpos]; tmp_vec->z = raw_obj->v[vc][zpos];
vertices[*vc].vec = tmp_vec; vertices[vc].vec = tmp_vec;
/* set unused/unknown values to NULL */ /* set unused/unknown values to NULL */
vertices[*vc].edge = NULL; vertices[vc].edge = NULL;
vertices[*vc].edge_array = NULL;
vertices[*vc].eac = 0;
vertices[*vc].dc = 0;
vertices[*vc].col = malloc(sizeof(color)); vertices[vc].col = malloc(sizeof(color));
vertices[*vc].col->red = default_color; vertices[vc].col->red = default_color;
vertices[*vc].col->green = default_color; vertices[vc].col->green = default_color;
vertices[*vc].col->blue = default_color; vertices[vc].col->blue = default_color;
(*vc)++; /* set acc structure */
vertices[vc].acc = malloc(sizeof(HE_vert_acc));
vertices[vc].acc->edge_array = NULL;
vertices[vc].acc->eac = 0;
vertices[vc].acc->dc = 0;
vc++;
} }
he_obj->vertices = vertices;
} }
/** /**
@ -287,72 +272,78 @@ static void assemble_HE_stage1(VERTICES obj_v,
* This function isn't really modular, but makes * This function isn't really modular, but makes
* reading parse_obj() a bit less painful. * reading parse_obj() a bit less painful.
* *
* @param obj_f the raw faces as they are after parsing the obj file * @param raw_obj contains arrays of the items as they are in the .obj
* @param vertices the half-edge vertices * file
* @param faces the half-edge faces * @param he_obj the half-edge object containing array-pointers
* @param edges the half-edge edges * to all the HE_* structures; member vertices, edges
* @param fc the count of half-edge faces * and faces are modified [out]
* @param ec the count of half-edge edges
*/ */
static void assemble_HE_stage2(FACES *obj_f, static void assemble_HE_stage2(obj_items const * const raw_obj,
HE_vert *vertices, HE_obj *he_obj)
HE_face *faces,
HE_edge *edges,
uint32_t *fc,
uint32_t *ec)
{ {
*ec = 0; HE_vert *vertices = he_obj->vertices;
HE_edge *edges = he_obj->edges;
HE_face *faces = he_obj->faces;
FACES *obj_f = raw_obj->f;
uint32_t ec = 0,
fc = he_obj->fc;
/* create HE_edges and real HE_faces */ /* create HE_edges and real HE_faces */
for (uint32_t i = 0; i < *fc; i++) { /* for all faces */ for (uint32_t i = 0; i < fc; i++) { /* for all faces */
uint32_t j = 0; uint32_t j = 0;
/* for all vertices of the face */ /* for all vertices of the face */
while (obj_f->v[i][j]) { while (obj_f->v[i][j]) {
uint32_t fv_arr_id = uint32_t fv_arr_id =
obj_f->v[i][j] - 1; /* fv_id starts at 1 */ obj_f->v[i][j] - 1; /* fv_id starts at 1 */
edges[*ec].vert = &(vertices[fv_arr_id]); edges[ec].vert = &(vertices[fv_arr_id]);
edges[*ec].face = &(faces[i]); edges[ec].face = &(faces[i]);
edges[*ec].pair = NULL; /* preliminary */ edges[ec].pair = NULL; /* preliminary */
vertices[fv_arr_id].edge = &(edges[*ec]); /* last one wins */ vertices[fv_arr_id].edge = &(edges[ec]); /* last one wins */
vertices[fv_arr_id].dummys = NULL; /* preliminary */ vertices[fv_arr_id].acc->dummys = NULL; /* preliminary */
/* Skip j == 0 here, so we don't underrun the arrays, /* Skip j == 0 here, so we don't underrun the arrays,
* since we always look one edge back. The first edge * since we always look one edge back. The first edge
* element is taken care of below as well. */ * element is taken care of below as well. */
if (j > 0) { if (j > 0) {
uint32_t *eac = &(edges[*ec].vert->eac); uint32_t *eac = &(edges[ec].vert->acc->eac);
/* connect previous edge to current edge */ /* connect previous edge to current edge */
edges[*ec - 1].next = &(edges[*ec]); edges[ec - 1].next = &(edges[ec]);
/* Acceleration struct: /* Acceleration struct:
* add previous edge to edge_array of current vertice */ * add previous edge to edge_array of current vertice */
REALLOC(edges[*ec].vert->edge_array, REALLOC(edges[ec].vert->acc->edge_array,
sizeof(HE_edge*) * (*eac + 1)); sizeof(HE_edge*) * (*eac + 1));
edges[*ec].vert->edge_array[*eac] = &(edges[*ec - 1]); edges[ec].vert->acc->edge_array[*eac] = &(edges[ec - 1]);
(*eac)++; (*eac)++;
if (!obj_f->v[i][j + 1]) { /* no vertice left */ if (!obj_f->v[i][j + 1]) { /* no vertice left */
uint32_t *eac; uint32_t *eac;
/* connect last edge to first edge */ /* connect last edge to first edge */
edges[*ec].next = &(edges[*ec - j]); edges[ec].next = &(edges[ec - j]);
eac = &(edges[*ec].next->vert->eac); eac = &(edges[ec].next->vert->acc->eac);
/* Acceleration struct: /* Acceleration struct:
* add last edge to edge_array element of first vertice */ * add last edge to edge_array element of first vertice */
REALLOC(edges[*ec].next->vert->edge_array, REALLOC(edges[ec].next->vert->acc->edge_array,
sizeof(HE_edge*) * (*eac + 1)); sizeof(HE_edge*) * (*eac + 1));
edges[*ec].next->vert->edge_array[*eac] = &(edges[*ec]); edges[ec].next->vert->acc->edge_array[*eac] = &(edges[ec]);
(*eac)++; (*eac)++;
} }
} }
(*ec)++; ec++;
j++; j++;
} }
faces[i].edge = &(edges[*ec - 1]); /* "last" edge */ faces[i].edge = &(edges[ec - 1]); /* "last" edge */
} }
he_obj->vertices = vertices;
he_obj->edges = edges;
he_obj->faces = faces;
} }
/** /**
@ -361,25 +352,26 @@ static void assemble_HE_stage2(FACES *obj_f,
* possibility of border-edges, where we have to set up * possibility of border-edges, where we have to set up
* dummy edges and connect them properly. * dummy edges and connect them properly.
* *
* @param edges the half-edge edges * @param he_obj the half-edge object containing array-pointers;
* @param ec the half-edge edges count * member dec is set and edges is modified [out]
* @param dec the dummy edges count
*/ */
static void assemble_HE_stage3(HE_edge *edges, static void assemble_HE_stage3(HE_obj *he_obj)
uint32_t *ec,
uint32_t *dec)
{ {
HE_edge *edges = he_obj->edges;
uint32_t ec = he_obj->ec;
uint32_t dec = 0;
/* find pairs */ /* find pairs */
for (uint32_t i = 0; i < *ec; i++) { /* for all edges */ for (uint32_t i = 0; i < ec; i++) { /* for all edges */
uint32_t eac = edges[i].vert->eac; uint32_t eac = edges[i].vert->acc->eac;
bool pair_found = false; bool pair_found = false;
for (uint32_t j = 0; j < eac; j++) { /* for all potential pairs */ for (uint32_t j = 0; j < eac; j++) { /* for all potential pairs */
if (edges[i].vert->edge_array[j] && if (edges[i].vert->acc->edge_array[j] &&
(edges[i].next->vert == (edges[i].next->vert ==
edges[i].vert->edge_array[j]->vert)) { edges[i].vert->acc->edge_array[j]->vert)) {
edges[i].pair = edges[i].vert->edge_array[j]; edges[i].pair = edges[i].vert->acc->edge_array[j];
edges[i].vert->edge_array[j] = NULL; edges[i].vert->acc->edge_array[j] = NULL;
pair_found = true; pair_found = true;
break; break;
@ -388,40 +380,43 @@ static void assemble_HE_stage3(HE_edge *edges,
/* create dummy pair edge if we have a border edge */ /* create dummy pair edge if we have a border edge */
if (!pair_found) { if (!pair_found) {
uint32_t *vert_dc = &(edges[i].next->vert->dc); uint32_t *vert_dc = &(edges[i].next->vert->acc->dc);
REALLOC(edges[i].next->vert->dummys, REALLOC(edges[i].next->vert->acc->dummys,
sizeof(HE_edge*) * (*vert_dc + 1)); sizeof(HE_edge*) * (*vert_dc + 1));
/* NULL-face indicates border-edge */ /* NULL-face indicates border-edge */
edges[*ec + *dec].face = NULL; edges[ec + dec].face = NULL;
/* we don't know this one yet */ /* we don't know this one yet */
edges[*ec + *dec].next = NULL; edges[ec + dec].next = NULL;
/* set both pairs */ /* set both pairs */
edges[*ec + *dec].pair = &(edges[i]); edges[ec + dec].pair = &(edges[i]);
edges[i].pair = &(edges[*ec + *dec]); edges[i].pair = &(edges[ec + dec]);
/* set vertex */ /* set vertex */
edges[*ec + *dec].vert = edges[i].next->vert; edges[ec + dec].vert = edges[i].next->vert;
/* add the dummy edge to the dummys array of the vertex */ /* add the dummy edge to the dummys array of the vertex */
edges[*ec + *dec].vert->dummys[*vert_dc] = &(edges[*ec + *dec]); edges[ec + dec].vert->acc->dummys[*vert_dc] = &(edges[ec + dec]);
(*vert_dc)++; (*vert_dc)++;
(*dec)++; dec++;
} }
} }
/* now we have to connect the dummy edges together */ /* now we have to connect the dummy edges together */
for (uint32_t i = 0; i < *dec; i++) { /* for all dummy edges */ for (uint32_t i = 0; i < dec; i++) { /* for all dummy edges */
/* vertex the dummy edge points to */ /* vertex the dummy edge points to */
HE_vert *vert = edges[*ec + i].pair->vert; HE_vert *vert = edges[ec + i].pair->vert;
/* iterate over the dummy array */ /* iterate over the dummy array */
for (uint32_t j = 0; j < vert->dc; j++) { for (uint32_t j = 0; j < vert->acc->dc; j++) {
if (vert == vert->dummys[j]->vert) if (vert == vert->acc->dummys[j]->vert)
edges[*ec + i].next = vert->dummys[j]; edges[ec + i].next = vert->acc->dummys[j];
j++; j++;
} }
} }
he_obj->edges = edges;
he_obj->dec = dec;
} }
/** /**
@ -434,20 +429,10 @@ static void assemble_HE_stage3(HE_edge *edges,
*/ */
HE_obj *parse_obj(char const * const obj_string) HE_obj *parse_obj(char const * const obj_string)
{ {
uint32_t vc = 0, /* vertices count */
fc = 0, /* face count */
ec = 0, /* edge count */
dec = 0, /* dummy edge count */
vtc = 0;
char *string = NULL, char *string = NULL,
*str_ptr; *str_ptr;
HE_vert *vertices = NULL; HE_obj *he_obj = NULL;
HE_edge *edges = NULL; obj_items raw_obj;
HE_face *faces = NULL;
HE_obj *obj = NULL;
FACES *obj_f = NULL;
VERTICES obj_v = NULL;
V_TEXTURES obj_vt = NULL;
if (!obj_string || !*obj_string) if (!obj_string || !*obj_string)
return NULL; return NULL;
@ -456,47 +441,81 @@ HE_obj *parse_obj(char const * const obj_string)
strcpy(string, obj_string); strcpy(string, obj_string);
str_ptr = string; str_ptr = string;
if (!assemble_obj_arrays(string, &obj_v, &obj_vt, &obj_f, /*
&vc, &fc, &ec, &vtc)) * allocation for he_obj
*/
he_obj = (HE_obj*) malloc(sizeof(HE_obj));
CHECK_PTR_VAL(he_obj);
/*
* assemble pseudo-object, also sets vc, fc, ec
*/
if (!assemble_obj_arrays(string, &raw_obj, he_obj))
return NULL; return NULL;
vertices = malloc(sizeof(HE_vert) * /*
(vc + 1)); * he_obj member allocation
CHECK_PTR_VAL(vertices); */
faces = (HE_face*) malloc(sizeof(HE_face) * fc); he_obj->vertices = malloc(sizeof(HE_vert) *
CHECK_PTR_VAL(faces); (he_obj->vc + 1));
CHECK_PTR_VAL(he_obj->vertices);
he_obj->faces = (HE_face*) malloc(sizeof(HE_face) * he_obj->fc);
CHECK_PTR_VAL(he_obj->faces);
/* hold enough space for possible dummy edges */ /* hold enough space for possible dummy edges */
edges = (HE_edge*) malloc(sizeof(HE_edge) * ec * 2); he_obj->edges = (HE_edge*) malloc(sizeof(HE_edge) * he_obj->ec * 2);
CHECK_PTR_VAL(edges); CHECK_PTR_VAL(he_obj->edges);
assemble_HE_stage1(obj_v, vertices, &vc, &fc); /*
assemble_HE_stage2(obj_f, vertices, faces, edges, &fc, &ec); * run the stages of assemblance
assemble_HE_stage3(edges, &ec, &dec); */
assemble_HE_stage1(&raw_obj, he_obj);
obj = (HE_obj*) malloc(sizeof(HE_obj)); assemble_HE_stage2(&raw_obj, he_obj);
CHECK_PTR_VAL(obj); assemble_HE_stage3(he_obj);
obj->edges = edges;
obj->vertices = vertices;
obj->faces = faces;
obj->ec = ec;
obj->vc = vc;
obj->fc = fc;
/* cleanup */ /* cleanup */
for (uint32_t i = 0; i < fc; i++) { delete_raw_object(&raw_obj, he_obj->fc, he_obj->vc, he_obj->vtc);
free(obj_f->v[i]); delete_accel_struct(he_obj);
free(obj_f->vt[i]);
}
free(obj_f->v);
free(obj_f->vt);
free(obj_f);
for (uint32_t i = 0; i < vc; i++) {
free(vertices[i].dummys);
free(vertices[i].edge_array);
free(obj_v[i]);
}
free(obj_v);
free(string); free(string);
return obj; return he_obj;
}
/**
* Delete the acceleration structure of
* HE_vert.
*/
static void delete_accel_struct(HE_obj *he_obj)
{
for (uint32_t i = 0; i < he_obj->vc; i++) {
free(he_obj->vertices[i].acc->dummys);
free(he_obj->vertices[i].acc->edge_array);
free(he_obj->vertices[i].acc);
}
}
/**
* Delete the raw obj pseudo struct which is only
* used for assembling the HE_obj.
*/
static void delete_raw_object(obj_items *raw_obj,
uint32_t fc,
uint32_t vc,
uint32_t vtc)
{
if (!raw_obj)
return;
for (uint32_t i = 0; i < vtc; i++)
free(raw_obj->vt[i]);
for (uint32_t i = 0; i < vc; i++)
free(raw_obj->v[i]);
for (uint32_t i = 0; i < fc; i++) {
free(raw_obj->f->v[i]);
free(raw_obj->f->vt[i]);
}
free(raw_obj->f->v);
free(raw_obj->f->vt);
free(raw_obj->v);
free(raw_obj->vt);
free(raw_obj->f);
} }