62 #define GP_SELECT_BUFFER_CHUNK 256
63 #define GP_GRID_PIXEL_SIZE 10.0f
174 if (*buffer_used + 1 > *buffer_size) {
175 if ((*buffer_size == 0) || (buffer_array ==
NULL)) {
185 *buffer_size = *buffer_used = 0;
194 if (buffer_array !=
NULL) {
195 memset(buffer_array, 0,
sizeof(
tGP_Selected) * *buffer_size);
222 float influence = brush->
size;
236 influence *= brush_falloff;
285 grid = &gso->
grid[grid_index];
305 if (gso->
dvec[1] < 0.0f) {
306 if ((gso->
dvec[0] >= -1.0f) && (gso->
dvec[0] < -0.8f)) {
310 else if ((gso->
dvec[0] >= -0.8f) && (gso->
dvec[0] < -0.6f)) {
314 else if ((gso->
dvec[0] >= -0.6f) && (gso->
dvec[0] < 0.6f)) {
318 else if ((gso->
dvec[0] >= 0.6f) && (gso->
dvec[0] < 0.8f)) {
322 else if (gso->
dvec[0] >= 0.8f) {
329 if ((gso->
dvec[0] >= -1.0f) && (gso->
dvec[0] < -0.8f)) {
333 else if ((gso->
dvec[0] >= -0.8f) && (gso->
dvec[0] < -0.6f)) {
337 else if ((gso->
dvec[0] >= -0.6f) && (gso->
dvec[0] < 0.6f)) {
341 else if ((gso->
dvec[0] >= 0.6f) && (gso->
dvec[0] < 0.8f)) {
345 else if (gso->
dvec[0] >= 0.8f) {
356 for (
int i = 0; i < gso->
grid_len; i++) {
385 gps_selected = selected->
gps;
389 if (grid_index > -1) {
390 grid = &gso->
grid[grid_index];
394 grid->
color[3] = 1.0f;
401 for (
int i = 0; i < gso->
grid_len; i++) {
402 grid = &gso->
grid[i];
433 CLAMP(inf, 0.0f, 1.0f);
434 CLAMP(inf_fill, 0.0f, 1.0f);
517 gps_selected = selected->
gps;
519 if ((gps_selected == gps) && (selected->
pt_index == pt_index)) {
532 mul_v3_fl(r_color, (1.0f / (
float)totcol));
579 float average_color[3])
595 alpha_fill -= inf_fill;
599 alpha_fill += inf_fill;
611 CLAMP(alpha_fill, 0.0f, 1.0f);
630 bool changed =
false;
655 CLAMP(fac, 0.0f, 1.0f);
663 if (grid_index > -1) {
666 row += average_idx[0];
667 col += average_idx[1];
673 grid = &gso->
grid[new_index];
678 if (grid_index > -1) {
679 if (grid->
color[3] > 0.0f) {
689 if (grid_index > -1) {
690 if (grid->
color[3] > 0.0f) {
705 TIP_(
"GPencil Vertex Paint: LMB to paint | RMB/Escape to Exit"
706 " | Ctrl to Invert Action"));
828 const float diff_mat[4][4],
829 const float bound_mat[4][4])
845 bool include_last =
false;
875 if (pt_active !=
NULL) {
887 for (i = 0; (i + 1) < gps->
totpoints; i++) {
890 pt2 = gps->
points + i + 1;
896 include_last =
false;
920 if (pt_active !=
NULL) {
943 if (pt_active !=
NULL) {
947 include_last =
false;
955 else if (include_last) {
963 if (pt_active !=
NULL) {
967 include_last =
false;
977 gps_active->mat_nr + 1);
985 for (
int repeat = 0; repeat < 50; repeat++) {
1002 const float diff_mat[4][4],
1003 const float bound_mat[4][4])
1041 float average_color[3] = {0};
1064 mul_v3_fl(average_color, (1.0f / (
float)totcol));
1071 bool changed =
false;
1079 brush_tint_apply(gso, selected->gps, selected->pt_index, radius, selected->pc);
1084 brush_blur_apply(gso, selected->gps, selected->pt_index, radius, selected->pc);
1090 gso, selected->gps, selected->pt_index, radius, selected->pc, average_color);
1106 printf(
"ERROR: Unknown type of GPencil Vertex Paint brush\n");
1123 bool changed =
false;
1136 float diff_mat[4][4], bound_mat[4][4];
1139 mul_m4_m4m4(diff_mat, diff_mat, gpl->layer_invmat);
1172 if (gpl->actframe !=
NULL) {
1175 C, gso, gpl, gpl->actframe, diff_mat, bound_mat);
1192 bool changed =
false;
1196 gso->
mval[0] = mouse[0] = (int)(mousef[0]);
1197 gso->
mval[1] = mouse[1] = (int)(mousef[1]);
1253 mouse[0] =
event->mval[0] + 1;
1254 mouse[1] =
event->mval[1] + 1;
1264 float pressure =
event->tablet.pressure;
1265 CLAMP(pressure, 0.0f, 1.0f);
1314 if (is_modal ==
false) {
1333 bool redraw_region =
false;
1334 bool redraw_toolsettings =
false;
1339 switch (event->
type) {
1347 redraw_region =
true;
1377 switch (event->
type) {
1400 redraw_region =
true;
1431 if (redraw_region) {
1436 if (redraw_toolsettings) {
1447 ot->
name =
"Stroke Vertex Paint";
1448 ot->
idname =
"GPENCIL_OT_vertex_paint";
typedef float(TangentPoint)[2]
float BKE_brush_curve_strength(const struct Brush *br, float p, const 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, ReportType 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])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
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])
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, const int x, const 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 RGB to Bright Vector Camera CLAMP
#define RNA_BEGIN(sptr, itemptr, propname)
StructRNA RNA_OperatorStrokeElement
const Depsgraph * depsgraph
static CCL_NAMESPACE_BEGIN const double alpha
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(GP_SpaceConversion *gsc, bGPDstroke *gps, const float mouse[2], const int radius, const float diff_mat[4][4])
bool ED_gpencil_stroke_point_is_inside(bGPDstroke *gps, GP_SpaceConversion *gsc, int mouse[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
void *(* MEM_callocN)(size_t len, const char *str)
static void clear(Message *msg)
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
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
ccl_device_inline float distance(const float2 &a, const float2 &b)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)