WIP: Layered Animation System - Minimal Data Model #114098

Draft
Sybren A. Stüvel wants to merge 154 commits from anim/animation-id-113594 into main

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

This is very much work in progress, on a first version of the Animation data-block for layered animation. See #113594 and the Animation Workshop June 2023 blog post for more info.

This PR currently just exists for interested people to easily see what's being worked on.

This is very much work in progress, on a first version of the `Animation` data-block for layered animation. See #113594 and the [Animation Workshop June 2023 blog post](https://code.blender.org/2023/07/animation-workshop-june-2023/) for more info. This PR currently just exists for interested people to easily see what's being worked on.
Sybren A. Stüvel added 42 commits 2023-10-24 12:23:25 +02:00
9bcd526e89 Anim: add Animation ID data structures to DNA
No other functionality yet, isn't even written to the blend file or
actually registered as ID data-blocks.
6cf99fac80 Anim: some tweaks to the data model
- Removal of child layers -- not needed for the MVP
- Addition of some `next` and `prev` pointers
- Multiple `ID*` per output
bc16ba6461 Anim: more work on exposing Animation datablock to RNA
This also includes the start of a C++ function for creating a new
Animation data-block. Still very much work in progress.
413387daf1 Anim: refactor storage model of layers
Store layers as array-of-pointers instead of `ListBase`. This gives more
pointer safety, and makes it easier to use spans (which in turn give
safer, macro-free iteration).
22bb726ed2 Anim: make the AnimationChannelsForOutput::fcurves an array
This also includes some other API changes to clean things up a bit.
d39232aa46 Anim: writing Animation data to blend files
This is untested, as the reading code isn't there yet.
78f10dd475 Anim: make it possible to actually assign Animation data-blocks
This includes additions to the `AnimData` struct, so that it can point
to an `Animation`, including the stable index of the desired output, and
the accompanying fallback string.
49f8a446dd Anim: unstable, attempt at reading & writing to blend file
It crashes, so better to not push this to `anim/animation-id-113594` on
the blender repo.
beacecbce2 Anim: slight improvement of reading code
Still not good enough, there's still a heap-use-after-free when freeing
the Scene for some reason.
c6c70afa66 Anim: Rename `stable_index_t` to `output_index_t`
This is part of a bigger change to rename `stable_index` to `output_index`.
0e9edee46b Merge remote-tracking branch 'origin/main' into anim/animation-id-113594
# Conflicts:
#	source/blender/animrig/CMakeLists.txt
59e34e297b Anim: remove AnimationOutput::runtime
We can do without at the moment, so better to just remove it.
32c19a7391 RNA: generate valid infinite float property default values
In `makesrna`, generate valid default values for float properties, when
those defaults are positive/negative infinity.

Blender would currently generate the strings `inff` and `-inff`, which
are not valid C++. This PR changes that to
`std::numeric_limits<float>::infinity()` and
`-std::numeric_limits<float>::infinity()`.
e7bf209770 Anim: fix crash loading file when there are multiple animation layers
Just a copy-paste error, using the wrong array index.
c199676eec Anim: Add frame start/end/offset properties to RNA
Since 395ac4c41f RNA properties can have
±infinite default values, so now we can add these.
buildbot/vexp-code-patch-coordinator Build done. Details
31b1a853a6
Anim: add temporary Animation Layers panel
Add a temporary Animation Layers panel to the 3D Viewport. It's just there
for some demos at the conference, so that the existence of the new
animation data model can be seen *somewhere*.
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/PR114098) when ready.
Sybren A. Stüvel added 1 commit 2023-10-24 15:57:50 +02:00
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/PR114098) when ready.
Sybren A. Stüvel added 1 commit 2023-11-02 11:48:26 +01:00
Sybren A. Stüvel added 1 commit 2023-11-03 14:25:44 +01:00
Sybren A. Stüvel added 3 commits 2023-11-06 17:27:27 +01:00
52a5fb1d2e Anim: separate animation evaluation from updating the data-block
Instead of directly writing to the animated data-block, store the
evaluation result. This makes it possible in the future to move that
result from layer to layer, until the evaluation is done, and only then
write the evaluation result to the data-block.
Sybren A. Stüvel added 2 commits 2023-11-06 18:19:18 +01:00
950196100f Anim: add basic mixing of animation layer results
This is done on a per-channel basis, so nothing like proper quaternion
SLERP or anything.
Sybren A. Stüvel added 2 commits 2023-11-06 18:38:13 +01:00
Sybren A. Stüvel added 1 commit 2023-11-06 18:44:28 +01:00
Sybren A. Stüvel added 1 commit 2023-11-06 18:55:18 +01:00
Sybren A. Stüvel added 1 commit 2023-11-06 19:01:13 +01:00
Sybren A. Stüvel added 1 commit 2023-11-07 15:13:00 +01:00
6a1f65b530 Merge remote-tracking branch 'origin/main' into anim/animation-id-113594
And adjust one #include to avoid breaking the code.

