BMesh: Fix for previous own fix (re-enable DynamicPaint previews in Object mode).
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 23 Jan 2012 17:17:08 +0000 (17:17 +0000)
committerBastien Montagne <montagne29@wanadoo.fr>
Mon, 23 Jan 2012 17:17:08 +0000 (17:17 +0000)
In fact, we have to add a CD_WEIGHT_MCOL layer (if not yet present) when updating CD_WEIGHT_MLOOPCOL, else with modifiers modifying the topology (like subsurf), it will sigsev.

That step should probably be done at tesselation time, though…

source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/dynamicpaint.c

index 509cb40f01478b217635164f971eb10b5157c83c..686d6a4018c0e4e58c9cb5abee75a8a6f682d9cb 100644 (file)
@@ -1062,8 +1062,7 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
        if (wtcol_f) {
                unsigned char *wtcol_f_step = wtcol_f;
 # else
-       /* XXX Seems we still need to create a CD_WEIGHT_MCOL, else it sigsev...
-        *     Strange that we do not have that problem with DPaint VCol preview? */
+       /* XXX We have to create a CD_WEIGHT_MCOL, else it might sigsev (after a SubSurf mod, eg)... */
        if(!dm->getTessFaceDataArray(dm, CD_WEIGHT_MCOL))
                CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_CALLOC, NULL, numFaces);
 
index 9e30003f9c794bbb05f6adab35cdefa2240025e2..59b7b654a458a27692ff8a9225390c9faa603e0f 100644 (file)
@@ -1608,6 +1608,13 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
                                                        MPoly *mp = CDDM_get_polys(result);
                                                        int totpoly = result->numPolyData;
 
+                                                       /* XXX We have to create a CD_WEIGHT_MCOL, else it might sigsev
+                                                        *     (after a SubSurf mod, eg)... */
+                                                       if(!result->getTessFaceDataArray(result, CD_WEIGHT_MCOL)) {
+                                                               int numFaces = result->getNumTessFaces(result);
+                                                               CustomData_add_layer(&result->faceData, CD_WEIGHT_MCOL, CD_CALLOC, NULL, numFaces);
+                                                       }
+
                                                        /* Save preview results to weight layer to be
                                                        *   able to share same drawing methods */
                                                        col = CustomData_get_layer(&result->loopData, CD_WEIGHT_MLOOPCOL);