Blender V5.3
DNA_armature_types.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "DNA_ID.h"
12#include "DNA_defs.h"
13#include "DNA_listBase.h"
14#include "DNA_theme_types.h"
15
16#include "BLI_enum_flags.hh"
17#include "BLI_span.hh"
18
19namespace blender {
20
21namespace animrig {
22class BoneColor;
23}
24
25namespace bke {
27}
28
29struct AnimData;
30struct BoneCollection;
33struct EditBone;
34
35/* armature->flag */
36/* don't use bit 7, was saved in files to disable stuff */
37enum eArmature_Flag : int {
38 ARM_RESTPOS = (1 << 0),
40 ARM_FLAG_UNUSED_1 = (1 << 1), /* cleared */
41 ARM_DRAWAXES = (1 << 2),
42 ARM_DRAWNAMES = (1 << 3),
43 /* ARM_POSEMODE = (1 << 4), Deprecated. */
47 ARM_DRAW_RELATION_FROM_HEAD = (1 << 5), /* Cleared in versioning of pre-2.80 files. */
54 ARM_BCOLL_SOLO_ACTIVE = (1 << 6), /* Cleared in versioning of pre-2.80 files. */
55 ARM_FLAG_UNUSED_7 = (1 << 7), /* cleared */
56 ARM_MIRROR_EDIT = (1 << 8),
59 ARM_NO_CUSTOM = (1 << 10),
61 ARM_COL_CUSTOM = (1 << 11),
63 ARM_FLAG_UNUSED_12 = (1 << 12), /* cleared */
65 ARM_DS_EXPAND = (1 << 13),
67 ARM_HAS_VIZ_DEPS = (1 << 14),
68};
70
71/* armature->drawtype */
73 ARM_DRAW_TYPE_ARMATURE_DEFINED = -1, /* Use draw type from Armature (only used on Bones). */
79};
80
81/* armature->deformflag */
83 ARM_DEF_VGROUP = (1 << 0),
84 ARM_DEF_ENVELOPE = (1 << 1),
87 ARM_DEF_B_BONE_REST = (1 << 3), /* deprecated */
88#endif
90};
92
93#ifdef DNA_DEPRECATED_ALLOW /* Old animation system (armature only viz). */
95enum eArmature_PathFlag : short {
96 ARM_PATH_FNUMS = (1 << 0),
97 ARM_PATH_KFRAS = (1 << 1),
98 ARM_PATH_HEADS = (1 << 2),
99 ARM_PATH_ACFRA = (1 << 3),
100 ARM_PATH_KFNOS = (1 << 4),
101};
102#endif
103
104/* bone->flag */
105enum eBone_Flag : int {
116 BONE_SELECTED = (1 << 0),
117 BONE_ROOTSEL = (1 << 1),
118 BONE_TIPSEL = (1 << 2),
120 BONE_TRANSFORM = (1 << 3),
122 BONE_CONNECTED = (1 << 4),
123 /* 32 used to be quatrot, was always set in files, do not reuse unless you clear it always */
128 BONE_HIDDEN_P = (1 << 6),
130 BONE_DONE = (1 << 7),
134 BONE_HINGE = (1 << 9),
139 BONE_HIDDEN_A = (1 << 10),
141 BONE_MULT_VG_ENV = (1 << 11),
143 BONE_NO_DEFORM = (1 << 12),
144#ifdef DNA_DEPRECATED_ALLOW
146 BONE_UNKEYED = (1 << 13),
148 BONE_HINGE_CHILD_TRANSFORM = (1 << 14),
150 BONE_NO_SCALE = (1 << 15),
151#endif
153 BONE_DRAWWIRE = (1 << 17),
158#ifdef DNA_DEPRECATED_ALLOW
160 BONE_TRANSFORM_CHILD = (1 << 20),
161#endif
163 BONE_UNSELECTABLE = (1 << 21),
168#ifdef DNA_DEPRECATED_ALLOW
170 BONE_ADD_PARENT_END_ROLL = (1 << 24),
171#endif
176};
178
179/* bone->inherit_scale_mode */
181 /* Inherit all scale and shear. */
183 /* Inherit scale, but remove final shear. */
185 /* Inherit average scale. */
187 /* Inherit no scale or shear. */
189 /* Inherit effects of shear on parent (same as old disabled Inherit Scale). */
191 /* Inherit parent X scale as child X scale etc. */
193};
194
195/* bone->bbone_prev_type, bbone_next_type */
197 BBONE_HANDLE_AUTO = 0, /* Default mode based on parents & children. */
198 BBONE_HANDLE_ABSOLUTE = 1, /* Custom handle in absolute position mode. */
199 BBONE_HANDLE_RELATIVE = 2, /* Custom handle in relative position mode. */
200 BBONE_HANDLE_TANGENT = 3, /* Custom handle in tangent mode (use direction, not location). */
201};
202
203/* bone->bbone_mapping_mode */
205 BBONE_MAPPING_STRAIGHT = 0, /* Default mode that ignores the rest pose curvature. */
206 BBONE_MAPPING_CURVED = 1, /* Mode that takes the rest pose curvature into account. */
207};
208
209/* bone->bbone_flag */
217
218/* bone->bbone_prev/next_flag */
232
233#define MAXBONENAME 64
234
237 BONE_COLLECTION_VISIBLE = (1 << 0), /* Visibility flag of this particular collection. */
238 BONE_COLLECTION_SELECTABLE = (1 << 1), /* Intended to be implemented in the not-so-far future. */
239 BONE_COLLECTION_OVERRIDE_LIBRARY_LOCAL = (1 << 2), /* Added by a local library override. */
240
248
261
262 BONE_COLLECTION_EXPANDED = (1 << 5), /* Expanded in the tree view. */
263};
265
266/* The Armature system works on different transformation space levels:
267 *
268 * 1) Bone Space: In the orientation of the parent bone, position relative
269 * to the parent's tail. Same as Armature Space for bones
270 * without parent.
271 * 2) Armature Space: The bone's rest transform in Object space. This is the
272 * multiplication of the bone space matrices of the bone and
273 * all its ancestors.
274 * 3) Pose Space: The bone's posed transform in Object space. This is the
275 * same space as Armature Space, except that it represents
276 * the current bone transform instead of the rest pose.
277 * See bPoseChannel::pose_mat
278 * 4) Channel Space: The bone's local transform relative to its rest transform.
279 * See bPoseChannel::chan_mat
280 */
281
282struct BoneColor {
290 uint8_t _pad0[7] = {};
292#ifdef __cplusplus
294 const animrig::BoneColor &wrap() const;
295#endif
296};
297
299 ListBaseT<BoneCollectionReference> collections = {nullptr, nullptr};
300};
301
302struct Bone {
304
305
306 struct Bone *next = nullptr, *prev = nullptr;
308 IDProperty *prop = nullptr;
311 void *_pad0 = nullptr;
313 struct Bone *parent = nullptr;
315 ListBaseT<Bone> childbase = {nullptr, nullptr};
317 char name[/*MAXBONENAME*/ 64] = "";
318
320 float roll = 0;
322 float head[3] = {};
324 float tail[3] = {};
329 float bone_mat[3][3] = {};
330
333 char _pad1[3] = {};
334 BoneColor color; /* MUST be named the same as in bPoseChannel and EditBone structs. */
335
337 char _pad[3] = {};
338
340 float arm_head[3] = {};
342 float arm_tail[3] = {};
344 float arm_mat[4][4] = {};
346 float arm_roll = 0;
347
349 float dist = 0;
351 float weight = 0;
358 float xwidth = 0, length = 0, zwidth = 0;
363 float rad_head = 0, rad_tail = 0;
364
366 float roll1 = 0, roll2 = 0;
367 float curve_in_x = 0, curve_in_z = 0;
368 float curve_out_x = 0, curve_out_z = 0;
370 float ease1 = 0, ease2 = 0;
375 float scale_in[3] = {1.0f, 1.0f, 1.0f};
376 float scale_out[3] = {1.0f, 1.0f, 1.0f};
377
379 float size[3] = {};
381 int layer = 0;
383 short segments = 0;
386 char _pad2[7] = {};
387
396 struct Bone *bbone_prev = nullptr;
397 struct Bone *bbone_next = nullptr;
398
399 /* Keep last. */
401};
402
403struct bArmature {
404#ifdef __cplusplus
407 static constexpr ID_Type id_type = ID_AR;
408#endif
409
411 struct AnimData *adt = nullptr;
412
414 ListBaseT<Bone> bonebase = {nullptr, nullptr};
415
417 struct GHash *bonehash = nullptr;
418 void *_pad1 = nullptr;
419
421 ListBaseT<EditBone> *edbo = nullptr;
422
423 /* active bones should work like active object where possible
424 * - active and selection are unrelated
425 * - active & hidden is not allowed
426 * - from the user perspective active == last selected
427 * - active should be ignored when not visible (hidden layer) */
428
430 Bone *act_bone = nullptr;
432 struct EditBone *act_edbone = nullptr;
433
436 char _pad0[3] = {};
437
440
442 short pathflag = 0;
443
450 ListBaseT<BoneCollection> collections_legacy = {nullptr, nullptr};
451
453 nullptr; /* Array of `collection_array_num` BoneCollections. */
461
466 char active_collection_name[/*MAX_NAME*/ 64] = "";
467
469 DNA_DEPRECATED unsigned int layer_used = 0;
471 DNA_DEPRECATED unsigned int layer = 1;
473
475 float axes_position = 0;
476
479
480#ifdef __cplusplus
481 /* Collection array access for convenient for-loop iteration. */
482 Span<const BoneCollection *> collections_span() const;
483 Span<BoneCollection *> collections_span();
484
485 /* Span of all root collections. */
486 Span<const BoneCollection *> collections_roots() const;
487 Span<BoneCollection *> collections_roots();
488
489 /* Return the span of children of the given bone collection. */
490 Span<const BoneCollection *> collection_children(const BoneCollection *parent) const;
491 Span<BoneCollection *> collection_children(BoneCollection *parent);
492
493 const Bone *bone_get_indexed(int64_t bone_index) const;
494 Bone *bone_get_indexed(int64_t bone_index);
495
496#endif
497};
498
511 struct BoneCollection *next = nullptr, *prev = nullptr;
512
513 char name[/*MAX_NAME*/ 64] = "";
514
515 ListBaseT<BoneCollectionMember> bones = {nullptr, nullptr};
516
518 uint8_t _pad0[7] = {};
519
520 /*
521 * Hierarchy information. The Armature has an array of BoneCollection pointers. These are ordered
522 * such that siblings are always stored in consecutive array elements.
523 */
525 int child_index = 0;
527 int child_count = 0;
528
530 struct IDProperty *prop = nullptr;
532 struct IDProperty *system_properties = nullptr;
533
534#ifdef __cplusplus
544 bool is_visible() const;
545
551 bool is_visible_ancestors() const;
552
561 bool is_visible_with_ancestors() const;
562
566 bool is_solo() const;
572 bool is_expanded() const;
573#endif
574};
575
578 struct BoneCollectionMember *next = nullptr, *prev = nullptr;
579 struct Bone *bone = nullptr;
580};
581
589 struct BoneCollectionReference *next = nullptr, *prev = nullptr;
590 struct BoneCollection *bcoll = nullptr;
591};
592
593#ifdef __cplusplus
594
595inline animrig::BoneColor &BoneColor::wrap()
596{
597 return *reinterpret_cast<animrig::BoneColor *>(this);
598}
599inline const animrig::BoneColor &BoneColor::wrap() const
600{
601 return *reinterpret_cast<const animrig::BoneColor *>(this);
602}
603#endif
604
605} // namespace blender
#define ENUM_OPERATORS(_enum_type)
ID and Library types, which are fundamental for SDNA.
#define DNA_DEFINE_CXX_METHODS(class_name)
Definition DNA_defs.h:104
#define DNA_DEPRECATED
Definition DNA_defs.h:21
These structs are the foundation for all linked lists in the library system.
ENUM_OPERATORS(Layer::Flags)
BLI_INLINE Texture * wrap(MTLTexture *texture)
BMesh Iterators.
__int64 int64_t
Definition BKE_text.h:90
@ ARM_DRAW_RELATION_FROM_HEAD
unsigned char uint8_t
Definition BKE_text.h:79
@ ARM_DRAW_TYPE_ARMATURE_DEFINED
@ BONE_INHERIT_SCALE_NONE_LEGACY
@ BONE_INHERIT_SCALE_FIX_SHEAR
@ BONE_COLLECTION_OVERRIDE_LIBRARY_LOCAL
@ BONE_COLLECTION_ANCESTORS_VISIBLE
signed char int8_t
Definition BKE_text.h:76
struct BoneCollectionMember * next
struct BoneCollectionMember * prev
struct BoneCollectionReference * prev
struct BoneCollectionReference * next
struct BoneCollection * prev
eBoneCollection_Flag flags
struct IDProperty * system_properties
ListBaseT< BoneCollectionMember > bones
struct BoneCollection * next
ListBaseT< BoneCollectionReference > collections
struct Bone * bbone_prev
eBone_BBoneFlag bbone_flag
eBone_BBoneHandleFlag bbone_next_flag
DNA_DEPRECATED float scale_in_x
struct Bone * bbone_next
struct Bone * parent
eBone_BBoneHandleType bbone_prev_type
eBone_BBoneHandleFlag bbone_prev_flag
eBone_BBoneMappingMode bbone_mapping_mode
DNA_DEPRECATED float scale_out_z
Bone_Runtime runtime
eBone_BBoneHandleType bbone_next_type
IDProperty * system_properties
struct Bone * next
struct Bone * prev
ListBaseT< Bone > childbase
DNA_DEPRECATED float scale_out_x
DNA_DEPRECATED float scale_in_z
eBone_InheritScaleMode inherit_scale_mode
ListBaseT< EditBone > * edbo
DNA_DEPRECATED unsigned int layer
eArmature_DeformFlag deformflag
struct EditBone * act_edbone
struct AnimData * adt
DNA_DEPRECATED unsigned int layer_protected
bke::bArmature_Runtime * runtime
ListBaseT< Bone > bonebase
struct BoneCollection ** collection_array
DNA_DEPRECATED unsigned int layer_used
ListBaseT< BoneCollection > collections_legacy
eArmature_Drawtype drawtype
#define DNA_DEPRECATED_ALLOW
Definition versioning.cc:11