# Conflicts:
#	source/blender/animrig/CMakeLists.txt
Sybren A. Stüvel added 3 commits 2023-11-07 15:38:42 +01:00
Sybren A. Stüvel added 1 commit 2023-12-04 17:37:58 +01:00
9472c9bd03 Merge remote-tracking branch 'origin/main' into anim/animation-id-113594
# Conflicts:
#	source/blender/animrig/CMakeLists.txt
#	source/blender/makesrna/intern/rna_main_api.cc
Sybren A. Stüvel added 2 commits 2024-01-18 15:27:53 +01:00
944a68954a Anim: fixes after merge
Just some headers that were changed from C to C++, and a change in the
`insert_vert_fcurve()` signature.
Sybren A. Stüvel added 2 commits 2024-01-18 16:03:10 +01:00
d0d2a0c80b Anim: move `keyframe_insert()` into the `KeyframeStrip` class
Instead of having a function `keyframe_insert(strip, ...)`, it's now
called as `strip.keyframe_insert(...)`. This also changes the parameters
a little bit, to make it more like `insert_vert_fcurve()`.
Sybren A. Stüvel added 1 commit 2024-01-19 12:15:23 +01:00
543043f37c Anim: do not automatically create a keyframe strip on a new layer
The API should be as simple as possible, and not do anything extra. Also
that automatically-created keyframe strip might not be of the right strip
type anyway.
Sybren A. Stüvel added 1 commit 2024-01-19 12:39:47 +01:00
038b250fd4 Merge remote-tracking branch 'origin/main' into anim/animation-id-113594
# Conflicts:
#	source/blender/animrig/CMakeLists.txt
Sybren A. Stüvel added 6 commits 2024-01-19 15:00:21 +01:00
80501df3f0 Refactor: Anim KeyframeStrip: use KeyframeSettings parameter
Instead of explicitly passing the keyframe type to
`keyframe_insert::keyframe_insert()`, use the new `KeyframeSettings`
type.
3580a7564d Anim: add test for animation layer evaluation
This also required moving around some code so that it can be called from
a unit test.
Sybren A. Stüvel added 2 commits 2024-01-19 17:47:01 +01:00
5b6230dc02 Anim: remove need for `std::optional<EvaluationResult>`
There is now no more distinction between "no EvaluationResult" and "empty
EvaluationResult". Added some operators & move constructor to make things
reasonably efficient & easy to work with.
Sybren A. Stüvel added 1 commit 2024-01-23 14:45:04 +01:00
Sybren A. Stüvel added 1 commit 2024-01-25 16:23:32 +01:00
Sybren A. Stüvel added 4 commits 2024-01-26 14:13:13 +01:00
7fcbcde47e Refactor: Anim evaluation test, move some common code to the test class
In `AnimationEvaluationTest`, move some of the soon-to-be-common code
into the test class itself. This makes it easier to add more animation
evaluation tests, and also makes it easier to see what the test is
actually testing for.
e1c2b614fb Tests: Anim, add test for animation strip boundaries
Test that evaluation of an animation layer correctly handles strip
boundaries.

No functional changes.
335a160365 Anim: when evaluating animation layer, add special case for strip overlap
Add a special case to the animation layer evaluation, for when the
evaluation time is exactly on the last frame of an animation strip. In
this case that strip should be used, unless it is also overlapping with
another strip, in which case that strip is used.

Example: there are two strips `A=[t1, t2]` and `B=[t3, t4]`, and they
are evaluated at time `t2`.

