Refactor: pose_slide.c #107610

Merged
Christoph Lendenfeld merged 4 commits from ChrisLend/blender:refactor_pose_slide into main 2023-05-05 15:30:36 +02:00
  • add const where possible
  • reduce calls to ED_slider_factor_get and instead store that in const float factor
  • rename variables from camel case to snake case, using full words, to conform to naming convention
  • use interpf where possible

no functional changes

split off from: #107397: Fix: Slider bidirectionality in pose_slide.c

* add const where possible * reduce calls to `ED_slider_factor_get` and instead store that in `const float factor` * rename variables from camel case to snake case, using full words, to conform to naming convention * use interpf where possible no functional changes split off from: [#107397: Fix: Slider bidirectionality in pose_slide.c](https://projects.blender.org/blender/blender/pulls/107397)
Christoph Lendenfeld added the
Module
Animation & Rigging
label 2023-05-04 11:49:30 +02:00
Christoph Lendenfeld added 1 commit 2023-05-04 11:49:36 +02:00
Christoph Lendenfeld requested review from Sybren A. Stüvel 2023-05-04 12:14:37 +02:00
Sybren A. Stüvel approved these changes 2023-05-05 12:37:17 +02:00
Sybren A. Stüvel left a comment
Member

LGTM! Just a few tiny things that can be addressed before landing the patch. Thanks!

LGTM! Just a few tiny things that can be addressed before landing the patch. Thanks!
@ -362,2 +360,2 @@
float sVal, eVal;
float w1, w2;
float prev_frame, next_frame;
float next_weight, prev_weight;

Now that you're cleaning up anyway, probably a good idea to keep the prev/next order consistent between the two lines.

Now that you're cleaning up anyway, probably a good idea to keep the prev/next order consistent between the two lines.
@ -376,2 +370,2 @@
w1 = ED_slider_factor_get(pso->slider); /* This must come second. */
w2 = 1.0f - w1; /* This must come first. */
next_weight = factor; /* This must come second. */
prev_weight = 1.0f - next_weight; /* This must come first. */

AAAAAAAA those comments (I know, not yours, just AAAAAA). IMO you can just remove those as well. I mean, saying "this must come first" on the 2nd thing just makes no sense to me.

AAAAAAAA those comments (I know, not yours, just AAAAAA). IMO you can just remove those as well. I mean, saying "this must come first" on the 2nd thing just makes no sense to me.
@ -397,1 +393,3 @@
* the value the current frame is closer to.
* - In all of these, the start+end values are multiplied by prev_weight and next_weight
* (respectively), since multiplication in another order would decrease the value the current
* frame is closer to.

Aaaah that is what those comments were referring to. Yeah, just remove them. This one explains it all, and is just as clear without the confusion.

... wait... no it doesn't make sense at all. The 'prev' and 'next' values are just summed, so it doesn't matter in which order they're calculated. And with the naming that you're introducing now it's so logical that you multiply the prevs together and the nexts, that IMO this comment can just be removed as well.

Aaaah **that** is what those comments were referring to. Yeah, just remove them. This one explains it all, and is just as clear without the confusion. ... wait... no it doesn't make sense at all. The 'prev' and 'next' values are just summed, so it doesn't matter in which order they're calculated. And with the naming that you're introducing now it's *so* logical that you multiply the `prev`s together and the `next`s, that IMO this comment can just be removed as well.
@ -687,2 +681,3 @@
/* Compute breakdown based on actual frame range. */
const float factor = (cframe - pso->prevFrame) / (float)(pso->nextFrame - pso->prevFrame);
const float interp_factor = (current_frame - pso->prevFrame) /
(float)(pso->nextFrame - pso->prevFrame);

Could you use interpf() here as well? Might simplify the code a little bit.

Could you use `interpf()` here as well? Might simplify the code a little bit.
Author
Member

not sure how tbh. This is calculation the factor to use in the interp_qt
how would I get the 0-1 value from an interpf

not sure how tbh. This is calculation the factor to use in the `interp_qt` how would I get the 0-1 value from an `interpf`

You're right, I mis-read.

You're right, I mis-read.
Christoph Lendenfeld added 3 commits 2023-05-05 15:12:34 +02:00
Sybren A. Stüvel approved these changes 2023-05-05 15:14:20 +02:00
Sybren A. Stüvel left a comment
Member

👍

:+1:
Christoph Lendenfeld merged commit 9654b96ffa into main 2023-05-05 15:30:36 +02:00
Christoph Lendenfeld deleted branch refactor_pose_slide 2023-05-05 15:30:37 +02:00
Howard Trickey referenced this issue from a commit 2023-05-29 02:51:42 +02: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 project
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#107610
No description provided.