104 ImBuf *ibuf,
int x,
int y,
int w,
int h,
int *tx,
int *ty,
int *tw,
int *th)
106 int srcx = 0, srcy = 0;
119 ImBuf *tmpibuf =
nullptr;
120 int tilex, tiley, tilew, tileh, tx, ty;
121 int srcx = 0, srcy = 0;
125 if (
w == 0 || h == 0) {
137 for (ty = tiley; ty <= tileh; ty++) {
138 for (tx = tilex; tx <= tilew; tx++) {
140 undo_tiles, ima, ibuf, &tmpibuf, iuser, tx, ty,
nullptr,
nullptr,
false, find_old);
168 if (ibuf !=
nullptr && ibuf->
planes == 8) {
175 if (texpaint || (sima && sima->
lock)) {
193 BlurKernel *kernel = MEM_new<BlurKernel>(
"BlurKernel");
202 side = kernel->
side = 2;
214 side = kernel->
side = radius * 2 + 1;
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");
296 if (sima->
image !=
nullptr &&
332 if (image_paint_settings.
clone) {
367 std::optional<blender::float3> &initial_hsv_jitter,
377 const std::optional<BrushColorJitterSettings> color_jitter_settings =
397 else if (color_jitter_settings) {
404 *color_jitter_settings, *initial_hsv_jitter,
distance, pressure, color);
471 if (p.
runtime->paint_cursor && !enable) {
473 p.
runtime->paint_cursor =
nullptr;
548 cmv->
startx =
event->xy[0];
549 cmv->
starty =
event->xy[1];
564 float startfx, startfy, fx, fy, delta[2];
567 switch (event->
type) {
576 ®ion->
v2d, cmv->
startx - xmin, cmv->
starty - ymin, &startfx, &startfy);
579 delta[0] = fx - startfx;
580 delta[1] = fy - startfy;
604 ot->name =
"Grab Clone";
605 ot->idname =
"PAINT_OT_grab_clone";
606 ot->description =
"Move the clone source image";
626 "Delta offset of clone image in 0.0 to 1.0 coordinates",
645 const std::optional<Bounds<float3>>
bounds = mesh_eval->bounds_min_max();
656 const std::optional<blender::Bounds<blender::float3>>
bounds =
657 curves.
geometry.wrap().bounds_min_max();
668 const std::optional<Bounds<float3>>
bounds = grease_pencil.bounds_min_max(frame);
697 mul_m4_v3(ob->object_to_world().ptr(), location);
709 Image *ima =
nullptr;
741 if (
U.glreslimit != 0) {
776 if (
U.glreslimit != 0) {
817 const bool is_mode_set = (ob.
mode & mode_flag) != 0;
825 if (ob.
mode & mode_flag) {
843 ot->name =
"Texture Paint Mode";
844 ot->idname =
"PAINT_OT_texture_paint_toggle";
845 ot->description =
"Toggle texture paint mode in 3D view";
912 ot->name =
"Swap Colors";
913 ot->idname =
"PAINT_OT_brush_colors_flip";
914 ot->description =
"Swap primary and secondary brush colors";
934 if (sima && sima->
image) {
939 const float mouse_init[2] = {
float(mouse[0]),
float(mouse[1])};
void BKE_brush_color_sync_legacy(Brush *brush)
const float * BKE_brush_color_get(const Paint *paint, const Brush *brush)
const float * BKE_brush_secondary_color_get(const Paint *paint, const Brush *brush)
std::optional< BrushColorJitterSettings > BKE_brush_color_jitter_get_settings(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)
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.
void BKE_texpaint_slots_refresh_object(Scene *scene, Object *ob)
Material * BKE_object_material_get(Object *ob, short act)
Mesh * BKE_mesh_from_object(Object *ob)
General operations, lookup, etc. for blender objects.
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
blender::float3 BKE_paint_randomize_color(const BrushColorJitterSettings &color_jitter, const blender::float3 &initial_hsv_jitter, const float distance, const float pressure, const blender::float3 &color)
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, bool ensure_brushes=true)
bool BKE_paint_use_unified_color(const Paint *paint)
Paint * BKE_paint_get_active_from_context(const bContext *C)
Brush * BKE_paint_brush(Paint *paint)
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 linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3])
void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
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)
void DEG_id_tag_update(ID *id, unsigned int flags)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
#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_region_tag_redraw(ARegion *region)
void IMB_partial_display_buffer_update_delayed(ImBuf *ibuf, int xmin, int ymin, int xmax, int ymax)
void IMB_rectclip(ImBuf *dbuf, const ImBuf *sbuf, int *destx, int *desty, int *srcx, int *srcy, int *width, int *height)
void IMB_freeImBuf(ImBuf *ibuf)
Read Guarded memory(de)allocation.
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()
BPy_StructRNA * depsgraph
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
static RandomNumberGenerator from_random_seed()
float distance(VecOp< float, D >, VecOp< float, D >) RET
VecBase< float, 3 > float3
CCL_NAMESPACE_BEGIN ccl_device float invert(const float color, const float factor)
void * MEM_callocN(size_t len, const char *str)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
ccl_device_inline float2 fmod(const float2 a, const float b)
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
void paint_cursor_delete_textures()
void paint_delete_blur_kernel(BlurKernel *kernel)
static wmOperatorStatus brush_colors_flip_exec(bContext *C, wmOperator *)
static wmOperatorStatus grab_clone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
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 Brush * image_paint_brush(bContext *C)
static bool image_paint_poll_ex(bContext *C, bool check_tool)
static bool texture_paint_poll(bContext *C)
bool vert_paint_poll(bContext *C)
static void grab_clone_cancel(bContext *, 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 wmOperatorStatus grab_clone_exec(bContext *C, wmOperator *op)
static blender::float3 paint_init_pivot_grease_pencil(Object *ob, const int frame)
void ED_object_texture_paint_mode_exit(bContext *C)
bool facemask_paint_poll(bContext *C)
bool image_texture_paint_poll(bContext *C)
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])
blender::float3 seed_hsv_jitter()
bool image_paint_poll_ignore_tool(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 wmOperatorStatus grab_clone_modal(bContext *C, wmOperator *op, const wmEvent *event)
BlurKernel * paint_new_blur_kernel(Brush *br, bool proj)
static blender::float3 paint_init_pivot_curves(Object *ob)
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)
void PAINT_OT_grab_clone(wmOperatorType *ot)
void paint_brush_exit_tex(Brush *brush)
static wmOperatorStatus texture_paint_toggle_exec(bContext *C, wmOperator *op)
bool paint_use_opacity_masking(const Paint *paint, const Brush *brush)
void ED_object_texture_paint_mode_exit_ex(Main &bmain, Scene &scene, Object &ob)
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)
void paint_init_pivot(Object *ob, Scene *scene, Paint *paint)
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)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
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)
struct ColorBand * gradient
char gradient_stroke_mode
struct TexPaintSlot * texpaintslot
struct UnifiedPaintSettings unified_paint_settings
PaintRuntimeHandle * runtime
struct ToolSettings * toolsettings
struct bNodeTree * nodetree
bNodeTreeRuntimeHandle * runtime
blender::float3 average_stroke_accum
int average_stroke_counter
struct ReportList * reports
struct wmOperatorType * type
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)