Blender V4.3
paint_vertex.cc File Reference
#include "MEM_guardedalloc.h"
#include "CLG_log.h"
#include "BLI_array_utils.h"
#include "BLI_color.hh"
#include "BLI_color_mix.hh"
#include "BLI_enumerable_thread_specific.hh"
#include "BLI_listbase.h"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.hh"
#include "BLI_math_rotation.h"
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BLI_task.h"
#include "BLI_task.hh"
#include "BLI_vector.hh"
#include "DNA_brush_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "BKE_attribute.hh"
#include "BKE_brush.hh"
#include "BKE_colortools.hh"
#include "BKE_context.hh"
#include "BKE_deform.hh"
#include "BKE_editmesh.hh"
#include "BKE_lib_id.hh"
#include "BKE_mesh.hh"
#include "BKE_object.hh"
#include "BKE_object_deform.h"
#include "BKE_object_types.hh"
#include "BKE_paint.hh"
#include "BKE_report.hh"
#include "DEG_depsgraph.hh"
#include "WM_api.hh"
#include "WM_message.hh"
#include "WM_toolsystem.hh"
#include "WM_types.hh"
#include "ED_image.hh"
#include "ED_mesh.hh"
#include "ED_object.hh"
#include "ED_object_vgroup.hh"
#include "ED_paint.hh"
#include "ED_screen.hh"
#include "ED_sculpt.hh"
#include "ED_view3d.hh"
#include "IMB_imbuf.hh"
#include "BKE_ccg.hh"
#include "bmesh.hh"
#include "mesh_brush_common.hh"
#include "paint_intern.hh"
#include "sculpt_automask.hh"
#include "sculpt_boundary.hh"
#include "sculpt_cloth.hh"
#include "sculpt_intern.hh"
#include "sculpt_pose.hh"
#include "sculpt_undo.hh"

Go to the source code of this file.

Classes

struct  VPaintAverageAccum< BlendType >
 
struct  VPaintData
 

Namespaces

namespace  blender
 
namespace  blender::ed
 
namespace  blender::ed::sculpt_paint
 
namespace  blender::ed::sculpt_paint::vwpaint
 

Functions

template<typename T >
static void blender::ed::sculpt_paint::fill_bm_face_or_corner_attribute (BMesh &bm, const T &value, const AttrDomain domain, const int cd_offset, const bool use_vert_sel)
 
template<typename T >
static void blender::ed::sculpt_paint::fill_mesh_face_or_corner_attribute (Mesh &mesh, const T &value, const AttrDomain domain, const MutableSpan< T > data, const bool use_vert_sel, const bool use_face_sel, const bool affect_alpha)
 
static void blender::ed::sculpt_paint::fill_mesh_color (Mesh &mesh, const ColorPaint4f &color, const StringRef attribute_name, const bool use_vert_sel, const bool use_face_sel, const bool affect_alpha)
 
static bool blender::ed::sculpt_paint::fill_active_color (Object &ob, ColorPaint4f fill_color, bool only_selected=true, bool affect_alpha=true)
 
bool blender::ed::sculpt_paint::object_active_color_fill (Object &ob, const float fill_color[4], bool only_selected)
 
Internal Utilities
static bool isZero (ColorPaint4f c)
 
static bool isZero (ColorPaint4b c)
 
template<typename Color >
static ColorPaint4f toFloat (const Color &c)
 
template<typename Color >
static Color fromFloat (const ColorPaint4f &c)
 
bool vertex_paint_mode_poll (bContext *C)
 
static bool vertex_paint_poll_ex (bContext *C, bool check_tool)
 
bool vertex_paint_poll (bContext *C)
 
bool vertex_paint_poll_ignore_tool (bContext *C)
 
static ColorPaint4f vpaint_get_current_col (Scene &scene, VPaint &vp, bool secondary)
 
template<typename Color , typename Traits >
static Color vpaint_blend (const VPaint &vp, Color color_curr, Color color_orig, Color color_paint, const typename Traits::ValueType alpha, const typename Traits::BlendType brush_alpha_value)
 
