Blender V4.3
paint_utils.cc File Reference
#include <cmath>
#include <cstdlib>
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_brush_types.h"
#include "DNA_scene_types.h"
#include "BLI_listbase.h"
#include "BLI_math_color.h"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_matrix.hh"
#include "BLI_math_vector.hh"
#include "BLI_rect.h"
#include "BLI_utildefines.h"
#include "BLT_translation.hh"
#include "BKE_brush.hh"
#include "BKE_bvhutils.hh"
#include "BKE_colortools.hh"
#include "BKE_context.hh"
#include "BKE_customdata.hh"
#include "BKE_image.hh"
#include "BKE_layer.hh"
#include "BKE_material.h"
#include "BKE_mesh.hh"
#include "BKE_mesh_sample.hh"
#include "BKE_object.hh"
#include "BKE_paint.hh"
#include "BKE_report.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "RNA_prototypes.hh"
#include "IMB_imbuf_types.hh"
#include "IMB_interp.hh"
#include "RE_texture.h"
#include "ED_image.hh"
#include "ED_screen.hh"
#include "ED_select_utils.hh"
#include "ED_view3d.hh"
#include "BLI_sys_types.h"
#include "ED_mesh.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "paint_intern.hh"

Go to the source code of this file.

Functions

bool paint_convert_bb_to_rect (rcti *rect, const float bb_min[3], const float bb_max[3], const ARegion &region, const RegionView3D &rv3d, const Object &ob)
 
void paint_calc_redraw_planes (float planes[4][4], const ARegion &region, const Object &ob, const rcti &screen_rect)
 
float paint_calc_object_space_radius (const ViewContext &vc, const blender::float3 &center, const float pixel_radius)
 
bool paint_get_tex_pixel (const MTex *mtex, float u, float v, ImagePool *pool, int thread, float *r_intensity, float r_rgba[4])
 
void paint_stroke_operator_properties (wmOperatorType *ot)
 
static blender::float2 imapaint_pick_uv (const Mesh *mesh_eval, Scene *scene, Object *ob_eval, const int tri_index, const blender::float3 &bary_coord)
 
static int imapaint_pick_face (ViewContext *vc, const int mval[2], int *r_tri_index, int *r_face_index, blender::float3 *r_bary_coord, const Mesh &mesh)
 
void paint_sample_color (bContext *C, ARegion *region, int x, int y, bool texpaint_proj, bool use_palette)
 
static int brush_curve_preset_exec (bContext *C, wmOperator *op)
 
static bool brush_curve_preset_poll (bContext *C)
 
void BRUSH_OT_curve_preset (wmOperatorType *ot)
 
static bool brush_sculpt_curves_falloff_preset_poll (bContext *C)
 
static int brush_sculpt_curves_falloff_preset_exec (bContext *C, wmOperator *op)
 
void BRUSH_OT_sculpt_curves_falloff_preset (wmOperatorType *ot)
 
static int paint_select_linked_exec (bContext *C, wmOperator *)
 
void PAINT_OT_face_select_linked (wmOperatorType *ot)
 
static int paint_select_linked_pick_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void PAINT_OT_face_select_linked_pick (wmOperatorType *ot)
 
static int face_select_all_exec (bContext *C, wmOperator *op)
 
void PAINT_OT_face_select_all (wmOperatorType *ot)
 
static int paint_select_more_exec (bContext *C, wmOperator *op)
 
void PAINT_OT_face_select_more (wmOperatorType *ot)
 
static int paint_select_less_exec (bContext *C, wmOperator *op)
 
void PAINT_OT_face_select_less (wmOperatorType *ot)
 
static int paintface_select_loop_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void PAINT_OT_face_select_loop (wmOperatorType *ot)
 
static int vert_select_all_exec (bContext *C, wmOperator *op)
 
void PAINT_OT_vert_select_all (wmOperatorType *ot)
 
static int vert_select_ungrouped_exec (bContext *C, wmOperator *op)
 
void PAINT_OT_vert_select_ungrouped (wmOperatorType *ot)
 
static int paintvert_select_linked_exec (bContext *C, wmOperator *)
 
