Anim: Add custom pre and post frame color to motion path #119375

Merged
Christoph Lendenfeld merged 19 commits from ChrisLend/blender:mpath_custom_pre_post_color into main 2024-04-12 15:12:03 +02:00

This PR adds an option to specify custom colors for a
motion path. One for frames before the current frame
and one frame for after. With this it is easier to see
the relation of the motion path to the current frame.
That was already the case with the default colors, but
not with custom colors.


Test Build

This has been suggested by @P2design and could also help alleviate
this suggestion from Right Click Select

Before After
image image

The user interface has been adapted to show two colors
image

On a technical side note, the colors pre and post the current frame were already different.
The shader multiplied the custom color by 0.25 for anything pre current frame.
You can kind of see it in the comparison.
Only for the line though.

For the default colors I've made a design task to give them a proper entry in the theme
#119376: Theme colors for time visualization

This PR adds an option to specify custom colors for a motion path. One for frames before the current frame and one frame for after. With this it is easier to see the relation of the motion path to the current frame. That was already the case with the default colors, but not with custom colors. ------- **[Test Build](https://builder.blender.org/download/patch/PR119375/)** This has been suggested by @P2design and could also help alleviate this suggestion from [Right Click Select](https://blender.community/c/rightclickselect/znW2/?sorting=hot#comment-71202) | Before | After | | - | -| | ![image](/attachments/40953b19-fb13-4156-a79a-1745594c5622) | ![image](/attachments/3e0449be-cd68-48bf-8469-4c97a559fccb) | The user interface has been adapted to show two colors ![image](/attachments/593b93c7-0fde-40fd-bb80-e77d7795b470) On a technical side note, the colors pre and post the current frame were already different. The shader multiplied the custom color by 0.25 for anything pre current frame. You can kind of see it in the comparison. Only for the line though. For the default colors I've made a design task to give them a proper entry in the theme [#119376: Theme colors for time visualization](https://projects.blender.org/blender/blender/issues/119376)
Christoph Lendenfeld added this to the 4.2 LTS milestone 2024-03-12 13:19:01 +01:00
Christoph Lendenfeld added the
Module
Animation & Rigging
label 2024-03-12 13:19:01 +01:00
Christoph Lendenfeld added 1 commit 2024-03-12 13:19:11 +01:00
Christoph Lendenfeld added 2 commits 2024-03-12 13:31:30 +01:00
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-lint 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-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
a126c067fd
lay out custom colors nicer
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR119375) when ready.
Christoph Lendenfeld added 1 commit 2024-03-12 16:04:04 +01:00
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
53d9b7cab6
Merge branch 'main' into mpath_custom_pre_post_color
Author
Member

@blender-bot package windows

@blender-bot package windows
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR119375) when ready.

I think this is nice. I do have a bunch of questions though.

The user interface has been adapted to show two colors

Which user interface? Is this a per-motion-path option?

Have you considered making this a theme option, so it can be chosen to be nice & contrasty for the other viewport colours?

I think this is nice. I do have a bunch of questions though. > The user interface has been adapted to show two colors Which user interface? Is this a per-motion-path option? Have you considered making this a theme option, so it can be chosen to be nice & contrasty for the other viewport colours?
Author
Member

@dr.sybren
yes that UI is exactly where the old one was

Yep thought about that as well: #119376: Theme colors for time visualization

