diff options
author | Joshua Leung <aligorith@gmail.com> | 2015-12-13 11:03:13 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2015-12-13 11:03:13 +0300 |
commit | a1f87064c4c0cd9e8eafc19c599c4ad4ccdba49f (patch) | |
tree | d016e95050f10eda7bc44e1bdfa2f7c4fc0fc024 /source/blender/blenkernel | |
parent | d9ee88d126ddb59b68d2561694b522a99e4923b6 (diff) |
Grease Pencil: Merge GPencil_Editing_Stage3 branch into master
This commit merges all the work done in the GPencil_Editing_Stage3 branch
as of ef2aecf2db981b5344e0d14e7f074f1742b0b2f7 into master. For more details
about the changes that this brings, see the WIP release notes:
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.77/GPencil
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_gpencil.h | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 70 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 47 |
3 files changed, 132 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index 084c5527f21..99fc195ed57 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -47,6 +47,7 @@ void BKE_gpencil_free(struct bGPdata *gpd); void gpencil_stroke_sync_selection(struct bGPDstroke *gps); struct bGPDframe *gpencil_frame_addnew(struct bGPDlayer *gpl, int cframe); +struct bGPDframe *gpencil_frame_addcopy(struct bGPDlayer *gpl, int cframe); struct bGPDlayer *gpencil_layer_addnew(struct bGPdata *gpd, const char *name, int setactive); struct bGPdata *gpencil_data_addnew(const char name[]); @@ -56,9 +57,24 @@ struct bGPdata *gpencil_data_duplicate(struct bGPdata *gpd, bool internal_copy); void gpencil_frame_delete_laststroke(struct bGPDlayer *gpl, struct bGPDframe *gpf); + +/* How gpencil_layer_getframe() should behave when there + * is no existing GP-Frame on the frame requested. + */ +typedef enum eGP_GetFrame_Mode { + /* Use the preceeding gp-frame (i.e. don't add anything) */ + GP_GETFRAME_USE_PREV = 0, + + /* Add a new empty/blank frame */ + GP_GETFRAME_ADD_NEW = 1, + /* Make a copy of the active frame */ + GP_GETFRAME_ADD_COPY = 2 +} eGP_GetFrame_Mode; + +struct bGPDframe *gpencil_layer_getframe(struct bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew); struct bGPDframe *BKE_gpencil_layer_find_frame(struct bGPDlayer *gpl, int cframe); -struct bGPDframe *gpencil_layer_getframe(struct bGPDlayer *gpl, int cframe, short addnew); bool gpencil_layer_delframe(struct bGPDlayer *gpl, struct bGPDframe *gpf); + struct bGPDlayer *gpencil_layer_getactive(struct bGPdata *gpd); void gpencil_layer_setactive(struct bGPdata *gpd, struct bGPDlayer *active); void gpencil_layer_delete(struct bGPdata *gpd, struct bGPDlayer *gpl); diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index ee5c9192371..e629a0791c9 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -132,7 +132,7 @@ bGPDframe *gpencil_frame_addnew(bGPDlayer *gpl, int cframe) bGPDframe *gpf = NULL, *gf = NULL; short state = 0; - /* error checking (neg frame only if they are not allowed in Blender!) */ + /* error checking */ if (gpl == NULL) return NULL; @@ -178,6 +178,61 @@ bGPDframe *gpencil_frame_addnew(bGPDlayer *gpl, int cframe) return gpf; } +/* add a copy of the active gp-frame to the given layer */ +bGPDframe *gpencil_frame_addcopy(bGPDlayer *gpl, int cframe) +{ + bGPDframe *new_frame, *gpf; + bool found = false; + + /* Error checking/handling */ + if (gpl == NULL) { + /* no layer */ + return NULL; + } + else if (gpl->actframe == NULL) { + /* no active frame, so just create a new one from scratch */ + return gpencil_frame_addnew(gpl, cframe); + } + + /* Create a copy of the frame */ + new_frame = gpencil_frame_duplicate(gpl->actframe); + + /* Find frame to insert it before */ + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { + if (gpf->framenum > cframe) { + /* Add it here */ + BLI_insertlinkbefore(&gpl->frames, gpf, new_frame); + + found = true; + break; + } + else if (gpf->framenum == cframe) { + /* This only happens when we're editing with framelock on... + * - Delete the new frame and don't do anything else here... + */ + free_gpencil_strokes(new_frame); + MEM_freeN(new_frame); + new_frame = NULL; + + found = true; + break; + } + } + + if (found == false) { + /* Add new frame to the end */ + BLI_addtail(&gpl->frames, new_frame); + } + + /* Ensure that frame is set up correctly, and return it */ + if (new_frame) { + new_frame->framenum = cframe; + gpl->actframe = new_frame; + } + + return new_frame; +} + /* add a new gp-layer and make it the active layer */ bGPDlayer *gpencil_layer_addnew(bGPdata *gpd, const char *name, int setactive) { @@ -197,6 +252,13 @@ bGPDlayer *gpencil_layer_addnew(bGPdata *gpd, const char *name, int setactive) copy_v4_v4(gpl->color, U.gpencil_new_layer_col); gpl->thickness = 3; + /* onion-skinning settings */ + gpl->flag |= (GP_LAYER_GHOST_PREVCOL | GP_LAYER_GHOST_NEXTCOL); + + ARRAY_SET_ITEMS(gpl->gcolor_prev, 0.145098f, 0.419608f, 0.137255f); /* green */ + ARRAY_SET_ITEMS(gpl->gcolor_next, 0.125490f, 0.082353f, 0.529412f); /* blue */ + + /* auto-name */ BLI_strncpy(gpl->info, name, sizeof(gpl->info)); BLI_uniquename(&gpd->layers, gpl, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); @@ -387,7 +449,7 @@ bGPDframe *BKE_gpencil_layer_find_frame(bGPDlayer *gpl, int cframe) * - this sets the layer's actframe var (if allowed to) * - extension beyond range (if first gp-frame is after all frame in interest and cannot add) */ -bGPDframe *gpencil_layer_getframe(bGPDlayer *gpl, int cframe, short addnew) +bGPDframe *gpencil_layer_getframe(bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew) { bGPDframe *gpf = NULL; short found = 0; @@ -425,6 +487,8 @@ bGPDframe *gpencil_layer_getframe(bGPDlayer *gpl, int cframe, short addnew) if (addnew) { if ((found) && (gpf->framenum == cframe)) gpl->actframe = gpf; + else if (addnew == GP_GETFRAME_ADD_COPY) + gpl->actframe = gpencil_frame_addcopy(gpl, cframe); else gpl->actframe = gpencil_frame_addnew(gpl, cframe); } @@ -445,6 +509,8 @@ bGPDframe *gpencil_layer_getframe(bGPDlayer *gpl, int cframe, short addnew) if (addnew) { if ((found) && (gpf->framenum == cframe)) gpl->actframe = gpf; + else if (addnew == GP_GETFRAME_ADD_COPY) + gpl->actframe = gpencil_frame_addcopy(gpl, cframe); else gpl->actframe = gpencil_frame_addnew(gpl, cframe); } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 82a040f4ca0..b2ef693c7eb 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -750,6 +750,53 @@ void BKE_scene_init(Scene *sce) copy_v2_fl2(sce->safe_areas.action_center, 15.0f / 100.0f, 5.0f / 100.0f); sce->preview = NULL; + + /* GP Sculpt brushes */ + { + GP_BrushEdit_Settings *gset = &sce->toolsettings->gp_sculpt; + GP_EditBrush_Data *gp_brush; + + gp_brush = &gset->brush[GP_EDITBRUSH_TYPE_SMOOTH]; + gp_brush->size = 25; + gp_brush->strength = 0.3f; + gp_brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE; + + gp_brush = &gset->brush[GP_EDITBRUSH_TYPE_THICKNESS]; + gp_brush->size = 25; + gp_brush->strength = 0.5f; + gp_brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; + + gp_brush = &gset->brush[GP_EDITBRUSH_TYPE_GRAB]; + gp_brush->size = 50; + gp_brush->strength = 0.3f; + gp_brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; + + gp_brush = &gset->brush[GP_EDITBRUSH_TYPE_PUSH]; + gp_brush->size = 25; + gp_brush->strength = 0.3f; + gp_brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; + + gp_brush = &gset->brush[GP_EDITBRUSH_TYPE_TWIST]; + gp_brush->size = 50; + gp_brush->strength = 0.3f; // XXX? + gp_brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; + + gp_brush = &gset->brush[GP_EDITBRUSH_TYPE_PINCH]; + gp_brush->size = 50; + gp_brush->strength = 0.5f; // XXX? + gp_brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; + + gp_brush = &gset->brush[GP_EDITBRUSH_TYPE_RANDOMISE]; + gp_brush->size = 25; + gp_brush->strength = 0.5f; + gp_brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; + } + + /* GP Stroke Placement */ + sce->toolsettings->gpencil_v3d_align = GP_PROJECT_VIEWSPACE; + sce->toolsettings->gpencil_v2d_align = GP_PROJECT_VIEWSPACE; + sce->toolsettings->gpencil_seq_align = GP_PROJECT_VIEWSPACE; + sce->toolsettings->gpencil_ima_align = GP_PROJECT_VIEWSPACE; } Scene *BKE_scene_add(Main *bmain, const char *name) |