diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2019-08-10 14:24:26 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2019-08-10 14:24:26 +0300 |
commit | b9898ebde44d6584ea37a05aaeca8760d31ccc7b (patch) | |
tree | e6dfc796cc82b4b8b8c248c4ff29d2e2047ff84c /source/blender/editors/gpencil/gpencil_brush.c | |
parent | b17380971a144896b34b7863a82bbda3ff68a39f (diff) | |
parent | 553b581f25c1782c4231816965cd3f6ce58a449a (diff) |
Merge branch 'master' into filebrowser_redesign
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_brush.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_brush.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index 7d866aedd87..8e4d2655ef0 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -87,7 +87,6 @@ typedef struct tGP_BrushEditData { /* Current editor/region/etc. */ /* NOTE: This stuff is mainly needed to handle 3D view projection stuff... */ - Depsgraph *depsgraph; struct Main *bmain; Scene *scene; Object *object; @@ -1051,11 +1050,8 @@ static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso) tGPSB_CloneBrushData *data = gso->customdata; Object *ob = CTX_data_active_object(C); - bGPDlayer *gpl = CTX_data_active_gpencil_layer(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); - int cfra_eval = (int)DEG_get_ctime(depsgraph); - - bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_ADD_NEW); + bGPdata *gpd = (bGPdata *)ob->data; + Scene *scene = CTX_data_scene(C); bGPDstroke *gps; float delta[3]; @@ -1074,6 +1070,18 @@ static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso) bGPDspoint *pt; int i; + bGPDlayer *gpl = NULL; + /* Try to use original layer. */ + if (gps->runtime.tmp_layerinfo != NULL) { + gpl = BLI_findstring(&gpd->layers, gps->runtime.tmp_layerinfo, offsetof(bGPDlayer, info)); + } + + /* if not available, use active layer. */ + if (gpl == NULL) { + gpl = CTX_data_active_gpencil_layer(C); + } + bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_ADD_NEW); + /* Make a new stroke */ new_stroke = MEM_dupallocN(gps); @@ -1088,10 +1096,10 @@ static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso) BLI_addtail(&gpf->strokes, new_stroke); /* Fix color references */ - Material *ma = BLI_ghash_lookup(data->new_colors, &new_stroke->mat_nr); - gps->mat_nr = BKE_gpencil_object_material_get_index(ob, ma); - if (!ma || gps->mat_nr) { - gps->mat_nr = 0; + Material *ma = BLI_ghash_lookup(data->new_colors, POINTER_FROM_INT(new_stroke->mat_nr)); + new_stroke->mat_nr = BKE_gpencil_object_material_get_index(ob, ma); + if (!ma || new_stroke->mat_nr < 0) { + new_stroke->mat_nr = 0; } /* Adjust all the stroke's points, so that the strokes * get pasted relative to where the cursor is now @@ -1224,7 +1232,6 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op) gso = MEM_callocN(sizeof(tGP_BrushEditData), "tGP_BrushEditData"); op->customdata = gso; - gso->depsgraph = CTX_data_depsgraph(C); gso->bmain = CTX_data_main(C); /* store state */ gso->settings = gpsculpt_get_settings(scene); @@ -1276,7 +1283,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op) /* Init multi-edit falloff curve data before doing anything, * so we won't have to do it again later. */ if (gso->is_multiframe) { - curvemapping_initialize(ts->gp_sculpt.cur_falloff); + BKE_curvemapping_initialize(ts->gp_sculpt.cur_falloff); } /* initialise custom data for brushes */ @@ -1400,10 +1407,11 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso) bGPdata *gpd = gso->gpd; bGPDlayer *gpl; - int cfra_eval = (int)DEG_get_ctime(gso->depsgraph); + Scene *scene = gso->scene; + int cfra = CFRA; /* only try to add a new frame if this is the first stroke, or the frame has changed */ - if ((gpd == NULL) || (cfra_eval == gso->cfra)) { + if ((gpd == NULL) || (cfra == gso->cfra)) { return; } @@ -1419,14 +1427,14 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso) * spent too much time editing the wrong frame. */ // XXX: should this be allowed when framelock is enabled? - if (gpf->framenum != cfra_eval) { - BKE_gpencil_frame_addcopy(gpl, cfra_eval); + if (gpf->framenum != cfra) { + BKE_gpencil_frame_addcopy(gpl, cfra); } } } /* save off new current frame, so that next update works fine */ - gso->cfra = cfra_eval; + gso->cfra = cfra; } /* Apply ----------------------------------------------- */ @@ -1478,7 +1486,7 @@ static bool gpsculpt_brush_do_stroke(tGP_BrushEditData *gso, /* Skip if neither one is selected * (and we are only allowed to edit/consider selected points) */ - if (gso->settings->flag & GP_SCULPT_SETT_FLAG_SELECT_MASK) { + if ((gso->settings->flag & GP_SCULPT_SETT_FLAG_SELECT_MASK) && (!gso->is_weight_mode)) { if (!(pt1->flag & GP_SPOINT_SELECT) && !(pt2->flag & GP_SPOINT_SELECT)) { include_last = false; continue; @@ -1642,7 +1650,7 @@ static bool gpsculpt_brush_do_frame( static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso) { ToolSettings *ts = CTX_data_tool_settings(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = gso->object; bGPdata *gpd = gso->gpd; bool changed = false; |