void PAINT_OT_vert_select_linked (wmOperatorType *ot)
 
static int paintvert_select_linked_pick_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void PAINT_OT_vert_select_linked_pick (wmOperatorType *ot)
 
static int paintvert_select_more_exec (bContext *C, wmOperator *op)
 
void PAINT_OT_vert_select_more (wmOperatorType *ot)
 
static int paintvert_select_less_exec (bContext *C, wmOperator *op)
 
void PAINT_OT_vert_select_less (wmOperatorType *ot)
 
static int face_select_hide_exec (bContext *C, wmOperator *op)
 
void PAINT_OT_face_select_hide (wmOperatorType *ot)
 
static int vert_select_hide_exec (bContext *C, wmOperator *op)
 
void PAINT_OT_vert_select_hide (wmOperatorType *ot)
 
static int face_vert_reveal_exec (bContext *C, wmOperator *op)
 
static bool face_vert_reveal_poll (bContext *C)
 
void PAINT_OT_face_vert_reveal (wmOperatorType *ot)
 

Variables

static const EnumPropertyItem prop_shape_items []
 

Function Documentation

◆ brush_curve_preset_exec()

◆ brush_curve_preset_poll()

static bool brush_curve_preset_poll ( bContext * C)
static

◆ BRUSH_OT_curve_preset()

◆ BRUSH_OT_sculpt_curves_falloff_preset()

◆ brush_sculpt_curves_falloff_preset_exec()

◆ brush_sculpt_curves_falloff_preset_poll()

static bool brush_sculpt_curves_falloff_preset_poll ( bContext * C)
static

◆ face_select_all_exec()

◆ face_select_hide_exec()

static int face_select_hide_exec ( bContext * C,
wmOperator * op )
static

◆ face_vert_reveal_exec()

◆ face_vert_reveal_poll()

static bool face_vert_reveal_poll ( bContext * C)
static

◆ imapaint_pick_face()

◆ imapaint_pick_uv()

◆ paint_calc_object_space_radius()

◆ paint_calc_redraw_planes()

void paint_calc_redraw_planes ( float planes[4][4],
const ARegion & region,
const Object & ob,
const rcti & screen_rect )

Get four planes in object-space that describe the projection of screen_rect from screen into object-space (essentially converting a 2D screens-space bounding box into four 3D planes).

Definition at line 112 of file paint_utils.cc.

References ED_view3d_clipping_calc(), rcti::xmax, rcti::xmin, rcti::ymax, and rcti::ymin.

◆ paint_convert_bb_to_rect()

bool paint_convert_bb_to_rect ( rcti * rect,
const float bb_min[3],
const float bb_max[3],
const ARegion & region,
const RegionView3D & rv3d,
const Object & ob )

Convert the object-space axis-aligned bounding box (expressed as its minimum and maximum corners) into a screen-space rectangle, returns zero if the result is empty.

Definition at line 69 of file paint_utils.cc.

References BLI_rcti_do_minmax_v(), BLI_rcti_init_minmax(), ED_view3d_ob_project_mat_get(), ED_view3d_project_float_v2_m4(), rcti::xmax, rcti::xmin, rcti::ymax, and rcti::ymin.

Referenced by blender::ed::sculpt_paint::trim::calc_expand_factor(), and SCULPT_get_redraw_rect().

◆ paint_get_tex_pixel()

bool paint_get_tex_pixel ( const MTex * mtex,
float u,
float v,
ImagePool * pool,
int thread,
float * r_intensity,
float r_rgba[4] )

Returns true when a color was sampled and false when a value was sampled.

Definition at line 149 of file paint_utils.cc.

References RE_texture_evaluate(), and v.

Referenced by blender::ed::sculpt_paint::load_tex_task_cb_ex(), and sculpt_apply_texture().

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

◆ PAINT_OT_face_select_more()

◆ PAINT_OT_face_vert_reveal()

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

◆ PAINT_OT_vert_select_ungrouped()

◆ paint_sample_color()

void paint_sample_color ( bContext * C,
ARegion * region,
int x,
int y,
bool texpaint_proj,
bool palette )

Used for both 3D view and image window.

