1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 * 16 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 17 * All rights reserved. 18 */ 19 20 /** \file 21 * \ingroup DNA 22 */ 23 24 #pragma once 25 26 #include "DNA_ID.h" 27 #include "DNA_defs.h" 28 #include "DNA_listBase.h" 29 30 struct AnimData; 31 32 /* this system works on different transformation space levels; 33 * 34 * 1) Bone Space; with each Bone having own (0,0,0) origin 35 * 2) Armature Space; the rest position, in Object space, Bones Spaces are applied hierarchical 36 * 3) Pose Space; the animation position, in Object space 37 * 4) World Space; Object matrix applied to Pose or Armature space 38 */ 39 40 typedef struct Bone { 41 /** Next/prev elements within this list. */ 42 struct Bone *next, *prev; 43 /** User-Defined Properties on this Bone. */ 44 IDProperty *prop; 45 /** Parent (ik parent if appropriate flag is set. */ 46 struct Bone *parent; 47 /** Children . */ 48 ListBase childbase; 49 /** Name of the bone - must be unique within the armature, MAXBONENAME. */ 50 char name[64]; 51 52 /** roll is input for editmode, length calculated. */ 53 float roll; 54 float head[3]; 55 /** head/tail and roll in Bone Space . */ 56 float tail[3]; 57 /** rotation derived from head/tail/roll. */ 58 float bone_mat[3][3]; 59 60 int flag; 61 62 char inherit_scale_mode; 63 char _pad[7]; 64 65 float arm_head[3]; 66 /** head/tail in Armature Space (rest pos). */ 67 float arm_tail[3]; 68 /** matrix: (bonemat(b)+head(b))*arm_mat(b-1), rest po.s*/ 69 float arm_mat[4][4]; 70 /** Roll in Armature Space (rest pos). */ 71 float arm_roll; 72 73 /** dist, weight: for non-deformgroup deforms. */ 74 float dist, weight; 75 /** width: for block bones. keep in this order, transform!. */ 76 float xwidth, length, zwidth; 77 /** Radius for head/tail sphere, defining deform as well, parent->rad_tip overrides rad_head. */ 78 float rad_head, rad_tail; 79 80 /** Curved bones settings - these define the "restpose" for a curved bone. */ 81 float roll1, roll2; 82 float curve_in_x, curve_in_y; 83 float curve_out_x, curve_out_y; 84 /** Length of bezier handles. */ 85 float ease1, ease2; 86 float scale_in_x, scale_in_y; 87 float scale_out_x, scale_out_y; 88 89 /** patch for upward compat, UNUSED!. */ 90 float size[3]; 91 /** Layers that bone appears on. */ 92 int layer; 93 /** for B-bones. */ 94 short segments; 95 96 /** Type of next/prev bone handles. */ 97 char bbone_prev_type; 98 char bbone_next_type; 99 /** Next/prev bones to use as handle references when calculating bbones (optional). */ 100 struct Bone *bbone_prev; 101 struct Bone *bbone_next; 102 } Bone; 103 104 typedef struct bArmature { 105 ID id; 106 struct AnimData *adt; 107 108 ListBase bonebase; 109 110 /** Ghash for quicker lookups of bones by name. */ 111 struct GHash *bonehash; 112 void *_pad1; 113 114 /** Editbone listbase, we use pointer so we can check state. */ 115 ListBase *edbo; 116 117 /* active bones should work like active object where possible 118 * - active and selection are unrelated 119 * - active & hidden is not allowed 120 * - from the user perspective active == last selected 121 * - active should be ignored when not visible (hidden layer) */ 122 123 /** Active bone. */ 124 Bone *act_bone; 125 /** Active editbone (in editmode). */ 126 struct EditBone *act_edbone; 127 128 /** ID data is older than edit-mode data (TODO: move to edit-mode struct). */ 129 char needs_flush_to_id; 130 char _pad0[7]; 131 132 int flag; 133 int drawtype; 134 135 short deformflag; 136 short pathflag; 137 138 /** For UI, to show which layers are there. */ 139 unsigned int layer_used; 140 /** For buttons to work, both variables in this order together. */ 141 unsigned int layer, layer_protected; 142 } bArmature; 143 144 /* armature->flag */ 145 /* don't use bit 7, was saved in files to disable stuff */ 146 typedef enum eArmature_Flag { 147 ARM_RESTPOS = (1 << 0), 148 /** XRAY is here only for backwards converting */ 149 ARM_FLAG_UNUSED_1 = (1 << 1), /* cleared */ 150 ARM_DRAWAXES = (1 << 2), 151 ARM_DRAWNAMES = (1 << 3), 152 ARM_POSEMODE = (1 << 4), 153 ARM_FLAG_UNUSED_5 = (1 << 5), /* cleared */ 154 ARM_FLAG_UNUSED_6 = (1 << 6), /* cleared */ 155 ARM_FLAG_UNUSED_7 = (1 << 7), 156 ARM_MIRROR_EDIT = (1 << 8), 157 ARM_FLAG_UNUSED_9 = (1 << 9), 158 /** made option negative, for backwards compat */ 159 ARM_NO_CUSTOM = (1 << 10), 160 /** draw custom colors */ 161 ARM_COL_CUSTOM = (1 << 11), 162 /** when ghosting, only show selected bones (this should belong to ghostflag instead) */ 163 ARM_FLAG_UNUSED_12 = (1 << 12), /* cleared */ 164 /** dopesheet channel is expanded */ 165 ARM_DS_EXPAND = (1 << 13), 166 /** other objects are used for visualizing various states (hack for efficient updates) */ 167 ARM_HAS_VIZ_DEPS = (1 << 14), 168 } eArmature_Flag; 169 170 /* armature->drawtype */ 171 typedef enum eArmature_Drawtype { 172 ARM_OCTA = 0, 173 ARM_LINE = 1, 174 ARM_B_BONE = 2, 175 ARM_ENVELOPE = 3, 176 ARM_WIRE = 4, 177 } eArmature_Drawtype; 178 179 /* armature->deformflag */ 180 typedef enum eArmature_DeformFlag { 181 ARM_DEF_VGROUP = (1 << 0), 182 ARM_DEF_ENVELOPE = (1 << 1), 183 ARM_DEF_QUATERNION = (1 << 2), 184 #ifdef DNA_DEPRECATED_ALLOW 185 ARM_DEF_B_BONE_REST = (1 << 3), /* deprecated */ 186 #endif 187 ARM_DEF_INVERT_VGROUP = (1 << 4), 188 } eArmature_DeformFlag; 189 190 /* armature->pathflag */ 191 // XXX deprecated... old animation system (armature only viz) 192 #ifdef DNA_DEPRECATED_ALLOW 193 typedef enum eArmature_PathFlag { 194 ARM_PATH_FNUMS = (1 << 0), 195 ARM_PATH_KFRAS = (1 << 1), 196 ARM_PATH_HEADS = (1 << 2), 197 ARM_PATH_ACFRA = (1 << 3), 198 ARM_PATH_KFNOS = (1 << 4), 199 } eArmature_PathFlag; 200 #endif 201 202 /* bone->flag */ 203 typedef enum eBone_Flag { 204 BONE_SELECTED = (1 << 0), 205 BONE_ROOTSEL = (1 << 1), 206 BONE_TIPSEL = (1 << 2), 207 /** Used instead of BONE_SELECTED during transform (clear before use) */ 208 BONE_TRANSFORM = (1 << 3), 209 /** when bone has a parent, connect head of bone to parent's tail*/ 210 BONE_CONNECTED = (1 << 4), 211 /* 32 used to be quatrot, was always set in files, do not reuse unless you clear it always */ 212 /** hidden Bones when drawing PoseChannels */ 213 BONE_HIDDEN_P = (1 << 6), 214 /** For detecting cyclic dependencies */ 215 BONE_DONE = (1 << 7), 216 /** active is on mouse clicks only - deprecated, ONLY USE FOR DRAWING */ 217 BONE_DRAW_ACTIVE = (1 << 8), 218 /** No parent rotation or scale */ 219 BONE_HINGE = (1 << 9), 220 /** hidden Bones when drawing Armature Editmode */ 221 BONE_HIDDEN_A = (1 << 10), 222 /** multiplies vgroup with envelope */ 223 BONE_MULT_VG_ENV = (1 << 11), 224 /** bone doesn't deform geometry */ 225 BONE_NO_DEFORM = (1 << 12), 226 /** set to prevent destruction of its unkeyframed pose (after transform) */ 227 BONE_UNKEYED = (1 << 13), 228 /** set to prevent hinge child bones from influencing the transform center */ 229 BONE_HINGE_CHILD_TRANSFORM = (1 << 14), 230 #ifdef DNA_DEPRECATED_ALLOW 231 /** No parent scale */ 232 BONE_NO_SCALE = (1 << 15), 233 #endif 234 /** hidden bone when drawing PoseChannels (for ghost drawing) */ 235 BONE_HIDDEN_PG = (1 << 16), 236 /** bone should be drawn as OB_WIRE, regardless of draw-types of view+armature */ 237 BONE_DRAWWIRE = (1 << 17), 238 /** when no parent, bone will not get cyclic offset */ 239 BONE_NO_CYCLICOFFSET = (1 << 18), 240 /** bone transforms are locked in EditMode */ 241 BONE_EDITMODE_LOCKED = (1 << 19), 242 /** Indicates that a parent is also being transformed */ 243 BONE_TRANSFORM_CHILD = (1 << 20), 244 /** bone cannot be selected */ 245 BONE_UNSELECTABLE = (1 << 21), 246 /** bone location is in armature space */ 247 BONE_NO_LOCAL_LOCATION = (1 << 22), 248 /** object child will use relative transform (like deform) */ 249 BONE_RELATIVE_PARENTING = (1 << 23), 250 /** it will add the parent end roll to the inroll */ 251 BONE_ADD_PARENT_END_ROLL = (1 << 24), 252 /** this bone was transformed by the mirror function */ 253 BONE_TRANSFORM_MIRROR = (1 << 25), 254 /** this bone is associated with a locked vertex group, ONLY USE FOR DRAWING */ 255 BONE_DRAW_LOCKED_WEIGHT = (1 << 26), 256 } eBone_Flag; 257 258 /* bone->inherit_scale_mode */ 259 typedef enum eBone_InheritScaleMode { 260 /* Inherit all scale and shear. */ 261 BONE_INHERIT_SCALE_FULL = 0, 262 /* Inherit scale, but remove final shear. */ 263 BONE_INHERIT_SCALE_FIX_SHEAR = 1, 264 /* Inherit average scale. */ 265 BONE_INHERIT_SCALE_AVERAGE = 2, 266 /* Inherit no scale or shear. */ 267 BONE_INHERIT_SCALE_NONE = 3, 268 /* Inherit effects of shear on parent (same as old disabled Inherit Scale). */ 269 BONE_INHERIT_SCALE_NONE_LEGACY = 4, 270 /* Inherit parent X scale as child X scale etc. */ 271 BONE_INHERIT_SCALE_ALIGNED = 5, 272 } eBone_InheritScaleMode; 273 274 /* bone->bbone_prev_type, bbone_next_type */ 275 typedef enum eBone_BBoneHandleType { 276 BBONE_HANDLE_AUTO = 0, /* Default mode based on parents & children. */ 277 BBONE_HANDLE_ABSOLUTE = 1, /* Custom handle in absolute position mode. */ 278 BBONE_HANDLE_RELATIVE = 2, /* Custom handle in relative position mode. */ 279 BBONE_HANDLE_TANGENT = 3, /* Custom handle in tangent mode (use direction, not location). */ 280 } eBone_BBoneHandleType; 281 282 #define MAXBONENAME 64 283