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  * Constraint DNA data
19  */
20 
21 /** \file
22  * \ingroup DNA
23  */
24 
25 #pragma once
26 
27 #include "DNA_ID.h"
28 #include "DNA_defs.h"
29 #include "DNA_listBase.h"
30 
31 struct Action;
32 struct Ipo;
33 struct Text;
34 
35 /* channels reside in Object or Action (ListBase) constraintChannels */
36 // XXX deprecated... old AnimSys
37 typedef struct bConstraintChannel {
38   struct bConstraintChannel *next, *prev;
39   struct Ipo *ipo;
40   short flag;
41   char name[30];
42 } bConstraintChannel;
43 
44 /* A Constraint */
45 typedef struct bConstraint {
46   struct bConstraint *next, *prev;
47 
48   /** Constraint data (a valid constraint type). */
49   void *data;
50   /** Constraint type.    */
51   short type;
52   /** Flag - General Settings.    */
53   short flag;
54 
55   /** Space that owner should be evaluated in. */
56   char ownspace;
57   /** Space that target should be evaluated in (only used if 1 target). */
58   char tarspace;
59 
60   /** Constraint name, MAX_NAME. */
61   char name[64];
62 
63   /* Flag for panel and subpanel closed / open state in the UI. */
64   short ui_expand_flag;
65 
66   /** Amount of influence exherted by constraint (0.0-1.0). */
67   float enforce;
68   /** Point along subtarget bone where the actual target is. 0=head (default for all), 1=tail. */
69   float headtail;
70 
71   /* old animation system, deprecated for 2.5. */
72   /** Local influence ipo or driver */
73   struct Ipo *ipo DNA_DEPRECATED;
74 
75   /* below are readonly fields that are set at runtime
76    * by the solver for use in the GE (only IK atm) */
77   /** Residual error on constraint expressed in blender unit. */
78   float lin_error;
79   /** Residual error on constraint expressed in radiant. */
80   float rot_error;
81 } bConstraint;
82 
83 /* Multiple-target constraints ---------------------  */
84 
85 /* This struct defines a constraint target.
86  * It is used during constraint solving regardless of how many targets the
87  * constraint has.
88  */
89 typedef struct bConstraintTarget {
90   struct bConstraintTarget *next, *prev;
91 
92   /** Object to use as target. */
93   struct Object *tar;
94   /** Subtarget - pchan or vgroup name, MAX_ID_NAME-2. */
95   char subtarget[64];
96 
97   /** Matrix used during constraint solving - should be cleared before each use. */
98   float matrix[4][4];
99 
100   /** Space that target should be evaluated in (overrides bConstraint->tarspace). */
101   short space;
102   /** Runtime settings (for editor, etc.). */
103   short flag;
104   /** Type of target (eConstraintObType). */
105   short type;
106   /** Rotation order for target (as defined in BLI_math.h). */
107   short rotOrder;
108   /** Weight for armature deform. */
109   float weight;
110   char _pad[4];
111 } bConstraintTarget;
112 
113 /* bConstraintTarget -> flag */
114 typedef enum eConstraintTargetFlag {
115   /** temporary target-struct that needs to be freed after use */
116   CONSTRAINT_TAR_TEMP = (1 << 0),
117 } eConstraintTargetFlag;
118 
119 /* bConstraintTarget/bConstraintOb -> type */
120 typedef enum eConstraintObType {
121   /** string is "" */
122   CONSTRAINT_OBTYPE_OBJECT = 1,
123   /** string is bone-name */
124   CONSTRAINT_OBTYPE_BONE = 2,
125   /** string is vertex-group name */
126   CONSTRAINT_OBTYPE_VERT = 3,
127   /** string is vertex-group name - is not available until curves get vgroups */
128   /* CONSTRAINT_OBTYPE_CV = 4, */ /* UNUSED */
129 } eConstraintObType;
130 
131 /* Python Script Constraint */
132 typedef struct bPythonConstraint {
133   /** Text-buffer (containing script) to execute. */
134   struct Text *text;
135   /** 'id-properties' used to store custom properties for constraint. */
136   IDProperty *prop;
137 
138   /** General settings/state indicators accessed by bitmapping. */
139   int flag;
140   /** Number of targets - usually only 1-3 are needed. */
141   int tarnum;
142 
143   /** A list of targets that this constraint has (bConstraintTarget-s). */
144   ListBase targets;
145 
146   /**
147    * Target from previous implementation
148    * (version-patch sets this to NULL on file-load).
149    */
150   struct Object *tar;
151   /**
152    * Subtarget from previous implementation
153    * (version-patch sets this to "" on file-load), MAX_ID_NAME-2.
154    */
155   char subtarget[64];
156 } bPythonConstraint;
157 
158 /* Inverse-Kinematics (IK) constraint
159  * This constraint supports a variety of mode determine by the type field
160  * according to eConstraint_IK_Type.
161  * Some fields are used by all types, some are specific to some types
162  * This is indicated in the comments for each field
163  */
164 typedef struct bKinematicConstraint {
165   /** All: target object in case constraint needs a target. */
166   struct Object *tar;
167   /** All: Maximum number of iterations to try. */
168   short iterations;
169   /** All & CopyPose: some options Like CONSTRAINT_IK_TIP. */
170   short flag;
171   /** All: index to rootbone, if zero go all the way to mother bone. */
172   short rootbone;
173   /** CopyPose: for auto-ik, maximum length of chain. */
174   short max_rootbone;
175   /** All: String to specify sub-object target, MAX_ID_NAME-2. */
176   char subtarget[64];
177   /** All: Pole vector target. */
178   struct Object *poletar;
179   /** All: Pole vector sub-object target, MAX_ID_NAME-2. */
180   char polesubtarget[64];
181   /** All: Pole vector rest angle. */
182   float poleangle;
183   /** All: Weight of constraint in IK tree. */
184   float weight;
185   /** CopyPose: Amount of rotation a target applies on chain. */
186   float orientweight;
187   /** CopyPose: for target-less IK. */
188   float grabtarget[3];
189   /** Subtype of IK constraint: eConstraint_IK_Type. */
190   short type;
191   /** Distance: how to limit in relation to clamping sphere: LIMITDIST_... */
192   short mode;
193   /** Distance: distance (radius of clamping sphere) from target. */
194   float dist;
195 } bKinematicConstraint;
196 
197 typedef enum eConstraint_IK_Type {
198   /** 'standard' IK constraint: match position and/or orientation of target */
199   CONSTRAINT_IK_COPYPOSE = 0,
200   /** maintain distance with target */
201   CONSTRAINT_IK_DISTANCE = 1,
202 } eConstraint_IK_Type;
203 
204 /* Spline IK Constraint
205  * Aligns 'n' bones to the curvature defined by the curve,
206  * with the chain ending on the bone that owns this constraint,
207  * and starting on the nth parent.
208  */
209 typedef struct bSplineIKConstraint {
210   /* target(s) */
211   /** Curve object (with follow path enabled) which drives the bone chain. */
212   struct Object *tar;
213 
214   /* binding details */
215   /**
216    * Array of numpoints items,
217    * denoting parametric positions along curve that joints should follow.
218    */
219   float *points;
220   /** Number of points to bound in points array. */
221   short numpoints;
222   /** Number of bones ('n') that are in the chain. */
223   short chainlen;
224 
225   /* settings */
226   /** General settings for constraint. */
227   short flag;
228   /** Method used for determining the x & z scaling of the bones. */
229   short xzScaleMode;
230   /** Method used for determining the y scaling of the bones. */
231   short yScaleMode;
232   short _pad[3];
233 
234   /* volume preservation settings */
235   float bulge;
236   float bulge_min;
237   float bulge_max;
238   float bulge_smooth;
239 } bSplineIKConstraint;
240 
241 /* Armature Constraint */
242 typedef struct bArmatureConstraint {
243   /** General settings/state indicators accessed by bitmapping. */
244   int flag;
245   char _pad[4];
246 
247   /** A list of targets that this constraint has (bConstraintTarget-s). */
248   ListBase targets;
249 } bArmatureConstraint;
250 
251 /* Single-target subobject constraints ---------------------  */
252 
253 /* Track To Constraint */
254 typedef struct bTrackToConstraint {
255   struct Object *tar;
256   /**
257    * I'll be using reserved1 and reserved2 as Track and Up flags,
258    * not sure if that's what they were intended for anyway.
259    * Not sure either if it would create backward incompatibility if I were to rename them.
260    * - theeth
261    */
262   int reserved1;
263   int reserved2;
264   int flags;
265   char _pad[4];
266   /** MAX_ID_NAME-2. */
267   char subtarget[64];
268 } bTrackToConstraint;
269 
270 /* Copy Rotation Constraint */
271 typedef struct bRotateLikeConstraint {
272   struct Object *tar;
273   int flag;
274   char euler_order;
275   char mix_mode;
276   char _pad[2];
277   /** MAX_ID_NAME-2. */
278   char subtarget[64];
279 } bRotateLikeConstraint;
280 
281 /* Copy Location Constraint */
282 typedef struct bLocateLikeConstraint {
283   struct Object *tar;
284   int flag;
285   int reserved1;
286   /** MAX_ID_NAME-2. */
287   char subtarget[64];
288 } bLocateLikeConstraint;
289 
290 /* Copy Scale Constraint */
291 typedef struct bSizeLikeConstraint {
292   struct Object *tar;
293   int flag;
294   float power;
295   /** MAX_ID_NAME-2. */
296   char subtarget[64];
297 } bSizeLikeConstraint;
298 
299 /* Maintain Volume Constraint */
300 typedef struct bSameVolumeConstraint {
301   char free_axis;
302   char mode;
303   char _pad[2];
304   float volume;
305 } bSameVolumeConstraint;
306 
307 /* Copy Transform Constraint */
308 typedef struct bTransLikeConstraint {
309   struct Object *tar;
310   char mix_mode;
311   char _pad[7];
312   /** MAX_ID_NAME-2. */
313   char subtarget[64];
314 } bTransLikeConstraint;
315 
316 /* Floor Constraint */
317 typedef struct bMinMaxConstraint {
318   struct Object *tar;
319   int minmaxflag;
320   float offset;
321   int flag;
322   /** MAX_ID_NAME-2. */
323   char subtarget[64];
324   int _pad;
325 } bMinMaxConstraint;
326 
327 /* Action Constraint */
328 typedef struct bActionConstraint {
329   struct Object *tar;
330   /** What transform 'channel' drives the result. */
331   short type;
332   /** Was used in versions prior to the Constraints recode. */
333   short local;
334   int start;
335   int end;
336   float min;
337   float max;
338   int flag;
339   char mix_mode;
340   char _pad[3];
341   float eval_time; /* Only used when flag ACTCON_USE_EVAL_TIME is set. */
342   struct bAction *act;
343   /** MAX_ID_NAME-2. */
344   char subtarget[64];
345 } bActionConstraint;
346 
347 /* Locked Axis Tracking constraint */
348 typedef struct bLockTrackConstraint {
349   struct Object *tar;
350   int trackflag;
351   int lockflag;
352   /** MAX_ID_NAME-2. */
353   char subtarget[64];
354 } bLockTrackConstraint;
355 
356 /* Damped Tracking constraint */
357 typedef struct bDampTrackConstraint {
358   struct Object *tar;
359   int trackflag;
360   char _pad[4];
361   /** MAX_ID_NAME-2. */
362   char subtarget[64];
363 } bDampTrackConstraint;
364 
365 /* Follow Path constraints */
366 typedef struct bFollowPathConstraint {
367   /** Must be path object. */
368   struct Object *tar;
369 
370   /** Offset in time on the path (in frames), when NOT using 'fixed position'. */
371   float offset;
372   /** Parametric offset factor defining position along path, when using 'fixed position'. */
373   float offset_fac;
374 
375   int followflag;
376 
377   short trackflag;
378   short upflag;
379 } bFollowPathConstraint;
380 
381 /* Stretch to constraint */
382 typedef struct bStretchToConstraint {
383   struct Object *tar;
384   int flag;
385   int volmode;
386   int plane;
387   float orglength;
388   float bulge;
389   float bulge_min;
390   float bulge_max;
391   float bulge_smooth;
392   /** MAX_ID_NAME-2. */
393   char subtarget[64];
394 } bStretchToConstraint;
395 
396 /* Rigid Body constraint */
397 typedef struct bRigidBodyJointConstraint {
398   struct Object *tar;
399   struct Object *child;
400   int type;
401   float pivX;
402   float pivY;
403   float pivZ;
404   float axX;
405   float axY;
406   float axZ;
407   float minLimit[6];
408   float maxLimit[6];
409   float extraFz;
410   short flag;
411   char _pad[6];
412 } bRigidBodyJointConstraint;
413 
414 /* Clamp-To Constraint */
415 typedef struct bClampToConstraint {
416   /** 'target' must be a curve. */
417   struct Object *tar;
418   /** Which axis/plane to compare owner's location on . */
419   int flag;
420   /** For legacy reasons, this is flag2. used for any extra settings. */
421   int flag2;
422 } bClampToConstraint;
423 
424 /* Child Of Constraint */
425 typedef struct bChildOfConstraint {
426   /** Object which will act as parent (or target comes from). */
427   struct Object *tar;
428   /** Settings. */
429   int flag;
430   char _pad[4];
431   /** Parent-inverse matrix to use. */
432   float invmat[4][4];
433   /** String to specify a subobject target, MAX_ID_NAME-2. */
434   char subtarget[64];
435 } bChildOfConstraint;
436 
437 /* Generic Transform->Transform Constraint */
438 typedef struct bTransformConstraint {
439   /** Target (i.e. 'driver' object/bone). */
440   struct Object *tar;
441   /** MAX_ID_NAME-2. */
442   char subtarget[64];
443 
444   /** Can be loc(0), rot(1) or size(2). */
445   short from, to;
446   /** Defines which target-axis deform is copied by each owner-axis. */
447   char map[3];
448   /** Extrapolate motion? if 0, confine to ranges. */
449   char expo;
450 
451   /** Input rotation type - uses the same values as driver targets. */
452   char from_rotation_mode;
453   /** Output euler order override. */
454   char to_euler_order;
455 
456   /** Mixing modes for location, rotation, and scale. */
457   char mix_mode_loc;
458   char mix_mode_rot;
459   char mix_mode_scale;
460 
461   char _pad[3];
462 
463   /** From_min/max defines range of target transform. */
464   float from_min[3];
465   /** To map on to to_min/max range. */
466   float from_max[3];
467   /** Range of motion on owner caused by target . */
468   float to_min[3];
469   float to_max[3];
470 
471   /** From_min/max defines range of target transform. */
472   float from_min_rot[3];
473   /** To map on to to_min/max range. */
474   float from_max_rot[3];
475   /** Range of motion on owner caused by target . */
476   float to_min_rot[3];
477   float to_max_rot[3];
478 
479   /** From_min/max defines range of target transform. */
480   float from_min_scale[3];
481   /** To map on to to_min/max range. */
482   float from_max_scale[3];
483   /** Range of motion on owner caused by target . */
484   float to_min_scale[3];
485   float to_max_scale[3];
486 } bTransformConstraint;
487 
488 /* Pivot Constraint */
489 typedef struct bPivotConstraint {
490   /* Pivot Point:
491    * Either target object + offset, or just offset is used
492    */
493   /** Target object (optional). */
494   struct Object *tar;
495   /** Subtarget name (optional), MAX_ID_NAME-2. */
496   char subtarget[64];
497   /** Offset from the target to use, regardless of whether it exists. */
498   float offset[3];
499 
500   /* Rotation-driven activation:
501    * This option provides easier one-stop setups for foot-rolls.
502    */
503   /** Rotation axes to consider for this (#ePivotConstraint_Axis). */
504   short rotAxis;
505 
506   /* General flags */
507   /** #ePivotConstraint_Flag. */
508   short flag;
509 } bPivotConstraint;
510 
511 /* transform limiting constraints - zero target ----------------------------  */
512 /* Limit Location Constraint */
513 typedef struct bLocLimitConstraint {
514   float xmin, xmax;
515   float ymin, ymax;
516   float zmin, zmax;
517   short flag;
518   short flag2;
519 } bLocLimitConstraint;
520 
521 /* Limit Rotation Constraint */
522 typedef struct bRotLimitConstraint {
523   float xmin, xmax;
524   float ymin, ymax;
525   float zmin, zmax;
526   short flag;
527   short flag2;
528 } bRotLimitConstraint;
529 
530 /* Limit Scale Constraint */
531 typedef struct bSizeLimitConstraint {
532   float xmin, xmax;
533   float ymin, ymax;
534   float zmin, zmax;
535   short flag;
536   short flag2;
537 } bSizeLimitConstraint;
538 
539 /* Limit Distance Constraint */
540 typedef struct bDistLimitConstraint {
541   struct Object *tar;
542   /** MAX_ID_NAME-2. */
543   char subtarget[64];
544 
545   /** Distance (radius of clamping sphere) from target. */
546   float dist;
547   /** Distance from clamping-sphere to start applying 'fade'. */
548   float soft;
549 
550   /** Settings. */
551   short flag;
552   /** How to limit in relation to clamping sphere. */
553   short mode;
554   char _pad[4];
555 } bDistLimitConstraint;
556 
557 /* ShrinkWrap Constraint */
558 typedef struct bShrinkwrapConstraint {
559   struct Object *target;
560   /** Distance to kept from target. */
561   float dist;
562   /** Shrink type (look on MOD shrinkwrap for values). */
563   short shrinkType;
564   /** Axis to project/constrain. */
565   char projAxis;
566   /** Space to project axis in. */
567   char projAxisSpace;
568   /** Distance to search. */
569   float projLimit;
570   /** Inside/outside/on surface (see MOD shrinkwrap). */
571   char shrinkMode;
572   /** Options. */
573   char flag;
574   /** Axis to align to normal. */
575   char trackAxis;
576   char _pad;
577 } bShrinkwrapConstraint;
578 
579 /* Follow Track constraints */
580 typedef struct bFollowTrackConstraint {
581   struct MovieClip *clip;
582   /** MAX_NAME. */
583   char track[64];
584   int flag;
585   int frame_method;
586   /** MAX_NAME. */
587   char object[64];
588   struct Object *camera;
589   struct Object *depth_ob;
590 } bFollowTrackConstraint;
591 
592 /* Camera Solver constraints */
593 typedef struct bCameraSolverConstraint {
594   struct MovieClip *clip;
595   int flag;
596   char _pad[4];
597 } bCameraSolverConstraint;
598 
599 /* Camera Solver constraints */
600 typedef struct bObjectSolverConstraint {
601   struct MovieClip *clip;
602   int flag;
603   char _pad[4];
604   /** MAX_NAME. */
605   char object[64];
606   /** Parent-inverse matrix to use. */
607   float invmat[4][4];
608   struct Object *camera;
609 } bObjectSolverConstraint;
610 
611 /* Transform matrix cache constraint */
612 typedef struct bTransformCacheConstraint {
613   struct CacheFile *cache_file;
614   /** FILE_MAX. */
615   char object_path[1024];
616 
617   /* Runtime. */
618   struct CacheReader *reader;
619   char reader_object_path[1024];
620 } bTransformCacheConstraint;
621 
622 /* ------------------------------------------ */
623 
624 /* bConstraint->type
625  * - Do not ever change the order of these, or else files could get
626  *   broken as their correct value cannot be resolved
627  */
628 typedef enum eBConstraint_Types {
629   /** Invalid/legacy constraint */
630   CONSTRAINT_TYPE_NULL = 0,
631   /** Unimplemented non longer :) - during constraints recode, Aligorith */
632   CONSTRAINT_TYPE_CHILDOF = 1,
633   CONSTRAINT_TYPE_TRACKTO = 2,
634   CONSTRAINT_TYPE_KINEMATIC = 3,
635   CONSTRAINT_TYPE_FOLLOWPATH = 4,
636   /** Unimplemented no longer :) - Aligorith */
637   CONSTRAINT_TYPE_ROTLIMIT = 5,
638   /** Unimplemented no longer :) - Aligorith */
639   CONSTRAINT_TYPE_LOCLIMIT = 6,
640   /** Unimplemented no longer :) - Aligorith */
641   CONSTRAINT_TYPE_SIZELIMIT = 7,
642   CONSTRAINT_TYPE_ROTLIKE = 8,
643   CONSTRAINT_TYPE_LOCLIKE = 9,
644   CONSTRAINT_TYPE_SIZELIKE = 10,
645   /** Unimplemented no longer :) - Aligorith. Scripts */
646   CONSTRAINT_TYPE_PYTHON = 11,
647   CONSTRAINT_TYPE_ACTION = 12,
648   /** New Tracking constraint that locks an axis in place - theeth */
649   CONSTRAINT_TYPE_LOCKTRACK = 13,
650   /** limit distance */
651   CONSTRAINT_TYPE_DISTLIMIT = 14,
652   /** claiming this to be mine :) is in tuhopuu bjornmose */
653   CONSTRAINT_TYPE_STRETCHTO = 15,
654   /** floor constraint */
655   CONSTRAINT_TYPE_MINMAX = 16,
656   /* CONSTRAINT_TYPE_DEPRECATED = 17 */
657   /** clampto constraint */
658   CONSTRAINT_TYPE_CLAMPTO = 18,
659   /** transformation (loc/rot/size -> loc/rot/size) constraint */
660   CONSTRAINT_TYPE_TRANSFORM = 19,
661   /** shrinkwrap (loc/rot) constraint */
662   CONSTRAINT_TYPE_SHRINKWRAP = 20,
663   /** New Tracking constraint that minimizes twisting */
664   CONSTRAINT_TYPE_DAMPTRACK = 21,
665   /** Spline-IK - Align 'n' bones to a curve */
666   CONSTRAINT_TYPE_SPLINEIK = 22,
667   /** Copy transform matrix */
668   CONSTRAINT_TYPE_TRANSLIKE = 23,
669   /** Maintain volume during scaling */
670   CONSTRAINT_TYPE_SAMEVOL = 24,
671   /** Pivot Constraint */
672   CONSTRAINT_TYPE_PIVOT = 25,
673   /** Follow Track Constraint */
674   CONSTRAINT_TYPE_FOLLOWTRACK = 26,
675   /** Camera Solver Constraint */
676   CONSTRAINT_TYPE_CAMERASOLVER = 27,
677   /** Object Solver Constraint */
678   CONSTRAINT_TYPE_OBJECTSOLVER = 28,
679   /** Transform Cache Constraint */
680   CONSTRAINT_TYPE_TRANSFORM_CACHE = 29,
681   /** Armature Deform Constraint */
682   CONSTRAINT_TYPE_ARMATURE = 30,
683 
684   /* NOTE: no constraints are allowed to be added after this */
685   NUM_CONSTRAINT_TYPES,
686 } eBConstraint_Types;
687 
688 /* bConstraint->flag */
689 /* flags 0x2 (1 << 1) and 0x8 (1 << 3) were used in past */
690 /* flag 0x20 (1 << 5) was used to indicate that a constraint was evaluated
691  *                  using a 'local' hack for posebones only. */
692 typedef enum eBConstraint_Flags {
693   /* Expansion for old box constraint layouts. Just for versioning. */
694   CONSTRAINT_EXPAND_DEPRECATED = (1 << 0),
695   /* pre-check for illegal object name or bone name */
696   CONSTRAINT_DISABLE = (1 << 2),
697   /* to indicate which Ipo should be shown, maybe for 3d access later too */
698   CONSTRAINT_ACTIVE = (1 << 4),
699   /* to indicate that the owner's space should only be changed into ownspace, but not out of it */
700   CONSTRAINT_SPACEONCE = (1 << 6),
701   /* influence ipo is on constraint itself, not in action channel */
702   CONSTRAINT_OWN_IPO = (1 << 7),
703   /* indicates that constraint was added locally (i.e.  didn't come from the proxy-lib) */
704   CONSTRAINT_PROXY_LOCAL = (1 << 8),
705   /* indicates that constraint is temporarily disabled (only used in GE) */
706   CONSTRAINT_OFF = (1 << 9),
707   /* use bbone curve shape when calculating headtail values (also used by dependency graph!) */
708   CONSTRAINT_BBONE_SHAPE = (1 << 10),
709   /* That constraint has been inserted in local override (i.e. it can be fully edited!). */
710   CONSTRAINT_OVERRIDE_LIBRARY_LOCAL = (1 << 11),
711   /* use full transformation (not just segment locations) - only set at runtime  */
712   CONSTRAINT_BBONE_SHAPE_FULL = (1 << 12),
713 } eBConstraint_Flags;
714 
715 /* bConstraint->ownspace/tarspace */
716 typedef enum eBConstraint_SpaceTypes {
717   /** Default for all - worldspace. */
718   CONSTRAINT_SPACE_WORLD = 0,
719   /**
720    * For objects (relative to parent/without parent influence),
721    * for bones (along normals of bone, without parent/rest-positions).
722    */
723   CONSTRAINT_SPACE_LOCAL = 1,
724   /** For posechannels - pose space. */
725   CONSTRAINT_SPACE_POSE = 2,
726   /** For posechannels - local with parent. */
727   CONSTRAINT_SPACE_PARLOCAL = 3,
728   /** For files from between 2.43-2.46 (should have been parlocal). */
729   CONSTRAINT_SPACE_INVALID = 4, /* do not exchange for anything! */
730 } eBConstraint_SpaceTypes;
731 
732 /* Common enum for constraints that support override. */
733 typedef enum eConstraint_EulerOrder {
734   /** Automatic euler mode. */
735   CONSTRAINT_EULER_AUTO = 0,
736 
737   /** Explicit euler rotation modes - must sync with BLI_math_rotation.h defines. */
738   CONSTRAINT_EULER_XYZ = 1,
739   CONSTRAINT_EULER_XZY = 2,
740   CONSTRAINT_EULER_YXZ = 3,
741   CONSTRAINT_EULER_YZX = 4,
742   CONSTRAINT_EULER_ZXY = 5,
743   CONSTRAINT_EULER_ZYX = 6,
744 } eConstraint_EulerOrder;
745 
746 /* -------------------------------------- */
747 
748 /* bRotateLikeConstraint.flag */
749 typedef enum eCopyRotation_Flags {
750   ROTLIKE_X = (1 << 0),
751   ROTLIKE_Y = (1 << 1),
752   ROTLIKE_Z = (1 << 2),
753   ROTLIKE_X_INVERT = (1 << 4),
754   ROTLIKE_Y_INVERT = (1 << 5),
755   ROTLIKE_Z_INVERT = (1 << 6),
756 #ifdef DNA_DEPRECATED_ALLOW
757   ROTLIKE_OFFSET = (1 << 7),
758 #endif
759 } eCopyRotation_Flags;
760 
761 /* bRotateLikeConstraint.mix_mode */
762 typedef enum eCopyRotation_MixMode {
763   /* Replace rotation channel values. */
764   ROTLIKE_MIX_REPLACE = 0,
765   /* Legacy Offset mode - don't use. */
766   ROTLIKE_MIX_OFFSET = 1,
767   /* Add Euler components together. */
768   ROTLIKE_MIX_ADD = 2,
769   /* Multiply the copied rotation on the left. */
770   ROTLIKE_MIX_BEFORE = 3,
771   /* Multiply the copied rotation on the right. */
772   ROTLIKE_MIX_AFTER = 4,
773 } eCopyRotation_MixMode;
774 
775 /* bLocateLikeConstraint.flag */
776 typedef enum eCopyLocation_Flags {
777   LOCLIKE_X = (1 << 0),
778   LOCLIKE_Y = (1 << 1),
779   LOCLIKE_Z = (1 << 2),
780   /** LOCLIKE_TIP is a deprecated option... use headtail=1.0f instead */
781   LOCLIKE_TIP = (1 << 3),
782   LOCLIKE_X_INVERT = (1 << 4),
783   LOCLIKE_Y_INVERT = (1 << 5),
784   LOCLIKE_Z_INVERT = (1 << 6),
785   LOCLIKE_OFFSET = (1 << 7),
786 } eCopyLocation_Flags;
787 
788 /* bSizeLikeConstraint.flag */
789 typedef enum eCopyScale_Flags {
790   SIZELIKE_X = (1 << 0),
791   SIZELIKE_Y = (1 << 1),
792   SIZELIKE_Z = (1 << 2),
793   SIZELIKE_OFFSET = (1 << 3),
794   SIZELIKE_MULTIPLY = (1 << 4),
795   SIZELIKE_UNIFORM = (1 << 5),
796 } eCopyScale_Flags;
797 
798 /* bTransLikeConstraint.mix_mode */
799 typedef enum eCopyTransforms_MixMode {
800   /* Replace rotation channel values. */
801   TRANSLIKE_MIX_REPLACE = 0,
802   /* Multiply the copied transformation on the left, with anti-shear scale handling. */
803   TRANSLIKE_MIX_BEFORE = 1,
804   /* Multiply the copied transformation on the right, with anti-shear scale handling. */
805   TRANSLIKE_MIX_AFTER = 2,
806 } eCopyTransforms_MixMode;
807 
808 /* bTransformConstraint.to/from */
809 typedef enum eTransform_ToFrom {
810   TRANS_LOCATION = 0,
811   TRANS_ROTATION = 1,
812   TRANS_SCALE = 2,
813 } eTransform_ToFrom;
814 
815 /* bTransformConstraint.mix_mode_loc */
816 typedef enum eTransform_MixModeLoc {
817   /* Add component values together (default). */
818   TRANS_MIXLOC_ADD = 0,
819   /* Replace component values. */
820   TRANS_MIXLOC_REPLACE = 1,
821 } eTransform_MixModeLoc;
822 
823 /* bTransformConstraint.mix_mode_rot */
824 typedef enum eTransform_MixModeRot {
825   /* Add component values together (default). */
826   TRANS_MIXROT_ADD = 0,
827   /* Replace component values. */
828   TRANS_MIXROT_REPLACE = 1,
829   /* Multiply the generated rotation on the left. */
830   TRANS_MIXROT_BEFORE = 2,
831   /* Multiply the generated rotation on the right. */
832   TRANS_MIXROT_AFTER = 3,
833 } eTransform_MixModeRot;
834 
835 /* bTransformConstraint.mix_mode_scale */
836 typedef enum eTransform_MixModeScale {
837   /* Replace component values (default). */
838   TRANS_MIXSCALE_REPLACE = 0,
839   /* Multiply component values together. */
840   TRANS_MIXSCALE_MULTIPLY = 1,
841 } eTransform_MixModeScale;
842 
843 /* bSameVolumeConstraint.free_axis */
844 typedef enum eSameVolume_Axis {
845   SAMEVOL_X = 0,
846   SAMEVOL_Y = 1,
847   SAMEVOL_Z = 2,
848 } eSameVolume_Axis;
849 
850 /* bSameVolumeConstraint.mode */
851 typedef enum eSameVolume_Mode {
852   /* Strictly maintain the volume, overriding non-free axis scale. */
853   SAMEVOL_STRICT = 0,
854   /* Maintain the volume when scale is uniform, pass non-uniform other axis scale through. */
855   SAMEVOL_UNIFORM = 1,
856   /* Maintain the volume when scaled only on the free axis, pass other axis scale through. */
857   SAMEVOL_SINGLE_AXIS = 2,
858 } eSameVolume_Mode;
859 
860 /* bActionConstraint.flag */
861 typedef enum eActionConstraint_Flags {
862   /* Bones use "object" part of target action, instead of "same bone name" part */
863   ACTCON_BONE_USE_OBJECT_ACTION = (1 << 0),
864   /* Ignore the transform of 'tar' and use 'eval_time' instead: */
865   ACTCON_USE_EVAL_TIME = (1 << 1),
866 } eActionConstraint_Flags;
867 
868 /* bActionConstraint.mix_mode */
869 typedef enum eActionConstraint_MixMode {
870   /* Multiply the action transformation on the right. */
871   ACTCON_MIX_AFTER_FULL = 0,
872   /* Multiply the action transformation on the right, with anti-shear scale handling. */
873   ACTCON_MIX_AFTER = 1,
874   /* Multiply the action transformation on the left, with anti-shear scale handling. */
875   ACTCON_MIX_BEFORE = 2,
876 } eActionConstraint_MixMode;
877 
878 /* Locked-Axis Values (Locked Track) */
879 typedef enum eLockAxis_Modes {
880   LOCK_X = 0,
881   LOCK_Y = 1,
882   LOCK_Z = 2,
883 } eLockAxis_Modes;
884 
885 /* Up-Axis Values (TrackTo and Locked Track) */
886 typedef enum eUpAxis_Modes {
887   UP_X = 0,
888   UP_Y = 1,
889   UP_Z = 2,
890 } eUpAxis_Modes;
891 
892 /* Tracking axis (TrackTo, Locked Track, Damped Track) and minmax (floor) constraint */
893 typedef enum eTrackToAxis_Modes {
894   TRACK_X = 0,
895   TRACK_Y = 1,
896   TRACK_Z = 2,
897   TRACK_nX = 3,
898   TRACK_nY = 4,
899   TRACK_nZ = 5,
900 } eTrackToAxis_Modes;
901 
902 /* Shrinkwrap flags */
903 typedef enum eShrinkwrap_Flags {
904   /* Also raycast in the opposite direction. */
905   CON_SHRINKWRAP_PROJECT_OPPOSITE = (1 << 0),
906   /* Invert the cull mode when projecting opposite. */
907   CON_SHRINKWRAP_PROJECT_INVERT_CULL = (1 << 1),
908   /* Align the specified axis to the target normal. */
909   CON_SHRINKWRAP_TRACK_NORMAL = (1 << 2),
910 
911   /* Ignore front faces in project; same value as MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE */
912   CON_SHRINKWRAP_PROJECT_CULL_FRONTFACE = (1 << 3),
913   /* Ignore back faces in project; same value as MOD_SHRINKWRAP_CULL_TARGET_BACKFACE */
914   CON_SHRINKWRAP_PROJECT_CULL_BACKFACE = (1 << 4),
915 } eShrinkwrap_Flags;
916 
917 #define CON_SHRINKWRAP_PROJECT_CULL_MASK \
918   (CON_SHRINKWRAP_PROJECT_CULL_FRONTFACE | CON_SHRINKWRAP_PROJECT_CULL_BACKFACE)
919 
920 /* FollowPath flags */
921 typedef enum eFollowPath_Flags {
922   FOLLOWPATH_FOLLOW = (1 << 0),
923   FOLLOWPATH_STATIC = (1 << 1),
924   FOLLOWPATH_RADIUS = (1 << 2),
925 } eFollowPath_Flags;
926 
927 /* bTrackToConstraint->flags */
928 typedef enum eTrackTo_Flags {
929   TARGET_Z_UP = (1 << 0),
930 } eTrackTo_Flags;
931 
932 /* Stretch To Constraint -> volmode */
933 typedef enum eStretchTo_VolMode {
934   VOLUME_XZ = 0,
935   VOLUME_X = 1,
936   VOLUME_Z = 2,
937   NO_VOLUME = 3,
938 } eStretchTo_VolMode;
939 
940 /* Stretch To Constraint -> plane mode */
941 typedef enum eStretchTo_PlaneMode {
942   PLANE_X = 0,
943   SWING_Y = 1,
944   PLANE_Z = 2,
945 } eStretchTo_PlaneMode;
946 
947 /* Clamp-To Constraint ->flag */
948 typedef enum eClampTo_Modes {
949   CLAMPTO_AUTO = 0,
950   CLAMPTO_X = 1,
951   CLAMPTO_Y = 2,
952   CLAMPTO_Z = 3,
953 } eClampTo_Modes;
954 
955 /* ClampTo Constraint ->flag2 */
956 typedef enum eClampTo_Flags {
957   CLAMPTO_CYCLIC = (1 << 0),
958 } eClampTo_Flags;
959 
960 /* bKinematicConstraint->flag */
961 typedef enum eKinematic_Flags {
962   CONSTRAINT_IK_TIP = (1 << 0),
963   CONSTRAINT_IK_ROT = (1 << 1),
964   /* targetless */
965   CONSTRAINT_IK_AUTO = (1 << 2),
966   /* autoik */
967   CONSTRAINT_IK_TEMP = (1 << 3),
968   CONSTRAINT_IK_STRETCH = (1 << 4),
969   CONSTRAINT_IK_POS = (1 << 5),
970   CONSTRAINT_IK_SETANGLE = (1 << 6),
971   CONSTRAINT_IK_GETANGLE = (1 << 7),
972   /* limit axis */
973   CONSTRAINT_IK_NO_POS_X = (1 << 8),
974   CONSTRAINT_IK_NO_POS_Y = (1 << 9),
975   CONSTRAINT_IK_NO_POS_Z = (1 << 10),
976   CONSTRAINT_IK_NO_ROT_X = (1 << 11),
977   CONSTRAINT_IK_NO_ROT_Y = (1 << 12),
978   CONSTRAINT_IK_NO_ROT_Z = (1 << 13),
979   /* axis relative to target */
980   CONSTRAINT_IK_TARGETAXIS = (1 << 14),
981 } eKinematic_Flags;
982 
983 /* bSplineIKConstraint->flag */
984 typedef enum eSplineIK_Flags {
985   /* chain has been attached to spline */
986   CONSTRAINT_SPLINEIK_BOUND = (1 << 0),
987   /* root of chain is not influenced by the constraint */
988   CONSTRAINT_SPLINEIK_NO_ROOT = (1 << 1),
989 #ifdef DNA_DEPRECATED_ALLOW
990   /* bones in the chain should not scale to fit the curve */
991   CONSTRAINT_SPLINEIK_SCALE_LIMITED = (1 << 2),
992 #endif
993   /* evenly distribute the bones along the path regardless of length */
994   CONSTRAINT_SPLINEIK_EVENSPLITS = (1 << 3),
995   /* don't adjust the x and z scaling of the bones by the curve radius */
996   CONSTRAINT_SPLINEIK_NO_CURVERAD = (1 << 4),
997 
998   /* for "volumetric" xz scale mode, limit the minimum or maximum scale values */
999   CONSTRAINT_SPLINEIK_USE_BULGE_MIN = (1 << 5),
1000   CONSTRAINT_SPLINEIK_USE_BULGE_MAX = (1 << 6),
1001 
1002   /* apply volume preservation over original scaling of the bone */
1003   CONSTRAINT_SPLINEIK_USE_ORIGINAL_SCALE = (1 << 7),
1004 } eSplineIK_Flags;
1005 
1006 /* bSplineIKConstraint->xzScaleMode */
1007 typedef enum eSplineIK_XZScaleModes {
1008   /* no x/z scaling */
1009   CONSTRAINT_SPLINEIK_XZS_NONE = 0,
1010   /* bones in the chain should take their x/z scales from the original scaling */
1011   CONSTRAINT_SPLINEIK_XZS_ORIGINAL = 1,
1012   /* x/z scales are the inverse of the y-scale */
1013   CONSTRAINT_SPLINEIK_XZS_INVERSE = 2,
1014   /* x/z scales are computed using a volume preserving technique (from Stretch To constraint) */
1015   CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC = 3,
1016 } eSplineIK_XZScaleModes;
1017 
1018 /* bSplineIKConstraint->yScaleMode */
1019 typedef enum eSplineIK_YScaleModes {
1020   /* no y scaling */
1021   CONSTRAINT_SPLINEIK_YS_NONE = 0,
1022   /* bones in the chain should be scaled to fit the length of the curve */
1023   CONSTRAINT_SPLINEIK_YS_FIT_CURVE = 1,
1024   /* bones in the chain should take their y scales from the original scaling */
1025   CONSTRAINT_SPLINEIK_YS_ORIGINAL = 2,
1026 } eSplineIK_YScaleModes;
1027 
1028 /* bArmatureConstraint -> flag */
1029 typedef enum eArmature_Flags {
1030   /** use dual quaternion blending */
1031   CONSTRAINT_ARMATURE_QUATERNION = (1 << 0),
1032   /** use envelopes */
1033   CONSTRAINT_ARMATURE_ENVELOPE = (1 << 1),
1034   /** use current bone location */
1035   CONSTRAINT_ARMATURE_CUR_LOCATION = (1 << 2),
1036 } eArmature_Flags;
1037 
1038 /* MinMax (floor) flags */
1039 typedef enum eFloor_Flags {
1040   /* MINMAX_STICKY = (1 << 0), */ /* Deprecated. */
1041   /* MINMAX_STUCK = (1 << 1), */  /* Deprecated. */
1042   MINMAX_USEROT = (1 << 2),
1043 } eFloor_Flags;
1044 
1045 /* transform limiting constraints -> flag2 */
1046 typedef enum eTransformLimits_Flags2 {
1047   /* not used anymore - for older Limit Location constraints only */
1048   /* LIMIT_NOPARENT = (1 << 0), */ /* UNUSED */
1049   /* for all Limit constraints - allow to be used during transform? */
1050   LIMIT_TRANSFORM = (1 << 1),
1051 } eTransformLimits_Flags2;
1052 
1053 /* transform limiting constraints -> flag (own flags)  */
1054 typedef enum eTransformLimits_Flags {
1055   LIMIT_XMIN = (1 << 0),
1056   LIMIT_XMAX = (1 << 1),
1057   LIMIT_YMIN = (1 << 2),
1058   LIMIT_YMAX = (1 << 3),
1059   LIMIT_ZMIN = (1 << 4),
1060   LIMIT_ZMAX = (1 << 5),
1061 } eTransformLimits_Flags;
1062 
1063 /* limit rotation constraint -> flag (own flags) */
1064 typedef enum eRotLimit_Flags {
1065   LIMIT_XROT = (1 << 0),
1066   LIMIT_YROT = (1 << 1),
1067   LIMIT_ZROT = (1 << 2),
1068 } eRotLimit_Flags;
1069 
1070 /* distance limit constraint */
1071 /* bDistLimitConstraint->flag */
1072 typedef enum eDistLimit_Flag {
1073   /* "soft" cushion effect when reaching the limit sphere */  // NOT IMPLEMENTED!
1074   LIMITDIST_USESOFT = (1 << 0),
1075   /* as for all Limit constraints - allow to be used during transform? */
1076   LIMITDIST_TRANSFORM = (1 << 1),
1077 } eDistLimit_Flag;
1078 
1079 /* bDistLimitConstraint->mode */
1080 typedef enum eDistLimit_Modes {
1081   LIMITDIST_INSIDE = 0,
1082   LIMITDIST_OUTSIDE = 1,
1083   LIMITDIST_ONSURFACE = 2,
1084 } eDistLimit_Modes;
1085 
1086 /* python constraint -> flag */
1087 typedef enum ePyConstraint_Flags {
1088   PYCON_USETARGETS = (1 << 0),
1089   PYCON_SCRIPTERROR = (1 << 1),
1090 } ePyConstraint_Flags;
1091 
1092 /* ChildOf Constraint -> flag */
1093 typedef enum eChildOf_Flags {
1094   CHILDOF_LOCX = (1 << 0),
1095   CHILDOF_LOCY = (1 << 1),
1096   CHILDOF_LOCZ = (1 << 2),
1097   CHILDOF_ROTX = (1 << 3),
1098   CHILDOF_ROTY = (1 << 4),
1099   CHILDOF_ROTZ = (1 << 5),
1100   CHILDOF_SIZEX = (1 << 6),
1101   CHILDOF_SIZEY = (1 << 7),
1102   CHILDOF_SIZEZ = (1 << 8),
1103   CHILDOF_ALL = 511,
1104   /* Temporary flag used by the Set Inverse operator. */
1105   CHILDOF_SET_INVERSE = (1 << 9),
1106 } eChildOf_Flags;
1107 
1108 /* Pivot Constraint */
1109 /* Restrictions for Pivot Constraint axis to consider for enabling constraint */
1110 typedef enum ePivotConstraint_Axis {
1111   /* do not consider this activity-clamping */
1112   PIVOTCON_AXIS_NONE = -1,
1113 
1114   /* consider -ve x-axis rotations */
1115   PIVOTCON_AXIS_X_NEG = 0,
1116   /* consider -ve y-axis rotations */
1117   PIVOTCON_AXIS_Y_NEG = 1,
1118   /* consider -ve z-axis rotations */
1119   PIVOTCON_AXIS_Z_NEG = 2,
1120 
1121   /* consider +ve x-axis rotations */
1122   PIVOTCON_AXIS_X = 3,
1123   /* consider +ve y-axis rotations */
1124   PIVOTCON_AXIS_Y = 4,
1125   /* consider +ve z-axis rotations */
1126   PIVOTCON_AXIS_Z = 5,
1127 } ePivotConstraint_Axis;
1128 
1129 /* settings for Pivot Constraint in general */
1130 typedef enum ePivotConstraint_Flag {
1131   /* offset is to be interpreted as being a fixed-point in space */
1132   PIVOTCON_FLAG_OFFSET_ABS = (1 << 0),
1133   /* rotation-based activation uses negative rotation to drive result */
1134   PIVOTCON_FLAG_ROTACT_NEG = (1 << 1),
1135 } ePivotConstraint_Flag;
1136 
1137 typedef enum eFollowTrack_Flags {
1138   FOLLOWTRACK_ACTIVECLIP = (1 << 0),
1139   FOLLOWTRACK_USE_3D_POSITION = (1 << 1),
1140   FOLLOWTRACK_USE_UNDISTORTION = (1 << 2),
1141 } eFollowTrack_Flags;
1142 
1143 typedef enum eFollowTrack_FrameMethod {
1144   FOLLOWTRACK_FRAME_STRETCH = 0,
1145   FOLLOWTRACK_FRAME_FIT = 1,
1146   FOLLOWTRACK_FRAME_CROP = 2,
1147 } eFollowTrack_FrameMethod;
1148 
1149 /* CameraSolver Constraint -> flag */
1150 typedef enum eCameraSolver_Flags {
1151   CAMERASOLVER_ACTIVECLIP = (1 << 0),
1152 } eCameraSolver_Flags;
1153 
1154 /* ObjectSolver Constraint -> flag */
1155 typedef enum eObjectSolver_Flags {
1156   OBJECTSOLVER_ACTIVECLIP = (1 << 0),
1157   /* Temporary flag used by the Set Inverse operator. */
1158   OBJECTSOLVER_SET_INVERSE = (1 << 1),
1159 } eObjectSolver_Flags;
1160 
1161 /* ObjectSolver Constraint -> flag */
1162 typedef enum eStretchTo_Flags {
1163   STRETCHTOCON_USE_BULGE_MIN = (1 << 0),
1164   STRETCHTOCON_USE_BULGE_MAX = (1 << 1),
1165 } eStretchTo_Flags;
1166 
1167 /* important: these defines need to match up with PHY_DynamicTypes headerfile */
1168 #define CONSTRAINT_RB_BALL 1
1169 #define CONSTRAINT_RB_HINGE 2
1170 #define CONSTRAINT_RB_CONETWIST 4
1171 #define CONSTRAINT_RB_VEHICLE 11
1172 #define CONSTRAINT_RB_GENERIC6DOF 12
1173