[Bf-blender-cvs] [287358c269c] temp-vertex-paint: temp-vertex-paint: Use sculpt undo for vertex paint
Joseph Eagar
noreply at git.blender.org
Fri Feb 25 08:23:42 CET 2022
Commit: 287358c269cf7dea6bdeda72ddc04a3c6c66de21
Author: Joseph Eagar
Date: Thu Feb 24 23:23:10 2022 -0800
Branches: temp-vertex-paint
https://developer.blender.org/rB287358c269cf7dea6bdeda72ddc04a3c6c66de21
temp-vertex-paint: Use sculpt undo for vertex paint
===================================================================
M source/blender/editors/sculpt_paint/paint_intern.h
M source/blender/editors/sculpt_paint/paint_vertex.cc
M source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
M source/blender/editors/sculpt_paint/paint_vertex_color_utils.hh
M source/blender/editors/sculpt_paint/sculpt_undo.c
===================================================================
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 82fdf49c28e..e45228274d3 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -133,7 +133,7 @@ void PAINT_OT_weight_gradient(struct wmOperatorType *ot);
void PAINT_OT_vertex_paint_toggle(struct wmOperatorType *ot);
void PAINT_OT_vertex_paint(struct wmOperatorType *ot);
-unsigned int vpaint_get_current_col(struct Scene *scene, struct VPaint *vp, bool secondary);
+unsigned int vpaint_get_current_col(struct Scene *scene, struct VPaint *vp, bool secondary, float r_color[4]);
/* paint_vertex_color_utils.c */
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc
index b26fc570eaf..c3565928104 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.cc
+++ b/source/blender/editors/sculpt_paint/paint_vertex.cc
@@ -325,13 +325,17 @@ bool weight_paint_poll_ignore_tool(bContext *C)
return weight_paint_poll_ex(C, false);
}
-uint vpaint_get_current_col(Scene *scene, VPaint *vp, bool secondary)
+uint vpaint_get_current_col(Scene *scene, VPaint *vp, bool secondary, float floatcolor[4])
{
Brush *brush = BKE_paint_brush(&vp->paint);
uchar col[4];
- rgb_float_to_uchar(col,
- secondary ? BKE_brush_secondary_color_get(scene, brush) :
- BKE_brush_color_get(scene, brush));
+
+ copy_v4_v4(floatcolor,
+ secondary ? BKE_brush_secondary_color_get(scene, brush) :
+ BKE_brush_color_get(scene, brush));
+
+ rgb_float_to_uchar(col, floatcolor);
+
col[3] = 255; /* alpha isn't used, could even be removed to speedup paint a little */
return *(uint *)col;
}
@@ -2815,6 +2819,7 @@ struct VPaintData {
struct NormalAnglePrecalc normal_angle_precalc;
uint paintcol;
+ float floatcolor[4];
struct VertProjHandle *vp_handle;
struct CoNo *vertexcosnos;
@@ -2878,7 +2883,7 @@ extern "C" static bool vpaint_stroke_test_start(bContext *C,
(vp->paint.brush->flag & BRUSH_FRONTFACE_FALLOFF) != 0);
vpd->paintcol = vpaint_get_current_col(
- scene, vp, (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT));
+ scene, vp, (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT), vpd->floatcolor);
vpd->is_texbrush = !(brush->vertexpaint_tool == VPAINT_TOOL_BLUR) && brush->mtex.tex;
@@ -3690,14 +3695,14 @@ template<class Color> struct VPaintModeData {
template<class Color, typename Traits, bool is_verts>
static void vpaint_do_draw_intern(bContext *C,
- Sculpt *sd,
- VPaint *vp,
- struct VPaintData *vpd,
- Object *ob,
- Mesh *me,
- PBVHNode **nodes,
- int totnode,
- Color *lcol)
+ Sculpt *sd,
+ VPaint *vp,
+ struct VPaintData *vpd,
+ Object *ob,
+ Mesh *me,
+ PBVHNode **nodes,
+ int totnode,
+ Color *lcol)
{
using Value = Traits::ValueType;
@@ -3892,6 +3897,11 @@ static void vpaint_paint_leaves(bContext *C,
PBVHNode **nodes,
int totnode)
{
+
+ for (int i : IndexRange(totnode)) {
+ SCULPT_undo_push_node(ob, nodes[i], SCULPT_UNDO_COLOR);
+ }
+
const Brush *brush = ob->sculpt->cache->brush;
CustomDataLayer *layer = BKE_id_attributes_active_color_get(&me->id);
@@ -4129,6 +4139,8 @@ static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
MEM_freeN(vpd);
+ SCULPT_undo_push_end(ob);
+
SCULPT_cache_free(ob->sculpt->cache);
ob->sculpt->cache = NULL;
}
@@ -4146,6 +4158,8 @@ extern "C" static int vpaint_invoke(bContext *C, wmOperator *op, const wmEvent *
vpaint_stroke_done,
event->type);
+ SCULPT_undo_push_begin(CTX_data_active_object(C), "Vertex Paint");
+
if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) {
paint_stroke_free(C, op, (PaintStroke *)op->customdata);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
index 619607408e5..9380b165bc3 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
@@ -92,7 +92,9 @@ static int vertex_color_set_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
- uint paintcol = vpaint_get_current_col(scene, scene->toolsettings->vpaint, false);
+ float color[4];
+
+ uint paintcol = vpaint_get_current_col(scene, scene->toolsettings->vpaint, false, color);
if (vertex_color_set(obact, paintcol)) {
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obact);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_utils.hh b/source/blender/editors/sculpt_paint/paint_vertex_color_utils.hh
index ba000ac4f69..66d4ab87b4d 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_color_utils.hh
+++ b/source/blender/editors/sculpt_paint/paint_vertex_color_utils.hh
@@ -204,7 +204,7 @@ static Color mcol_mul(Color col_src, Color col_dst, typename Traits::BlendType f
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac;
+ Blend mfac;
Color col_mix(0, 0, 0, 0);
if (fac == 0) {
@@ -237,7 +237,7 @@ static Color mcol_lighten(Color col_src, Color col_dst, typename Traits::BlendTy
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac;
+ Blend mfac;
Color col_mix(0, 0, 0, 0);
if (fac == 0) {
@@ -274,7 +274,7 @@ static Color mcol_darken(Color col_src, Color col_dst, typename Traits::BlendTyp
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac;
+ Blend mfac;
Color col_mix(0, 0, 0, 0);
if (fac == 0) {
@@ -310,7 +310,7 @@ static Color mcol_colordodge(Color col_src, Color col_dst, typename Traits::Blen
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac, temp;
+ Blend mfac, temp;
Color col_mix(0, 0, 0, 0);
if (fac == 0) {
@@ -351,7 +351,7 @@ static Color mcol_difference(Color col_src, Color col_dst, typename Traits::Blen
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac, temp;
+ Blend mfac, temp;
Color col_mix(0, 0, 0, 0);
if (fac == 0) {
@@ -382,7 +382,7 @@ static Color mcol_screen(Color col_src, Color col_dst, typename Traits::BlendTyp
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac, temp;
+ Blend mfac, temp;
Color col_mix(0, 0, 0, 0);
if (fac == 0) {
@@ -421,7 +421,7 @@ static Color mcol_hardlight(Color col_src, Color col_dst, typename Traits::Blend
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac, temp;
+ Blend mfac, temp;
Color col_mix(0, 0, 0, 0);
if (fac == 0) {
@@ -456,7 +456,7 @@ static Color mcol_overlay(Color col_src, Color col_dst, typename Traits::BlendTy
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac, temp;
+ Blend mfac, temp;
Color col_mix(0, 0, 0, 0);
if (fac == 0) {
@@ -491,7 +491,7 @@ static Color mcol_softlight(Color col_src, Color col_dst, typename Traits::Blend
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac, temp;
+ Blend mfac, temp;
Color col_mix(0, 0, 0, 0);
if (fac == 0) {
@@ -527,7 +527,7 @@ static Color mcol_exclusion(Color col_src, Color col_dst, typename Traits::Blend
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac, temp;
+ Blend mfac, temp;
Color col_mix(0, 0, 0, 0);
if (fac == 0) {
@@ -558,7 +558,7 @@ static Color mcol_luminosity(Color col_src, Color col_dst, typename Traits::Blen
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac;
+ Blend mfac;
Color col_mix(0, 0, 0, 0);
if (fac == 0) {
@@ -605,7 +605,7 @@ static Color mcol_saturation(Color col_src, Color col_dst, typename Traits::Blen
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac;
+ Blend mfac;
Color col_mix(0, 0, 0, 0);
if (fac == 0) {
@@ -653,7 +653,7 @@ static Color mcol_hue(Color col_src, Color col_dst, typename Traits::BlendType f
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac;
+ Blend mfac;
Color col_mix(0, 0, 0, 0);
if (fac == 0) {
@@ -746,7 +746,7 @@ static Color mcol_pinlight(Color col_src, Color col_dst, typename Traits::BlendT
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac;
+ Blend mfac;
Color col_mix(0, 0, 0, 0);
if (fac == 0) {
@@ -786,7 +786,7 @@ static Color mcol_linearlight(Color col_src, Color col_dst, typename Traits::Ble
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac;
+ Blend mfac;
Color col_mix(0, 0, 0, 0);
if (fac == 0) {
@@ -803,7 +803,7 @@ static Color mcol_linearlight(Color col_src, Color col_dst, typename Traits::Ble
int i = 3;
while (i--) {
- int temp;
+ Blend temp;
if (cp_dst[i] > cmp) {
temp = Traits::min(cp_src[i] + 2 * (cp_dst[i] - cmp), Traits::range);
@@ -826,7 +826,7 @@ static Color mcol_vividlight(Color col_src, Color col_dst, typename Traits::Blen
using Blend = typename Traits::BlendType;
Value *cp_src, *cp_dst, *cp_mix;
- int mfac;
+ Blend mfac;
Color col_mix(0, 0, 0, 0);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list