- When `t2 < t3`, only strip `A` should be evaluated.
- When `t2 >= t3`, only strip `B` should be evaluated.

The current code doesn't mix between strips yet, so for now this is
sufficient.
Sybren A. Stüvel added 2 commits 2024-01-26 17:34:56 +01:00
283594087a Anim: RNA, add function to add new animation strips
Animation layers no longer come with a keyframe strip by default, so this
has to be added explicitly now. This commit introduces the RNA function
`anim_layer.strips.new('KEYFRAME')` for this. The one parameter is the
strip type, which is limited to only `KEYFRAME` for now.
04c46f2a1d Anim: Recompute animation when changing layer/strip properties
Re-evaluate the Animation data-block when the following properties are
changed:

- `AnimationLayer.influence`
- `AnimationLayer.mix_mode`
- `AnimationStrip.frame_start`
- `AnimationStrip.frame_end`
- `AnimationStrip.frame_offset`
Sybren A. Stüvel added 4 commits 2024-01-29 12:02:42 +01:00
1f7db036c3 Anim: RNA, make `type` argument of `Layers.strips.new(type)` optional
Make the `type` argument optional when creating a new strip, defaulting
to creating keyframe strips.

The function declaration is now like `layer.strips.new(type='KEYFRAME')`.
a39120b4db Anim: add support for removing layers from animations
Basically the same as removing strips, but then for layers.
Sybren A. Stüvel added 1 commit 2024-01-29 15:21:51 +01:00
Sybren A. Stüvel added 1 commit 2024-01-29 15:55:04 +01:00
Sybren A. Stüvel added 1 commit 2024-01-29 17:46:57 +01:00
0774e8d468 Anim: hook up the Animation data-block to property state colors in the UI
Expand `BKE_animadata_fcurve_find_by_rna_path()` so that it can also find
animation data stored in an `Animation` data-block.

If there is a Keyframe Strip overlapping the given frame time, and it
has a matching FCurve, that will be returned. Otherwise it will fall back
to searching Keyframe Strips that do not overlap. This at least ensures
a consistent "is this property animated?" indicator, even when it may not
be animated at this particular point in time.

Note that this might be a bit dangerous, as I didn't fully investigate all
(indirect) uses of the FCurve returned by this function.
Sybren A. Stüvel added 1 commit 2024-01-29 17:53:55 +01:00
34061b4593 Cleanup: anim, add more thoughts in a comment
Add a comment with some more thoughts to `fcurve_find_by_rna_path()`.

No functional changes.
Sybren A. Stüvel added 2 commits 2024-02-01 16:58:46 +01:00
7a83758515 Merge remote-tracking branch 'origin/main' into anim/animation-id-113594
Plus adjustments to make things work again after the merge.

# Conflicts:
#	source/blender/blenkernel/intern/fcurve.cc
#	source/blender/editors/animation/anim_channels_edit.cc
#	source/blender/makesrna/intern/rna_internal.h
Sybren A. Stüvel added 3 commits 2024-02-02 14:01:48 +01:00
b6800be0c3 Anim: fix id_code of Animation IDTypeInfo
It still had `ID_AC` (Action) instead of `ID_AN` (Animation).
38a610cc84 Anim: add `ID_AN` to some more lists
Add `ID_AN` to some more places where ID types are handled.

- Outliner icon. Even though the outliner doesn't include the Animation
  data-block yet, I'd rather add this now that I've seen that this entry
  is missing. It's easy to overlook otherwise.
- `rna_enum_id_type_items`, `RNA_type_to_ID_code`, and `rna_ID_update_tag`.
Sybren A. Stüvel added 3 commits 2024-02-02 16:44:31 +01:00
9c0d9ca805 Anim: change how the output for a particular animated ID is found
The output is now selected by:

- If the Animation is already assigned: `id->adt->output_stable_index`
- Search output named `id->adt->output_fallback_string`
- Search output naemd `id->name`
61ff62c574 Refactor, Anim: rename output 'fallback string' to 'name'
The output 'string identifier' that was previously called 'the fallback
string' is becoming more important, and to reflect that, it got renamed
to simply 'name'.
31b21e729c Anim: keep the ID code as part of the Output name
The ID code is to be part of the output name, so there can be separate
outputs `MECube` and `OBCube`.

