Curves: Add support for proportional editing #104620

Closed
Falk David wants to merge 15 commits from filedescriptor:curves-proportional-editing into blender-v3.5-release

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

This adds initial support for proportional editing. Also works with "Only Connected".

image
video

This adds initial support for proportional editing. Also works with "Only Connected". ![image](/attachments/9bf261ae-2c8d-4713-81b4-30096ddc6b2b) ![video](/attachments/b8dfe0ef-bc91-429e-9fba-81525e9a8f2c)
Falk David added this to the Module: Nodes & Physics project 2023-02-11 19:30:09 +01:00
Falk David requested review from Hans Goudey 2023-02-11 19:30:42 +01:00
Hans Goudey requested changes 2023-02-13 02:32:58 +01:00
Hans Goudey left a comment
Member

Nice! "Connected Only" doesn't work exactly as I expected, compared to mesh edit mode anyway. Points from one curve seem to affect points from other curves. I'm not sure how proportional editing works, but two mesh faces next to each other don't affect each other in the same way.

image

Nice! "Connected Only" doesn't work exactly as I expected, compared to mesh edit mode anyway. Points from one curve seem to affect points from other curves. I'm not sure how proportional editing works, but two mesh faces next to each other don't affect each other in the same way. ![image](/attachments/f2b1f9ed-cacb-4e61-9b43-f6b8eedabf1d)
@ -28,6 +28,7 @@ static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t)
MutableSpan<TransDataContainer> trans_data_contrainers(t->data_container, t->data_container_len);
Array<Vector<int64_t>> selected_indices_per_object(t->data_container_len);
Array<IndexMask> selection_per_object(t->data_container_len);
const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
Member

prop -> proportional? Curious what you think about that-- saving a few characters doesn't help so much here.

`prop` -> `proportional`? Curious what you think about that-- saving a few characters doesn't help so much here.
filedescriptor marked this conversation as resolved
@ -77,0 +70,4 @@
".selection", ATTR_DOMAIN_POINT, true);
threading::parallel_for(curves.curves_range(), 1024, [&](const IndexRange range) {
for (const int curve_i : range) {
bool has_any_selected = false;
Member

What do you think about processing has_any_selected in a separate loop? It's probably possible to use one of the curves utilities with that name, right? In that case, maybe it's possible to skip the rest of the work in the curve in that case, and it probably makes the code a bit more readable.

What do you think about processing `has_any_selected` in a separate loop? It's probably possible to use one of the curves utilities with that name, right? In that case, maybe it's possible to skip the rest of the work in the curve in that case, and it probably makes the code a bit more readable.
@ -77,0 +72,4 @@
for (const int curve_i : range) {
bool has_any_selected = false;
for (const int point_i : points_by_curve[curve_i]) {
TransData *td = &tc.data[point_i];
Member

TransData &td = tc.data[point_i];

`TransData &td = tc.data[point_i];`
filedescriptor marked this conversation as resolved
@ -77,0 +82,4 @@
has_any_selected = true;
}
td->flag = (selection[point_i]) ? TD_SELECTED : 0;
Member

(selection[point_i]) -> selection[point_i]

Unnecessary parentheses

`(selection[point_i])` -> `selection[point_i]` Unnecessary parentheses
filedescriptor marked this conversation as resolved
@ -77,0 +91,4 @@
if (!has_any_selected) {
for (const int point_i : points_by_curve[curve_i]) {
TransData *td = &tc.data[point_i];
Member
TransData *td = &tc.data[point_i];
td->flag |= TD_NOTCONNECTED;

->

tc.data[point_i].flag |= TD_NOTCONNECTED;
``` TransData *td = &tc.data[point_i]; td->flag |= TD_NOTCONNECTED; ``` -> ``` tc.data[point_i].flag |= TD_NOTCONNECTED; ```
filedescriptor marked this conversation as resolved
Falk David changed title from Curves: Add support for proportional editing to WIP: Curves: Add support for proportional editing 2023-02-13 12:17:50 +01:00
Author
Member

Nice! "Connected Only" doesn't work exactly as I expected, compared to mesh edit mode anyway.

This is indeed not working right. Marking this as WIP for the time being.

> Nice! "Connected Only" doesn't work exactly as I expected, compared to mesh edit mode anyway. This is indeed not working right. Marking this as WIP for the time being.
Author
Member

Adding a note for myself. What I need to do is:

  • Find the distance for every point to it's closest selected point.
  • Store it in td->dist when proportional edit is in connected only mode.
Adding a note for myself. What I need to do is: - Find the distance for every point to it's closest selected point. - Store it in `td->dist` when proportional edit is in connected only mode.
Falk David force-pushed curves-proportional-editing from b168662316 to 4c82867844 2023-02-14 19:38:37 +01:00 Compare
Falk David changed title from WIP: Curves: Add support for proportional editing to Curves: Add support for proportional editing 2023-02-14 19:39:34 +01:00
Falk David requested review from Hans Goudey 2023-02-17 18:07:28 +01:00
Hans Goudey requested changes 2023-02-17 20:10:42 +01:00
Hans Goudey left a comment
Member

This is working nicely!

This is working nicely!
@ -28,3 +62,4 @@
MutableSpan<TransDataContainer> trans_data_contrainers(t->data_container, t->data_container_len);
Array<Vector<int64_t>> selected_indices_per_object(t->data_container_len);
Array<IndexMask> selection_per_object(t->data_container_len);
const bool is_prop_edit = (t->flag & T_PROP_EDIT_ALL) != 0;
Member

is_prop_edit -> use_proportional_edit
is_prop_connected -> proportional_connected_only

Or something like that

`is_prop_edit` -> `use_proportional_edit` `is_prop_connected` -> `proportional_connected_only` Or something like that
filedescriptor marked this conversation as resolved
@ -74,3 +101,1 @@
copy_m3_m3(td->mtx, mtx);
}
});
float3 *positions_ptr = curves.positions_for_write().data();
Member

Separate positions_read and positions_ptr shouldn't be necessary, the old positions span should still work fine

Separate `positions_read` and `positions_ptr` shouldn't be necessary, the old `positions` span should still work fine
Author
Member

Last time I tried this, the compiler complained because I was passing pointers to td->loc when the Span is const. So I think I need float3 *positions_ptr = curves.positions_for_write().data(); just to pass the pointers into the TransData struct.

Last time I tried this, the compiler complained because I was passing pointers to `td->loc` when the Span is const. So I think I need `float3 *positions_ptr = curves.positions_for_write().data();` just to pass the pointers into the `TransData` struct.
Member

Just replacing positions_ptr with a mutable span seems to work fine here

Just replacing `positions_ptr` with a mutable span seems to work fine here
filedescriptor marked this conversation as resolved
@ -77,0 +117,4 @@
}
if (!has_any_selected) {
for (const int point_i : points_by_curve[curve_i]) {
Member

for (const int point_i : points) {

`for (const int point_i : points) {`
filedescriptor marked this conversation as resolved
@ -77,0 +128,4 @@
}
const Span<float3> positions_curve = positions_read.slice(points_by_curve[curve_i]);
Array<float> closest_distances(positions_curve.size(), FLT_MAX);
Member

This array makes things a bit more readable, but it isn't really necessary considering all the data will go into TransData.dist right after. It might be worth skipping the array, since this will be an allocation and free for every single curve.

This array makes things a bit more readable, but it isn't really necessary considering all the data will go into `TransData.dist` right after. It might be worth skipping the array, since this will be an allocation and free for every single curve.
Author
Member

I am not sure how I would rewrite the code to not use an array in this case. The td->dist values are not sequential, so I can't write to them directly. But the implementation needs some container that I can build the InplacePriorityQueue on top of.

I am not sure how I would rewrite the code to not use an array in this case. The `td->dist` values are not sequential, so I can't write to them directly. But the implementation needs some container that I can build the `InplacePriorityQueue` on top of.
Member

Ah right! That's totally fine, it was just a thought.

Ah right! That's totally fine, it was just a thought.
filedescriptor marked this conversation as resolved
Falk David requested review from Hans Goudey 2023-02-19 16:45:48 +01:00
Falk David changed target branch from main to blender-v3.5-release 2023-02-20 15:27:03 +01:00
Falk David force-pushed curves-proportional-editing from 9ed2acb8fa to 2aceb2ba99 2023-02-20 15:45:13 +01:00 Compare
Hans Goudey approved these changes 2023-02-20 18:46:36 +01:00
Hans Goudey left a comment
Member

Works very well now!

I made some changes in a branch here: https://projects.blender.org/HooglyBoogly/blender/commits/branch/curves-proportional-editing

Feel free to cherry-pick them, or if you disagree anywhere let me know :)
I'll accept now since with those changes the path looks good to me.

Works very well now! I made some changes in a branch here: https://projects.blender.org/HooglyBoogly/blender/commits/branch/curves-proportional-editing Feel free to cherry-pick them, or if you disagree anywhere let me know :) I'll accept now since with those changes the path looks good to me.
@ -26,0 +37,4 @@
}
visited[index] = true;
/* TODO (Falk): Handle cyclic curves here. */
Member

Tiny thing, but fairly sure this will end up in a cleanup commit by Campbell to remove the space between TODO and (Falk) :P

I'd remove your name or the space

Tiny thing, but fairly sure this will end up in a cleanup commit by Campbell to remove the space between `TODO` and `(Falk)` :P I'd remove your name or the space
filedescriptor marked this conversation as resolved
Falk David force-pushed curves-proportional-editing from 2aceb2ba99 to 92d4f78941 2023-02-21 10:49:55 +01:00 Compare
Falk David closed this pull request 2023-02-21 11:08:57 +01:00
Falk David deleted branch curves-proportional-editing 2023-02-21 11:09:52 +01:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
FBX
Interest
Freestyle
Interest
Geometry Nodes
Interest
glTF
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 & 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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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#104620
No description provided.