[Bf-blender-cvs] [416aef4e13c] master: Curves: New tools for curves sculpt mode.
Jacques Lucke
noreply at git.blender.org
Thu Jun 30 15:10:09 CEST 2022
Commit: 416aef4e13ccc30e82ecaa691f26af54dbd5ee7e
Author: Jacques Lucke
Date: Thu Jun 30 15:09:13 2022 +0200
Branches: master
https://developer.blender.org/rB416aef4e13ccc30e82ecaa691f26af54dbd5ee7e
Curves: New tools for curves sculpt mode.
This commit contains various new features for curves sculpt mode
that have been developed in parallel.
* Selection:
* Operator to select points/curves randomly.
* Operator to select endpoints of curves.
* Operator to grow/shrink an existing selection.
* New Brushes:
* Pinch: Moves points towards the brush center.
* Smooth: Makes individual curves straight without changing the root
or tip position.
* Puff: Makes curves stand up, aligning them with the surface normal.
* Density: Add or remove curves to achieve a certain density defined
by a minimum distance value.
* Slide: Move root points on the surface.
Differential Revision: https://developer.blender.org/D15134
===================================================================
M release/scripts/presets/keyconfig/keymap_data/blender_default.py
M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M release/scripts/startup/bl_ui/space_view3d.py
M source/blender/blenkernel/intern/brush.c
M source/blender/blenloader/intern/versioning_300.c
M source/blender/editors/curves/CMakeLists.txt
M source/blender/editors/curves/intern/curves_ops.cc
M source/blender/editors/include/ED_curves.h
M source/blender/editors/sculpt_paint/CMakeLists.txt
A source/blender/editors/sculpt_paint/curves_sculpt_density.cc
M source/blender/editors/sculpt_paint/curves_sculpt_intern.hh
M source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
A source/blender/editors/sculpt_paint/curves_sculpt_pinch.cc
A source/blender/editors/sculpt_paint/curves_sculpt_puff.cc
A source/blender/editors/sculpt_paint/curves_sculpt_slide.cc
A source/blender/editors/sculpt_paint/curves_sculpt_smooth.cc
M source/blender/editors/sculpt_paint/paint_stroke.c
M source/blender/makesdna/DNA_brush_enums.h
M source/blender/makesdna/DNA_brush_types.h
M source/blender/makesrna/intern/rna_brush.c
===================================================================
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 623ca2340d1..d12d68ee5a0 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -5624,6 +5624,7 @@ def km_sculpt_curves(params):
("curves.disable_selection", {"type": 'TWO', "value": 'PRESS', "alt": True}, None),
*_template_paint_radial_control("curves_sculpt"),
*_template_items_select_actions(params, "sculpt_curves.select_all"),
+ ("sculpt_curves.min_distance_edit", {"type": 'R', "value": 'PRESS', "shift": True}, {}),
])
return keymap
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 5831aa52cc1..9f7ca89b8c9 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -2377,6 +2377,51 @@ class _defs_curves_sculpt:
data_block='GROW_SHRINK'
)
+ @ToolDef.from_fn
+ def pinch():
+ return dict(
+ idname="builtin_brush.pinch",
+ label="Pinch",
+ icon="ops.curves.sculpt_pinch",
+ data_block='PINCH'
+ )
+
+ @ToolDef.from_fn
+ def smooth():
+ return dict(
+ idname="builtin_brush.smooth",
+ label="Smooth",
+ icon="ops.curves.sculpt_smooth",
+ data_block='SMOOTH'
+ )
+
+ @ToolDef.from_fn
+ def puff():
+ return dict(
+ idname="builtin_brush.puff",
+ label="Puff",
+ icon="ops.curves.sculpt_puff",
+ data_block='PUFF'
+ )
+
+ @ToolDef.from_fn
+ def density():
+ return dict(
+ idname="builtin_brush.density",
+ label="Density",
+ icon="ops.curves.sculpt_density",
+ data_block="DENSITY"
+ )
+
+ @ToolDef.from_fn
+ def slide():
+ return dict(
+ idname="builtin_brush.slide",
+ label="Slide",
+ icon="ops.curves.sculpt_slide",
+ data_block="SLIDE"
+ )
+
class _defs_gpencil_vertex:
@@ -3140,6 +3185,11 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
_defs_curves_sculpt.delete,
_defs_curves_sculpt.snake_hook,
_defs_curves_sculpt.grow_shrink,
+ _defs_curves_sculpt.pinch,
+ _defs_curves_sculpt.smooth,
+ _defs_curves_sculpt.puff,
+ _defs_curves_sculpt.density,
+ _defs_curves_sculpt.slide,
None,
*_tools_annotate,
],
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 411bad65991..c2342e8949a 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -535,6 +535,31 @@ class _draw_tool_settings_context_mode:
layout.prop(brush, "direction", expand=True, text="")
layout.prop(brush, "falloff_shape", expand=True)
layout.popover("VIEW3D_PT_tools_brush_falloff")
+ elif curves_tool == 'PINCH':
+ layout.prop(brush, "direction", expand=True, text="")
+ layout.prop(brush, "falloff_shape", expand=True)
+ layout.popover("VIEW3D_PT_tools_brush_falloff")
+ elif curves_tool == 'SMOOTH':
+ layout.prop(brush, "falloff_shape", expand=True)
+ layout.popover("VIEW3D_PT_tools_brush_falloff")
+ elif curves_tool == 'PUFF':
+ layout.prop(brush, "falloff_shape", expand=True)
+ layout.popover("VIEW3D_PT_tools_brush_falloff")
+ elif curves_tool == 'DENSITY':
+ layout.prop(brush, "falloff_shape", expand=True)
+ row = layout.row(align=True)
+ row.prop(brush.curves_sculpt_settings, "density_mode", text="", expand=True)
+ row = layout.row(align=True)
+ row.prop(brush.curves_sculpt_settings, "minimum_distance")
+ row.operator_context = 'INVOKE_REGION_WIN'
+ row.operator("sculpt_curves.min_distance_edit", text="", icon='DRIVER_DISTANCE')
+ row = layout.row(align=True)
+ row.enabled = brush.curves_sculpt_settings.density_mode != 'REMOVE'
+ row.prop(brush.curves_sculpt_settings, "density_add_attempts", text="Max Count")
+ layout.popover("VIEW3D_PT_tools_brush_falloff")
+ layout.popover("VIEW3D_PT_curves_sculpt_add_shape", text="Curve Shape")
+ elif curves_tool == "SLIDE":
+ layout.popover("VIEW3D_PT_tools_brush_falloff")
class VIEW3D_HT_header(Header):
@@ -2005,6 +2030,9 @@ class VIEW3D_MT_select_sculpt_curves(Menu):
layout.operator("sculpt_curves.select_all", text="All").action = 'SELECT'
layout.operator("sculpt_curves.select_all", text="None").action = 'DESELECT'
layout.operator("sculpt_curves.select_all", text="Invert").action = 'INVERT'
+ layout.operator("sculpt_curves.select_random", text="Random")
+ layout.operator("sculpt_curves.select_end", text="Endpoints")
+ layout.operator("sculpt_curves.select_grow", text="Grow")
class VIEW3D_MT_angle_control(Menu):
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 1cda0e8a4bb..dd38af126fe 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -1562,6 +1562,7 @@ void BKE_brush_init_curves_sculpt_settings(Brush *brush)
settings->points_per_curve = 8;
settings->minimum_length = 0.01f;
settings->curve_length = 0.3f;
+ settings->density_add_attempts = 100;
}
struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode ob_mode)
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 68df560a389..35b1367ca1e 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -3243,5 +3243,13 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
*/
{
/* Keep this block, even when empty. */
+
+ /* Initialize brush curves sculpt settings. */
+ LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
+ if (brush->ob_mode != OB_MODE_SCULPT_CURVES) {
+ continue;
+ }
+ brush->curves_sculpt_settings->density_add_attempts = 100;
+ }
}
}
diff --git a/source/blender/editors/curves/CMakeLists.txt b/source/blender/editors/curves/CMakeLists.txt
index 3c31e8014ff..303d2fb71dc 100644
--- a/source/blender/editors/curves/CMakeLists.txt
+++ b/source/blender/editors/curves/CMakeLists.txt
@@ -8,6 +8,7 @@ set(INC
../../depsgraph
../../functions
../../geometry
+ ../../gpu
../../makesdna
../../makesrna
../../windowmanager
@@ -27,5 +28,17 @@ set(LIB
bf_blenlib
)
+if(WITH_TBB)
+ list(APPEND INC_SYS
+ ${TBB_INCLUDE_DIRS}
+ )
+ add_definitions(-DWITH_TBB)
+ if(WIN32)
+ # TBB includes Windows.h which will define min/max macros
+ # that will collide with the stl versions.
+ add_definitions(-DNOMINMAX)
+ endif()
+endif()
+
blender_add_lib(bf_editor_curves "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
add_dependencies(bf_editor_curves bf_rna)
diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc
index 25bcba6cfb3..dd7edf66920 100644
--- a/source/blender/editors/curves/intern/curves_ops.cc
+++ b/source/blender/editors/curves/intern/curves_ops.cc
@@ -72,7 +72,7 @@ static bool object_has_editable_curves(const Main &bmain, const Object &object)
return true;
}
-static VectorSet<Curves *> get_unique_editable_curves(const bContext &C)
+VectorSet<Curves *> get_unique_editable_curves(const bContext &C)
{
VectorSet<Curves *> unique_curves;
@@ -715,7 +715,7 @@ static void CURVES_OT_snap_curves_to_surface(wmOperatorType *ot)
"How to find the point on the surface to attach to");
}
-static bool selection_poll(bContext *C)
+bool selection_operator_poll(bContext *C)
{
const Object *object = CTX_data_active_object(C);
if (object == nullptr) {
@@ -784,7 +784,7 @@ static void CURVES_OT_set_selection_domain(wmOperatorType *ot)
ot->description = "Change the mode used for selection masking in curves sculpt mode";
ot->exec = set_selection_domain::curves_set_selection_domain_exec;
- ot->poll = selection_poll;
+ ot->poll = selection_operator_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -820,13 +820,11 @@ static void CURVES_OT_disable_selection(wmOperatorType *ot)
ot->description = "Disable the drawing of influence of selection in sculpt mode";
ot->exec = disable_selection::curves_disable_selection_exec;
- ot->poll = selection_poll;
+ ot->poll = selection_operator_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-namespace select_all {
-
static bool varray_contains_nonzero(const VArray<float> &data)
{
bool contains_nonzero = false;
@@ -841,6 +839,19 @@ static bool varray_contains_nonzero(const VArray<float> &data)
return contains_nonzero;
}
+bool has_anything_selected(const Curves &curves_id)
+{
+ const CurvesGeometry &curves = CurvesGeometry::wrap(curves_id.geometry);
+ switch (curves_id.selection_domain) {
+ case ATTR_DOMAIN_POINT:
+ return varray_contains_nonzero(curves.selection_point_float());
+ case ATTR_DOMAIN_CURVE:
+ return varray_contains_nonzero(curves.selection_curve_float());
+ }
+ BLI_assert_unreachable();
+ return false;
+}
+
static bool any_point_selected(const CurvesGeometry &curves)
{
return varray_contains_nonzero(curves.selection_point_float());
@@ -856,6 +867,8 @@ static bool any_point_selected(const Span<Curves *> curves_ids)
return false;
}
+namespace select_all {
+
static void invert_selection(MutableSpan<float> selection)
{
threading::parallel_for(selection.index_range(), 2048, [&](IndexRange range) {
@@ -924,7 +937,7 @@ static void SCULPT_CURVES_OT_select_all(wmOperatorType *o
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list