37 #include "RNA_prototypes.h"
52 #define GP_SELECT_BUFFER_CHUNK 256
144 if (*buffer_used + 1 > *buffer_size) {
145 if ((*buffer_size == 0) || (buffer_array ==
NULL)) {
155 *buffer_size = *buffer_used = 0;
164 if (buffer_array !=
NULL) {
165 memset(buffer_array, 0,
sizeof(
tGP_Selected) * *buffer_size);
180 float influence = brush->
alpha;
195 influence *= brush_falloff;
238 if ((ob_armature !=
NULL)) {
240 if (actbone !=
NULL) {
389 const float diff_mat[4][4],
390 const float bound_mat[4][4])
406 bool include_last =
false;
427 if (pt_active !=
NULL) {
437 for (i = 0; (i + 1) < gps->
totpoints; i++) {
440 pt2 = gps->
points + i + 1;
461 if (pt_active !=
NULL) {
477 if (pt_active !=
NULL) {
480 include_last =
false;
487 else if (include_last) {
495 if (pt_active !=
NULL) {
499 include_last =
false;
512 const float diff_mat[4][4],
513 const float bound_mat[4][4])
545 bool changed =
false;
552 brush_draw_apply(gso, selected->gps, selected->pt_index, radius, selected->pc);
557 printf(
"ERROR: Unknown type of GPencil Weight Paint brush\n");
574 bool changed =
false;
587 float diff_mat[4][4], bound_mat[4][4];
590 mul_m4_m4m4(diff_mat, diff_mat, gpl->layer_invmat);
623 if (gpl->actframe !=
NULL) {
627 C, gso, gpl, gpl->actframe, diff_mat, bound_mat);
644 bool changed =
false;
648 gso->
mval[0] = mouse[0] = (int)(mousef[0]);
649 gso->
mval[1] = mouse[1] = (int)(mousef[1]);
695 mouse[0] =
event->mval[0] + 1;
696 mouse[1] =
event->mval[1] + 1;
706 float pressure =
event->tablet.pressure;
707 CLAMP(pressure, 0.0f, 1.0f);
756 if (is_modal ==
false) {
775 bool redraw_region =
false;
776 bool redraw_toolsettings =
false;
781 switch (event->
type) {
789 redraw_region =
true;
819 switch (event->
type) {
842 redraw_region =
true;
878 if (redraw_toolsettings) {
889 ot->
name =
"Stroke Weight Paint";
890 ot->
idname =
"GPENCIL_OT_weight_paint";
typedef float(TangentPoint)[2]
Blender kernel action and pose functionality.
struct bPoseChannel * BKE_pose_channel_find_name(const struct bPose *pose, const char *name)
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 Main * CTX_data_main(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)
void BKE_gpencil_dvert_ensure(struct bGPDstroke *gps)
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])
struct Object * BKE_modifiers_is_deformed_by_armature(struct Object *ob)
void BKE_report(ReportList *reports, eReportType type, const char *message)
#define LISTBASE_FOREACH(type, var, list)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE float max_ff(float a, float b)
MINLINE float interpf(float a, float b, float t)
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_int(int r[2], const int a[2])
MINLINE float normalize_v2(float r[2])
bool BLI_rcti_isect_pt(const struct rcti *rect, int x, int y)
struct Depsgraph Depsgraph
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
struct ID * DEG_get_evaluated_id(const struct Depsgraph *depsgraph, struct ID *id)
#define GPENCIL_MULTIEDIT_SESSIONS_ON(gpd)
@ GP_SCULPT_SETT_FLAG_FRAME_FALLOFF
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)
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)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
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_can_use(const bContext *C, const bGPDstroke *gps)
bGPdata * ED_gpencil_data_get_active(const bContext *C)
static void gpencil_weightpaint_brush_header_set(bContext *C)
static bool brush_draw_apply(tGP_BrushWeightpaintData *gso, bGPDstroke *gps, int pt_index, const int radius, const int co[2])
static int gpencil_weightpaint_brush_modal(bContext *C, wmOperator *op, const wmEvent *event)
static int gpencil_weightpaint_brush_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void gpencil_weightpaint_brush_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
static bool gpencil_weightpaint_brush_apply_to_layers(bContext *C, tGP_BrushWeightpaintData *gso)
static float brush_influence_calc(tGP_BrushWeightpaintData *gso, const int radius, const int co[2])
static void gpencil_save_selected_point(tGP_BrushWeightpaintData *gso, bGPDstroke *gps, int index, int pc[2])
void GPENCIL_OT_weight_paint(wmOperatorType *ot)
static tGP_Selected * gpencil_select_buffer_ensure(tGP_Selected *buffer_array, int *buffer_size, int *buffer_used, const bool clear)
static void gpencil_weightpaint_brush_exit(bContext *C, wmOperator *op)
struct tGP_BrushWeightpaintData tGP_BrushWeightpaintData
static bool gpencil_weightpaint_brush_poll(bContext *C)
#define GP_SELECT_BUFFER_CHUNK
static bool gpencil_weightpaint_brush_do_frame(bContext *C, tGP_BrushWeightpaintData *gso, bGPDlayer *gpl, bGPDframe *gpf, const float diff_mat[4][4], const float bound_mat[4][4])
static bool gpencil_weightpaint_brush_init(bContext *C, wmOperator *op)
static void gpencil_weightpaint_brush_apply_event(bContext *C, wmOperator *op, const wmEvent *event)
static void gpencil_weightpaint_select_stroke(tGP_BrushWeightpaintData *gso, bGPDstroke *gps, const float diff_mat[4][4], const float bound_mat[4][4])
static int gpencil_weightpaint_brush_exec(bContext *C, wmOperator *op)
static void brush_calc_dvec_2d(tGP_BrushWeightpaintData *gso)
struct tGP_Selected tGP_Selected
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 MDeformVert * dvert
ListBase vertex_group_names
int vertex_group_active_index
bool use_multiframe_falloff
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)