From 1a93d8834319b890ff0cbc70231b14635603ae95 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 22 Jan 2012 17:54:23 +0000 Subject: Add weight preview to WeightVG modifiers, and first, simple/basic refactor of how modifiers can generate preview. User side: * Preview for DynamicPaint should keep the same behavior (for now). Weight preview should be somawhat quicker, though. * Preview for WeightVG modifiers is only active in WeightPaint mode, and if the affected vgroup is the active one. * Last active preview modifier in stack wins! Note: that modifier preview topic is yet to be further refined, quite raw/incomplete for now. Dev side: * In draw code, renamed DRAW_DYNAMIC_PAINT_PREVIEW flag to DRAW_MODIFIERS_PREVIEW * Removed use of MOD_DPAINT_PREVIEW_READY in DynamicPaint code (seems unecessary, and if it was, should be of more general scope). * Added eModifierTypeFlag_UsesPreview to ModifierTypeFlag, for modifiers that can generate some preview data. * Added three new modifier funcs, to handle preview modifiers in draw code / mod stack. * For weights preview: added the generic DM_update_weight_mcol func, which can update WEIGHT_MCOL layer with either a given array of weights (currently used by DynamicPaint only), or from current active vgroup(s). So now, draw code is fully generic (i.e. no more modifier-type checking in it). Mod stack code is generic to some extent, but will need more work. --- source/blender/blenkernel/intern/dynamicpaint.c | 26 +------------------------ 1 file changed, 1 insertion(+), 25 deletions(-) (limited to 'source/blender/blenkernel/intern/dynamicpaint.c') diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 6a2207d455c..18c8d0f0106 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -1574,7 +1574,6 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData DynamicPaintSurface *surface = pmd->canvas->surfaces.first; int update_normals = 0; - pmd->canvas->flags &= ~MOD_DPAINT_PREVIEW_READY; /* loop through surfaces */ for (; surface; surface=surface->next) { @@ -1651,7 +1650,6 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData } } } - pmd->canvas->flags |= MOD_DPAINT_PREVIEW_READY; } } @@ -1711,29 +1709,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData if (surface->flags & MOD_DPAINT_PREVIEW) { /* Save preview results to weight layer, to be * able to share same drawing methods */ - MFace *mface = result->getFaceArray(result); - int numOfFaces = result->getNumFaces(result); - int i; - MCol *col = result->getFaceDataArray(result, CD_WEIGHT_MCOL); - if (!col) col = CustomData_add_layer(&result->faceData, CD_WEIGHT_MCOL, CD_CALLOC, NULL, numOfFaces); - - if (col) { - #pragma omp parallel for schedule(static) - for (i=0; icanvas->flags |= MOD_DPAINT_PREVIEW_READY; - } + DM_update_weight_mcol(ob, result, 0, weight, 0, NULL); } /* apply weights into a vertex group, if doesnt exists add a new layer */ -- cgit v1.2.3