56 (mesh && mesh->
faces_num && !mesh->deform_verts().is_empty());
62 Mesh &mesh = *
static_cast<Mesh *
>(
object.data);
93 if (deform_group ==
nullptr) {
102 if (!color_attribute) {
141 ot->name =
"Vertex Color from Weight";
142 ot->idname =
"PAINT_OT_vertex_color_from_weight";
143 ot->description =
"Convert active weight into gray scale vertex colors";
170 ".select_poly", domain,
false);
175 ".select_vert", domain,
false);
235 ot->name =
"Smooth Vertex Colors";
236 ot->idname =
"PAINT_OT_vertex_color_smooth";
237 ot->description =
"Smooth colors across vertices";
265 if (!color_attribute) {
277 using T =
typename decltype(type_tag)::type;
278 for ([[maybe_unused]]
const int i : segment) {
279 if constexpr (std::is_void_v<T>) {
282 else if constexpr (std::is_same_v<T, ColorGeometry4f>) {
287 else if constexpr (std::is_same_v<T, ColorGeometry4b>) {
334 brightness /= 100.0f;
335 float delta = contrast / 200.0f;
342 gain = 1.0f - delta * 2.0f;
343 gain = 1.0f /
max_ff(gain, FLT_EPSILON);
344 offset = gain * (brightness - delta);
348 gain =
max_ff(1.0f - delta * 2.0f, 0.0f);
349 offset = gain * brightness + delta;
361 for (
int i = 0;
i < 3;
i++) {
374 ot->name =
"Vertex Paint Brightness/Contrast";
375 ot->idname =
"PAINT_OT_vertex_color_brightness_contrast";
376 ot->description =
"Adjust vertex color brightness/contrast";
386 const float min = -100,
max = +100;
411 hsv[0] += (hue - 0.5f);
415 else if (hsv[0] < 0.0f) {
430 ot->name =
"Vertex Paint Hue/Saturation/Value";
431 ot->idname =
"PAINT_OT_vertex_color_hsv";
432 ot->description =
"Adjust vertex color Hue/Saturation/Value";
443 RNA_def_float(
ot->srna,
"s", 1.0f, 0.0f, 2.0f,
"Saturation",
"", 0.0f, 2.0f);
444 RNA_def_float(
ot->srna,
"v", 1.0f, 0.0f, 2.0f,
"Value",
"", 0.0f, 2.0f);
459 for (
int i = 0;
i < 3;
i++) {
470 ot->name =
"Vertex Paint Invert";
471 ot->idname =
"PAINT_OT_vertex_color_invert";
472 ot->description =
"Invert RGB values";
497 for (
int i = 0;
i < 3;
i++) {
510 ot->name =
"Vertex Paint Levels";
511 ot->idname =
"PAINT_OT_vertex_color_levels";
512 ot->description =
"Adjust levels of vertex colors";
523 ot->srna,
"offset", 0.0f, -1.0f, 1.0f,
"Offset",
"Value to add to colors", -1.0f, 1.0f);
525 ot->srna,
"gain", 1.0f, 0.0f,
FLT_MAX,
"Gain",
"Value to multiply colors by", 0.0f, 10.0f);
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Object * CTX_data_active_object(const bContext *C)
void BKE_mesh_batch_cache_dirty_tag(Mesh *mesh, eMeshBatchDirtyMode mode)
@ BKE_MESH_BATCH_DIRTY_ALL
Mesh * BKE_mesh_from_object(Object *ob)
void BKE_sculpt_update_object_for_edit(Depsgraph *depsgraph, Object *ob_orig, bool is_paint_tool)
#define BLI_assert_unreachable()
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE float max_ff(float a, float b)
void hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
void DEG_id_tag_update(ID *id, unsigned int flags)
Object is a sort of wrapper for general info.
bool ED_mesh_color_ensure(Mesh *mesh, const char *name)
static IndexMask from_bools(Span< bool > bools, IndexMaskMemory &memory)
void to_static_type_tag(const Fn &fn) const
const void * data() const
const CPPType & type() const
void materialize(void *dst) const
void get(int64_t index, void *r_value) const
void set_all(const void *src)
void set_by_copy(int64_t index, const void *value)
GAttributeReader lookup_or_default(StringRef attribute_id, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
bool contains(StringRef attribute_id) const
GVArray adapt_domain(const GVArray &varray, const AttrDomain from_domain, const AttrDomain to_domain) const
GAttributeReader lookup(const StringRef attribute_id) const
int domain_size(const AttrDomain domain) const
GAttributeWriter lookup_for_write(StringRef attribute_id)
GSpanAttributeWriter lookup_for_write_span(StringRef attribute_id)
void tag_attribute_changed(const IndexMask &node_mask, StringRef attribute_name)
void foreach_segment(Fn &&fn) const
pbvh::Tree * pbvh_get(Object &object)
IndexMask all_leaf_nodes(const Tree &pbvh, IndexMaskMemory &memory)
AttrType cpp_type_to_attribute_type(const CPPType &type)
BLI_INLINE ColorSceneLinear4f< Alpha > decode(const ColorSceneLinearByteEncoded4b< Alpha > &color)
BLI_INLINE ColorSceneLinearByteEncoded4b< Alpha > encode(const ColorSceneLinear4f< Alpha > &color)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
ColorSceneLinearByteEncoded4b< eAlpha::Premultiplied > ColorGeometry4b
bool vertex_paint_mode_poll(bContext *C)
static wmOperatorStatus vertex_color_invert_exec(bContext *C, wmOperator *)
static wmOperatorStatus vertex_color_smooth_exec(bContext *C, wmOperator *)
static bool vertex_color_smooth(Object &ob)
void PAINT_OT_vertex_color_smooth(wmOperatorType *ot)
static bool vertex_weight_paint_mode_poll(bContext *C)
static wmOperatorStatus vertex_color_brightness_contrast_exec(bContext *C, wmOperator *op)
void PAINT_OT_vertex_color_hsv(wmOperatorType *ot)
static wmOperatorStatus vertex_color_levels_exec(bContext *C, wmOperator *op)
static wmOperatorStatus vertex_paint_from_weight_exec(bContext *C, wmOperator *)
static IndexMask get_selected_indices(const Mesh &mesh, const blender::bke::AttrDomain domain, IndexMaskMemory &memory)
static void transform_active_color_data(Mesh &mesh, const FunctionRef< void(ColorGeometry4f &color)> transform_fn)
static bool vertex_paint_from_weight(Object &ob)
static void face_corner_color_equalize_verts(Mesh &mesh, const IndexMask selection)
static void tag_object_after_update(Object &object)
void PAINT_OT_vertex_color_levels(wmOperatorType *ot)
void PAINT_OT_vertex_color_from_weight(wmOperatorType *ot)
static wmOperatorStatus vertex_color_hsv_exec(bContext *C, wmOperator *op)
void PAINT_OT_vertex_color_brightness_contrast(wmOperatorType *ot)
static void transform_active_color(bContext *C, const FunctionRef< void(ColorGeometry4f &color)> transform_fn)
void PAINT_OT_vertex_color_invert(wmOperatorType *ot)
float RNA_float_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
ListBase vertex_group_names
int vertex_group_active_index
char * active_color_attribute
void WM_event_add_notifier(const bContext *C, uint type, void *reference)