GPv3: Delete operator #111571
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#111571
Loading…
Reference in New Issue
No description provided.
Delete Branch "casey-bianco-davis/blender:GPv3-delete"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds the delete operator to edit mode grease pencil, and also adds it to the delete menu.
Hi, please, just use already exist code of points delete from Delete Geometry node for curve geometry (see:
source\blender\nodes\geometry\nodes\node_geo_delete_geometry.cc
,separate_curves_selection
) (you can move it tosource\blender\geometry
as shared geometry function).EDIT: Even more than that, you just need to call
bke::curves_copy_point_selection
.Hi @mod_moder if I am not mistaken
bke::curves_copy_point_selection
does not break the strokes into separate parts. and behaves like dissolve. where as this will break up the curves.Well, actually, i'm not sure if you're supposed to split curves by removing points.
There is the
Dissolve
operator does not split the curves (#111079), but in the legacy grease pencil system there is a operator calleddelete
(accessed by the menu that opens with 'x') that remove the points while breaking the curve into separate segments.@ -561,0 +579,4 @@
{0, nullptr, 0, nullptr, nullptr},
};
static bke::CurvesGeometry delete_points(const bke::CurvesGeometry &curves,
I think we should name this something like
remove_points_and_split
.@ -561,0 +579,4 @@
{0, nullptr, 0, nullptr, nullptr},
};
static bke::CurvesGeometry remove_points_and_split(const bke::CurvesGeometry &curves,
I guess it would be better to move this function in
curves_geometry.cc
Falk/Hans ^
Maybe at some point, but since
Curves
don't have this functionality at the moment, it's fine to be a static function here.Thank you for working on this! Some initial comments :)
@ -561,0 +562,4 @@
/** \name Delete Operator
* \{ */
enum class DeleteMode {
I think we shouldn't have this property on the operator.
The operator should delete points vs strokes depending on the selection mode.
@ -561,0 +688,4 @@
bool changed = false;
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [&](int /*drawing_index*/, bke::greasepencil::Drawing &drawing) {
In
main
theforeach_editable_drawing
drawing function changed. This now gives alayer_index
instead of thedrawing_index
, so the parameter should be renamed (not that it matters for the logic of the code below).I did a pass together with Hans on this. Here are some comments
@ -564,0 +566,4 @@
* \{ */
static bke::CurvesGeometry remove_points_and_split(const bke::CurvesGeometry &curves,
const VArray<bool> selection)
Should be
const VArray<bool> &selection
. Avoids some smallish overhead when copying theVArray
.@ -564,0 +570,4 @@
{
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
const VArray<bool> src_cyclic = curves.cyclic();
const Span<bool> points_to_delete = selection.get_internal_span();
Although the selection is usually a span, this call can still fail. This should use
VArraySpan<bool>
.@ -564,0 +595,4 @@
IndexRange first_range = ranges_to_keep.first().shift(points.first());
IndexRange last_range = ranges_to_keep.last().shift(points.first());
const bool is_last_segment_selected = first_range.first() == points.first() &&
Since it looks like we're only using
first_range
andlast_range
once, we can write it like this:const bool is_last_segment_selected = curve_cyclic && ranges_to_keep.first().first() == 0 && ranges_to_keep.last().last() == points.size() - 1;
@ -564,0 +601,4 @@
const bool is_cyclic = ranges_to_keep.size() == 1 && is_last_segment_selected;
IndexRange range_ids = ranges_to_keep.index_range();
for (const int range_id : range_ids) {
Usually we like to name the iterator
thing_i
. Also we can skip over the first element usingdrop_front
:for (const int range_i : ranges_to_keep.index_range().drop_front(is_curve_self_joined)) {
@ -564,0 +676,4 @@
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [&](int /*layer_index*/, bke::greasepencil::Drawing &drawing) {
bke::CurvesGeometry &curves = drawing.strokes_for_write();
if (curves.points_num() == 0) {
With the
ed::curves::has_anything_selected(curves)
check below, this check is not necessary.@ -564,0 +688,4 @@
blender::ed::curves::select_linked(curves);
}
const VArray<bool> selection = *curves.attributes().lookup_or_default<bool>(
This should use
ed::curves::retrieve_selected_curves
in the case ofATTR_DOMAIN_CURVE
. This also means theselect_linked
above is not necessary.@ -564,0 +714,4 @@
/* Identifiers. */
ot->name = "Delete";
ot->idname = "GREASE_PENCIL_OT_delete";
ot->description = "Delete selected Grease Pencil strokes or points";
"Delete selected strokes or points"
This is pretty much ready to go. One last comment.
@ -564,0 +641,4 @@
const bke::AttributeAccessor src_attributes = curves.attributes();
/* Transfer curve attributes. */
for (bke::AttributeTransferData &attribute : bke::retrieve_attributes_for_transfer(
There is a new API that we can use here:
bke::gather_attributes
(the one with theSpan<int> indices
parameter).@ -564,0 +651,4 @@
array_utils::copy(dst_cyclic.as_span(), dst_curves.cyclic_for_write());
/* Transfer point attributes. */
for (bke::AttributeTransferData &attribute : bke::retrieve_attributes_for_transfer(
Same as above.
Thanks for the patience :) I'll merge this now.