Add an API for armature layer access. Instead of accessing `arm->layer` and friends directly, the code now uses this API. This will make things easier to replace by bone collections in the future. The functions are named "bonecoll" (short for "bone collection"), as that's the soon-to-be-introduced replacement for armature layers. This API is the first step towards that replacement, and should help to reduce the changes necessary when functional changes are committed. This also creates a new module `source/blender/animrig` for Animation & Rigging code. This will, for example, house the bone collection system in the near future. There is a bunch of code currently spread across blenkernel and editors in a rather ad-hoc way; it is intended that at some point that code gets moved into `animrig` as well (or at least the subset of that code where such a move makes sense; brain still required). Ref: #108941 No functional changes.
63 lines
1.4 KiB
C++
63 lines
1.4 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup animrig
|
|
*/
|
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
#include "BLI_math_bits.h"
|
|
|
|
#include "ANIM_bone_collections.h"
|
|
|
|
/* ********************************* */
|
|
/* Armature Layers transitional API. */
|
|
|
|
void ANIM_armature_enable_layers(bArmature *armature, const int layers)
|
|
{
|
|
armature->layer |= layers;
|
|
}
|
|
|
|
void ANIM_armature_disable_all_layers(bArmature *armature)
|
|
{
|
|
armature->layer = 0;
|
|
}
|
|
|
|
void ANIM_bone_set_layer_ebone(EditBone *ebone, const int layer)
|
|
{
|
|
ebone->layer = layer;
|
|
}
|
|
|
|
void ANIM_bone_set_ebone_layer_from_armature(EditBone *ebone, const bArmature *armature)
|
|
{
|
|
ebone->layer = armature->layer;
|
|
}
|
|
|
|
void ANIM_armature_ensure_first_layer_enabled(bArmature *armature)
|
|
{
|
|
armature->layer = 1;
|
|
}
|
|
|
|
void ANIM_armature_ensure_layer_enabled_from_bone(bArmature *armature, const Bone *bone)
|
|
{
|
|
if (ANIM_bonecoll_is_visible(armature, bone)) {
|
|
return;
|
|
}
|
|
armature->layer |= 1U << bitscan_forward_uint(bone->layer);
|
|
}
|
|
|
|
void ANIM_armature_ensure_layer_enabled_from_ebone(bArmature *armature, const EditBone *ebone)
|
|
{
|
|
if (ANIM_bonecoll_is_visible_editbone(armature, ebone)) {
|
|
return;
|
|
}
|
|
armature->layer |= 1U << bitscan_forward_uint(ebone->layer);
|
|
}
|
|
|
|
void ANIM_armature_ensure_layer_enabled_from_pchan(bArmature *armature, const bPoseChannel *pchan)
|
|
{
|
|
ANIM_armature_ensure_layer_enabled_from_bone(armature, pchan->bone);
|
|
}
|