Access sub elements of a subdivided face?

How do you access the resulting top level verts, faces and edges of a face that has been subdivided in a nice way?

I use this but is there a nicer way (eg. base_face->sub_verts[y * row_size + x] ) ?

``````/*
*  creates a larger grid from each quarter grid so that x and y access is
*  for the entire face, as oposed to each corner of the face
*/
static void fill_elems_in_order(CCGKey *key, int g_idx, CCGElem **grids, CCGElem **r_sub_vs)
{
printf("FUNCTION: fill_elems_in_order \n");

int grid_size = key->grid_size;
int size_last = grid_size - 1;
int width = grid_size * 2 - 1;

/* top-left quarter */
int row = 0, col;
for (int x = size_last; x >= 0; x--, row++) {

col = 0;
for (int y = size_last; y >= 0; y--, col++) {

int idx = row * width + col;
r_sub_vs[idx] = CCG_grid_elem(key, grids[g_idx], x, y);
}
}

/* top-right quarter */
row = 0;
for (int y = size_last; y >= 0; y--, row++) {

col = size_last;
for (int x = 0; x < grid_size; x++, col++) {

int idx = row * width + col;
r_sub_vs[idx] = CCG_grid_elem(key, grids[g_idx + 1], x, y);
}
}

/* bot-right quarter */
row = size_last;
for (int x = 0; x < grid_size; x++, row++) {

col = size_last;
for (int y = 0; y < grid_size; y++, col++) {

int idx = row * width + col;
r_sub_vs[idx] = CCG_grid_elem(key, grids[g_idx + 2], x, y);
}
}

/* bot-left quarter */
row = size_last;
for (int y = 0; y < grid_size; y++, row++) {

col = 0;
for (int x = size_last; x >= 0; x--, col++) {

int idx = row * width + col;
r_sub_vs[idx] = CCG_grid_elem(key, grids[g_idx + 3], x, y);
}
}

printf("  verts in order \n");
for (int y = 0; y < width; y++) {
for (int x = 0; x < width; x++) {

int idx = y * width + x;
float *co = CCG_elem_co(key, r_sub_vs[idx]);
printf("    r_sub_vs_co[%d][%d] = %f %f %f \n", x, y, co[0], co[1], co[2]);
}
}
printf("\n");
}``````

There is no more convenient way as far as I know.

Thanks, but its still weird