Anim: update slot selection for Action Constraint
Like with NLA strips, Action assignment on Action Constraints needs to have an extra step (compared to regular assignment to animated data-blocks). For the Action Constraint, the auto slot selection gets one more fallback option (compared to the generic code). This is to support the following scenario, which used to be necessary as a workaround for a bug in Blender (#127976): - Python script creates an Action, - assigns it to the animated object, - unassigns it from that object, - and assigns it to the object's Action Constraint. The generic code doesn't work for this. The first assignment would see the slot `XXSlot`, and because it has never been used, just use it. This would change its name to `OBSlot`. The assignment to the Action Constraint would not see a 'virgin' slot, and thus not auto-select `OBSlot`. This behaviour makes sense when assigning Actions in the Action editor (it shouldn't automatically pick the first slot of matching ID type), but for the Action Constraint I (Sybren) feel that it could be a bit more 'enthousiastic' in auto-picking a slot. Note that this is the same behaviour as for NLA strips, albeit for a slightly different reason. Because of that it's not sharing code with the NLA. Pull Request: https://projects.blender.org/blender/blender/pulls/128892
This commit is contained in:
@@ -11,6 +11,7 @@ import sys
|
||||
import unittest
|
||||
|
||||
import bpy
|
||||
from bpy.types import Constraint
|
||||
from mathutils import Matrix
|
||||
|
||||
|
||||
@@ -439,6 +440,37 @@ class CopyTransformsTest(AbstractConstraintTests):
|
||||
)))
|
||||
|
||||
|
||||
class ActionConstraintTest(AbstractConstraintTests):
|
||||
layer_collection = "Action"
|
||||
|
||||
def setUp(self):
|
||||
bpy.context.preferences.view.show_developer_ui = True
|
||||
bpy.context.preferences.experimental.use_animation_baklava = True
|
||||
return super().setUp()
|
||||
|
||||
def tearDown(self) -> None:
|
||||
bpy.context.preferences.view.show_developer_ui = False
|
||||
bpy.context.preferences.experimental.use_animation_baklava = False
|
||||
return super().tearDown()
|
||||
|
||||
def constraint(self) -> Constraint:
|
||||
owner = bpy.context.scene.objects["Action.owner"]
|
||||
constraint = owner.constraints["Action"]
|
||||
return constraint
|
||||
|
||||
def test_assign_action_slot_virgin(self):
|
||||
action = bpy.data.actions.new("Slotted")
|
||||
slot = action.slots.new()
|
||||
|
||||
con = self.constraint()
|
||||
con.action = action
|
||||
|
||||
self.assertEqual(
|
||||
slot,
|
||||
con.action_slot,
|
||||
"Assigning an Action with a virgin slot should automatically select that slot")
|
||||
|
||||
|
||||
def main():
|
||||
global args
|
||||
import argparse
|
||||
|
||||
Reference in New Issue
Block a user