[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59757] trunk/blender/source/blender: Tweaks to New Driver creation behaviour

Daniel Salazar - 3Developer.com zanqdo at gmail.com
Tue Sep 3 02:48:59 CEST 2013


Oh and this is actually made worse by a bug(?) that has been always
present in blender 2.5+ that makes it impossible to delete the
keyframes without deleting the actual driver. Would be nice if this
gets fixed at least I can delete all the curves.

kind regards
Daniel Salazar
patazstudio.com


On Mon, Sep 2, 2013 at 6:37 PM, Daniel Salazar - 3Developer.com
<zanqdo at gmail.com> wrote:
> Humn, I really wish drivers didn't create anything. The vast majority
> of drivers do not use mapping other than 1-1 (in my experience). I'd
> prefer an easy way to add 1-1 curve when the user wants to instead of
> doing stuff the user never asked for!
>
> cheers
> Daniel Salazar
> patazstudio.com
>
>
> On Mon, Sep 2, 2013 at 6:28 PM, Joshua Leung <aligorith at gmail.com> wrote:
>> Revision: 59757
>>           http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59757
>> Author:   aligorith
>> Date:     2013-09-03 00:28:23 +0000 (Tue, 03 Sep 2013)
>> Log Message:
>> -----------
>> Tweaks to New Driver creation behaviour
>>
>> * 'Show Debug' now enabled for all newly created drivers. For most users, it is
>> useful to be able to see this to help figure out what's going on
>>
>> * Removed failed experiment of creating new drivers with Generator FModifiers. I
>> had hoped that this would make it easier to create drivers that doubled or
>> halved the input values, but that has proved to not be the case, and instead
>> made harder for most users to set things up (as they'd have to remove these
>> first).
>>
>> Now, when adding drivers from the UI, these get created with two keyframes (at
>> (0,0) and (1,1) for a 1-1 mapping), which can be easily tweaked normally.
>>
>> However, for backwards compatability of scripts (notably rigify, and perhaps
>> some others out there), when creating drivers from scripts, they will still get
>> created with Generator FModifiers for now. We can review this situation again
>> for 2.7, but for now it seems ok.
>>
>> Modified Paths:
>> --------------
>>     trunk/blender/source/blender/editors/animation/drivers.c
>>     trunk/blender/source/blender/editors/animation/keyframing.c
>>     trunk/blender/source/blender/editors/include/ED_keyframing.h
>>     trunk/blender/source/blender/python/intern/bpy_rna_anim.c
>>
>> Modified: trunk/blender/source/blender/editors/animation/drivers.c
>> ===================================================================
>> --- trunk/blender/source/blender/editors/animation/drivers.c    2013-09-02 23:32:21 UTC (rev 59756)
>> +++ trunk/blender/source/blender/editors/animation/drivers.c    2013-09-03 00:28:23 UTC (rev 59757)
>> @@ -75,7 +75,8 @@
>>   * for the given Animation Data block. This assumes that all the destinations are valid.
>>   *
>>   *     - add:  0 - don't add anything if not found,
>> - *                     1 - add new Driver FCurve,
>> + *                     1 - add new Driver FCurve (with keyframes for visual tweaking),
>> + *                     2 - add new Driver FCurve (with generator, for script backwards compatability)
>>   *                     -1 - add new Driver FCurve without driver stuff (for pasting)
>>   */
>>  FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_index, short add)
>> @@ -114,11 +115,38 @@
>>
>>                 /* if add is negative, don't init this data yet, since it will be filled in by the pasted driver */
>>                 if (add > 0) {
>> +                       BezTriple *bezt;
>> +                       size_t i;
>> +
>>                         /* add some new driver data */
>>                         fcu->driver = MEM_callocN(sizeof(ChannelDriver), "ChannelDriver");
>> +                       fcu->driver->flag |= DRIVER_FLAG_SHOWDEBUG;
>>
>> -                       /* add simple generator modifier for driver so that there is some visible representation */
>> -                       add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR);
>> +                       /* F-Modifier or Keyframes? */
>> +                       // FIXME: replace these magic numbers with defines
>> +                       if (add == 2) {
>> +                               /* Python API Backwards compatability hack:
>> +                                * Create FModifier so that old scripts won't break
>> +                                * for now before 2.7 series -- (September 4, 2013)
>> +                                */
>> +                               add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR);
>> +                       }
>> +                       else {
>> +                               /* add 2 keyframes so that user has something to work with
>> +                                * - These are configured to 0,0 and 1,1 to give a 1-1 mapping
>> +                                *   which can be easily tweaked from there.
>> +                                */
>> +                               insert_vert_fcurve(fcu, 0.0f, 0.0f, INSERTKEY_FAST);
>> +                               insert_vert_fcurve(fcu, 1.0f, 1.0f, INSERTKEY_FAST);
>> +
>> +                               /* configure this curve to extrapolate */
>> +                               for (i = 0, bezt = fcu->bezt;  (i < fcu->totvert) && bezt;  i++, bezt++) {
>> +                                       bezt->h1 = bezt->h2 = HD_VECT;
>> +                               }
>> +
>> +                               fcu->extend = FCURVE_EXTRAPOLATE_LINEAR;
>> +                               calchandles_fcurve(fcu);
>> +                       }
>>                 }
>>
>>                 /* just add F-Curve to end of driver list */
>> @@ -166,8 +194,10 @@
>>
>>         /* will only loop once unless the array index was -1 */
>>         for (; array_index < array_index_max; array_index++) {
>> +               short add_mode = (flag & CREATEDRIVER_WITH_FMODIFIER) ? 2 : 1;
>> +
>>                 /* create F-Curve with Driver */
>> -               fcu = verify_driver_fcurve(id, rna_path, array_index, 1);
>> +               fcu = verify_driver_fcurve(id, rna_path, array_index, add_mode);
>>
>>                 if (fcu && fcu->driver) {
>>                         ChannelDriver *driver = fcu->driver;
>>
>> Modified: trunk/blender/source/blender/editors/animation/keyframing.c
>> ===================================================================
>> --- trunk/blender/source/blender/editors/animation/keyframing.c 2013-09-02 23:32:21 UTC (rev 59756)
>> +++ trunk/blender/source/blender/editors/animation/keyframing.c 2013-09-03 00:28:23 UTC (rev 59757)
>> @@ -256,7 +256,7 @@
>>                                 dst->f1 = bezt->f1;
>>                                 dst->f2 = bezt->f2;
>>                                 dst->f3 = bezt->f3;
>> -
>> +
>>                                 /* TODO: perform some other operations? */
>>                         }
>>                 }
>>
>> Modified: trunk/blender/source/blender/editors/include/ED_keyframing.h
>> ===================================================================
>> --- trunk/blender/source/blender/editors/include/ED_keyframing.h        2013-09-02 23:32:21 UTC (rev 59756)
>> +++ trunk/blender/source/blender/editors/include/ED_keyframing.h        2013-09-03 00:28:23 UTC (rev 59757)
>> @@ -222,6 +222,7 @@
>>  /* Flags for use by driver creation calls */
>>  typedef enum eCreateDriverFlags {
>>         CREATEDRIVER_WITH_DEFAULT_DVAR  = (1 << 0),   /* create drivers with a default variable for nicer UI */
>> +       CREATEDRIVER_WITH_FMODIFIER     = (1 << 1),   /* create drivers with Generator FModifier (for backwards compat) */
>>  } eCreateDriverFlags;
>>
>>  /* -------- */
>>
>> Modified: trunk/blender/source/blender/python/intern/bpy_rna_anim.c
>> ===================================================================
>> --- trunk/blender/source/blender/python/intern/bpy_rna_anim.c   2013-09-02 23:32:21 UTC (rev 59756)
>> +++ trunk/blender/source/blender/python/intern/bpy_rna_anim.c   2013-09-03 00:28:23 UTC (rev 59757)
>> @@ -312,7 +312,8 @@
>>
>>                 BKE_reports_init(&reports, RPT_STORE);
>>
>> -               result = ANIM_add_driver(&reports, (ID *)self->ptr.id.data, path_full, index, 0, DRIVER_TYPE_PYTHON);
>> +               result = ANIM_add_driver(&reports, (ID *)self->ptr.id.data, path_full, index,
>> +                                        CREATEDRIVER_WITH_FMODIFIER, DRIVER_TYPE_PYTHON);
>>
>>                 if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
>>                         return NULL;
>>
>> _______________________________________________
>> Bf-blender-cvs mailing list
>> Bf-blender-cvs at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-blender-cvs


More information about the Bf-committers mailing list