Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2020-03-09 18:27:24 +0300
committerAntonio Vazquez <blendergit@gmail.com>2020-03-09 18:27:24 +0300
commit29f3af95272590d26f610ae828b2eeee89c82a00 (patch)
treea696a58a2561c48f7ec6166e369e22081e0a64d8 /source/blender/blenkernel/BKE_gpencil.h
parentdcb93126876879d969a30a7865700abd072066f8 (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/blenkernel/BKE_gpencil.h')
-rw-r--r--source/blender/blenkernel/BKE_gpencil.h159
1 files changed, 113 insertions, 46 deletions
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 1a186d2d682..9d382775df7 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -32,19 +32,22 @@ struct BoundBox;
struct Brush;
struct CurveMapping;
struct Depsgraph;
+struct GHash;
struct ListBase;
struct Main;
struct Material;
struct Object;
struct Scene;
+struct SpaceImage;
struct ToolSettings;
struct bDeformGroup;
struct bGPDframe;
struct bGPDlayer;
+struct bGPDlayer_Mask;
struct bGPDspoint;
struct bGPDstroke;
struct bGPdata;
-
+struct MaterialGPencilStyle;
struct MDeformVert;
#define GPENCIL_SIMPLIFY(scene) ((scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_ENABLE))
@@ -54,18 +57,33 @@ struct MDeformVert;
#define GPENCIL_SIMPLIFY_FILL(scene, playing) \
((GPENCIL_SIMPLIFY_ONPLAY(playing) && (GPENCIL_SIMPLIFY(scene)) && \
(scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_FILL)))
-#define GPENCIL_SIMPLIFY_MODIF(scene, playing) \
- ((GPENCIL_SIMPLIFY_ONPLAY(playing) && (GPENCIL_SIMPLIFY(scene)) && \
- (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_MODIFIER)))
+#define GPENCIL_SIMPLIFY_MODIF(scene) \
+ ((GPENCIL_SIMPLIFY(scene) && (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_MODIFIER)))
#define GPENCIL_SIMPLIFY_FX(scene, playing) \
((GPENCIL_SIMPLIFY_ONPLAY(playing) && (GPENCIL_SIMPLIFY(scene)) && \
(scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_FX)))
-#define GPENCIL_SIMPLIFY_BLEND(scene, playing) \
- ((GPENCIL_SIMPLIFY_ONPLAY(playing) && (GPENCIL_SIMPLIFY(scene)) && \
- (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_BLEND)))
-#define GPENCIL_SIMPLIFY_TINT(scene, playing) \
- ((GPENCIL_SIMPLIFY_ONPLAY(playing) && (GPENCIL_SIMPLIFY(scene)) && \
- (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_TINT)))
+#define GPENCIL_SIMPLIFY_TINT(scene) \
+ ((GPENCIL_SIMPLIFY(scene)) && (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_TINT))
+#define GPENCIL_SIMPLIFY_AA(scene) \
+ ((GPENCIL_SIMPLIFY(scene)) && (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_AA))
+
+/* Vertex Color macros. */
+#define GPENCIL_USE_VERTEX_COLOR(toolsettings) \
+ ((toolsettings->gp_paint->mode == GPPAINT_FLAG_USE_VERTEXCOLOR))
+#define GPENCIL_USE_VERTEX_COLOR_STROKE(toolsettings, brush) \
+ ((GPENCIL_USE_VERTEX_COLOR(toolsettings) && \
+ ((brush->gpencil_settings->vertex_mode == GPPAINT_MODE_STROKE) || \
+ (brush->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH))))
+#define GPENCIL_USE_VERTEX_COLOR_FILL(toolsettings, brush) \
+ ((GPENCIL_USE_VERTEX_COLOR(toolsettings) && \
+ ((brush->gpencil_settings->vertex_mode == GPPAINT_MODE_FILL) || \
+ (brush->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH))))
+#define GPENCIL_TINT_VERTEX_COLOR_STROKE(brush) \
+ ((brush->gpencil_settings->vertex_mode == GPPAINT_MODE_STROKE) || \
+ (brush->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH))
+#define GPENCIL_TINT_VERTEX_COLOR_FILL(brush) \
+ ((brush->gpencil_settings->vertex_mode == GPPAINT_MODE_FILL) || \
+ (brush->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH))
/* ------------ Grease-Pencil API ------------------ */
@@ -75,8 +93,9 @@ void BKE_gpencil_free_stroke(struct bGPDstroke *gps);
bool BKE_gpencil_free_strokes(struct bGPDframe *gpf);
void BKE_gpencil_free_frames(struct bGPDlayer *gpl);
void BKE_gpencil_free_layers(struct ListBase *list);
-bool BKE_gpencil_free_frame_runtime_data(struct bGPDframe *gpf_eval);
void BKE_gpencil_free(struct bGPdata *gpd, bool free_all);
+void BKE_gpencil_eval_delete(struct bGPdata *gpd_eval);
+void BKE_gpencil_free_layer_masks(struct bGPDlayer *gpl);
void BKE_gpencil_batch_cache_dirty_tag(struct bGPdata *gpd);
void BKE_gpencil_batch_cache_free(struct bGPdata *gpd);
@@ -91,10 +110,11 @@ struct bGPdata *BKE_gpencil_data_addnew(struct Main *bmain, const char name[]);
struct bGPDframe *BKE_gpencil_frame_duplicate(const struct bGPDframe *gpf_src);
struct bGPDlayer *BKE_gpencil_layer_duplicate(const struct bGPDlayer *gpl_src);
void BKE_gpencil_frame_copy_strokes(struct bGPDframe *gpf_src, struct bGPDframe *gpf_dst);
-struct bGPDstroke *BKE_gpencil_stroke_duplicate(struct bGPDstroke *gps_src);
+struct bGPDstroke *BKE_gpencil_stroke_duplicate(struct bGPDstroke *gps_src, const bool dup_points);
void BKE_gpencil_copy_data(struct bGPdata *gpd_dst, const struct bGPdata *gpd_src, const int flag);
struct bGPdata *BKE_gpencil_copy(struct Main *bmain, const struct bGPdata *gpd);
+
struct bGPdata *BKE_gpencil_data_duplicate(struct Main *bmain,
const struct bGPdata *gpd,
bool internal_copy);
@@ -109,6 +129,11 @@ bool BKE_gpencil_material_index_used(struct bGPdata *gpd, int index);
void BKE_gpencil_material_remap(struct bGPdata *gpd,
const unsigned int *remap,
unsigned int remap_len);
+bool BKE_gpencil_merge_materials_table_get(struct Object *ob,
+ const float hue_threshold,
+ const float sat_threshold,
+ const float val_threshold,
+ struct GHash *r_mat_table);
/* statistics functions */
void BKE_gpencil_stats_update(struct bGPdata *gpd);
@@ -124,12 +149,11 @@ void BKE_gpencil_stroke_add_points(struct bGPDstroke *gps,
const int totpoints,
const float mat[4][4]);
-struct bGPDstroke *BKE_gpencil_add_stroke(struct bGPDframe *gpf,
- int mat_idx,
- int totpoints,
- short thickness);
+struct bGPDstroke *BKE_gpencil_stroke_new(int mat_idx, int totpoints, short thickness);
+struct bGPDstroke *BKE_gpencil_stroke_add(
+ struct bGPDframe *gpf, int mat_idx, int totpoints, short thickness, const bool insert_at_head);
-struct bGPDstroke *BKE_gpencil_add_stroke_existing_style(struct bGPDframe *gpf,
+struct bGPDstroke *BKE_gpencil_stroke_add_existing_style(struct bGPDframe *gpf,
struct bGPDstroke *existing,
int mat_idx,
int totpoints,
@@ -139,7 +163,7 @@ struct bGPDstroke *BKE_gpencil_add_stroke_existing_style(struct bGPDframe *gpf,
#define GPENCIL_ALPHA_OPACITY_THRESH 0.001f
#define GPENCIL_STRENGTH_MIN 0.003f
-bool gpencil_layer_is_editable(const struct bGPDlayer *gpl);
+bool BKE_gpencil_layer_is_editable(const struct bGPDlayer *gpl);
/* How gpencil_layer_getframe() should behave when there
* is no existing GP-Frame on the frame requested.
@@ -154,17 +178,25 @@ typedef enum eGP_GetFrame_Mode {
GP_GETFRAME_ADD_COPY = 2,
} eGP_GetFrame_Mode;
-struct bGPDframe *BKE_gpencil_layer_getframe(struct bGPDlayer *gpl,
- int cframe,
- eGP_GetFrame_Mode addnew);
-struct bGPDframe *BKE_gpencil_layer_find_frame(struct bGPDlayer *gpl, int cframe);
-bool BKE_gpencil_layer_delframe(struct bGPDlayer *gpl, struct bGPDframe *gpf);
+struct bGPDframe *BKE_gpencil_layer_frame_get(struct bGPDlayer *gpl,
+ int cframe,
+ eGP_GetFrame_Mode addnew);
+struct bGPDframe *BKE_gpencil_layer_frame_find(struct bGPDlayer *gpl, int cframe);
+bool BKE_gpencil_layer_frame_delete(struct bGPDlayer *gpl, struct bGPDframe *gpf);
-struct bGPDlayer *BKE_gpencil_layer_getactive(struct bGPdata *gpd);
-void BKE_gpencil_layer_setactive(struct bGPdata *gpd, struct bGPDlayer *active);
+struct bGPDlayer *BKE_gpencil_layer_named_get(struct bGPdata *gpd, const char *name);
+struct bGPDlayer *BKE_gpencil_layer_active_get(struct bGPdata *gpd);
+void BKE_gpencil_layer_active_set(struct bGPdata *gpd, struct bGPDlayer *active);
void BKE_gpencil_layer_delete(struct bGPdata *gpd, struct bGPDlayer *gpl);
void BKE_gpencil_layer_autolock_set(struct bGPdata *gpd, const bool unlock);
+struct bGPDlayer_Mask *BKE_gpencil_layer_mask_add(struct bGPDlayer *gpl, const char *name);
+void BKE_gpencil_layer_mask_remove(struct bGPDlayer *gpl, struct bGPDlayer_Mask *mask);
+void BKE_gpencil_layer_mask_remove_ref(struct bGPdata *gpd, const char *name);
+struct bGPDlayer_Mask *BKE_gpencil_layer_mask_named_get(struct bGPDlayer *gpl, const char *name);
+void BKE_gpencil_layer_mask_sort(struct bGPdata *gpd, struct bGPDlayer *gpl);
+void BKE_gpencil_layer_mask_sort_all(struct bGPdata *gpd);
+
/* Brush */
struct Material *BKE_gpencil_brush_material_get(struct Brush *brush);
void BKE_gpencil_brush_material_set(struct Brush *brush, struct Material *material);
@@ -183,9 +215,9 @@ struct Material *BKE_gpencil_object_material_new(struct Main *bmain,
const char *name,
int *r_index);
-int BKE_gpencil_object_material_get_index(struct Object *ob, struct Material *ma);
+int BKE_gpencil_object_material_index_get(struct Object *ob, struct Material *ma);
-struct Material *BKE_gpencil_object_material_get_from_brush(struct Object *ob,
+struct Material *BKE_gpencil_object_material_from_brush_get(struct Object *ob,
struct Brush *brush);
int BKE_gpencil_object_material_get_index_from_brush(struct Object *ob, struct Brush *brush);
@@ -206,22 +238,23 @@ bool BKE_gpencil_stroke_select_check(const struct bGPDstroke *gps);
struct BoundBox *BKE_gpencil_boundbox_get(struct Object *ob);
void BKE_gpencil_centroid_3d(struct bGPdata *gpd, float r_centroid[3]);
+void BKE_gpencil_stroke_boundingbox_calc(struct bGPDstroke *gps);
/* vertex groups */
void BKE_gpencil_dvert_ensure(struct bGPDstroke *gps);
void BKE_gpencil_vgroup_remove(struct Object *ob, struct bDeformGroup *defgroup);
void BKE_gpencil_stroke_weights_duplicate(struct bGPDstroke *gps_src, struct bGPDstroke *gps_dst);
-/* GPencil geometry evaluation */
-void BKE_gpencil_eval_geometry(struct Depsgraph *depsgraph, struct bGPdata *gpd);
+/* Set active frame by layer. */
+void BKE_gpencil_frame_active_set(struct Depsgraph *depsgraph, struct bGPdata *gpd);
/* stroke geometry utilities */
void BKE_gpencil_stroke_normal(const struct bGPDstroke *gps, float r_normal[3]);
-void BKE_gpencil_simplify_stroke(struct bGPDstroke *gps, float factor);
-void BKE_gpencil_simplify_fixed(struct bGPDstroke *gps);
-void BKE_gpencil_subdivide(struct bGPDstroke *gps, int level, int flag);
-bool BKE_gpencil_trim_stroke(struct bGPDstroke *gps);
-void BKE_gpencil_merge_distance_stroke(struct bGPDframe *gpf,
+void BKE_gpencil_stroke_simplify_adaptive(struct bGPDstroke *gps, float factor);
+void BKE_gpencil_stroke_simplify_fixed(struct bGPDstroke *gps);
+void BKE_gpencil_stroke_subdivide(struct bGPDstroke *gps, int level, int type);
+bool BKE_gpencil_stroke_trim(struct bGPDstroke *gps);
+void BKE_gpencil_stroke_merge_distance(struct bGPDframe *gpf,
struct bGPDstroke *gps,
const float threshold,
const bool use_unselected);
@@ -237,31 +270,33 @@ void BKE_gpencil_stroke_2d_flat_ref(const struct bGPDspoint *ref_points,
float (*points2d)[2],
const float scale,
int *r_direction);
-void BKE_gpencil_triangulate_stroke_fill(struct bGPdata *gpd, struct bGPDstroke *gps);
+void BKE_gpencil_stroke_fill_triangulate(struct bGPDstroke *gps);
+void BKE_gpencil_stroke_geometry_update(struct bGPDstroke *gps);
+void BKE_gpencil_stroke_uv_update(struct bGPDstroke *gps);
void BKE_gpencil_transform(struct bGPdata *gpd, float mat[4][4]);
-bool BKE_gpencil_sample_stroke(struct bGPDstroke *gps, const float dist, const bool select);
-bool BKE_gpencil_smooth_stroke(struct bGPDstroke *gps, int i, float inf);
-bool BKE_gpencil_smooth_stroke_strength(struct bGPDstroke *gps, int point_index, float influence);
-bool BKE_gpencil_smooth_stroke_thickness(struct bGPDstroke *gps, int point_index, float influence);
-bool BKE_gpencil_smooth_stroke_uv(struct bGPDstroke *gps, int point_index, float influence);
-bool BKE_gpencil_close_stroke(struct bGPDstroke *gps);
+bool BKE_gpencil_stroke_sample(struct bGPDstroke *gps, const float dist, const bool select);
+bool BKE_gpencil_stroke_smooth(struct bGPDstroke *gps, int i, float inf);
+bool BKE_gpencil_stroke_smooth_strength(struct bGPDstroke *gps, int point_index, float influence);
+bool BKE_gpencil_stroke_smooth_thickness(struct bGPDstroke *gps, int point_index, float influence);
+bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps, int point_index, float influence);
+bool BKE_gpencil_stroke_close(struct bGPDstroke *gps);
void BKE_gpencil_dissolve_points(struct bGPDframe *gpf, struct bGPDstroke *gps, const short tag);
-bool BKE_gpencil_stretch_stroke(struct bGPDstroke *gps, const float dist, const float tip_length);
-bool BKE_gpencil_trim_stroke_points(struct bGPDstroke *gps,
+bool BKE_gpencil_stroke_stretch(struct bGPDstroke *gps, const float dist, const float tip_length);
+bool BKE_gpencil_stroke_trim_points(struct bGPDstroke *gps,
const int index_from,
const int index_to);
-bool BKE_gpencil_split_stroke(struct bGPDframe *gpf,
+bool BKE_gpencil_stroke_split(struct bGPDframe *gpf,
struct bGPDstroke *gps,
const int before_index,
struct bGPDstroke **remaining_gps);
-bool BKE_gpencil_shrink_stroke(struct bGPDstroke *gps, const float dist);
+bool BKE_gpencil_stroke_shrink(struct bGPDstroke *gps, const float dist);
float BKE_gpencil_stroke_length(const struct bGPDstroke *gps, bool use_3d);
-void BKE_gpencil_get_range_selected(struct bGPDlayer *gpl, int *r_initframe, int *r_endframe);
+void BKE_gpencil_frame_range_selected(struct bGPDlayer *gpl, int *r_initframe, int *r_endframe);
float BKE_gpencil_multiframe_falloff_calc(
struct bGPDframe *gpf, int actnum, int f_init, int f_end, struct CurveMapping *cur_falloff);
@@ -273,9 +308,41 @@ void BKE_gpencil_convert_curve(struct Main *bmain,
const bool use_collections,
const bool only_stroke);
+void BKE_gpencil_palette_ensure(struct Main *bmain, struct Scene *scene);
+
+bool BKE_gpencil_from_image(struct SpaceImage *sima,
+ struct bGPDframe *gpf,
+ const float size,
+ const bool mask);
+
+/* Iterator */
+/* frame & stroke are NULL if it is a layer callback. */
+typedef void (*gpIterCb)(struct bGPDlayer *layer,
+ struct bGPDframe *frame,
+ struct bGPDstroke *stroke,
+ void *thunk);
+
+void BKE_gpencil_visible_stroke_iter(struct Object *ob,
+ gpIterCb layer_cb,
+ gpIterCb stroke_cb,
+ void *thunk,
+ bool do_onion,
+ int cfra);
+
extern void (*BKE_gpencil_batch_cache_dirty_tag_cb)(struct bGPdata *gpd);
extern void (*BKE_gpencil_batch_cache_free_cb)(struct bGPdata *gpd);
+void BKE_gpencil_frame_original_pointers_update(const struct bGPDframe *gpf_orig,
+ const struct bGPDframe *gpf_eval);
+void BKE_gpencil_update_orig_pointers(const struct Object *ob_orig, const struct Object *ob_eval);
+
+void BKE_gpencil_parent_matrix_get(const struct Depsgraph *depsgraph,
+ struct Object *obact,
+ struct bGPDlayer *gpl,
+ float diff_mat[4][4]);
+
+void BKE_gpencil_update_layer_parent(const struct Depsgraph *depsgraph, struct Object *ob);
+
#ifdef __cplusplus
}
#endif