diff options
author | Antonioya <blendergit@gmail.com> | 2018-07-31 11:22:19 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-07-31 11:50:43 +0300 |
commit | 66da2f537ae80ce2b31d1eaf34ad8c03d858938d (patch) | |
tree | 4776b9d2e43e4280d01d6f0b7088e6d4f417db0f /source/blender/editors/space_outliner | |
parent | 27496cc46bbfd76e98ad3b1ccb8fea534763ffb5 (diff) |
New Grease Pencil object for 2D animation
This commit merge the full development done in greasepencil-object branch and include mainly the following features.
- New grease pencil object.
- New drawing engine.
- New grease pencil modes Draw/Sculpt/Edit and Weight Paint.
- New brushes for grease pencil.
- New modifiers for grease pencil.
- New shaders FX.
- New material system (replace old palettes and colors).
- Split of annotations (old grease pencil) and new grease pencil object.
- UI adapted to blender 2.8.
You can get more info here:
https://code.blender.org/2017/12/drawing-2d-animation-in-blender-2-8/
https://code.blender.org/2018/07/grease-pencil-status-update/
This is the result of nearly two years of development and I want thanks firstly the other members of the grease pencil team: Daniel M. Lara, Matias Mendiola and Joshua Leung for their support, ideas and to keep working in the project all the time, without them this project had been impossible.
Also, I want thanks other Blender developers for their help, advices and to be there always to help me, and specially to Clément Foucault, Dalai Felinto, Pablo Vázquez and Campbell Barton.
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_draw.c | 415 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_select.c | 30 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_tree.c | 2 |
3 files changed, 257 insertions, 190 deletions
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 435e0018ac0..feab82a59c8 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -32,6 +32,7 @@ #include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_gpencil_types.h" +#include "DNA_gpencil_modifier_types.h" #include "DNA_group_types.h" #include "DNA_lamp_types.h" #include "DNA_lightprobe_types.h" @@ -50,6 +51,7 @@ #include "BKE_context.h" #include "BKE_deform.h" #include "BKE_fcurve.h" +#include "BKE_gpencil.h" #include "BKE_global.h" #include "BKE_idcode.h" #include "BKE_layer.h" @@ -438,12 +440,16 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) } case TSE_GP_LAYER: { - bGPdata *gpd = (bGPdata *)tselem->id; // id = GP Datablock + bGPdata *gpd = (bGPdata *)tselem->id; /* id = GP Datablock */ bGPDlayer *gpl = te->directdata; + /* always make layer active */ + BKE_gpencil_layer_setactive(gpd, gpl); + // XXX: name needs translation stuff BLI_uniquename(&gpd->layers, gpl, "GP Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, gpd); break; } @@ -872,39 +878,6 @@ static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon) } -static void UNUSED_FUNCTION(tselem_draw_gp_icon_uibut)(struct DrawIconArg *arg, ID *id, bGPDlayer *gpl) -{ - /* restrict column clip - skip it for now... */ - if (arg->x >= arg->xmax) { - /* pass */ - } - else { - PointerRNA ptr; - const float eps = 0.001f; - const bool is_stroke_visible = (gpl->color[3] > eps); - const bool is_fill_visible = (gpl->fill[3] > eps); - float w = 0.5f * UI_UNIT_X; - float h = 0.85f * UI_UNIT_Y; - - RNA_pointer_create(id, &RNA_GPencilLayer, gpl, &ptr); - - UI_block_align_begin(arg->block); - - UI_block_emboss_set(arg->block, is_stroke_visible ? UI_EMBOSS : UI_EMBOSS_NONE); - uiDefButR(arg->block, UI_BTYPE_COLOR, 1, "", arg->xb, arg->yb, w, h, - &ptr, "color", -1, - 0, 0, 0, 0, NULL); - - UI_block_emboss_set(arg->block, is_fill_visible ? UI_EMBOSS : UI_EMBOSS_NONE); - uiDefButR(arg->block, UI_BTYPE_COLOR, 1, "", arg->xb + w, arg->yb, w, h, - &ptr, "fill_color", -1, - 0, 0, 0, 0, NULL); - - UI_block_emboss_set(arg->block, UI_EMBOSS_NONE); - UI_block_align_end(arg->block); - } -} - static void tselem_draw_icon( uiBlock *block, int xmax, float x, float y, TreeStoreElem *tselem, TreeElement *te, float alpha, const bool is_clickable) @@ -969,156 +942,212 @@ static void tselem_draw_icon( case TSE_MODIFIER: { Object *ob = (Object *)tselem->id; - ModifierData *md = BLI_findlink(&ob->modifiers, tselem->nr); - switch ((ModifierType)md->type) { - case eModifierType_Subsurf: - ICON_DRAW(ICON_MOD_SUBSURF); - break; - case eModifierType_Armature: - ICON_DRAW(ICON_MOD_ARMATURE); - break; - case eModifierType_Lattice: - ICON_DRAW(ICON_MOD_LATTICE); - break; - case eModifierType_Curve: - ICON_DRAW(ICON_MOD_CURVE); - break; - case eModifierType_Build: - ICON_DRAW(ICON_MOD_BUILD); - break; - case eModifierType_Mirror: - ICON_DRAW(ICON_MOD_MIRROR); - break; - case eModifierType_Decimate: - ICON_DRAW(ICON_MOD_DECIM); - break; - case eModifierType_Wave: - ICON_DRAW(ICON_MOD_WAVE); - break; - case eModifierType_Hook: - ICON_DRAW(ICON_HOOK); - break; - case eModifierType_Softbody: - ICON_DRAW(ICON_MOD_SOFT); - break; - case eModifierType_Boolean: - ICON_DRAW(ICON_MOD_BOOLEAN); - break; - case eModifierType_ParticleSystem: - ICON_DRAW(ICON_MOD_PARTICLES); - break; - case eModifierType_ParticleInstance: - ICON_DRAW(ICON_MOD_PARTICLES); - break; - case eModifierType_EdgeSplit: - ICON_DRAW(ICON_MOD_EDGESPLIT); - break; - case eModifierType_Array: - ICON_DRAW(ICON_MOD_ARRAY); - break; - case eModifierType_UVProject: - case eModifierType_UVWarp: /* TODO, get own icon */ - ICON_DRAW(ICON_MOD_UVPROJECT); - break; - case eModifierType_Displace: - ICON_DRAW(ICON_MOD_DISPLACE); - break; - case eModifierType_Shrinkwrap: - ICON_DRAW(ICON_MOD_SHRINKWRAP); - break; - case eModifierType_Cast: - ICON_DRAW(ICON_MOD_CAST); - break; - case eModifierType_MeshDeform: - case eModifierType_SurfaceDeform: - ICON_DRAW(ICON_MOD_MESHDEFORM); - break; - case eModifierType_Bevel: - ICON_DRAW(ICON_MOD_BEVEL); - break; - case eModifierType_Smooth: - case eModifierType_LaplacianSmooth: - case eModifierType_CorrectiveSmooth: - ICON_DRAW(ICON_MOD_SMOOTH); - break; - case eModifierType_SimpleDeform: - ICON_DRAW(ICON_MOD_SIMPLEDEFORM); - break; - case eModifierType_Mask: - ICON_DRAW(ICON_MOD_MASK); - break; - case eModifierType_Cloth: - ICON_DRAW(ICON_MOD_CLOTH); - break; - case eModifierType_Explode: - ICON_DRAW(ICON_MOD_EXPLODE); - break; - case eModifierType_Collision: - case eModifierType_Surface: - ICON_DRAW(ICON_MOD_PHYSICS); - break; - case eModifierType_Fluidsim: - ICON_DRAW(ICON_MOD_FLUIDSIM); - break; - case eModifierType_Multires: - ICON_DRAW(ICON_MOD_MULTIRES); - break; - case eModifierType_Smoke: - ICON_DRAW(ICON_MOD_SMOKE); - break; - case eModifierType_Solidify: - ICON_DRAW(ICON_MOD_SOLIDIFY); - break; - case eModifierType_Screw: - ICON_DRAW(ICON_MOD_SCREW); - break; - case eModifierType_Remesh: - ICON_DRAW(ICON_MOD_REMESH); - break; - case eModifierType_WeightVGEdit: - case eModifierType_WeightVGMix: - case eModifierType_WeightVGProximity: - ICON_DRAW(ICON_MOD_VERTEX_WEIGHT); - break; - case eModifierType_DynamicPaint: - ICON_DRAW(ICON_MOD_DYNAMICPAINT); - break; - case eModifierType_Ocean: - ICON_DRAW(ICON_MOD_OCEAN); - break; - case eModifierType_Warp: - ICON_DRAW(ICON_MOD_WARP); - break; - case eModifierType_Skin: - ICON_DRAW(ICON_MOD_SKIN); - break; - case eModifierType_Triangulate: - ICON_DRAW(ICON_MOD_TRIANGULATE); - break; - case eModifierType_MeshCache: - ICON_DRAW(ICON_MOD_MESHDEFORM); /* XXX, needs own icon */ - break; - case eModifierType_MeshSequenceCache: - ICON_DRAW(ICON_MOD_MESHDEFORM); /* XXX, needs own icon */ - break; - case eModifierType_Wireframe: - ICON_DRAW(ICON_MOD_WIREFRAME); - break; - case eModifierType_LaplacianDeform: - ICON_DRAW(ICON_MOD_MESHDEFORM); /* XXX, needs own icon */ - break; - case eModifierType_DataTransfer: - ICON_DRAW(ICON_MOD_DATA_TRANSFER); - break; - case eModifierType_NormalEdit: - ICON_DRAW(ICON_MOD_NORMALEDIT); - break; - /* Default */ - case eModifierType_None: - case eModifierType_ShapeKey: - case NUM_MODIFIER_TYPES: - ICON_DRAW(ICON_DOT); - break; + if (ob->type != OB_GPENCIL) { + ModifierData *md = BLI_findlink(&ob->modifiers, tselem->nr); + switch ((ModifierType)md->type) { + case eModifierType_Subsurf: + ICON_DRAW(ICON_MOD_SUBSURF); + break; + case eModifierType_Armature: + ICON_DRAW(ICON_MOD_ARMATURE); + break; + case eModifierType_Lattice: + ICON_DRAW(ICON_MOD_LATTICE); + break; + case eModifierType_Curve: + ICON_DRAW(ICON_MOD_CURVE); + break; + case eModifierType_Build: + ICON_DRAW(ICON_MOD_BUILD); + break; + case eModifierType_Mirror: + ICON_DRAW(ICON_MOD_MIRROR); + break; + case eModifierType_Decimate: + ICON_DRAW(ICON_MOD_DECIM); + break; + case eModifierType_Wave: + ICON_DRAW(ICON_MOD_WAVE); + break; + case eModifierType_Hook: + ICON_DRAW(ICON_HOOK); + break; + case eModifierType_Softbody: + ICON_DRAW(ICON_MOD_SOFT); + break; + case eModifierType_Boolean: + ICON_DRAW(ICON_MOD_BOOLEAN); + break; + case eModifierType_ParticleSystem: + ICON_DRAW(ICON_MOD_PARTICLES); + break; + case eModifierType_ParticleInstance: + ICON_DRAW(ICON_MOD_PARTICLES); + break; + case eModifierType_EdgeSplit: + ICON_DRAW(ICON_MOD_EDGESPLIT); + break; + case eModifierType_Array: + ICON_DRAW(ICON_MOD_ARRAY); + break; + case eModifierType_UVProject: + case eModifierType_UVWarp: /* TODO, get own icon */ + ICON_DRAW(ICON_MOD_UVPROJECT); + break; + case eModifierType_Displace: + ICON_DRAW(ICON_MOD_DISPLACE); + break; + case eModifierType_Shrinkwrap: + ICON_DRAW(ICON_MOD_SHRINKWRAP); + break; + case eModifierType_Cast: + ICON_DRAW(ICON_MOD_CAST); + break; + case eModifierType_MeshDeform: + case eModifierType_SurfaceDeform: + ICON_DRAW(ICON_MOD_MESHDEFORM); + break; + case eModifierType_Bevel: + ICON_DRAW(ICON_MOD_BEVEL); + break; + case eModifierType_Smooth: + case eModifierType_LaplacianSmooth: + case eModifierType_CorrectiveSmooth: + ICON_DRAW(ICON_MOD_SMOOTH); + break; + case eModifierType_SimpleDeform: + ICON_DRAW(ICON_MOD_SIMPLEDEFORM); + break; + case eModifierType_Mask: + ICON_DRAW(ICON_MOD_MASK); + break; + case eModifierType_Cloth: + ICON_DRAW(ICON_MOD_CLOTH); + break; + case eModifierType_Explode: + ICON_DRAW(ICON_MOD_EXPLODE); + break; + case eModifierType_Collision: + case eModifierType_Surface: + ICON_DRAW(ICON_MOD_PHYSICS); + break; + case eModifierType_Fluidsim: + ICON_DRAW(ICON_MOD_FLUIDSIM); + break; + case eModifierType_Multires: + ICON_DRAW(ICON_MOD_MULTIRES); + break; + case eModifierType_Smoke: + ICON_DRAW(ICON_MOD_SMOKE); + break; + case eModifierType_Solidify: + ICON_DRAW(ICON_MOD_SOLIDIFY); + break; + case eModifierType_Screw: + ICON_DRAW(ICON_MOD_SCREW); + break; + case eModifierType_Remesh: + ICON_DRAW(ICON_MOD_REMESH); + break; + case eModifierType_WeightVGEdit: + case eModifierType_WeightVGMix: + case eModifierType_WeightVGProximity: + ICON_DRAW(ICON_MOD_VERTEX_WEIGHT); + break; + case eModifierType_DynamicPaint: + ICON_DRAW(ICON_MOD_DYNAMICPAINT); + break; + case eModifierType_Ocean: + ICON_DRAW(ICON_MOD_OCEAN); + break; + case eModifierType_Warp: + ICON_DRAW(ICON_MOD_WARP); + break; + case eModifierType_Skin: + ICON_DRAW(ICON_MOD_SKIN); + break; + case eModifierType_Triangulate: + ICON_DRAW(ICON_MOD_TRIANGULATE); + break; + case eModifierType_MeshCache: + ICON_DRAW(ICON_MOD_MESHDEFORM); /* XXX, needs own icon */ + break; + case eModifierType_MeshSequenceCache: + ICON_DRAW(ICON_MOD_MESHDEFORM); /* XXX, needs own icon */ + break; + case eModifierType_Wireframe: + ICON_DRAW(ICON_MOD_WIREFRAME); + break; + case eModifierType_LaplacianDeform: + ICON_DRAW(ICON_MOD_MESHDEFORM); /* XXX, needs own icon */ + break; + case eModifierType_DataTransfer: + ICON_DRAW(ICON_MOD_DATA_TRANSFER); + break; + case eModifierType_NormalEdit: + ICON_DRAW(ICON_MOD_NORMALEDIT); + break; + /* Default */ + case eModifierType_None: + case eModifierType_ShapeKey: + + case NUM_MODIFIER_TYPES: + ICON_DRAW(ICON_DOT); + break; + } + } + else { + /* grease pencil modifiers */ + GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, tselem->nr); + switch ((GpencilModifierType)md->type) { + case eGpencilModifierType_Noise: + ICON_DRAW(ICON_RNDCURVE); + break; + case eGpencilModifierType_Subdiv: + ICON_DRAW(ICON_MOD_SUBSURF); + break; + case eGpencilModifierType_Thick: + ICON_DRAW(ICON_MAN_ROT); + break; + case eGpencilModifierType_Tint: + ICON_DRAW(ICON_COLOR); + break; + case eGpencilModifierType_Instance: + ICON_DRAW(ICON_MOD_ARRAY); + break; + case eGpencilModifierType_Build: + ICON_DRAW(ICON_MOD_BUILD); + break; + case eGpencilModifierType_Opacity: + ICON_DRAW(ICON_MOD_MASK); + break; + case eGpencilModifierType_Color: + ICON_DRAW(ICON_GROUP_VCOL); + break; + case eGpencilModifierType_Lattice: + ICON_DRAW(ICON_MOD_LATTICE); + break; + case eGpencilModifierType_Mirror: + ICON_DRAW(ICON_MOD_MIRROR); + break; + case eGpencilModifierType_Simplify: + ICON_DRAW(ICON_MOD_DECIM); + break; + case eGpencilModifierType_Smooth: + ICON_DRAW(ICON_MOD_SMOOTH); + break; + case eGpencilModifierType_Hook: + ICON_DRAW(ICON_HOOK); + break; + case eGpencilModifierType_Offset: + ICON_DRAW(ICON_MOD_DISPLACE); + break; + + /* Default */ + default: + ICON_DRAW(ICON_DOT); + break; + } } break; } @@ -1185,11 +1214,18 @@ static void tselem_draw_icon( ICON_DRAW(ICON_GROUP); break; /* Removed the icons from outliner. Need a better structure with Layers, Palettes and Colors */ -#if 0 case TSE_GP_LAYER: - tselem_draw_gp_icon_uibut(&arg, tselem->id, te->directdata); + { + /* indicate whether layer is active */ + bGPDlayer *gpl = te->directdata; + if (gpl->flag & GP_LAYER_ACTIVE) { + ICON_DRAW(ICON_GREASEPENCIL); + } + else { + ICON_DRAW(ICON_DOT); + } break; -#endif + } default: ICON_DRAW(ICON_DOT); break; @@ -1229,6 +1265,9 @@ static void tselem_draw_icon( ICON_CLICK_DRAW(ICON_OUTLINER_OB_EMPTY); } break; + case OB_GPENCIL: + ICON_CLICK_DRAW(ICON_OUTLINER_OB_GREASEPENCIL); break; + break; } } else { @@ -1304,7 +1343,7 @@ static void tselem_draw_icon( case ID_LS: tselem_draw_icon_uibut(&arg, ICON_LINE_DATA); break; case ID_GD: - tselem_draw_icon_uibut(&arg, ICON_GREASEPENCIL); break; + tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_GREASEPENCIL); break; case ID_LP: { LightProbe * lp = (LightProbe *)tselem->id; diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 7ab13f36953..ec5e11520a6 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -39,6 +39,7 @@ #include "DNA_scene_types.h" #include "DNA_sequence_types.h" #include "DNA_world_types.h" +#include "DNA_gpencil_types.h" #include "BLI_utildefines.h" #include "BLI_listbase.h" @@ -46,9 +47,11 @@ #include "BKE_armature.h" #include "BKE_collection.h" #include "BKE_context.h" +#include "BKE_gpencil.h" #include "BKE_layer.h" #include "BKE_main.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_sequencer.h" #include "BKE_workspace.h" @@ -60,6 +63,7 @@ #include "ED_screen.h" #include "ED_sequencer.h" #include "ED_undo.h" +#include "ED_gpencil.h" #include "WM_api.h" #include "WM_types.h" @@ -470,6 +474,28 @@ static eOLDrawState tree_element_active_defgroup( return OL_DRAWSEL_NONE; } +static eOLDrawState UNUSED_FUNCTION(tree_element_active_gplayer)( + bContext *C, Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) +{ + bGPdata *gpd = (bGPdata *)tselem->id; + bGPDlayer *gpl = te->directdata; + + /* We can only have a single "active" layer at a time + * and there must always be an active layer... + */ + if (set != OL_SETSEL_NONE) { + if (gpl) { + BKE_gpencil_layer_setactive(gpd, gpl); + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, gpd); + } + } + else { + return OL_DRAWSEL_NORMAL; + } + + return OL_DRAWSEL_NONE; +} + static eOLDrawState tree_element_active_posegroup( bContext *C, Scene *UNUSED(scene), ViewLayer *view_layer, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) { @@ -1006,6 +1032,10 @@ static void do_outliner_item_activate_tree_element( } } } + else if (ELEM(te->idcode, ID_GD)) { + /* set grease pencil to object mode */ + WM_operator_name_call(C, "GPENCIL_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL); + } else { // rest of types tree_element_active(C, scene, view_layer, soops, te, OL_SETSEL_NORMAL, false); } diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 28890e42139..539df3aa085 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -319,8 +319,6 @@ static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *s if (outliner_animdata_test(sce->adt)) outliner_add_element(soops, lb, sce, te, TSE_ANIM_DATA, 0); - /* Grease Pencil */ - outliner_add_element(soops, lb, sce->gpd, te, 0, 0); } TreeTraversalAction outliner_find_selected_objects(TreeElement *te, void *customdata) |