Blender V5.0
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_userdef_types.h"
15
16#include "BLI_utildefines.h"
17
18#include "BLI_utildefines.h"
19
20#ifdef __cplusplus
21# include "BLI_span.hh"
22namespace blender::animrig {
23class BoneColor;
24}
25#endif
26
27struct AnimData;
28struct BoneCollection;
29
30/* The Armature system works on different transformation space levels:
31 *
32 * 1) Bone Space: In the orientation of the parent bone, position relative
33 * to the parent's tail. Same as Armature Space for bones
34 * without parent.
35 * 2) Armature Space: The bone's rest transform in Object space. This is the
36 * multiplication of the bone space matrices of the bone and
37 * all its ancestors.
38 * 3) Pose Space: The bone's posed transform in Object space. This is the
39 * same space as Armature Space, except that it represents
40 * the current bone transform instead of the rest pose.
41 * See bPoseChannel::pose_mat
42 * 4) Channel Space: The bone's local transform relative to its rest transform.
43 * See bPoseChannel::chan_mat
44 */
45
46typedef struct BoneColor {
54 uint8_t _pad0[7];
56#ifdef __cplusplus
58 const blender::animrig::BoneColor &wrap() const;
59#endif
61
62typedef struct Bone_Runtime {
63 /* #BoneCollectionReference */
66
67typedef struct Bone {
69 struct Bone *next, *prev;
74 void *_pad0;
76 struct Bone *parent;
80 char name[/*MAXBONENAME*/ 64];
81
83 float roll;
85 float head[3];
87 float tail[3];
92 float bone_mat[3][3];
93
94 int flag;
95 int8_t drawtype; /* eArmature_Drawtype */
96 char _pad1[3];
97 BoneColor color; /* MUST be named the same as in bPoseChannel and EditBone structs. */
98
100 char _pad[3];
101
103 float arm_head[3];
105 float arm_tail[3];
107 float arm_mat[4][4];
109 float arm_roll;
110
112 float dist;
114 float weight;
127
129 float roll1, roll2;
133 float ease1, ease2;
134 float scale_in_x DNA_DEPRECATED, scale_in_z DNA_DEPRECATED;
135 float scale_out_x DNA_DEPRECATED, scale_out_z DNA_DEPRECATED;
136 float scale_in[3], scale_out[3];
137
139 float size[3];
141 int layer;
143 short segments;
146 char _pad2[7];
147
158
159 /* Keep last. */
162
174
175typedef struct bArmature {
176#ifdef __cplusplus
178 static constexpr ID_Type id_type = ID_AR;
179#endif
180
182 struct AnimData *adt;
183
185
188 void *_pad1;
189
192
193 /* active bones should work like active object where possible
194 * - active and selection are unrelated
195 * - active & hidden is not allowed
196 * - from the user perspective active == last selected
197 * - active should be ignored when not visible (hidden layer) */
198
203
206 char _pad0[3];
207
208 int flag;
209 int drawtype; /* eArmature_Drawtype */
210
212 short pathflag;
213
220 ListBase collections_legacy; /* BoneCollection. */
221
222 struct BoneCollection **collection_array; /* Array of `collection_array_num` BoneCollections. */
230
235 char active_collection_name[/*MAX_NAME*/ 64];
236
238 unsigned int layer_used DNA_DEPRECATED;
240 unsigned int layer DNA_DEPRECATED, layer_protected DNA_DEPRECATED;
241
244
247
248#ifdef __cplusplus
249 /* Collection array access for convenient for-loop iteration. */
250 blender::Span<const BoneCollection *> collections_span() const;
251 blender::Span<BoneCollection *> collections_span();
252
253 /* Span of all root collections. */
254 blender::Span<const BoneCollection *> collections_roots() const;
255 blender::Span<BoneCollection *> collections_roots();
256
257 /* Return the span of children of the given bone collection. */
258 blender::Span<const BoneCollection *> collection_children(const BoneCollection *parent) const;
259 blender::Span<BoneCollection *> collection_children(BoneCollection *parent);
260#endif
262
274typedef struct BoneCollection {
276
277 char name[/*MAX_NAME*/ 64];
278
281
283 uint8_t flags;
284 uint8_t _pad0[7];
285
286 /*
287 * Hierarchy information. The Armature has an array of BoneCollection pointers. These are ordered
288 * such that siblings are always stored in consecutive array elements.
289 */
294
299
300#ifdef __cplusplus
310 bool is_visible() const;
311
317 bool is_visible_ancestors() const;
318
327 bool is_visible_with_ancestors() const;
328
332 bool is_solo() const;
338 bool is_expanded() const;
339#endif
341
347
358
359/* armature->flag */
360/* don't use bit 7, was saved in files to disable stuff */
361typedef enum eArmature_Flag {
362 ARM_RESTPOS = (1 << 0),
364 ARM_FLAG_UNUSED_1 = (1 << 1), /* cleared */
365 ARM_DRAWAXES = (1 << 2),
366 ARM_DRAWNAMES = (1 << 3),
367 /* ARM_POSEMODE = (1 << 4), Deprecated. */
371 ARM_DRAW_RELATION_FROM_HEAD = (1 << 5), /* Cleared in versioning of pre-2.80 files. */
378 ARM_BCOLL_SOLO_ACTIVE = (1 << 6), /* Cleared in versioning of pre-2.80 files. */
379 ARM_FLAG_UNUSED_7 = (1 << 7), /* cleared */
380 ARM_MIRROR_EDIT = (1 << 8),
383 ARM_NO_CUSTOM = (1 << 10),
385 ARM_COL_CUSTOM = (1 << 11),
387 ARM_FLAG_UNUSED_12 = (1 << 12), /* cleared */
389 ARM_DS_EXPAND = (1 << 13),
391 ARM_HAS_VIZ_DEPS = (1 << 14),
393
394/* armature->drawtype */
403
404/* armature->deformflag */
406 ARM_DEF_VGROUP = (1 << 0),
410 ARM_DEF_B_BONE_REST = (1 << 3), /* deprecated */
411#endif
414
415#ifdef DNA_DEPRECATED_ALLOW /* Old animation system (armature only viz). */
417typedef enum eArmature_PathFlag {
418 ARM_PATH_FNUMS = (1 << 0),
419 ARM_PATH_KFRAS = (1 << 1),
420 ARM_PATH_HEADS = (1 << 2),
421 ARM_PATH_ACFRA = (1 << 3),
422 ARM_PATH_KFNOS = (1 << 4),
423} eArmature_PathFlag;
424#endif
425
426/* bone->flag */
427typedef enum eBone_Flag {
438 BONE_SELECTED = (1 << 0),
439 BONE_ROOTSEL = (1 << 1),
440 BONE_TIPSEL = (1 << 2),
442 BONE_TRANSFORM = (1 << 3),
444 BONE_CONNECTED = (1 << 4),
445 /* 32 used to be quatrot, was always set in files, do not reuse unless you clear it always */
450 BONE_HIDDEN_P = (1 << 6),
452 BONE_DONE = (1 << 7),
456 BONE_HINGE = (1 << 9),
461 BONE_HIDDEN_A = (1 << 10),
463 BONE_MULT_VG_ENV = (1 << 11),
465 BONE_NO_DEFORM = (1 << 12),
466#ifdef DNA_DEPRECATED_ALLOW
468 BONE_UNKEYED = (1 << 13),
470 BONE_HINGE_CHILD_TRANSFORM = (1 << 14),
472 BONE_NO_SCALE = (1 << 15),
473#endif
475 BONE_DRAWWIRE = (1 << 17),
480#ifdef DNA_DEPRECATED_ALLOW
482 BONE_TRANSFORM_CHILD = (1 << 20),
483#endif
485 BONE_UNSELECTABLE = (1 << 21),
490#ifdef DNA_DEPRECATED_ALLOW
492 BONE_ADD_PARENT_END_ROLL = (1 << 24),
493#endif
500
501/* bone->inherit_scale_mode */
503 /* Inherit all scale and shear. */
505 /* Inherit scale, but remove final shear. */
507 /* Inherit average scale. */
509 /* Inherit no scale or shear. */
511 /* Inherit effects of shear on parent (same as old disabled Inherit Scale). */
513 /* Inherit parent X scale as child X scale etc. */
516
517/* bone->bbone_prev_type, bbone_next_type */
519 BBONE_HANDLE_AUTO = 0, /* Default mode based on parents & children. */
520 BBONE_HANDLE_ABSOLUTE = 1, /* Custom handle in absolute position mode. */
521 BBONE_HANDLE_RELATIVE = 2, /* Custom handle in relative position mode. */
522 BBONE_HANDLE_TANGENT = 3, /* Custom handle in tangent mode (use direction, not location). */
524
525/* bone->bbone_mapping_mode */
527 BBONE_MAPPING_STRAIGHT = 0, /* Default mode that ignores the rest pose curvature. */
528 BBONE_MAPPING_CURVED = 1, /* Mode that takes the rest pose curvature into account. */
530
531/* bone->bbone_flag */
538
539/* bone->bbone_prev/next_flag */
553
554#define MAXBONENAME 64
555
558 BONE_COLLECTION_VISIBLE = (1 << 0), /* Visibility flag of this particular collection. */
559 BONE_COLLECTION_SELECTABLE = (1 << 1), /* Intended to be implemented in the not-so-far future. */
560 BONE_COLLECTION_OVERRIDE_LIBRARY_LOCAL = (1 << 2), /* Added by a local library override. */
561
569
582
583 BONE_COLLECTION_EXPANDED = (1 << 5), /* Expanded in the tree view. */
586
587#ifdef __cplusplus
588
589inline blender::animrig::BoneColor &BoneColor::wrap()
590{
591 return *reinterpret_cast<blender::animrig::BoneColor *>(this);
592}
593inline const blender::animrig::BoneColor &BoneColor::wrap() const
594{
595 return *reinterpret_cast<const blender::animrig::BoneColor *>(this);
596}
597#endif
#define ENUM_OPERATORS(_type, _max)
ID and Library types, which are fundamental for SDNA.
ID_Type
@ ID_AR
eBoneCollection_Flag
@ BONE_COLLECTION_VISIBLE
@ BONE_COLLECTION_SELECTABLE
@ BONE_COLLECTION_ANCESTORS_VISIBLE
@ BONE_COLLECTION_SOLO
@ BONE_COLLECTION_EXPANDED
@ BONE_COLLECTION_OVERRIDE_LIBRARY_LOCAL
eArmature_DeformFlag
@ ARM_DEF_VGROUP
@ ARM_DEF_QUATERNION
@ ARM_DEF_INVERT_VGROUP
@ ARM_DEF_ENVELOPE
eBone_BBoneMappingMode
@ BBONE_MAPPING_STRAIGHT
@ BBONE_MAPPING_CURVED
eBone_BBoneHandleType
@ BBONE_HANDLE_AUTO
@ BBONE_HANDLE_TANGENT
@ BBONE_HANDLE_ABSOLUTE
@ BBONE_HANDLE_RELATIVE
@ BONE_DRAW_LOCKED_WEIGHT
@ BONE_ROOTSEL
@ BONE_DRAWWIRE
@ BONE_SELECTED
@ BONE_NO_CYCLICOFFSET
@ BONE_TRANSFORM
@ BONE_UNSELECTABLE
@ BONE_DONE
@ BONE_HIDDEN_A
@ BONE_EDITMODE_LOCKED
@ BONE_TRANSFORM_MIRROR
@ BONE_NO_LOCAL_LOCATION
@ BONE_MULT_VG_ENV
@ BONE_HIDDEN_P
@ BONE_DRAW_ACTIVE
@ BONE_TIPSEL
@ BONE_NO_DEFORM
@ BONE_CONNECTED
@ BONE_RELATIVE_PARENTING
@ BONE_HINGE
@ ARM_DRAW_RELATION_FROM_HEAD
@ ARM_NO_CUSTOM
@ ARM_HAS_VIZ_DEPS
@ ARM_COL_CUSTOM
@ ARM_DRAWNAMES
@ ARM_DS_EXPAND
@ ARM_BCOLL_SOLO_ACTIVE
@ ARM_FLAG_UNUSED_12
@ ARM_FLAG_UNUSED_7
@ ARM_FLAG_UNUSED_1
@ ARM_MIRROR_EDIT
@ ARM_DRAWAXES
@ ARM_FLAG_UNUSED_9
@ ARM_RESTPOS
eArmature_Drawtype
@ ARM_DRAW_TYPE_ENVELOPE
@ ARM_DRAW_TYPE_STICK
@ ARM_DRAW_TYPE_B_BONE
@ ARM_DRAW_TYPE_WIRE
@ ARM_DRAW_TYPE_ARMATURE_DEFINED
@ ARM_DRAW_TYPE_OCTA
eBone_BBoneFlag
@ BBONE_ADD_PARENT_END_ROLL
@ BBONE_SCALE_EASING
eBone_BBoneHandleFlag
@ BBONE_HANDLE_SCALE_EASE
@ BBONE_HANDLE_SCALE_Y
@ BBONE_HANDLE_SCALE_X
@ BBONE_HANDLE_SCALE_ANY
@ BBONE_HANDLE_SCALE_Z
eBone_InheritScaleMode
@ BONE_INHERIT_SCALE_FULL
@ BONE_INHERIT_SCALE_NONE
@ BONE_INHERIT_SCALE_FIX_SHEAR
@ BONE_INHERIT_SCALE_NONE_LEGACY
@ BONE_INHERIT_SCALE_ALIGNED
@ BONE_INHERIT_SCALE_AVERAGE
These structs are the foundation for all linked lists in the library system.
#define typedef
float wrap(float value, float max, float min)
Definition node_math.h:103
struct BoneCollectionMember * next
struct BoneCollectionMember * prev
struct BoneCollectionReference * next
struct BoneCollectionReference * prev
struct BoneCollection * bcoll
struct IDProperty * system_properties
struct IDProperty * prop
struct BoneCollection * next
struct BoneCollection * prev
ThemeWireColor custom
uint8_t _pad0[7]
char _pad[3]
float curve_in_z
float scale_in_x DNA_DEPRECATED
int8_t drawtype
BoneColor color
short bbone_next_flag
short bbone_prev_flag
Bone_Runtime runtime
struct Bone * parent
struct Bone * bbone_prev
float arm_head[3]
char name[64]
float tail[3]
float arm_tail[3]
struct Bone * bbone_next
char inherit_scale_mode
char bbone_prev_type
float curve_in_x
char _pad2[7]
float scale_out[3]
float size[3]
IDProperty * prop
char _pad1[3]
float curve_out_z
char bbone_mapping_mode
void * _pad0
float arm_mat[4][4]
float bone_mat[3][3]
float scale_in[3]
float head[3]
char bbone_next_type
struct Bone * next
float curve_out_x
ListBase childbase
struct Bone * prev
IDProperty * system_properties
Definition DNA_ID.h:414
struct BoneCollection * active_collection
struct AnimData * adt
struct BoneCollection ** collection_array
char active_collection_name[64]
struct GHash * bonehash
struct EditBone * act_edbone
unsigned int layer_used DNA_DEPRECATED
ListBase collections_legacy
ListBase * edbo
struct bArmature_Runtime runtime
#define DNA_DEPRECATED_ALLOW
Definition versioning.cc:11