Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / source / blender / blenkernel / intern / cdderivedmesh.c
index 538e65b..706eece 100644 (file)
@@ -482,10 +482,14 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
        CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
        MVert *mv = cddm->mvert;
        MFace *mf = cddm->mface;
-       MCol *mc = DM_get_face_data_layer(dm, CD_MCOL);
+       MCol *mc;
        float *nors= dm->getFaceDataArray(dm, CD_NORMAL);
        int i, orig, *index = DM_get_face_data_layer(dm, CD_ORIGINDEX);
 
+       mc = DM_get_face_data_layer(dm, CD_WEIGHT_MCOL);
+       if(!mc)
+               mc = DM_get_face_data_layer(dm, CD_MCOL);
+
        for(i = 0; i < dm->numFaceData; i++, mf++) {
                int drawSmooth = (mf->flag & ME_SMOOTH);
 
@@ -926,13 +930,6 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *ob)
        index = CustomData_get_layer(&dm->faceData, CD_ORIGINDEX);
        for(i = 0; i < mesh->totface; ++i, ++index)
                *index = i;
-       
-       /* works in conjunction with hack during modifier calc, where active mcol
-          layer with weight paint colors is temporarily added */
-       /* XXX make this real but temporary layer */
-//     if ((G.f & G_WEIGHTPAINT) &&
-//             (ob && ob==(scene->basact?scene->basact->object:NULL)))
-//             CustomData_duplicate_referenced_layer(&dm->faceData, CD_MCOL);
 
        return dm;
 }
@@ -1223,7 +1220,7 @@ void CDDM_calc_edges(DerivedMesh *dm)
        BLI_edgehashIterator_free(ehi);
 
        /* free old CustomData and assign new one */
-       CustomData_free(&dm->edgeData, dm->numVertData);
+       CustomData_free(&dm->edgeData, dm->numEdgeData);
        dm->edgeData = edgeData;
        dm->numEdgeData = numEdges;
 
@@ -1301,7 +1298,7 @@ typedef struct MultiresDM {
        int *face_offsets;
 
        Mesh *me;
-       int flags;
+       int modified;
 
        void (*update)(DerivedMesh*);
 } MultiresDM;
@@ -1312,7 +1309,7 @@ static void MultiresDM_release(DerivedMesh *dm)
        int mvert_layer;
 
        /* Before freeing, need to update the displacement map */
-       if(dm->needsFree && !(mrdm->flags & MULTIRES_DM_UPDATE_BLOCK))
+       if(dm->needsFree && mrdm->modified)
                mrdm->update(dm);
 
        /* If the MVert data is being used as the sculpt undo store, don't free it */
@@ -1385,7 +1382,7 @@ DerivedMesh *MultiresDM_new(MultiresSubsurf *ms, DerivedMesh *orig, int numVerts
        mrdm->lvl = ms->mmd->lvl;
        mrdm->totlvl = ms->mmd->totlvl;
        mrdm->subco = MEM_callocN(sizeof(MVert)*numVerts, "multires subdivided verts");
-       mrdm->flags = 0;
+       mrdm->modified = 0;
 
        dm->release = MultiresDM_release;
 
@@ -1471,7 +1468,7 @@ int *MultiresDM_get_face_offsets(DerivedMesh *dm)
        return mrdm->face_offsets;
 }
 
-int *MultiresDM_get_flags(DerivedMesh *dm)
+void MultiresDM_mark_as_modified(DerivedMesh *dm)
 {
-       return &((MultiresDM*)dm)->flags;
+       ((MultiresDM*)dm)->modified = 1;
 }