Curves: Add select more/less #104626

Merged
Falk David merged 7 commits from filedescriptor/blender:curves-select-more-less into main 2023-02-16 17:02:54 +01:00
Member

This adds the "Select More/Less" operators for Curves. Both operators use the select_adjacent function to (de)select adjacent points.

This adds the "Select More/Less" operators for Curves. Both operators use the `select_adjacent` function to (de)select adjacent points.
Falk David requested review from Hans Goudey 2023-02-11 18:58:52 +01:00
Falk David force-pushed curves-select-more-less from fce8214871 to 17363c293d 2023-02-11 19:27:27 +01:00 Compare
Falk David added this to the Nodes & Physics project 2023-02-11 19:30:20 +01:00
Hans Goudey requested changes 2023-02-13 02:04:16 +01:00
Hans Goudey left a comment
Member

Just two small comments inline.

Just two small comments inline.
@ -270,0 +313,4 @@
MutableSpan<bool> selection_typed = selection.typed<bool>();
return !selection_typed[current] && selection_typed[next];
}
else if (selection.type().is<float>()) {
Member

else after return

else after return
filedescriptor marked this conversation as resolved
@ -270,0 +346,4 @@
if (check_adjacent_selection(selection_curve, point_i, point_i - 1)) {
apply_selection_operation_at_index(selection_curve, point_i, SEL_OP_ADD);
}
}
Member

Looks like this doesn't handle cyclic curves. For some similar logic, ControlPointNeighborFieldInput might be worth checking out.

IMO, this is pushing the boundaries of what should be done with dynamic types per index, since there's 2 reads per index. But I strongly doubt the selection operators will noticeably non-instantaneous, and it can always be improved later.

Looks like this doesn't handle cyclic curves. For some similar logic, `ControlPointNeighborFieldInput` _might_ be worth checking out. IMO, this is pushing the boundaries of what should be done with dynamic types per index, since there's 2 reads per index. But I strongly doubt the selection operators will noticeably non-instantaneous, and it can always be improved later.
filedescriptor marked this conversation as resolved
Falk David requested review from Hans Goudey 2023-02-16 12:55:54 +01:00
Hans Goudey requested changes 2023-02-16 14:16:31 +01:00
@ -199,6 +199,46 @@ static void invert_selection(GMutableSpan selection)
}
}
static void apply_selection_operation_at_index(GMutableSpan selection,
Member

Looks like this doesn't need to move in this patch anymore? It looks like the type could still be abstracted, but duplicating things twice isn't so bad in return for making the type-interaction more obvious.

Looks like this doesn't need to move in this patch anymore? It looks like the type could still be abstracted, but duplicating things twice isn't so bad in return for making the type-interaction more obvious.
filedescriptor marked this conversation as resolved
@ -270,0 +323,4 @@
threading::parallel_for(curves.curves_range(), 256, [&](const IndexRange range) {
for (const int curve_i : range) {
MutableSpan<bool> selection_curve = selection_typed.slice(points_by_curve[curve_i]);
const int last_i = points_by_curve.size(curve_i) - 1;
Member

I think a local const IndexRange points variable to hold the curve points range would make this slightly more readable.

I think a local `const IndexRange points` variable to hold the curve points range would make this slightly more readable.
filedescriptor marked this conversation as resolved
@ -270,0 +340,4 @@
}
/* Handle cyclic curve case. */
if (cyclic[curve_i]) {
Member

Nice, that's simpler than I expected. Only needing to propagate it by one element helps!

Nice, that's simpler than I expected. Only needing to propagate it by one element helps!
filedescriptor marked this conversation as resolved
@ -270,0 +365,4 @@
/* Handle all cases in the backwards direction. */
for (int point_i = last_i; point_i > 0; point_i--) {
if ((selection_typed[point_i] == 0.0f) && (selection_typed[point_i - 1] > 0.0f)) {
Member

This mix of using selection_typed and selection_curve is confusing, it's hard to tell what's correct here.

If it's possible, I'd suggest only using actual point indices (rather than 0..points.size() for each curve). Having a local IndexRange variable with the .last(N) method should make that simpler.

This mix of using `selection_typed` and `selection_curve` is confusing, it's hard to tell what's correct here. If it's possible, I'd suggest only using actual point indices (rather than 0..points.size() for each curve). Having a local `IndexRange` variable with the `.last(N)` method should make that simpler.
Author
Member

Ah good catch, that's actually a bug I was trying to fix. It didn't work with float selection, so I think that is why.

Ah good catch, that's actually a bug I was trying to fix. It didn't work with float selection, so I think that is why.
filedescriptor marked this conversation as resolved
Falk David force-pushed curves-select-more-less from 824cee6ec3 to 6d5f46c4e0 2023-02-16 15:31:44 +01:00 Compare
Falk David requested review from Hans Goudey 2023-02-16 15:33:01 +01:00
Hans Goudey approved these changes 2023-02-16 16:04:36 +01:00
@ -270,0 +272,4 @@
const OffsetIndices points_by_curve = curves.points_by_curve();
bke::GSpanAttributeWriter selection = ensure_selection_attribute(
curves, ATTR_DOMAIN_POINT, CD_PROP_BOOL);
VArray<bool> cyclic = curves.cyclic();
Member

VArray<bool> cyclic -> const VArray<bool> cyclic

`VArray<bool> cyclic` -> `const VArray<bool> cyclic`
Falk David added 1 commit 2023-02-16 17:01:15 +01:00
Falk David merged commit 55843cd64b into main 2023-02-16 17:02:54 +01:00
Falk David deleted branch curves-select-more-less 2023-02-16 17:02:55 +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 Assignees
2 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#104626
No description provided.