static void paint_and_tex_color_alpha_intern (const VPaint &vp, const ViewContext *vc, const float co[3], float r_rgba[4])
 
static void vertex_paint_init_stroke (Depsgraph &depsgraph, Object &ob)
 
Shared vertex/weight paint code.
void blender::ed::sculpt_paint::vwpaint::view_angle_limits_init (NormalAnglePrecalc *a, float angle, bool do_mask_normal)
 
float blender::ed::sculpt_paint::vwpaint::view_angle_limits_apply_falloff (const NormalAnglePrecalc *a, float angle_cos, float *mask_p)
 
bool blender::ed::sculpt_paint::vwpaint::test_brush_angle_falloff (const Brush &brush, const NormalAnglePrecalc &normal_angle_precalc, const float angle_cos, float *brush_strength)
 
bool blender::ed::sculpt_paint::vwpaint::use_normal (const VPaint &vp)
 
bool blender::ed::sculpt_paint::vwpaint::brush_use_accumulate_ex (const Brush &brush, eObjectMode ob_mode)
 
bool blender::ed::sculpt_paint::vwpaint::brush_use_accumulate (const VPaint &vp)
 
void blender::ed::sculpt_paint::vwpaint::init_stroke (Depsgraph &depsgraph, Object &ob)
 
void blender::ed::sculpt_paint::vwpaint::init_session (Main &bmain, Depsgraph &depsgraph, Scene &scene, Object &ob, eObjectMode object_mode)
 
void blender::ed::sculpt_paint::vwpaint::init_session_data (const ToolSettings &ts, Object &ob)
 
IndexMask blender::ed::sculpt_paint::vwpaint::pbvh_gather_generic (const Depsgraph &depsgraph, const Object &ob, const VPaint &wp, const Brush &brush, IndexMaskMemory &memory)
 
void blender::ed::sculpt_paint::vwpaint::mode_enter_generic (Main &bmain, Depsgraph &depsgraph, Scene &scene, Object &ob, eObjectMode mode_flag)
 
void blender::ed::sculpt_paint::vwpaint::mode_exit_generic (Object &ob, eObjectMode mode_flag)
 
bool blender::ed::sculpt_paint::vwpaint::mode_toggle_poll_test (bContext *C)
 
void blender::ed::sculpt_paint::vwpaint::smooth_brush_toggle_off (const bContext *C, Paint *paint, StrokeCache *cache)
 
void blender::ed::sculpt_paint::vwpaint::update_cache_invariants (bContext *C, VPaint &vp, SculptSession &ss, wmOperator *op, const float mval[2])
 
void blender::ed::sculpt_paint::vwpaint::update_cache_variants (bContext *C, VPaint &vp, Object &ob, PointerRNA *ptr)
 
void blender::ed::sculpt_paint::vwpaint::get_brush_alpha_data (const Scene &scene, const SculptSession &ss, const Brush &brush, float *r_brush_size_pressure, float *r_brush_alpha_value, float *r_brush_alpha_pressure)
 
void blender::ed::sculpt_paint::vwpaint::last_stroke_update (Scene &scene, const float location[3])
 
void blender::ed::sculpt_paint::vwpaint::smooth_brush_toggle_on (const bContext *C, Paint *paint, StrokeCache *cache)
 
Enter Vertex Paint Mode
void ED_object_vpaintmode_enter_ex (Main &bmain, Depsgraph &depsgraph, Scene &scene, Object &ob)
 
void ED_object_vpaintmode_enter (bContext *C, Depsgraph &depsgraph)
 
Exit Vertex Paint Mode
void ED_object_vpaintmode_exit_ex (Object &ob)
 
void ED_object_vpaintmode_exit (bContext *C)
 
Toggle Vertex Paint Operator
static int vpaint_mode_toggle_exec (bContext *C, wmOperator *op)
 
void PAINT_OT_vertex_paint_toggle (wmOperatorType *ot)
 
Vertex Paint Operator
template<typename Func >
static void to_static_color_type (const eCustomDataType type, const Func &func)
 
static std::unique_ptr< VPaintDatavpaint_init_vpaint (bContext *C, wmOperator *op, Scene &scene, Depsgraph &depsgraph, VPaint &vp, Object &ob, Mesh &mesh, const AttrDomain domain, const eCustomDataType type, const Brush &brush)
 
static bool vpaint_stroke_test_start (bContext *C, wmOperator *op, const float mouse[2])
 
static void filter_factors_with_selection (const Span< bool > select_vert, const Span< int > verts, const MutableSpan< float > factors)
 
static void do_vpaint_brush_blur_loops (const bContext *C, const VPaint &vp, VPaintData &vpd, Object &ob, Mesh &mesh, const Span< bke::pbvh::MeshNode > nodes, const IndexMask &node_mask, GMutableSpan attribute)
 
static void do_vpaint_brush_blur_verts (const bContext *C, const VPaint &vp, VPaintData &vpd, Object &ob, Mesh &mesh, const Span< bke::pbvh::MeshNode > nodes, const IndexMask &node_mask, GMutableSpan attribute)
 
static void do_vpaint_brush_smear (const bContext *C, const VPaint &vp, VPaintData &vpd, Object &ob, Mesh &mesh, const Span< bke::pbvh::MeshNode > nodes, const IndexMask &node_mask, GMutableSpan attribute)
 
static void calculate_average_color (VPaintData &vpd, Object &ob, Mesh &mesh, const Brush &brush, const GSpan attribute, const Span< bke::pbvh::MeshNode > nodes, const IndexMask &node_mask)
 
template<typename Color >
static float paint_and_tex_color_alpha (const VPaint &vp, VPaintData &vpd, const float v_co[3], Color *r_color)
 
static void vpaint_do_draw (const bContext *C, const VPaint &vp, VPaintData &vpd, Object &ob, Mesh &mesh, const Span< bke::pbvh::MeshNode > nodes, const IndexMask &node_mask, GMutableSpan attribute)
 
static void vpaint_do_blur (const bContext *C, const VPaint &vp, VPaintData &vpd, Object &ob, Mesh &mesh, const Span< bke::pbvh::MeshNode > nodes, const IndexMask &node_mask, GMutableSpan attribute)
 
static void vpaint_paint_leaves (bContext *C, const VPaint &vp, VPaintData &vpd, Object &ob, Mesh &mesh, GMutableSpan attribute, const Span< bke::pbvh::MeshNode > nodes, const IndexMask &node_mask)
 
static void vpaint_do_paint (bContext *C, const VPaint &vp, VPaintData &vpd, Object &ob, Mesh &mesh, const Brush &brush, const ePaintSymmetryFlags symm, const int axis, const int i, const float angle)
 
static void vpaint_do_radial_symmetry (bContext *C, const VPaint &vp, VPaintData &vpd, Object &ob, Mesh &mesh, const Brush &brush, const ePaintSymmetryFlags symm, const int axis)
 
static void vpaint_do_symmetrical_brush_actions (bContext *C, const VPaint &vp, VPaintData &vpd, Object &ob)
 
static void vpaint_stroke_update_step (bContext *C, wmOperator *, PaintStroke *stroke, PointerRNA *itemptr)
 
static void vpaint_stroke_done (const bContext *C, PaintStroke *stroke)
 
static int vpaint_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static int vpaint_exec (bContext *C, wmOperator *op)
 
static void vpaint_cancel (bContext *C, wmOperator *op)
 
static int vpaint_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
void PAINT_OT_vertex_paint (wmOperatorType *ot)
 
Set Vertex Colors Operator
static int vertex_color_set_exec (bContext *C, wmOperator *op)
 
void PAINT_OT_vertex_color_set (wmOperatorType *ot)
 

Variables

static CLG_LogRef LOG = {"ed.sculpt_paint"}
 

Detailed Description

Used for vertex color & weight paint and mode switching.

Note
This file is already big, use paint_vertex_color_ops.cc & paint_vertex_weight_ops.cc for general purpose operators.

Definition in file paint_vertex.cc.

Function Documentation

◆ calculate_average_color()

◆ do_vpaint_brush_blur_loops()

static void do_vpaint_brush_blur_loops ( const bContext * C,
const VPaint & vp,
VPaintData & vpd,
Object & ob,
Mesh & mesh,
const Span< bke::pbvh::MeshNode > nodes,
const IndexMask & node_mask,
GMutableSpan attribute )
static

Definition at line 1037 of file paint_vertex.cc.

References Blend, blend, blender::ed::sculpt_paint::StrokeCache::brush, brush_strength(), blender::ed::sculpt_paint::StrokeCache::bstrength, SculptSession::cache, blender::ed::sculpt_paint::calc_brush_distances(), blender::ed::sculpt_paint::calc_brush_strength_factors(), col, CTX_data_depsgraph_pointer(), CTX_data_scene(), depsgraph, blender::ed::sculpt_paint::LocalData::distances, dot_v3v3(), blender::bke::mesh::face_find_corner_from_vert(), blender::ed::sculpt_paint::LocalData::factors, Brush::falloff_shape, blender::ed::sculpt_paint::fill_factor_from_hide(), blender::ed::sculpt_paint::filter_distances_with_radius(), filter_factors_with_selection(), blender::index_mask::IndexMask::foreach_index(), blender::ed::sculpt_paint::vwpaint::get_brush_alpha_data(), blender::Span< T >::is_empty(), isZero(), blender::threading::EnumerableThreadSpecific< T >::local(), ME_EDIT_PAINT_FACE_SEL, ME_EDIT_PAINT_VERT_SEL, VPaintData::normal_angle_precalc, VPaintData::prev_colors, blender::ed::sculpt_paint::StrokeCache::radius, blender::Vector< T, InlineBufferCapacity, Allocator >::resize(), Object::sculpt, SCULPT_brush_frontface_normal_from_falloff_shape(), sqrtf, blender::ed::sculpt_paint::vwpaint::test_brush_angle_falloff(), to_static_color_type(), VPaintData::type, blender::ed::sculpt_paint::vwpaint::use_normal(), blender::bke::pbvh::vert_normals_eval(), blender::bke::pbvh::vert_positions_eval(), verts, and vpaint_blend().

Referenced by vpaint_do_blur().

◆ do_vpaint_brush_blur_verts()

static void do_vpaint_brush_blur_verts ( const bContext * C,
const VPaint & vp,
VPaintData & vpd,
Object & ob,
Mesh & mesh,
const Span< bke::pbvh::MeshNode > nodes,
const IndexMask & node_mask,
GMutableSpan attribute )
static

◆ do_vpaint_brush_smear()

static void do_vpaint_brush_smear ( const bContext * C,
const VPaint & vp,
VPaintData & vpd,
Object & ob,
Mesh & mesh,
const Span< bke::pbvh::MeshNode > nodes,
const IndexMask & node_mask,
GMutableSpan attribute )
static

Definition at line 1338 of file paint_vertex.cc.

