Revision: 43639 http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43639 Author: mont29 Date: 2012-01-23 16:32:11 +0000 (Mon, 23 Jan 2012) Log Message: ----------- BMesh: Fix (re-enable) DynamicPaint previews in Object mode.
Also simplifies DM_update_weight_mcol: no need to update CD_WEIGHT_MCOL here, as it is anyway recreated from CD_WEIGHT_MLOOPCOL at tesselation time. Only commented out code for now. Modified Paths: -------------- branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c branches/bmesh/blender/source/blender/blenkernel/intern/dynamicpaint.c branches/bmesh/blender/source/blender/editors/space_view3d/drawobject.c Modified: branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c =================================================================== --- branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c 2012-01-23 14:03:09 UTC (rev 43638) +++ branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c 2012-01-23 16:32:11 UTC (rev 43639) @@ -1040,9 +1040,13 @@ ColorBand *coba= stored_cb; /* warning, not a local var */ unsigned char *wtcol_v; +#if 0 /* See coment below. */ unsigned char *wtcol_f = dm->getTessFaceDataArray(dm, CD_WEIGHT_MCOL); +#endif unsigned char(*wtcol_l)[4] = CustomData_get_layer(dm->getLoopDataLayout(dm), CD_WEIGHT_MLOOPCOL); +#if 0 /* See coment below. */ MFace *mf = dm->getTessFaceArray(dm); +#endif MLoop *mloop = dm->getLoopArray(dm), *ml; MPoly *mp = dm->getPolyArray(dm); int numFaces = dm->getNumTessFaces(dm); @@ -1050,13 +1054,22 @@ int totloop; int i, j; +#if 0 /* See comment below */ /* If no CD_WEIGHT_MCOL existed yet, add a new one! */ if (!wtcol_f) wtcol_f = CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_CALLOC, NULL, numFaces); 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? */ + if(!dm->getTessFaceDataArray(dm, CD_WEIGHT_MCOL)) + CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_CALLOC, NULL, numFaces); + { +#endif + /* Weights are given by caller. */ if (weights) { float *w = weights; @@ -1082,6 +1095,10 @@ /* Now copy colors in all face verts. */ /*first add colors to the tesselation faces*/ + /* XXX Why update that layer? We have to update WEIGHT_MLOOPCOL anyway, + * and tesselation recreates mface layers from mloop/mpoly ones, so no + * need to fill WEIGHT_MCOL here. */ +#if 0 for (i = 0; i < numFaces; i++, mf++, wtcol_f_step += (4 * 4)) { /*origindex being NULL means we're operating on original mesh data*/ #if 0 @@ -1103,7 +1120,7 @@ (char *)&wtcol_v[4 * (*(&mf->v1 + fidx))]); } while (fidx--); } - +#endif /*now add to loops, so the data can be passed through the modifier stack*/ /* If no CD_WEIGHT_MLOOPCOL existed yet, we have to add a new one! */ if (!wtcol_l) { @@ -1470,10 +1487,6 @@ range_vn_i(DM_get_edge_data_layer(dm, CD_ORIGINDEX), dm->numEdgeData, 0); range_vn_i(DM_get_poly_data_layer(dm, CD_ORIGINDEX), dm->numPolyData, 0); } - -/* if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT))*/ -/* add_weight_mcol_dm(ob, dm, draw_flag);*/ - } Modified: branches/bmesh/blender/source/blender/blenkernel/intern/dynamicpaint.c =================================================================== --- branches/bmesh/blender/source/blender/blenkernel/intern/dynamicpaint.c 2012-01-23 14:03:09 UTC (rev 43638) +++ branches/bmesh/blender/source/blender/blenkernel/intern/dynamicpaint.c 2012-01-23 16:32:11 UTC (rev 43639) @@ -1604,14 +1604,14 @@ } /* viewport preview */ - if (0 && surface->flags & MOD_DPAINT_PREVIEW) { + if (surface->flags & MOD_DPAINT_PREVIEW) { MPoly *mp = CDDM_get_polys(result); int totpoly = result->numPolyData; /* Save preview results to weight layer to be * able to share same drawing methods */ - col = CustomData_get_layer(&dm->loopData, CD_WEIGHT_MLOOPCOL); - if (!col) col = CustomData_add_layer(&dm->loopData, CD_WEIGHT_MLOOPCOL, CD_CALLOC, NULL, totloop); + col = CustomData_get_layer(&result->loopData, CD_WEIGHT_MLOOPCOL); + if (!col) col = CustomData_add_layer(&result->loopData, CD_WEIGHT_MLOOPCOL, CD_CALLOC, NULL, totloop); if (col) { #pragma omp parallel for schedule(static) @@ -1703,7 +1703,7 @@ float *weight = (float*)sData->type_data; /* viewport preview */ - if (0 && surface->flags & MOD_DPAINT_PREVIEW) { + if (surface->flags & MOD_DPAINT_PREVIEW) { /* Save preview results to weight layer to be * able to share same drawing methods */ DM_update_weight_mcol(ob, result, 0, weight, 0, NULL); Modified: branches/bmesh/blender/source/blender/editors/space_view3d/drawobject.c =================================================================== --- branches/bmesh/blender/source/blender/editors/space_view3d/drawobject.c 2012-01-23 14:03:09 UTC (rev 43638) +++ branches/bmesh/blender/source/blender/editors/space_view3d/drawobject.c 2012-01-23 16:32:11 UTC (rev 43639) @@ -3158,7 +3158,7 @@ /* Check to draw dynamic paint colors (or weights from WeightVG modifiers). * Note: Last "preview-active" modifier in stack will win! */ - if(DM_get_poly_data_layer(dm, CD_WEIGHT_MCOL) && modifiers_isPreview(ob)) + if(DM_get_tessface_data_layer(dm, CD_WEIGHT_MCOL) && modifiers_isPreview(ob)) draw_flags |= DRAW_MODIFIERS_PREVIEW; /* Unwanted combination */ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs