diff options
author | Jacques Lucke <jacques@blender.org> | 2022-06-30 16:09:13 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-06-30 16:09:13 +0300 |
commit | 416aef4e13ccc30e82ecaa691f26af54dbd5ee7e (patch) | |
tree | a4f8e3b96e01031e5f8049b48043ed3208bfe168 /source/blender/editors/curves/intern/curves_ops.cc | |
parent | 0f22b5599a03d5ce61450528c74ad2f2e47cf913 (diff) |
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
Diffstat (limited to 'source/blender/editors/curves/intern/curves_ops.cc')
-rw-r--r-- | source/blender/editors/curves/intern/curves_ops.cc | 27 |
1 files changed, 20 insertions, 7 deletions
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 *ot) ot->description = "(De)select all control points"; ot->exec = select_all::select_all_exec; - ot->poll = selection_poll; + ot->poll = selection_operator_poll; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; |