@dr.sybren yes that UI is exactly where the old one was Yep thought about that as well: [#119376: Theme colors for time visualization](https://projects.blender.org/blender/blender/issues/119376)
Christoph Lendenfeld added 1 commit 2024-04-04 11:34:26 +02:00
Christoph Lendenfeld added 2 commits 2024-04-04 14:23:13 +02:00

Tested and approved at my side.
Didn't find any bugs.
Tested on multiple objects with different color sets.

Tested and approved at my side. Didn't find any bugs. Tested on multiple objects with different color sets.
Christoph Lendenfeld requested review from Nathan Vegdahl 2024-04-04 15:06:07 +02:00
Nathan Vegdahl requested changes 2024-04-05 12:30:55 +02:00
Nathan Vegdahl left a comment
Member

Basically looks good to me. Just some comments to update and a code structure nit.

Also works great in testing.

Basically looks good to me. Just some comments to update and a code structure nit. Also works great in testing.
@ -41,3 +40,4 @@
if (frame < frameCurrent) {
if (use_custom_color) {
/* Custom color: previous frames color is darker than current frame */
Member

This comment is out of date.

This comment is out of date.
nathanvegdahl marked this conversation as resolved
@ -78,3 +76,4 @@
interp.color.rgb = colorCurrentFrame.rgb;
}
else {
/* green - on frameCurrent */
Member

It looks like this comment was already out of date before this PR: the current frame color is definitely not green. Maybe worth updating the comment in this PR?

There's also a similar comment in overlay_motion_path_point_vert.glsl (that I can't directly comment on because the line is too distant from the PR changes).

It looks like this comment was already out of date before this PR: the current frame color is definitely not green. Maybe worth updating the comment in this PR? There's also a similar comment in `overlay_motion_path_point_vert.glsl` (that I can't directly comment on because the line is too distant from the PR changes).
nathanvegdahl marked this conversation as resolved
@ -42,6 +42,14 @@ void main()
/* Bias more to get these on top of keyframes */
gl_Position.z -= 1e-4;
}
if (use_custom_color) {
Member

At first glance, it wasn't clear to me that this is always exclusive with the previous if statement. Maybe something like this would be clearer:

if (frame == frameCurrent) {
    // ...
} else if (frame < frameCurrent) {
    if (use_custom_color) {
        // ...
    }
} else {
    if (use_custom_color) {
        // ...
    }
}

It's a bit more verbose, but it makes the relationship between the cases more obvious IMO.

(I think some people might object to the lone if statement inside the last else, so that could be turned into an else-if instead. But IMO this code structure as-is makes the case relationships clearer, where all of the top-level branches are for the frame number, and the nested ones are for whether we're using a custom color or not. But I don't feel too strongly about it.)

At first glance, it wasn't clear to me that this is always exclusive with the previous if statement. Maybe something like this would be clearer: ```c if (frame == frameCurrent) { // ... } else if (frame < frameCurrent) { if (use_custom_color) { // ... } } else { if (use_custom_color) { // ... } } ``` It's a bit more verbose, but it makes the relationship between the cases more obvious IMO. (I think some people might object to the lone if statement inside the last else, so that could be turned into an else-if instead. But IMO this code structure as-is makes the case relationships clearer, where all of the top-level branches are for the frame number, and the nested ones are for whether we're using a custom color or not. But I don't feel too strongly about it.)
Author
Member

agreed, makes it a lot clearer.
I left an extra comment to make it clearer that the else is only for the frame > frameCurrent case

agreed, makes it a lot clearer. I left an extra comment to make it clearer that the `else` is only for the `frame > frameCurrent` case
nathanvegdahl marked this conversation as resolved
Motion Path Options
image image

It seems that the keys (when turning the "Keyframe" option off) are always drawn in the 'before' colour.

| Motion Path | Options | | -- | -- | | ![image](/attachments/5de135c6-daa4-4b81-ad0d-4ac75e66fc37) | ![image](/attachments/a6204cc6-d6e4-4b21-b291-934b5e56528c) | It seems that the keys (when turning the "Keyframe" option off) are always drawn in the 'before' colour.
Member

Ah! Good catch, @dr.sybren!

Ah! Good catch, @dr.sybren!
Christoph Lendenfeld added 2 commits 2024-04-05 15:02:28 +02:00
Christoph Lendenfeld added 1 commit 2024-04-05 15:09:56 +02:00
Christoph Lendenfeld requested review from Nathan Vegdahl 2024-04-05 15:10:53 +02:00
Author
Member

thanks @dr.sybren
I fixed that by restructuring the shader a bit. The code that checks for a keyframe is now at the end, effectively overriding the custom color. This also makes the [ ] Keyframes setting more useful since even with custom colors you can now see your keyframes highlighted

thanks @dr.sybren I fixed that by restructuring the shader a bit. The code that checks for a keyframe is now at the end, effectively overriding the custom color. This also makes the `[ ] Keyframes` setting more useful since even with custom colors you can now see your keyframes highlighted
Sybren A. Stüvel requested changes 2024-04-08 12:52:37 +02:00
Sybren A. Stüvel left a comment
Member

Nice work! Just some small remarks.

Nice work! Just some small remarks.
@ -196,1 +196,4 @@
mpath->color_post[0] = 0.1;
mpath->color_post[1] = 1.0;
mpath->color_post[2] = 0.1;

These values should be added to DNA_action_defaults.h as well, so that an older file with already-existing motion paths also gets these colors (instead of black).

These values should be added to `DNA_action_defaults.h` as well, so that an older file with already-existing motion paths also gets these colors (instead of black).
Author
Member

DNA_actions_defaults.h doesn't seem to exist. It seems like previously, the versioning code was used for that, which I now also did

`DNA_actions_defaults.h` doesn't seem to exist. It seems like previously, the versioning code was used for that, which I now also did
dr.sybren marked this conversation as resolved
@ -137,2 +137,3 @@
float no_custom_col[3] = {-1.0f, -1.0f, -1.0f};
float *color = (mpath->flag & MOTIONPATH_FLAG_CUSTOM) ? mpath->color : no_custom_col;
float *color_pre = (mpath->flag & MOTIONPATH_FLAG_CUSTOM) ? mpath->color : no_custom_col;
float *color_post = (mpath->flag & MOTIONPATH_FLAG_CUSTOM) ? mpath->color_post : no_custom_col;

These can be const float. I also think it would be nice to extract the flag check:

const bool use_custom_color = (mpath->flag & MOTIONPATH_FLAG_CUSTOM);
const float *color_pre = use_custom_color ? mpath->color : no_custom_col;
const float *color_post = use_custom_color ? mpath->color_post : no_custom_col;
These can be `const float`. I also think it would be nice to extract the flag check: ```cpp const bool use_custom_color = (mpath->flag & MOTIONPATH_FLAG_CUSTOM); const float *color_pre = use_custom_color ? mpath->color : no_custom_col; const float *color_post = use_custom_color ? mpath->color_post : no_custom_col; ```
Christoph Lendenfeld added 2 commits 2024-04-09 10:55:05 +02:00
Christoph Lendenfeld added 1 commit 2024-04-09 11:04:20 +02:00
Christoph Lendenfeld requested review from Sybren A. Stüvel 2024-04-09 11:04:37 +02:00
Sybren A. Stüvel approved these changes 2024-04-09 11:48:19 +02:00
Sybren A. Stüvel left a comment
Member

LGTM! Just some small stuff to handle when landing.

LGTM! Just some small stuff to handle when landing.
@ -3112,0 +3116,4 @@
mpath->color_post[1] = 1.0f;
mpath->color_post[2] = 0.1f;
}
/* bones motion path */

