forked from blender/blender
WIP: uv-simple-select #1
@ -23,6 +23,7 @@ set(INC
|
|||||||
set(SRC
|
set(SRC
|
||||||
intern/curves_add.cc
|
intern/curves_add.cc
|
||||||
intern/curves_data.cc
|
intern/curves_data.cc
|
||||||
|
intern/curves_edit.cc
|
||||||
intern/curves_ops.cc
|
intern/curves_ops.cc
|
||||||
intern/curves_selection.cc
|
intern/curves_selection.cc
|
||||||
intern/curves_undo.cc
|
intern/curves_undo.cc
|
||||||
|
38
source/blender/editors/curves/intern/curves_edit.cc
Normal file
38
source/blender/editors/curves/intern/curves_edit.cc
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \ingroup edcurves
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "BLI_index_mask_ops.hh"
|
||||||
|
|
||||||
|
#include "BKE_curves.hh"
|
||||||
|
|
||||||
|
#include "ED_curves.h"
|
||||||
|
|
||||||
|
namespace blender::ed::curves {
|
||||||
|
|
||||||
|
bool remove_selection(bke::CurvesGeometry &curves, const eAttrDomain selection_domain)
|
||||||
|
{
|
||||||
|
const bke::AttributeAccessor attributes = curves.attributes();
|
||||||
|
const VArray<bool> selection = attributes.lookup_or_default<bool>(
|
||||||
|
".selection", selection_domain, true);
|
||||||
|
const int domain_size_orig = attributes.domain_size(selection_domain);
|
||||||
|
Vector<int64_t> indices;
|
||||||
|
const IndexMask mask = index_mask_ops::find_indices_from_virtual_array(
|
||||||
|
selection.index_range(), selection, 4096, indices);
|
||||||
|
switch (selection_domain) {
|
||||||
|
case ATTR_DOMAIN_POINT:
|
||||||
|
curves.remove_points(mask);
|
||||||
|
break;
|
||||||
|
case ATTR_DOMAIN_CURVE:
|
||||||
|
curves.remove_curves(mask);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
BLI_assert_unreachable();
|
||||||
|
}
|
||||||
|
|
||||||
|
return attributes.domain_size(selection_domain) != domain_size_orig;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace blender::ed::curves
|
@ -1097,24 +1097,7 @@ static int delete_exec(bContext *C, wmOperator * /*op*/)
|
|||||||
{
|
{
|
||||||
for (Curves *curves_id : get_unique_editable_curves(*C)) {
|
for (Curves *curves_id : get_unique_editable_curves(*C)) {
|
||||||
bke::CurvesGeometry &curves = curves_id->geometry.wrap();
|
bke::CurvesGeometry &curves = curves_id->geometry.wrap();
|
||||||
const eAttrDomain domain = eAttrDomain(curves_id->selection_domain);
|
if (remove_selection(curves, eAttrDomain(curves_id->selection_domain))) {
|
||||||
const bke::AttributeAccessor attributes = curves.attributes();
|
|
||||||
const VArray<bool> selection = attributes.lookup_or_default<bool>(".selection", domain, false);
|
|
||||||
const int domain_size_orig = attributes.domain_size(domain);
|
|
||||||
Vector<int64_t> indices;
|
|
||||||
const IndexMask mask = index_mask_ops::find_indices_from_virtual_array(
|
|
||||||
selection.index_range(), selection, 4096, indices);
|
|
||||||
switch (domain) {
|
|
||||||
case ATTR_DOMAIN_POINT:
|
|
||||||
curves.remove_points(mask);
|
|
||||||
break;
|
|
||||||
case ATTR_DOMAIN_CURVE:
|
|
||||||
curves.remove_curves(mask);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
BLI_assert_unreachable();
|
|
||||||
}
|
|
||||||
if (attributes.domain_size(domain) != domain_size_orig) {
|
|
||||||
DEG_id_tag_update(&curves_id->id, ID_RECALC_GEOMETRY);
|
DEG_id_tag_update(&curves_id->id, ID_RECALC_GEOMETRY);
|
||||||
WM_event_add_notifier(C, NC_GEOM | ND_DATA, curves_id);
|
WM_event_add_notifier(C, NC_GEOM | ND_DATA, curves_id);
|
||||||
}
|
}
|
||||||
|
@ -185,5 +185,17 @@ bool select_circle(const ViewContext &vc,
|
|||||||
eSelectOp sel_op);
|
eSelectOp sel_op);
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/** \name Editing
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove (dissolve) selected curves or points based on the ".selection" attribute.
|
||||||
|
* \returns true if any point or curve was removed.
|
||||||
|
*/
|
||||||
|
bool remove_selection(bke::CurvesGeometry &curves, eAttrDomain selection_domain);
|
||||||
|
|
||||||
|
/** \} */
|
||||||
|
|
||||||
} // namespace blender::ed::curves
|
} // namespace blender::ed::curves
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user