[#21067] Weight painting doesn't work with mirror modifier enabled.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 9 Feb 2010 18:06:57 +0000 (18:06 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 9 Feb 2010 18:06:57 +0000 (18:06 +0000)
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/cdderivedmesh.c

index decea8c4127f7ec76fbecb02f778c4d6381d18b7..b13f914e2e78c8fc9ed59783d4c394f02744ebf7 100644 (file)
@@ -1771,6 +1771,22 @@ 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, dm);
+
+                               /* constructive modifiers need to have an origindex
+                                * otherwise they wont have anywhere to copy the data from */
+                               if(needMapping) {
+                                       int *index, i;
+                                       DM_add_vert_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
+                                       DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
+                                       DM_add_face_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
+
+                                       index = DM_get_vert_data_layer(dm, CD_ORIGINDEX);
+                                       for(i=0; i<dm->numVertData; i++) *index++= i;
+                                       index = DM_get_edge_data_layer(dm, CD_ORIGINDEX);
+                                       for(i=0; i<dm->numEdgeData; i++) *index++= i;
+                                       index = DM_get_face_data_layer(dm, CD_ORIGINDEX);
+                                       for(i=0; i<dm->numFaceData; i++) *index++= i;
+                               }
                        }
 
                        /* create an orco derivedmesh in parallel */
@@ -2109,9 +2125,9 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask)
        Object *obact = scene->basact?scene->basact->object:NULL;
        int editing = paint_facesel_test(ob);
        /* weight paint and face select need original indicies because of selection buffer drawing */
-       int needMapping = (ob==obact) && (editing || (ob->mode & OB_MODE_WEIGHT_PAINT) || paint_facesel_test(ob));
+       int needMapping = (ob==obact) && (editing || (ob->mode & OB_MODE_WEIGHT_PAINT) || editing);
        float min[3], max[3];
-       
+
        clear_mesh_caches(ob);
 
        mesh_calc_modifiers(scene, ob, NULL, &ob->derivedDeform,
index 51c5ca4bc9b9927163662591fda9ed63a9f85a00..c091a7b251fe4f8e106f51a36a62b30b11df308e 100644 (file)
@@ -1021,7 +1021,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
                char *varray = 0;
                int numdata = 0, elementsize = 0, offset;
                int start = 0, numfaces = 0, prevdraw = 0, curface = 0;
-               GPUAttrib datatypes[32];
+               GPUAttrib datatypes[GPU_MAX_ATTRIB]; /* TODO, messing up when switching materials many times - [#21056]*/
                memset(&attribs, 0, sizeof(attribs));
 
                GPU_vertex_setup(dm);