66 int size = int(scalar * old_size);
68 if (
abs(old_size -
size) <
U.pixelsize) {
72 else if (scalar < 1) {
77 if (use_unified_size) {
88 float unprojected_radius = scalar * (use_unified_size ?
92 unprojected_radius = std::max(unprojected_radius, 0.001f);
94 if (use_unified_size) {
112 ot->name =
"Scale Sculpt/Paint Brush Size";
113 ot->description =
"Change brush size by a scalar";
114 ot->idname =
"BRUSH_OT_scale_size";
122 RNA_def_float(
ot->srna,
"scalar", 1, 0, 2,
"Scalar",
"Factor to scale brush size by", 0, 2);
143 ot->name =
"Add New Palette";
144 ot->description =
"Add new palette";
145 ot->idname =
"PALETTE_OT_new";
203 ot->name =
"New Palette Color";
204 ot->description =
"Add new color to active palette";
205 ot->idname =
"PALETTE_OT_color_add";
231 ot->name =
"Delete Palette Color";
232 ot->description =
"Remove active color from palette";
233 ot->idname =
"PALETTE_OT_color_delete";
274 const int range = int(
pow(10.0f, threshold));
275 for (
int row = 0; row < ibuf->
y; row++) {
279 for (
int i = 0;
i < 3;
i++) {
280 color[
i] = truncf(color[
i] * range) / range;
309 ot->name =
"Extract Palette from Image";
310 ot->idname =
"PALETTE_OT_extract_from_image";
311 ot->description =
"Extract all colors used in Image and create a Palette";
321 prop =
RNA_def_int(
ot->srna,
"threshold", 1, 1, 1,
"Threshold",
"", 1, 1);
333 if (palette ==
nullptr) {
348 rgb_to_hsv(color->rgb[0], color->rgb[1], color->rgb[2], &h, &s, &
v);
349 col_elm = &color_array[t];
351 col_elm->
value = color->value;
361 else if (type == 2) {
364 else if (type == 3) {
377 for (
int i = 0;
i < totcol;
i++) {
378 col_elm = &color_array[
i];
399 {1,
"HSV", 0,
"Hue, Saturation, Value",
""},
400 {2,
"SVH", 0,
"Saturation, Value, Hue",
""},
401 {3,
"VHS", 0,
"Value, Hue, Saturation",
""},
402 {4,
"LUMINANCE", 0,
"Luminance",
""},
403 {0,
nullptr, 0,
nullptr,
nullptr},
407 ot->name =
"Sort Palette";
408 ot->idname =
"PALETTE_OT_sort";
409 ot->description =
"Sort Palette Colors";
429 if (palcolor ==
nullptr) {
447 {-1,
"UP", 0,
"Up",
""},
448 {1,
"DOWN", 0,
"Down",
""},
449 {0,
nullptr, 0,
nullptr,
nullptr},
453 ot->name =
"Move Palette Color";
454 ot->idname =
"PALETTE_OT_color_move";
455 ot->description =
"Move the active Color up/down in the list";
473 Palette *palette_join =
nullptr;
479 if ((palette ==
nullptr) || (name[0] ==
'\0')) {
484 if (palette_join ==
nullptr) {
495 palcol->
value = color->value;
517 ot->name =
"Join Palette Swatches";
518 ot->idname =
"PALETTE_OT_join";
519 ot->description =
"Join Palette Swatches";
605 const float mvalf[2] = {float(event->
mval[0]), float(event->
mval[1])};
656#define PIXEL_MARGIN 5
659 const float mvalf[2] = {float(mval[0]), float(mval[1])};
720 switch (event->
type) {
788 {0,
nullptr, 0,
nullptr,
nullptr},
794 {0,
nullptr, 0,
nullptr,
nullptr},
797 ot->name =
"Stencil Brush Control";
798 ot->description =
"Control the stencil brush";
799 ot->idname =
"BRUSH_OT_stencil_control";
825 MTex *mtex =
nullptr;
834 float orig_area, stencil_area, factor;
838 aspx *= mtex->
size[0];
839 aspy *= mtex->
size[1];
847 orig_area =
fabsf(aspx * aspy);
856 factor =
sqrtf(stencil_area / orig_area);
877 ot->name =
"Image Aspect";
879 "When using an image texture, adjust the stencil size to fit the image aspect ratio";
880 ot->idname =
"BRUSH_OT_stencil_fit_image_aspect";
889 RNA_def_boolean(
ot->srna,
"use_repeat",
true,
"Use Repeat",
"Use repeat mapping values");
890 RNA_def_boolean(
ot->srna,
"use_scale",
true,
"Use Scale",
"Use texture scale values");
892 ot->srna,
"mask",
false,
"Modify Mask Stencil",
"Modify either the primary or mask stencil");
933 ot->name =
"Reset Transform";
934 ot->description =
"Reset the stencil transformation to the default";
935 ot->idname =
"BRUSH_OT_stencil_reset_transform";
945 ot->srna,
"mask",
false,
"Modify Mask Stencil",
"Modify either the primary or mask stencil");
956 "Add Curve Point and Slide",
957 "Add new curve point and slide it",
959 ot->description =
"Add new curve point and slide it";
float BKE_brush_unprojected_radius_get(const Scene *scene, const Brush *brush)
int BKE_brush_size_get(const Scene *scene, const Brush *brush)
void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojected_radius)
void BKE_brush_size_set(Scene *scene, Brush *brush, int size)
const float * BKE_brush_color_get(const Scene *scene, const Paint *paint, const Brush *brush)
void BKE_brush_tag_unsaved_changes(Brush *brush)
SpaceImage * CTX_wm_space_image(const bContext *C)
SpaceLink * CTX_wm_space_data(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
bool BKE_image_has_ibuf(Image *ima, ImageUser *iuser)
ID * BKE_libblock_find_name(Main *bmain, short type, const char *name, const std::optional< Library * > lib=std::nullopt) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
PaletteColor * BKE_palette_color_add(Palette *palette)
void BKE_palette_sort_hsv(tPaletteColorHSV *color_array, int totcol)
bool BKE_palette_from_hash(Main *bmain, GHash *color_table, const char *name, bool linear)
void BKE_palette_sort_svh(tPaletteColorHSV *color_array, int totcol)
void BKE_palette_color_remove(Palette *palette, PaletteColor *color)
void BKE_palette_sort_vhs(tPaletteColorHSV *color_array, int totcol)
const Brush * BKE_paint_brush_for_read(const Paint *paint)
Paint * BKE_paint_get_active_from_context(const bContext *C)
Palette * BKE_palette_add(Main *bmain, const char *name)
void BKE_palette_sort_luminance(tPaletteColorHSV *color_array, int totcol)
Brush * BKE_paint_brush(Paint *paint)
void BKE_paint_palette_set(Paint *paint, Palette *palette)
PaintMode BKE_paintmode_get_active_from_context(const bContext *C)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
bool BLI_ghash_haskey(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
GHash * BLI_ghash_int_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void void void bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL()
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
unsigned int rgb_to_cpack(float r, float g, float b)
void rgb_to_hsv(float r, float g, float b, float *r_h, float *r_s, float *r_v)
MINLINE float len_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void clamp_v2(float vec[2], float min, float max)
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void zero_v3(float r[3])
#define POINTER_FROM_INT(i)
@ OB_MODE_PAINT_GREASE_PENCIL
void ED_image_get_uv_aspect(Image *ima, ImageUser *iuser, float *r_aspx, float *r_aspy)
void ED_region_tag_redraw(ARegion *region)
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
void IMB_sampleImageAtLocation(ImBuf *ibuf, float x, float y, bool make_linear_rgb, float color[4])
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
void * MEM_mallocN(size_t len, const char *str)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
void modal_keymap(wmKeyConfig *keyconf)
void PAINT_OT_hide_show_polyline_gesture(wmOperatorType *ot)
void PAINT_OT_hide_show_masked(wmOperatorType *ot)
void PAINT_OT_hide_show_line_gesture(wmOperatorType *ot)
void PAINT_OT_visibility_invert(wmOperatorType *ot)
void PAINT_OT_hide_show_lasso_gesture(wmOperatorType *ot)
void PAINT_OT_visibility_filter(wmOperatorType *ot)
void PAINT_OT_hide_show_all(wmOperatorType *ot)
void PAINT_OT_hide_show(wmOperatorType *ot)
void PAINT_OT_mask_polyline_gesture(wmOperatorType *ot)
void PAINT_OT_mask_line_gesture(wmOperatorType *ot)
void PAINT_OT_mask_box_gesture(wmOperatorType *ot)
void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot)
void PAINT_OT_mask_flood_fill(wmOperatorType *ot)
bool curves_sculpt_poll(bContext *C)
void BRUSH_OT_asset_save(wmOperatorType *ot)
bool paint_supports_texture(PaintMode mode)
void BRUSH_OT_asset_delete(wmOperatorType *ot)
void BRUSH_OT_asset_edit_metadata(wmOperatorType *ot)
void BRUSH_OT_asset_load_preview(wmOperatorType *ot)
void BRUSH_OT_asset_revert(wmOperatorType *ot)
wmKeyMap * paint_stroke_modal_keymap(wmKeyConfig *keyconf)
void BRUSH_OT_asset_save_as(wmOperatorType *ot)
void BRUSH_OT_asset_activate(wmOperatorType *ot)
bool paint_curve_poll(bContext *C)
void PAINTCURVE_OT_new(wmOperatorType *ot)
void PAINTCURVE_OT_add_point(wmOperatorType *ot)
void PAINTCURVE_OT_delete_point(wmOperatorType *ot)
void PAINTCURVE_OT_draw(wmOperatorType *ot)
void PAINTCURVE_OT_cursor(wmOperatorType *ot)
void PAINTCURVE_OT_slide(wmOperatorType *ot)
void PAINTCURVE_OT_select(wmOperatorType *ot)
bool vert_paint_poll(bContext *C)
bool facemask_paint_poll(bContext *C)
bool image_texture_paint_poll(bContext *C)
void PAINT_OT_sample_color(wmOperatorType *ot)
void PAINT_OT_texture_paint_toggle(wmOperatorType *ot)
void PAINT_OT_brush_colors_flip(wmOperatorType *ot)
void PAINT_OT_grab_clone(wmOperatorType *ot)
void PAINT_OT_image_paint(wmOperatorType *ot)
void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot)
void PAINT_OT_add_simple_uvs(wmOperatorType *ot)
void PAINT_OT_project_image(wmOperatorType *ot)
void PAINT_OT_image_from_view(wmOperatorType *ot)
void SCULPT_OT_uv_sculpt_relax(wmOperatorType *ot)
void PAINT_OT_weight_set(wmOperatorType *ot)
void PAINT_OT_vertex_color_set(wmOperatorType *ot)
void PAINT_OT_face_select_more(wmOperatorType *ot)
void PAINT_OT_vert_select_less(wmOperatorType *ot)
void PAINT_OT_vertex_color_smooth(wmOperatorType *ot)
void PAINT_OT_weight_paint(wmOperatorType *ot)
void PAINT_OT_face_select_hide(wmOperatorType *ot)
void PAINT_OT_face_select_loop(wmOperatorType *ot)
void PAINT_OT_vertex_color_hsv(wmOperatorType *ot)
void PAINT_OT_vert_select_linked(wmOperatorType *ot)
void PAINT_OT_vertex_paint(wmOperatorType *ot)
void PAINT_OT_face_select_linked_pick(wmOperatorType *ot)
bool weight_paint_mode_poll(bContext *C)
void PAINT_OT_vert_select_linked_pick(wmOperatorType *ot)
void PAINT_OT_vert_select_ungrouped(wmOperatorType *ot)
void BRUSH_OT_sculpt_curves_falloff_preset(wmOperatorType *ot)
void BRUSH_OT_curve_preset(wmOperatorType *ot)
void PAINT_OT_face_select_less(wmOperatorType *ot)
void PAINT_OT_weight_sample(wmOperatorType *ot)
void PAINT_OT_vert_select_all(wmOperatorType *ot)
void PAINT_OT_vertex_color_levels(wmOperatorType *ot)
void PAINT_OT_face_select_all(wmOperatorType *ot)
void PAINT_OT_vertex_color_from_weight(wmOperatorType *ot)
void PAINT_OT_face_select_linked(wmOperatorType *ot)
bool vertex_paint_mode_poll(bContext *C)
void PAINT_OT_weight_from_bones(wmOperatorType *ot)
void PAINT_OT_vertex_color_brightness_contrast(wmOperatorType *ot)
void PAINT_OT_weight_paint_toggle(wmOperatorType *ot)
void PAINT_OT_weight_gradient(wmOperatorType *ot)
void SCULPT_OT_uv_sculpt_pinch(wmOperatorType *ot)
void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot)
void PAINT_OT_vertex_color_invert(wmOperatorType *ot)
void PAINT_OT_vert_select_hide(wmOperatorType *ot)
void PAINT_OT_weight_sample_group(wmOperatorType *ot)
void PAINT_OT_vert_select_more(wmOperatorType *ot)
void SCULPT_OT_uv_sculpt_grab(wmOperatorType *ot)
void PAINT_OT_face_vert_reveal(wmOperatorType *ot)
static void BRUSH_OT_scale_size(wmOperatorType *ot)
static wmOperatorStatus palette_color_delete_exec(bContext *C, wmOperator *)
static void PALETTE_OT_join(wmOperatorType *ot)
static bool stencil_control_poll(bContext *C)
void ED_operatortypes_paint()
static void PALETTE_OT_extract_from_image(wmOperatorType *ot)
static void BRUSH_OT_stencil_reset_transform(wmOperatorType *ot)
static wmOperatorStatus palette_sort_exec(bContext *C, wmOperator *op)
static bool palette_poll(bContext *C)
static wmOperatorStatus palette_join_exec(bContext *C, wmOperator *op)
static wmOperatorStatus stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void BRUSH_OT_stencil_fit_image_aspect(wmOperatorType *ot)
static wmOperatorStatus palette_color_add_exec(bContext *C, wmOperator *)
static void stencil_control_calculate(StencilControlData *scd, const int mval[2])
static wmOperatorStatus stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void stencil_set_target(StencilControlData *scd)
static wmOperatorStatus palette_new_exec(bContext *C, wmOperator *)
void ED_operatormacros_paint()
static wmOperatorStatus palette_extract_img_exec(bContext *C, wmOperator *op)
static void PALETTE_OT_new(wmOperatorType *ot)
static void PALETTE_OT_color_delete(wmOperatorType *ot)
static void PALETTE_OT_color_move(wmOperatorType *ot)
static wmOperatorStatus brush_scale_size_exec(bContext *C, wmOperator *op)
static void PALETTE_OT_color_add(wmOperatorType *ot)
static wmOperatorStatus stencil_reset_transform_exec(bContext *C, wmOperator *op)
static void BRUSH_OT_stencil_control(wmOperatorType *ot)
static wmOperatorStatus palette_color_move_exec(bContext *C, wmOperator *op)
static void stencil_restore(StencilControlData *scd)
static bool palette_extract_img_poll(bContext *C)
static void PALETTE_OT_sort(wmOperatorType *ot)
static void stencil_control_cancel(bContext *, wmOperator *op)
static wmOperatorStatus stencil_fit_image_aspect_exec(bContext *C, wmOperator *op)
void ED_keymap_paint(wmKeyConfig *keyconf)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
int RNA_int_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
bool SCULPT_mode_poll(bContext *C)
float stencil_dimension[2]
float mask_stencil_pos[2]
struct BrushGpencilSettings * gpencil_settings
float mask_stencil_dimension[2]
ImBufByteBuffer byte_buffer
StencilConstraint constrain_mode
bool(* poll)(struct bContext *)
struct ReportList * reports
int WM_userdef_event_type_from_keymap_type(int kmitype)
void WM_main_add_notifier(uint type, void *reference)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
wmOperatorTypeMacro * WM_operatortype_macro_define(wmOperatorType *ot, const char *idname)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
wmOperatorType * WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag)