Blender V5.0
ANIM_bone_collections.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#pragma once
12
13#ifndef __cplusplus
14# error This is a C++ header.
15#endif
16
17#include "BLI_map.hh"
18
19#include "BKE_armature.hh"
20
21#include "DNA_action_types.h"
22#include "DNA_armature_types.h"
23
24struct bArmature;
25struct Bone;
26struct BoneCollection;
27struct bPoseChannel;
28struct EditBone;
29
41
53void ANIM_bonecoll_free(BoneCollection *bcoll, bool do_id_user_count = true);
54
61
67
77 const char *name,
78 int parent_index = -1);
79
90 const bArmature *armature_src,
91 const BoneCollection *anchor_in_dst,
92 const BoneCollection *bcoll_to_copy);
93
97void ANIM_armature_bonecoll_remove_from_index(bArmature *armature, const int index);
98
103
113
119void ANIM_armature_bonecoll_active_index_set(bArmature *armature, int bone_collection_index);
120
127void ANIM_armature_bonecoll_active_name_set(bArmature *armature, const char *name);
128
139
146bool ANIM_armature_bonecoll_is_editable(const bArmature *armature, const BoneCollection *bcoll);
147
174bool ANIM_armature_bonecoll_move_to_index(bArmature *armature, int from_index, int to_index);
175
176enum class MoveLocation {
177 Before, /* Move to before the item at the given index. */
178 After, /* Move to after the item at the given index. */
179};
180
182 int from_index,
183 int to_index,
184 MoveLocation before_after);
185
197bool ANIM_armature_bonecoll_move(bArmature *armature, BoneCollection *bcoll, int step);
198
200 const char *name) ATTR_WARN_UNUSED_RESULT;
201
207 const char *name) ATTR_WARN_UNUSED_RESULT;
208
209void ANIM_armature_bonecoll_name_set(bArmature *armature, BoneCollection *bcoll, const char *name);
210
216void ANIM_bonecoll_show(bArmature *armature, BoneCollection *bcoll);
217
223void ANIM_bonecoll_hide(bArmature *armature, BoneCollection *bcoll);
224
236 BoneCollection *bcoll,
237 bool is_visible);
238
242void ANIM_armature_bonecoll_solo_set(bArmature *armature, BoneCollection *bcoll, bool is_solo);
243
248
254 const BoneCollection *bcoll);
255
259void ANIM_armature_bonecoll_is_expanded_set(BoneCollection *bcoll, bool is_expanded);
260
277
278/* Assign the edit bone to the armature's active collection. */
280
285 const BoneCollection *bcoll);
286
294
295/*
296 * Armature/Bone Layer abstractions. These functions are intended as the sole
297 * accessors for `bone->layer`, `armature->layer`, etc. to get a grip on which
298 * queries & operations are performed.
299 *
300 * The functions are named "bonecoll" (short for "bone collection"), as that's
301 * the soon-to-be-introduced replacement for armature layers. This API is the
302 * first step towards replacement.
303 */
304
306bool ANIM_bone_in_visible_collection(const bArmature *armature, const Bone *bone);
307
314bool ANIM_bonecoll_is_visible_editbone(const bArmature *armature, const EditBone *ebone);
315
316inline bool ANIM_bonecoll_is_visible_pchan(const bArmature *armature, const bPoseChannel *pchan)
317{
318 return ANIM_bone_in_visible_collection(armature, pchan->bone);
319}
320
321inline bool ANIM_bonecoll_is_visible_actbone(const bArmature *armature)
322{
323 return ANIM_bone_in_visible_collection(armature, armature->act_bone);
324}
325
328
332
333namespace blender::animrig {
334
339int armature_bonecoll_find_index(const bArmature *armature, const ::BoneCollection *bcoll);
340
344int armature_bonecoll_find_parent_index(const bArmature *armature, int bcoll_index);
345
354int armature_bonecoll_child_number_find(const bArmature *armature, const ::BoneCollection *bcoll);
355
365 ::BoneCollection *bcoll,
366 int new_child_number);
367
368bool armature_bonecoll_is_root(const bArmature *armature, int bcoll_index);
369
370bool armature_bonecoll_is_child_of(const bArmature *armature,
371 int potential_parent_index,
372 int potential_child_index);
373
375 int potential_parent_index,
376 int potential_descendant_index);
377
378bool bonecoll_has_children(const BoneCollection *bcoll);
379
388 Span<const BoneCollection *> bcolls_source);
389
404 int from_bcoll_index,
405 int to_child_num,
406 int from_parent_index,
407 int to_parent_index);
408
409/* --------------------------------------------------------------------
410 * The following functions are only used by edit-mode Armature undo:
411 */
412
441 BoneCollection ***bcoll_array_dst,
442 int *bcoll_array_dst_num,
443 BoneCollection **bcoll_array_src,
444 int bcoll_array_src_num,
445 bool do_id_user);
463void ANIM_bonecoll_array_free(BoneCollection ***bcoll_array,
464 int *bcoll_array_num,
465 bool do_id_user);
466
467} // namespace blender::animrig
void ANIM_armature_bonecoll_unassign_all_editbone(EditBone *ebone)
void ANIM_armature_refresh_solo_active(bArmature *armature)
void ANIM_armature_runtime_free(bArmature *armature)
bool ANIM_armature_bonecoll_assign_and_move(BoneCollection *bcoll, Bone *bone)
void ANIM_armature_bonecoll_active_set(bArmature *armature, BoneCollection *bcoll)
void ANIM_armature_bonecoll_hide_all(bArmature *armature)
bool ANIM_armature_bonecoll_is_editable(const bArmature *armature, const BoneCollection *bcoll)
BoneCollection * ANIM_armature_bonecoll_insert_copy_after(bArmature *armature_dst, const bArmature *armature_src, const BoneCollection *anchor_in_dst, const BoneCollection *bcoll_to_copy)
bool ANIM_armature_bonecoll_assign_and_move_editbone(BoneCollection *bcoll, EditBone *ebone)
void ANIM_armature_bonecoll_is_expanded_set(BoneCollection *bcoll, bool is_expanded)
int ANIM_armature_bonecoll_move_before_after_index(bArmature *armature, int from_index, int to_index, MoveLocation before_after)
void ANIM_bonecoll_hide(bArmature *armature, BoneCollection *bcoll)
void ANIM_armature_runtime_refresh(bArmature *armature)
void ANIM_armature_bonecoll_active_name_set(bArmature *armature, const char *name)
void ANIM_armature_bonecoll_show_from_ebone(bArmature *armature, const EditBone *ebone)
void ANIM_armature_bonecoll_show_from_bone(bArmature *armature, const Bone *bone)
bool ANIM_bonecoll_is_visible_editbone(const bArmature *armature, const EditBone *ebone)
BoneCollection * ANIM_bonecoll_new(const char *name) ATTR_WARN_UNUSED_RESULT
bool ANIM_armature_bonecoll_unassign_editbone(BoneCollection *bcoll, EditBone *ebone)
void ANIM_bonecoll_free(BoneCollection *bcoll, bool do_id_user_count=true)
void ANIM_armature_bonecoll_assign_active(const bArmature *armature, EditBone *ebone)
bool ANIM_armature_bonecoll_assign(BoneCollection *bcoll, Bone *bone)
void ANIM_armature_bonecoll_remove(bArmature *armature, BoneCollection *bcoll)
bool ANIM_armature_bonecoll_unassign(BoneCollection *bcoll, Bone *bone)
void ANIM_armature_bonecoll_unassign_all(Bone *bone)
void ANIM_bonecoll_show(bArmature *armature, BoneCollection *bcoll)
bool ANIM_armature_bonecoll_move_to_index(bArmature *armature, int from_index, int to_index)
void ANIM_armature_bonecoll_remove_from_index(bArmature *armature, const int index)
void ANIM_armature_bonecoll_show_from_pchan(bArmature *armature, const bPoseChannel *pchan)
bool ANIM_bonecoll_is_visible_pchan(const bArmature *armature, const bPoseChannel *pchan)
void ANIM_armature_bonecoll_active_runtime_refresh(bArmature *armature)
bool ANIM_armature_bonecoll_is_visible_effectively(const bArmature *armature, const BoneCollection *bcoll)
void ANIM_armature_bonecoll_name_set(bArmature *armature, BoneCollection *bcoll, const char *name)
void ANIM_armature_bonecoll_solo_set(bArmature *armature, BoneCollection *bcoll, bool is_solo)
int ANIM_armature_bonecoll_get_index_by_name(bArmature *armature, const char *name) ATTR_WARN_UNUSED_RESULT
void ANIM_armature_bonecoll_show_all(bArmature *armature)
bool ANIM_armature_bonecoll_move(bArmature *armature, BoneCollection *bcoll, int step)
BoneCollection * ANIM_armature_bonecoll_new(bArmature *armature, const char *name, int parent_index=-1)
void ANIM_armature_bonecoll_reconstruct(bArmature *armature)
bool ANIM_bonecoll_is_visible_actbone(const bArmature *armature)
bool ANIM_armature_bonecoll_contains_active_bone(const bArmature *armature, const BoneCollection *bcoll)
bool ANIM_bone_in_visible_collection(const bArmature *armature, const Bone *bone)
void ANIM_armature_bonecoll_is_visible_set(bArmature *armature, BoneCollection *bcoll, bool is_visible)
BoneCollection * ANIM_armature_bonecoll_get_by_name(bArmature *armature, const char *name) ATTR_WARN_UNUSED_RESULT
bool ANIM_armature_bonecoll_assign_editbone(BoneCollection *bcoll, EditBone *ebone)
void ANIM_armature_bonecoll_active_index_set(bArmature *armature, int bone_collection_index)
#define ATTR_WARN_UNUSED_RESULT
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
blender::Map< BoneCollection *, BoneCollection * > ANIM_bonecoll_array_copy_no_membership(BoneCollection ***bcoll_array_dst, int *bcoll_array_dst_num, BoneCollection **bcoll_array_src, int bcoll_array_src_num, bool do_id_user)
bool armature_bonecoll_is_root(const bArmature *armature, int bcoll_index)
void bonecolls_copy_expanded_flag(Span< BoneCollection * > bcolls_dest, Span< const BoneCollection * > bcolls_source)
int armature_bonecoll_child_number_find(const bArmature *armature, const ::BoneCollection *bcoll)
bool bonecoll_has_children(const BoneCollection *bcoll)
int armature_bonecoll_find_index(const bArmature *armature, const ::BoneCollection *bcoll)
bool armature_bonecoll_is_descendant_of(const bArmature *armature, int potential_parent_index, int potential_descendant_index)
int armature_bonecoll_find_parent_index(const bArmature *armature, int bcoll_index)
int armature_bonecoll_child_number_set(bArmature *armature, ::BoneCollection *bcoll, int new_child_number)
void ANIM_bonecoll_array_free(BoneCollection ***bcoll_array, int *bcoll_array_num, bool do_id_user)
int armature_bonecoll_move_to_parent(bArmature *armature, int from_bcoll_index, int to_child_num, int from_parent_index, int to_parent_index)
bool armature_bonecoll_is_child_of(const bArmature *armature, int potential_parent_index, int potential_child_index)
const char * name
Bone * bone
EditBone * ebone
struct Bone * bone