GPv3: Simplify Modifier #120018

Merged
Falk David merged 31 commits from filedescriptor/blender:gpv3-simplify-modifier into main 2024-03-28 18:16:24 +01:00
Member

Implements the GPv2 simplify modifier.

TODO:

  • Add conversion code
Implements the GPv2 simplify modifier. TODO: - [x] Add conversion code
Falk David added 17 commits 2024-03-28 15:26:38 +01:00
Falk David requested review from Hans Goudey 2024-03-28 15:27:18 +01:00
Falk David added this to the Grease Pencil project 2024-03-28 15:27:23 +01:00
Falk David added 1 commit 2024-03-28 15:28:59 +01:00
Falk David added 2 commits 2024-03-28 15:41:29 +01:00
Falk David changed title from WIP: GPv3: Simplify Modifier to GPv3: Simplify Modifier 2024-03-28 15:42:03 +01:00
Hans Goudey requested changes 2024-03-28 16:04:45 +01:00
Dismissed
@ -0,0 +1,430 @@
/* SPDX-FileCopyrightText: 2005 Blender Authors
Member

Copyright year

Copyright year
filedescriptor marked this conversation as resolved
@ -0,0 +138,4 @@
if (src_point_size == 0) {
return {};
}
OffsetIndices<int> points_by_curve = src_curves.points_by_curve();
Member

Declare these const

Declare these const
filedescriptor marked this conversation as resolved
@ -0,0 +169,4 @@
}
});
bke::CurvesGeometry dst_curves = bke::curves::copy_only_curve_domain(src_curves);
Member

Create the curves above the counting, using bke::curves::copy_only_curve_domain, then fill in the offsets directly.

Currently I think this is losing curve domain attributes

Create the curves above the counting, using `bke::curves::copy_only_curve_domain`, then fill in the offsets directly. Currently I think this is losing curve domain attributes
filedescriptor marked this conversation as resolved
@ -0,0 +178,4 @@
offset_indices::accumulate_counts_to_offsets(dst_curves.offsets_for_write());
int merged_points = 0;
Array<int> src_to_dst_indices(src_point_size);
Member

Any chance you could share this index manipulation with the point cloud merge by distance index manipulation? I remember that being a huge pain to get right, and it might be nice to avoid having to refactor it multiple times.

OTOH there's always the argument that sharing code with the legacy modifiers makes it harder to change, but maybe that's not so relevant here.

Any chance you could share this index manipulation with the point cloud merge by distance index manipulation? I remember that being a huge pain to get right, and it might be nice to avoid having to refactor it multiple times. OTOH there's always the argument that sharing code with the legacy modifiers makes it harder to change, but maybe that's not so relevant here.
Author
Member

I would prefer a curves_merge_by_distance implementation in the geometry namespace then TBH. And I can work on that soonish when e.g. porting the edit mode operator to merge by distance.

I would prefer a `curves_merge_by_distance` implementation in the `geometry` namespace then TBH. And I can work on that soonish when e.g. porting the edit mode operator to merge by distance.
Member

I would extract the index mapping code from the point cloud stuff and just use that here. It could be in a separate header, or in the same point cloud header. My main concern is just not duplicating all this tricky code, even if we hope it's only temporary.

I didn't look to see how much of a direct copy this was though, maybe you changed some parts of it?

I would extract the index mapping code from the point cloud stuff and just use that here. It could be in a separate header, or in the same point cloud header. My main concern is just not duplicating all this tricky code, even if we hope it's only temporary. I didn't look to see how much of a direct copy this was though, maybe you changed some parts of it?
Author
Member

It's mostly the same as far as I remember. I'll have a look at what could be reused and report back here.

It's mostly the same as far as I remember. I'll have a look at what could be reused and report back here.
Author
Member

Hm this will be tricky to share because of merge_indices_per_curve it looks like. The logic is sort of the same but has one more level of nesting.

Hm this will be tricky to share because of `merge_indices_per_curve` it looks like. The logic is sort of the same but has one more level of nesting.
Member

Okay, no need to force it, we can just leave it as is maybe. Thanks for checking.

Okay, no need to force it, we can just leave it as is maybe. Thanks for checking.
@ -0,0 +274,4 @@
const bke::CurvesGeometry &curves = drawing.strokes();
const IndexMask strokes = modifier::greasepencil::get_filtered_stroke_mask(
&ob, curves, mmd.influence, memory);
Member

Removing this newline is nice aesthetically since it puts the empty check right after the variable it's checking :)

Removing this newline is nice aesthetically since it puts the empty check right after the variable it's checking :)
filedescriptor marked this conversation as resolved
@ -0,0 +282,4 @@
switch (mmd.mode) {
case MOD_GREASE_PENCIL_SIMPLIFY_FIXED: {
const IndexMask points_to_delete = simplify_fixed(curves, mmd.step, memory);
drawing.strokes_for_write().remove_points(points_to_delete, {});
Member

If you have the energy, better to implement this in terms of curves_copy_point_selection to avoid the IndexMask complement inside of remove_points.

If you have the energy, better to implement this in terms of `curves_copy_point_selection` to avoid the `IndexMask` complement inside of `remove_points`.
filedescriptor marked this conversation as resolved
@ -0,0 +298,4 @@
break;
}
case MOD_GREASE_PENCIL_SIMPLIFY_SAMPLE: {
drawing.strokes_for_write() = std::move(geometry::resample_to_length(
Member

No need to move an R-Value

No need to move an R-Value
filedescriptor marked this conversation as resolved
@ -0,0 +314,4 @@
}
return false;
});
drawing.strokes_for_write() = std::move(
Member

No need to std::move an R-value

No need to `std::move` an R-value
filedescriptor marked this conversation as resolved
@ -0,0 +318,4 @@
curves_merge_by_distance(curves, mmd.distance, points, {}));
break;
}
default:
Member

No need for the default here

No need for the default here
filedescriptor marked this conversation as resolved
@ -0,0 +329,4 @@
const ModifierEvalContext *ctx,
bke::GeometrySet *geometry_set)
{
auto *mmd = reinterpret_cast<GreasePencilSimplifyModifierData *>(md);
Member

const

`const`
filedescriptor marked this conversation as resolved
Falk David added 10 commits 2024-03-28 17:35:23 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-windows-amd64 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-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
3b588d743b
Use const
Falk David requested review from Hans Goudey 2024-03-28 17:35:34 +01:00
Falk David reviewed 2024-03-28 17:40:41 +01:00
@ -0,0 +243,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)};
Author
Member

@HooglyBoogly @mod_moder had a comment here in the PR that was merged by mistake: #118546 (comment).
What do you think?

@HooglyBoogly @mod_moder had a comment here in the PR that was merged by mistake: https://projects.blender.org/blender/blender/pulls/118546#issuecomment-1156080. What do you think?
Member

I think this is fine. It's using a size of one just to avoid unnecessary temporary array allocations. Maybe use an array is better but I wouldn't worry about it here.

I think this is fine. It's using a size of one just to avoid unnecessary temporary array allocations. Maybe use an array is better but I wouldn't worry about it here.

Thanks for remaind, didn't understand the idea of merging pr and opening another one\

Thanks for remaind, didn't understand the idea of merging pr and opening another one\
Hans Goudey approved these changes 2024-03-28 17:48:01 +01:00
Author
Member

@blender-bot build

@blender-bot build
Falk David added 1 commit 2024-03-28 17:54:11 +01:00
Falk David merged commit 8b7d5f8587 into main 2024-03-28 18:16:24 +01:00
Falk David referenced this issue from a commit 2024-03-28 18:16:26 +01:00
Falk David deleted branch gpv3-simplify-modifier 2024-03-28 18:16:27 +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#120018
No description provided.