diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2020-03-09 18:27:24 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2020-03-09 18:27:24 +0300 |
commit | 29f3af95272590d26f610ae828b2eeee89c82a00 (patch) | |
tree | a696a58a2561c48f7ec6166e369e22081e0a64d8 /source/blender/editors/gpencil/gpencil_intern.h | |
parent | dcb93126876879d969a30a7865700abd072066f8 (diff) |
GPencil: Refactor of Draw Engine, Vertex Paint and all internal functions
This commit is a full refactor of the grease pencil modules including Draw Engine, Modifiers, VFX, depsgraph update, improvements in operators and conversion of Sculpt and Weight paint tools to real brushes.
Also, a huge code cleanup has been done at all levels.
Thanks to @fclem for his work and yo @pepeland and @mendio for the testing and help in the development.
Differential Revision: https://developer.blender.org/D6293
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_intern.h')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_intern.h | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index 077b5b88118..2d36e426835 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -111,6 +111,8 @@ typedef struct tGPDinterpolate_layer { } tGPDinterpolate_layer; typedef struct tGPDinterpolate { + /** Current depsgraph from context */ + struct Depsgraph *depsgraph; /** current scene from context */ struct Scene *scene; /** area where painting originated */ @@ -138,10 +140,6 @@ typedef struct tGPDinterpolate { int flag; NumInput num; /* numeric input */ - /** handle for drawing strokes while operator is running 3d stuff */ - void *draw_handle_3d; - /** handle for drawing strokes while operator is running screen stuff */ - void *draw_handle_screen; } tGPDinterpolate; /* Temporary primitive operation data */ @@ -155,6 +153,8 @@ typedef struct tGPDprimitive { struct Scene *scene; /** current active gp object */ struct Object *ob; + /** current evaluated gp object */ + struct Object *ob_eval; /** area where painting originated */ struct ScrArea *sa; /** region where painting originated */ @@ -166,7 +166,7 @@ typedef struct tGPDprimitive { /** current GP datablock */ struct bGPdata *gpd; /** current material */ - struct Material *mat; + struct Material *material; /** current brush */ struct Brush *brush; @@ -233,10 +233,6 @@ typedef struct tGPDprimitive { } tGPDprimitive; /* Modal Operator Drawing Callbacks ------------------------ */ - -void ED_gp_draw_interpolation(const struct bContext *C, - struct tGPDinterpolate *tgpi, - const int type); void ED_gp_draw_fill(struct tGPDdraw *tgpw); /* ***************************************************** */ @@ -284,7 +280,6 @@ void gp_point_to_parent_space(const bGPDspoint *pt, const float diff_mat[4][4], */ void gp_apply_parent(struct Depsgraph *depsgraph, struct Object *obact, - bGPdata *gpd, bGPDlayer *gpl, bGPDstroke *gps); /** @@ -292,7 +287,6 @@ void gp_apply_parent(struct Depsgraph *depsgraph, */ void gp_apply_parent_point(struct Depsgraph *depsgraph, struct Object *obact, - bGPdata *gpd, bGPDlayer *gpl, bGPDspoint *pt); @@ -342,7 +336,6 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, int gp_delete_selected_point_wrap(bContext *C); void gp_subdivide_stroke(bGPDstroke *gps, const int subdivide); -void gp_randomize_stroke(bGPDstroke *gps, Brush *brush, struct RNG *rng); /* Layers Enums -------------------------------------- */ @@ -367,6 +360,14 @@ void GPENCIL_OT_annotate(struct wmOperatorType *ot); void GPENCIL_OT_draw(struct wmOperatorType *ot); void GPENCIL_OT_fill(struct wmOperatorType *ot); +/* Vertex Paint. */ +void GPENCIL_OT_vertex_paint(struct wmOperatorType *ot); +void GPENCIL_OT_vertex_color_brightness_contrast(struct wmOperatorType *ot); +void GPENCIL_OT_vertex_color_hsv(struct wmOperatorType *ot); +void GPENCIL_OT_vertex_color_invert(struct wmOperatorType *ot); +void GPENCIL_OT_vertex_color_levels(struct wmOperatorType *ot); +void GPENCIL_OT_vertex_color_set(struct wmOperatorType *ot); + /* Guides ----------------------- */ void GPENCIL_OT_guide_rotate(struct wmOperatorType *ot); @@ -390,6 +391,7 @@ void GPENCIL_OT_selectmode_toggle(struct wmOperatorType *ot); void GPENCIL_OT_paintmode_toggle(struct wmOperatorType *ot); void GPENCIL_OT_sculptmode_toggle(struct wmOperatorType *ot); void GPENCIL_OT_weightmode_toggle(struct wmOperatorType *ot); +void GPENCIL_OT_vertexmode_toggle(struct wmOperatorType *ot); void GPENCIL_OT_selection_opacity_toggle(struct wmOperatorType *ot); void GPENCIL_OT_select(struct wmOperatorType *ot); @@ -405,6 +407,7 @@ void GPENCIL_OT_select_less(struct wmOperatorType *ot); void GPENCIL_OT_select_first(struct wmOperatorType *ot); void GPENCIL_OT_select_last(struct wmOperatorType *ot); void GPENCIL_OT_select_alternate(struct wmOperatorType *ot); +void GPENCIL_OT_select_color(struct wmOperatorType *ot); void GPENCIL_OT_duplicate(struct wmOperatorType *ot); void GPENCIL_OT_delete(struct wmOperatorType *ot); @@ -415,16 +418,19 @@ void GPENCIL_OT_extrude(struct wmOperatorType *ot); void GPENCIL_OT_move_to_layer(struct wmOperatorType *ot); void GPENCIL_OT_layer_change(struct wmOperatorType *ot); +void GPENCIL_OT_layer_active(struct wmOperatorType *ot); void GPENCIL_OT_snap_to_grid(struct wmOperatorType *ot); void GPENCIL_OT_snap_to_cursor(struct wmOperatorType *ot); void GPENCIL_OT_snap_cursor_to_selected(struct wmOperatorType *ot); void GPENCIL_OT_reproject(struct wmOperatorType *ot); +void GPENCIL_OT_recalc_geometry(struct wmOperatorType *ot); /* stroke sculpting -- */ void GPENCIL_OT_sculpt_paint(struct wmOperatorType *ot); +void GPENCIL_OT_weight_paint(struct wmOperatorType *ot); /* buttons editing --- */ @@ -440,6 +446,9 @@ void GPENCIL_OT_layer_annotation_move(struct wmOperatorType *ot); void GPENCIL_OT_layer_duplicate(struct wmOperatorType *ot); void GPENCIL_OT_layer_duplicate_object(struct wmOperatorType *ot); +void GPENCIL_OT_layer_mask_add(struct wmOperatorType *ot); +void GPENCIL_OT_layer_mask_remove(struct wmOperatorType *ot); + void GPENCIL_OT_hide(struct wmOperatorType *ot); void GPENCIL_OT_reveal(struct wmOperatorType *ot); @@ -459,6 +468,7 @@ void GPENCIL_OT_frame_clean_fill(struct wmOperatorType *ot); void GPENCIL_OT_frame_clean_loose(struct wmOperatorType *ot); void GPENCIL_OT_convert(struct wmOperatorType *ot); +void GPENCIL_OT_image_to_grease_pencil(struct wmOperatorType *ot); enum { GP_STROKE_JOIN = -1, @@ -498,8 +508,16 @@ void GPENCIL_OT_stroke_merge(struct wmOperatorType *ot); void GPENCIL_OT_stroke_cutter(struct wmOperatorType *ot); void GPENCIL_OT_stroke_trim(struct wmOperatorType *ot); void GPENCIL_OT_stroke_merge_by_distance(struct wmOperatorType *ot); +void GPENCIL_OT_stroke_merge_material(struct wmOperatorType *ot); -void GPENCIL_OT_brush_presets_create(struct wmOperatorType *ot); +void GPENCIL_OT_material_to_vertex_color(struct wmOperatorType *ot); +void GPENCIL_OT_extract_palette_vertex(struct wmOperatorType *ot); + +void GPENCIL_OT_transform_fill(struct wmOperatorType *ot); +void GPENCIL_OT_reset_transform_fill(struct wmOperatorType *ot); + +void GPENCIL_OT_brush_reset(struct wmOperatorType *ot); +void GPENCIL_OT_brush_reset_all(struct wmOperatorType *ot); /* undo stack ---------- */ @@ -617,7 +635,7 @@ struct GP_EditableStrokes_Iter { bGPDframe *init_gpf_ = (is_multiedit_) ? gpl->frames.first : gpl->actframe; \ for (bGPDframe *gpf_ = init_gpf_; gpf_; gpf_ = gpf_->next) { \ if ((gpf_ == gpl->actframe) || ((gpf_->flag & GP_FRAME_SELECT) && is_multiedit_)) { \ - ED_gpencil_parent_location(depsgraph_, obact_, gpd_, gpl, gpstroke_iter.diff_mat); \ + BKE_gpencil_parent_matrix_get(depsgraph_, obact_, gpl, gpstroke_iter.diff_mat); \ invert_m4_m4(gpstroke_iter.inverse_diff_mat, gpstroke_iter.diff_mat); \ /* loop over strokes */ \ bGPDstroke *gpsn_; \ @@ -643,10 +661,6 @@ struct GP_EditableStrokes_Iter { } \ (void)0 -#define GPENCIL_ANY_SCULPT_MASK(flag) \ - ((flag & (GP_SCULPT_MASK_SELECTMODE_POINT | GP_SCULPT_MASK_SELECTMODE_STROKE | \ - GP_SCULPT_MASK_SELECTMODE_SEGMENT))) - /** * Iterate over all editable strokes using evaluated data in the current context, * stopping on each usable layer + stroke pair (i.e. gpl and gps) @@ -662,26 +676,21 @@ struct GP_EditableStrokes_Iter { struct GP_EditableStrokes_Iter gpstroke_iter = {{{0}}}; \ Depsgraph *depsgraph_ = CTX_data_ensure_evaluated_depsgraph(C); \ Object *obact_ = CTX_data_active_object(C); \ - Object *obeval_ = DEG_get_evaluated_object(depsgraph_, obact_); \ - bGPdata *gpd_ = CTX_data_gpencil_data(C); \ + Object *ob_eval_ = (Object *)DEG_get_evaluated_id(depsgraph_, &obact_->id); \ + bGPdata *gpd_ = (bGPdata *)ob_eval_->data; \ const bool is_multiedit_ = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_); \ - int idx_eval = 0; \ - for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { \ - if (gpencil_layer_is_editable(gpl)) { \ + LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd_->layers) { \ + if (BKE_gpencil_layer_is_editable(gpl)) { \ bGPDframe *init_gpf_ = gpl->actframe; \ if (is_multiedit_) { \ init_gpf_ = gpl->frames.first; \ } \ for (bGPDframe *gpf_ = init_gpf_; gpf_; gpf_ = gpf_->next) { \ if ((gpf_ == gpl->actframe) || ((gpf_->flag & GP_FRAME_SELECT) && is_multiedit_)) { \ - ED_gpencil_parent_location(depsgraph_, obact_, gpd_, gpl, gpstroke_iter.diff_mat); \ + BKE_gpencil_parent_matrix_get(depsgraph_, obact_, gpl, gpstroke_iter.diff_mat); \ invert_m4_m4(gpstroke_iter.inverse_diff_mat, gpstroke_iter.diff_mat); \ - /* get evaluated frame with modifiers applied */ \ - bGPDframe *gpf_eval_ = (!is_multiedit_) ? \ - &obeval_->runtime.gpencil_evaluated_frames[idx_eval] : \ - gpf_; \ /* loop over strokes */ \ - for (bGPDstroke *gps = gpf_eval_->strokes.first; gps; gps = gps->next) { \ + for (bGPDstroke *gps = gpf_->strokes.first; gps; gps = gps->next) { \ /* skip strokes that are invalid for current view */ \ if (ED_gpencil_stroke_can_use(C, gps) == false) \ continue; \ @@ -698,7 +707,6 @@ struct GP_EditableStrokes_Iter { } \ } \ } \ - idx_eval++; \ } \ } \ (void)0 |