Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2010-01-05 00:15:45 +0300
committerJoshua Leung <aligorith@gmail.com>2010-01-05 00:15:45 +0300
commita9861e3381f4c2ac44fcc880aa1bd030a3ba8dae (patch)
tree72f8f0d8e7f4abb1833456bbaa8b27ac82a2e829 /source/blender/makesdna/DNA_anim_types.h
parentc79cf56b69ecf3f49c220ce6dea626caa48e089b (diff)
Durian Request: Drivers Recode
Highlights: * Support for Multi-Target Variables This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that. * New Variable Types With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones). * New Driver Types In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to. * Fix for Driver F-Curve colouring bug Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used. Notes: * This commit breaks existing 2.5 files with drivers (in other words, they are lost forever). * Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later. * Version patching for 2.49 files still needs to be put back in place.
Diffstat (limited to 'source/blender/makesdna/DNA_anim_types.h')
-rw-r--r--source/blender/makesdna/DNA_anim_types.h80
1 files changed, 64 insertions, 16 deletions
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index dcb10d0f2cf..f2d4471607f 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -232,26 +232,72 @@ typedef enum eFMod_Noise_Modifications {
/* Drivers -------------------------------------- */
-/* Driver Target
+/* Driver Target (dtar)
*
- * A 'variable' for use as a target of the driver/expression.
+ * Defines how to access a dependency needed for a driver variable.
+ */
+typedef struct DriverTarget {
+ ID *id; /* ID-block which owns the target */
+
+ char *rna_path; /* target channel to use as driver value */
+ char pchan_name[32]; /* name of the posebone to use (for certain types of variable only) */
+
+ int idtype; /* type of ID-block that this target can use */
+ int flag; /* flags for the validity of the target (NOTE: these get reset everytime the types change) */
+} DriverTarget;
+
+/* Driver Target flags */
+typedef enum eDriverTarget_Flag {
+ /* used for targets that use the pchan_name instead of RNA path
+ * (i.e. rotation difference)
+ */
+ DTAR_FLAG_STRUCT_REF = (1<<0),
+ /* idtype can only be 'Object' */
+ DTAR_FLAG_ID_OB_ONLY = (1<<1),
+} eDriverTarget_Flag;
+
+/* --- */
+
+/* maximum number of driver targets per variable */
+// FIXME: make this get used below (for DriverVariable defines) if DNA supports preprocessor stuff..
+#define MAX_DRIVER_TARGETS 8
+
+
+/* Driver Variable (dvar)
+ *
+ * A 'variable' for use as an input for the driver evaluation.
* Defines a way of accessing some channel to use, that can be
* referred to in the expression as a variable, thus simplifying
* expressions and also Depsgraph building.
*/
-typedef struct DriverTarget {
- struct DriverTarget *next, *prev;
+typedef struct DriverVar {
+ struct DriverVar *next, *prev;
- ID *id; /* ID-block which owns the target */
- char *rna_path; /* target channel to use as driver value */
- int array_index; /* if applicable, the index of the RNA-array item to use as driver */
+ char name[64]; /* name of the variable to use in py-expression (must be valid python identifier) */
- int idtype; /* type of ID-block that this target can use */
- int flags; /* flags for the validity of the target */
- int pad;
+ DriverTarget targets[8]; /* MAX_DRIVER_TARGETS - targets available for use for this type of variable */
+ int num_targets; /* number of targets used by this variable */
- char name[64]; /* name of the variable */
-} DriverTarget;
+ int type; /* type of driver target (eDriverTarget_Types) */
+} DriverVar;
+
+/* Driver Variable Types */
+typedef enum eDriverVar_Types {
+ /* single RNA property */
+ DVAR_TYPE_SINGLE_PROP = 0,
+ /* rotation difference (between 2 bones) */
+ DVAR_TYPE_ROT_DIFF,
+ /* distance between objects/bones */
+ DVAR_TYPE_LOC_DIFF,
+
+ /* maximum number of variable types
+ * NOTE: this must always be th last item in this list,
+ * so add new types above this line
+ */
+ MAX_DVAR_TYPES
+} eDriverVar_Types;
+
+/* --- */
/* Channel Driver (i.e. Drivers / Expressions) (driver)
*
@@ -265,7 +311,7 @@ typedef struct DriverTarget {
* evaluated in. This order is set by the Depsgraph's sorting stuff.
*/
typedef struct ChannelDriver {
- ListBase targets; /* targets for this driver (i.e. list of DriverTarget) */
+ ListBase variables; /* targets for this driver (i.e. list of DriverVar) */
/* python expression to execute (may call functions defined in an accessory file)
* which relates the target 'variables' in some way to yield a single usable value
@@ -287,10 +333,12 @@ typedef enum eDriver_Types {
DRIVER_TYPE_AVERAGE = 0,
/* python expression/function relates targets */
DRIVER_TYPE_PYTHON,
- /* rotational difference (must use rotation channels only) */
- DRIVER_TYPE_ROTDIFF,
/* sum of all values */
DRIVER_TYPE_SUM,
+ /* smallest value */
+ DRIVER_TYPE_MIN,
+ /* largest value */
+ DRIVER_TYPE_MAX,
} eDriver_Types;
/* driver flags */
@@ -301,7 +349,7 @@ typedef enum eDriver_Flags {
DRIVER_FLAG_RECALC = (1<<1),
/* driver does replace value, but overrides (for layering of animation over driver) */
// TODO: this needs to be implemented at some stage or left out...
- DRIVER_FLAG_LAYERING = (1<<2),
+ //DRIVER_FLAG_LAYERING = (1<<2),
/* use when the expression needs to be recompiled */
DRIVER_FLAG_RECOMPILE = (1<<3),
} eDriver_Flags;