This might need some more thought when it comes to what's going to be
exposed in RNA.
Sybren A. Stüvel added 1 commit 2024-02-05 17:54:32 +01:00
Sybren A. Stüvel added 1 commit 2024-02-09 12:27:13 +01:00
e7b854b0f8 Scripts: call `register_props()` in every `bl_ui` module
In `startup/bl_ui/__init__.py`, generalise the call to
`space_filebrowser.register_props()` so that the `register_props()`
function is called on any submodule that has such a function.
Sybren A. Stüvel force-pushed anim/animation-id-113594 from 9195af744d to ebdf92e55d 2024-02-09 12:29:35 +01:00 Compare
Sybren A. Stüvel added 2 commits 2024-02-09 16:58:37 +01:00
228c742e3e Anim: make `Output::name` a proper name
`Output::name` is now unique within the `Animation` data-block. This also
changes slightly what happens when assigning an animated ID to another
Output, or when un-assigning an ID from the Animation.

Assigning an ID to an Output will rename the Output to that ID, but ONLY
if the Output has no name yet. Otherwise the name will just be kept as-is.

Unassigning an Animation from an ID will write back the last used Output
name to the ID's AnimData. This is basically a workaround for the fact that
this doesn't happen on Output rename yet. That is marked as TODO in the
code for future implementation.
Sybren A. Stüvel added 2 commits 2024-02-12 11:26:55 +01:00
Sybren A. Stüvel added 2 commits 2024-02-16 12:34:09 +01:00
e3866f09fd Anim: update Baklava UI
Set the title to "Baklava" and hide the strips.
b8b7c57bea Anim: Baklava, rename layer mix modes
Rename two layer mix modes:

- Override → Replace
- Combine → Offset

Their meaning stays the same. We just felt these names are easier to
understand.
Sybren A. Stüvel added 2 commits 2024-02-16 12:49:20 +01:00
dd1f386fea Merge remote-tracking branch 'origin/main' into anim/animation-id-113594
This commit still doesn't compile as things changed in IDTypeInfo.
Will fix in upcoming commit.

# Conflicts:
#	source/blender/blenkernel/intern/idtype.cc
#	source/blender/blenkernel/intern/lib_query.cc
#	source/blender/makesdna/DNA_ID.h
f23d093771 Anim: fix merge issues
Fix issues caused by a borked merge with origin/main.
Sybren A. Stüvel added 10 commits 2024-02-19 11:17:32 +01:00
a864453bb8 Cleanup: Anim, document why FCurves are written as listbase
Document why FCurves of an Animation data-block are written to disk as
listbase, even though they are otherwise handled as array.
9f74886b10 Cleanup: Anim, add missing function declaration
Just add the `const` version of `trip::as<KeyframeStrip>();`

The implementation was already there, the declaration was just missing.
It's not in use, just there for completeness.
50203b1240 Anim: avoid atomic operation when allocating an animation output
The bigger operation of adding a new Output to an Animation is NOT thread-
safe. So better to remove the one atomic operation, as it suggests more
thread-safety than there actually is.
3cb78a3d06 Cleanup: Anim, add more documentation comments
And remove some out-of-date comments.
2464afda26 Anim: do exact match in `Strip::is_last_frame()`
Avoid 4-ULP interval comparison in `Strip::is_last_frame()`, as the 4 ULP
difference was sort of arbitrary, and doing a fuzzy compare in this
particular spot can cause issues as well (as it would have to be done
consistently in all comparisons, or not at all).
Sybren A. Stüvel added 5 commits 2024-02-19 16:11:22 +01:00
6fd31210a4 Anim: Revert merging bork
Revert a change likely caused by a borked merge with `origin/main`.
0e6cc5592d Anim: revert unneeded RNA change
Not sure why I did that change. Rolling it back.
e75cc5848a Anim: make `get_animation(animated_id)` account for nullptr
Make `get_animation(animated_id)` return `nullptr` when the ID turns out
to be non-animated.
Sybren A. Stüvel added 1 commit 2024-02-19 16:13:58 +01:00
c7c1a7fa3a Anim: revert a comment change
It doesn't belong in this PR.
Nathan Vegdahl added 1 commit 2024-02-19 16:58:02 +01:00
Sybren A. Stüvel added 3 commits 2024-02-19 17:26:42 +01:00
0ef5dd989c Anim: only name Output on assign in higher-level function
`Output::assign_id(id)` would name the Output after the ID if the Output
didn't have a name yet. This is now only done when assigning via
`Animation::assign(output, id)` to avoid Output name collisions.
b0e41b3674 Anim: Refuse to assign animation when ID is already animated
Let `Animation::assign_id(id)` refuse to assign itself to the ID when that
ID already has an animation assigned.

