Quiet annoying warning:
[blender.git] / source / blender / blenkernel / intern / DerivedMesh.c
index 6ff3b20049c1ed950bdc108c96545b158705ac34..628c07f7a6d7cc21194081edc2034a3e94af7a34 100644 (file)
@@ -424,11 +424,11 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob)
        }
 
        /* yes, must be before _and_ after tesselate */
-       mesh_update_customdata_pointers(&tmp);
+       mesh_update_customdata_pointers(&tmp, TRUE);
 
        tmp.totface = mesh_recalcTesselation(&tmp.fdata, &tmp.ldata, &tmp.pdata, tmp.mvert, tmp.totface, tmp.totloop, tmp.totpoly);
 
-       mesh_update_customdata_pointers(&tmp);
+       mesh_update_customdata_pointers(&tmp, TRUE);
 
 
        CustomData_free(&me->vdata, me->totvert);
@@ -767,12 +767,10 @@ static void *get_orco_coords_dm(Object *ob, BMEditMesh *em, int layer, int *free
                   by a more flexible customdata system, but not simple */
                if(!em) {
                        ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
-                       if (clmd) {
-                               KeyBlock *kb= key_get_keyblock(ob_get_key(ob), clmd->sim_parms->shapekey_rest);
-       
-                               if(kb->data)
-                                       return kb->data;
-                       }
+                       KeyBlock *kb= key_get_keyblock(ob_get_key(ob), clmd->sim_parms->shapekey_rest);
+
+                       if(kb->data)
+                               return kb->data;
                }
 
                return NULL;
@@ -1111,6 +1109,8 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
        int draw_flag= ((scene->toolsettings->multipaint ? CALC_WP_MULTIPAINT : 0) |
                        (scene->toolsettings->auto_normalize ? CALC_WP_AUTO_NORMALIZE : 0));
 
+       short do_re_tessellate;
+
        if(mmd && !mmd->sculptlvl)
                has_multires = 0;
 
@@ -1170,7 +1170,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                 */
                if (deform_r) {
                        *deform_r = CDDM_from_mesh(me, ob);
-                       
+                        
                        if (build_shapekey_layers)
                                add_shapekey_layers(dm, me, ob);
                        
@@ -1411,12 +1411,20 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                dm->release(dm);
 
                CDDM_apply_vert_coords(finaldm, deformedVerts);
+
+               /* BMESH_TODO, do_re_tesselate recalculates normals anyway, this seems redundant! - campbell */
                CDDM_calc_normals(finaldm);
 
                if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT))
                        add_weight_mcol_dm(ob, finaldm, draw_flag);
+
+               do_re_tessellate= TRUE;
+
        } else if(dm) {
                finaldm = dm;
+
+               do_re_tessellate= TRUE;
+
        } else {
                int recalc_normals= 0;
 
@@ -1437,6 +1445,8 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
                
                if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT))
                        add_weight_mcol_dm(ob, finaldm, draw_flag);
+
+               do_re_tessellate= FALSE;
        }
 
        /* add an orco layer if needed */
@@ -1459,13 +1469,23 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
        }
 #endif /* WITH_GAMEENGINE */
 
-       /* Re-tesselation is necessary to push render data (uvs, textures, colors)
-          from loops and polys onto the tessfaces. This may be currently be redundant
-          in cases where the render mode doesn't use these inputs, but ideally
-          eventually tesselation would happen on-demand, and this is one of the primary
-          places it would be needed. */
-       finaldm->recalcTesselation(finaldm);
-       finaldm->calcNormals(finaldm);
+
+       /* need to check when this isnt needed.
+        * - when the mesh has no modifiers (shouldnt be needed)
+        * - deform only? (unside, can try skip) but need to double check
+        * - rebuild mesh with constructive modifier (ofcourse)
+        *
+        * Need to watch this, it can cause issues, see bug [#29338]
+        */
+       if (do_re_tessellate) {
+               /* Re-tesselation is necessary to push render data (uvs, textures, colors)
+                * from loops and polys onto the tessfaces. This may be currently be redundant
+                * in cases where the render mode doesn't use these inputs, but ideally
+                * eventually tesselation would happen on-demand, and this is one of the primary
+                * places it would be needed. */
+               finaldm->recalcTesselation(finaldm);
+               finaldm->calcNormals(finaldm);
+       }
 
        *final_r = finaldm;
 
@@ -2240,7 +2260,10 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
                                attribs->tface[a].array = tfdata->layers[layer].data;
                                attribs->tface[a].emOffset = tfdata->layers[layer].offset;
                                attribs->tface[a].glIndex = gattribs->layer[b].glindex;
-                       } /*else {
+                               /* attribs->tface[a].glTexco = gattribs->layer[b].gltexco; */ /* BMESH_TODO, trunk has this but not bmesh, need to investigate whats going on here - campbell */
+                       }
+                       /* BMESH ONLY, may need to get this working?, otherwise remove */
+                       /* else {
                                int player;
                                CustomData *pdata = dm->getPolyDataLayout(dm);
                                
@@ -2259,7 +2282,8 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
                                        attribs->tface[a].glTexco = gattribs->layer[b].gltexco;
                                        
                                }
-                       }*/
+                       }
+                       */
                }
                else if(gattribs->layer[b].type == CD_MCOL) {
                        /* vertex colors */