Code cleanup: don't use GHash for GPU_build_mesh_buffers().

At the point where GPU_build_mesh_buffers is called, the
face_vert_indices map has already been built; it contains the same
data in an easier-to-access format.
This commit is contained in:
Nicholas Bishop
2012-02-22 22:48:34 +00:00
parent 78e1da961c
commit fd87bf3ef6
3 changed files with 23 additions and 26 deletions

View File

@@ -420,10 +420,10 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node)
if(!G.background) {
node->draw_buffers =
GPU_build_mesh_buffers(map, bvh->faces,
GPU_build_mesh_buffers(node->face_vert_indices,
bvh->faces,
node->prim_indices,
node->totprim,
node->uniq_verts);
node->totprim);
}
node->flag |= PBVH_UpdateDrawBuffers;

View File

@@ -159,16 +159,21 @@ int GPU_buffer_legacy( struct DerivedMesh *dm );
/* Buffers for non-DerivedMesh drawing */
typedef struct GPU_Buffers GPU_Buffers;
GPU_Buffers *GPU_build_mesh_buffers(struct GHash *map,
struct MFace *mface, int *face_indices,
int totface, int uniq_verts);
GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4],
struct MFace *mface, int *face_indices, int totface);
void GPU_update_mesh_buffers(GPU_Buffers *buffers, struct MVert *mvert,
int *vert_indices, int totvert, int smooth);
GPU_Buffers *GPU_build_grid_buffers(struct DMGridData **grids,
int *grid_indices, int totgrid, int gridsize);
void GPU_update_grid_buffers(GPU_Buffers *buffers, struct DMGridData **grids,
int *grid_indices, int totgrid, int gridsize, int smooth);
void GPU_draw_buffers(GPU_Buffers *buffers);
void GPU_free_buffers(GPU_Buffers *buffers);
#endif

View File

@@ -1334,9 +1334,12 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert,
buffers->smooth = smooth;
}
GPU_Buffers *GPU_build_mesh_buffers(GHash *map, MFace *mface,
/*GPU_Buffers *GPU_build_mesh_buffers(GHash *map, MFace *mface,
int *face_indices, int totface,
int tot_uniq_verts)
int tot_uniq_verts)*/
GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4],
MFace *mface, int *face_indices,
int totface)
{
GPU_Buffers *buffers;
unsigned short *tri_data;
@@ -1365,29 +1368,18 @@ GPU_Buffers *GPU_build_mesh_buffers(GHash *map, MFace *mface,
MFace *f = mface + face_indices[i];
int v[3];
v[0]= f->v1;
v[1]= f->v2;
v[2]= f->v3;
v[0]= 0;
v[1]= 1;
v[2]= 2;
for(j = 0; j < (f->v4 ? 2 : 1); ++j) {
for(k = 0; k < 3; ++k) {
void *value, *key = SET_INT_IN_POINTER(v[k]);
int vbo_index;
value = BLI_ghash_lookup(map, key);
vbo_index = GET_INT_FROM_POINTER(value);
if(vbo_index < 0) {
vbo_index = -vbo_index +
tot_uniq_verts - 1;
}
*tri_data = vbo_index;
*tri_data = face_vert_indices[i][v[k]];
++tri_data;
}
v[0] = f->v4;
v[1] = f->v1;
v[2] = f->v3;
v[0] = 3;
v[1] = 0;
v[2] = 2;
}
}
glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB);