Blender V5.0
paint_vertex.cc File Reference
#include "MEM_guardedalloc.h"
#include "CLG_log.h"
#include "BLI_color.hh"
#include "BLI_color_mix.hh"
#include "BLI_enumerable_thread_specific.hh"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.hh"
#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_library.hh"
#include "BKE_mesh.hh"
#include "BKE_object.hh"
#include "BKE_object_types.hh"
#include "BKE_paint.hh"
#include "BKE_paint_types.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 "bmesh.hh"
#include "mesh_brush_common.hh"
#include "paint_intern.hh"
#include "sculpt_automask.hh"
#include "sculpt_intern.hh"
#include "sculpt_pose.hh"

Go to the source code of this file.

Classes

struct  VPaintAverageAccum< BlendType >
struct  VPaintData
struct  NormalAnglePrecalc

Namespaces

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

Enumerations

enum class  AttrDomain

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 (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)
template<typename Color, typename Traits>
static Color vpaint_blend_stroke (const VPaint &vp, MutableSpan< Color > prev_vertex_colors, MutableSpan< Color > vertex_colors, MutableSpan< Color > stroke_buffer, Color brush_mark_color, float brush_mark_alpha, float brush_strength, int index)
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, 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, Paint &paint, 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 (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 SculptSession &ss, const Paint &paint, 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 (const float location[3], Paint &paint)
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 wmOperatorStatus 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 bke::AttrType 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 bke::AttrType 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 blender::float3 get_brush_color (const Paint *paint, const Brush *brush, const StrokeCache &cache, const ColorPaint4f &paint_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 wmOperatorStatus vpaint_invoke (bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus vpaint_exec (bContext *C, wmOperator *op)
static void vpaint_cancel (bContext *C, wmOperator *op)
static wmOperatorStatus vpaint_modal (bContext *C, wmOperator *op, const wmEvent *event)
void PAINT_OT_vertex_paint (wmOperatorType *ot)
Set Vertex Colors Operator
static wmOperatorStatus vertex_color_set_exec (bContext *C, wmOperator *op)
void PAINT_OT_vertex_color_set (wmOperatorType *ot)

Variables

static CLG_LogRef LOG = {"paint.vertex"}

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.

Enumeration Type Documentation

◆ AttrDomain

enum class blender::bke::AttrDomain : int8_t
strong

Definition at line 63 of file BKE_attribute.hh.

Function Documentation

◆ calculate_average_color()

◆ do_vpaint_brush_blur_loops()

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 1101 of file paint_vertex.cc.

References blend(), blender::ed::sculpt_paint::StrokeCache::brush, brush_strength(), blender::ed::sculpt_paint::StrokeCache::bstrength, C, SculptSession::cache, blender::ed::sculpt_paint::calc_brush_distances(), blender::ed::sculpt_paint::calc_brush_strength_factors(), col, blender::ed::sculpt_paint::Color, CTX_data_depsgraph_pointer(), depsgraph, dot_v3v3(), blender::bke::Face, blender::bke::mesh::face_find_corner_from_vert(), faces, Brush::falloff_shape, blender::ed::sculpt_paint::fill_factor_from_hide(), blender::ed::sculpt_paint::filter_distances_with_radius(), filter_factors_with_selection(), blender::ed::sculpt_paint::filter_region_clip_factors(), blender::index_mask::IndexMask::foreach_index(), blender::ed::sculpt_paint::vwpaint::get_brush_alpha_data(), i, blender::Span< T >::is_empty(), isZero(), blender::threading::EnumerableThreadSpecific< T >::local(), blender::bke::AttributeAccessor::lookup(), ME_EDIT_PAINT_FACE_SEL, ME_EDIT_PAINT_VERT_SEL, VPaintData::normal_angle_precalc, VPaint::paint, blender::bke::Point, VPaintData::prev_colors, blender::ed::sculpt_paint::StrokeCache::radius, 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()

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

Definition at line 1256 of file paint_vertex.cc.

References blend(), blender::ed::sculpt_paint::StrokeCache::brush, brush_strength(), blender::ed::sculpt_paint::StrokeCache::bstrength, C, SculptSession::cache, blender::ed::sculpt_paint::calc_brush_distances(), blender::ed::sculpt_paint::calc_brush_strength_factors(), col, blender::ed::sculpt_paint::Color, CTX_data_depsgraph_pointer(), depsgraph, dot_v3v3(), blender::bke::Face, faces, Brush::falloff_shape, blender::ed::sculpt_paint::fill_factor_from_hide(), blender::ed::sculpt_paint::filter_distances_with_radius(), filter_factors_with_selection(), blender::ed::sculpt_paint::filter_region_clip_factors(), blender::index_mask::IndexMask::foreach_index(), blender::ed::sculpt_paint::vwpaint::get_brush_alpha_data(), i, blender::Span< T >::is_empty(), isZero(), blender::threading::EnumerableThreadSpecific< T >::local(), blender::bke::AttributeAccessor::lookup(), ME_EDIT_PAINT_FACE_SEL, ME_EDIT_PAINT_VERT_SEL, VPaintData::normal_angle_precalc, VPaint::paint, blender::bke::Point, VPaintData::prev_colors, blender::ed::sculpt_paint::StrokeCache::radius, Object::sculpt, SCULPT_brush_frontface_normal_from_falloff_shape(), blender::Span< T >::slice(), 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_smear()

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 1402 of file paint_vertex.cc.

References blender::ed::sculpt_paint::StrokeCache::brush, brush_strength(), blender::ed::sculpt_paint::StrokeCache::bstrength, C, SculptSession::cache, blender::ed::sculpt_paint::calc_brush_distances(), blender::ed::sculpt_paint::calc_brush_strength_factors(), blender::ed::sculpt_paint::Color, VPaintData::color_curr, VPaintData::color_prev, CTX_data_depsgraph_pointer(), depsgraph, VPaintData::domain, dot_v3v3(), blender::bke::Face, blender::bke::mesh::face_find_corner_from_vert(), faces, Brush::falloff_shape, blender::ed::sculpt_paint::fill_factor_from_hide(), blender::ed::sculpt_paint::filter_distances_with_radius(), filter_factors_with_selection(), blender::ed::sculpt_paint::filter_region_clip_factors(), blender::index_mask::IndexMask::foreach_index(), blender::ed::sculpt_paint::vwpaint::get_brush_alpha_data(), i, if(), 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, blender::bke::AttributeAccessor::lookup(), ME_EDIT_PAINT_FACE_SEL, ME_EDIT_PAINT_VERT_SEL, VPaintData::normal_angle_precalc, normalize_v3(), VPaint::paint, blender::bke::Point, VPaintData::prev_colors, project_plane_v3_v3v3(), blender::ed::sculpt_paint::StrokeCache::radius, 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 839 of file paint_vertex.cc.

References C, CTX_data_active_object(), and ED_object_vpaintmode_exit_ex().

◆ ED_object_vpaintmode_exit_ex()

◆ filter_factors_with_selection()

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

◆ fromFloat()

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

Definition at line 108 of file paint_vertex.cc.

References blender::color::encode().

Referenced by paint_and_tex_color_alpha().

◆ get_brush_color()

◆ isZero() [1/2]

◆ isZero() [2/2]

◆ paint_and_tex_color_alpha()

template<typename Color>
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()

void PAINT_OT_vertex_color_set ( wmOperatorType * ot)

◆ PAINT_OT_vertex_paint()

◆ PAINT_OT_vertex_paint_toggle()

void PAINT_OT_vertex_paint_toggle ( wmOperatorType * ot)

◆ to_static_color_type()

◆ toFloat()

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

Definition at line 98 of file paint_vertex.cc.

References blender::color::decode().

Referenced by calculate_average_color(), and paint_and_tex_color_alpha().

◆ vertex_color_set_exec()

◆ vertex_paint_init_stroke()

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

◆ vertex_paint_mode_poll()

◆ vertex_paint_poll()

bool vertex_paint_poll ( bContext * C)

◆ vertex_paint_poll_ex()

◆ vertex_paint_poll_ignore_tool()

bool vertex_paint_poll_ignore_tool ( bContext * C)

Definition at line 647 of file paint_vertex.cc.

References C, and vertex_paint_poll_ex().

Referenced by sample_color_poll().

◆ vpaint_blend()

template<typename Color, typename Traits>
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_blend_stroke()

template<typename Color, typename Traits>
Color vpaint_blend_stroke ( const VPaint & vp,
MutableSpan< Color > prev_vertex_colors,
MutableSpan< Color > vertex_colors,
MutableSpan< Color > stroke_buffer,
Color brush_mark_color,
float brush_mark_alpha,
float brush_strength,
int index )
static

If in accumulate mode, blend brush mark directly onto mesh, else blend into temporary stroke_buffer and blend the stroke onto the mesh.

Parameters
brush_mark_alphaModulated strength on a per-vertex basis
brush_strengthUnmodified raw value of the brush

Definition at line 732 of file paint_vertex.cc.

References BLI_assert, blender::color::BLI_mix_colors(), brush_strength(), blender::ed::sculpt_paint::vwpaint::brush_use_accumulate(), blender::ed::sculpt_paint::Color, IMB_BLEND_MIX, blender::MutableSpan< T >::is_empty(), isZero(), result, and vpaint_blend().

◆ vpaint_cancel()

◆ vpaint_do_blur()

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

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

◆ vpaint_do_paint()

◆ vpaint_do_radial_symmetry()

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 1980 of file paint_vertex.cc.

References angle(), C, i, M_PI, and vpaint_do_paint().

Referenced by vpaint_do_symmetrical_brush_actions().

◆ vpaint_do_symmetrical_brush_actions()

◆ vpaint_exec()

◆ vpaint_get_current_col()

ColorPaint4f vpaint_get_current_col ( VPaint & vp,
bool secondary )
static

◆ vpaint_init_vpaint()

◆ vpaint_invoke()

◆ vpaint_modal()

wmOperatorStatus 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 = {"paint.vertex"}
static

Definition at line 82 of file paint_vertex.cc.