GPv3: Split Stroke #115842
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#115842
Loading…
Reference in New Issue
No description provided.
Delete Branch "arryemoji/blender:gpv3-stroke-split"
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?
Ports the split stroke operator to GPv3
Code mostly adapted from Delete and Duplicate operators
Resolves #113643
263b35dbfb
toae3246c69b
I have some higher level thoughts about this.
In summary, the
Split Strokes
operator will make sure all the point selection ranges within a stroke become their own stroke. This means thata) The number of points stays exactly the same and all the point attributes stay the same.
b) The number of curves/strokes changes so we need to change the
offsets
and propagate the curve attributes.So we don't need to recreate a new
CurvesGeometry
. We canresize
the existingCurvesGeometry
and only change the number of strokes.The
duplicate_points
function ingrease_pencil_edit.cc
is doing something similar. Note that for the duplicate operation we do need to add more points, which in the split case, we don't.I made changes here in case you hadn't seen @filedescriptor
Hi, I'm not sure why selected and unselected cases are handled separately. Would it not work if we just change the offset to separate strokes based on selection_range. I mean for each range_i , do
curve_counts.append(range.first())
andcurve_counts.append(range.last());
so we can have 3 strokes (old_curve_count = 1) in results when selection_range is 1I think I'll implement this roughly and share it here later
@PratikPB2123 I did want to combine the loops but wasn't sure how to do that. Your help is appreciated.
Did some changes in existing "duplicate operator" code and got this working.
Points we're going to split the curve at, are end points of each "selection range":
Following code adds the new offset values to the end of
new_curve_offsets
then reorders this span/array in ascending order.Feel free to try this.
I'm not sure whether this approach is correct. (@filedescriptor @HooglyBoogly knows better)
Something like this should work
I managed to get it down to one loop. I made a to_ranges function so I could have the one range and iterate only over that.
@ -587,0 +591,4 @@
/**
* Finds all the index ranges for consecutive values in \a span.
*/
template<typename T> inline Vector<IndexRange> to_ranges(const Span<T> span)
No need to reimplement this. Use
array_utils::find_all_ranges
(from here).I was using
array_utils::find_all_ranges
before, but it takes a value and only returns the ranges for indices equal to that value, so I had to have two ranges for selected and unselected points. I added this so I could get all the ranges at once and only need one loop.The structure looks good to me, I left some cleanup comments.
Would like @HooglyBoogly to take a look too.
@ -592,0 +705,4 @@
});
array_utils::copy(cyclic.as_span(), curves.cyclic_for_write());
curves.remove_attributes_based_on_types();
The types of the curves did not change, so this line can be removed.
@ -592,0 +707,4 @@
curves.remove_attributes_based_on_types();
return;
Remove
return
, not needed@ -592,0 +717,4 @@
Object *object = CTX_data_active_object(C);
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
const blender::bke::AttrDomain selection_domain = ED_grease_pencil_selection_domain_get(scene->toolsettings);
Looks like this is unused, can be removed.
@ -592,0 +723,4 @@
const Array<MutableDrawingInfo> drawings = retrieve_editable_drawings(*scene, grease_pencil);
threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
IndexMaskMemory memory;
const IndexMask mask = ed::greasepencil::retrieve_editable_and_selected_elements(
I believe this operator should only work in point selection mode? I that case this should just use
retrieve_editable_and_selected_points
@ -592,0 +751,4 @@
/* callbacks */
ot->exec = grease_pencil_stroke_split_exec;
ot->poll = editable_grease_pencil_poll;
->
editable_grease_pencil_point_selection_poll
While testing this PR locally, I noticed that when selecting the first point, then using the operator, it does not create a new stroke for that point.
Figured out what I did wrong. Fixed now.
The code for this looks generally fine now, one comment
@ -252,0 +252,4 @@
/**
* Finds all the index ranges for consecutive values in \a span.
*/
template<typename T> inline Vector<IndexRange> to_ranges(const Span<T> span)
I'd expect this to return
OffsetIndices<int>
, which would make this a bit better. Indexing intoOffsetIndices
withoperator[]
still gives you anIndexRange
so it shouldn't change the rest of your code :)I've done this. If there's a better way to handle the backing vector, please let me know. I couldn't find any other examples so I went this route. Thanks!
@ -408,0 +409,4 @@
/** \name Split Stroke Operator
* \{ */
static void split_points(bke::CurvesGeometry &curves, const IndexMask &mask)
It is this is not the same thing as
remove_points_and_split
?No,
remove_points_and_split
will remove points, this doesn't remove them. It creates new curves.But I agree, there are some overlapping things. Could be refactored at some point.
remove_points_and_split(mask)
+remove_points_and_split(!mask)
!=split_points(mask)
?I would argue
remove_points_and_split
=split_points
+curves_copy_point_selection
;)casey-bianco-davis referenced this pull request2024-02-06 21:49:19 +01:00
Checkout
From your project repository, check out a new branch and test the changes.