References blender::ed::sculpt_paint::StrokeCache::brush, brush_strength(), blender::ed::sculpt_paint::StrokeCache::bstrength, SculptSession::cache, blender::ed::sculpt_paint::calc_brush_distances(), blender::ed::sculpt_paint::calc_brush_strength_factors(), VPaintData::color_curr, VPaintData::color_prev, CTX_data_depsgraph_pointer(), CTX_data_scene(), depsgraph, blender::ed::sculpt_paint::LocalData::distances, VPaintData::domain, dot_v3v3(), blender::bke::mesh::face_find_corner_from_vert(), blender::ed::sculpt_paint::LocalData::factors, Brush::falloff_shape, blender::ed::sculpt_paint::fill_factor_from_hide(), blender::ed::sculpt_paint::filter_distances_with_radius(), filter_factors_with_selection(), blender::index_mask::IndexMask::foreach_index(), blender::ed::sculpt_paint::vwpaint::get_brush_alpha_data(), blender::Span< T >::is_empty(), blender::ed::sculpt_paint::StrokeCache::is_last_valid, isZero(), blender::ed::sculpt_paint::StrokeCache::last_location_symm, blender::threading::EnumerableThreadSpecific< T >::local(), blender::ed::sculpt_paint::StrokeCache::location_symm, ME_EDIT_PAINT_FACE_SEL, ME_EDIT_PAINT_VERT_SEL, VPaintData::normal_angle_precalc, normalize_v3(), VPaintData::prev_colors, project_plane_v3_v3v3(), blender::ed::sculpt_paint::StrokeCache::radius, blender::Vector< T, InlineBufferCapacity, Allocator >::resize(), Object::sculpt, SCULPT_brush_frontface_normal_from_falloff_shape(), VPaintData::smear, sub_v3_v3v3(), blender::ed::sculpt_paint::vwpaint::test_brush_angle_falloff(), to_static_color_type(), VPaintData::type, blender::ed::sculpt_paint::vwpaint::use_normal(), blender::bke::pbvh::vert_normals_eval(), blender::bke::pbvh::vert_positions_eval(), verts, blender::ed::sculpt_paint::StrokeCache::view_normal_symm, and vpaint_blend().

Referenced by vpaint_paint_leaves().

◆ ED_object_vpaintmode_enter()

void ED_object_vpaintmode_enter ( bContext * C,
Depsgraph & depsgraph )

◆ ED_object_vpaintmode_enter_ex()

void ED_object_vpaintmode_enter_ex ( Main & bmain,
Depsgraph & depsgraph,
Scene & scene,
Object & ob )

◆ ED_object_vpaintmode_exit()

void ED_object_vpaintmode_exit ( bContext * C)

Definition at line 783 of file paint_vertex.cc.

References CTX_data_active_object(), and ED_object_vpaintmode_exit_ex().

◆ ED_object_vpaintmode_exit_ex()

◆ filter_factors_with_selection()

static void filter_factors_with_selection ( const Span< bool > select_vert,
const Span< int > verts,
const MutableSpan< float > factors )
static

◆ fromFloat()

template<typename Color >
static Color fromFloat ( const ColorPaint4f & c)
static

◆ isZero() [1/2]

◆ isZero() [2/2]

◆ paint_and_tex_color_alpha()

template<typename Color >
static float paint_and_tex_color_alpha ( const VPaint & vp,
VPaintData & vpd,
const float v_co[3],
Color * r_color )
static

◆ paint_and_tex_color_alpha_intern()

◆ PAINT_OT_vertex_color_set()

◆ PAINT_OT_vertex_paint()

◆ PAINT_OT_vertex_paint_toggle()

◆ to_static_color_type()

◆ toFloat()

template<typename Color >
static ColorPaint4f toFloat ( const Color & c)
static

Definition at line 109 of file paint_vertex.cc.

Referenced by calculate_average_color(), and paint_and_tex_color_alpha().

◆ vertex_color_set_exec()

◆ vertex_paint_init_stroke()

static void vertex_paint_init_stroke ( Depsgraph & depsgraph,
Object & ob )
static

◆ vertex_paint_mode_poll()

◆ vertex_paint_poll()

◆ vertex_paint_poll_ex()

◆ vertex_paint_poll_ignore_tool()

bool vertex_paint_poll_ignore_tool ( bContext * C)

Definition at line 645 of file paint_vertex.cc.

References vertex_paint_poll_ex().

Referenced by sample_color_poll().

◆ vpaint_blend()

template<typename Color , typename Traits >
static Color vpaint_blend ( const VPaint & vp,
Color color_curr,
Color color_orig,
Color color_paint,
const typename Traits::ValueType alpha,
const typename Traits::BlendType brush_alpha_value )
static

