Files
test2/scripts/startup/bl_ui/temp_anim_layers.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
1.8 KiB
Python
Raw Normal View History

# SPDX-FileCopyrightText: 2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
"""NOTE: this is temporary UI code to show animation layers.
It is not meant for any particular use, just to have *something* in the UI.
"""
import bpy
from bpy.types import (
Panel,
WindowManager,
)
from bpy.props import PointerProperty
class VIEW3D_PT_animation_layers(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Animation"
bl_label = "Animation Debug"
@classmethod
def poll(cls, context):
return context.preferences.experimental.use_animation_baklava and context.object
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
Anim: Change how names of Bindings work, and how Bindings are created/assigned This cleans up some of the Animation/Binding API, and adds a distinction between a binding's "name" and its "display name". `name`: internal name that is unique within the `Animation`. As such, it is also the key into the `anim.bindings` collection. - To ensure the uniqueness, `name` is always prefxed with the ID identifier, like `OBCube` and `CACamera`. - A binding that was not created to animate a specific ID will be called `XXBinding`. `name_display`: display name that strips the first two characters, so in the above examples would be `Cube`, `Camera`, and `Binding`. ### RNA setter behaviour `name`: always sets the name, emitting a warning when the name's prefix doesn't match the ID type of the Binding. This implicitly changes the display name (as they are two views into the same string). `name_display`: sets `name = prefix_for_ID_type + name_display`. So even when the old name was `QQSomethingWeird`, setting `binding.name_display = "NewName"` would effectively set `binding.name = "OBNewName"` (assuming it was already bound to some object earlier). Bindings now also **always have a name**. Previously it was possible to create bindings named `""`, but that's no longer possible. Bindings used to be **renamed automatically** when they were first assigned, for example from `XXBinding` to `OBCube`. This behaviour has been removed, as it could potentially cause confusion. Pull Request: https://projects.blender.org/blender/blender/pulls/120941
2024-04-30 15:51:47 +02:00
col = layout.column(align=False)
adt = context.object.animation_data
Anim: merge Animation data-block into bAction The new/experimental, layered `Animation` data-block is merged with the existing `bAction` data-block. The `Animation` data-block is considerably newer than `bAction`, so the supporting code that was written for it is also more modern. When moving that code into `bAction`, I chose to keep the modernity where possible, and thus some of the old code has been updated as well. Things like preferring references over pointers. The `Animation` data-block is now gone from DNA, the main database, etc. As this was still an experimental feature, there is no versioning code to convert any of that to Actions. The DNA struct `bAction` now has a C++ wrapper `animrig::Action`, that can be obtained via `some_action->wrap()`. `animrig::Action` has functions `is_empty()`, `is_action_legacy()`, and `is_action_layered()`. They **all** return `true` when the Action is empty, as in that case none of the data that makes an action either 'legacy' or 'layered' is there. The 'animation filtering' code (for showing things in the dope sheet, graph editor, etc) that I wrote for `Animation` is intentionally kept around. These types now target 'layered actions' and the already-existing ones 'legacy actions'. A future PR may merge these two together, but given how much work it was to add something new there, I'd rather wait until the dust has settled on this commit. There are plenty of variables (and some comments) named `anim` or `animation` that now are of type `animrig::Action`. I haven't renamed them all, to keep the noise level low in this commit (it's already big enough). This can be done in a followup, non-functional PR. Related task: #121355 Pull Request: https://projects.blender.org/blender/blender/pulls/121357
2024-05-13 15:51:26 +02:00
anim = adt and adt.action
if anim:
slot_sub = col.column(align=True)
slot_sub.template_search(
adt, "action_slot",
adt, "action_slots",
new="",
unlink="anim.slot_unassign_object",
)
internal_sub = slot_sub.box().column(align=True)
internal_sub.active = False # Just to dim.
internal_sub.prop(adt, "action_slot_handle", text="handle")
if adt.action_slot:
internal_sub.prop(adt.action_slot, "name", text="Internal Name")
Anim: Change how names of Bindings work, and how Bindings are created/assigned This cleans up some of the Animation/Binding API, and adds a distinction between a binding's "name" and its "display name". `name`: internal name that is unique within the `Animation`. As such, it is also the key into the `anim.bindings` collection. - To ensure the uniqueness, `name` is always prefxed with the ID identifier, like `OBCube` and `CACamera`. - A binding that was not created to animate a specific ID will be called `XXBinding`. `name_display`: display name that strips the first two characters, so in the above examples would be `Cube`, `Camera`, and `Binding`. ### RNA setter behaviour `name`: always sets the name, emitting a warning when the name's prefix doesn't match the ID type of the Binding. This implicitly changes the display name (as they are two views into the same string). `name_display`: sets `name = prefix_for_ID_type + name_display`. So even when the old name was `QQSomethingWeird`, setting `binding.name_display = "NewName"` would effectively set `binding.name = "OBNewName"` (assuming it was already bound to some object earlier). Bindings now also **always have a name**. Previously it was possible to create bindings named `""`, but that's no longer possible. Bindings used to be **renamed automatically** when they were first assigned, for example from `XXBinding` to `OBCube`. This behaviour has been removed, as it could potentially cause confusion. Pull Request: https://projects.blender.org/blender/blender/pulls/120941
2024-04-30 15:51:47 +02:00
if adt:
col.prop(adt, "action_slot_name", text="ADT Slot Name")
else:
col.label(text="ADT Slot Name: -")
classes = (
VIEW3D_PT_animation_layers,
)
if __name__ == "__main__": # only for live edit.
register_, _ = bpy.utils.register_classes_factory(classes)
register_()