Fix #119596: Multiple points operations of Curvemap and Curveprofile #120242

Open
XDzZyq wants to merge 15 commits from Zyq-XDz/blender:curve-mapping-multiselect into main

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

As the issue mentioned in #119596, there are a few undefined behaviors when operating more than one point. This PR will try to fix this issue by defining the operations such as shift and remove for more than one selected point.

  • Curvemap
  • Curveprofile
As the issue mentioned in https://projects.blender.org/blender/blender/issues/119596, there are a few undefined behaviors when operating more than one point. This PR will try to fix this issue by defining the operations such as ```shift``` and ```remove``` for more than one selected point. - [x] Curvemap - [x] Curveprofile
XDzZyq added 1 commit 2024-04-04 08:18:29 +02:00
XDzZyq added 3 commits 2024-04-04 10:08:07 +02:00
Author
Contributor

the general goal has been accomplished.

  • Shift all selected points together with slider control.
  • Display selected points properties (flags) properly.
  • Clamp the position on the boundary.

However, the center of the selected points is now stored in CurveMap and will be updated in interface_template.cc, I am not sure it is a good idea.

the general goal has been accomplished. - Shift all selected points together with slider control. - Display selected points properties (flags) properly. - Clamp the position on the boundary. <video src="/attachments/9a627dc6-b747-4ac3-aad8-85cd294823e4" title="multi-selection.mp4" controls></video> However, the center of the selected points is now stored in ```CurveMap``` and will be updated in ```interface_template.cc```, I am not sure it is a good idea.
XDzZyq changed title from WIP: Fix #119596: Multiple points operations of curvemapping to Fix #119596: Multiple points operations of curvemapping 2024-04-04 10:18:14 +02:00
XDzZyq requested review from Campbell Barton 2024-04-04 10:23:10 +02:00
XDzZyq added 1 commit 2024-04-04 10:25:48 +02:00
Iliya Katushenock reviewed 2024-04-04 16:28:01 +02:00
@ -4560,3 +4560,2 @@
/* Sliders for selected curve point. */
int i;
CurveMapPoint *cmp = nullptr;
Vector<CurveMapPoint *> cmps{};

Vector<CurveMapPoint *> cmps;

