|
Blender V5.0
|
Functions to paint images in 2D and 3D. More...
#include <cfloat>#include <cmath>#include <cstdio>#include <cstring>#include "MEM_guardedalloc.h"#include "BLI_listbase.h"#include "BLI_math_color.h"#include "BLI_math_vector.hh"#include "BLI_rand.hh"#include "BLI_string.h"#include "BLI_utildefines.h"#include "IMB_imbuf.hh"#include "IMB_imbuf_types.hh"#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 "DNA_scene_types.h"#include "BKE_brush.hh"#include "BKE_colorband.hh"#include "BKE_context.hh"#include "BKE_curves.hh"#include "BKE_grease_pencil.hh"#include "BKE_image.hh"#include "BKE_library.hh"#include "BKE_main.hh"#include "BKE_material.hh"#include "BKE_mesh.hh"#include "BKE_node_runtime.hh"#include "BKE_object.hh"#include "BKE_paint.hh"#include "BKE_paint_types.hh"#include "BKE_scene.hh"#include "NOD_texture.h"#include "DEG_depsgraph.hh"#include "DEG_depsgraph_query.hh"#include "UI_view2d.hh"#include "ED_grease_pencil.hh"#include "ED_image.hh"#include "ED_object.hh"#include "ED_paint.hh"#include "ED_screen.hh"#include "WM_api.hh"#include "WM_message.hh"#include "WM_toolsystem.hh"#include "WM_types.hh"#include "RNA_access.hh"#include "RNA_define.hh"#include "IMB_colormanagement.hh"#include "paint_intern.hh"Go to the source code of this file.
Classes | |
| struct | GrabClone |
Image Paint Tile Utilities (Partial Update) | |
| static ImagePaintPartialRedraw | imapaintpartial = {{0}} |
| ImagePaintPartialRedraw * | get_imapaintpartial () |
| void | set_imapaintpartial (ImagePaintPartialRedraw *ippr) |
| void | ED_imapaint_clear_partial_redraw () |
| void | imapaint_region_tiles (ImBuf *ibuf, int x, int y, int w, int h, int *tx, int *ty, int *tw, int *th) |
| void | ED_imapaint_dirty_region (Image *ima, ImBuf *ibuf, ImageUser *iuser, int x, int y, int w, int h, bool find_old) |
| void | imapaint_image_update (SpaceImage *sima, Image *image, ImBuf *ibuf, ImageUser *iuser, short texpaint) |
Functions to paint images in 2D and 3D.
Definition in file paint_image.cc.
|
static |
Definition at line 861 of file paint_image.cc.
References BKE_brush_color_sync_legacy(), BKE_brush_tag_unsaved_changes(), BKE_paint_brush(), BKE_paint_get_active_from_context(), BKE_paint_use_unified_color(), C, Brush::color, UnifiedPaintSettings::color, NA_EDITED, NC_BRUSH, OPERATOR_CANCELLED, OPERATOR_FINISHED, Brush::secondary_color, UnifiedPaintSettings::secondary_color, swap_v3_v3(), Paint::unified_paint_settings, and WM_event_add_notifier().
Referenced by PAINT_OT_brush_colors_flip().
|
static |
Definition at line 885 of file paint_image.cc.
References C, CTX_data_active_object(), ED_image_tools_paint_poll(), ELEM, blender::ed::greasepencil::grease_pencil_painting_poll(), blender::ed::greasepencil::grease_pencil_vertex_painting_poll(), Brush::image_brush_type, image_paint_brush(), IMAGE_PAINT_BRUSH_TYPE_DRAW, IMAGE_PAINT_BRUSH_TYPE_FILL, Object::mode, OB_MODE_SCULPT, OB_MODE_TEXTURE_PAINT, and OB_MODE_VERTEX_PAINT.
Referenced by PAINT_OT_brush_colors_flip().
| bool ED_image_tools_paint_poll | ( | bContext * | C | ) |
Definition at line 313 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 | ( | bContext * | C, |
| float const | color[3], | ||
| wmOperator * | op, | ||
| const int | mouse[2] ) |
Definition at line 930 of file paint_image.cc.
References C, CTX_wm_space_image(), DEG_id_tag_update(), ED_image_undo_push_begin(), ED_image_undo_push_end(), float, Image::id, SpaceImage::image, wmOperatorType::name, paint_2d_bucket_fill(), Texture2D, and wmOperator::type.
Referenced by drop_color_invoke().
| void ED_imapaint_clear_partial_redraw | ( | ) |
Definition at line 98 of file paint_image.cc.
References BLI_rcti_init_minmax(), and imapaintpartial.
Referenced by image_flip_exec(), image_invert_exec(), image_rotate_orthogonal_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 116 of file paint_image.cc.
References BKE_image_mark_dirty(), BLI_rcti_do_minmax_rcti(), BLI_rcti_init(), 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().
| void ED_object_texture_paint_mode_enter | ( | bContext * | C | ) |
Definition at line 762 of file paint_image.cc.
References C, CTX_data_active_object(), CTX_data_depsgraph_pointer(), CTX_data_main(), CTX_data_scene(), depsgraph, and ED_object_texture_paint_mode_enter_ex().
| void ED_object_texture_paint_mode_enter_ex | ( | Main & | bmain, |
| Scene & | scene, | ||
| Depsgraph & | depsgraph, | ||
| Object & | ob ) |
Definition at line 704 of file paint_image.cc.
References Object::actcol, BKE_image_free_all_gputextures(), BKE_image_paint_set_mipmap(), BKE_mesh_from_object(), BKE_object_material_get(), BKE_paint_brushes_validate(), BKE_paint_init(), BKE_scene_graph_evaluated_ensure(), BKE_texpaint_slots_refresh_object(), BLI_assert, ImagePaintSettings::canvas, DEG_get_evaluated(), DEG_id_tag_update(), depsgraph, ED_paint_proj_mesh_data_check(), ED_space_image_sync(), Mesh::id, ID_RECALC_SYNC_TO_EVAL, TexPaintSlot::ima, IMAGEPAINT_MODE_IMAGE, IMAGEPAINT_MODE_MATERIAL, ToolSettings::imapaint, ImagePaintSettings::mode, Object::mode, NC_SCENE, ND_MODE, OB_MODE_TEXTURE_PAINT, ImagePaintSettings::paint, Material::paint_active_slot, paint_init_pivot(), Material::texpaintslot, Texture3D, toggle_paint_cursor(), Scene::toolsettings, U, and WM_main_add_notifier().
Referenced by ED_object_texture_paint_mode_enter(), and texture_paint_toggle_exec().
| void ED_object_texture_paint_mode_exit | ( | bContext * | C | ) |
Definition at line 788 of file paint_image.cc.
References C, CTX_data_active_object(), CTX_data_main(), CTX_data_scene(), and ED_object_texture_paint_mode_exit_ex().
Definition at line 772 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_SYNC_TO_EVAL, Object::mode, NC_SCENE, ND_MODE, OB_MODE_TEXTURE_PAINT, toggle_paint_cursor(), U, and WM_main_add_notifier().
Referenced by blender::ed::object::ed_object_mode_generic_exit_ex(), ED_object_texture_paint_mode_exit(), and texture_paint_toggle_exec().
| void ED_space_image_paint_update | ( | Main * | bmain, |
| wmWindowManager * | wm, | ||
| 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 481 of file paint_image.cc.
References 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(), SI_MODE_PAINT, SPACE_IMAGE, Texture2D, Scene::toolsettings, wmWindowManager::windows, and WM_window_get_active_screen().
Referenced by ED_editors_init().
| bool facemask_paint_poll | ( | bContext * | C | ) |
Definition at line 970 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_less(), PAINT_OT_face_select_linked(), PAINT_OT_face_select_linked_pick(), PAINT_OT_face_select_loop(), and PAINT_OT_face_select_more().
Definition at line 443 of file paint_image.cc.
References C, CTX_wm_area(), CTX_wm_region(), ED_space_image_get_zoom(), ListBase::first, SpaceImage::mode, SI_MODE_PAINT, SPACE_IMAGE, ScrArea::spacedata, and ScrArea::spacetype.
Referenced by blender::ed::sculpt_paint::paint_cursor_context_init(), and blender::ed::sculpt_paint::paint_stroke_new().
| ImagePaintPartialRedraw * get_imapaintpartial | ( | ) |
Definition at line 86 of file paint_image.cc.
References imapaintpartial.
|
static |
Definition at line 520 of file paint_image.cc.
References add_v2_v2(), C, ImagePaintSettings::clone_offset, CTX_data_scene(), CTX_wm_region(), ED_region_tag_redraw(), ToolSettings::imapaint, wmOperator::ptr, RNA_float_get_array(), and Scene::toolsettings.
Referenced by grab_clone_exec(), and grab_clone_modal().
|
static |
Definition at line 595 of file paint_image.cc.
References wmOperator::customdata.
Referenced by PAINT_OT_grab_clone().
|
static |
Definition at line 532 of file paint_image.cc.
References C, grab_clone_apply(), and OPERATOR_FINISHED.
Referenced by PAINT_OT_grab_clone().
|
static |
Definition at line 539 of file paint_image.cc.
References C, ImagePaintSettings::clone_offset, copy_v2_v2(), CTX_data_scene(), wmOperator::customdata, ToolSettings::imapaint, MEM_callocN(), OPERATOR_RUNNING_MODAL, GrabClone::startoffset, GrabClone::startx, GrabClone::starty, Scene::toolsettings, and WM_event_add_modal_handler().
Referenced by PAINT_OT_grab_clone().
|
static |
Definition at line 557 of file paint_image.cc.
References C, ImagePaintSettings::clone_offset, copy_v2_v2(), CTX_data_scene(), CTX_wm_region(), wmOperator::customdata, grab_clone_apply(), ToolSettings::imapaint, LEFTMOUSE, MEM_freeN(), MIDDLEMOUSE, MOUSEMOVE, OPERATOR_FINISHED, OPERATOR_RUNNING_MODAL, wmOperator::ptr, RIGHTMOUSE, RNA_float_set_array(), GrabClone::startoffset, GrabClone::startx, GrabClone::starty, Scene::toolsettings, wmEvent::type, UI_view2d_region_to_view(), ARegion::v2d, ARegion::winrct, rcti::xmin, wmEvent::xy, and rcti::ymin.
Referenced by PAINT_OT_grab_clone().
|
static |
Definition at line 323 of file paint_image.cc.
References C, ImagePaintSettings::clone, CTX_data_scene(), CTX_wm_region_view3d(), ED_image_tools_paint_poll(), Brush::image_brush_type, image_paint_brush(), IMAGE_PAINT_BRUSH_TYPE_CLONE, ToolSettings::imapaint, and Scene::toolsettings.
Referenced by PAINT_OT_grab_clone().
Definition at line 270 of file paint_image.cc.
References BKE_paint_brush(), C, CTX_data_scene(), ToolSettings::imapaint, ImagePaintSettings::paint, and Scene::toolsettings.
Referenced by brush_colors_flip_poll(), image_paint_2d_clone_poll(), and image_paint_poll_ex().
|
static |
Definition at line 278 of file paint_image.cc.
References C, CTX_data_active_object(), CTX_wm_region(), CTX_wm_region_view3d(), CTX_wm_space_image(), ID_IS_EDITABLE, 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().
| bool image_paint_poll_ignore_tool | ( | bContext * | C | ) |
Definition at line 318 of file paint_image.cc.
References C, and image_paint_poll_ex().
Referenced by sample_color_poll().
| bool image_texture_paint_poll | ( | bContext * | C | ) |
Definition at line 965 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 151 of file paint_image.cc.
References BKE_image_partial_update_mark_full_update(), BKE_image_update_gputexture(), BLI_rcti_is_empty(), BLI_rcti_size_x(), BLI_rcti_size_y(), imapaintpartial, IMB_partial_display_buffer_update_delayed(), SpaceImage::lock, ImBuf::planes, and w().
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 103 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().
| bool mask_paint_poll | ( | bContext * | C | ) |
Definition at line 980 of file paint_image.cc.
References BKE_paint_select_elem_test(), C, and CTX_data_active_object().
| void paint_brush_color_get | ( | const Paint * | paint, |
| Brush * | br, | ||
| std::optional< blender::float3 > & | initial_hsv_jitter, | ||
| bool | invert, | ||
| float | distance, | ||
| float | pressure, | ||
| float | r_color[3] ) |
Definition at line 365 of file paint_image.cc.
References BKE_brush_color_get(), BKE_brush_color_jitter_get_settings(), BKE_brush_secondary_color_get(), BKE_colorband_evaluate(), BKE_paint_randomize_color(), BRUSH_GRADIENT_PRESSURE, BRUSH_GRADIENT_SPACING_CLAMP, BRUSH_GRADIENT_SPACING_REPEAT, BRUSH_USE_GRADIENT, copy_v3_v3(), distance(), Brush::flag, fmod(), Brush::gradient, Brush::gradient_spacing, Brush::gradient_stroke_mode, invert(), linearrgb_to_srgb_v3_v3(), and srgb_to_linearrgb_v3_v3().
Referenced by brush_painter_imbuf_new(), brush_painter_imbuf_update(), and paint_proj_stroke_ps().
| void paint_brush_exit_tex | ( | Brush * | brush | ) |
Definition at line 429 of file paint_image.cc.
References Brush::mask_mtex, Brush::mtex, Tex::nodetree, ntreeTexEndExecTree(), bNodeTree::runtime, and MTex::tex.
Referenced by paint_2d_stroke_done(), and paint_proj_stroke_done().
| void paint_brush_init_tex | ( | Brush * | brush | ) |
Definition at line 413 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 257 of file paint_image.cc.
References MEM_freeN(), and BlurKernel::wdata.
Referenced by paint_2d_canvas_free(), paint_new_blur_kernel(), and project_paint_end().
Initialize viewport pivot from evaluated bounding box center of ob.
Definition at line 676 of file paint_image.cc.
References blender::bke::PaintRuntime::average_stroke_accum, blender::bke::PaintRuntime::average_stroke_counter, BLI_assert_unreachable, RenderData::cfra, copy_v3_v3(), blender::bke::PaintRuntime::last_stroke_valid, mul_m4_v3(), OB_CURVES, OB_GREASE_PENCIL, OB_MESH, paint_init_pivot_curves(), paint_init_pivot_grease_pencil(), paint_init_pivot_mesh(), Scene::r, Paint::runtime, and Object::type.
Referenced by blender::ed::sculpt_paint::curves_sculptmode_enter(), and ED_object_texture_paint_mode_enter_ex().
|
static |
Definition at line 653 of file paint_image.cc.
References bounds(), Object::data, Curves::geometry, and blender::math::midpoint().
Referenced by paint_init_pivot().
|
static |
Definition at line 664 of file paint_image.cc.
References bounds(), Object::data, and blender::math::midpoint().
Referenced by paint_init_pivot().
|
static |
Definition at line 637 of file paint_image.cc.
References BKE_object_get_evaluated_mesh(), bounds(), Object::data, and blender::math::midpoint().
Referenced by paint_init_pivot().
| BlurKernel * paint_new_blur_kernel | ( | 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 190 of file paint_image.cc.
References Brush::blur_kernel_radius, Brush::blur_mode, exp, i, KERNEL_BOX, KERNEL_GAUSSIAN, MEM_malloc_arrayN(), paint_delete_blur_kernel(), BlurKernel::pixel_len, printf, BlurKernel::side, BlurKernel::side_squared, and BlurKernel::wdata.
Referenced by paint_2d_new_stroke(), and project_state_init().
| void PAINT_OT_brush_colors_flip | ( | wmOperatorType * | ot | ) |
Definition at line 909 of file paint_image.cc.
References brush_colors_flip_exec(), brush_colors_flip_poll(), OPTYPE_REGISTER, and ot.
Referenced by ED_operatortypes_paint().
| void PAINT_OT_grab_clone | ( | wmOperatorType * | ot | ) |
Definition at line 601 of file paint_image.cc.
References FLT_MAX, grab_clone_cancel(), grab_clone_exec(), grab_clone_invoke(), grab_clone_modal(), image_paint_2d_clone_poll(), OPTYPE_BLOCKING, OPTYPE_REGISTER, OPTYPE_UNDO, ot, and RNA_def_float_vector().
Referenced by ED_operatortypes_paint().
| void PAINT_OT_texture_paint_toggle | ( | wmOperatorType * | ot | ) |
Definition at line 840 of file paint_image.cc.
References OPTYPE_REGISTER, OPTYPE_UNDO, ot, texture_paint_toggle_exec(), and texture_paint_toggle_poll().
Referenced by ED_operatortypes_paint().
Definition at line 347 of file paint_image.cc.
References BKE_brush_color_jitter_get_settings(), BRUSH_AIRBRUSH, BRUSH_ANCHORED, BRUSH_DRAG_DOT, MTex::brush_map_mode, BRUSH_USE_GRADIENT, ELEM, Brush::flag, Brush::image_brush_type, IMAGE_PAINT_BRUSH_TYPE_FILL, IMAGE_PAINT_BRUSH_TYPE_SMEAR, IMAGE_PAINT_BRUSH_TYPE_SOFTEN, Brush::mtex, MTEX_MAP_MODE_3D, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_TILED, and MTex::tex.
Referenced by paint_2d_canvas_set(), and project_state_init().
| blender::float3 seed_hsv_jitter | ( | ) |
Definition at line 959 of file paint_image.cc.
References blender::RandomNumberGenerator::from_random_seed(), and blender::RandomNumberGenerator::get_float().
Referenced by brush_painter_2d_new(), paint_proj_new_stroke(), blender::ed::sculpt_paint::sculpt_update_cache_invariants(), and blender::ed::sculpt_paint::vwpaint::update_cache_invariants().
| void set_imapaintpartial | ( | ImagePaintPartialRedraw * | ippr | ) |
Definition at line 91 of file paint_image.cc.
References imapaintpartial.
Referenced by project_image_refresh_tagged().
|
static |
Definition at line 948 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 809 of file paint_image.cc.
References C, CTX_data_active_object(), CTX_data_depsgraph_pointer(), CTX_data_main(), CTX_data_scene(), CTX_wm_message_bus(), depsgraph, ED_object_texture_paint_mode_enter_ex(), ED_object_texture_paint_mode_exit_ex(), Object::id, Object::mode, blender::ed::object::mode_compat_set(), OB_MODE_TEXTURE_PAINT, OPERATOR_CANCELLED, OPERATOR_FINISHED, wmOperator::reports, WM_msg_publish_rna_prop, and WM_toolsystem_update_from_context_view3d().
Referenced by PAINT_OT_texture_paint_toggle().
|
static |
Definition at line 796 of file paint_image.cc.
References C, CTX_data_active_object(), Object::data, ID_IS_EDITABLE, ID_IS_OVERRIDE_LIBRARY, OB_MESH, and Object::type.
Referenced by PAINT_OT_texture_paint_toggle(), and texture_paint_poll().
|
static |
Definition at line 466 of file paint_image.cc.
References ED_image_tools_paint_poll(), ED_paint_cursor_start(), ToolSettings::imapaint, ImagePaintSettings::paint, paint_cursor_delete_textures(), Paint::runtime, Scene::toolsettings, and WM_paint_cursor_end().
Referenced by ED_object_texture_paint_mode_enter_ex(), and ED_object_texture_paint_mode_exit_ex().
| bool vert_paint_poll | ( | bContext * | C | ) |
Definition at line 975 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(), PAINT_OT_vert_select_less(), PAINT_OT_vert_select_linked(), PAINT_OT_vert_select_linked_pick(), PAINT_OT_vert_select_more(), 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 84 of file paint_image.cc.
Referenced by ED_imapaint_clear_partial_redraw(), ED_imapaint_dirty_region(), get_imapaintpartial(), imapaint_image_update(), and set_imapaintpartial().