Blender V5.3
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#include "BLI_map.hh"
14
15#include "BKE_armature.hh"
16
17#include "DNA_action_types.h"
18#include "DNA_armature_types.h"
19
20namespace blender {
21
22struct bArmature;
23struct Bone;
24struct BoneCollection;
25struct bPoseChannel;
26struct EditBone;
27
39
51void ANIM_bonecoll_free(BoneCollection *bcoll, bool do_id_user_count = true);
52
59
65
75 const char *name,
76 int parent_index = -1);
77
88 const bArmature *armature_src,
89 const BoneCollection *anchor_in_dst,
90 const BoneCollection *bcoll_to_copy);
91
96
101
111
117void ANIM_armature_bonecoll_active_index_set(bArmature *armature, int bone_collection_index);
118
125void ANIM_armature_bonecoll_active_name_set(bArmature *armature, const char *name);
126
137
144bool ANIM_armature_bonecoll_is_editable(const bArmature *armature, const BoneCollection *bcoll);
145
172bool ANIM_armature_bonecoll_move_to_index(bArmature *armature, int from_index, int to_index);
173
174enum class MoveLocation {
175 Before, /* Move to before the item at the given index. */
176 After, /* Move to after the item at the given index. */
177};
178
180 int from_index,
181 int to_index,
182 MoveLocation before_after);
183
195bool ANIM_armature_bonecoll_move(bArmature *armature, BoneCollection *bcoll, int step);
196
197BoneCollection *ANIM_armature_bonecoll_get_by_name(bArmature *armature,
198 const char *name) ATTR_WARN_UNUSED_RESULT;
199
205int ANIM_armature_bonecoll_get_index_by_name(bArmature *armature,
206 const char *name) ATTR_WARN_UNUSED_RESULT;
207
208void ANIM_armature_bonecoll_name_set(Main &bmain,
209 bArmature *armature,
210 BoneCollection *bcoll,
211 const char *name);
212
219void ANIM_bonecoll_show(bArmature *armature, BoneCollection *bcoll);
220
227void ANIM_bonecoll_hide(bArmature *armature, BoneCollection *bcoll);
228
239void ANIM_armature_bonecoll_is_visible_set(bArmature *armature,
240 BoneCollection *bcoll,
241 bool is_visible);
242
246void ANIM_armature_bonecoll_solo_set(bArmature *armature, BoneCollection *bcoll, bool is_solo);
247
251void ANIM_armature_refresh_solo_active(bArmature *armature);
252
257bool ANIM_armature_bonecoll_is_visible_effectively(const bArmature *armature,
258 const BoneCollection *bcoll);
259
263void ANIM_armature_bonecoll_is_expanded_set(BoneCollection *bcoll, bool is_expanded);
264
273bool ANIM_armature_bonecoll_assign(BoneCollection *bcoll, Bone *bone);
274bool ANIM_armature_bonecoll_assign_editbone(BoneCollection *bcoll, EditBone *ebone);
278void ANIM_armature_bonecoll_assign_from_other_editbone(EditBone *dst, EditBone *src);
279bool ANIM_armature_bonecoll_assign_and_move(BoneCollection *bcoll, Bone *bone);
280bool ANIM_armature_bonecoll_assign_and_move_editbone(BoneCollection *bcoll, EditBone *ebone);
281bool ANIM_armature_bonecoll_unassign(BoneCollection *bcoll, Bone *bone);
282bool ANIM_armature_bonecoll_unassign_editbone(BoneCollection *bcoll, EditBone *ebone);
285
286/* Assign the edit bone to the armature's active collection. */
287void ANIM_armature_bonecoll_assign_active(const bArmature *armature, EditBone *ebone);
288
292bool ANIM_armature_bonecoll_contains_active_bone(const bArmature *armature,
293 const BoneCollection *bcoll);
294
301void ANIM_armature_bonecoll_reconstruct(bArmature *armature);
302
303/*
304 * Armature/Bone Layer abstractions. These functions are intended as the sole
305 * accessors for `bone->layer`, `armature->layer`, etc. to get a grip on which
306 * queries & operations are performed.
307 *
308 * The functions are named "bonecoll" (short for "bone collection"), as that's
309 * the soon-to-be-introduced replacement for armature layers. This API is the
310 * first step towards replacement.
311 */
312
314bool ANIM_bone_in_visible_collection(const bArmature *armature, const Bone *bone);
315
322bool ANIM_bonecoll_is_visible_editbone(const bArmature *armature, const EditBone *ebone);
323
324inline bool ANIM_bonecoll_is_visible_pchan(const bArmature *armature, const bPoseChannel *pchan)
325{
326 return ANIM_bone_in_visible_collection(armature, pchan->bone_get(*armature));
327}
328
329inline bool ANIM_bonecoll_is_visible_actbone(const bArmature *armature)
330{
331 return ANIM_bone_in_visible_collection(armature, armature->act_bone);
332}
333
334void ANIM_armature_bonecoll_show_all(bArmature *armature);
335void ANIM_armature_bonecoll_hide_all(bArmature *armature);
336
337void ANIM_armature_bonecoll_show_from_bone(bArmature *armature, const Bone *bone);
338void ANIM_armature_bonecoll_show_from_ebone(bArmature *armature, const EditBone *ebone);
339void ANIM_armature_bonecoll_show_from_pchan(bArmature *armature, const bPoseChannel *pchan);
340
341namespace animrig {
342
347int armature_bonecoll_find_index(const bArmature *armature, const BoneCollection *bcoll);
348
352int armature_bonecoll_find_parent_index(const bArmature *armature, int bcoll_index);
353
362int armature_bonecoll_child_number_find(const bArmature *armature, const BoneCollection *bcoll);
363
372int armature_bonecoll_child_number_set(bArmature *armature,
373 BoneCollection *bcoll,
374 int new_child_number);
375
376bool armature_bonecoll_is_root(const bArmature *armature, int bcoll_index);
377
378bool armature_bonecoll_is_child_of(const bArmature *armature,
379 int potential_parent_index,
380 int potential_child_index);
381
382bool armature_bonecoll_is_descendant_of(const bArmature *armature,
383 int potential_parent_index,
384 int potential_descendant_index);
385
386bool bonecoll_has_children(const BoneCollection *bcoll);
387
396 Span<const BoneCollection *> bcolls_source);
397
411int armature_bonecoll_move_to_parent(bArmature *armature,
412 int from_bcoll_index,
413 int to_child_num,
414 int from_parent_index,
415 int to_parent_index);
416
417/* --------------------------------------------------------------------
418 * The following functions are only used by edit-mode Armature undo:
419 */
420
448Map<BoneCollection *, BoneCollection *> ANIM_bonecoll_array_copy_no_membership(
449 BoneCollection ***bcoll_array_dst,
450 int *bcoll_array_dst_num,
451 BoneCollection **bcoll_array_src,
452 int bcoll_array_src_num,
453 bool do_id_user);
471void ANIM_bonecoll_array_free(BoneCollection ***bcoll_array,
472 int *bcoll_array_num,
473 bool do_id_user);
474
475} // namespace animrig
476} // namespace blender
#define ATTR_WARN_UNUSED_RESULT
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
int armature_bonecoll_find_index(const bArmature *armature, const BoneCollection *bcoll)
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)
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 bonecoll_has_children(const BoneCollection *bcoll)
int armature_bonecoll_child_number_set(bArmature *armature, BoneCollection *bcoll, int new_child_number)
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_find(const bArmature *armature, const BoneCollection *bcoll)
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)
BMesh Iterators.
void ANIM_armature_runtime_free(bArmature *armature)
void ANIM_bonecoll_show(bArmature *armature, BoneCollection *bcoll)
void ANIM_armature_bonecoll_is_expanded_set(BoneCollection *bcoll, bool is_expanded)
bool ANIM_armature_bonecoll_assign(BoneCollection *bcoll, Bone *bone)
bool ANIM_armature_bonecoll_assign_editbone(BoneCollection *bcoll, EditBone *ebone)
void ANIM_armature_bonecoll_active_index_set(bArmature *armature, int bone_collection_index)
BoneCollection * ANIM_armature_bonecoll_new(bArmature *armature, const char *name, int parent_index=-1)
void ANIM_armature_bonecoll_remove(bArmature *armature, BoneCollection *bcoll)
bool ANIM_bone_in_visible_collection(const bArmature *armature, const Bone *bone)
bool ANIM_armature_bonecoll_assign_and_move(BoneCollection *bcoll, Bone *bone)
BoneCollection * ANIM_bonecoll_new(const char *name) ATTR_WARN_UNUSED_RESULT
bool ANIM_bonecoll_is_visible_actbone(const bArmature *armature)
bool ANIM_bonecoll_is_visible_pchan(const bArmature *armature, const bPoseChannel *pchan)
void ANIM_armature_bonecoll_active_runtime_refresh(bArmature *armature)
void ANIM_bonecoll_free(BoneCollection *bcoll, bool do_id_user_count=true)
void ANIM_armature_bonecoll_hide_all(bArmature *armature)
void ANIM_armature_refresh_solo_active(bArmature *armature)
BoneCollection * ANIM_armature_bonecoll_insert_copy_after(bArmature *armature_dst, const bArmature *armature_src, const BoneCollection *anchor_in_dst, const BoneCollection *bcoll_to_copy)
void ANIM_armature_bonecoll_unassign_all(Bone *bone)
void ANIM_armature_bonecoll_reconstruct(bArmature *armature)
bool ANIM_armature_bonecoll_unassign_editbone(BoneCollection *bcoll, EditBone *ebone)
bool ANIM_bonecoll_is_visible_editbone(const bArmature *armature, const EditBone *ebone)
BoneCollection * ANIM_armature_bonecoll_get_by_name(bArmature *armature, const char *name) ATTR_WARN_UNUSED_RESULT
void ANIM_armature_bonecoll_remove_from_index(bArmature *armature, const int index)
bool ANIM_armature_bonecoll_contains_active_bone(const bArmature *armature, const BoneCollection *bcoll)
void ANIM_bonecoll_hide(bArmature *armature, BoneCollection *bcoll)
void ANIM_armature_bonecoll_active_name_set(bArmature *armature, const char *name)
bool ANIM_armature_bonecoll_assign_and_move_editbone(BoneCollection *bcoll, EditBone *ebone)
void ANIM_armature_bonecoll_show_all(bArmature *armature)
void ANIM_armature_bonecoll_show_from_ebone(bArmature *armature, const EditBone *ebone)
int ANIM_armature_bonecoll_get_index_by_name(bArmature *armature, const char *name) ATTR_WARN_UNUSED_RESULT
void ANIM_armature_bonecoll_show_from_pchan(bArmature *armature, const bPoseChannel *pchan)
void ANIM_armature_bonecoll_assign_from_other_editbone(EditBone *dst, EditBone *src)
void ANIM_armature_bonecoll_active_set(bArmature *armature, BoneCollection *bcoll)
void ANIM_armature_bonecoll_assign_active(const bArmature *armature, EditBone *ebone)
void ANIM_armature_bonecoll_name_set(Main &bmain, bArmature *armature, BoneCollection *bcoll, const char *name)
void ANIM_armature_runtime_refresh(bArmature *armature)
bool ATTR_WARN_UNUSED_RESULT
bool ANIM_armature_bonecoll_unassign(BoneCollection *bcoll, Bone *bone)
bool ANIM_armature_bonecoll_move_to_index(bArmature *armature, int from_index, int to_index)
void ANIM_armature_bonecoll_is_visible_set(bArmature *armature, BoneCollection *bcoll, bool is_visible)
int ANIM_armature_bonecoll_move_before_after_index(bArmature *armature, int from_index, int to_index, MoveLocation before_after)
bool ANIM_armature_bonecoll_is_visible_effectively(const bArmature *armature, const BoneCollection *bcoll)
bool ANIM_armature_bonecoll_move(bArmature *armature, BoneCollection *bcoll, int step)
void ANIM_armature_bonecoll_solo_set(bArmature *armature, BoneCollection *bcoll, bool is_solo)
bool ANIM_armature_bonecoll_is_editable(const bArmature *armature, const BoneCollection *bcoll)
void ANIM_armature_bonecoll_show_from_bone(bArmature *armature, const Bone *bone)
void ANIM_armature_bonecoll_unassign_all_editbone(EditBone *ebone)