◆ vpaint_cancel()

◆ vpaint_do_blur()

static void vpaint_do_blur ( const bContext * C,
const VPaint & vp,
VPaintData & vpd,
Object & ob,
Mesh & mesh,
const Span< bke::pbvh::MeshNode > nodes,
const IndexMask & node_mask,
GMutableSpan attribute )
static

◆ vpaint_do_draw()

static void vpaint_do_draw ( const bContext * C,
const VPaint & vp,
VPaintData & vpd,
Object & ob,
Mesh & mesh,
const Span< bke::pbvh::MeshNode > nodes,
const IndexMask & node_mask,
GMutableSpan attribute )
static

Definition at line 1662 of file paint_vertex.cc.

References blender::ed::sculpt_paint::StrokeCache::brush, brush_strength(), blender::ed::sculpt_paint::StrokeCache::bstrength, SculptSession::cache, blender::ed::sculpt_paint::calc_brush_distances(), blender::ed::sculpt_paint::calc_brush_strength_factors(), blender::ed::sculpt_paint::Color, CTX_data_depsgraph_pointer(), CTX_data_scene(), depsgraph, blender::ed::sculpt_paint::LocalData::distances, VPaintData::domain, dot_v3v3(), blender::bke::mesh::face_find_corner_from_vert(), blender::ed::sculpt_paint::LocalData::factors, Brush::falloff_shape, blender::ed::sculpt_paint::fill_factor_from_hide(), blender::ed::sculpt_paint::filter_distances_with_radius(), filter_factors_with_selection(), blender::index_mask::IndexMask::foreach_index(), blender::ed::sculpt_paint::vwpaint::get_brush_alpha_data(), blender::Span< T >::is_empty(), isZero(), blender::threading::EnumerableThreadSpecific< T >::local(), ME_EDIT_PAINT_FACE_SEL, ME_EDIT_PAINT_VERT_SEL, VPaintData::normal_angle_precalc, VPaintData::prev_colors, blender::ed::sculpt_paint::StrokeCache::radius, blender::Vector< T, InlineBufferCapacity, Allocator >::resize(), Object::sculpt, SCULPT_brush_frontface_normal_from_falloff_shape(), blender::ed::sculpt_paint::vwpaint::test_brush_angle_falloff(), to_static_color_type(), VPaintData::type, blender::ed::sculpt_paint::vwpaint::use_normal(), blender::bke::pbvh::vert_normals_eval(), blender::bke::pbvh::vert_positions_eval(), verts, and vpaint_blend().

Referenced by vpaint_paint_leaves().

◆ vpaint_do_paint()

◆ vpaint_do_radial_symmetry()

static void vpaint_do_radial_symmetry ( bContext * C,
const VPaint & vp,
VPaintData & vpd,
Object & ob,
Mesh & mesh,
const Brush & brush,
const ePaintSymmetryFlags symm,
const int axis )
static

Definition at line 1910 of file paint_vertex.cc.

References M_PI, VPaint::radial_symm, and vpaint_do_paint().

Referenced by vpaint_do_symmetrical_brush_actions().

◆ vpaint_do_symmetrical_brush_actions()

◆ vpaint_exec()

◆ vpaint_get_current_col()

static ColorPaint4f vpaint_get_current_col ( Scene & scene,
VPaint & vp,
bool secondary )
static

◆ vpaint_init_vpaint()

◆ vpaint_invoke()

◆ vpaint_modal()

static int vpaint_modal ( bContext * C,
wmOperator * op,
const wmEvent * event )
static

◆ vpaint_mode_toggle_exec()

◆ vpaint_paint_leaves()

◆ vpaint_stroke_done()

◆ vpaint_stroke_test_start()

◆ vpaint_stroke_update_step()

Variable Documentation

◆ LOG

CLG_LogRef LOG = {"ed.sculpt_paint"}
static

Definition at line 93 of file paint_vertex.cc.