Commit: 3f0eb1fc4b222239dec1edba89410c4c408a9d2b
Author: Sergey Sharybin
Date:   Fri Jul 4 17:03:32 2014 +0600
https://developer.blender.org/rB3f0eb1fc4b222239dec1edba89410c4c408a9d2b

OpenSubdiv: Support edge and outline drawing

This gives some performance drop, most of it could be solved
by skipping base vertices synchronization when drawing both
outline ad solid view.

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

M       intern/opensubdiv/opensubdiv_capi.h
M       intern/opensubdiv/opensubdiv_gpu_capi.cc
M       source/blender/blenkernel/intern/CCGSubSurf.c
M       source/blender/blenkernel/intern/CCGSubSurf.h
M       source/blender/blenkernel/intern/subsurf_ccg.c

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

diff --git a/intern/opensubdiv/opensubdiv_capi.h 
b/intern/opensubdiv/opensubdiv_capi.h
index 36604d6..ccf88be 100644
--- a/intern/opensubdiv/opensubdiv_capi.h
+++ b/intern/opensubdiv/opensubdiv_capi.h
@@ -70,7 +70,7 @@ void openSubdiv_osdGLMeshUpdateVertexBuffer(struct 
OpenSubdiv_GLMesh *gl_mesh,
                                             int num_verts);
 void openSubdiv_osdGLMeshRefine(struct OpenSubdiv_GLMesh *gl_mesh);
 void openSubdiv_osdGLMeshSynchronize(struct OpenSubdiv_GLMesh *gl_mesh);
-void openSubdiv_osdGLMeshDisplay(struct OpenSubdiv_GLMesh *gl_mesh);
+void openSubdiv_osdGLMeshDisplay(struct OpenSubdiv_GLMesh *gl_mesh, int 
fill_quads);
 void openSubdiv_osdGLMeshBindvertexBuffer(struct OpenSubdiv_GLMesh *gl_mesh);
 
 int openSubdiv_getAvailableControllers(void);
diff --git a/intern/opensubdiv/opensubdiv_gpu_capi.cc 
b/intern/opensubdiv/opensubdiv_gpu_capi.cc
index 29ce53c..33a678e 100644
--- a/intern/opensubdiv/opensubdiv_gpu_capi.cc
+++ b/intern/opensubdiv/opensubdiv_gpu_capi.cc
@@ -111,7 +111,7 @@ static GLuint linkProgram(const char *define)
 }
 #endif  /* OPENSUBDIV_LEGACY_DRAW */
 
-void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh *gl_mesh)
+void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh *gl_mesh, int fill_quads)
 {
 #ifndef OPENSUBDIV_LEGACY_DRAW
        static GLuint quad_fill_program = 0;
@@ -134,6 +134,10 @@ void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh 
*gl_mesh)
        glUseProgram(quad_fill_program);
 #endif
 
+       if (!fill_quads) {
+               glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+       }
+
        for (int i = 0; i < (int)patches.size(); ++i) {
                OpenSubdiv::OsdDrawContext::PatchArray const &patch = 
patches[i];
                OpenSubdiv::OsdDrawContext::PatchDescriptor desc = 
patch.GetDescriptor();
@@ -146,6 +150,14 @@ void openSubdiv_osdGLMeshDisplay(OpenSubdiv_GLMesh 
*gl_mesh)
                                       NULL);
                }
        }
+
+       /* Restore state. */
+       if (!fill_quads) {
+               glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+       }
        glBindVertexArray(0);
+#ifndef OPENSUBDIV_LEGACY_DRAW
+       /* TODO(sergey): Store previously used program and roll back to it? */
        glUseProgram(0);
+#endif
 }
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c 
b/source/blender/blenkernel/intern/CCGSubSurf.c
index 13098bf..e282ada 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -2388,12 +2388,12 @@ void ccgSubSurf_prepareGLMesh(CCGSubSurf *ss)
        }
 }
 
-void ccgSubSurf_drawGLMesh(CCGSubSurf *ss)
+void ccgSubSurf_drawGLMesh(CCGSubSurf *ss, bool fill_quads)
 {
        if (LIKELY(ss->osd_mesh != NULL)) {
                openSubdiv_osdGLMeshBindvertexBuffer(ss->osd_mesh);
                glBindVertexArray(ss->osd_vao);
-               openSubdiv_osdGLMeshDisplay(ss->osd_mesh);
+               openSubdiv_osdGLMeshDisplay(ss->osd_mesh, fill_quads);
                glBindVertexArray(0);
                glBindBuffer(GL_ARRAY_BUFFER, 0);
        }
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.h 
b/source/blender/blenkernel/intern/CCGSubSurf.h
index 93f4756..4589927 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.h
+++ b/source/blender/blenkernel/intern/CCGSubSurf.h
@@ -188,7 +188,7 @@ void                                ccgFaceIterator_free    
        (CCGFaceIterator *fi);
 
 #ifdef WITH_OPENSUBDIV
 void ccgSubSurf_prepareGLMesh(CCGSubSurf *ss);
-void ccgSubSurf_drawGLMesh(CCGSubSurf *ss);
+void ccgSubSurf_drawGLMesh(CCGSubSurf *ss, bool fill_quads);
 void ccgSubSurf_setSkipGrids(CCGSubSurf *ss, bool skip_grids);
 #endif
 
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c 
b/source/blender/blenkernel/intern/subsurf_ccg.c
index e494f38..fb49569 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -1662,10 +1662,9 @@ static void ccgDM_drawEdges(DerivedMesh *dm, bool 
drawLooseEdges, bool drawAllEd
 
 #ifdef WITH_OPENSUBDIV
        if (!ccgSubSurf_getSimpleSubdiv(ss)) {
-               /* TODO(sergey): Support edge drawing. */
-               (void) dm;
-               (void) drawLooseEdges;
-               (void) drawAllEdges;
+               /* TODO(sergey): We currently only support all edges drawing. */
+               ccgSubSurf_prepareGLMesh(ss);
+               ccgSubSurf_drawGLMesh(ss, false);
                return;
        }
 #endif
@@ -1809,7 +1808,7 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float 
(*partial_redraw_planes)
                glShadeModel(shademodel);
 
                ccgSubSurf_prepareGLMesh(ss);
-               ccgSubSurf_drawGLMesh(ss);
+               ccgSubSurf_drawGLMesh(ss, true);
 
                /* We're done with drawing if drawing happens using OpenSubdiv. 
*/
                return;

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

Reply via email to