svn merge -r41575:41602 ^/trunk/blender
[blender.git] / source / blender / editors / sculpt_paint / paint_image.c
index ce603ce80b65ba62d3973c4f43f2244f1a42925a..85d46d9e627e74c255e98c06392fad2bb968e5ff 100644 (file)
@@ -2922,11 +2922,11 @@ static void project_paint_begin(ProjPaintState *ps)
        }
        
        ps->dm_mvert = ps->dm->getVertArray(ps->dm);
-       ps->dm_mface = ps->dm->getFaceArray(ps->dm);
-       ps->dm_mtface= ps->dm->getFaceDataArray(ps->dm, CD_MTFACE);
+       ps->dm_mface = ps->dm->getTessFaceArray(ps->dm);
+       ps->dm_mtface= ps->dm->getTessFaceDataArray(ps->dm, CD_MTFACE);
        
        ps->dm_totvert = ps->dm->getNumVerts(ps->dm);
-       ps->dm_totface = ps->dm->getNumFaces(ps->dm);
+       ps->dm_totface = ps->dm->getNumTessFaces(ps->dm);
        
        /* use clone mtface? */
        
@@ -2959,15 +2959,18 @@ static void project_paint_begin(ProjPaintState *ps)
        }
        
        /* when using subsurf or multires, mface arrays are thrown away, we need to keep a copy */
-       if(ps->dm->type != DM_TYPE_CDDM) {
+       // this seems like a bad check, since some constructive modifiers use cddm? - joeedh
+       if(1) { //ps->dm->type != DM_TYPE_CDDM) {
                ps->dm_mvert= MEM_dupallocN(ps->dm_mvert);
                ps->dm_mface= MEM_dupallocN(ps->dm_mface);
                /* looks like these are ok for now.*/
-               /*
+               
                ps->dm_mtface= MEM_dupallocN(ps->dm_mtface);
-               ps->dm_mtface_clone= MEM_dupallocN(ps->dm_mtface_clone);
-               ps->dm_mtface_stencil= MEM_dupallocN(ps->dm_mtface_stencil);
-                */
+               if (ps->dm_mtface_clone)
+                       ps->dm_mtface_clone= MEM_dupallocN(ps->dm_mtface_clone);
+               if (ps->dm_mtface_stencil)
+                       ps->dm_mtface_stencil= MEM_dupallocN(ps->dm_mtface_stencil);
+                
        }
        
        ps->viewDir[0] = 0.0f;
@@ -3445,7 +3448,8 @@ static void project_paint_end(ProjPaintState *ps)
        }
        
        /* copy for subsurf/multires, so throw away */
-       if(ps->dm->type != DM_TYPE_CDDM) {
+       // this seems like a bad check, since some constructive modifiers use cddm? - joeedh
+       if(1) { //ps->dm->type != DM_TYPE_CDDM) {
                if(ps->dm_mvert) MEM_freeN(ps->dm_mvert);
                if(ps->dm_mface) MEM_freeN(ps->dm_mface);
                /* looks like these dont need copying */
@@ -4754,9 +4758,29 @@ static int texture_paint_init(bContext *C, wmOperator *op)
        pop->orig_brush_size= brush_size(brush);
 
        if(pop->mode != PAINT_MODE_2D) {
+               Mesh *me;
+
                pop->s.ob = OBACT;
+               if (!pop->ps.ob)
+                       pop->ps.ob = pop->s.ob;
+               
                pop->s.me = get_mesh(pop->s.ob);
                if (!pop->s.me) return 0;
+               
+               me = pop->s.me;
+
+               /*recalc mesh tesselation so the face origindex values point
+                 to the tesselation faces themselves, instead of polys*/
+               me->totface = mesh_recalcTesselation(&me->fdata, &me->ldata, 
+                       &me->pdata, me->mvert, me->totface, me->totloop, me->totpoly, 0, 1);
+               mesh_update_customdata_pointers(me);
+               
+               /*force customdata update*/
+               makeDerivedMesh(scene, pop->ps.ob, NULL, CD_MASK_BAREMESH, 0);
+
+               /* Dont allow brush size below 2 */
+               if (pop->ps.brush && pop->ps.brush->size<=1)
+                       pop->ps.brush->size = 2;
        }
        else {
                pop->s.image = pop->s.sima->image;