diff options
author | Mike Erwin <significant.bit@gmail.com> | 2015-03-23 22:29:42 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2015-03-23 22:40:44 +0300 |
commit | 38321faa8d111ec51ebdeb7f2e939062d5e080a1 (patch) | |
tree | bb5c80313a0a2de4f11d83f84a7ccca5acd96b30 /source/blender/gpu/intern/gpu_buffers.c | |
parent | 722ddaaccd089457d40f4be01c891a91f707c597 (diff) |
cleanup: use spaces for alignment
while studying GPU lib
Diffstat (limited to 'source/blender/gpu/intern/gpu_buffers.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_buffers.c | 193 |
1 files changed, 98 insertions, 95 deletions
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index e622943597a..4b7dc7f5c9d 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -383,8 +383,9 @@ void GPU_buffer_free(GPUBuffer *buffer) BLI_mutex_unlock(&buffer_mutex); } -/* currently unused */ -// #define USE_GPU_POINT_LINK +#if 0 /* currently unused */ +# define USE_GPU_POINT_LINK +#endif typedef struct GPUVertPointLink { #ifdef USE_GPU_POINT_LINK @@ -452,7 +453,7 @@ static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int to int i, *mat_orig_to_new; mat_orig_to_new = MEM_callocN(sizeof(*mat_orig_to_new) * totmat, - "GPUDrawObject.mat_orig_to_new"); + "GPUDrawObject.mat_orig_to_new"); /* allocate the array and space for links */ gdo->vert_points = MEM_mallocN(sizeof(GPUVertPointLink) * gdo->totvert, "GPUDrawObject.vert_points"); @@ -1007,7 +1008,7 @@ const GPUBufferTypeSettings gpu_buffer_type_settings[] = { {GPU_buffer_copy_normal, GL_ARRAY_BUFFER_ARB, 3}, {GPU_buffer_copy_mcol, GL_ARRAY_BUFFER_ARB, 3}, {GPU_buffer_copy_uv, GL_ARRAY_BUFFER_ARB, 2}, - {GPU_buffer_copy_uv_texpaint, GL_ARRAY_BUFFER_ARB, 4}, + {GPU_buffer_copy_uv_texpaint, GL_ARRAY_BUFFER_ARB, 4}, {GPU_buffer_copy_edge, GL_ELEMENT_ARRAY_BUFFER_ARB, 2}, {GPU_buffer_copy_uvedge, GL_ELEMENT_ARRAY_BUFFER_ARB, 4} }; @@ -1498,6 +1499,7 @@ struct GPU_PBVH_Buffers { bool use_matcaps; float diffuse_color[4]; }; + typedef enum { VBO_ENABLED, VBO_DISABLED @@ -1577,8 +1579,8 @@ static void gpu_color_from_mask_quad_set(const CCGKey *key, } void GPU_update_mesh_pbvh_buffers(GPU_PBVH_Buffers *buffers, MVert *mvert, - int *vert_indices, int totvert, const float *vmask, - int (*face_vert_indices)[4], bool show_diffuse_color) + int *vert_indices, int totvert, const float *vmask, + int (*face_vert_indices)[4], bool show_diffuse_color) { VertexBufferFormat *vert_data; int i, j, k; @@ -1715,9 +1717,9 @@ void GPU_update_mesh_pbvh_buffers(GPU_PBVH_Buffers *buffers, MVert *mvert, } GPU_PBVH_Buffers *GPU_build_mesh_pbvh_buffers(int (*face_vert_indices)[4], - MFace *mface, MVert *mvert, - int *face_indices, - int totface) + MFace *mface, MVert *mvert, + int *face_indices, + int totface) { GPU_PBVH_Buffers *buffers; unsigned short *tri_data; @@ -1807,8 +1809,8 @@ GPU_PBVH_Buffers *GPU_build_mesh_pbvh_buffers(int (*face_vert_indices)[4], } void GPU_update_grid_pbvh_buffers(GPU_PBVH_Buffers *buffers, CCGElem **grids, - const DMFlagMat *grid_flag_mats, int *grid_indices, - int totgrid, const CCGKey *key, bool show_diffuse_color) + const DMFlagMat *grid_flag_mats, int *grid_indices, + int totgrid, const CCGKey *key, bool show_diffuse_color) { VertexBufferFormat *vert_data; int i, j, k, x, y; @@ -1921,51 +1923,51 @@ void GPU_update_grid_pbvh_buffers(GPU_PBVH_Buffers *buffers, CCGElem **grids, /* Build the element array buffer of grid indices using either * unsigned shorts or unsigned ints. */ #define FILL_QUAD_BUFFER(type_, tot_quad_, buffer_) \ - { \ - type_ *tri_data; \ - int offset = 0; \ - int i, j, k; \ - \ - glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, \ - sizeof(type_) * (tot_quad_) * 6, NULL, \ - GL_STATIC_DRAW_ARB); \ - \ - /* Fill the buffer */ \ - tri_data = glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, \ - GL_WRITE_ONLY_ARB); \ - if (tri_data) { \ - for (i = 0; i < totgrid; ++i) { \ - BLI_bitmap *gh = NULL; \ - if (grid_hidden) \ - gh = grid_hidden[(grid_indices)[i]]; \ - \ - for (j = 0; j < gridsize - 1; ++j) { \ - for (k = 0; k < gridsize - 1; ++k) { \ - /* Skip hidden grid face */ \ - if (gh && \ - paint_is_grid_face_hidden(gh, \ - gridsize, k, j)) \ - continue; \ - \ - *(tri_data++) = offset + j * gridsize + k + 1; \ - *(tri_data++) = offset + j * gridsize + k; \ - *(tri_data++) = offset + (j + 1) * gridsize + k; \ - \ - *(tri_data++) = offset + (j + 1) * gridsize + k + 1; \ - *(tri_data++) = offset + j * gridsize + k + 1; \ - *(tri_data++) = offset + (j + 1) * gridsize + k; \ - } \ - } \ - \ - offset += gridsize * gridsize; \ - } \ - glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB); \ - } \ - else { \ - glDeleteBuffersARB(1, &(buffer_)); \ - (buffer_) = 0; \ - } \ - } (void)0 + { \ + type_ *tri_data; \ + int offset = 0; \ + int i, j, k; \ + \ + glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, \ + sizeof(type_) * (tot_quad_) * 6, NULL, \ + GL_STATIC_DRAW_ARB); \ + \ + /* Fill the buffer */ \ + tri_data = glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, \ + GL_WRITE_ONLY_ARB); \ + if (tri_data) { \ + for (i = 0; i < totgrid; ++i) { \ + BLI_bitmap *gh = NULL; \ + if (grid_hidden) \ + gh = grid_hidden[(grid_indices)[i]]; \ + \ + for (j = 0; j < gridsize - 1; ++j) { \ + for (k = 0; k < gridsize - 1; ++k) { \ + /* Skip hidden grid face */ \ + if (gh && \ + paint_is_grid_face_hidden(gh, \ + gridsize, k, j)) \ + continue; \ + \ + *(tri_data++) = offset + j * gridsize + k + 1; \ + *(tri_data++) = offset + j * gridsize + k; \ + *(tri_data++) = offset + (j + 1) * gridsize + k; \ + \ + *(tri_data++) = offset + (j + 1) * gridsize + k + 1; \ + *(tri_data++) = offset + j * gridsize + k + 1; \ + *(tri_data++) = offset + (j + 1) * gridsize + k; \ + } \ + } \ + \ + offset += gridsize * gridsize; \ + } \ + glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB); \ + } \ + else { \ + glDeleteBuffersARB(1, &(buffer_)); \ + (buffer_) = 0; \ + } \ + } (void)0 /* end FILL_QUAD_BUFFER */ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *totquad) @@ -2021,7 +2023,7 @@ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *to } GPU_PBVH_Buffers *GPU_build_grid_pbvh_buffers(int *grid_indices, int totgrid, - BLI_bitmap **grid_hidden, int gridsize) + BLI_bitmap **grid_hidden, int gridsize) { GPU_PBVH_Buffers *buffers; int totquad; @@ -2103,7 +2105,6 @@ static void gpu_bmesh_vert_to_buffer_copy(BMVert *v, BM_ELEM_CD_GET_FLOAT(v, cd_vert_mask_offset), diffuse_color, vd->color); - /* Assign index for use in the triangle index buffer */ /* note: caller must set: bm->elem_index_dirty |= BM_VERT; */ @@ -2153,11 +2154,11 @@ static int gpu_bmesh_face_visible_count(GSet *bm_faces) /* Creates a vertex buffer (coordinate, normal, color) and, if smooth * shading, an element index buffer. */ void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers, - BMesh *bm, - GSet *bm_faces, - GSet *bm_unique_verts, - GSet *bm_other_verts, - bool show_diffuse_color) + BMesh *bm, + GSet *bm_faces, + GSet *bm_unique_verts, + GSet *bm_other_verts, + bool show_diffuse_color) { VertexBufferFormat *vert_data; void *tri_data; @@ -2204,8 +2205,8 @@ void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers, /* Initialize vertex buffer */ glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf); glBufferDataARB(GL_ARRAY_BUFFER_ARB, - sizeof(VertexBufferFormat) * totvert, - NULL, GL_STATIC_DRAW_ARB); + sizeof(VertexBufferFormat) * totvert, + NULL, GL_STATIC_DRAW_ARB); /* Fill vertex buffer */ vert_data = glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); @@ -2246,7 +2247,9 @@ void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers, float fmask = 0; int i; - // BM_iter_as_array(bm, BM_VERTS_OF_FACE, f, (void**)v, 3); +#if 0 + BM_iter_as_array(bm, BM_VERTS_OF_FACE, f, (void**)v, 3); +#endif BM_face_as_array_vert_tri(f, v); /* Average mask value */ @@ -2666,7 +2669,7 @@ bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, GSet *bm_faces, GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color); } else if (buffers->use_bmesh) { - /* due to dynamc nature of dyntopo, only get first material */ + /* due to dynamic nature of dyntopo, only get first material */ if (BLI_gset_size(bm_faces) > 0) { GSetIterator gs_iter; BMFace *f; @@ -2717,7 +2720,7 @@ static void gpu_pbvh_buffer_free_intern(GLuint id) if (pool->maxpbvhsize == pool->totpbvhbufids) { pool->maxpbvhsize += MAX_FREE_GPU_BUFF_IDS; pool->pbvhbufids = MEM_reallocN(pool->pbvhbufids, - sizeof(*pool->pbvhbufids) * pool->maxpbvhsize); + sizeof(*pool->pbvhbufids) * pool->maxpbvhsize); } /* insert the buffer into the beginning of the pool */ @@ -2742,33 +2745,33 @@ void GPU_free_pbvh_buffers(GPU_PBVH_Buffers *buffers) void GPU_draw_pbvh_BB(float min[3], float max[3], bool leaf) { const float quads[4][4][3] = { - { - {min[0], min[1], min[2]}, - {max[0], min[1], min[2]}, - {max[0], min[1], max[2]}, - {min[0], min[1], max[2]} - }, - - { - {min[0], min[1], min[2]}, - {min[0], max[1], min[2]}, - {min[0], max[1], max[2]}, - {min[0], min[1], max[2]} - }, - - { - {max[0], max[1], min[2]}, - {max[0], min[1], min[2]}, - {max[0], min[1], max[2]}, - {max[0], max[1], max[2]} - }, - - { - {max[0], max[1], min[2]}, - {min[0], max[1], min[2]}, - {min[0], max[1], max[2]}, - {max[0], max[1], max[2]} - }, + { + {min[0], min[1], min[2]}, + {max[0], min[1], min[2]}, + {max[0], min[1], max[2]}, + {min[0], min[1], max[2]} + }, + + { + {min[0], min[1], min[2]}, + {min[0], max[1], min[2]}, + {min[0], max[1], max[2]}, + {min[0], min[1], max[2]} + }, + + { + {max[0], max[1], min[2]}, + {max[0], min[1], min[2]}, + {max[0], min[1], max[2]}, + {max[0], max[1], max[2]} + }, + + { + {max[0], max[1], min[2]}, + {min[0], max[1], min[2]}, + {min[0], max[1], max[2]}, + {max[0], max[1], max[2]} + }, }; if (leaf) |