GPv3: Clean loose points operator #115923

Merged
Falk David merged 4 commits from PratikPB2123/blender:gpv3-clean-loose into main 2023-12-08 16:53:21 +01:00
Member

Similar to the legacy GP operator. Removes strokes with a number of points less than or equal to the "limit" property.
Resolves #113599.

Similar to the legacy GP operator. Removes strokes with a number of points less than or equal to the "limit" property. Resolves #113599.
Pratik Borhade added 1 commit 2023-12-08 05:05:39 +01:00
133785e5a0 GPv3: Clean loose points
Similar to legacy GP operator.
Remove strokes having points less than or equal to "limit" property.
Resolves #113599
Pratik Borhade requested review from Falk David 2023-12-08 05:05:55 +01:00
Pratik Borhade requested review from Hans Goudey 2023-12-08 05:05:56 +01:00
Pratik Borhade added the
Module
Grease Pencil
label 2023-12-08 05:06:03 +01:00
Pratik Borhade added this to the Grease Pencil project 2023-12-08 05:06:10 +01:00
Hans Goudey approved these changes 2023-12-08 05:18:37 +01:00
Hans Goudey left a comment
Member

Based on the code, this looks good. Just a few cleanup comments.

Based on the code, this looks good. Just a few cleanup comments.
@ -1705,0 +1714,4 @@
threading::parallel_for_each(
drawings, [&](MutableDrawingInfo &info) {
bke::CurvesGeometry &curves = info.drawing.strokes_for_write();
if (curves.curves_num() == 0) {
Member

This check should be unnecessary

This check should be unnecessary
filedescriptor marked this conversation as resolved
@ -1705,0 +1725,4 @@
return points_by_curve[i].size() <= limit;
});
curves.remove_curves(curves_to_delete);
Member

Looks like clang format is missing

Looks like clang format is missing
filedescriptor marked this conversation as resolved
Hans Goudey reviewed 2023-12-08 05:19:37 +01:00
@ -1705,0 +1721,4 @@
IndexMaskMemory memory;
const IndexMask curves_to_delete = IndexMask::from_predicate(
curves.curves_range(), GrainSize(4096), memory, [&](const int i) {
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
Member

Retrieve points_by_curve outside of the from_predicate loop. Such data access isn't necessarily cheap enough to do once per curve

Retrieve `points_by_curve` outside of the `from_predicate` loop. Such data access isn't necessarily cheap enough to do once per curve
filedescriptor marked this conversation as resolved
Pratik Borhade added 1 commit 2023-12-08 05:24:38 +01:00
9e74582c39 Some changes
- Clag format
- Move points_by_curve() outside of predicate
- Remove if() condition
Falk David requested changes 2023-12-08 10:50:43 +01:00
Falk David left a comment
Member

Thanks @PratikPB2123 :) I have one comment

Thanks @PratikPB2123 :) I have one comment
@ -1705,0 +1716,4 @@
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
IndexMaskMemory memory;
const IndexMask curves_to_delete = IndexMask::from_predicate(
Member

One thing I'm noticing here is that this ignores the editable_strokes. E.g. it will remove strokes even if they can't be edited. I think we should get both masks, then combine them, similar to how it's done in retrieve_editable_and_selected_strokes using BitVector.

One thing I'm noticing here is that this ignores the `editable_strokes`. E.g. it will remove strokes even if they can't be edited. I think we should get both masks, then combine them, similar to how it's done in `retrieve_editable_and_selected_strokes` using `BitVector`.
Author
Member

Thanks for the review :)
Instead, can we just pass IndexMask from retrieve_editable_strokes() to the predicate?

     const IndexMask curves_to_delete = IndexMask::from_predicate(
-        curves.curves_range(), GrainSize(4096), memory, [&](const int i) {
+        editable_strokes, GrainSize(4096), memory, [&](const int i) {
           return points_by_curve[i].size() <= limit;
         });
Thanks for the review :) Instead, can we just pass IndexMask from `retrieve_editable_strokes()` to the predicate? ```Diff const IndexMask curves_to_delete = IndexMask::from_predicate( - curves.curves_range(), GrainSize(4096), memory, [&](const int i) { + editable_strokes, GrainSize(4096), memory, [&](const int i) { return points_by_curve[i].size() <= limit; }); ```
Member

Haven't tried using the universe for this, but sure! If it works, then that's even better :)

Haven't tried using the `universe` for this, but sure! If it works, then that's even better :)

Yep, this is case for universe.

Yep, this is case for `universe`.
@ -1705,0 +1742,4 @@
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_int(ot->srna,
Member

Looks like this isn't formatted.

Looks like this isn't formatted.
filedescriptor marked this conversation as resolved
Pratik Borhade added 1 commit 2023-12-08 12:46:26 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
c41a8aca69
Formatting and use retrieve_editable_stroke
Falk David approved these changes 2023-12-08 12:53:43 +01:00
Falk David left a comment
Member

One last comment. Otherwise looks good 👍

One last comment. Otherwise looks good 👍
@ -1705,0 +1716,4 @@
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
IndexMaskMemory memory;
const IndexMask editable_strokes = ed::greasepencil::retrieve_editable_strokes(
Member

Put this above the bke::CurvesGeometry &curves = ... and add

if (editable_strokes.is_empty()) {
   return;
}
Put this above the `bke::CurvesGeometry &curves = ...` and add ``` if (editable_strokes.is_empty()) { return; } ```
Member

The is_empty check is unnecessary. It should be redundant with checks inside of from_predicate and remove_curves.

The `is_empty` check is unnecessary. It should be redundant with checks inside of `from_predicate` and `remove_curves`.
Member

Alright then

Alright then
filedescriptor marked this conversation as resolved
Falk David changed title from GPv3: Clean loose points to GPv3: Clean loose points operator 2023-12-08 13:59:59 +01:00
Member

@blender-bot build

@blender-bot build
Member

@PratikPB2123 please run make format there are still linting issues (see https://builder.blender.org/admin/#/builders/210/builds/11).

@PratikPB2123 please run `make format` there are still linting issues (see https://builder.blender.org/admin/#/builders/210/builds/11).
Pratik Borhade added 1 commit 2023-12-08 14:58:39 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
af87742507
Make format
Author
Member

@blender-bot build

@blender-bot build
Falk David merged commit 2e5d4a8799 into main 2023-12-08 16:53:21 +01:00
Author
Member

Thanks for reviewing and merging :)
Windows build failed though on buildbot : https://builder.blender.org/admin/#/builders/133/builds/2884

Thanks for reviewing and merging :) Windows build failed though on buildbot : https://builder.blender.org/admin/#/builders/133/builds/2884
Pratik Borhade deleted branch gpv3-clean-loose 2023-12-09 06:35:25 +01:00
Member

@PratikPB2123 It compiled the code but then failed before running the tests. So it was a buildbot issue. Since the tests ran fine on all the other platforms I assumed it's ok.

@PratikPB2123 It compiled the code but then failed before running the tests. So it was a buildbot issue. Since the tests ran fine on all the other platforms I assumed it's ok.
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#115923
No description provided.