Refactor: Anim, move refresh of active bone collection to own function
Move some of the functionality of `ANIM_armature_runtime_refresh()` into a function of its own (`ANIM_armature_bonecoll_active_runtime_refresh()`). It will be called from another place as well in upcoming commits. No functional changes.
This commit is contained in:
@@ -122,6 +122,17 @@ void ANIM_armature_bonecoll_active_index_set(struct bArmature *armature,
|
||||
*/
|
||||
void ANIM_armature_bonecoll_active_name_set(struct bArmature *armature, const char *name);
|
||||
|
||||
/**
|
||||
* Refresh the Armature runtime info about the active bone collection.
|
||||
*
|
||||
* The ground truth for the active bone collection is the collection's name,
|
||||
* whereas the runtime info also contains the active collection's index and
|
||||
* pointer. This function updates the runtime info to point to the named
|
||||
* collection. If that named collection cannot be found, the name will be
|
||||
* cleared.
|
||||
*/
|
||||
void ANIM_armature_bonecoll_active_runtime_refresh(struct bArmature *armature);
|
||||
|
||||
/**
|
||||
* Determine whether the given bone collection is editable.
|
||||
*
|
||||
|
||||
@@ -93,10 +93,7 @@ static void add_reverse_pointers(BoneCollection *bcoll)
|
||||
void ANIM_armature_runtime_refresh(bArmature *armature)
|
||||
{
|
||||
ANIM_armature_runtime_free(armature);
|
||||
|
||||
BoneCollection *active = ANIM_armature_bonecoll_get_by_name(armature,
|
||||
armature->active_collection_name);
|
||||
ANIM_armature_bonecoll_active_set(armature, active);
|
||||
ANIM_armature_bonecoll_active_runtime_refresh(armature);
|
||||
|
||||
/* Construct the bone-to-collections mapping. */
|
||||
for (BoneCollection *bcoll : armature->collections_span()) {
|
||||
@@ -282,6 +279,28 @@ void ANIM_armature_bonecoll_active_name_set(bArmature *armature, const char *nam
|
||||
ANIM_armature_bonecoll_active_set(armature, bcoll);
|
||||
}
|
||||
|
||||
void ANIM_armature_bonecoll_active_runtime_refresh(struct bArmature *armature)
|
||||
{
|
||||
const std::string_view active_name = armature->active_collection_name;
|
||||
if (active_name.empty()) {
|
||||
armature_bonecoll_active_clear(armature);
|
||||
return;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for (BoneCollection *bcoll : armature->collections_span()) {
|
||||
if (bcoll->name == active_name) {
|
||||
armature->runtime.active_collection_index = index;
|
||||
armature->runtime.active_collection = bcoll;
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
/* No bone collection with the name was found, so better to clear everything.*/
|
||||
armature_bonecoll_active_clear(armature);
|
||||
}
|
||||
|
||||
bool ANIM_armature_bonecoll_is_editable(const bArmature *armature, const BoneCollection *bcoll)
|
||||
{
|
||||
const bool is_override = ID_IS_OVERRIDE_LIBRARY(armature);
|
||||
|
||||
Reference in New Issue
Block a user