GPv3: Merge by distance #113917
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
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#113917
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
Merge from selected/all points based on threshold value
GREASE_PENCIL_OT_stroke_merge_by_distance
ingrease_pencil_edit.cc
threshold
(int)retrieve_editable_drawings
)bke::CurvesGeometry &curves = drawing.strokes_for_write();
merge_indices
with the size of the points as well as a counter for the number of points to be merged for later.threading::parallel_for(curves.curves_range(), ...
ed::greasepencil::smooth_curve_attribute
)IndexMask::to_ranges()
distances
that computes the accumulated distance for every point to the first point (e.g. the fist point has a distance of 0, every next point has a distances of prev_distance + distance to previous point)KDTree_1d
for the distances (BLI_kdtree_1d_new
,BLI_kdtree_1d_insert
,BLI_kdtree_1d_balance
)BLI_kdtree_1d_calc_duplicates_fast
to find the points that need to be merged. The return value is the number of points that need to be merged, e.g. remove. Make sure to accumulate this count into the counter declared above so that we can calculate the size of the finalCurvesGeometry
.BLI_kdtree_1d_calc_duplicates_fast
intomerge_indices
. Make sure to use the correct offsets.CurvesGeometry
with the same number of curves and calculate the number of points (remaining after merges).merge_indicies
array (see logic inpoint_merge_by_distance.cc
) as well as aOffsetIndices<int> map_offsets
.bke::attribute_math::DefaultMixer<T> mixer
to mix the values for all the destination points. Use themap_offsets
to find the source points to mix the attributes from (There might only be one point if it just need to be copied, that's fine).I think the actual merging is fairly tricky here, at least doing it in a performant way.
The same behavior should be used as a geometry node (possibly the existing "Merge by Distance" node), that's something to keep in mind.
Rather than having an "unselected" toggle, IMO it would be simpler and clearer to just require selecting every point for that case. All it would require is first pressing "A".
After a discussion with @HooglyBoogly I edited the task to reflect the changes.
While solving this issue I got stuck at
Create an array distances that computes the accumulated distance for every point to the first point (e.g. the fist point has a distance of 0, every next point has a distances of prev_distance + distance to previous point)
How will I get the points and calculate distance for every selection range , could you give me an overview of how should I approach this and steps after this. Thank you.Hello. Is this task currently being worked on?
@Chao-Li We have a way of merging by distance in the simplify modifier now. I guess the same function could be used to implement the operator.
Let me take a look there. Thank you for the pointer!