Anim: update some uses of listbases of fcurves #127920

Merged
Nathan Vegdahl merged 3 commits from nathanvegdahl/blender:fcurve_listbase_loops into main 2024-09-24 10:00:10 +02:00
Member

Because we're moving to layered actions, which don't store their
fcurves in a list base, we need to update the places that assume the old
listbase-based structure.

This commit addresses the low-hanging fruit where code was previously
using the LISTBASE_FOREACH macro on a listbase of fcurves and it was
fairly obvious how to correctly update the code with minimal changes.
Other cases that either weren't immediately obvious or required
non-trivial code changes (or both) have been left for future PRs.
Additionally, uses of the list base that didn't use LISTBASE_FOREACH
were not investigated as part of this PR, whether trivial to update or
not.

Ref: #123424

Because we're moving to layered actions, which don't store their fcurves in a list base, we need to update the places that assume the old listbase-based structure. This commit addresses the low-hanging fruit where code was previously using the `LISTBASE_FOREACH` macro on a listbase of fcurves and it was fairly obvious how to correctly update the code with minimal changes. Other cases that either weren't immediately obvious or required non-trivial code changes (or both) have been left for future PRs. Additionally, uses of the list base that didn't use `LISTBASE_FOREACH` were not investigated as part of this PR, whether trivial to update or not. Ref: #123424
Nathan Vegdahl added the
Module
Animation & Rigging
label 2024-09-20 16:54:17 +02:00
Nathan Vegdahl added 1 commit 2024-09-20 16:54:28 +02:00
Anim: update some uses of listbases of fcurves
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
c59c585418
Because we're moving to layered actions, which don't store their
fcurves in a list base, we need to update the places that assume the old
listbase-based structure.

This commit addressed the low-hanging fruit where it was fairly obvious
how to correctly update the code with minimal changes. Other cases that
either weren't immediately obvious or required non-trivial code changes
(or both) have been left for future PRs.
Author
Member

@blender-bot build

@blender-bot build
Nathan Vegdahl requested review from Sybren A. Stüvel 2024-09-23 11:06:05 +02:00
Author
Member

@blender-bot build

@blender-bot build
Author
Member

Gah, Monday brain. Already did a build bot run...

Gah, Monday brain. Already did a build bot run...
Sybren A. Stüvel requested changes 2024-09-23 14:32:30 +02:00
Dismissed
@ -959,0 +963,4 @@
newName,
oldKey,
newKey,
blender::animrig::legacy::fcurves_all(strip->act),

fcurves_all() returns a Vector, which only should be destructed after the call to fcurves_path_rename_fix() returns. Keep a reference in a local variable to do that.

Same for the other places where fcurves_all() is used directly a function parameter.

`fcurves_all()` returns a Vector, which only should be destructed after the call to `fcurves_path_rename_fix()` returns. Keep a reference in a local variable to do that. Same for the other places where `fcurves_all()` is used directly a function parameter.
Author
Member

I could have sworn that wasn't necessary. See: https://stackoverflow.com/questions/37946437/when-exactly-does-the-destruction-of-a-temporary-object-happen-in-a-function-cal

But maybe there's something additional going on here that makes that not apply...?

I could have sworn that wasn't necessary. See: https://stackoverflow.com/questions/37946437/when-exactly-does-the-destruction-of-a-temporary-object-happen-in-a-function-cal But maybe there's something additional going on here that makes that not apply...?

Linked from there is https://eel.is/c++draft/class.temporary#4 so yeah, my comment is moot.

Linked from there is https://eel.is/c++draft/class.temporary#4 so yeah, my comment is moot.
dr.sybren marked this conversation as resolved
@ -4743,3 +4745,3 @@
AnimData *adt = ob->adt;
if (adt->action != nullptr) {
LISTBASE_FOREACH (FCurve *, fcu, &adt->action->curves) {
for (FCurve *fcu : blender::animrig::legacy::fcurves_all(adt->action)) {

This should use legacy::fcurves_for_action_slot(adt->action, adt->slot_handle) to avoid false positives.

This should use `legacy::fcurves_for_action_slot(adt->action, adt->slot_handle)` to avoid false positives.
nathanvegdahl marked this conversation as resolved
@ -371,3 +372,3 @@
AnimKeylist *keylist = ED_keylist_create();
LISTBASE_FOREACH (FCurve *, fcu, &ob->adt->action->curves) {
for (FCurve *fcu : blender::animrig::legacy::fcurves_all(ob->adt->action)) {

This should use legacy::fcurves_for_action_slot(adt->action, adt->slot_handle) to only consider keys of the relevant slot.

This should use `legacy::fcurves_for_action_slot(adt->action, adt->slot_handle)` to only consider keys of the relevant slot.
nathanvegdahl marked this conversation as resolved
@ -513,3 +515,3 @@
int frame_end = PEFRA;
LISTBASE_FOREACH (FCurve *, fcu, &adt->action->curves) {
for (FCurve *fcu : blender::animrig::legacy::fcurves_all(adt->action)) {

Since this is for a specific ADT, it should use the slot for that ADT (legacy::fcurves_for_action_slot(adt->action, adt->slot_handle))

Since this is for a specific ADT, it should use the slot for that ADT (`legacy::fcurves_for_action_slot(adt->action, adt->slot_handle)`)
nathanvegdahl marked this conversation as resolved
@ -752,3 +754,3 @@
}
void bc_enable_fcurves(bAction *act, char *bone_name)
void bc_enable_fcurves(bAction *act, blender::animrig::slot_handle_t slot_handle, char *bone_name)

const

But also, according to #123424, this change shouldn't even be here as the Collada stuff was excluded?

`const` But also, according to #123424, this change shouldn't even be here as the Collada stuff was excluded?
Author
Member

The Collada todo in #123424 is for add_keyframes_from() and the things it impacts. This change is separate from that, and was a low-hanging fruit.

The Collada todo in #123424 is for `add_keyframes_from()` and the things it impacts. This change is separate from that, and was a low-hanging fruit.
nathanvegdahl marked this conversation as resolved
Nathan Vegdahl added 1 commit 2024-09-23 15:55:51 +02:00
Nathan Vegdahl requested review from Sybren A. Stüvel 2024-09-23 15:56:10 +02:00
Nathan Vegdahl added 1 commit 2024-09-23 16:31:07 +02:00
Address additional in-person comments
All checks were successful
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
84907d7532
Author
Member

@blender-bot build

@blender-bot build
Sybren A. Stüvel approved these changes 2024-09-23 17:33:51 +02:00
Sybren A. Stüvel left a comment
Member

LGTM!

LGTM!
Nathan Vegdahl merged commit 4bfa0de388 into main 2024-09-24 10:00:10 +02:00
Nathan Vegdahl deleted branch fcurve_listbase_loops 2024-09-24 10:00:14 +02:00
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
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
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
Core
Module
Development Management
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
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 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#127920
No description provided.