diff options
author | Joshua Leung <aligorith@gmail.com> | 2016-03-26 07:55:42 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2016-03-26 08:02:02 +0300 |
commit | 0512e20ae9939f4a688f4f485acdf246dc4d7682 (patch) | |
tree | 083a670c45518c9182b7db151f4800000246b98c /source/blender/editors/include | |
parent | ee9898e0fafaa7953561817eb064655b857ab5b6 (diff) |
Driver Setup Workflow Improvement: Property Eyedropper
This commit brings some long requested improvements to the workflow for setting up
drivers, which should make it easier and faster to set up new drivers in a more
interactive fashion.
The new workflow is as follows:
1) Hover over the property (e.g. "Lamp Energy" or "Y Location") or properties ("Rotation")
you wish to add drivers to. We'll refer to this as the "destination"
2) Ctrl-D to active the new "Add Drivers" eyedropper
3) Click on the property you want to use as the source/target. The property under the
mouse will be used to drive the property you invoked Ctrl-D on.
For example, to drive the X, Y, and Z location of the Cube using the Y Location of the Lamp,
hover over any of the X/Y/Z location buttons, hit Ctrl-D, then click on the Y-Location
button of the Lamp object. Drivers will be added to the X, Y, and Z Location properties
of the Cube; each driver will have a single variable, which uses the Y-Location Transform
Channel of the Lamp.
Tips:
- Transform properties will automatically create "Transform Channel" driver variables.
Everything else will use "Single Property" ones
- Due to the way that Blender's UI Context works, you'll need two Properties Panel instances
open (and to have pinned one of the two to show the properties for the unselected
object). It's slightly clunky, but necessary for implementing a workflow like this,
as the UI cannot be manipulated while using eyedroppers to pick data.
- The eyedropper operator implemented here actually has three modes of operation.
1) The "1-N" (one to many) mode is the default used for Ctrl-D, and "Add Driver to All"
in the RMB Menu. This is the behaviour described above.
2) There's also a "1-1" (one to one) mode that is used for the "Add Single Driver" in the
RMB Menu.
3) Finally, there's the "N-N" mode (many to many), which isn't currently exposed.
The point of this is to allow mapping XYZ to XYZ elementwise (i.e. direct copying)
which is useful for things like locations, rotations, scaling, and colours.
Implementation Notes:
- The bulk of the driver adding logic is in editors/animation/drivers.c, where most of
the Driver UI operators and tools are defined
- The property eyedropper code is in interface_eyedropper.c along with all the other
eyedroppers (even though they don't share much actual code in common). However, this
turns out to be necessary, as we can't get access to many of the low-level buttons API's
otherwise.
Todo:
- It may be necessary to restore a way to access the old behaviour (i.e. "manual setup")
in case it is not practical to immediately pick a property.
- Other things to investigate here include extra hotkeys (e.g. Ctrl-Shift-D for Add Single?),
and to expose the N-N mode.
- Other things we could try include interactively applying scaling factors, picking
multiple targets (e.g. for location difference and rotation difference drivers),
and/or other ways of using these property picking methods.
Diffstat (limited to 'source/blender/editors/include')
-rw-r--r-- | source/blender/editors/include/ED_keyframing.h | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 02b22bdbf42..eb21a431702 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -235,6 +235,16 @@ typedef enum eCreateDriverFlags { CREATEDRIVER_WITH_FMODIFIER = (1 << 1), /* create drivers with Generator FModifier (for backwards compat) */ } eCreateDriverFlags; +/* Heuristic to use for connecting target properties to driven ones */ +typedef enum eCreateDriver_MappingTypes { + CREATEDRIVER_MAPPING_1_N = 0, /* 1 to Many - Use the specified index, and drive all elements with it */ + CREATEDRIVER_MAPPING_1_1 = 1, /* 1 to 1 - Only for the specified index on each side */ + CREATEDRIVER_MAPPING_N_N = 2, /* Many to Many - Match up the indices one by one (only for drivers on vectors/arrays) */ +} eCreateDriver_MappingTypes; + +/* RNA Enum of eCreateDriver_MappingTypes, for use by the appropriate operators */ +extern EnumPropertyItem prop_driver_create_mapping_types[]; + /* -------- */ /* Low-level call to add a new driver F-Curve. This shouldn't be used directly for most tools, @@ -244,8 +254,24 @@ struct FCurve *verify_driver_fcurve(struct ID *id, const char rna_path[], const /* -------- */ -/* Returns whether there is a driver in the copy/paste buffer to paste */ -bool ANIM_driver_can_paste(void); +/* Main Driver Management API calls: + * Add a new driver for the specified property on the given ID block, + * and make it be driven by the specified target. + * + * This is intended to be used in conjunction with a modal "eyedropper" + * for picking the variable that is going to be used to drive this one. + * + * - flag: eCreateDriverFlags + * - driver_type: eDriver_Types + * - mapping_type: eCreateDriver_MappingTypes + */ +int ANIM_add_driver_with_target( + struct ReportList *reports, + struct ID *dst_id, const char dst_path[], int dst_index, + struct ID *src_id, const char src_path[], int src_index, + short flag, int driver_type, short mapping_type); + +/* -------- */ /* Main Driver Management API calls: * Add a new driver for the specified property on the given ID block @@ -257,6 +283,11 @@ int ANIM_add_driver(struct ReportList *reports, struct ID *id, const char rna_pa */ bool ANIM_remove_driver(struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag); +/* -------- */ + +/* Returns whether there is a driver in the copy/paste buffer to paste */ +bool ANIM_driver_can_paste(void); + /* Main Driver Management API calls: * Make a copy of the driver for the specified property on the given ID block */ |