Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2022-02-18 11:12:41 +0300
committerJacques Lucke <jacques@blender.org>2022-02-18 11:14:54 +0300
commit61aaeb3745ad72c681c17f4535dd06ffaaf78c58 (patch)
treec843b445e3e68938aa8c1f5f704dc55eb2be5c6d /source/blender/blenkernel
parent964d3a38fac8fd9ba90e6a94d26546f2d0651116 (diff)
Curves: initial brush system integration for curves sculpt mode
This adds the boilerplate code that is necessary to use the tool/brush/paint systems in the new sculpt curves mode. Two temporary dummy tools are part of this patch. They do nothing and only serve to test the boilerplate. When the first actual tool is added, those dummy tools will be removed. Differential Revision: https://developer.blender.org/D14117
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_paint.h4
-rw-r--r--source/blender/blenkernel/intern/paint.c24
-rw-r--r--source/blender/blenkernel/intern/paint_toolslots.c3
-rw-r--r--source/blender/blenkernel/intern/scene.c26
4 files changed, 56 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 1f37e95a023..8ab89b6c244 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -74,9 +74,11 @@ typedef enum ePaintMode {
PAINT_MODE_VERTEX_GPENCIL = 7,
PAINT_MODE_SCULPT_GPENCIL = 8,
PAINT_MODE_WEIGHT_GPENCIL = 9,
+ /** Curves. */
+ PAINT_MODE_SCULPT_CURVES = 10,
/** Keep last. */
- PAINT_MODE_INVALID = 10,
+ PAINT_MODE_INVALID = 11,
} ePaintMode;
#define PAINT_MODE_HAS_BRUSH(mode) !ELEM(mode, PAINT_MODE_SCULPT_UV)
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index ffd0a03fc51..d42c8ea37d5 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -327,6 +327,9 @@ bool BKE_paint_ensure_from_paintmode(Scene *sce, ePaintMode mode)
case PAINT_MODE_WEIGHT_GPENCIL:
paint_ptr = (Paint **)&ts->gp_weightpaint;
break;
+ case PAINT_MODE_SCULPT_CURVES:
+ paint_ptr = (Paint **)&ts->curves_sculpt;
+ break;
case PAINT_MODE_INVALID:
break;
}
@@ -362,6 +365,8 @@ Paint *BKE_paint_get_active_from_paintmode(Scene *sce, ePaintMode mode)
return &ts->gp_sculptpaint->paint;
case PAINT_MODE_WEIGHT_GPENCIL:
return &ts->gp_weightpaint->paint;
+ case PAINT_MODE_SCULPT_CURVES:
+ return &ts->curves_sculpt->paint;
case PAINT_MODE_INVALID:
return NULL;
default:
@@ -394,6 +399,8 @@ const EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode)
return rna_enum_brush_gpencil_sculpt_types_items;
case PAINT_MODE_WEIGHT_GPENCIL:
return rna_enum_brush_gpencil_weight_types_items;
+ case PAINT_MODE_SCULPT_CURVES:
+ return rna_enum_brush_curves_sculpt_tool_items;
case PAINT_MODE_INVALID:
break;
}
@@ -422,6 +429,8 @@ const char *BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode)
return "gpencil_sculpt_tool";
case PAINT_MODE_WEIGHT_GPENCIL:
return "gpencil_weight_tool";
+ case PAINT_MODE_SCULPT_CURVES:
+ return "curves_sculpt_tool";
case PAINT_MODE_INVALID:
break;
}
@@ -453,6 +462,8 @@ Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer)
return &ts->gp_sculptpaint->paint;
case OB_MODE_WEIGHT_GPENCIL:
return &ts->gp_weightpaint->paint;
+ case OB_MODE_SCULPT_CURVES:
+ return &ts->curves_sculpt->paint;
case OB_MODE_EDIT:
return ts->uvsculpt ? &ts->uvsculpt->paint : NULL;
default:
@@ -573,6 +584,8 @@ ePaintMode BKE_paintmode_get_from_tool(const struct bToolRef *tref)
return PAINT_MODE_SCULPT_GPENCIL;
case CTX_MODE_WEIGHT_GPENCIL:
return PAINT_MODE_WEIGHT_GPENCIL;
+ case CTX_MODE_SCULPT_CURVES:
+ return PAINT_MODE_SCULPT_CURVES;
}
}
else if (tref->space_type == SPACE_IMAGE) {
@@ -641,6 +654,10 @@ void BKE_paint_runtime_init(const ToolSettings *ts, Paint *paint)
paint->runtime.tool_offset = offsetof(Brush, gpencil_weight_tool);
paint->runtime.ob_mode = OB_MODE_WEIGHT_GPENCIL;
}
+ else if (ts->curves_sculpt && paint == &ts->curves_sculpt->paint) {
+ paint->runtime.tool_offset = offsetof(Brush, curves_sculpt_tool);
+ paint->runtime.ob_mode = OB_MODE_SCULPT_CURVES;
+ }
else {
BLI_assert_unreachable();
}
@@ -668,6 +685,8 @@ uint BKE_paint_get_brush_tool_offset_from_paintmode(const ePaintMode mode)
return offsetof(Brush, gpencil_sculpt_tool);
case PAINT_MODE_WEIGHT_GPENCIL:
return offsetof(Brush, gpencil_weight_tool);
+ case PAINT_MODE_SCULPT_CURVES:
+ return offsetof(Brush, curves_sculpt_tool);
case PAINT_MODE_INVALID:
break; /* We don't use these yet. */
}
@@ -1028,6 +1047,7 @@ bool BKE_paint_ensure(ToolSettings *ts, struct Paint **r_paint)
(Paint *)ts->vpaint,
(Paint *)ts->wpaint,
(Paint *)ts->uvsculpt,
+ (Paint *)ts->curves_sculpt,
(Paint *)&ts->imapaint));
#ifdef DEBUG
struct Paint paint_test = **r_paint;
@@ -1075,6 +1095,10 @@ bool BKE_paint_ensure(ToolSettings *ts, struct Paint **r_paint)
UvSculpt *data = MEM_callocN(sizeof(*data), __func__);
paint = &data->paint;
}
+ else if ((CurvesSculpt **)r_paint == &ts->curves_sculpt) {
+ CurvesSculpt *data = MEM_callocN(sizeof(*data), __func__);
+ paint = &data->paint;
+ }
else if (*r_paint == &ts->imapaint.paint) {
paint = &ts->imapaint.paint;
}
diff --git a/source/blender/blenkernel/intern/paint_toolslots.c b/source/blender/blenkernel/intern/paint_toolslots.c
index 04b70aae199..f35755021d2 100644
--- a/source/blender/blenkernel/intern/paint_toolslots.c
+++ b/source/blender/blenkernel/intern/paint_toolslots.c
@@ -98,6 +98,9 @@ void BKE_paint_toolslots_init_from_main(struct Main *bmain)
if (ts->gp_weightpaint) {
paint_toolslots_init_with_runtime(bmain, ts, &ts->gp_weightpaint->paint);
}
+ if (ts->curves_sculpt) {
+ paint_toolslots_init_with_runtime(bmain, ts, &ts->curves_sculpt->paint);
+ }
}
}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 7827c40e2c2..2eb4497aa0e 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -718,6 +718,16 @@ static void scene_foreach_toolsettings(LibraryForeachIDData *data,
reader,
&toolsett_old->gp_weightpaint->paint));
}
+ if (toolsett->curves_sculpt) {
+ BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS_FUNCTION_CALL(
+ data,
+ do_undo_restore,
+ scene_foreach_paint(data,
+ &toolsett->curves_sculpt->paint,
+ do_undo_restore,
+ reader,
+ &toolsett_old->curves_sculpt->paint));
+ }
BKE_LIB_FOREACHID_UNDO_PRESERVE_PROCESS_IDSUPER(data,
toolsett->gp_sculpt.guide.reference_object,
@@ -972,6 +982,10 @@ static void scene_blend_write(BlendWriter *writer, ID *id, const void *id_addres
BLO_write_struct(writer, GpWeightPaint, tos->gp_weightpaint);
BKE_paint_blend_write(writer, &tos->gp_weightpaint->paint);
}
+ if (tos->curves_sculpt) {
+ BLO_write_struct(writer, CurvesSculpt, tos->curves_sculpt);
+ BKE_paint_blend_write(writer, &tos->curves_sculpt->paint);
+ }
/* write grease-pencil custom ipo curve to file */
if (tos->gp_interpolate.custom_ipo) {
BKE_curvemapping_blend_write(writer, tos->gp_interpolate.custom_ipo);
@@ -1148,6 +1162,7 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id)
direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_vertexpaint);
direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_sculptpaint);
direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->gp_weightpaint);
+ direct_link_paint_helper(reader, sce, (Paint **)&sce->toolsettings->curves_sculpt);
BKE_paint_blend_read_data(reader, sce, &sce->toolsettings->imapaint.paint);
@@ -1406,6 +1421,9 @@ static void scene_blend_read_lib(BlendLibReader *reader, ID *id)
if (sce->toolsettings->gp_weightpaint) {
BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->gp_weightpaint->paint);
}
+ if (sce->toolsettings->curves_sculpt) {
+ BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->curves_sculpt->paint);
+ }
if (sce->toolsettings->sculpt) {
BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->sculpt->gravity_object);
@@ -1726,6 +1744,10 @@ ToolSettings *BKE_toolsettings_copy(ToolSettings *toolsettings, const int flag)
ts->gp_weightpaint = MEM_dupallocN(ts->gp_weightpaint);
BKE_paint_copy(&ts->gp_weightpaint->paint, &ts->gp_weightpaint->paint, flag);
}
+ if (ts->curves_sculpt) {
+ ts->curves_sculpt = MEM_dupallocN(ts->curves_sculpt);
+ BKE_paint_copy(&ts->curves_sculpt->paint, &ts->curves_sculpt->paint, flag);
+ }
BKE_paint_copy(&ts->imapaint.paint, &ts->imapaint.paint, flag);
ts->particle.paintcursor = NULL;
@@ -1781,6 +1803,10 @@ void BKE_toolsettings_free(ToolSettings *toolsettings)
BKE_paint_free(&toolsettings->gp_weightpaint->paint);
MEM_freeN(toolsettings->gp_weightpaint);
}
+ if (toolsettings->curves_sculpt) {
+ BKE_paint_free(&toolsettings->curves_sculpt->paint);
+ MEM_freeN(toolsettings->curves_sculpt);
+ }
BKE_paint_free(&toolsettings->imapaint.paint);
/* free Grease Pencil interpolation curve */