Code cleanup: don't use GHash for GPU_build_mesh_buffers().
authorNicholas Bishop <nicholasbishop@gmail.com>
Wed, 22 Feb 2012 22:48:34 +0000 (22:48 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Wed, 22 Feb 2012 22:48:34 +0000 (22:48 +0000)
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.

source/blender/blenlib/intern/pbvh.c
source/blender/gpu/GPU_buffers.h
source/blender/gpu/intern/gpu_buffers.c

index 7d57dd7d54608b07eec10146200655523646d842..81332dfba6aee968387fb7a69a3b228abf4f9a6f 100644 (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;
index 5c567c311636be220e46453c857bf061b210dc9b..e244b20bbb03d4496f91d05d015bc94100033cd6 100644 (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
index 0a4970a6a916b11e4689559ccaa16cfbe104204a..9a5585d4acec5abe8f7a68c594e77f751e9ef2d4 100644 (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);