Before this was only tested with a `BLI_assert()`, now it's part of the
API and properly tested.
49d8c32229 Merge remote-tracking branch 'origin/main' into anim/animation-id-113594
# Conflicts:
#	scripts/startup/bl_ui/space_userpref.py
#	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
Sybren A. Stüvel added 1 commit 2024-02-19 17:58:46 +01:00
Sybren A. Stüvel added 1 commit 2024-02-20 16:01:14 +01:00
Sybren A. Stüvel added 3 commits 2024-02-20 16:56:08 +01:00
4a460ca52f Anim: fix Layer RNA path function
It still used "%s" in the format string, even though `fmt::format()`
expects `{}` as a placeholder.

Also added a unittest.
41ac35d714 Anim: limit Animation datablocks to 1 layer and 1 strip
Limit the RNA functions from creating more than 1 layer with 1 strip on
an Animation datablock.

Also remove the Strip properties `frame_start`, `frame_end`, and
`frame_offset`. These can be added back when needed.

Note that upon creation an Animation data-block still has zero layers.
It's up to the caller to create the initial layer and the initial,
infinite strip.
Nathan Vegdahl added 1 commit 2024-02-20 17:34:28 +01:00
Nathan Vegdahl added 1 commit 2024-02-22 14:49:24 +01:00
Sybren A. Stüvel added 2 commits 2024-02-22 15:03:58 +01:00
e0bb19055e Anim: add missing notifiers to RNA animation API
For now the notifiers are just kept as `NC_ANIMATION | ND_ANIMCHAN`, until
we allow for more than a single layer with a single strip.
Nathan Vegdahl added 1 commit 2024-02-22 15:37:06 +01:00
Nathan Vegdahl added 3 commits 2024-02-22 16:55:45 +01:00
Sybren A. Stüvel added 3 commits 2024-02-22 17:04:32 +01:00
75dc72df8e Refactor: Anim, use a Main for unit tests
Use a `Main *` for ID datablocks in the `Animation` unit tests. This will
be necessary soon when there is the need to update all animated IDs.

Apart from that, no functional changes to the actual tests.
Nathan Vegdahl added 1 commit 2024-02-22 19:51:50 +01:00
Nathan Vegdahl force-pushed anim/animation-id-113594 from 76324b1f75 to bd6b336831 2024-02-23 10:35:30 +01:00 Compare
Sybren A. Stüvel added 4 commits 2024-02-23 12:23:27 +01:00
07aac786e0 Refactor: Anim, make Animation::output_add() return a reference
It returned a pointer that was never `nullptr`, and now it returns a
reference to drive that point(er) home.
732fa54962 Refactor: Anim, rename Output::assign_id() to connect_id()
The connection goes both ways, the animated ID is pointed to this Output,
and the Output is set up to limit to that particular ID type.

This also disambiguates `Output::assign_id()` from `Animation::assign_id()`
Sybren A. Stüvel added 1 commit 2024-02-23 12:39:40 +01:00
This pull request has changes conflicting with the target branch.
  • scripts/startup/bl_ui/__init__.py
  • scripts/startup/bl_ui/space_userpref.py
  • source/blender/animrig/ANIM_animation.hh
  • source/blender/animrig/ANIM_animdata.hh
  • source/blender/animrig/ANIM_evaluation.hh
  • source/blender/animrig/ANIM_fcurve.hh
  • source/blender/animrig/intern/animation.cc
  • source/blender/animrig/intern/animation_test.cc
  • source/blender/animrig/intern/animdata.cc
  • source/blender/animrig/intern/evaluation.cc

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin anim/animation-id-113594:anim/animation-id-113594
git checkout anim/animation-id-113594
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
3 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#114098
No description provided.