110 ImBuf *ibuf,
int x,
int y,
int w,
int h,
int *tx,
int *ty,
int *tw,
int *th)
112 int srcx = 0, srcy = 0;
126 int tilex, tiley, tilew, tileh, tx, ty;
127 int srcx = 0, srcy = 0;
131 if (
w == 0 || h == 0) {
153 for (ty = tiley; ty <= tileh; ty++) {
154 for (tx = tilex; tx <= tilew; tx++) {
156 undo_tiles, ima, ibuf, &tmpibuf, iuser, tx, ty,
NULL,
NULL,
false, find_old);
180 if (texpaint || (sima && sima->
lock)) {
202 side = kernel->
side = 2;
214 side = kernel->
side = radius * 2 + 1;
223 kernel->
wdata[i] = 1.0;
229 float standard_dev = radius / 3.0f;
232 standard_dev = -standard_dev * standard_dev * 2;
234 for (i = 0; i < side; i++) {
235 for (j = 0; j < side; j++) {
236 float idist = radius - i;
237 float jdist = radius - j;
238 float value =
exp((idist * idist + jdist * jdist) / standard_dev);
240 kernel->
wdata[i + j * side] = value;
248 printf(
"unidentified kernel type, aborting\n");
367 bool color_correction,
404 if (color_correction) {
496 bool uvs, mat,
tex, stencil;
664 if (pop->s.warnmultifile) {
667 "Image requires 4 color channels to paint: %s",
668 pop->s.warnmultifile);
670 if (pop->s.warnpackedfile) {
673 "Packed MultiLayer files cannot be painted: %s",
674 pop->s.warnpackedfile);
752 ot->
idname =
"PAINT_OT_image_paint";
880 float startfx, startfy, fx, fy, delta[2];
883 switch (event->
type) {
892 ®ion->
v2d, cmv->
startx - xmin, cmv->
starty - ymin, &startfx, &startfy);
895 delta[0] = fx - startfx;
896 delta[1] = fy - startfy;
938 "Delta offset of clone image in 0.0 to 1.0 coordinates",
959 TIP_(
"Sample color for %s"),
960 !
data->sample_palette ?
961 TIP_(
"Brush. Use Left Click to sample for palette instead") :
962 TIP_(
"Palette. Use Left Click to sample more colors"));
1010 data->sample_palette =
false;
1044 if (
data->show_cursor) {
1048 if (
data->sample_palette) {
1063 switch (event->
type) {
1077 if (!
data->sample_palette) {
1078 data->sample_palette =
true;
1097 ot->
name =
"Sample Color";
1098 ot->
idname =
"PAINT_OT_sample_color";
1099 ot->
description =
"Use the mouse to sample a color in the image";
1169 if (
U.glreslimit != 0) {
1194 if (
U.glreslimit != 0) {
1234 const bool is_mode_set = (ob->
mode & mode_flag) != 0;
1242 if (ob->
mode & mode_flag) {
1259 ot->
name =
"Texture Paint Toggle";
1260 ot->
idname =
"PAINT_OT_texture_paint_toggle";
1316 ot->
name =
"Swap Colors";
1317 ot->
idname =
"PAINT_OT_brush_colors_flip";
1318 ot->
description =
"Swap primary and secondary brush colors";
1335 if (sima && sima->
image) {
1340 const float mouse_init[2] = {mouse[0], mouse[1]};
void BKE_brush_alpha_set(struct Scene *scene, struct Brush *brush, float alpha)
const float * BKE_brush_secondary_color_get(const struct Scene *scene, const struct Brush *brush)
float BKE_brush_alpha_get(const struct Scene *scene, const struct Brush *brush)
const float * BKE_brush_color_get(const struct Scene *scene, const struct Brush *brush)
int BKE_brush_size_get(const struct Scene *scene, const struct Brush *brush)
void BKE_brush_color_set(struct Scene *scene, struct Brush *brush, const float color[3])
bool BKE_brush_use_alpha_pressure(const struct Brush *brush)
bool BKE_colorband_evaluate(const struct ColorBand *coba, float in, float out[4])
struct ScrArea * CTX_wm_area(const bContext *C)
struct Scene * CTX_data_scene(const bContext *C)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct ViewLayer * CTX_data_view_layer(const bContext *C)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct Object * CTX_data_active_object(const bContext *C)
struct wmMsgBus * CTX_wm_message_bus(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct SpaceImage * CTX_wm_space_image(const bContext *C)
struct Main * CTX_data_main(const bContext *C)
struct ToolSettings * CTX_data_tool_settings(const bContext *C)
struct RegionView3D * CTX_wm_region_view3d(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
void BKE_image_paint_set_mipmap(struct Main *bmain, bool mipmap)
void BKE_image_mark_dirty(struct Image *image, struct ImBuf *ibuf)
void BKE_image_free_all_gputextures(struct Main *bmain)
void BKE_image_update_gputexture(struct Image *ima, struct ImageUser *iuser, int x, int y, int w, int h)
General operations, lookup, etc. for materials.
struct Material * BKE_object_material_get(struct Object *ob, short act)
void BKE_texpaint_slots_refresh_object(struct Scene *scene, struct Object *ob)
struct Mesh * BKE_mesh_from_object(struct Object *ob)
void ntreeTexEndExecTree(struct bNodeTreeExec *exec)
struct bNodeTreeExec * ntreeTexBeginExecTree(struct bNodeTree *ntree)
bool BKE_paint_select_elem_test(struct Object *ob)
ePaintMode BKE_paintmode_get_active_from_context(const struct bContext *C)
struct Brush * BKE_paint_brush(struct Paint *paint)
void BKE_paint_init(struct Main *bmain, struct Scene *sce, ePaintMode mode, const char col[3])
struct Paint * BKE_paint_get_active_from_context(const struct bContext *C)
bool BKE_paint_select_vert_test(struct Object *ob)
const char PAINT_CURSOR_TEXTURE_PAINT[3]
bool BKE_paint_select_face_test(struct Object *ob)
void BKE_paint_toolslots_brush_validate(struct Main *bmain, struct Paint *paint)
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
#define LISTBASE_FOREACH(type, var, list)
MINLINE float max_ff(float a, float b)
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
MINLINE void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
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 add_v2_v2(float r[2], const float a[2])
MINLINE void swap_v3_v3(float a[3], float b[3])
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
struct Depsgraph Depsgraph
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_COPY_ON_WRITE
#define ID_IS_LINKED(_id)
@ BRUSH_GRADIENT_SPACING_CLAMP
@ BRUSH_GRADIENT_PRESSURE
@ BRUSH_GRADIENT_SPACING_REPEAT
Object is a sort of wrapper for general info.
@ IMAGEPAINT_MODE_MATERIAL
#define OBACT(_view_layer)
#define IMAGEPAINT_DRAWING
#define MTEX_MAP_MODE_STENCIL
#define MTEX_MAP_MODE_TILED
#define OPERATOR_RETVAL_CHECK(ret)
void ED_space_image_get_zoom(struct SpaceImage *sima, const struct ARegion *region, float *r_zoomx, float *r_zoomy)
void ED_space_image_set(struct Main *bmain, struct SpaceImage *sima, struct Object *obedit, struct Image *ima, bool automatic)
bool ED_object_mode_compat_set(struct bContext *C, struct Object *ob, eObjectMode mode, struct ReportList *reports)
void ED_paint_data_warning(struct ReportList *reports, bool uvs, bool mat, bool tex, bool stencil)
void ED_image_undo_push_begin(const char *name, int paint_mode)
void ED_image_undo_restore(struct UndoStep *us)
void ED_image_undo_push_end(void)
struct ListBase * ED_image_paint_tile_list_get(void)
bool ED_paint_proj_mesh_data_check(struct Scene *scene, struct Object *ob, bool *uvs, bool *mat, bool *tex, bool *stencil)
void * ED_image_paint_tile_push(struct ListBase *paint_tiles, struct Image *image, struct ImBuf *ibuf, struct ImBuf **tmpibuf, struct ImageUser *iuser, int x_tile, int y_tile, unsigned short **r_mask, bool **r_valid, bool use_thread_lock, bool find_prev)
#define ED_IMAGE_UNDO_TILE_BITS
void ED_region_tag_redraw(struct ARegion *region)
void ED_workspace_status_text(struct bContext *C, const char *str)
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
_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 type
_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
@ GPU_SHADER_2D_UNIFORM_COLOR
void GPU_blend(eGPUBlend blend)
void GPU_line_width(float width)
void GPU_line_smooth(bool enable)
void IMB_partial_display_buffer_update_delayed(struct ImBuf *ibuf, int xmin, int ymin, int xmax, int ymax)
void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], struct ColorManagedDisplay *display)
void IMB_colormanagement_scene_linear_to_srgb_v3(float pixel[3])
void IMB_rectclip(struct ImBuf *dbuf, const struct ImBuf *sbuf, int *destx, int *desty, int *srcx, int *srcy, int *width, int *height)
void IMB_freeImBuf(struct ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
void UI_view2d_region_to_view(const struct View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
const Depsgraph * depsgraph
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
INLINE Rall1d< T, V, S > exp(const Rall1d< T, V, S > &arg)
static void area(int d1, int d2, int e1, int e2, float weights[2])
void paint_cursor_delete_textures(void)
void paint_cursor_start(Paint *p, bool(*poll)(bContext *C))
void paint_delete_blur_kernel(BlurKernel *kernel)
static void paint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
static bool image_paint_2d_clone_poll(bContext *C)
static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
BlurKernel * paint_new_blur_kernel(Brush *br, bool proj)
static bool image_paint_poll_ex(bContext *C, bool check_tool)
struct GrabClone GrabClone
static PaintOperation * texture_paint_init(bContext *C, wmOperator *op, const float mouse[2])
void ED_imapaint_bucket_fill(struct bContext *C, float color[3], wmOperator *op, const int mouse[2])
static bool texture_paint_poll(bContext *C)
bool vert_paint_poll(bContext *C)
static int grab_clone_exec(bContext *C, wmOperator *op)
void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, ImageUser *iuser, short texpaint)
static void paint_stroke_done(const bContext *C, struct PaintStroke *stroke)
ImagePaintPartialRedraw * get_imapaintpartial(void)
void paint_brush_init_tex(Brush *brush)
static bool texture_paint_toggle_poll(bContext *C)
void ED_imapaint_dirty_region(Image *ima, ImBuf *ibuf, ImageUser *iuser, int x, int y, int w, int h, bool find_old)
void ED_object_texture_paint_mode_exit_ex(Main *bmain, Scene *scene, Object *ob)
static int sample_color_exec(bContext *C, wmOperator *op)
static Brush * image_paint_brush(bContext *C)
static int grab_clone_modal(bContext *C, wmOperator *op, const wmEvent *event)
void ED_object_texture_paint_mode_exit(bContext *C)
bool facemask_paint_poll(bContext *C)
bool image_texture_paint_poll(bContext *C)
void ED_imapaint_clear_partial_redraw(void)
void ED_object_texture_paint_mode_enter_ex(Main *bmain, Scene *scene, Object *ob)
static bool image_paint_poll(bContext *C)
void PAINT_OT_sample_color(wmOperatorType *ot)
void set_imapaintpartial(struct ImagePaintPartialRedraw *ippr)
static void sample_color_update_header(SampleColorData *data, bContext *C)
static ImagePaintPartialRedraw imapaintpartial
void PAINT_OT_texture_paint_toggle(wmOperatorType *ot)
void ED_space_image_paint_update(Main *bmain, wmWindowManager *wm, Scene *scene)
bool mask_paint_poll(bContext *C)
static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op))
static bool paint_stroke_test_start(bContext *C, wmOperator *op, const float mouse[2])
bool paint_use_opacity_masking(Brush *brush)
void paint_brush_color_get(struct Scene *scene, struct Brush *br, bool color_correction, bool invert, float distance, float pressure, float color[3], struct ColorManagedDisplay *display)
static int grab_clone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
struct PaintOperation PaintOperation
static void toggle_paint_cursor(Scene *scene, bool enable)
static void grab_clone_cancel(bContext *UNUSED(C), wmOperator *op)
void ED_object_texture_paint_mode_enter(bContext *C)
static void grab_clone_apply(bContext *C, wmOperator *op)
void PAINT_OT_brush_colors_flip(wmOperatorType *ot)
bool get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
static bool brush_colors_flip_poll(bContext *C)
static int paint_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void PAINT_OT_grab_clone(wmOperatorType *ot)
void paint_brush_exit_tex(Brush *brush)
static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customdata)
static bool sample_color_poll(bContext *C)
void imapaint_region_tiles(ImBuf *ibuf, int x, int y, int w, int h, int *tx, int *ty, int *tw, int *th)
static bool image_paint_poll_ignore_tool(bContext *C)
static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void PAINT_OT_image_paint(wmOperatorType *ot)
static int paint_exec(bContext *C, wmOperator *op)
static void paint_stroke_redraw(const bContext *C, struct PaintStroke *stroke, bool final)
void paint_2d_bucket_fill(const bContext *C, const float color[3], Brush *br, const float mouse_init[2], const float mouse_final[2], void *ps)
void paint_2d_gradient_fill(const bContext *C, Brush *br, const float mouse_init[2], const float mouse_final[2], void *ps)
void paint_2d_stroke_done(void *ps)
void paint_2d_stroke(void *ps, const float prev_mval[2], const float mval[2], const bool eraser, float pressure, float distance, float base_size)
void * paint_2d_new_stroke(bContext *C, wmOperator *op, int mode)
void paint_2d_redraw(const bContext *C, void *ps, bool final)
void * paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int mode)
void paint_proj_stroke(const bContext *C, void *ps_handle_p, const float prev_pos[2], const float pos[2], const bool eraser, float pressure, float distance, float size)
void paint_proj_redraw(const bContext *C, void *ps_handle_p, bool final)
void paint_proj_stroke_done(void *ps_handle_p)
bool paint_stroke_flipped(struct PaintStroke *stroke)
struct PaintStroke * paint_stroke_new(struct bContext *C, struct wmOperator *op, StrokeGetLocation get_location, StrokeTestStart test_start, StrokeUpdateStep update_step, StrokeRedraw redraw, StrokeDone done, int event_type)
int paint_stroke_modal(struct bContext *C, struct wmOperator *op, const struct wmEvent *event)
bool vertex_paint_poll_ignore_tool(struct bContext *C)
void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data)
int paint_stroke_exec(struct bContext *C, struct wmOperator *op)
void paint_stroke_free(struct bContext *C, struct wmOperator *op)
void * paint_stroke_mode_data(struct PaintStroke *stroke)
bool paint_stroke_inverted(struct PaintStroke *stroke)
void paint_sample_color(struct bContext *C, struct ARegion *region, int x, int y, bool texpaint_proj, bool palette)
void paint_stroke_cancel(struct bContext *C, struct wmOperator *op)
void paint_stroke_operator_properties(struct wmOperatorType *ot)
float paint_stroke_distance_get(struct PaintStroke *stroke)
void RNA_int_set_array(PointerRNA *ptr, const char *name, const int *values)
void RNA_int_get_array(PointerRNA *ptr, const char *name, int *values)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
PropertyRNA * RNA_def_int_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const int *default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
struct ColorBand * gradient
char gradient_stroke_mode
struct ImBuf * mipmap[IMB_MIPMAP_LEVELS]
struct TexPaintSlot * texpaintslot
struct ToolSettings * toolsettings
struct bNodeTree * nodetree
struct UndoStep * step_init
struct bNodeTreeExec * execdata
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
struct wmOperatorType * type
struct UndoStack * undo_stack
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
ccl_device_inline float distance(const float2 &a, const float2 &b)
void WM_cursor_modal_set(wmWindow *win, int val)
void WM_cursor_modal_restore(wmWindow *win)
void WM_redraw_windows(bContext *C)
void WM_paint_cursor_tag_redraw(wmWindow *win, ARegion *UNUSED(region))
int WM_userdef_event_type_from_keymap_type(int kmitype)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_)
bool WM_paint_cursor_end(wmPaintCursor *handle)
wmPaintCursor * WM_paint_cursor_activate(short space_type, short region_type, bool(*poll)(bContext *C), wmPaintCursorDraw draw, void *customdata)
bScreen * WM_window_get_active_screen(const wmWindow *win)