32 #include "RNA_prototypes.h"
47 #define GP_SELECT_BUFFER_CHUNK 256
48 #define GP_GRID_PIXEL_SIZE 10.0f
159 if (*buffer_used + 1 > *buffer_size) {
160 if ((*buffer_size == 0) || (buffer_array ==
NULL)) {
170 *buffer_size = *buffer_used = 0;
179 if (buffer_array !=
NULL) {
180 memset(buffer_array, 0,
sizeof(
tGP_Selected) * *buffer_size);
207 float influence = brush->
size;
221 influence *= brush_falloff;
270 grid = &gso->
grid[grid_index];
290 if (gso->
dvec[1] < 0.0f) {
291 if ((gso->
dvec[0] >= -1.0f) && (gso->
dvec[0] < -0.8f)) {
295 else if ((gso->
dvec[0] >= -0.8f) && (gso->
dvec[0] < -0.6f)) {
299 else if ((gso->
dvec[0] >= -0.6f) && (gso->
dvec[0] < 0.6f)) {
303 else if ((gso->
dvec[0] >= 0.6f) && (gso->
dvec[0] < 0.8f)) {
307 else if (gso->
dvec[0] >= 0.8f) {
314 if ((gso->
dvec[0] >= -1.0f) && (gso->
dvec[0] < -0.8f)) {
318 else if ((gso->
dvec[0] >= -0.8f) && (gso->
dvec[0] < -0.6f)) {
322 else if ((gso->
dvec[0] >= -0.6f) && (gso->
dvec[0] < 0.6f)) {
326 else if ((gso->
dvec[0] >= 0.6f) && (gso->
dvec[0] < 0.8f)) {
330 else if (gso->
dvec[0] >= 0.8f) {
341 for (
int i = 0; i < gso->
grid_len; i++) {
370 gps_selected = selected->
gps;
374 if (grid_index > -1) {
375 grid = &gso->
grid[grid_index];
379 grid->
color[3] = 1.0f;
386 for (
int i = 0; i < gso->
grid_len; i++) {
387 grid = &gso->
grid[i];
418 CLAMP(inf, 0.0f, 1.0f);
419 CLAMP(inf_fill, 0.0f, 1.0f);
502 gps_selected = selected->
gps;
504 if ((gps_selected == gps) && (selected->
pt_index == pt_index)) {
517 mul_v3_fl(r_color, (1.0f / (
float)totcol));
564 float average_color[3])
580 alpha_fill -= inf_fill;
584 alpha_fill += inf_fill;
589 CLAMP(alpha, 0.0f, 1.0f);
596 CLAMP(alpha_fill, 0.0f, 1.0f);
615 bool changed =
false;
640 CLAMP(fac, 0.0f, 1.0f);
648 if (grid_index > -1) {
651 row += average_idx[0];
652 col += average_idx[1];
658 grid = &gso->
grid[new_index];
663 if (grid_index > -1) {
664 if (grid->
color[3] > 0.0f) {
674 if (grid_index > -1) {
675 if (grid->
color[3] > 0.0f) {
690 TIP_(
"GPencil Vertex Paint: LMB to paint | RMB/Escape to Exit"
691 " | Ctrl to Invert Action"));
813 const float diff_mat[4][4],
814 const float bound_mat[4][4])
830 bool include_last =
false;
860 if (pt_active !=
NULL) {
872 for (i = 0; (i + 1) < gps->
totpoints; i++) {
875 pt2 = gps->
points + i + 1;
881 include_last =
false;
905 if (pt_active !=
NULL) {
928 if (pt_active !=
NULL) {
932 include_last =
false;
940 else if (include_last) {
948 if (pt_active !=
NULL) {
952 include_last =
false;
962 gps_active->mat_nr + 1);
970 for (
int repeat = 0; repeat < 50; repeat++) {
987 const float diff_mat[4][4],
988 const float bound_mat[4][4])
1026 float average_color[3] = {0};
1049 mul_v3_fl(average_color, (1.0f / (
float)totcol));
1056 bool changed =
false;
1064 brush_tint_apply(gso, selected->gps, selected->pt_index, radius, selected->pc);
1069 brush_blur_apply(gso, selected->gps, selected->pt_index, radius, selected->pc);
1075 gso, selected->gps, selected->pt_index, radius, selected->pc, average_color);
1091 printf(
"ERROR: Unknown type of GPencil Vertex Paint brush\n");
1108 bool changed =
false;
1121 float diff_mat[4][4], bound_mat[4][4];
1124 mul_m4_m4m4(diff_mat, diff_mat, gpl->layer_invmat);
1157 if (gpl->actframe !=
NULL) {
1160 C, gso, gpl, gpl->actframe, diff_mat, bound_mat);
1177 bool changed =
false;
1181 gso->
mval[0] = mouse[0] = (int)(mousef[0]);
1182 gso->
mval[1] = mouse[1] = (int)(mousef[1]);
1238 mouse[0] =
event->mval[0] + 1;
1239 mouse[1] =
event->mval[1] + 1;
1249 float pressure =
event->tablet.pressure;
1250 CLAMP(pressure, 0.0f, 1.0f);
1299 if (is_modal ==
false) {
1318 bool redraw_region =
false;
1319 bool redraw_toolsettings =
false;
1324 switch (event->
type) {
1332 redraw_region =
true;
1362 switch (event->
type) {
1385 redraw_region =
true;
1416 if (redraw_region) {
1421 if (redraw_toolsettings) {
1432 ot->
name =
"Stroke Vertex Paint";
1433 ot->
idname =
"GPENCIL_OT_vertex_paint";
typedef float(TangentPoint)[2]
float BKE_brush_curve_strength(const struct Brush *br, float p, float len)
struct Scene * CTX_data_scene(const bContext *C)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct Object * CTX_data_active_object(const bContext *C)
#define CTX_DATA_COUNT(C, member)
struct ARegion * CTX_wm_region(const bContext *C)
struct ToolSettings * CTX_data_tool_settings(const bContext *C)
float BKE_gpencil_multiframe_falloff_calc(struct bGPDframe *gpf, int actnum, int f_init, int f_end, struct CurveMapping *cur_falloff)
#define GPENCIL_TINT_VERTEX_COLOR_STROKE(brush)
bool BKE_gpencil_layer_is_editable(const struct bGPDlayer *gpl)
void BKE_gpencil_frame_range_selected(struct bGPDlayer *gpl, int *r_initframe, int *r_endframe)
void BKE_gpencil_layer_transform_matrix_get(const struct Depsgraph *depsgraph, struct Object *obact, struct bGPDlayer *gpl, float diff_mat[4][4])
#define GPENCIL_TINT_VERTEX_COLOR_FILL(brush)
General operations, lookup, etc. for materials.
struct MaterialGPencilStyle * BKE_gpencil_material_settings(struct Object *ob, short act)
void BKE_report(ReportList *reports, eReportType type, const char *message)
#define LISTBASE_FOREACH(type, var, list)
MINLINE void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
MINLINE void round_v2i_v2fl(int r[2], const float a[2])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE float len_v2v2_int(const int v1[2], const int v2[2])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void zero_v3(float r[3])
MINLINE float normalize_v2(float r[2])
MINLINE void add_v3_v3(float r[3], const float a[3])
bool BLI_rcti_isect_pt(const struct rcti *rect, int x, int y)
#define ARRAY_SET_ITEMS(...)
struct Depsgraph Depsgraph
void DEG_id_tag_update(struct ID *id, int flag)
struct ID * DEG_get_evaluated_id(const struct Depsgraph *depsgraph, struct ID *id)
#define GPENCIL_ANY_VERTEX_MASK(flag)
@ GP_CURVE_NEEDS_STROKE_UPDATE
#define GPENCIL_MULTIEDIT_SESSIONS_ON(gpd)
@ GP_SCULPT_SETT_FLAG_FRAME_FALLOFF
enum eGP_vertex_SelectMaskFlag eGP_Vertex_SelectMaskFlag
bScreen * ED_screen_animation_playing(const struct wmWindowManager *wm)
void ED_region_tag_redraw(struct ARegion *region)
void ED_workspace_status_text(struct bContext *C, const char *str)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble top
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble bottom
Read Guarded memory(de)allocation.
#define MEM_recallocN(vmemh, len)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
#define RNA_BEGIN(sptr, itemptr, propname)
const Depsgraph * depsgraph
void gpencil_point_conversion_init(struct bContext *C, GP_SpaceConversion *r_gsc)
void gpencil_point_to_parent_space(const bGPDspoint *pt, const float diff_mat[4][4], bGPDspoint *r_pt)
bool gpencil_stroke_inside_circle(const float mval[2], int rad, int x0, int y0, int x1, int y1)
void gpencil_point_to_xy(const GP_SpaceConversion *gsc, const struct bGPDstroke *gps, const struct bGPDspoint *pt, int *r_x, int *r_y)
bool ED_gpencil_stroke_material_editable(Object *ob, const bGPDlayer *gpl, const bGPDstroke *gps)
bool ED_gpencil_stroke_check_collision(const GP_SpaceConversion *gsc, bGPDstroke *gps, const float mval[2], const int radius, const float diff_mat[4][4])
bool ED_gpencil_stroke_point_is_inside(const bGPDstroke *gps, const GP_SpaceConversion *gsc, const int mval[2], const float diff_mat[4][4])
bool ED_gpencil_stroke_can_use(const bContext *C, const bGPDstroke *gps)
bGPdata * ED_gpencil_data_get_active(const bContext *C)
static void gpencil_vertexpaint_brush_apply_event(bContext *C, wmOperator *op, const wmEvent *event)
static bool gpencil_vertexpaint_brush_do_frame(bContext *C, tGP_BrushVertexpaintData *gso, bGPDlayer *gpl, bGPDframe *gpf, const float diff_mat[4][4], const float bound_mat[4][4])
static int gpencil_vertexpaint_brush_exec(bContext *C, wmOperator *op)
static bool brush_blur_apply(tGP_BrushVertexpaintData *gso, bGPDstroke *gps, int pt_index, const int radius, const int co[2])
static bool brush_tint_apply(tGP_BrushVertexpaintData *gso, bGPDstroke *gps, int pt_index, const int radius, const int co[2])
static int gpencil_vertexpaint_brush_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void gpencil_vertexpaint_brush_exit(bContext *C, wmOperator *op)
static bool brush_invert_check(tGP_BrushVertexpaintData *gso)
static bool brush_replace_apply(tGP_BrushVertexpaintData *gso, bGPDstroke *gps, int pt_index)
static tGP_Selected * gpencil_select_buffer_ensure(tGP_Selected *buffer_array, int *buffer_size, int *buffer_used, const bool clear)
static void brush_calc_dvec_2d(tGP_BrushVertexpaintData *gso)
#define GP_SELECT_BUFFER_CHUNK
static int gpencil_vertexpaint_brush_modal(bContext *C, wmOperator *op, const wmEvent *event)
static bool brush_smear_apply(tGP_BrushVertexpaintData *gso, bGPDstroke *gps, int pt_index, tGP_Selected *selected)
static void gpencil_grid_cells_init(tGP_BrushVertexpaintData *gso)
#define GP_GRID_PIXEL_SIZE
static void gpencil_vertexpaint_brush_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
static void gpencil_save_selected_point(tGP_BrushVertexpaintData *gso, bGPDstroke *gps, int index, int pc[2])
static bool gpencil_vertexpaint_brush_apply_to_layers(bContext *C, tGP_BrushVertexpaintData *gso)
static bool brush_average_apply(tGP_BrushVertexpaintData *gso, bGPDstroke *gps, int pt_index, const int radius, const int co[2], float average_color[3])
static bool get_surrounding_color(tGP_BrushVertexpaintData *gso, bGPDstroke *gps, int pt_index, float r_color[3])
static void gpencil_grid_cell_average_color_idx_get(tGP_BrushVertexpaintData *gso, int r_idx[2])
static bool gpencil_vertexpaint_select_stroke(tGP_BrushVertexpaintData *gso, bGPDstroke *gps, const char tool, const float diff_mat[4][4], const float bound_mat[4][4])
void GPENCIL_OT_vertex_paint(wmOperatorType *ot)
static void gpencil_grid_colors_calc(tGP_BrushVertexpaintData *gso)
static void gpencil_vertexpaint_brush_header_set(bContext *C)
static int gpencil_grid_cell_index_get(tGP_BrushVertexpaintData *gso, const int pc[2])
struct tGP_Selected tGP_Selected
@ GP_VERTEX_FLAG_TMP_INVERT
static float brush_influence_calc(tGP_BrushVertexpaintData *gso, const int radius, const int co[2])
static bool gpencil_vertexpaint_brush_init(bContext *C, wmOperator *op)
static bool gpencil_vertexpaint_brush_poll(bContext *C)
struct tGP_BrushVertexpaintData tGP_BrushVertexpaintData
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
void *(* MEM_callocN)(size_t len, const char *str)
static void clear(Message *msg)
T distance(const T &a, const T &b)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
void RNA_collection_add(PointerRNA *ptr, const char *name, PointerRNA *r_value)
float RNA_float_get(PointerRNA *ptr, const char *name)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_collection_runtime(StructOrFunctionRNA *cont_, const char *identifier, StructRNA *type, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
struct CurveMapping * curve
struct BrushGpencilSettings * gpencil_settings
struct CurveMapping * cur_falloff
struct bGPDspoint * pt_orig
bGPDspoint_Runtime runtime
struct bGPDstroke * gps_orig
bGPDstroke_Runtime runtime
struct bGPDcurve * editcurve
bool use_multiframe_falloff
eGPDvertex_brush_Flag flag
eGP_Vertex_SelectMaskFlag mask
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
void(* cancel)(struct bContext *, struct wmOperator *)
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)