Commit: 76eebcde3a7ae4487abb15f63d956673bc4517a3
Author: Antony Riakiotakis
Date:   Thu Jul 16 17:33:32 2015 +0200
Branches: temp-derivedmesh-looptri
https://developer.blender.org/rB76eebcde3a7ae4487abb15f63d956673bc4517a3

Merge branch 'master' into temp-derivedmesh-looptri

Conflicts:
        source/blender/gpu/GPU_buffers.h
        source/blender/gpu/intern/gpu_buffers.c

===================================================================



===================================================================

diff --cc source/blender/blenkernel/intern/cdderivedmesh.c
index 6381322,c16af7c..b7ccec2
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@@ -654,12 -666,12 +654,12 @@@ static void cdDM_drawMappedFaces
                unsigned int *fi_map;
  
                findex_buffer = GPU_buffer_alloc(dm->drawObject->tot_loop_verts 
* sizeof(int), false);
-               fi_map = GPU_buffer_lock(findex_buffer);
+               fi_map = GPU_buffer_lock(findex_buffer, GPU_BINDING_ARRAY);
  
                if (fi_map) {
 -                      for (i = 0; i < dm->numTessFaceData; i++, mf++) {
 +                      for (i = 0; i < totpoly; i++, mpoly++) {
                                int selcol = 0xFFFFFFFF;
 -                              orig = (index_mf_to_mpoly) ? 
DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, i) : i;
 +                              orig = (index_mp_to_orig) ? index_mp_to_orig[i] 
: i;
  
                                if ((orig != ORIGINDEX_NONE) && (!useHide || 
!(me->mpoly[orig].flag & ME_HIDE))) {
                                        WM_framebuffer_index_get(orig + 1, 
&selcol);
@@@ -670,9 -686,10 +670,9 @@@
                        }
  
                        start_element = 0;
 -                      mf = cddm->mface;
 +                      mpoly = cddm->mpoly;
  
-                       GPU_buffer_unlock(findex_buffer);
+                       GPU_buffer_unlock(findex_buffer, GPU_BINDING_ARRAY);
                        GPU_buffer_bind_as_color(findex_buffer);
                }
        }
@@@ -1058,9 -1107,14 +1058,9 @@@ static void cdDM_drawMappedFacesGLSL
                                        }
                                }
  
 -                              if (mface->v4) {
 -                                      tot_loops += 4;
 -                              }
 -                              else {
 -                                      tot_loops += 3;
 -                              }
 +                              tot_loops += mpoly->totloop;
                        }
-                       GPU_buffer_unlock(buffer);
+                       GPU_buffer_unlock(buffer, GPU_BINDING_ARRAY);
                }
  
                for (a = 0; a < tot_active_mat; a++) {
diff --cc source/blender/gpu/GPU_buffers.h
index 3a8b71c,9c2ca6c..0176394
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@@ -202,14 -212,12 +212,14 @@@ void GPU_interleaved_attrib_unbind(void
  typedef struct GPU_PBVH_Buffers GPU_PBVH_Buffers;
  
  /* build */
 -GPU_PBVH_Buffers *GPU_build_mesh_pbvh_buffers(const int 
(*face_vert_indices)[4],
 -        const struct MFace *mface, const struct MVert *mvert,
 -        const int *face_indices, int totface);
 +GPU_PBVH_Buffers *GPU_build_mesh_pbvh_buffers(
 +        const int (*face_vert_indices)[4],
 +        const struct MPoly *mpoly, const struct MLoop *mloop, const struct 
MLoopTri *looptri,
 +        const struct MVert *verts,
 +        const int *face_indices, int totprim);
  
  GPU_PBVH_Buffers *GPU_build_grid_pbvh_buffers(int *grid_indices, int totgrid,
-                                     unsigned int **grid_hidden, int gridsize);
+                                     unsigned int **grid_hidden, int gridsize, 
const struct CCGKey *key);
  
  GPU_PBVH_Buffers *GPU_build_bmesh_pbvh_buffers(int smooth_shading);
  
diff --cc source/blender/gpu/intern/gpu_buffers.c
index 370a11f,d30ca9f..b5ea91a
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@@ -1337,51 -1344,50 +1341,43 @@@ GPU_PBVH_Buffers *GPU_build_mesh_pbvh_b
        /* An element index buffer is used for smooth shading, but flat
         * shading requires separate vertex normals so an index buffer is
         * can't be used there. */
-       if (gpu_vbo_enabled() && buffers->smooth)
-               glGenBuffersARB(1, &buffers->index_buf);
+       if (buffers->smooth)
+               buffers->index_buf = GPU_buffer_alloc(sizeof(unsigned short) * 
tottri * 3, false);
  
        if (buffers->index_buf) {
-               /* Generate index buffer object */
-               glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 
buffers->index_buf);
-               glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
-                               sizeof(unsigned short) * tottri * 3, NULL, 
GL_STATIC_DRAW_ARB);
- 
                /* Fill the triangle buffer */
-               tri_data = glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 
GL_WRITE_ONLY_ARB);
+               tri_data = GPU_buffer_lock(buffers->index_buf, 
GPU_BINDING_INDEX);
                if (tri_data) {
 -                      for (i = 0; i < totface; ++i) {
 -                              const MFace *f = mface + face_indices[i];
 -                              int v[3];
 +                      for (i = 0; i < looptri_num; ++i) {
 +                              const MLoopTri *lt = &looptri[face_indices[i]];
  
                                /* Skip hidden faces */
 -                              if (paint_is_face_hidden(f, mvert))
 +                              if (paint_is_face_hidden(lt, mvert, mloop))
                                        continue;
  
 -                              v[0] = 0;
 -                              v[1] = 1;
 -                              v[2] = 2;
 -
 -                              for (j = 0; j < (f->v4 ? 2 : 1); ++j) {
 -                                      for (k = 0; k < 3; ++k) {
 -                                              *tri_data = 
face_vert_indices[i][v[k]];
 -                                              tri_data++;
 -                                      }
 -                                      v[0] = 3;
 -                                      v[1] = 0;
 -                                      v[2] = 2;
 +                              for (j = 0; j < 3; ++j) {
 +                                      *tri_data = face_vert_indices[i][j];
 +                                      tri_data++;
                                }
                        }
-                       glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB);
+                       GPU_buffer_unlock(buffers->index_buf, 
GPU_BINDING_INDEX);
                }
                else {
-                       glDeleteBuffersARB(1, &buffers->index_buf);
-                       buffers->index_buf = 0;
+                       GPU_buffer_free(buffers->index_buf);
+                       buffers->index_buf = NULL;
                }
  
                glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
        }
  
-       if (gpu_vbo_enabled() && (buffers->index_buf || !buffers->smooth))
-               glGenBuffersARB(1, &buffers->vert_buf);
- 
        buffers->tot_tri = tottri;
  
 -      buffers->mface = mface;
 +      buffers->mpoly = mpoly;
 +      buffers->mloop = mloop;
 +      buffers->looptri = looptri;
 +
        buffers->face_indices = face_indices;
 -      buffers->totface = totface;
 +      buffers->totface = looptri_num;
  
        return buffers;
  }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to