GPv3: Cyclical set operator #111904

Merged
Falk David merged 16 commits from casey-bianco-davis/blender:GPv3-cyclical-set-operator into main 2023-10-20 10:12:34 +02:00

Simply sets the cyclical property selected strokes. Note this does not add extra geometry like the legacy operator.

Note: adds a key bind 'alt c' to toggle, same as for curves.

Resolves #113671

Simply sets the cyclical property selected strokes. Note this does not add extra geometry like the legacy operator. Note: adds a key bind 'alt c' to toggle, same as for curves. Resolves #113671
casey-bianco-davis added 1 commit 2023-09-03 23:10:00 +02:00
9c6a7f74bb GPv3: Cyclical set operator
Note adds a key bind 'alt c' to toggle, same as for curves.
Iliya Katushenock added this to the Grease Pencil project 2023-09-03 23:16:21 +02:00
Hans Goudey requested review from Hans Goudey 2023-09-04 01:24:08 +02:00
Falk David requested review from Falk David 2023-09-11 11:51:23 +02:00
casey-bianco-davis added 1 commit 2023-09-13 03:27:28 +02:00
casey-bianco-davis added 1 commit 2023-09-13 03:32:40 +02:00
casey-bianco-davis added 1 commit 2023-09-13 03:34:44 +02:00
Member

Is there some design task, or an existing operator to reference? Compared to just setting the "cyclic" attribute on curves, this seems pretty complicated. Anyway, the PR description should explain more about the decisions made in the code.

Is there some design task, or an existing operator to reference? Compared to just setting the "cyclic" attribute on curves, this seems pretty complicated. Anyway, the PR description should explain more about the decisions made in the code.
casey-bianco-davis added 1 commit 2023-10-03 01:58:54 +02:00
casey-bianco-davis added 2 commits 2023-10-14 03:53:16 +02:00
Member

@HooglyBoogly Yea the part that takes up most of this PR is the add_geometry option. Basically, when closing a stroke, it would subdivide the last segment and add more points to it.

I agree that this is not ideal and should probably just be handled by the subdivide operator specifically (I am not sure if subdividing the closing segment is possible right now).

@HooglyBoogly Yea the part that takes up most of this PR is the `add_geometry` option. Basically, when closing a stroke, it would subdivide the last segment and add more points to it. I agree that this is not ideal and should probably just be handled by the subdivide operator specifically (I am not sure if subdividing the closing segment is possible right now).
Falk David requested changes 2023-10-16 13:57:45 +02:00
Falk David left a comment
Member

It's probably better if the set_cyclic operator doesn't do more then setting the cyclic attribute even though this would not be consistent with the old operator. If user really wanted to, we could still support this by using an operator macro, that would first set the cyclic attribute and then create the points using another operator.

It's probably better if the `set_cyclic` operator doesn't do more then setting the `cyclic` attribute even though this would not be consistent with the old operator. If user really wanted to, we could still support this by using an operator macro, that would first set the `cyclic` attribute and then create the points using another operator.
@ -804,0 +957,4 @@
MutableSpan<bool> cyclic = curves.cyclic_for_write();
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
const VArray<bool> selection = *curves.attributes().lookup_or_default<bool>(
Member

I think it would be better to use retrieve_selected_curves(const bke::CurvesGeometry &curves, IndexMaskMemory &memory) and then do a IndexMask.foreach_index(...).

I think it would be better to use `retrieve_selected_curves(const bke::CurvesGeometry &curves, IndexMaskMemory &memory)` and then do a `IndexMask.foreach_index(...)`.
casey-bianco-davis marked this conversation as resolved
casey-bianco-davis added 2 commits 2023-10-17 01:35:27 +02:00
Member

@casey-bianco-davis I think if we remove the if (add_geometry) case, we could merge this PR already pretty much. You could split the geometry case into another PR.

@casey-bianco-davis I think if we remove the `if (add_geometry) ` case, we could merge this PR already pretty much. You could split the `geometry` case into another PR.
casey-bianco-davis added 2 commits 2023-10-17 21:41:57 +02:00
casey-bianco-davis requested review from Falk David 2023-10-17 21:55:11 +02:00
Falk David approved these changes 2023-10-18 10:16:28 +02:00
Falk David left a comment
Member

Awesome! Looks good.

Awesome! Looks good.
Hans Goudey requested changes 2023-10-18 10:28:15 +02:00
Hans Goudey left a comment
Member

Looks good, just two suggestions to make this extra nice :)

Suggested inline moving some constant checks out of the loop, and adding a new version of array_utils::invert_booleans that also takes a const IndexMask & parameter.

Also, if the cyclic attribute doesn't already exist, and the mode is CLOSE, it would be nice to avoid adding the attribute.

Also, the description should be updated to reflect the current behavior.

Looks good, just two suggestions to make this extra nice :) Suggested inline moving some constant checks out of the loop, and adding a new version of `array_utils::invert_booleans` that also takes a `const IndexMask &` parameter. Also, if the `cyclic` attribute doesn't already exist, and the mode is `CLOSE`, it would be nice to avoid adding the attribute. Also, the description should be updated to reflect the current behavior.
@ -805,0 +824,4 @@
static int grease_pencil_cyclical_set_exec(bContext *C, wmOperator *op)
{
using namespace blender;
Member

We're already in the blender:: namespace, this shouldn't be necessary

We're already in the `blender::` namespace, this shouldn't be necessary
casey-bianco-davis marked this conversation as resolved
@ -805,0 +847,4 @@
IndexMaskMemory memory;
const IndexMask curve_selection = ed::curves::retrieve_selected_curves(curves, memory);
curve_selection.foreach_index([&](const int64_t curve_i) {
Member
switch (mode) {
  case CyclicalMode::CLOSE:
    index_mask::masked_fill(cyclic, true, curve_selection);
    break;
  case CyclicalMode::OPEN:
    index_mask::masked_fill(cyclic, false, curve_selection);
    break;
  case CyclicalMode::TOGGLE:
    array_utils::invert_booleans(cyclic, curve_selection);
    break;
}
``` switch (mode) { case CyclicalMode::CLOSE: index_mask::masked_fill(cyclic, true, curve_selection); break; case CyclicalMode::OPEN: index_mask::masked_fill(cyclic, false, curve_selection); break; case CyclicalMode::TOGGLE: array_utils::invert_booleans(cyclic, curve_selection); break; } ```
casey-bianco-davis marked this conversation as resolved
casey-bianco-davis added 2 commits 2023-10-19 02:08:04 +02:00
casey-bianco-davis added 1 commit 2023-10-19 02:36:48 +02:00
casey-bianco-davis added 1 commit 2023-10-19 04:34:28 +02:00
casey-bianco-davis requested review from Hans Goudey 2023-10-19 04:34:32 +02:00
Hans Goudey approved these changes 2023-10-19 09:32:07 +02:00
Hans Goudey left a comment
Member

Very nice, thanks!

Very nice, thanks!
@ -855,0 +914,4 @@
}
/* Remove the attribute if it is empty. */
if (!ed::curves::has_anything_selected(curves.cyclic(), curves.curves_range())) {
Member

This doesn't need to run in "Close" mode.

This doesn't need to run in "Close" mode.
casey-bianco-davis marked this conversation as resolved
casey-bianco-davis added 1 commit 2023-10-20 01:16:11 +02:00
Falk David merged commit 5a79023409 into main 2023-10-20 10:12:34 +02: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#111904
No description provided.