Blender V2.61 - r43446

DNA_anim_types.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
00019  * All rights reserved.
00020  *
00021  * Contributor(s): Joshua Leung (full recode)
00022  *
00023  * ***** END GPL LICENSE BLOCK *****
00024  */
00025 
00030 #ifndef DNA_ANIM_TYPES_H
00031 #define DNA_ANIM_TYPES_H
00032 
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif
00036 
00037 #include "DNA_ID.h"
00038 #include "DNA_listBase.h"
00039 #include "DNA_action_types.h"
00040 #include "DNA_curve_types.h"
00041 
00042 /* ************************************************ */
00043 /* F-Curve DataTypes */
00044 
00045 /* Modifiers -------------------------------------- */
00046 
00047 /* F-Curve Modifiers (fcm) 
00048  *
00049  * These alter the way F-Curves behave, by altering the value that is returned
00050  * when evaluating the curve's data at some time (t). 
00051  */
00052 typedef struct FModifier {
00053     struct FModifier *next, *prev;
00054     
00055     void *data;         /* pointer to modifier data */
00056     void *edata;        /* pointer to temporary data used during evaluation */
00057     
00058     char name[64];      /* user-defined description for the modifier */
00059     short type;         /* type of f-curve modifier */
00060     short flag;         /* settings for the modifier */
00061     
00062     float influence;    /* the amount that the modifier should influence the value */
00063     
00064     float sfra;         /* start frame of restricted frame-range */
00065     float efra;         /* end frame of restricted frame-range */
00066     float blendin;      /* number of frames from sfra before modifier takes full influence */
00067     float blendout;     /* number of frames from efra before modifier fades out */
00068 } FModifier;
00069 
00070 /* Types of F-Curve modifier 
00071  * WARNING: order here is important!
00072  */
00073 typedef enum eFModifier_Types {
00074     FMODIFIER_TYPE_NULL = 0,
00075     FMODIFIER_TYPE_GENERATOR,
00076     FMODIFIER_TYPE_FN_GENERATOR,
00077     FMODIFIER_TYPE_ENVELOPE,
00078     FMODIFIER_TYPE_CYCLES,
00079     FMODIFIER_TYPE_NOISE,
00080     FMODIFIER_TYPE_FILTER,      /* unimplemented - for applying: fft, high/low pass filters, etc. */
00081     FMODIFIER_TYPE_PYTHON,  
00082     FMODIFIER_TYPE_LIMITS,
00083     FMODIFIER_TYPE_STEPPED,
00084     
00085     /* NOTE: all new modifiers must be added above this line */
00086     FMODIFIER_NUM_TYPES
00087 } eFModifier_Types;
00088 
00089 /* F-Curve Modifier Settings */
00090 typedef enum eFModifier_Flags {
00091         /* modifier is not able to be evaluated for some reason, and should be skipped (internal) */
00092     FMODIFIER_FLAG_DISABLED      = (1<<0),
00093         /* modifier's data is expanded (in UI) */
00094     FMODIFIER_FLAG_EXPANDED      = (1<<1),
00095         /* modifier is active one (in UI) for editing purposes */
00096     FMODIFIER_FLAG_ACTIVE        = (1<<2),
00097         /* user wants modifier to be skipped */
00098     FMODIFIER_FLAG_MUTED         = (1<<3),
00099         /* restrict range that F-Modifier can be considered over */
00100     FMODIFIER_FLAG_RANGERESTRICT = (1<<4),
00101         /* use influence control */
00102     FMODIFIER_FLAG_USEINFLUENCE  = (1<<5)
00103 } eFModifier_Flags; 
00104 
00105 /* --- */
00106 
00107 /* Generator modifier data */
00108 typedef struct FMod_Generator {
00109         /* general generator information */
00110     float *coefficients;        /* coefficients array */
00111     unsigned int arraysize;     /* size of the coefficients array */
00112     
00113     int poly_order;             /* order of polynomial generated (i.e. 1 for linear, 2 for quadratic) */
00114     int mode;                   /* which 'generator' to use eFMod_Generator_Modes */
00115     
00116         /* settings */
00117     int flag;                   /* settings */
00118 } FMod_Generator;
00119 
00120 /* generator modes */
00121 typedef enum eFMod_Generator_Modes {
00122     FCM_GENERATOR_POLYNOMIAL    = 0,
00123     FCM_GENERATOR_POLYNOMIAL_FACTORISED
00124 } eFMod_Generator_Modes;
00125 
00126 
00127 /* generator flags 
00128  *  - shared by Generator and Function Generator
00129  */
00130 typedef enum eFMod_Generator_Flags {
00131         /* generator works in conjunction with other modifiers (i.e. doesn't replace those before it) */
00132     FCM_GENERATOR_ADDITIVE  = (1<<0)
00133 } eFMod_Generator_Flags;
00134 
00135 
00136 /* 'Built-In Function' Generator modifier data
00137  * 
00138  * This uses the general equation for equations:
00139  *      y = amplitude * fn(phase_multiplier*x + phase_offset) + y_offset
00140  *
00141  * where amplitude, phase_multiplier/offset, y_offset are user-defined coefficients,
00142  * x is the evaluation 'time', and 'y' is the resultant value
00143  */
00144 typedef struct FMod_FunctionGenerator {
00145         /* coefficients for general equation (as above) */
00146     float amplitude;
00147     float phase_multiplier;
00148     float phase_offset;
00149     float value_offset;
00150     
00151         /* flags */
00152     int type;               /* eFMod_Generator_Functions */
00153     int flag;               /* eFMod_Generator_flags */
00154 } FMod_FunctionGenerator;
00155 
00156 /* 'function' generator types */
00157 typedef enum eFMod_Generator_Functions {
00158     FCM_GENERATOR_FN_SIN    = 0,
00159     FCM_GENERATOR_FN_COS,
00160     FCM_GENERATOR_FN_TAN,
00161     FCM_GENERATOR_FN_SQRT,
00162     FCM_GENERATOR_FN_LN,
00163     FCM_GENERATOR_FN_SINC
00164 } eFMod_Generator_Functions;
00165 
00166 
00167 /* envelope modifier - envelope data */
00168 typedef struct FCM_EnvelopeData {
00169     float min, max;             /* min/max values for envelope at this point (absolute values)  */
00170     float time;                 /* time for that this sample-point occurs */
00171     
00172     short f1;                   /* settings for 'min' control point */
00173     short f2;                   /* settings for 'max' control point */
00174 } FCM_EnvelopeData;
00175 
00176 /* envelope-like adjustment to values (for fade in/out) */
00177 typedef struct FMod_Envelope {
00178     FCM_EnvelopeData *data;     /* data-points defining envelope to apply (array)  */
00179     int totvert;                /* number of envelope points */
00180     
00181     float midval;               /* value that envelope's influence is centered around / based on */
00182     float min, max;             /* distances from 'middle-value' for 1:1 envelope influence */
00183 } FMod_Envelope;
00184 
00185 
00186 /* cycling/repetition modifier data */
00187 // TODO: we can only do complete cycles...
00188 typedef struct FMod_Cycles {
00189     short   before_mode;        /* extrapolation mode to use before first keyframe */
00190     short   after_mode;         /* extrapolation mode to use after last keyframe */
00191     short   before_cycles;      /* number of 'cycles' before first keyframe to do */
00192     short   after_cycles;       /* number of 'cycles' after last keyframe to do */
00193 } FMod_Cycles;
00194 
00195 /* cycling modes */
00196 typedef enum eFMod_Cycling_Modes {
00197     FCM_EXTRAPOLATE_NONE = 0,           /* don't do anything */
00198     FCM_EXTRAPOLATE_CYCLIC,             /* repeat keyframe range as-is */
00199     FCM_EXTRAPOLATE_CYCLIC_OFFSET,      /* repeat keyframe range, but with offset based on gradient between values */
00200     FCM_EXTRAPOLATE_MIRROR              /* alternate between forward and reverse playback of keyframe range */
00201 } eFMod_Cycling_Modes;
00202 
00203 
00204 /* Python-script modifier data */
00205 typedef struct FMod_Python {
00206     struct Text *script;        /* text buffer containing script to execute */
00207     IDProperty *prop;           /* ID-properties to provide 'custom' settings */
00208 } FMod_Python;
00209 
00210 
00211 /* limits modifier data */
00212 typedef struct FMod_Limits {
00213     rctf rect;                  /* rect defining the min/max values */
00214     int flag;                   /* settings for limiting */
00215     int pad;
00216 } FMod_Limits;
00217 
00218 /* limiting flags */
00219 typedef enum eFMod_Limit_Flags {
00220     FCM_LIMIT_XMIN      = (1<<0),
00221     FCM_LIMIT_XMAX      = (1<<1),
00222     FCM_LIMIT_YMIN      = (1<<2),
00223     FCM_LIMIT_YMAX      = (1<<3)
00224 } eFMod_Limit_Flags;
00225 
00226 
00227 /* noise modifier data */
00228 typedef struct FMod_Noise {
00229     float size;
00230     float strength;
00231     float phase;
00232     float pad;
00233     
00234     short depth;
00235     short modification;
00236 } FMod_Noise;
00237     
00238 /* modification modes */
00239 typedef enum eFMod_Noise_Modifications {
00240     FCM_NOISE_MODIF_REPLACE = 0,    /* Modify existing curve, matching it's shape */
00241     FCM_NOISE_MODIF_ADD,            /* Add noise to the curve */
00242     FCM_NOISE_MODIF_SUBTRACT,       /* Subtract noise from the curve */
00243     FCM_NOISE_MODIF_MULTIPLY        /* Multiply the curve by noise */
00244 } eFMod_Noise_Modifications;
00245 
00246 
00247 /* stepped modifier data */
00248 typedef struct FMod_Stepped {
00249     float step_size;                /* Number of frames each interpolated value should be held */
00250     float offset;                   /* Reference frame number that stepping starts from */
00251     
00252     float start_frame;              /* start frame of the frame range that modifier works in */             
00253     float end_frame;                /* end frame of the frame range that modifier works in */
00254     
00255     int flag;                       /* various settings */  
00256 } FMod_Stepped;
00257 
00258 /* stepped modifier range flags */
00259 typedef enum eFMod_Stepped_Flags {
00260     FCM_STEPPED_NO_BEFORE   = (1<<0),   /* don't affect frames before the start frame */
00261     FCM_STEPPED_NO_AFTER    = (1<<1),   /* don't affect frames after the end frame */
00262 } eFMod_Stepped_Flags;
00263 
00264 /* Drivers -------------------------------------- */
00265 
00266 /* Driver Target (dtar)
00267  *
00268  * Defines how to access a dependency needed for a driver variable.
00269  */
00270 typedef struct DriverTarget {
00271     ID  *id;                /* ID-block which owns the target, no user count */
00272     
00273     char *rna_path;         /* RNA path defining the setting to use (for DVAR_TYPE_SINGLE_PROP) */
00274     
00275     char pchan_name[32];    /* name of the posebone to use (for vars where DTAR_FLAG_STRUCT_REF is used) */
00276     short transChan;        /* transform channel index (for DVAR_TYPE_TRANSFORM_CHAN)*/
00277     
00278     short flag;             /* flags for the validity of the target (NOTE: these get reset everytime the types change) */
00279     int idtype;             /* type of ID-block that this target can use */
00280 } DriverTarget;
00281 
00282 /* Driver Target flags */
00283 typedef enum eDriverTarget_Flag {
00284         /* used for targets that use the pchan_name instead of RNA path 
00285          * (i.e. rotation difference) 
00286          */
00287     DTAR_FLAG_STRUCT_REF    = (1<<0),
00288         /* idtype can only be 'Object' */
00289     DTAR_FLAG_ID_OB_ONLY    = (1<<1),
00290     
00291     /* "localspace" flags */
00292         /* base flag - basically "pre parent+constraints" */
00293     DTAR_FLAG_LOCALSPACE    = (1<<2),
00294         /* include constraints transformed to space including parents */
00295     DTAR_FLAG_LOCAL_CONSTS  = (1<<3),
00296 } eDriverTarget_Flag;
00297 
00298 /* Transform Channels for Driver Targets */
00299 typedef enum eDriverTarget_TransformChannels {
00300     DTAR_TRANSCHAN_LOCX = 0,
00301     DTAR_TRANSCHAN_LOCY,
00302     DTAR_TRANSCHAN_LOCZ,
00303     DTAR_TRANSCHAN_ROTX,
00304     DTAR_TRANSCHAN_ROTY,
00305     DTAR_TRANSCHAN_ROTZ,
00306     DTAR_TRANSCHAN_SCALEX,
00307     DTAR_TRANSCHAN_SCALEY,
00308     DTAR_TRANSCHAN_SCALEZ,
00309     
00310     MAX_DTAR_TRANSCHAN_TYPES
00311 } eDriverTarget_TransformChannels;
00312 
00313 /* --- */
00314 
00315 /* maximum number of driver targets per variable */
00316 #define MAX_DRIVER_TARGETS  8
00317 
00318 
00319 /* Driver Variable (dvar)
00320  *
00321  * A 'variable' for use as an input for the driver evaluation.
00322  * Defines a way of accessing some channel to use, that can be
00323  * referred to in the expression as a variable, thus simplifying
00324  * expressions and also Depsgraph building.
00325  */
00326 typedef struct DriverVar {
00327     struct DriverVar *next, *prev;
00328     
00329     char name[64];              /* name of the variable to use in py-expression (must be valid python identifier) */
00330     
00331     DriverTarget targets[8];    /* MAX_DRIVER_TARGETS, target slots */  
00332     short num_targets;          /* number of targets actually used by this variable */
00333     
00334     short type;                 /* type of driver target (eDriverTarget_Types) */   
00335     float curval;               /* result of previous evaluation */
00336 } DriverVar;
00337 
00338 /* Driver Variable Types */
00339 typedef enum eDriverVar_Types {
00340         /* single RNA property */
00341     DVAR_TYPE_SINGLE_PROP   = 0,
00342         /* rotation difference (between 2 bones) */
00343     DVAR_TYPE_ROT_DIFF,
00344         /* distance between objects/bones */
00345     DVAR_TYPE_LOC_DIFF,
00346         /* 'final' transform for object/bones */
00347     DVAR_TYPE_TRANSFORM_CHAN,
00348     
00349     /* maximum number of variable types 
00350      * NOTE: this must always be th last item in this list,
00351      *      so add new types above this line
00352      */
00353     MAX_DVAR_TYPES
00354 } eDriverVar_Types;
00355 
00356 /* --- */
00357 
00358 /* Channel Driver (i.e. Drivers / Expressions) (driver)
00359  *
00360  * Channel Drivers are part of the dependency system, and are executed in addition to 
00361  * normal user-defined animation. They take the animation result of some channel(s), and
00362  * use that (optionally combined with its own F-Curve for modification of results) to define
00363  * the value of some setting semi-procedurally.
00364  *
00365  * Drivers are stored as part of F-Curve data, so that the F-Curve's RNA-path settings (for storing
00366  * what setting the driver will affect). The order in which they are stored defines the order that they're
00367  * evaluated in. This order is set by the Depsgraph's sorting stuff. 
00368  */
00369 typedef struct ChannelDriver {
00370     ListBase variables; /* targets for this driver (i.e. list of DriverVar) */
00371     
00372     /* python expression to execute (may call functions defined in an accessory file) 
00373      * which relates the target 'variables' in some way to yield a single usable value
00374      */
00375     char expression[256];   /* expression to compile for evaluation */
00376     void *expr_comp;        /* PyObject - compiled expression, dont save this */
00377     
00378     float curval;       /* result of previous evaluation */
00379     float influence;    /* influence of driver on result */ // XXX to be implemented... this is like the constraint influence setting
00380     
00381         /* general settings */
00382     int type;           /* type of driver */
00383     int flag;           /* settings of driver */
00384 } ChannelDriver;
00385 
00386 /* driver type */
00387 typedef enum eDriver_Types {
00388         /* target values are averaged together */
00389     DRIVER_TYPE_AVERAGE = 0,
00390         /* python expression/function relates targets */
00391     DRIVER_TYPE_PYTHON,
00392         /* sum of all values */
00393     DRIVER_TYPE_SUM,
00394         /* smallest value */
00395     DRIVER_TYPE_MIN,
00396         /* largest value */
00397     DRIVER_TYPE_MAX
00398 } eDriver_Types;
00399 
00400 /* driver flags */
00401 typedef enum eDriver_Flags {
00402         /* driver has invalid settings (internal flag)  */
00403     DRIVER_FLAG_INVALID     = (1<<0),
00404         /* driver needs recalculation (set by depsgraph) */
00405     DRIVER_FLAG_RECALC      = (1<<1),
00406         /* driver does replace value, but overrides (for layering of animation over driver) */
00407         // TODO: this needs to be implemented at some stage or left out...
00408     //DRIVER_FLAG_LAYERING  = (1<<2),
00409         /* use when the expression needs to be recompiled */
00410     DRIVER_FLAG_RECOMPILE   = (1<<3),
00411         /* the names are cached so they dont need have python unicode versions created each time */
00412     DRIVER_FLAG_RENAMEVAR   = (1<<4),
00413         /* intermediate values of driver should be shown in the UI for debugging purposes */
00414     DRIVER_FLAG_SHOWDEBUG   = (1<<5)
00415 } eDriver_Flags;
00416 
00417 /* F-Curves -------------------------------------- */
00418 
00419 /* FPoint (fpt)
00420  *
00421  * This is the bare-minimum data required storing motion samples. Should be more efficient
00422  * than using BPoints, which contain a lot of other unnecessary data...
00423  */
00424 typedef struct FPoint {
00425     float vec[2];       /* time + value */
00426     int flag;           /* selection info */
00427     int pad;
00428 } FPoint;
00429 
00430 /* 'Function-Curve' - defines values over time for a given setting (fcu) */
00431 typedef struct FCurve {
00432     struct FCurve *next, *prev;
00433     
00434         /* group */
00435     bActionGroup *grp;      /* group that F-Curve belongs to */
00436     
00437         /* driver settings */
00438     ChannelDriver *driver;  /* only valid for drivers (i.e. stored in AnimData not Actions) */
00439         /* evaluation settings */
00440     ListBase modifiers;     /* FCurve Modifiers */
00441         
00442         /* motion data */
00443     BezTriple *bezt;        /* user-editable keyframes (array) */
00444     FPoint *fpt;            /* 'baked/imported' motion samples (array) */
00445     unsigned int totvert;   /* total number of points which define the curve (i.e. size of arrays in FPoints) */
00446     
00447         /* value cache + settings */
00448     float curval;           /* value stored from last time curve was evaluated */
00449     short flag;             /* user-editable settings for this curve */
00450     short extend;           /* value-extending mode for this curve (does not cover  */
00451     
00452         /* RNA - data link */
00453     int array_index;        /* if applicable, the index of the RNA-array item to get */
00454     char *rna_path;         /* RNA-path to resolve data-access */
00455     
00456         /* curve coloring (for editor) */
00457     int color_mode;         /* coloring method to use (eFCurve_Coloring) */
00458     float color[3];         /* the last-color this curve took */
00459 } FCurve;
00460 
00461 
00462 /* user-editable flags/settings */
00463 typedef enum eFCurve_Flags {
00464         /* curve/keyframes are visible in editor */
00465     FCURVE_VISIBLE      = (1<<0),
00466         /* curve is selected for editing  */
00467     FCURVE_SELECTED     = (1<<1),
00468         /* curve is active one */
00469     FCURVE_ACTIVE       = (1<<2),
00470         /* keyframes (beztriples) cannot be edited */
00471     FCURVE_PROTECTED    = (1<<3),
00472         /* fcurve will not be evaluated for the next round */
00473     FCURVE_MUTED        = (1<<4),
00474     
00475         /* fcurve uses 'auto-handles', which stay horizontal... */
00476         // DEPRECATED
00477     FCURVE_AUTO_HANDLES = (1<<5),
00478     
00479         /* skip evaluation, as RNA-path cannot be resolved (similar to muting, but cannot be set by user) */
00480     FCURVE_DISABLED         = (1<<10),
00481         /* curve can only have whole-number values (integer types) */
00482     FCURVE_INT_VALUES       = (1<<11),
00483         /* curve can only have certain discrete-number values (no interpolation at all, for enums/booleans) */
00484     FCURVE_DISCRETE_VALUES  = (1<<12),
00485     
00486         /* temporary tag for editing */
00487     FCURVE_TAGGED           = (1<<15)
00488 } eFCurve_Flags;
00489 
00490 /* extrapolation modes (only simple value 'extending') */
00491 typedef enum eFCurve_Extend {
00492     FCURVE_EXTRAPOLATE_CONSTANT = 0,    /* just extend min/max keyframe value  */
00493     FCURVE_EXTRAPOLATE_LINEAR           /* just extend gradient of segment between first segment keyframes */
00494 } eFCurve_Extend;
00495 
00496 /* curve coloring modes */
00497 typedef enum eFCurve_Coloring {
00498     FCURVE_COLOR_AUTO_RAINBOW = 0,      /* automatically determine color using rainbow (calculated at drawtime) */
00499     FCURVE_COLOR_AUTO_RGB,              /* automatically determine color using XYZ (array index) <-> RGB */
00500     FCURVE_COLOR_CUSTOM                 /* custom color */
00501 } eFCurve_Coloring;
00502 
00503 /* ************************************************ */
00504 /* 'Action' Datatypes */
00505 
00506 /* NOTE: Although these are part of the Animation System,
00507  * they are not stored here... see DNA_action_types.h instead
00508  */
00509 
00510  
00511 /* ************************************************ */
00512 /* Animation Reuse - i.e. users of Actions */
00513 
00514 /* Retargetting ----------------------------------- */
00515 
00516 /* Retargetting Pair
00517  *
00518  * Defines what parts of the paths should be remapped from 'abc' to 'xyz'.
00519  * TODO:
00520  *  - Regrex (possibly provided through PY, though having our own module might be faster)
00521  *    would be important to have at some point. Current replacements are just simple
00522  *    string matches...
00523  */
00524 typedef struct AnimMapPair {
00525     char from[128];     /* part of path to bed replaced */
00526     char to[128];       /* part of path to replace with */
00527 } AnimMapPair;
00528 
00529 /* Retargetting Information for Actions 
00530  *
00531  * This should only be used if it is strictly necessary (i.e. user will need to explictly 
00532  * add this when they find that some channels do not match, or motion is not going to right 
00533  * places). When executing an action, this will be checked to see if it provides any useful
00534  * remaps for the given paths.
00535  *
00536  * NOTE: we currently don't store this in the Action itself, as that causes too many problems.
00537  */
00538 // FIXME: will this be too clumsy or slow? If we're using RNA paths anyway, we'll have to accept
00539 // such consequences...
00540 typedef struct AnimMapper {
00541     struct AnimMapper *next, *prev;
00542     
00543     bAction *target;        /* target action */
00544     ListBase mappings;      /* remapping table (bAnimMapPair) */
00545 } AnimMapper;
00546 
00547 /* ************************************************ */
00548 /* NLA - Non-Linear Animation */
00549 
00550 /* NLA Strips ------------------------------------- */
00551 
00552 /* NLA Strip (strip)
00553  *
00554  * A NLA Strip is a container for the reuse of Action data, defining parameters
00555  * to control the remapping of the Action data to some destination. 
00556  */
00557 typedef struct NlaStrip {
00558     struct NlaStrip *next, *prev;
00559     
00560     ListBase strips;            /* 'Child' strips (used for 'meta' strips) */
00561     bAction *act;               /* Action that is referenced by this strip (strip is 'user' of the action) */
00562     AnimMapper *remap;          /* Remapping info this strip (for tweaking correspondance of action with context) */
00563     
00564     ListBase fcurves;           /* F-Curves for controlling this strip's influence and timing */    // TODO: move out?
00565     ListBase modifiers;         /* F-Curve modifiers to be applied to the entire strip's referenced F-Curves */
00566     
00567     char name[64];              /* User-Visible Identifier for Strip */
00568     
00569     float influence;            /* Influence of strip */
00570     float strip_time;           /* Current 'time' within action being used (automatically evaluated, but can be overridden) */
00571     
00572     float start, end;           /* extents of the strip */
00573     float actstart, actend;     /* range of the action to use */
00574     
00575     float repeat;               /* The number of times to repeat the action range (only when no F-Curves) */
00576     float scale;                /* The amount the action range is scaled by (only when no F-Curves) */
00577     
00578     float blendin, blendout;    /* strip blending length (only used when there are no F-Curves) */  
00579     short blendmode;            /* strip blending mode (layer-based mixing) */
00580     
00581     short extendmode;           /* strip extrapolation mode (time-based mixing) */
00582     short pad1;
00583     
00584     short type;                 /* type of NLA strip */
00585     
00586     void *speaker_handle;       /* handle for speaker objects */
00587     
00588     int flag;                   /* settings */
00589     int pad2;
00590 } NlaStrip;
00591 
00592 /* NLA Strip Blending Mode */
00593 typedef enum eNlaStrip_Blend_Mode {
00594     NLASTRIP_MODE_REPLACE = 0,
00595     NLASTRIP_MODE_ADD,
00596     NLASTRIP_MODE_SUBTRACT,
00597     NLASTRIP_MODE_MULTIPLY
00598 } eNlaStrip_Blend_Mode;
00599 
00600 /* NLA Strip Extrpolation Mode */
00601 typedef enum eNlaStrip_Extrapolate_Mode {
00602         /* extend before first frame if no previous strips in track, and always hold+extend last frame */
00603     NLASTRIP_EXTEND_HOLD    = 0,        
00604         /* only hold+extend last frame */
00605     NLASTRIP_EXTEND_HOLD_FORWARD,   
00606         /* don't contribute at all */
00607     NLASTRIP_EXTEND_NOTHING
00608 } eNlaStrip_Extrapolate_Mode;
00609 
00610 /* NLA Strip Settings */
00611 typedef enum eNlaStrip_Flag {
00612     /* UI selection flags */
00613         /* NLA strip is the active one in the track (also indicates if strip is being tweaked) */
00614     NLASTRIP_FLAG_ACTIVE        = (1<<0),   
00615         /* NLA strip is selected for editing */
00616     NLASTRIP_FLAG_SELECT        = (1<<1),
00617 //  NLASTRIP_FLAG_SELECT_L      = (1<<2),   // left handle selected
00618 //  NLASTRIP_FLAG_SELECT_R      = (1<<3),   // right handle selected
00619         /* NLA strip uses the same action that the action being tweaked uses (not set for the twaking one though) */
00620     NLASTRIP_FLAG_TWEAKUSER     = (1<<4),
00621     
00622     /* controls driven by local F-Curves */
00623         /* strip influence is controlled by local F-Curve */
00624     NLASTRIP_FLAG_USR_INFLUENCE = (1<<5),
00625     NLASTRIP_FLAG_USR_TIME      = (1<<6),
00626     NLASTRIP_FLAG_USR_TIME_CYCLIC = (1<<7),
00627     
00628         /* NLA strip length is synced to the length of the referenced action */
00629     NLASTRIP_FLAG_SYNC_LENGTH   = (1<<9),
00630     
00631     /* playback flags (may be overriden by F-Curves) */
00632         /* NLA strip blendin/out values are set automatically based on overlaps */
00633     NLASTRIP_FLAG_AUTO_BLENDS   = (1<<10),
00634         /* NLA strip is played back in reverse order */
00635     NLASTRIP_FLAG_REVERSE       = (1<<11),
00636         /* NLA strip is muted (i.e. doesn't contribute in any way) */
00637     NLASTRIP_FLAG_MUTED         = (1<<12),
00638         /* NLA Strip is played back in 'ping-pong' style */
00639     NLASTRIP_FLAG_MIRROR        = (1<<13),
00640     
00641     /* temporary editing flags */
00642         /* NLA-Strip is really just a temporary meta used to facilitate easier transform code */
00643     NLASTRIP_FLAG_TEMP_META     = (1<<30),
00644     NLASTRIP_FLAG_EDIT_TOUCHED  = (1<<31)
00645 } eNlaStrip_Flag;
00646 
00647 /* NLA Strip Type */
00648 typedef enum eNlaStrip_Type {   
00649         /* 'clip' - references an Action */
00650     NLASTRIP_TYPE_CLIP  = 0,
00651         /* 'transition' - blends between the adjacent strips */
00652     NLASTRIP_TYPE_TRANSITION,
00653         /* 'meta' - a strip which acts as a container for a few others */
00654     NLASTRIP_TYPE_META, 
00655     
00656         /* 'emit sound' - a strip which is used for timing when speaker emits sounds */
00657     NLASTRIP_TYPE_SOUND
00658 } eNlaStrip_Type;
00659 
00660 /* NLA Tracks ------------------------------------- */
00661 
00662 /* NLA Track (nlt)
00663  *
00664  * A track groups a bunch of 'strips', which should form a continous set of 
00665  * motion, on top of which other such groups can be layered. This should allow
00666  * for animators to work in a non-destructive manner, layering tweaks, etc. over
00667  * 'rough' blocks of their work.
00668  */
00669 typedef struct NlaTrack {
00670     struct NlaTrack *next, *prev;
00671     
00672     ListBase strips;        /* bActionStrips in this track */
00673     
00674     int flag;               /* settings for this track */
00675     int index;              /* index of the track in the stack (NOTE: not really useful, but we need a pad var anyways!) */
00676     
00677     char name[64];          /* short user-description of this track */
00678 } NlaTrack;
00679 
00680 /* settings for track */
00681 typedef enum eNlaTrack_Flag {
00682         /* track is the one that settings can be modified on, also indicates if track is being 'tweaked' */
00683     NLATRACK_ACTIVE     = (1<<0),
00684         /* track is selected in UI for relevant editing operations */
00685     NLATRACK_SELECTED   = (1<<1),
00686         /* track is not evaluated */
00687     NLATRACK_MUTED      = (1<<2),
00688         /* track is the only one evaluated (must be used in conjunction with adt->flag) */
00689     NLATRACK_SOLO       = (1<<3),
00690         /* track's settings (and strips) cannot be edited (to guard against unwanted changes) */
00691     NLATRACK_PROTECTED  = (1<<4),
00692     
00693         /* track is not allowed to execute, usually as result of tweaking being enabled (internal flag) */
00694     NLATRACK_DISABLED   = (1<<10)
00695 } eNlaTrack_Flag;
00696 
00697 
00698 /* ************************************ */
00699 /* KeyingSet Datatypes */
00700 
00701 /* Path for use in KeyingSet definitions (ksp) 
00702  *
00703  * Paths may be either specific (specifying the exact sub-ID
00704  * dynamic data-block - such as PoseChannels - to act upon, ala
00705  * Maya's 'Character Sets' and XSI's 'Marking Sets'), or they may
00706  * be generic (using various placeholder template tags that will be
00707  * replaced with appropriate information from the context). 
00708  */
00709 typedef struct KS_Path {
00710     struct KS_Path *next, *prev;
00711     
00712     ID *id;                 /* ID block that keyframes are for */
00713     char group[64];         /* name of the group to add to */
00714     
00715     int idtype;             /* ID-type that path can be used on */
00716     
00717     short groupmode;        /* group naming (eKSP_Grouping) */
00718     short pad;
00719     
00720     char *rna_path;         /* dynamically (or statically in the case of predefined sets) path */
00721     int array_index;        /* index that path affects */
00722     
00723     short flag;             /* various settings, etc. */
00724     short keyingflag;       /* settings to supply insertkey() with */
00725 } KS_Path;
00726 
00727 /* KS_Path->flag */
00728 typedef enum eKSP_Settings {
00729         /* entire array (not just the specified index) gets keyframed */
00730     KSP_FLAG_WHOLE_ARRAY    = (1<<0)
00731 } eKSP_Settings;
00732 
00733 /* KS_Path->groupmode */
00734 typedef enum eKSP_Grouping {
00735         /* path should be grouped using group name stored in path */
00736     KSP_GROUP_NAMED = 0,
00737         /* path should not be grouped at all */
00738     KSP_GROUP_NONE,
00739         /* path should be grouped using KeyingSet's name */
00740     KSP_GROUP_KSNAME,
00741         /* path should be grouped using name of inner-most context item from templates 
00742          *  - this is most useful for relative KeyingSets only
00743          */
00744     KSP_GROUP_TEMPLATE_ITEM
00745 } eKSP_Grouping;
00746 
00747 /* ---------------- */
00748  
00749 /* KeyingSet definition (ks)
00750  *
00751  * A KeyingSet defines a group of properties that should
00752  * be keyframed together, providing a convenient way for animators
00753  * to insert keyframes without resorting to Auto-Keyframing.
00754  *
00755  * A few 'generic' (non-absolute and dependant on templates) KeyingSets 
00756  * are defined 'built-in' to facilitate easy animating for the casual
00757  * animator without the need to add extra steps to the rigging process.
00758  */
00759 typedef struct KeyingSet {
00760     struct KeyingSet *next, *prev;
00761     
00762     ListBase paths;         /* (KS_Path) paths to keyframe to */
00763     
00764     char name[64];          /* user-viewable name for KeyingSet (for menus, etc.) */
00765     char typeinfo[64];      /* name of the typeinfo data used for the relative paths */
00766     
00767     short flag;             /* settings for KeyingSet */
00768     short keyingflag;       /* settings to supply insertkey() with */
00769     
00770     int active_path;        /* index of the active path */
00771 } KeyingSet;
00772 
00773 /* KeyingSet settings */
00774 typedef enum eKS_Settings {
00775         /* keyingset cannot be removed (and doesn't need to be freed) */
00776     KEYINGSET_BUILTIN       = (1<<0),
00777         /* keyingset does not depend on context info (i.e. paths are absolute) */
00778     KEYINGSET_ABSOLUTE      = (1<<1)
00779 } eKS_Settings;
00780 
00781 /* Flags for use by keyframe creation/deletion calls */
00782 typedef enum eInsertKeyFlags {
00783     INSERTKEY_NEEDED    = (1<<0),   /* only insert keyframes where they're needed */
00784     INSERTKEY_MATRIX    = (1<<1),   /* insert 'visual' keyframes where possible/needed */
00785     INSERTKEY_FAST      = (1<<2),   /* don't recalculate handles,etc. after adding key */
00786     INSERTKEY_FASTR     = (1<<3),   /* don't realloc mem (or increase count, as array has already been set out) */
00787     INSERTKEY_REPLACE   = (1<<4),   /* only replace an existing keyframe (this overrides INSERTKEY_NEEDED) */
00788     INSERTKEY_XYZ2RGB   = (1<<5)    /* transform F-Curves should have XYZ->RGB color mode */
00789 } eInsertKeyFlags;
00790 
00791 /* ************************************************ */
00792 /* Animation Data */
00793 
00794 /* AnimOverride ------------------------------------- */
00795 
00796 /* Animation Override (aor) 
00797  *
00798  * This is used to as temporary storage of values which have been changed by the user, but not
00799  * yet keyframed (thus, would get overwritten by the animation system before the user had a chance
00800  * to see the changes that were made). 
00801  *
00802  * It is probably not needed for overriding keyframed values in most cases, as those will only get evaluated
00803  * on frame-change now. That situation may change in future.
00804  */
00805 typedef struct AnimOverride {
00806     struct AnimOverride *next, *prev;
00807     
00808     char *rna_path;         /* RNA-path to use to resolve data-access */
00809     int array_index;        /* if applicable, the index of the RNA-array item to get */
00810     
00811     float value;            /* value to override setting with */
00812 } AnimOverride;
00813 
00814 /* AnimData ------------------------------------- */
00815 
00816 /* Animation data for some ID block (adt)
00817  * 
00818  * This block of data is used to provide all of the necessary animation data for a datablock.
00819  * Currently, this data will not be reusable, as there shouldn't be any need to do so.
00820  * 
00821  * This information should be made available for most if not all ID-blocks, which should 
00822  * enable all of its settings to be animatable locally. Animation from 'higher-up' ID-AnimData
00823  * blocks may override local settings.
00824  *
00825  * This datablock should be placed immediately after the ID block where it is used, so that
00826  * the code which retrieves this data can do so in an easier manner. See blenkernel/intern/anim_sys.c for details.
00827  */
00828 typedef struct AnimData {   
00829         /* active action - acts as the 'tweaking track' for the NLA */
00830     bAction     *action;    
00831         /* temp-storage for the 'real' active action (i.e. the one used before the tweaking-action 
00832          * took over to be edited in the Animation Editors) 
00833          */
00834     bAction     *tmpact;
00835         /* remapping-info for active action - should only be used if needed 
00836          * (for 'foreign' actions that aren't working correctly) 
00837          */
00838     AnimMapper  *remap;         
00839     
00840         /* nla-tracks */
00841     ListBase    nla_tracks;
00842         /* active NLA-strip (only set/used during tweaking, so no need to worry about dangling pointers) */
00843     NlaStrip    *actstrip;
00844     
00845     /* 'drivers' for this ID-block's settings - FCurves, but are completely 
00846      * separate from those for animation data 
00847      */
00848     ListBase    drivers;    /* standard user-created Drivers/Expressions (used as part of a rig) */
00849     ListBase    overrides;  /* temp storage (AnimOverride) of values for settings that are animated (but the value hasn't been keyframed) */
00850     
00851         /* settings for animation evaluation */
00852     int flag;               /* user-defined settings */
00853     int recalc;             /* depsgraph recalculation flags */ 
00854     
00855         /* settings for active action evaluation (based on NLA strip settings) */
00856     short act_blendmode;    /* accumulation mode for active action */
00857     short act_extendmode;   /* extrapolation mode for active action */
00858     float act_influence;    /* influence for active action */
00859 } AnimData;
00860 
00861 /* Animation Data settings (mostly for NLA) */
00862 typedef enum eAnimData_Flag {
00863         /* only evaluate a single track in the NLA */
00864     ADT_NLA_SOLO_TRACK      = (1<<0),
00865         /* don't use NLA */
00866     ADT_NLA_EVAL_OFF        = (1<<1),
00867         /* NLA is being 'tweaked' (i.e. in EditMode) */
00868     ADT_NLA_EDIT_ON         = (1<<2),
00869         /* active Action for 'tweaking' does not have mapping applied for editing */
00870     ADT_NLA_EDIT_NOMAP      = (1<<3),
00871         /* NLA-Strip F-Curves are expanded in UI */
00872     ADT_NLA_SKEYS_COLLAPSED = (1<<4),
00873     
00874         /* drivers expanded in UI */
00875     ADT_DRIVERS_COLLAPSED   = (1<<10),
00876         /* don't execute drivers */
00877     ADT_DRIVERS_DISABLED    = (1<<11),
00878     
00879         /* AnimData block is selected in UI */
00880     ADT_UI_SELECTED         = (1<<14),
00881         /* AnimData block is active in UI */
00882     ADT_UI_ACTIVE           = (1<<15),
00883     
00884         /* F-Curves from this AnimData block are not visible in the Graph Editor */
00885     ADT_CURVES_NOT_VISIBLE  = (1<<16)
00886 } eAnimData_Flag;
00887 
00888 /* Animation Data recalculation settings (to be set by depsgraph) */
00889 typedef enum eAnimData_Recalc {
00890     ADT_RECALC_DRIVERS      = (1<<0),
00891     ADT_RECALC_ANIM         = (1<<1),
00892     ADT_RECALC_ALL          = (ADT_RECALC_DRIVERS|ADT_RECALC_ANIM)
00893 } eAnimData_Recalc;
00894 
00895 /* Base Struct for Anim ------------------------------------- */
00896 
00897 /* Used for BKE_animdata_from_id() 
00898  * All ID-datablocks which have their own 'local' AnimData
00899  * should have the same arrangement in their structs.
00900  */
00901 typedef struct IdAdtTemplate {
00902     ID id;
00903     AnimData *adt;
00904 } IdAdtTemplate;
00905 
00906 /* ************************************************ */
00907 
00908 #ifdef __cplusplus
00909 };
00910 #endif
00911 
00912 #endif /* DNA_ANIM_TYPES_H */