Blender V5.0
paint_image.cc File Reference

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

Functions

Image Paint Blur
BlurKernelpaint_new_blur_kernel (Brush *br, bool proj)
void paint_delete_blur_kernel (BlurKernel *kernel)
Image Paint Poll
static Brushimage_paint_brush (bContext *C)
static bool image_paint_poll_ex (bContext *C, bool check_tool)
bool ED_image_tools_paint_poll (bContext *C)
bool image_paint_poll_ignore_tool (bContext *C)
static bool image_paint_2d_clone_poll (bContext *C)
Paint Operator
bool paint_use_opacity_masking (const Paint *paint, const Brush *brush)
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])
void paint_brush_init_tex (Brush *brush)
void paint_brush_exit_tex (Brush *brush)
bool get_imapaint_zoom (bContext *C, float *zoomx, float *zoomy)
Cursor Drawing
static void toggle_paint_cursor (Scene &scene, bool enable)
void ED_space_image_paint_update (Main *bmain, wmWindowManager *wm, Scene *scene)
Grab Clone Operator
static void grab_clone_apply (bContext *C, wmOperator *op)
static wmOperatorStatus grab_clone_exec (bContext *C, wmOperator *op)
static wmOperatorStatus grab_clone_invoke (bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus grab_clone_modal (bContext *C, wmOperator *op, const wmEvent *event)
static void grab_clone_cancel (bContext *, wmOperator *op)
void PAINT_OT_grab_clone (wmOperatorType *ot)
Texture Paint Toggle Operator
static blender::float3 paint_init_pivot_mesh (Object *ob)
static blender::float3 paint_init_pivot_curves (Object *ob)
static blender::float3 paint_init_pivot_grease_pencil (Object *ob, const int frame)
void paint_init_pivot (Object *ob, Scene *scene, Paint *paint)
void ED_object_texture_paint_mode_enter_ex (Main &bmain, Scene &scene, Depsgraph &depsgraph, Object &ob)
void ED_object_texture_paint_mode_enter (bContext *C)
void ED_object_texture_paint_mode_exit_ex (Main &bmain, Scene &scene, Object &ob)
void ED_object_texture_paint_mode_exit (bContext *C)
static bool texture_paint_toggle_poll (bContext *C)
static wmOperatorStatus texture_paint_toggle_exec (bContext *C, wmOperator *op)
void PAINT_OT_texture_paint_toggle (wmOperatorType *ot)
Brush Color Flip Operator
static wmOperatorStatus brush_colors_flip_exec (bContext *C, wmOperator *)
static bool brush_colors_flip_poll (bContext *C)
void PAINT_OT_brush_colors_flip (wmOperatorType *ot)
Texture Paint Bucket Fill Operator
void ED_imapaint_bucket_fill (bContext *C, float const color[3], wmOperator *op, const int mouse[2])
static bool texture_paint_poll (bContext *C)
blender::float3 seed_hsv_jitter ()
bool image_texture_paint_poll (bContext *C)
bool facemask_paint_poll (bContext *C)
bool vert_paint_poll (bContext *C)
bool mask_paint_poll (bContext *C)

Image Paint Tile Utilities (Partial Update)

static ImagePaintPartialRedraw imapaintpartial = {{0}}
ImagePaintPartialRedrawget_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)

Detailed Description

Functions to paint images in 2D and 3D.

Definition in file paint_image.cc.

Function Documentation

◆ brush_colors_flip_exec()

◆ brush_colors_flip_poll()

◆ ED_image_tools_paint_poll()

◆ ED_imapaint_bucket_fill()

void ED_imapaint_bucket_fill ( bContext * C,
float const color[3],
wmOperator * op,
const int mouse[2] )

◆ ED_imapaint_clear_partial_redraw()

◆ ED_imapaint_dirty_region()

void ED_imapaint_dirty_region ( Image * ima,
ImBuf * ibuf,
ImageUser * iuser,
int x,
int y,
int w,
int h,
bool find_old )

◆ ED_object_texture_paint_mode_enter()

void ED_object_texture_paint_mode_enter ( bContext * C)

◆ ED_object_texture_paint_mode_enter_ex()

◆ ED_object_texture_paint_mode_exit()

void ED_object_texture_paint_mode_exit ( bContext * C)

◆ ED_object_texture_paint_mode_exit_ex()

◆ ED_space_image_paint_update()

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().

◆ facemask_paint_poll()

◆ get_imapaint_zoom()

◆ get_imapaintpartial()

ImagePaintPartialRedraw * get_imapaintpartial ( )

Definition at line 86 of file paint_image.cc.

References imapaintpartial.

◆ grab_clone_apply()

◆ grab_clone_cancel()

void grab_clone_cancel ( bContext * ,
wmOperator * op )
static

Definition at line 595 of file paint_image.cc.

References wmOperator::customdata.

Referenced by PAINT_OT_grab_clone().

◆ grab_clone_exec()

wmOperatorStatus grab_clone_exec ( bContext * C,
wmOperator * op )
static

Definition at line 532 of file paint_image.cc.

References C, grab_clone_apply(), and OPERATOR_FINISHED.

Referenced by PAINT_OT_grab_clone().

◆ grab_clone_invoke()

◆ grab_clone_modal()

◆ image_paint_2d_clone_poll()

◆ image_paint_brush()

◆ image_paint_poll_ex()

◆ 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().

◆ image_texture_paint_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().

◆ imapaint_image_update()

◆ imapaint_region_tiles()

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().

◆ mask_paint_poll()

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().

◆ paint_brush_color_get()

◆ paint_brush_exit_tex()

void paint_brush_exit_tex ( Brush * brush)

◆ paint_brush_init_tex()

void paint_brush_init_tex ( Brush * brush)

◆ paint_delete_blur_kernel()

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().

◆ paint_init_pivot()

◆ paint_init_pivot_curves()

blender::float3 paint_init_pivot_curves ( Object * ob)
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().

◆ paint_init_pivot_grease_pencil()

blender::float3 paint_init_pivot_grease_pencil ( Object * ob,
const int frame )
static

Definition at line 664 of file paint_image.cc.

References bounds(), Object::data, and blender::math::midpoint().

Referenced by paint_init_pivot().

◆ paint_init_pivot_mesh()

blender::float3 paint_init_pivot_mesh ( Object * ob)
static

◆ paint_new_blur_kernel()

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().

◆ PAINT_OT_brush_colors_flip()

void PAINT_OT_brush_colors_flip ( wmOperatorType * ot)

◆ PAINT_OT_grab_clone()

◆ PAINT_OT_texture_paint_toggle()

void PAINT_OT_texture_paint_toggle ( wmOperatorType * ot)

◆ paint_use_opacity_masking()

◆ seed_hsv_jitter()

◆ set_imapaintpartial()

void set_imapaintpartial ( ImagePaintPartialRedraw * ippr)

Definition at line 91 of file paint_image.cc.

References imapaintpartial.

Referenced by project_image_refresh_tagged().

◆ texture_paint_poll()

bool texture_paint_poll ( bContext * C)
static

◆ texture_paint_toggle_exec()

◆ texture_paint_toggle_poll()

bool texture_paint_toggle_poll ( bContext * C)
static

◆ toggle_paint_cursor()

◆ vert_paint_poll()

Variable Documentation

◆ imapaintpartial

ImagePaintPartialRedraw imapaintpartial = {{0}}
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().