GPv3: Simplify modifier #118546

Merged
YimingWu merged 18 commits from ChengduLittleA/blender:gp3-mod-simplify into main 2024-03-28 15:18:42 +01:00
Member

Implements the simplify modifier from GPv2.

Implements the simplify modifier from GPv2.
YimingWu added the
Module
Grease Pencil
label 2024-02-21 09:12:53 +01:00
YimingWu added 1 commit 2024-02-21 09:12:58 +01:00
YimingWu added this to the Grease Pencil project 2024-02-21 09:13:08 +01:00
Falk David reviewed 2024-02-21 12:02:37 +01:00
@ -0,0 +90,4 @@
switch (mmd.mode) {
case MOD_GREASE_PENCIL_SIMPLIFY_FIXED: {
for (int i = 0; i < mmd.step; i++) {
Member

Seems like this would use geometry::resample_to_count

Seems like this would use `geometry::resample_to_count`
ChengduLittleA marked this conversation as resolved
@ -0,0 +102,4 @@
}
case MOD_GREASE_PENCIL_SIMPLIFY_SAMPLE: {
//geometry::resample_to_length(drawing.strokes(),field_context,
//BKE_gpencil_stroke_sample(gpd, gps, mmd->length, false, mmd->sharp_threshold);
Member

and this would use geometry::resample_to_length

and this would use `geometry::resample_to_length`
filedescriptor marked this conversation as resolved
@ -0,0 +106,4 @@
break;
}
case MOD_GREASE_PENCIL_SIMPLIFY_MERGE: {
//BKE_gpencil_stroke_merge_distance(gpd, gpf, gps, mmd->distance, true);
Member

This one will be tricky...

This one will be tricky...
Author
Member

This doesn't connect multiple strokes, it only merges points inside one stroke it seems, so may not be that complicated eventually... But I'm not sure.

This doesn't connect multiple strokes, it only merges points inside one stroke it seems, so may not be that complicated eventually... But I'm not sure.
Member

Stil, we'd need a version of point_merge_by_distance for curves.

Stil, we'd need a version of `point_merge_by_distance` for curves.
filedescriptor marked this conversation as resolved
YimingWu force-pushed gp3-mod-simplify from e739f875bf to b1e3bd13c7 2024-02-21 13:35:42 +01:00 Compare
YimingWu added 1 commit 2024-02-21 15:03:34 +01:00
YimingWu added 1 commit 2024-02-26 06:18:59 +01:00
YimingWu added 3 commits 2024-02-29 14:09:08 +01:00
YimingWu added 1 commit 2024-02-29 14:50:57 +01:00
Falk David requested changes 2024-02-29 15:11:47 +01:00
Dismissed
Falk David left a comment
Member

Some comments

Some comments
@ -0,0 +80,4 @@
bke::greasepencil::Drawing &drawing)
{
IndexMaskMemory memory;
bke::CurvesGeometry curves = drawing.strokes_for_write();
Member

Make this const bke::CurvesGeometry &curves = drawing.strokes();
Then to write to the curves geometry use drawing.strokes_for_write() = std::move(...);

Make this `const bke::CurvesGeometry &curves = drawing.strokes();` Then to write to the curves geometry use `drawing.strokes_for_write() = std::move(...);`
ChengduLittleA marked this conversation as resolved
@ -0,0 +94,4 @@
const OffsetIndices points_by_curve = curves.points_by_curve();
Array<int> target_count(curves.curves_num());
strokes.foreach_index(GrainSize(4096), [&](const int i) {
target_count[i] = math::round(float(points_by_curve[i].size()) / 2.0f + 0.5);
Member

just use

target_count[i] = math::max(int(math::round(float(points_by_curve[i].size()) /
                                                    math::pow(2.0f, float(mmd.step - 1)))),
                                    2);

and get rid of the outer loop.

just use ``` target_count[i] = math::max(int(math::round(float(points_by_curve[i].size()) / math::pow(2.0f, float(mmd.step - 1)))), 2); ``` and get rid of the outer loop.
Author
Member

this is probably different than doing it step by step

this is probably different than doing it step by step
filedescriptor marked this conversation as resolved
YimingWu added 1 commit 2024-02-29 15:24:26 +01:00
YimingWu added 1 commit 2024-02-29 15:38:05 +01:00
YimingWu added 1 commit 2024-03-01 00:41:47 +01:00
Falk David requested changes 2024-03-01 10:18:33 +01:00
Dismissed
Falk David left a comment
Member

One more comment. Can you explain what is not working with the fixed mode now?

One more comment. Can you explain what is not working with the fixed mode now?
@ -0,0 +92,4 @@
case MOD_GREASE_PENCIL_SIMPLIFY_FIXED: {
const OffsetIndices points_by_curve = curves.points_by_curve();
Array<int> target_count(curves.curves_num());
target_count.fill(2);
Member

This line is not needed.

This line is not needed.
filedescriptor marked this conversation as resolved
Author
Member

@filedescriptor It will crash at the same old place with this code 🤔

@filedescriptor It will crash at the same old place with this code 🤔
Member

@ChengduLittleA What's the crash log?

@ChengduLittleA What's the crash log?
Author
Member

@filedescriptor I'll update in a bit

@filedescriptor I'll update in a bit
Falk David added 2 commits 2024-03-26 16:24:33 +01:00
Falk David added 3 commits 2024-03-28 11:28:33 +01:00
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
2fbadf08b1
Merge branch 'main' into gp3-mod-simplify
Falk David changed title from WIP: GPv3: Simplify modifier to GPv3: Simplify modifier 2024-03-28 11:29:28 +01:00
Member

@blender-bot build

@blender-bot build
Falk David requested review from Hans Goudey 2024-03-28 11:30:17 +01:00
Iliya Katushenock reviewed 2024-03-28 12:31:36 +01:00
@ -0,0 +245,4 @@
for (const int dst_point_i : range) {
/* Create a separate mixer for every point to avoid allocating temporary buffers
* in the mixer the size of the result curves and to improve memory locality. */
bke::attribute_math::DefaultMixer<T> mixer{dst_attribute.span.slice(dst_point_i, 1)};
bke::attribute_math::DefaultMixer<T> mixer(dst_attribute.span.slice(dst_curves.points_range()));

Using mixer of single value size does not improve something and violates the design of using this.

```Cpp bke::attribute_math::DefaultMixer<T> mixer(dst_attribute.span.slice(dst_curves.points_range())); ``` Using mixer of single value size does not improve something and violates the design of using this.
Member

This is taken from blender/source/blender/geometry/intern/point_merge_by_distance.cc:142

This is taken from `blender/source/blender/geometry/intern/point_merge_by_distance.cc:142`

This need to be refactored :)\

This need to be refactored :)\
Member

@HooglyBoogly Let me know what should be done here. I can refactor the pointcould one in a separate commit if it's necessary.

@HooglyBoogly Let me know what should be done here. I can refactor the pointcould one in a separate commit if it's necessary.

Didn't want to say that point_merge_by_distance should be refactored today..\

Didn't want to say that `point_merge_by_distance` should be refactored today..\
Member

If I fix it here, better fix it in the other place too :D

If I fix it here, better fix it in the other place too :D
Falk David approved these changes 2024-03-28 14:04:43 +01:00
YimingWu added 1 commit 2024-03-28 15:11:07 +01:00
YimingWu merged commit 279b8b5748 into main 2024-03-28 15:18:42 +01:00
YimingWu referenced this issue from a commit 2024-03-28 15:18:43 +01:00
YimingWu deleted branch gp3-mod-simplify 2024-03-28 15:18:45 +01:00
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
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#118546
No description provided.