Definition at line 306 of file paint_utils.cc.

References Palette::active_color, BKE_brush_color_set(), BKE_image_acquire_ibuf(), BKE_image_get_tile_from_pos(), BKE_image_release_ibuf(), BKE_imageuser_default(), BKE_object_get_evaluated_mesh(), BKE_object_material_get(), BKE_paint_brush(), BKE_paint_get_active_from_context(), BKE_paint_palette(), BKE_paint_palette_set(), BKE_palette_add(), BKE_palette_color_add(), BKE_texpaint_slot_refresh_cache(), BKE_view_layer_active_object_get(), BKE_view_layer_synced_ensure(), BLI_listbase_count(), ImBuf::byte_buffer, ImagePaintSettings::canvas, CD_PROP_FLOAT2, CD_PROP_INT32, CLAMP, blender::math::clamp(), Palette::colors, copy_v3_v3(), Mesh::corner_data, CTX_data_ensure_evaluated_depsgraph(), CTX_data_main(), CTX_data_scene(), CTX_data_view_layer(), CTX_wm_space_image(), CTX_wm_view3d(), CTX_wm_window(), CustomData_get_layer_named(), CustomData_has_layer(), ImBufByteBuffer::data, ImBufFloatBuffer::data, DEG_get_evaluated_object(), depsgraph, ED_space_image_color_sample(), ED_view3d_viewcontext_init(), Mesh::face_data, ImBuf::float_buffer, ImageUser::framenr, TexPaintSlot::ima, IMA_SRC_TILED, IMAGEPAINT_MODE_MATERIAL, imapaint_pick_face(), imapaint_pick_uv(), ImagePaintSettings::interp, interp(), TexPaintSlot::interp, linearrgb_to_srgb_v3_v3(), ImagePaintSettings::mode, Material::paint_active_slot, rgb_uchar_to_float(), SHD_INTERP_CLOSEST, SHD_INTERP_LINEAR, straight_to_premul_v4(), Material::texpaintslot, ImageUser::tile, v, WM_window_pixels_read_sample(), ImBuf::x, x, and ImBuf::y.

Referenced by sample_color_exec(), sample_color_invoke(), and sample_color_modal().

◆ paint_select_less_exec()

◆ paint_select_linked_exec()

static int paint_select_linked_exec ( bContext * C,
wmOperator *  )
static

◆ paint_select_linked_pick_invoke()

◆ paint_select_more_exec()

◆ paint_stroke_operator_properties()

◆ paintface_select_loop_invoke()

◆ paintvert_select_less_exec()

◆ paintvert_select_linked_exec()

static int paintvert_select_linked_exec ( bContext * C,
wmOperator *  )
static

◆ paintvert_select_linked_pick_invoke()

◆ paintvert_select_more_exec()

◆ vert_select_all_exec()

◆ vert_select_hide_exec()

static int vert_select_hide_exec ( bContext * C,
wmOperator * op )
static

◆ vert_select_ungrouped_exec()

Variable Documentation

◆ prop_shape_items

const EnumPropertyItem prop_shape_items[]
static
Initial value:
= {
{CURVE_PRESET_SHARP, "SHARP", 0, "Sharp", ""},
{CURVE_PRESET_SMOOTH, "SMOOTH", 0, "Smooth", ""},
{CURVE_PRESET_MAX, "MAX", 0, "Max", ""},
{CURVE_PRESET_LINE, "LINE", 0, "Line", ""},
{CURVE_PRESET_ROUND, "ROUND", 0, "Round", ""},
{CURVE_PRESET_ROOT, "ROOT", 0, "Root", ""},
{0, nullptr, 0, nullptr, nullptr},
}
@ CURVE_PRESET_ROOT
@ CURVE_PRESET_SMOOTH
@ CURVE_PRESET_ROUND
@ CURVE_PRESET_LINE
@ CURVE_PRESET_SHARP
@ CURVE_PRESET_MAX

Definition at line 491 of file paint_utils.cc.

Referenced by BRUSH_OT_curve_preset(), BRUSH_OT_sculpt_curves_falloff_preset(), and RENDER_OT_shutter_curve_preset().