Blender
V3.3
|
Functions to paint images in 2D and 3D. More...
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "DNA_brush_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "BKE_brush.h"
#include "BKE_colorband.h"
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_node.h"
#include "BKE_paint.h"
#include "BKE_undo_system.h"
#include "NOD_texture.h"
#include "DEG_depsgraph.h"
#include "UI_interface.h"
#include "UI_view2d.h"
#include "ED_image.h"
#include "ED_object.h"
#include "ED_paint.h"
#include "ED_screen.h"
#include "ED_view3d.h"
#include "WM_api.h"
#include "WM_message.h"
#include "WM_toolsystem.h"
#include "WM_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "GPU_immediate.h"
#include "GPU_state.h"
#include "IMB_colormanagement.h"
#include "paint_intern.h"
Go to the source code of this file.
Classes | |
struct | GrabClone |
struct | SampleColorData |
Variables | |
static ImagePaintPartialRedraw | imapaintpartial = {{0}} |
Functions to paint images in 2D and 3D.
Definition in file paint_image.cc.
|
static |
Definition at line 904 of file paint_image.cc.
References BKE_paint_brush(), BKE_paint_get_active_from_context(), C, CTX_data_scene(), UnifiedPaintSettings::flag, NA_EDITED, NC_BRUSH, OPERATOR_CANCELLED, OPERATOR_FINISHED, Brush::rgb, UnifiedPaintSettings::rgb, scene, Brush::secondary_rgb, UnifiedPaintSettings::secondary_rgb, swap_v3_v3(), Scene::toolsettings, UNIFIED_PAINT_COLOR, ToolSettings::unified_paint_settings, and WM_event_add_notifier().
Referenced by PAINT_OT_brush_colors_flip().
Definition at line 927 of file paint_image.cc.
References C, CTX_data_active_object(), ED_image_tools_paint_poll(), ELEM, image_paint_brush(), Brush::imagepaint_tool, Object::mode, OB_MODE_SCULPT, OB_MODE_TEXTURE_PAINT, OB_MODE_VERTEX_PAINT, PAINT_TOOL_DRAW, and PAINT_TOOL_FILL.
Referenced by PAINT_OT_brush_colors_flip().
Definition at line 291 of file paint_image.cc.
References C, and image_paint_poll_ex().
Referenced by brush_colors_flip_poll(), ED_space_image_paint_update(), image_listener(), image_paint_2d_clone_poll(), image_texture_paint_poll(), PAINT_OT_image_paint(), blender::ed::sculpt_paint::image::ops::paint::texture_paint_init(), and toggle_paint_cursor().
void ED_imapaint_bucket_fill | ( | struct bContext * | C, |
float | color[3], | ||
wmOperator * | op, | ||
const int | mouse[2] | ||
) |
Definition at line 961 of file paint_image.cc.
References C, color, CTX_wm_space_image(), DEG_id_tag_update(), ED_image_undo_push_begin(), ED_image_undo_push_end(), Image::id, SpaceImage::image, wmOperatorType::name, paint_2d_bucket_fill(), PAINT_MODE_TEXTURE_2D, and wmOperator::type.
Referenced by drop_color_invoke().
Definition at line 91 of file paint_image.cc.
References BLI_rcti_init_minmax(), ImagePaintPartialRedraw::dirty_region, and imapaintpartial.
Referenced by image_flip_exec(), image_invert_exec(), image_scale_exec(), paint_2d_bucket_fill(), paint_2d_gradient_fill(), and paint_2d_redraw().
void ED_imapaint_dirty_region | ( | Image * | ima, |
ImBuf * | ibuf, | ||
ImageUser * | iuser, | ||
int | x, | ||
int | y, | ||
int | w, | ||
int | h, | ||
bool | find_old | ||
) |
Definition at line 109 of file paint_image.cc.
References BKE_image_mark_dirty(), BLI_rcti_do_minmax_rcti(), BLI_rcti_init(), ImagePaintPartialRedraw::dirty_region, ED_image_paint_tile_map_get(), ED_image_paint_tile_push(), imapaint_region_tiles(), imapaintpartial, IMB_freeImBuf(), IMB_rectclip(), w(), x, and y.
Referenced by paint_2d_bucket_fill(), paint_2d_gradient_fill(), and paint_2d_op().
Definition at line 815 of file paint_image.cc.
References C, CTX_data_active_object(), CTX_data_main(), CTX_data_scene(), ED_object_texture_paint_mode_enter_ex(), and scene.
Definition at line 755 of file paint_image.cc.
References Object::actcol, blender::compositor::area(), bScreen::areabase, BKE_image_free_all_gputextures(), BKE_image_paint_set_mipmap(), BKE_mesh_from_object(), BKE_object_material_get(), BKE_paint_init(), BKE_paint_toolslots_brush_validate(), BKE_texpaint_slots_refresh_object(), BLI_assert, ImagePaintSettings::canvas, DEG_id_tag_update(), ED_paint_proj_mesh_data_check(), ED_space_image_set(), ListBase::first, Mesh::id, ID_RECALC_COPY_ON_WRITE, TexPaintSlot::ima, IMAGEPAINT_MODE_IMAGE, IMAGEPAINT_MODE_MATERIAL, ToolSettings::imapaint, LISTBASE_FOREACH, Object::mode, ImagePaintSettings::mode, NC_SCENE, ND_MODE, OB_MODE_TEXTURE_PAINT, ImagePaintSettings::paint, Material::paint_active_slot, PAINT_CURSOR_TEXTURE_PAINT, PAINT_MODE_TEXTURE_3D, SpaceImage::pin, scene, SPACE_IMAGE, SpaceLink::spacetype, Material::texpaintslot, toggle_paint_cursor(), Scene::toolsettings, wmWindowManager::windows, Main::wm, WM_main_add_notifier(), and WM_window_get_active_screen().
Referenced by ED_object_texture_paint_mode_enter(), and texture_paint_toggle_exec().
Definition at line 839 of file paint_image.cc.
References C, CTX_data_active_object(), CTX_data_main(), CTX_data_scene(), ED_object_texture_paint_mode_exit_ex(), and scene.
Definition at line 823 of file paint_image.cc.
References BKE_image_free_all_gputextures(), BKE_image_paint_set_mipmap(), BKE_mesh_from_object(), BLI_assert, DEG_id_tag_update(), Mesh::id, ID_RECALC_COPY_ON_WRITE, Object::mode, NC_SCENE, ND_MODE, OB_MODE_TEXTURE_PAINT, scene, toggle_paint_cursor(), and WM_main_add_notifier().
Referenced by ed_object_mode_generic_exit_ex(), ED_object_texture_paint_mode_exit(), and texture_paint_toggle_exec().
void ED_space_image_paint_update | ( | struct Main * | bmain, |
struct wmWindowManager * | wm, | ||
struct Scene * | scene | ||
) |
Enable the paint cursor if it isn't already.
purpose is to make sure the paint cursor is shown if paint mode is enabled in the image editor. The paint poll will ensure that the cursor is hidden when not in paint mode.
Definition at line 438 of file paint_image.cc.
References blender::compositor::area(), bScreen::areabase, BKE_paint_init(), ED_image_tools_paint_poll(), ED_paint_cursor_start(), enabled, ToolSettings::imapaint, LISTBASE_FOREACH, ImagePaintSettings::paint, paint_cursor_delete_textures(), PAINT_CURSOR_TEXTURE_PAINT, PAINT_MODE_TEXTURE_2D, scene, SI_MODE_PAINT, SPACE_IMAGE, Scene::toolsettings, wmWindowManager::windows, and WM_window_get_active_screen().
Referenced by ED_editors_init().
Definition at line 998 of file paint_image.cc.
References BKE_paint_select_face_test(), C, and CTX_data_active_object().
Referenced by ED_keymap_paint(), PAINT_OT_face_select_all(), PAINT_OT_face_select_hide(), PAINT_OT_face_select_linked(), and PAINT_OT_face_select_linked_pick().
Definition at line 404 of file paint_image.cc.
References blender::compositor::area(), C, CTX_wm_area(), CTX_wm_region(), ED_space_image_get_zoom(), SpaceImage::mode, SI_MODE_PAINT, and SPACE_IMAGE.
Referenced by paint_cursor_context_init(), and paint_stroke_new().
ImagePaintPartialRedraw* get_imapaintpartial | ( | void | ) |
Definition at line 79 of file paint_image.cc.
References imapaintpartial.
|
static |
Definition at line 473 of file paint_image.cc.
References add_v2_v2(), C, Brush::clone, CTX_wm_region(), ED_region_tag_redraw(), image_paint_brush(), BrushClone::offset, wmOperator::ptr, and RNA_float_get_array().
Referenced by grab_clone_exec(), and grab_clone_modal().
|
static |
Definition at line 539 of file paint_image.cc.
References wmOperator::customdata.
Referenced by PAINT_OT_grab_clone().
|
static |
Definition at line 483 of file paint_image.cc.
References C, grab_clone_apply(), and OPERATOR_FINISHED.
Referenced by PAINT_OT_grab_clone().
|
static |
Definition at line 490 of file paint_image.cc.
References C, Brush::clone, copy_v2_v2(), wmOperator::customdata, image_paint_brush(), BrushClone::offset, OPERATOR_RUNNING_MODAL, GrabClone::startoffset, GrabClone::startx, GrabClone::starty, and WM_event_add_modal_handler().
Referenced by PAINT_OT_grab_clone().
|
static |
Definition at line 506 of file paint_image.cc.
References C, Brush::clone, copy_v2_v2(), CTX_wm_region(), wmOperator::customdata, grab_clone_apply(), image_paint_brush(), LEFTMOUSE, MEM_freeN, MIDDLEMOUSE, MOUSEMOVE, BrushClone::offset, OPERATOR_FINISHED, OPERATOR_RUNNING_MODAL, wmOperator::ptr, RIGHTMOUSE, RNA_float_set_array(), GrabClone::startoffset, GrabClone::startx, GrabClone::starty, wmEvent::type, UI_view2d_region_to_view(), ARegion::v2d, ARegion::winrct, rcti::xmin, wmEvent::xy, and rcti::ymin.
Referenced by PAINT_OT_grab_clone().
Definition at line 301 of file paint_image.cc.
References C, Brush::clone, CTX_wm_region_view3d(), ED_image_tools_paint_poll(), BrushClone::image, image_paint_brush(), Brush::imagepaint_tool, and PAINT_TOOL_CLONE.
Referenced by PAINT_OT_grab_clone().
Definition at line 249 of file paint_image.cc.
References BKE_paint_brush(), C, CTX_data_scene(), ToolSettings::imapaint, ImagePaintSettings::paint, scene, and Scene::toolsettings.
Referenced by brush_colors_flip_poll(), grab_clone_apply(), grab_clone_invoke(), grab_clone_modal(), image_paint_2d_clone_poll(), and image_paint_poll_ex().
Definition at line 257 of file paint_image.cc.
References C, CTX_data_active_object(), CTX_wm_region(), CTX_wm_region_view3d(), CTX_wm_space_image(), ID_IS_LINKED, ID_IS_OVERRIDE_LIBRARY, SpaceImage::image, image_paint_brush(), Object::mode, SpaceImage::mode, OB_MODE_TEXTURE_PAINT, ARegion::regiontype, RGN_TYPE_WINDOW, SI_MODE_PAINT, and WM_toolsystem_active_tool_is_brush().
Referenced by ED_image_tools_paint_poll(), and image_paint_poll_ignore_tool().
Definition at line 296 of file paint_image.cc.
References C, and image_paint_poll_ex().
Referenced by sample_color_poll().
Definition at line 993 of file paint_image.cc.
References C, ED_image_tools_paint_poll(), and texture_paint_poll().
Referenced by ED_keymap_paint().
void imapaint_image_update | ( | SpaceImage * | sima, |
Image * | image, | ||
ImBuf * | ibuf, | ||
ImageUser * | iuser, | ||
short | texpaint | ||
) |
Definition at line 144 of file paint_image.cc.
References BKE_image_update_gputexture(), BLI_rcti_is_empty(), BLI_rcti_size_x(), BLI_rcti_size_y(), ImagePaintPartialRedraw::dirty_region, IB_MIPMAP_INVALID, image(), imapaintpartial, IMB_partial_display_buffer_update_delayed(), SpaceImage::lock, ImBuf::mipmap, ImBuf::userflags, w(), rcti::xmax, rcti::xmin, rcti::ymax, and rcti::ymin.
Referenced by paint_2d_bucket_fill(), paint_2d_gradient_fill(), paint_2d_redraw(), and project_image_refresh_tagged().
void imapaint_region_tiles | ( | ImBuf * | ibuf, |
int | x, | ||
int | y, | ||
int | w, | ||
int | h, | ||
int * | tx, | ||
int * | ty, | ||
int * | tw, | ||
int * | th | ||
) |
Definition at line 96 of file paint_image.cc.
References ED_IMAGE_UNDO_TILE_BITS, IMB_rectclip(), w(), x, and y.
Referenced by ED_imapaint_dirty_region(), and paint_2d_op().
Definition at line 1008 of file paint_image.cc.
References BKE_paint_select_elem_test(), C, and CTX_data_active_object().
Referenced by PAINT_OT_weight_set().
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 | ||
) |
Definition at line 332 of file paint_image.cc.
References BKE_brush_color_get(), BKE_brush_secondary_color_get(), BKE_colorband_evaluate(), BRUSH_GRADIENT_PRESSURE, BRUSH_GRADIENT_SPACING_CLAMP, BRUSH_GRADIENT_SPACING_REPEAT, BRUSH_USE_GRADIENT, color, copy_v3_v3(), blender::math::distance(), Brush::flag, Brush::gradient, Brush::gradient_spacing, Brush::gradient_stroke_mode, IMB_colormanagement_display_to_scene_linear_v3(), IMB_colormanagement_scene_linear_to_srgb_v3(), invert(), and scene.
Referenced by brush_painter_imbuf_new(), brush_painter_imbuf_update(), and paint_proj_stroke_ps().
Definition at line 390 of file paint_image.cc.
References bNodeTree::execdata, Brush::mask_mtex, Brush::mtex, Tex::nodetree, ntreeTexEndExecTree(), and MTex::tex.
Referenced by paint_2d_stroke_done(), and paint_proj_stroke_done().
Definition at line 374 of file paint_image.cc.
References Brush::mask_mtex, Brush::mtex, Tex::nodetree, ntreeTexBeginExecTree(), and MTex::tex.
Referenced by paint_2d_new_stroke(), and paint_proj_new_stroke().
void paint_delete_blur_kernel | ( | BlurKernel * | kernel | ) |
Definition at line 240 of file paint_image.cc.
References kernel, and MEM_freeN.
Referenced by paint_2d_canvas_free(), paint_new_blur_kernel(), and project_paint_end().
BlurKernel* paint_new_blur_kernel | ( | struct Brush * | br, |
bool | proj | ||
) |
Paint blur kernels. Projective painting enforces use of a 2x2 kernel due to lagging. Can be extended to other blur kernels later,
Definition at line 171 of file paint_image.cc.
References Brush::blur_kernel_radius, Brush::blur_mode, exp(), kernel, KERNEL_BOX, KERNEL_GAUSSIAN, MEM_mallocN, paint_delete_blur_kernel(), and type.
Referenced by paint_2d_new_stroke(), and project_state_init().
void PAINT_OT_brush_colors_flip | ( | wmOperatorType * | ot | ) |
Definition at line 946 of file paint_image.cc.
References brush_colors_flip_exec(), brush_colors_flip_poll(), wmOperatorType::description, wmOperatorType::exec, wmOperatorType::flag, wmOperatorType::idname, wmOperatorType::name, OPTYPE_REGISTER, ot, and wmOperatorType::poll.
Referenced by ED_operatortypes_paint().
void PAINT_OT_grab_clone | ( | wmOperatorType * | ot | ) |
Definition at line 545 of file paint_image.cc.
References wmOperatorType::cancel, wmOperatorType::description, wmOperatorType::exec, wmOperatorType::flag, grab_clone_cancel(), grab_clone_exec(), grab_clone_invoke(), grab_clone_modal(), wmOperatorType::idname, image_paint_2d_clone_poll(), wmOperatorType::invoke, wmOperatorType::modal, wmOperatorType::name, OPTYPE_BLOCKING, OPTYPE_REGISTER, OPTYPE_UNDO, ot, wmOperatorType::poll, RNA_def_float_vector(), and wmOperatorType::srna.
Referenced by ED_operatortypes_paint().
void PAINT_OT_sample_color | ( | wmOperatorType * | ot | ) |
Definition at line 726 of file paint_image.cc.
References wmOperatorType::description, wmOperatorType::exec, wmOperatorType::flag, wmOperatorType::idname, wmOperatorType::invoke, wmOperatorType::modal, wmOperatorType::name, OPTYPE_REGISTER, ot, wmOperatorType::poll, PROP_HIDDEN, PROP_SKIP_SAVE, RNA_def_boolean(), RNA_def_int_vector(), RNA_def_property_flag(), sample_color_exec(), sample_color_invoke(), sample_color_modal(), sample_color_poll(), and wmOperatorType::srna.
Referenced by ED_operatortypes_paint().
void PAINT_OT_texture_paint_toggle | ( | wmOperatorType * | ot | ) |
Definition at line 889 of file paint_image.cc.
References wmOperatorType::description, wmOperatorType::exec, wmOperatorType::flag, wmOperatorType::idname, wmOperatorType::name, OPTYPE_REGISTER, OPTYPE_UNDO, ot, wmOperatorType::poll, texture_paint_toggle_exec(), and texture_paint_toggle_poll().
Referenced by ED_operatortypes_paint().
Definition at line 317 of file paint_image.cc.
References BRUSH_AIRBRUSH, BRUSH_ANCHORED, BRUSH_DRAG_DOT, MTex::brush_map_mode, BRUSH_USE_GRADIENT, ELEM, Brush::flag, Brush::imagepaint_tool, Brush::mtex, MTEX_MAP_MODE_3D, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_TILED, PAINT_TOOL_FILL, PAINT_TOOL_SMEAR, PAINT_TOOL_SOFTEN, and MTex::tex.
Referenced by paint_2d_canvas_set(), and project_state_init().
|
static |
Definition at line 599 of file paint_image.cc.
References BKE_paint_brush(), BKE_paint_get_active_from_context(), BKE_paintmode_get_active_from_context(), C, CTX_wm_region(), CTX_wm_window(), Paint::flags, NA_EDITED, NC_BRUSH, OPERATOR_FINISHED, PAINT_MODE_TEXTURE_3D, paint_sample_color(), PAINT_SHOW_BRUSH, wmOperator::ptr, RNA_boolean_get(), RNA_int_get_array(), WM_event_add_notifier(), WM_paint_cursor_tag_redraw(), and WM_redraw_windows().
Referenced by PAINT_OT_sample_color().
|
static |
Definition at line 630 of file paint_image.cc.
References BKE_brush_color_get(), BKE_paint_brush(), BKE_paint_get_active_from_context(), BKE_paintmode_get_active_from_context(), C, copy_v3_v3(), CTX_data_scene(), CTX_wm_region(), CTX_wm_window(), wmOperator::customdata, data, Paint::flags, wmEvent::mval, NA_EDITED, NC_BRUSH, OPERATOR_RUNNING_MODAL, PAINT_MODE_TEXTURE_3D, paint_sample_color(), PAINT_SHOW_BRUSH, wmOperator::ptr, RNA_boolean_get(), RNA_int_set_array(), sample_color_update_header(), scene, wmEvent::type, WM_CURSOR_EYEDROPPER, WM_cursor_modal_set(), WM_event_add_modal_handler(), WM_event_add_notifier(), WM_paint_cursor_tag_redraw(), WM_redraw_windows(), and WM_userdef_event_type_from_keymap_type().
Referenced by PAINT_OT_sample_color().
|
static |
Definition at line 668 of file paint_image.cc.
References BKE_brush_color_set(), BKE_paint_brush(), BKE_paint_get_active_from_context(), BKE_paintmode_get_active_from_context(), C, CTX_data_scene(), CTX_wm_region(), CTX_wm_window(), wmOperator::customdata, data, ED_workspace_status_text(), Paint::flags, KM_PRESS, KM_RELEASE, LEFTMOUSE, MOUSEMOVE, wmEvent::mval, NA_EDITED, NC_BRUSH, OPERATOR_FINISHED, OPERATOR_RUNNING_MODAL, PAINT_MODE_TEXTURE_3D, paint_sample_color(), PAINT_SHOW_BRUSH, wmOperator::ptr, RNA_boolean_get(), RNA_boolean_set(), RNA_int_set_array(), sample_color_update_header(), scene, wmEvent::type, wmEvent::val, WM_cursor_modal_restore(), and WM_event_add_notifier().
Referenced by PAINT_OT_sample_color().
Definition at line 721 of file paint_image.cc.
References C, image_paint_poll_ignore_tool(), and vertex_paint_poll_ignore_tool().
Referenced by PAINT_OT_sample_color().
|
static |
Definition at line 583 of file paint_image.cc.
References blender::compositor::area(), BLI_snprintf(), C, CTX_wm_area(), data, ED_workspace_status_text(), TIP_, and UI_MAX_DRAW_STR.
Referenced by sample_color_invoke(), and sample_color_modal().
void set_imapaintpartial | ( | struct ImagePaintPartialRedraw * | ippr | ) |
Definition at line 84 of file paint_image.cc.
References imapaintpartial.
Referenced by project_image_refresh_tagged().
Definition at line 982 of file paint_image.cc.
References C, CTX_data_active_object(), OB_MODE_TEXTURE_PAINT, and texture_paint_toggle_poll().
Referenced by image_texture_paint_poll().
|
static |
Definition at line 860 of file paint_image.cc.
References C, CTX_data_active_object(), CTX_data_main(), CTX_data_scene(), CTX_wm_message_bus(), ED_object_mode_compat_set(), ED_object_texture_paint_mode_enter_ex(), ED_object_texture_paint_mode_exit_ex(), Object::id, Object::mode, OB_MODE_TEXTURE_PAINT, OPERATOR_CANCELLED, OPERATOR_FINISHED, wmOperator::reports, scene, WM_msg_publish_rna_prop, and WM_toolsystem_update_from_context_view3d().
Referenced by PAINT_OT_texture_paint_toggle().
Definition at line 847 of file paint_image.cc.
References C, CTX_data_active_object(), Object::data, ID_IS_LINKED, ID_IS_OVERRIDE_LIBRARY, OB_MESH, and Object::type.
Referenced by PAINT_OT_texture_paint_toggle(), and texture_paint_poll().
Definition at line 423 of file paint_image.cc.
References ED_image_tools_paint_poll(), ED_paint_cursor_start(), ToolSettings::imapaint, ImagePaintSettings::paint, Paint::paint_cursor, paint_cursor_delete_textures(), scene, Scene::toolsettings, and WM_paint_cursor_end().
Referenced by ED_object_texture_paint_mode_enter_ex(), and ED_object_texture_paint_mode_exit_ex().
Definition at line 1003 of file paint_image.cc.
References BKE_paint_select_vert_test(), C, and CTX_data_active_object().
Referenced by ED_keymap_paint(), PAINT_OT_vert_select_all(), PAINT_OT_vert_select_hide(), and PAINT_OT_vert_select_ungrouped().
|
static |
This is a static resource for non-global access. Maybe it should be exposed as part of the paint operation, but for now just give a public interface.
Definition at line 77 of file paint_image.cc.
Referenced by ED_imapaint_clear_partial_redraw(), ED_imapaint_dirty_region(), get_imapaintpartial(), imapaint_image_update(), and set_imapaintpartial().