Capitalise & end in period. But also a comment is not really necessary; given that it's conditional on ob->pose it's kinda clear where it's going.

Capitalise & end in period. But also a comment is not really necessary; given that it's conditional on `ob->pose` it's kinda clear where it's going.
@ -3112,0 +3117,4 @@
mpath->color_post[2] = 0.1f;
}
/* bones motion path */
if (ob->pose) {

This could be if (!ob->pose) { continue; } to reduce indentation.

This could be `if (!ob->pose) { continue; }` to reduce indentation.
Christoph Lendenfeld added 1 commit 2024-04-09 12:04:36 +02:00
Christoph Lendenfeld added 2 commits 2024-04-11 17:55:58 +02:00
Nathan Vegdahl approved these changes 2024-04-12 11:49:33 +02:00
Nathan Vegdahl left a comment
Member

Just a comment that I think needs updating. You can fix that while landing.

Just a comment that I think needs updating. You can fix that while landing.
@ -27,2 +27,4 @@
}
/* Draw special dot where the current frame is.
* NOTE: this is only done when keyframes are shown, since this adds similar types of clutter
Member

I think this comment is out of date now...? Since this code has been moved outside of the if (showKeyFrames) { block below, where it previously was.

I think this comment is out of date now...? Since this code has been moved outside of the `if (showKeyFrames) {` block below, where it previously was.
nathanvegdahl marked this conversation as resolved
Christoph Lendenfeld added 2 commits 2024-04-12 12:35:20 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
a040a30af5
fix comment
Author
Member

@blender-bot build

@blender-bot build
Christoph Lendenfeld added 1 commit 2024-04-12 14:47:20 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
7e2569c3ae
adapt vertex_no_geom shader
Author
Member

@blender-bot build

@blender-bot build
Christoph Lendenfeld merged commit 883af6dd63 into main 2024-04-12 15:12:03 +02:00
Christoph Lendenfeld deleted branch mpath_custom_pre_post_color 2024-04-12 15:12:05 +02:00
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
5 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#119375
No description provided.