OpenSubdiv: Properly support active UV layer in textured view
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 22 Jul 2016 12:50:21 +0000 (14:50 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 22 Jul 2016 12:56:15 +0000 (14:56 +0200)
intern/opensubdiv/opensubdiv_gpu_capi.cc
source/blender/blenkernel/intern/subsurf_ccg.c

index a7c42aea07f39467f159edc6ed20b38b1f209956..16a86f66265d44f8f4b1e2f879a9e7d2a017ebdf 100644 (file)
@@ -439,7 +439,10 @@ void bindProgram(OpenSubdiv_GLMesh *gl_mesh, int program)
        /* See notes below about why we use such values. */
        /* TOO(sergey): Get proper value for FVar width. */
        glUniform1i(glGetUniformLocation(program, "osd_fvar_count"), 2);
-       if (gl_mesh->fvar_data->channel_offsets.size() > 0 && g_active_uv_index >= 0) {
+       if (gl_mesh->fvar_data != NULL &&
+           gl_mesh->fvar_data->channel_offsets.size() > 0 &&
+           g_active_uv_index >= 0)
+       {
                glUniform1i(glGetUniformLocation(program, "osd_active_uv_offset"),
                            gl_mesh->fvar_data->channel_offsets[g_active_uv_index]);
        } else {
@@ -624,7 +627,10 @@ static GLuint prepare_patchDraw(OpenSubdiv_GLMesh *gl_mesh,
 
                                location = glGetUniformLocation(program, "osd_active_uv_offset");
                                if (location != -1) {
-                                       if (gl_mesh->fvar_data->channel_offsets.size() > 0 && g_active_uv_index >= 0) {
+                                       if (gl_mesh->fvar_data != NULL &&
+                                           gl_mesh->fvar_data->channel_offsets.size() > 0 &&
+                                           g_active_uv_index >= 0)
+                                       {
                                                glUniform1i(location,
                                                            gl_mesh->fvar_data->channel_offsets[g_active_uv_index]);
                                        } else {
index c6e20b995ba1e9b6ba7d7d2852c8e65968b64cb6..7239566b59ddd5fc2e86d6bc8a19a344935c4627 100644 (file)
@@ -3401,7 +3401,8 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
 
 #ifdef WITH_OPENSUBDIV
        if (ccgdm->useGpuBackend) {
-               if (UNLIKELY(ccgSubSurf_prepareGLMesh(ss, true, -1) == false)) {
+               const int active_uv_layer = CustomData_get_active_layer_index(&dm->loopData, CD_MLOOPUV);
+               if (UNLIKELY(ccgSubSurf_prepareGLMesh(ss, true, active_uv_layer) == false)) {
                        return;
                }
                if (drawParams == NULL) {