67 int size =
int(scalar * old_size);
69 if (
abs(old_size - size) <
U.pixelsize) {
73 else if (scalar < 1) {
78 if (use_unified_size) {
89 float unprojected_radius = scalar * (use_unified_size ?
93 if (unprojected_radius < 0.001f) {
94 unprojected_radius = 0.001f;
97 if (use_unified_size) {
115 ot->
name =
"Scale Sculpt/Paint Brush Size";
125 RNA_def_float(
ot->
srna,
"scalar", 1, 0, 2,
"Scalar",
"Factor to scale brush size by", 0, 2);
146 ot->
name =
"Add New Palette";
196 color->value = brush->
weight;
206 ot->
name =
"New Palette Color";
208 ot->
idname =
"PALETTE_OT_color_add";
234 ot->
name =
"Delete Palette Color";
236 ot->
idname =
"PALETTE_OT_color_delete";
277 const int range =
int(
pow(10.0f, threshold));
278 for (
int row = 0; row < ibuf->
y; row++) {
282 for (
int i = 0; i < 3; i++) {
283 color[i] = truncf(color[i] * range) /
range;
312 ot->
name =
"Extract Palette from Image";
313 ot->
idname =
"PALETTE_OT_extract_from_image";
314 ot->
description =
"Extract all colors used in Image and create a Palette";
336 if (palette ==
nullptr) {
346 color_array = MEM_cnew_array<tPaletteColorHSV>(totcol, __func__);
351 rgb_to_hsv(color->rgb[0], color->rgb[1], color->rgb[2], &h, &s, &
v);
352 col_elm = &color_array[t];
354 col_elm->
value = color->value;
364 else if (type == 2) {
367 else if (type == 3) {
380 for (
int i = 0; i < totcol; i++) {
381 col_elm = &color_array[i];
402 {1,
"HSV", 0,
"Hue, Saturation, Value",
""},
403 {2,
"SVH", 0,
"Saturation, Value, Hue",
""},
404 {3,
"VHS", 0,
"Value, Hue, Saturation",
""},
405 {4,
"LUMINANCE", 0,
"Luminance",
""},
406 {0,
nullptr, 0,
nullptr,
nullptr},
410 ot->
name =
"Sort Palette";
432 if (palcolor ==
nullptr) {
450 {-1,
"UP", 0,
"Up",
""},
451 {1,
"DOWN", 0,
"Down",
""},
452 {0,
nullptr, 0,
nullptr,
nullptr},
456 ot->
name =
"Move Palette Color";
457 ot->
idname =
"PALETTE_OT_color_move";
458 ot->
description =
"Move the active Color up/down in the list";
476 Palette *palette_join =
nullptr;
482 if ((palette ==
nullptr) || (name[0] ==
'\0')) {
487 if (palette_join ==
nullptr) {
498 palcol->
value = color->value;
520 ot->
name =
"Join Palette Swatches";
659#define PIXEL_MARGIN 5
662 const float mvalf[2] = {
float(mval[0]),
float(mval[1])};
697 angle =
atan2f(mdiff[1], mdiff[0]);
702 if (angle >
float(2 *
M_PI)) {
723 switch (event->
type) {
791 {0,
nullptr, 0,
nullptr,
nullptr},
797 {0,
nullptr, 0,
nullptr,
nullptr},
800 ot->
name =
"Stencil Brush Control";
802 ot->
idname =
"BRUSH_OT_stencil_control";
828 MTex *mtex =
nullptr;
837 float orig_area, stencil_area, factor;
841 aspx *= mtex->
size[0];
842 aspy *= mtex->
size[1];
850 orig_area =
fabsf(aspx * aspy);
859 factor =
sqrtf(stencil_area / orig_area);
880 ot->
name =
"Image Aspect";
882 "When using an image texture, adjust the stencil size to fit the image aspect ratio";
883 ot->
idname =
"BRUSH_OT_stencil_fit_image_aspect";
895 ot->
srna,
"mask",
false,
"Modify Mask Stencil",
"Modify either the primary or mask stencil");
936 ot->
name =
"Reset Transform";
937 ot->
description =
"Reset the stencil transformation to the default";
938 ot->
idname =
"BRUSH_OT_stencil_reset_transform";
948 ot->
srna,
"mask",
false,
"Modify Mask Stencil",
"Modify either the primary or mask stencil");
959 "Add Curve Point and Slide",
960 "Add new curve point and slide it",
1116 keymap = paint_stroke_modal_keymap(keyconf);
1121 keymap->
poll = curves_sculpt_poll;
1124 expand::modal_keymap(keyconf);
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
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void void bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL()
int BLI_listbase_count(const struct 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)
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
@ OB_MODE_PAINT_GREASE_PENCIL
Object is a sort of wrapper for general info.
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.
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 Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
ATTR_WARN_UNUSED_RESULT const BMVert * v
pow(value.r - subtrahend, 2.0)") .do_static_compilation(true)
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
ccl_device_inline float4 mask(const int4 mask, const float4 a)
bool paint_supports_texture(PaintMode mode)
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 int palette_color_move_exec(bContext *C, wmOperator *op)
static int stencil_fit_image_aspect_exec(bContext *C, wmOperator *op)
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 bool palette_poll(bContext *C)
static void BRUSH_OT_stencil_fit_image_aspect(wmOperatorType *ot)
static void stencil_control_calculate(StencilControlData *scd, const int mval[2])
static int palette_join_exec(bContext *C, wmOperator *op)
static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void stencil_set_target(StencilControlData *scd)
static int palette_new_exec(bContext *C, wmOperator *)
static int palette_extract_img_exec(bContext *C, wmOperator *op)
void ED_operatormacros_paint()
static void PALETTE_OT_new(wmOperatorType *ot)
static void PALETTE_OT_color_delete(wmOperatorType *ot)
static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *event)
static int palette_color_delete_exec(bContext *C, wmOperator *)
static void PALETTE_OT_color_move(wmOperatorType *ot)
static int palette_sort_exec(bContext *C, wmOperator *op)
static void PALETTE_OT_color_add(wmOperatorType *ot)
static int stencil_reset_transform_exec(bContext *C, wmOperator *op)
static void BRUSH_OT_stencil_control(wmOperatorType *ot)
static int brush_scale_size_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 int palette_color_add_exec(bContext *C, wmOperator *)
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 *)
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(* cancel)(bContext *C, wmOperator *op)
struct ReportList * reports
ccl_device_inline int abs(int x)
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)