`Vector<CurveMapPoint *> cmps;`
Zyq-XDz marked this conversation as resolved
@ -4609,2 +4608,2 @@
{
bt->flag |= UI_SELECT_DRAW;
for (CurveMapPoint *cmp : cmps) {

for (const CurveMapPoint *cmp : cmps) {

`for (const CurveMapPoint *cmp : cmps) {`
Zyq-XDz marked this conversation as resolved
@ -4676,1 +4687,4 @@
active_cm->center_y = 0.0f;
for (CurveMapPoint *cmp : cmps)
active_cm->center_y += cmp->y;
for (CurveMapPoint *cmp : cmps) {
  ...
}

See: https://developer.blender.org/docs/handbook/guidelines/c_cpp/#braces

And the same above.

```Cpp for (CurveMapPoint *cmp : cmps) { ... } ``` See: https://developer.blender.org/docs/handbook/guidelines/c_cpp/#braces And the same above.
Zyq-XDz marked this conversation as resolved
XDzZyq added 1 commit 2024-04-05 02:37:29 +02:00
Campbell Barton requested changes 2024-04-05 05:18:02 +02:00
Campbell Barton left a comment
Owner

It should be possible to implement this as a more straightforward operation that applies an offset on the selection. Notes inline.

It should be possible to implement this as a more straightforward operation that applies an offset on the selection. Notes inline.
@ -930,6 +930,34 @@ void BKE_curvemapping_premultiply(CurveMapping *cumap, bool restore)
}
/* ************************ more CurveMapping calls *************** */
void BKE_curvemap_shift(CurveMapping *cumap)

Prefer BKE_curvemap_translate a float2 offset argument.

Prefer `BKE_curvemap_translate` a float2 offset argument.
Zyq-XDz marked this conversation as resolved
@ -48,6 +48,8 @@ typedef struct CurveMap {
float ext_in[2], ext_out[2];
/** Actual curve. */
CurveMapPoint *curve;
/** Center of selected points */

I'd rather avoid adding run-time UI data into CurveMap, this seems like a value that could be stored in run-time data such as uiHandleButtonData.

I'd rather avoid adding run-time UI data into `CurveMap`, this seems like a value that could be stored in run-time data such as `uiHandleButtonData`.
Author
Contributor

I noticed there are a few members named vec[3] and origvec[3], may I modify them for this purpose?

I noticed there are a few members named ```vec[3]``` and ```origvec[3]```, may I modify them for this purpose?

These are for vector buttons but I suppose they could be used, check on using value, origvalue, startvalue in-place, that may be all you need.

These are for vector buttons but I suppose they could be used, check on using `value, origvalue, startvalue` in-place, that may be all you need.
Author
Contributor

294ccde79f/source/blender/makesdna/DNA_color_types.h (L30-L34)

Since each CurveMap requires runtime storage, I imitated how NodeCryptomatte_Runtime and Camera_Runtime are set up. I've also tried to implement it with pointers, not that much difference. If this solution is fine, I'll finish the rest of the code. :)

https://projects.blender.org/blender/blender/src/commit/294ccde79f84b267fe31c18683872406babeb4ee/source/blender/makesdna/DNA_color_types.h#L30-L34 Since each CurveMap requires runtime storage, I imitated how ```NodeCryptomatte_Runtime``` and ```Camera_Runtime``` are set up. I've also tried to implement it with pointers, not that much difference. If this solution is fine, I'll finish the rest of the code. :)
Zyq-XDz marked this conversation as resolved
XDzZyq changed title from Fix #119596: Multiple points operations of curvemapping to WIP: Fix #119596: Multiple points operations of curvemapping 2024-04-05 09:11:35 +02:00
Iliya Katushenock added this to the User Interface project 2024-04-05 10:18:48 +02:00
XDzZyq added 1 commit 2024-04-07 12:20:56 +02:00
XDzZyq changed title from WIP: Fix #119596: Multiple points operations of curvemapping to WIP: Fix #119596: Multiple points operations of Curvemap and Curveprofile 2024-04-07 17:05:16 +02:00
XDzZyq added 2 commits 2024-04-07 18:21:15 +02:00
XDzZyq added 1 commit 2024-04-08 06:38:08 +02:00
XDzZyq added 1 commit 2024-04-08 13:32:46 +02:00
XDzZyq added 1 commit 2024-04-08 13:57:05 +02:00
XDzZyq changed title from WIP: Fix #119596: Multiple points operations of Curvemap and Curveprofile to Fix #119596: Multiple points operations of Curvemap and Curveprofile 2024-04-08 13:57:53 +02:00
XDzZyq requested review from Campbell Barton 2024-04-08 13:58:12 +02:00
XDzZyq added 1 commit 2024-04-10 09:08:19 +02:00

Adding a curve-runtime to every curve map and curve profile seems unnecessary for UI logic where only one value is edited at a time.

It seems this can be replaced with a single static float[2] which also isn't so nice but at least avoids adding run-time UI data into DNA.

Attached a path that does this.


I would need to dig into this in more detail to check on having a more elegant solution, as I mentioned in chat, it might be cleanest to use the same method the 3D viewport uses to transform multiple vertices at once.

CC'ing @JulianEisel for a second opinion.

Adding a curve-runtime to every curve map and curve profile seems unnecessary for UI logic where only one value is edited at a time. It seems this can be replaced with a single `static float[2]` which also isn't so nice but at least avoids adding run-time UI data into DNA. Attached a path that does this. ---- I would need to dig into this in more detail to check on having a more elegant solution, as I mentioned in chat, it might be cleanest to use the same method the 3D viewport uses to transform multiple vertices at once. CC'ing @JulianEisel for a second opinion.
XDzZyq requested review from Julian Eisel 2024-04-11 16:53:44 +02:00
XDzZyq added 1 commit 2024-04-14 13:30:30 +02:00
XDzZyq added 1 commit 2024-04-24 09:30:41 +02:00
Merge conflict checking is in progress. Try again in few moments.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u curve-mapping-multiselect:Zyq-XDz-curve-mapping-multiselect
git checkout Zyq-XDz-curve-mapping-multiselect
Sign in to join this conversation.
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#120242
No description provided.