diff options
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r-- | source/blender/editors/gpencil/drawgpencil.c | 8 | ||||
-rw-r--r-- | source/blender/editors/gpencil/editaction_gpencil.c | 8 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_brush.c | 6 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_edit.c | 9 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_interpolate.c | 13 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_ops.c | 6 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 37 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 7 |
8 files changed, 58 insertions, 36 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 96f9959af02..63c15744388 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -1702,10 +1702,10 @@ void ED_gpencil_draw_view3d(wmWindowManager *wm, Scene *scene, View3D *v3d, AReg rctf rectf; ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &rectf, true); /* no shift */ - offsx = iroundf(rectf.xmin); - offsy = iroundf(rectf.ymin); - winx = iroundf(rectf.xmax - rectf.xmin); - winy = iroundf(rectf.ymax - rectf.ymin); + offsx = round_fl_to_int(rectf.xmin); + offsy = round_fl_to_int(rectf.ymin); + winx = round_fl_to_int(rectf.xmax - rectf.xmin); + winy = round_fl_to_int(rectf.ymax - rectf.ymin); } else { offsx = 0; diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index bd4856f1b93..90d44503013 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -252,8 +252,10 @@ bool ED_gplayer_frames_delete(bGPDlayer *gpl) for (gpf = gpl->frames.first; gpf; gpf = gpfn) { gpfn = gpf->next; - if (gpf->flag & GP_FRAME_SELECT) - changed |= BKE_gpencil_layer_delframe(gpl, gpf); + if (gpf->flag & GP_FRAME_SELECT) { + BKE_gpencil_layer_delframe(gpl, gpf); + changed = true; + } } return changed; @@ -314,7 +316,7 @@ void ED_gplayer_frames_keytype_set(bGPDlayer *gpl, short type) */ /* globals for copy/paste data (like for other copy/paste buffers) */ -ListBase gp_anim_copybuf = {NULL, NULL}; +static ListBase gp_anim_copybuf = {NULL, NULL}; static int gp_anim_copy_firstframe = 999999999; static int gp_anim_copy_lastframe = -999999999; static int gp_anim_copy_cfra = 0; diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index f478596deec..1cee8db792a 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -710,7 +710,7 @@ static bool gp_brush_randomize_apply(tGP_BrushEditData *gso, bGPDstroke *gps, in } else { /* ERROR */ - BLI_assert("3D stroke being sculpted in non-3D view"); + BLI_assert(!"3D stroke being sculpted in non-3D view"); } } else { @@ -991,11 +991,11 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customda /* Inner Ring: Light color for action of the brush */ /* TODO: toggle between add and remove? */ immUniformColor4ub(255, 255, 255, 200); - imm_draw_circle_wire(pos, x, y, brush->size, 40); + imm_draw_circle_wire_2d(pos, x, y, brush->size, 40); /* Outer Ring: Dark color for contrast on light backgrounds (e.g. gray on white) */ immUniformColor3ub(30, 30, 30); - imm_draw_circle_wire(pos, x, y, brush->size + 1, 40); + imm_draw_circle_wire_2d(pos, x, y, brush->size + 1, 40); immUnbindProgram(); diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 6310cab9e4e..4cd628b7fd3 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -79,6 +79,8 @@ #include "ED_view3d.h" #include "ED_space_api.h" +#include "DEG_depsgraph.h" + #include "gpencil_intern.h" /* ************************************************ */ @@ -343,7 +345,7 @@ ListBase gp_strokes_copypastebuf = {NULL, NULL}; * This is needed to prevent dangling and unsafe pointers when pasting across datablocks, * or after a color used by a stroke in the buffer gets deleted (via user action or undo). */ -GHash *gp_strokes_copypastebuf_colors = NULL; +static GHash *gp_strokes_copypastebuf_colors = NULL; /* Free copy/paste buffer data */ void ED_gpencil_strokes_copybuf_free(void) @@ -2106,9 +2108,12 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) /* init autodist for geometry projection */ if (mode == GP_REPROJECT_SURFACE) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + struct Depsgraph *graph = CTX_data_depsgraph(C); view3d_region_operator_needs_opengl(CTX_wm_window(C), gsc.ar); - ED_view3d_autodist_init(graph, gsc.ar, CTX_wm_view3d(C), 0); + ED_view3d_autodist_init(&eval_ctx, graph, gsc.ar, CTX_wm_view3d(C), 0); } // TODO: For deforming geometry workflow, create new frames? diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c index 59b5b41f114..83e2a85db49 100644 --- a/source/blender/editors/gpencil/gpencil_interpolate.c +++ b/source/blender/editors/gpencil/gpencil_interpolate.c @@ -117,8 +117,8 @@ static void gp_interpolate_update_points(bGPDstroke *gps_from, bGPDstroke *gps_t /* Interpolate all values */ interp_v3_v3v3(&pt->x, &prev->x, &next->x, factor); - pt->pressure = interpf(prev->pressure, next->pressure, factor); - pt->strength = interpf(prev->strength, next->strength, factor); + pt->pressure = interpf(prev->pressure, next->pressure, 1.0f - factor); + pt->strength = interpf(prev->strength, next->strength, 1.0f - factor); CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); } } @@ -284,7 +284,9 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi) new_stroke = MEM_dupallocN(gps_from); new_stroke->points = MEM_dupallocN(gps_from->points); new_stroke->triangles = MEM_dupallocN(gps_from->triangles); - + new_stroke->tot_triangles = 0; + new_stroke->flag |= GP_STROKE_RECALC_CACHES; + if (valid) { /* if destination stroke is smaller, resize new_stroke to size of gps_to stroke */ if (gps_from->totpoints > gps_to->totpoints) { @@ -302,6 +304,7 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi) new_stroke->points = MEM_recallocN(new_stroke->points, sizeof(*new_stroke->points)); new_stroke->tot_triangles = 0; new_stroke->triangles = MEM_recallocN(new_stroke->triangles, sizeof(*new_stroke->triangles)); + new_stroke->flag |= GP_STROKE_RECALC_CACHES; } /* add to strokes */ @@ -986,7 +989,9 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op) new_stroke = MEM_dupallocN(gps_from); new_stroke->points = MEM_dupallocN(gps_from->points); new_stroke->triangles = MEM_dupallocN(gps_from->triangles); - + new_stroke->tot_triangles = 0; + new_stroke->flag |= GP_STROKE_RECALC_CACHES; + /* if destination stroke is smaller, resize new_stroke to size of gps_to stroke */ if (gps_from->totpoints > gps_to->totpoints) { new_stroke->points = MEM_recallocN(new_stroke->points, sizeof(*new_stroke->points) * gps_to->totpoints); diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index 78e1a0dda36..3a2169798e5 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -99,8 +99,8 @@ static void ed_keymap_gpencil_general(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "GPENCIL_OT_editmode_toggle", TABKEY, KM_PRESS, 0, DKEY); /* Pie Menu - For standard tools */ - WM_keymap_add_menu_pie(keymap, "GPENCIL_PIE_tool_palette", QKEY, KM_PRESS, 0, DKEY); - WM_keymap_add_menu_pie(keymap, "GPENCIL_PIE_settings_palette", WKEY, KM_PRESS, 0, DKEY); + WM_keymap_add_menu_pie(keymap, "GPENCIL_MT_pie_tool_palette", QKEY, KM_PRESS, 0, DKEY); + WM_keymap_add_menu_pie(keymap, "GPENCIL_MT_pie_settings_palette", WKEY, KM_PRESS, 0, DKEY); /* Add Blank Frame */ /* XXX: BKEY or NKEY? BKEY is easier to reach from DKEY, so we'll use that for now */ @@ -135,7 +135,7 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "GPENCIL_OT_editmode_toggle", TABKEY, KM_PRESS, 0, 0); /* Pie Menu - For settings/tools easy access */ - WM_keymap_add_menu_pie(keymap, "GPENCIL_PIE_sculpt", EKEY, KM_PRESS, 0, DKEY); + WM_keymap_add_menu_pie(keymap, "GPENCIL_MT_pie_sculpt", EKEY, KM_PRESS, 0, DKEY); /* Brush Settings */ /* NOTE: We cannot expose these in the standard keymap, as they will interfere with regular hotkeys diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index b46095d3abb..e0751985bcd 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -80,6 +80,8 @@ #include "WM_api.h" #include "WM_types.h" +#include "DEG_depsgraph.h" + #include "gpencil_intern.h" /* ******************************************* */ @@ -114,6 +116,7 @@ typedef enum eGPencil_PaintFlags { * "p" = op->customdata */ typedef struct tGPsdata { + EvaluationContext eval_ctx; Scene *scene; /* current scene from context */ struct Depsgraph *graph; @@ -484,7 +487,8 @@ static void gp_brush_angle(bGPdata *gpd, bGPDbrush *brush, tGPspoint *pt, const } /* add current stroke-point to buffer (returns whether point was successfully added) */ -static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure, double curtime) +static short gp_stroke_addpoint( + tGPsdata *p, const int mval[2], float pressure, double curtime) { bGPdata *gpd = p->gpd; bGPDbrush *brush = p->brush; @@ -643,7 +647,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure, view3d_region_operator_needs_opengl(p->win, p->ar); ED_view3d_autodist_init( - p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); + &p->eval_ctx, p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); } /* convert screen-coordinates to appropriate coordinates (and store them) */ @@ -739,7 +743,7 @@ static void gp_stroke_simplify(tGPsdata *p) /* ignore return values on this... assume to be ok for now */ gp_stroke_addpoint(p, mco, pressure, p->inittime + (double)time); - + j += 2; } } @@ -1244,7 +1248,7 @@ static void gp_stroke_doeraser(tGPsdata *p) if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) { View3D *v3d = p->sa->spacedata.first; view3d_region_operator_needs_opengl(p->win, p->ar); - ED_view3d_autodist_init(p->graph, p->ar, v3d, 0); + ED_view3d_autodist_init(&p->eval_ctx, p->graph, p->ar, v3d, 0); } } @@ -1397,6 +1401,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) } /* pass on current scene and window */ + CTX_data_eval_ctx(C, &p->eval_ctx); p->scene = CTX_data_scene(C); p->graph = CTX_data_depsgraph(C); p->win = CTX_wm_window(C); @@ -1811,14 +1816,14 @@ static void gp_paint_strokeend(tGPsdata *p) /* need to restore the original projection settings before packing up */ view3d_region_operator_needs_opengl(p->win, p->ar); - ED_view3d_autodist_init(p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); + ED_view3d_autodist_init(&p->eval_ctx, p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); } /* check if doing eraser or not */ if ((p->gpd->sbuffer_sflag & GP_STROKE_ERASER) == 0) { /* simplify stroke before transferring? */ gp_stroke_simplify(p); - + /* transfer stroke to frame */ gp_stroke_newfrombuffer(p); } @@ -1860,11 +1865,11 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); immUniformColor4ub(255, 100, 100, 20); - imm_draw_circle_fill(shdr_pos, x, y, p->radius, 40); + imm_draw_circle_fill_2d(shdr_pos, x, y, p->radius, 40); immUnbindProgram(); - immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR); + immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; glGetFloatv(GL_VIEWPORT, viewport_size); @@ -1875,7 +1880,7 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr) immUniform1f("dash_width", 12.0f); immUniform1f("dash_factor", 0.5f); - imm_draw_circle_wire(shdr_pos, x, y, p->radius, + imm_draw_circle_wire_2d(shdr_pos, x, y, p->radius, /* XXX Dashed shader gives bad results with sets of small segments currently, * temp hack around the issue. :( */ max_ii(8, p->radius / 2)); /* was fixed 40 */ @@ -2057,7 +2062,7 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata *p) if (p->paintmode == GP_PAINTMODE_ERASER) { /* do 'live' erasing now */ gp_stroke_doeraser(p); - + /* store used values */ p->mvalo[0] = p->mval[0]; p->mvalo[1] = p->mval[1]; @@ -2067,7 +2072,7 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata *p) else if (gp_stroke_filtermval(p, p->mval, p->mvalo)) { /* try to add point */ short ok = gp_stroke_addpoint(p, p->mval, p->pressure, p->curtime); - + /* handle errors while adding point */ if ((ok == GP_STROKEADD_FULL) || (ok == GP_STROKEADD_OVERFLOW)) { /* finish off old stroke */ @@ -2212,7 +2217,7 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event) /* apply the current latest drawing point */ gpencil_draw_apply(op, p); - + /* force refresh */ ED_region_tag_redraw(p->ar); /* just active area for now, since doing whole screen is too slow */ } @@ -2388,9 +2393,9 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) static void gpencil_stroke_end(wmOperator *op) { tGPsdata *p = op->customdata; - + gp_paint_cleanup(p); - + gpencil_undo_push(p->gpd); gp_session_cleanup(p); @@ -2524,7 +2529,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* end stroke only, and then wait to resume painting soon */ /* printf("\t\tGP - end stroke only\n"); */ gpencil_stroke_end(op); - + /* If eraser mode is on, turn it off after the stroke finishes * NOTE: This just makes it nicer to work with drawing sessions */ @@ -2667,7 +2672,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* handle drawing event */ /* printf("\t\tGP - add point\n"); */ gpencil_draw_apply_event(op, event); - + /* finish painting operation if anything went wrong just now */ if (p->status == GP_STATUS_ERROR) { printf("\t\t\t\tGP - add error done!\n"); diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 82892561daa..fae08bd771e 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -65,6 +65,8 @@ #include "ED_clip.h" #include "ED_view3d.h" +#include "DEG_depsgraph.h" + #include "gpencil_intern.h" /* ******************************************************** */ @@ -538,11 +540,14 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) View3D *v3d = (View3D *)CTX_wm_space_data(C); RegionView3D *rv3d = ar->regiondata; + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + /* init 3d depth buffers */ view3d_operator_needs_opengl(C); view3d_region_operator_needs_opengl(win, ar); - ED_view3d_autodist_init(graph, ar, v3d, 0); + ED_view3d_autodist_init(&eval_ctx, graph, ar, v3d, 0); /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { |