GPv3: Join Strokes #113570

Closed
opened 2023-10-12 07:45:11 +02:00 by Pratik Borhade · 4 comments
Member

Join selected strokes

  • Define GREASE_PENCIL_OT_stroke_join operator in grease_pencil_edit.cc
  • For first selected stroke: create pointers to reference first_curve_index and layer-drawing.
  • Iterate through all the drawings at current scene frame (retrieve_editable_drawings)
    • Get geometry of this drawing: bke::CurvesGeometry &curves = drawing.strokes_for_write();
    • Check whether point/stroke is selected and identify index of selected curve
    • If pointers of first selected stroke are null, reference them.
    • Else: include these stroke-points at the end of first_selected_curve
      • Get geometry where first selected curve belongs: curves = drawing.strokes_for_write();
      • resize geometry of first selected curve: curves.resize()
      • Update the offset value of first selected curve (eventually need to update offset value of complete geometry)
      • Update position attribute

For reference:
see legacy GP operator: GPENCIL_OT_stroke_join
Also see other grease_pencil_* files

Join selected strokes - Define `GREASE_PENCIL_OT_stroke_join` operator in `grease_pencil_edit.cc` - For first selected stroke: create pointers to reference `first_curve_index` and layer-drawing. - Iterate through all the drawings at current scene frame (`retrieve_editable_drawings`) - Get geometry of this drawing: `bke::CurvesGeometry &curves = drawing.strokes_for_write();` - Check whether point/stroke is selected and identify index of selected curve - If pointers of first selected stroke are null, reference them. - Else: include these stroke-points at the end of first_selected_curve - Get geometry where first selected curve belongs: `curves = drawing.strokes_for_write();` - resize geometry of first selected curve: `curves.resize()` - Update the offset value of first selected curve (eventually need to update offset value of complete geometry) - Update position attribute For reference: see legacy GP operator: `GPENCIL_OT_stroke_join` Also see other `grease_pencil_*` files
Pratik Borhade added the
Status
Needs Triage
Type
Report
Priority
Normal
labels 2023-10-12 07:45:12 +02:00
Pratik Borhade added this to the Grease Pencil project 2023-10-12 12:08:36 +02:00
Pratik Borhade added
Type
To Do
and removed
Status
Needs Triage
Type
Report
labels 2023-10-12 12:49:49 +02:00
Pratik Borhade added the
Module
Grease Pencil
label 2023-10-12 13:30:58 +02:00
Member

@Nicolas-Mayora is giving this a shot.

@Nicolas-Mayora is giving this a shot.

After a quick discussion on the #grease-pencil-module channel, @filedescriptor came up with the following (high-level-ish) implementation:

  • Find all selected strokes and extract their end-points. (1)
  • Add them all to a KDTree_3d using BLI_kdtree_3d_insert.
  • For each point obtained in (1), let it be x:
    • Use BLI_kdtree_3d_find_nearest_n to get x's two nearest neighbours.
      • We need to get the two closest in case the closest is from x's own stroke, in which case, we discard it.
    • Create an edge between x with its closest (valid) neighbour.
    • Remove x and it's new neighbour from the KDTree.
After a quick discussion on the #grease-pencil-module channel, @filedescriptor came up with the following (high-level-ish) implementation: - Find all selected strokes and extract their end-points. (1) - Add them all to a `KDTree_3d` using `BLI_kdtree_3d_insert`. - For each point obtained in (1), let it be `x`: - Use `BLI_kdtree_3d_find_nearest_n` to get `x`'s two nearest neighbours. - We need to get the _two_ closest in case _the_ closest is from `x`'s own stroke, in which case, we discard it. - Create an edge between `x` with its closest (valid) neighbour. - Remove `x` and it's new neighbour from the KDTree.
Member

@Nicolas-Mayora there's another thing that's potentially important that is we need to consider the direction of how we join strokes, so that we can avoid zig-zagging in the result, which is also sometimes a nasty problem in line art chaining algorithm.

line art does have the 2d tile-based acceleration method. Maybe that can be used.

@Nicolas-Mayora there's another thing that's potentially important that is we need to consider the direction of how we join strokes, so that we can avoid zig-zagging in the result, which is also sometimes a nasty problem in line art chaining algorithm. line art does have the 2d tile-based acceleration method. Maybe that can be used.
Member

The "Join Strokes" operator seems to duplicate logic in the "Merge Points" operator. So the #116726: GPv3: Merge Points PR will replace this one.

The "Join Strokes" operator seems to duplicate logic in the "Merge Points" operator. So the [#116726: GPv3: Merge Points](https://projects.blender.org/blender/blender/pulls/116726) PR will replace this one.
Blender Bot added the
Status
Archived
label 2024-01-23 11:20:26 +01:00
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
4 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#113570
No description provided.