GPv3: Merge by distance Operator #120385

Open
Chao Li wants to merge 9 commits from Chao-Li/blender:merge-by-distance into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Contributor

The algorithm to merge points based on distance threshold has been implemented in 8b7d5f8587. This patch moves the function to blender::ed::greasepencil namespace and use it to implement merge by distance operator.

There are two parameters for the operator:
threshold: Distance threshold used for merging.
use_unselected: Use whole stroke or only selected points

Issue: #113917

The algorithm to merge points based on distance threshold has been implemented in 8b7d5f8587. This patch moves the function to blender::ed::greasepencil namespace and use it to implement merge by distance operator. There are two parameters for the operator: `threshold`: Distance threshold used for merging. `use_unselected`: Use whole stroke or only selected points Issue: #113917
Chao Li force-pushed merge-by-distance from 1182a86ff3 to 92c0becba1 2024-04-07 21:52:32 +02:00 Compare
Iliya Katushenock added this to the Grease Pencil project 2024-04-07 21:59:18 +02:00

Why this is not in geometry module?

Why this is not in geometry module?
Member

@mod_moder @HooglyBoogly was not in favor of putting it in the geometry module: #118616 (comment)

@mod_moder @HooglyBoogly was not in favor of putting it in the geometry module: https://projects.blender.org/blender/blender/pulls/118616#issuecomment-1130114
Chao Li force-pushed merge-by-distance from ace52265fd to d67b577f23 2024-04-08 20:49:55 +02:00 Compare
Falk David requested changes 2024-04-09 11:59:38 +02:00
Falk David left a comment
Member

Added some cleanup comments.

Added some cleanup comments.
@ -2436,0 +2445,4 @@
const float threshold = RNA_float_get(op->ptr, "threshold");
const bool use_unselected = RNA_boolean_get(op->ptr, "use_unselected");
bool changed = false;
Member

For correctness, this should be std::atomic<bool>.

For correctness, this should be `std::atomic<bool>`.
Chao-Li marked this conversation as resolved
@ -2436,0 +2451,4 @@
threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) {
bke::greasepencil::Drawing &drawing = info.drawing;
IndexMaskMemory memory;
IndexMask points = use_unselected ?
Member

const IndexMask

`const IndexMask`
Chao-Li marked this conversation as resolved
@ -2436,0 +2458,4 @@
if (points.is_empty()) {
return;
}
const bke::CurvesGeometry &curves = drawing.strokes();
Member

The curves variable is not needed. It's ok to pass drawing.strokes() to the merge by distance function.

The `curves` variable is not needed. It's ok to pass `drawing.strokes()` to the merge by distance function.
Chao-Li marked this conversation as resolved
Chao Li added 2 commits 2024-04-09 16:50:00 +02:00
Pratik Borhade reviewed 2024-04-11 12:06:34 +02:00
@ -8292,6 +8292,7 @@ class VIEW3D_MT_greasepencil_edit_context_menu(Menu):
col.separator()
col.operator("grease_pencil.stroke_merge_by_distance", text="Merge by Distance")
Member

Hi, Instead expose operator in clean up menu: VIEW3D_MT_edit_greasepencil_cleanup

(same as GPv2)

Hi, Instead expose operator in `clean up` menu: `VIEW3D_MT_edit_greasepencil_cleanup` (same as GPv2)
Author
Contributor

Hi. I updated the patch. Just to confirm, is "PAINT_GREASE_PENCIL" in the gpv3 the equivalent of "PAINT_GPENCIL" in gpv2?

Hi. I updated the patch. Just to confirm, is "PAINT_GREASE_PENCIL" in the gpv3 the equivalent of "PAINT_GPENCIL" in gpv2?
Member

Thanks.

is "PAINT_GREASE_PENCIL" in the gpv3 the equivalent of "PAINT_GPENCIL" in gpv2?

Yes, see: rna_enum_context_mode_items

Thanks. > is "PAINT_GREASE_PENCIL" in the gpv3 the equivalent of "PAINT_GPENCIL" in gpv2? Yes, see: `rna_enum_context_mode_items`
Chao-Li marked this conversation as resolved
Chao Li added 1 commit 2024-04-12 03:21:10 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
ed2c57f866
expose operator in `clean up` menu
Chao Li added 1 commit 2024-04-24 01:23:16 +02:00
Chao Li added 1 commit 2024-04-26 20:09:07 +02:00
This pull request has changes conflicting with the target branch.
  • source/blender/editors/grease_pencil/intern/grease_pencil_edit.cc

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u merge-by-distance:Chao-Li-merge-by-distance
git checkout Chao-Li-merge-by-distance
Sign in to join this conversation.
No reviewers
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#120385
No description provided.