GPv3: Split Stroke #113643

Open
opened 2023-10-13 08:22:44 +02:00 by Pratik Borhade · 5 comments
Member

Create a new stroke of selected points from a single stroke and remove previous points. Do this in same drawing.
This operator is specific to points mode.

  • Define operator GREASE_PENCIL_OT_stroke_split in grease_pencil_edit.cc
  • Iterate through all the drawings at current scene frame (foreach_editable_drawing)
    • Get geometry of current drawing: drawing.strokes_for_write();
    • Find selected points with the help of .selection attribute
    • Copy selected points are return it in new CurvesGeometry. (use: curves_copy_point_selection)
    • Delete selected points from current drawing: (#111571 is required)
    • Resize geometry at current drawing to include these new points and curves of new drawing: CurvesGeometry::resize()
    • Update offset and copy other attributes of new drawing in current drawing (maybe use bke::gather_attributes?)
Create a new stroke of selected points from a single stroke and remove previous points. Do this in same drawing. This operator is specific to points mode. - Define operator `GREASE_PENCIL_OT_stroke_split` in `grease_pencil_edit.cc` - Iterate through all the drawings at current scene frame (`foreach_editable_drawing`) - Get geometry of current drawing: `drawing.strokes_for_write();` - Find selected points with the help of `.selection` attribute - Copy selected points are return it in new CurvesGeometry. (use: `curves_copy_point_selection`) - Delete selected points from current drawing: (https://projects.blender.org/blender/blender/pulls/111571 is required) - Resize geometry at current drawing to include these new points and curves of new drawing: `CurvesGeometry::resize()` - Update offset and copy other attributes of new drawing in current drawing (maybe use `bke::gather_attributes`?)
Pratik Borhade added the
Priority
Normal
Module
Grease Pencil
Type
To Do
labels 2023-10-13 08:23:22 +02:00
Pratik Borhade added this to the Grease Pencil project 2023-10-13 08:23:46 +02:00
Member

I would suggest changing the steps a little bit to avoid allocating data more times than necessary. Avoiding .resize() is typically nice if we can know the final size before an allocation.

  • Calculate the total size of the new geometry after the deletion and addition
  • Create the new CurvesGeometry to contain the entire result
  • Copy the non-selected strokes/points into the beginning of the new curves
  • Copy the selected points to the end of the new curves
I would suggest changing the steps a little bit to avoid allocating data more times than necessary. Avoiding `.resize()` is typically nice if we can know the final size before an allocation. - Calculate the total size of the new geometry after the deletion and addition - Create the new CurvesGeometry to contain the entire result - Copy the non-selected strokes/points into the beginning of the new curves - Copy the selected points to the end of the new curves
Author
Member

@HooglyBoogly , thanks. I'm writing new task for GREASE_PENCIL_OT_stroke_separate so revisited this. I think curves_copy_point_selection won't help here. Because we expect to separate continuous selected points in new stroke. AFAICS this function don't create new stroke for continuous selected points.
I guess new steps could be:

  • Get selection attribute from source_geometry
  • Get continuous selected points: array_utils::find_all_ranges()
  • Create new CurvesGeometry (d_geom)
  • Write attributes, offset for unselected points
  • Write attributes, offset for selected points in d_geom (with the help of selection range and source_geometry)
@HooglyBoogly , thanks. I'm writing new task for `GREASE_PENCIL_OT_stroke_separate` so revisited this. I think `curves_copy_point_selection` won't help here. Because we expect to separate continuous selected points in new stroke. AFAICS this function don't create new stroke for continuous selected points. I guess new steps could be: - Get selection attribute from source_geometry - Get continuous selected points: `array_utils::find_all_ranges()` - Create new CurvesGeometry (d_geom) - Write attributes, offset for unselected points - Write attributes, offset for selected points in d_geom (with the help of selection range and source_geometry)
Member

Not sure how related it is, but I revisted an old patch for a split curves node too: #113926

Not sure how related it is, but I revisted an old patch for a split curves node too: #113926

Hi, I'd like to work on this if no one's already gotten to it.

Hi, I'd like to work on this if no one's already gotten to it.

#115842 should be ready to get looked at now

#115842 should be ready to get looked at now
Sign in to join this conversation.
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
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#113643
No description provided.