102 ImBuf *ibuf,
int x,
int y,
int w,
int h,
int *tx,
int *ty,
int *tw,
int *th)
104 int srcx = 0, srcy = 0;
117 ImBuf *tmpibuf =
nullptr;
118 int tilex, tiley, tilew, tileh, tx, ty;
119 int srcx = 0, srcy = 0;
123 if (
w == 0 || h == 0) {
135 for (ty = tiley; ty <= tileh; ty++) {
136 for (tx = tilex; tx <= tilew; tx++) {
138 undo_tiles, ima, ibuf, &tmpibuf, iuser, tx, ty,
nullptr,
nullptr,
false, find_old);
170 if (ibuf !=
nullptr && ibuf->
planes == 8) {
177 if (texpaint || (sima && sima->
lock)) {
195 BlurKernel *kernel = MEM_new<BlurKernel>(
"BlurKernel");
204 side = kernel->
side = 2;
206 kernel->
wdata =
static_cast<float *
>(
217 side = kernel->
side = radius * 2 + 1;
219 kernel->
wdata =
static_cast<float *
>(
227 kernel->
wdata[i] = 1.0;
233 float standard_dev = radius / 3.0f;
236 standard_dev = -standard_dev * standard_dev * 2;
238 for (i = 0; i < side; i++) {
239 for (j = 0; j < side; j++) {
240 float idist = radius - i;
241 float jdist = radius - j;
242 float value =
exp((idist * idist + jdist * jdist) / standard_dev);
244 kernel->
wdata[i + j * side] = value;
252 printf(
"unidentified kernel type, aborting\n");
300 if (sima->
image !=
nullptr &&
368 bool color_correction,
403 if (color_correction) {
538 cmv = MEM_cnew<GrabClone>(
"GrabClone");
540 cmv->
startx =
event->xy[0];
541 cmv->
starty =
event->xy[1];
554 float startfx, startfy, fx, fy, delta[2];
557 switch (event->
type) {
566 ®ion->
v2d, cmv->
startx - xmin, cmv->
starty - ymin, &startfx, &startfy);
569 delta[0] = fx - startfx;
570 delta[1] = fy - startfy;
592 ot->name =
"Grab Clone";
593 ot->idname =
"PAINT_OT_grab_clone";
594 ot->description =
"Move the clone source image";
614 "Delta offset of clone image in 0.0 to 1.0 coordinates",
639 IFACE_(
"Sample color for %s"),
640 !
data->sample_palette ?
641 IFACE_(
"Brush. Use Left Click to sample for palette instead") :
642 IFACE_(
"Palette. Use Left Click to sample more colors"));
690 data->sample_palette =
false;
724 if (
data->show_cursor) {
728 if (
data->sample_palette) {
743 switch (event->
type) {
757 if (!
data->sample_palette) {
758 data->sample_palette =
true;
778 ot->name =
"Sample Color";
779 ot->idname =
"PAINT_OT_sample_color";
780 ot->description =
"Use the mouse to sample a color in the image";
795 ot->srna,
"location", 2,
nullptr, 0, INT_MAX,
"Location",
"", 0, 16384);
798 RNA_def_boolean(
ot->srna,
"merged",
false,
"Sample Merged",
"Sample the output display color");
816 const std::optional<Bounds<float3>>
bounds = mesh_eval->bounds_min_max();
827 const std::optional<blender::Bounds<blender::float3>>
bounds =
828 curves.
geometry.wrap().bounds_min_max();
839 const std::optional<Bounds<float3>>
bounds = grease_pencil.bounds_min_max(frame);
867 mul_m4_v3(ob->object_to_world().ptr(), location);
879 Image *ima =
nullptr;
911 if (
U.glreslimit != 0) {
946 if (
U.glreslimit != 0) {
987 const bool is_mode_set = (ob.
mode & mode_flag) != 0;
995 if (ob.
mode & mode_flag) {
1013 ot->name =
"Texture Paint Toggle";
1014 ot->idname =
"PAINT_OT_texture_paint_toggle";
1015 ot->description =
"Toggle texture paint mode in 3D view";
1065 if (ob !=
nullptr) {
1082 ot->name =
"Swap Colors";
1083 ot->idname =
"PAINT_OT_brush_colors_flip";
1084 ot->description =
"Swap primary and secondary brush colors";
1104 if (sima && sima->
image) {
1109 const float mouse_init[2] = {
float(mouse[0]),
float(mouse[1])};
const float * BKE_brush_secondary_color_get(const Scene *scene, const Paint *paint, const Brush *brush)
void BKE_brush_color_set(Scene *scene, const Paint *paint, Brush *brush, const float color[3])
const float * BKE_brush_color_get(const Scene *scene, const Paint *paint, const Brush *brush)
void BKE_brush_tag_unsaved_changes(Brush *brush)
bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
SpaceImage * CTX_wm_space_image(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
wmMsgBus * CTX_wm_message_bus(const bContext *C)
Low-level operations for curves.
Low-level operations for grease pencil.
void BKE_image_update_gputexture(Image *ima, ImageUser *iuser, int x, int y, int w, int h)
void BKE_image_mark_dirty(Image *image, ImBuf *ibuf)
void BKE_image_paint_set_mipmap(Main *bmain, bool mipmap)
void BKE_image_free_all_gputextures(Main *bmain)
void BKE_image_partial_update_mark_full_update(Image *image)
Mark the whole image to be updated.
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)
Mesh * BKE_mesh_from_object(Object *ob)
General operations, lookup, etc. for blender objects.
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
bool BKE_paint_use_unified_color(const ToolSettings *tool_settings, const Paint *paint)
bool BKE_paint_select_elem_test(const Object *ob)
bool BKE_paint_select_vert_test(const Object *ob)
void BKE_paint_init(Main *bmain, Scene *sce, PaintMode mode, const uchar col[3], bool ensure_brushes=true)
Paint * BKE_paint_get_active_from_context(const bContext *C)
const uchar PAINT_CURSOR_TEXTURE_PAINT[3]
Brush * BKE_paint_brush(Paint *paint)
PaintMode BKE_paintmode_get_active_from_context(const bContext *C)
bool BKE_paint_select_face_test(const Object *ob)
void BKE_paint_brushes_validate(Main *bmain, Paint *paint)
void BKE_scene_graph_evaluated_ensure(Depsgraph *depsgraph, Main *bmain)
#define BLI_assert_unreachable()
#define LISTBASE_FOREACH(type, var, list)
void mul_m4_v3(const float M[4][4], float r[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])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void BLI_rcti_init_minmax(struct rcti *rect)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
bool BLI_rcti_is_empty(const struct rcti *rect)
void BLI_rcti_do_minmax_rcti(struct rcti *rect, const struct rcti *other)
#define SNPRINTF(dst, format,...)
void DEG_id_tag_update(ID *id, unsigned int flags)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
@ IMAGE_PAINT_BRUSH_TYPE_FILL
@ IMAGE_PAINT_BRUSH_TYPE_DRAW
@ IMAGE_PAINT_BRUSH_TYPE_CLONE
@ IMAGE_PAINT_BRUSH_TYPE_SOFTEN
@ IMAGE_PAINT_BRUSH_TYPE_SMEAR
@ BRUSH_GRADIENT_SPACING_CLAMP
@ BRUSH_GRADIENT_PRESSURE
@ BRUSH_GRADIENT_SPACING_REPEAT
Object is a sort of wrapper for general info.
#define IMAGEPAINT_MODE_IMAGE
#define IMAGEPAINT_MODE_MATERIAL
void ED_space_image_sync(Main *bmain, Image *image, bool ignore_render_viewer)
bool ED_image_tools_paint_poll(bContext *C)
void ED_space_image_get_zoom(SpaceImage *sima, const ARegion *region, float *r_zoomx, float *r_zoomy)
void ED_paint_cursor_start(Paint *paint, bool(*poll)(bContext *C))
void * ED_image_paint_tile_push(PaintTileMap *paint_tile_map, Image *image, ImBuf *ibuf, ImBuf **tmpibuf, ImageUser *iuser, int x_tile, int y_tile, unsigned short **r_mask, bool **r_valid, bool use_thread_lock, bool find_prev)
void ED_image_undo_push_begin(const char *name, PaintMode paint_mode)
void ED_image_undo_push_end()
PaintTileMap * ED_image_paint_tile_map_get()
bool ED_paint_proj_mesh_data_check(Scene &scene, Object &ob, bool *r_has_uvs, bool *r_has_mat, bool *r_has_tex, bool *r_has_stencil)
#define ED_IMAGE_UNDO_TILE_BITS
void ED_workspace_status_text(bContext *C, const char *str)
void ED_region_tag_redraw(ARegion *region)
void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], ColorManagedDisplay *display)
void IMB_partial_display_buffer_update_delayed(ImBuf *ibuf, int xmin, int ymin, int xmax, int ymax)
BLI_INLINE void IMB_colormanagement_scene_linear_to_srgb_v3(float srgb[3], const float scene_linear[3])
void IMB_rectclip(ImBuf *dbuf, const ImBuf *sbuf, int *destx, int *desty, int *srcx, int *srcy, int *width, int *height)
Contains defines and structs used throughout the imbuf module.
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
void ntreeTexEndExecTree(struct bNodeTreeExec *exec)
struct bNodeTreeExec * ntreeTexBeginExecTree(struct bNodeTree *ntree)
void UI_view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
@ OPTYPE_DEPENDS_ON_CURSOR
BPy_StructRNA * depsgraph
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
VecBase< float, 3 > float3
input_tx image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "preview_img") .compute_source("compositor_compute_preview.glsl") .do_static_compilation(true)
draw_view in_light_buf[] float
void IMB_freeImBuf(ImBuf *)
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
ccl_device_inline float2 fmod(const float2 a, const float b)
ccl_device_inline float3 exp(float3 v)
bool grease_pencil_vertex_painting_poll(bContext *C)
bool grease_pencil_painting_poll(bContext *C)
bool mode_compat_set(bContext *C, Object *ob, eObjectMode mode, ReportList *reports)
T midpoint(const T &a, const T &b)
VecBase< float, 3 > float3
float distance(float a, float b)
void paint_cursor_delete_textures()
void paint_delete_blur_kernel(BlurKernel *kernel)
void ED_object_texture_paint_mode_enter_ex(Main &bmain, Scene &scene, Depsgraph &depsgraph, Object &ob)
static bool image_paint_2d_clone_poll(bContext *C)
bool ED_image_tools_paint_poll(bContext *C)
static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
static Brush * image_paint_brush(bContext *C)
static bool image_paint_poll_ex(bContext *C, bool check_tool)
void paint_init_pivot(Object *ob, Scene *scene)
static bool texture_paint_poll(bContext *C)
bool vert_paint_poll(bContext *C)
static void grab_clone_cancel(bContext *, wmOperator *op)
static int grab_clone_exec(bContext *C, wmOperator *op)
static blender::float3 paint_init_pivot_mesh(Object *ob)
void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, ImageUser *iuser, short texpaint)
void ED_imapaint_bucket_fill(bContext *C, float const color[3], wmOperator *op, const int mouse[2])
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)
static int sample_color_exec(bContext *C, wmOperator *op)
static blender::float3 paint_init_pivot_grease_pencil(Object *ob, const int frame)
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 PAINT_OT_sample_color(wmOperatorType *ot)
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)
BlurKernel * paint_new_blur_kernel(Brush *br, bool proj)
static blender::float3 paint_init_pivot_curves(Object *ob)
bool paint_use_opacity_masking(Brush *brush)
static int grab_clone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void ED_object_texture_paint_mode_enter(bContext *C)
static void grab_clone_apply(bContext *C, wmOperator *op)
static int brush_colors_flip_exec(bContext *C, wmOperator *)
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)
void PAINT_OT_grab_clone(wmOperatorType *ot)
void paint_brush_color_get(Scene *scene, const Paint *paint, Brush *br, bool color_correction, bool invert, float distance, float pressure, ColorManagedDisplay *display, float r_color[3])
void paint_brush_exit_tex(Brush *brush)
static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
void ED_object_texture_paint_mode_exit_ex(Main &bmain, Scene &scene, Object &ob)
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 void toggle_paint_cursor(Scene &scene, bool enable)
static bool image_paint_poll_ignore_tool(bContext *C)
static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void set_imapaintpartial(ImagePaintPartialRedraw *ippr)
void ED_imapaint_clear_partial_redraw()
ImagePaintPartialRedraw * get_imapaintpartial()
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)
bool vertex_paint_poll_ignore_tool(bContext *C)
void paint_sample_color(bContext *C, ARegion *region, int x, int y, bool texpaint_proj, bool palette)
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)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
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_float_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, 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_int_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
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)
struct ColorBand * gradient
char gradient_stroke_mode
ImBuf * mipmap[IMB_MIPMAP_LEVELS]
struct TexPaintSlot * texpaintslot
struct ToolSettings * toolsettings
struct bNodeTree * nodetree
float average_stroke_accum[3]
int average_stroke_counter
bNodeTreeRuntimeHandle * runtime
struct ReportList * reports
struct wmOperatorType * type
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 *)
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)
#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_)
bool WM_paint_cursor_end(wmPaintCursor *handle)
bScreen * WM_window_get_active_screen(const wmWindow *win)