Animation: Gaussian Smooth operator for Graph Editor #105635
Merged
Christoph Lendenfeld
merged 15 commits from 2023-03-24 12:11:33 +01:00
ChrisLend/blender:graph_gauss_smooth
into main
Reviewers
Request review
No reviewers
Labels
Clear labels
This issue affects/is about backward or forward compatibility
Issues relating to security: https://wiki.blender.org/wiki/Process/Vulnerability_Reports
Apply labels
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
This issue affects/is about backward or forward compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
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
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
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
Issues relating to security: https://wiki.blender.org/wiki/Process/Vulnerability_Reports
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 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 & 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
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
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
Milestone
Set milestone
Clear milestone
No items
No Milestone
Projects
Set Project
Clear projects
No project
Assignees
Assign users
Clear assignees
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#105635
Reference in New Issue
There is no content yet.
Delete Branch "ChrisLend/blender:graph_gauss_smooth"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
Add a Gaussian smoothing operator to supersede the current smoothing operator in the graph editor.
Advantage over the current implementation:
Option in the redo panel to change
Impulse Response


The operator can be called from the Slider Operators Menu.

On a technical note, the operator needs to store additional data when running in modal to avoid allocating/deallocating data on every modal run. For that reason the
tGraphSliderOp
struct has been extended withvoid *operator_data
andvoid (*free_operator_data)(void *operator_data)
. The former is the data and the latter is a function responsible for freeing that data.revived from old patch: https://archive.blender.org/developer/D16778
Wip: Animation: Gauss Smooth operator for Graph Editorto WIP: Animation: Gauss Smooth operator for Graph EditorWIP: Animation: Gauss Smooth operator for Graph Editorto Animation: Gauss Smooth operator for Graph EditorVideo Demo
It should be Gaussian instead of Gauss. If there is only one smooth filter, the term Gaussian is quite technical and should be left to the tooltip only. If there are multiple smoothing filters, it's still better to put it last like
Smooth (Gaussian)
.I'm also agree with the term Gaussian.
that's what's in the redo panel :)
Feels to me like this one is a candidate for when you activate it the slider should start at 0 instead of 50%, what do you guys think?
Or optionally
middle of the slider (start) is 0 influence, if you go towards positive it will gaussian smooth, but if you go negative it will do the opposite like make the current curves more pushed?
Please update the patch description with some info about what made the current smoothing operator undesirable, and in which ways the new one is better.
Some minor remarks. The filter seems to work well, but I'll leave the final judgement of that to @BClark .
@ -394,1 +394,4 @@
}
/* ---------------- */
void get_1d_gauss_kernel(const float sigma, const int kernel_size, double *r_kernel)
For non-static functions, I think it might be better to move the
ED_anim_...
prefixes.@ -395,0 +395,4 @@
/* ---------------- */
void get_1d_gauss_kernel(const float sigma, const int kernel_size, double *r_kernel)
{
You could add
to document the assumptions of the code. If
sigma == 0
it'll cause some nice division issues.@ -395,0 +396,4 @@
void get_1d_gauss_kernel(const float sigma, const int kernel_size, double *r_kernel)
{
double norm = 1.0 / (M_2_SQRTPI * sigma);
I think you can remove
norm
from the calculations completely. Since you normalise the end result anyway, this constant factor doesn't have an impact on the final result.@ -395,0 +397,4 @@
void get_1d_gauss_kernel(const float sigma, const int kernel_size, double *r_kernel)
{
double norm = 1.0 / (M_2_SQRTPI * sigma);
double sigma_sq = 2.0 * sigma * sigma;
const
@ -395,0 +415,4 @@
/* Normalize kernel values. */
for (int i = 0; i < kernel_size; i++) {
r_kernel[i] = r_kernel[i] / sum;
@ -396,0 +426,4 @@
const int kernel_size,
double *kernel)
{
for (int i = segment->start_index; i < segment->start_index + segment->length; i++) {
segment->start_index + segment->length
andfcu->bezt[segment->start_index].vec[1][0]
don't change during the loop, so you can store them in a constant outside of the loop and use that instead.@ -396,0 +433,4 @@
double filter_result = 0;
/* Apply the kernel. */
for (int j = -kernel_size; j <= kernel_size; j++) {
filter_result += samples[sample_index + j] * kernel[abs(j)];
What do you think would be faster? The current approach? Or halving the loop and avoiding the call to
abs(j)
?@ -1056,0 +1073,4 @@
ListBase anim_data; /* bAnimListElem */
} tGaussOperatorData;
typedef struct tFCurveSegmentLink {
Document what this struct contains / what it's for.
Animation: Gauss Smooth operator for Graph Editorto Animation: Gaussian Smooth operator for Graph EditorJust two small notes, no need to re-review after addressing.
@ -396,0 +432,4 @@
for (int i = segment->start_index; i < segment_end_index; i++) {
const int sample_index = (int)(fcu->bezt[i].vec[1][0] - segment_start_x) + kernel_size;
double filter_result = samples[sample_index] * kernel[0];
/* Apply the kernel. */
This comment should swap with the line above it, as
double filter_result = samples[sample_index] * kernel[0];
is already part of applying the kernel.@ -192,2 +196,4 @@
}
if (gso->operator_data) {
gso->free_operator_data(gso->operator_data);
I think it's better to do a
NULL
check ongso->free_operator_data
itself. Callinggso->free_operator_data(...)
is guaranteed to crash if that pointer isNULL
, whereasgso->free_operator_data(NULL)
might be fine, depending on the implementation of that function.It also simplifies the API, in that, regardless of any other field, the function is simply called when it's not-
NULL
.a4208969b0
to5bcbc28f73
seems like I messed up with git
reverting and force pushing fixed it
@ -1056,0 +1141,4 @@
ED_slider_status_string_get(gso->slider, slider_string, UI_MAX_DRAW_STR);
strcpy(mode_str, TIP_("Gauss Smooth"));
Change this to:
It's using the old name now. Copying to a small fixed buffer like that can very easily overflow, but you don't need to copy at all.
sorry missed that one
will fix it shortly
Reviewers