- more fixes for wpaint mode, need to patch mesh modifier as well
authorDaniel Dunbar <daniel@zuster.org>
Tue, 23 Aug 2005 21:04:17 +0000 (21:04 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 23 Aug 2005 21:04:17 +0000 (21:04 +0000)
 - change wpaint to flush changes during painting... can see this
   is going to be a problem because will also redeform. what to
   do, what to do...

source/blender/blenkernel/intern/DerivedMesh.c
source/blender/src/vpaint.c

index da5e40268ddfea64a30cf6d135fe9e44a3f11b5c..16882eb91a5e9f189ee46a847148c5e91f66d04c 100644 (file)
@@ -77,6 +77,7 @@ typedef struct {
        Mesh *me;
        MVert *verts;
        float *nors;
+       MCol *wpaintMCol;
 
        int freeNors, freeVerts;
 } MeshDerivedMesh;
@@ -382,7 +383,9 @@ static void meshDM_drawFacesTex(DerivedMesh *dm, int (*setDrawParams)(TFace *tf,
                if (flag==0) {
                        continue;
                } else if (flag==1) {
-                       if (tf) {
+                       if (mdm->wpaintMCol) {
+                               cp= (unsigned char*) &mdm->wpaintMCol[i*4];
+                       } else if (tf) {
                                cp= (unsigned char*) tf->col;
                        } else if (me->mcol) {
                                cp= (unsigned char*) &me->mcol[i*4];
@@ -435,7 +438,9 @@ static void meshDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *
                        unsigned char *cp = NULL;
 
                        if (useColors) {
-                               if (me->tface) {
+                               if (mdm->wpaintMCol) {
+                                       cp= (unsigned char*) &mdm->wpaintMCol[i*4];
+                               } else if (me->tface) {
                                        cp= (unsigned char*) me->tface[i].col;
                                } else if (me->mcol) {
                                        cp= (unsigned char*) &me->mcol[i*4];
@@ -498,6 +503,7 @@ static void meshDM_release(DerivedMesh *dm)
 {
        MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
 
+       if (mdm->wpaintMCol) MEM_freeN(mdm->wpaintMCol);
        if (mdm->freeNors) MEM_freeN(mdm->nors);
        if (mdm->freeVerts) MEM_freeN(mdm->verts);
        MEM_freeN(mdm);
@@ -531,7 +537,12 @@ static DerivedMesh *getMeshDerivedMesh(Mesh *me, Object *ob, float (*vertCos)[3]
        mdm->dm.drawMappedFaces = meshDM_drawMappedFaces;
 
        mdm->dm.release = meshDM_release;
-       
+
+               /* Works in conjunction with hack during modifier calc */
+       if (G.f & G_WEIGHTPAINT) {
+               mdm->wpaintMCol = MEM_dupallocN(me->mcol);
+       }
+
        mdm->ob = ob;
        mdm->me = me;
        mdm->verts = me->mvert;
index 60d602e1e8a759a73ed6b885571e72a6bcbacb54..8b9f2be186778c57307935085b94e89321a1d87d 100644 (file)
@@ -1101,6 +1101,7 @@ void weight_paint(void)
                
                if(mval[0]!=mvalo[0] || mval[1]!=mvalo[1]) {
 
+                       DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
                        scrarea_do_windraw(curarea);
                        
                        if(Gwp.flag & (VP_AREA|VP_SOFT)) {