When creating a new NLA strip for an action, as well as when setting `strip.action` via RNA, use the generic action-assignment code. This ensures that the slot selection follows the same logic as other Action assignments. If the generic slot selection doesn't find a suitable slot, and there is a single slot on that Action of a suitable ID type, always assign it. This is to support the following scenario: - Python script creates an Action and adds F-Curves via the legacy API. - This creates a slot 'XXSlot'. - The script creates multiple NLA strips for that Action. - The desired result is that these strips get the same Slot assigned as well. The generic code doesn't work for this, because: - The first strip assignment would see the slot `XXSlot` (`XX` indicating "not bound to any ID type yet"). Because that slot has never been used, it will be assigned (which is good). This assignment would change its name to, for example, `OBSlot`. - The second strip assignment would not see a 'virgin' slot, and thus not auto-select `OBSlot`. This behaviour makes sense when assigning Actions in the Action editor (assigning an Action that already animates 'Cube' to 'Suzanne' should not assign the 'OBCube' slot to Suzanne), but for the NLA I feel that it could be a bit more 'enthousiastic' in auto-picking a slot to support the above case. This is preparation for the removal of the 'Slotted Actions' experimental flag, and getting the new code to run as compatibly as possible with the legacy code. The return value of `animrig::nla::assign_action()` has changed a bit. It used to indicate whether a slot was auto-selected; it now indicates whether the Action assignment was successful. Whether a slot was assigned or not can be seen at `strip.action_slot`. Pull Request: https://projects.blender.org/blender/blender/pulls/128892
48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
/* SPDX-FileCopyrightText: 2024 Blender Authors. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
/** \file
|
|
* \ingroup animrig
|
|
*/
|
|
|
|
#include "ANIM_action.hh"
|
|
|
|
struct ID;
|
|
struct NlaStrip;
|
|
|
|
namespace blender::animrig::nla {
|
|
|
|
/**
|
|
* Assign the Action to this NLA strip.
|
|
*
|
|
* Similar to animrig::assign_action(), this tries to find a suitable slot.
|
|
*
|
|
* \see blender::animrig::assign_action
|
|
*
|
|
* \returns whether the assignment was ok.
|
|
*/
|
|
bool assign_action(NlaStrip &strip, Action &action, ID &animated_id);
|
|
|
|
void unassign_action(NlaStrip &strip, ID &animated_id);
|
|
|
|
/**
|
|
* Assign a slot to the NLA strip.
|
|
*
|
|
* The strip should already have an Action assigned to it, and the given Slot should belong to that
|
|
* Action.
|
|
*
|
|
* \param slot_to_assign: the slot to assign, or nullptr to un-assign the current slot.
|
|
*/
|
|
ActionSlotAssignmentResult assign_action_slot(NlaStrip &strip,
|
|
Slot *slot_to_assign,
|
|
ID &animated_id);
|
|
|
|
ActionSlotAssignmentResult assign_action_slot_handle(NlaStrip &strip,
|
|
slot_handle_t slot_handle,
|
|
ID &animated_id);
|
|
|
|
} // namespace blender::animrig::nla
|