diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2012-01-22 21:54:23 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2012-01-22 21:54:23 +0400 |
commit | 1a93d8834319b890ff0cbc70231b14635603ae95 (patch) | |
tree | 87ee1ecd503872e91116566db9df4730b3ebccbe /source/blender/editors | |
parent | df51fd74cf826c42a90212082abb27e99484257a (diff) |
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.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_view3d/drawmesh.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 24 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 2 |
3 files changed, 9 insertions, 21 deletions
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 5f521cc3dd1..62c12500aa8 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -713,7 +713,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec } else { if(GPU_buffer_legacy(dm)) { - if (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW) + if (draw_flags & DRAW_MODIFIERS_PREVIEW) dm->drawFacesTex(dm, draw_mcol__set_draw_legacy, NULL, NULL); else dm->drawFacesTex(dm, draw_tface__set_draw_legacy, NULL, NULL); @@ -849,7 +849,7 @@ static int tex_mat_set_face_editmesh_cb(void *UNUSED(userData), int index) void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) { - if((!scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW)) { + if((!scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_MODIFIERS_PREVIEW)) { draw_mesh_textured_old(scene, v3d, rv3d, ob, dm, draw_flags); return; } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index f7f67bd4e73..1482340632e 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -36,7 +36,6 @@ #include "DNA_camera_types.h" #include "DNA_curve_types.h" #include "DNA_constraint_types.h" // for drawing constraint -#include "DNA_dynamicpaint_types.h" #include "DNA_lamp_types.h" #include "DNA_lattice_types.h" #include "DNA_material_types.h" @@ -3081,27 +3080,16 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D eWireDrawMode draw_wire= OBDRAW_WIRE_OFF; int /* totvert,*/ totedge, totface; DerivedMesh *dm= mesh_get_derived_final(scene, ob, scene->customdata_mask); - ModifierData *md = NULL; const short is_obact= (ob == OBACT); int draw_flags = (is_obact && paint_facesel_test(ob)) ? DRAW_FACE_SELECT : 0; if(!dm) return; - /* check to draw dynamic paint colors */ - if ((md = modifiers_findByType(ob, eModifierType_DynamicPaint))) - { - /* check if target has an active dpaint modifier */ - if(md && (md->mode & eModifierMode_Realtime)) - { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; - /* if canvas is ready to preview vertex colors */ - if (pmd->canvas && pmd->canvas->flags & MOD_DPAINT_PREVIEW_READY && - DM_get_face_data_layer(dm, CD_WEIGHT_MCOL)) { - draw_flags |= DRAW_DYNAMIC_PAINT_PREVIEW; - } - } - } + /* Check to draw dynamic paint colors (or weights from WeightVG modifiers). + * Note: Last "preview-active" modifier in stack will win! */ + if(DM_get_face_data_layer(dm, CD_WEIGHT_MCOL) && modifiers_isPreview(ob)) + draw_flags |= DRAW_MODIFIERS_PREVIEW; /* Unwanted combination */ if (draw_flags & DRAW_FACE_SELECT) { @@ -3142,7 +3130,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D draw_mesh_object_outline(v3d, ob, dm); } - if(draw_glsl_material(scene, ob, v3d, dt) && !(draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW)) { + if(draw_glsl_material(scene, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) { glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); dm->drawFacesGLSL(dm, GPU_enable_material); @@ -3193,7 +3181,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* since we already draw wire as wp guide, dont draw over the top */ draw_wire= OBDRAW_WIRE_OFF; } - else if (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW) { + else if (draw_flags & DRAW_MODIFIERS_PREVIEW) { /* for object selection draws no shade */ if (flag & (DRAW_PICKING|DRAW_CONSTCOLOR)) { dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index f6c82b0ba9d..07754c0883c 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -59,7 +59,7 @@ struct wmNDOFMotionData; #define DRAW_SCENESET 4 /* draw_mesh_fancy/draw_mesh_textured draw_flags */ -#define DRAW_DYNAMIC_PAINT_PREVIEW 1 +#define DRAW_MODIFIERS_PREVIEW 1 #define DRAW_FACE_SELECT 2 /* view3d_header.c */ |