From 47335b4e61db11e1ee2e38f421dc86fa3c3dd375 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Wed, 31 Jul 2019 18:42:03 +0300 Subject: Add a new Copy As Driver context menu option for properties. It is a very common need to create drivers that set the value of a property to the value of some other property, but it currently requires multiple actions: Copy Data Path on the input property, adding a driver to the output property, selecting the input ID reference, and pasting the path. This adds a new Copy As Driver context menu option, which creates a complete driver in the clipboard that reads the current property, so all that remains is to paste it to the output property. It is also possible to paste just the new driver variable into an existing driver to combine multiple inputs. Reviewers: brecht, billreynish Differential Revision: https://developer.blender.org/D5382 --- source/blender/editors/animation/drivers.c | 136 ++++++++++++++++++++--------- 1 file changed, 94 insertions(+), 42 deletions(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 7ca0f95d6c4..935d11a388f 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -23,6 +23,7 @@ #include #include +#include #include "MEM_guardedalloc.h" @@ -95,56 +96,65 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde if ((fcu == NULL) && (add)) { /* use default settings to make a F-Curve */ - fcu = MEM_callocN(sizeof(FCurve), "FCurve"); + fcu = alloc_driver_fcurve(rna_path, array_index, add); - fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED); - fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL; + /* just add F-Curve to end of driver list */ + BLI_addtail(&adt->drivers, fcu); + } - /* store path - make copy, and store that */ - fcu->rna_path = BLI_strdup(rna_path); - fcu->array_index = array_index; - - /* 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"); - - /* F-Modifier or Keyframes? */ - // FIXME: replace these magic numbers with defines - if (add == 2) { - /* Python API Backwards compatibility 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, fcu); - } - 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, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST); - insert_vert_fcurve(fcu, 1.0f, 1.0f, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST); + /* return the F-Curve */ + return fcu; +} - /* configure this curve to extrapolate */ - for (i = 0, bezt = fcu->bezt; (i < fcu->totvert) && bezt; i++, bezt++) { - bezt->h1 = bezt->h2 = HD_VECT; - } +struct FCurve *alloc_driver_fcurve(const char rna_path[], const int array_index, short add) +{ + FCurve *fcu = MEM_callocN(sizeof(FCurve), "FCurve"); - fcu->extend = FCURVE_EXTRAPOLATE_LINEAR; - calchandles_fcurve(fcu); - } + fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED); + fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL; + + /* store path - make copy, and store that */ + if (rna_path) { + fcu->rna_path = BLI_strdup(rna_path); + } + fcu->array_index = array_index; + + /* 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"); + + /* F-Modifier or Keyframes? */ + // FIXME: replace these magic numbers with defines + if (add == 2) { + /* Python API Backwards compatibility 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, fcu); } + 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, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST); + insert_vert_fcurve(fcu, 1.0f, 1.0f, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST); - /* just add F-Curve to end of driver list */ - BLI_addtail(&adt->drivers, fcu); + /* 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); + } } - /* return the F-Curve */ return fcu; } @@ -834,6 +844,48 @@ bool ANIM_driver_vars_paste(ReportList *reports, FCurve *fcu, bool replace) return true; } +/* -------------------------------------------------- */ + +/* Create a driver & variable that reads the specified property, + * and store it in the buffers for Paste Driver and Paste Variables. */ +void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const char *var_name) +{ + /* Clear copy/paste buffer first (for consistency with other copy/paste buffers). */ + ANIM_drivers_copybuf_free(); + ANIM_driver_vars_copybuf_free(); + + /* Create a dummy driver F-Curve. */ + FCurve *fcu = alloc_driver_fcurve(NULL, 0, 1); + ChannelDriver *driver = fcu->driver; + + /* Create a variable. */ + DriverVar *var = driver_add_new_variable(driver); + DriverTarget *target = &var->targets[0]; + + target->idtype = GS(target_id->name); + target->id = target_id; + target->rna_path = MEM_dupallocN(target_path); + + /* Set the variable name. */ + if (var_name) { + BLI_strncpy(var->name, var_name, sizeof(var->name)); + + /* Sanitize the name. */ + for (int i = 0; var->name[i]; i++) { + if (!(i > 0 ? isalnum(var->name[i]) : isalpha(var->name[i]))) { + var->name[i] = '_'; + } + } + } + + BLI_strncpy(driver->expression, var->name, sizeof(driver->expression)); + + /* Store the driver into the copy/paste buffers. */ + channeldriver_copypaste_buf = fcu; + + driver_variables_copy(&driver_vars_copybuf, &driver->variables); +} + /* ************************************************** */ /* UI-Button Interface */ -- cgit v1.2.3 From b4a325f535e56e37f1a22c12f189b39552fd6ba7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 6 Aug 2019 04:20:17 +1000 Subject: Cleanup: use unsigned char for theme colors Nearly all byte-color functions use 'uchar' causing casts when then colors were passed in. Declare as uchar to remove the need for casts. --- source/blender/editors/animation/anim_channels_defines.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 3d7178a4114..1649744ba8d 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -206,16 +206,16 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa * - only use group colors if allowed to, and if actually feasible */ if (showGroupColors && (grp) && (grp->customCol)) { - unsigned char cp[3]; + uchar cp[3]; if (indent == 2) { - copy_v3_v3_char((char *)cp, grp->cs.solid); + copy_v3_v3_uchar(cp, grp->cs.solid); } else if (indent == 1) { - copy_v3_v3_char((char *)cp, grp->cs.select); + copy_v3_v3_uchar(cp, grp->cs.select); } else { - copy_v3_v3_char((char *)cp, grp->cs.active); + copy_v3_v3_uchar(cp, grp->cs.active); } /* copy the colors over, transforming from bytes to floats */ @@ -850,10 +850,10 @@ static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[ /* highlight only for active */ if (ale->flag & AGRP_ACTIVE) { - copy_v3_v3_char((char *)cp, agrp->cs.select); + copy_v3_v3_uchar(cp, agrp->cs.select); } else { - copy_v3_v3_char((char *)cp, agrp->cs.solid); + copy_v3_v3_uchar(cp, agrp->cs.solid); } /* copy the colors over, transforming from bytes to floats */ -- cgit v1.2.3 From c9acc5faad08422e07be59fc160a028a45b7440c Mon Sep 17 00:00:00 2001 From: Antonioya Date: Wed, 14 Aug 2019 10:29:21 +0200 Subject: Fix T68597: GPencil Dope Sheet can fail to display active GP object Now, the dopesheet is activated if the object is in any Edition mode. --- source/blender/editors/animation/anim_filter.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 625a52fc800..a78a63f1347 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1829,13 +1829,13 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, } } - /* check selection and object type filters */ - if ((ads->filterflag & ADS_FILTER_ONLYSEL) && - !((base->flag & BASE_SELECTED) /*|| (base == scene->basact)*/)) { - /* only selected should be shown */ - continue; + /* check selection and object type filters only for Object mode */ + if (ob->mode == OB_MODE_OBJECT) { + if ((ads->filterflag & ADS_FILTER_ONLYSEL) && !((base->flag & BASE_SELECTED))) { + /* only selected should be shown */ + continue; + } } - /* check if object belongs to the filtering group if option to filter * objects by the grouped status is on * - used to ease the process of doing multiple-character choreographies -- cgit v1.2.3 From 0dcd442c1f23e0210363cb6c2ec0c2a6e39c35af Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 14 Aug 2019 16:12:16 +0200 Subject: Fix T68487: double free when inserting keyframe outside of action clip range --- source/blender/editors/animation/keyframing.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index de6e4c2fd0d..dcc596e67e1 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1484,10 +1484,10 @@ short insert_keyframe(Main *bmain, flag); } } - } - if (values != value_buffer) { - MEM_freeN(values); + if (values != value_buffer) { + MEM_freeN(values); + } } BKE_animsys_free_nla_keyframing_context_cache(&tmp_nla_cache); -- cgit v1.2.3 From 27907408136cd3339beac5ea98318830ff837ab6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 17 Aug 2019 00:54:22 +1000 Subject: Cleanup: spelling --- source/blender/editors/animation/anim_motion_paths.c | 5 ++--- source/blender/editors/animation/keyingsets.c | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c index 7a5b57b1ce6..bd4886817cd 100644 --- a/source/blender/editors/animation/anim_motion_paths.c +++ b/source/blender/editors/animation/anim_motion_paths.c @@ -60,9 +60,8 @@ typedef struct MPathTarget { Object *ob; /* source object */ bPoseChannel *pchan; /* source posechannel (if applicable) */ - /* "Evaluated" Copies (these come from the background COW copie - * that provide all the coordinates we want to save off) - */ + /* "Evaluated" Copies (these come from the background COW copy + * that provide all the coordinates we want to save off). */ Object *ob_eval; /* evaluated object */ } MPathTarget; diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index ccd0fc54611..7d31c6d3e3a 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -712,9 +712,9 @@ int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks) } } - /* still here, so try builtins list too - * - builtins are from (<= -1) - * - none/invalid is (= 0) + /* Still here, so try built-ins list too: + * - Built-ins are from (<= -1). + * - None/Invalid is (= 0). */ index = BLI_findindex(&builtin_keyingsets, ks); if (index != -1) { -- cgit v1.2.3 From b1959a96a2b54e9a425147f4ce3c3806c43c7188 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Aug 2019 04:11:50 +1000 Subject: Cleanup: spelling --- source/blender/editors/animation/drivers.c | 2 +- source/blender/editors/animation/keyframing.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 935d11a388f..e341a16378c 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -218,7 +218,7 @@ static int add_driver_with_target(ReportList *UNUSED(reports), /* Create a driver variable for the target * - For transform properties, we want to automatically use "transform channel" instead - * (The only issue is with quat rotations vs euler channels...) + * (The only issue is with quaternion rotations vs euler channels...) * - To avoid problems with transform properties depending on the final transform that they * control (thus creating pseudo-cycles - see T48734), we don't use transform channels * when both the source and destinations are in same places. diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index dcc596e67e1..7fd2338dbf3 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1544,9 +1544,9 @@ static bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra) static void deg_tag_after_keyframe_delete(Main *bmain, ID *id, AnimData *adt) { if (adt->action == NULL) { - /* In the case last f-curve wes removed need to inform dependency graph + /* In the case last f-curve was removed need to inform dependency graph * about relations update, since it needs to get rid of animation operation - * for this datablock. */ + * for this data-block. */ DEG_id_tag_update_ex(bmain, id, ID_RECALC_ANIMATION_NO_FLUSH); DEG_relations_tag_update(bmain); } -- cgit v1.2.3 From 2ba233a31fead52820763fb6637dcae20eeed574 Mon Sep 17 00:00:00 2001 From: Charlie Jolly Date: Thu, 22 Aug 2019 11:10:11 +0200 Subject: Nodes: Support for socket shapes other than circle Previously there was already "draw_shape" property, but it was doing nothing. This commit renames the property to "display_shape". Furthermore, different shapes like SQUARE and DIAMOND are supported now. Currently, the shapes are drawn using the shader that also draws keyframes. In the future we might want to separate this. The new shapes are not used anywhere yet, but they can be used by addon developers and will probably be useful when we want to support different kinds node systems later. For example, different shapes can be used to distinguish between data and control flow. Differential Revision: https://developer.blender.org/D2829 --- source/blender/editors/animation/keyframes_draw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 889d27480df..ca7e0eae136 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -814,8 +814,10 @@ static void draw_keylist(View2D *v2d, uint outline_color_id = GPU_vertformat_attr_add( format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); uint flags_id = GPU_vertformat_attr_add(format, "flags", GPU_COMP_U32, 1, GPU_FETCH_INT); - immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); + GPU_program_point_size(true); + immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); + immUniform1f("outline_scale", 1.0f); immUniform2f( "ViewportSize", BLI_rcti_size_x(&v2d->mask) + 1, BLI_rcti_size_y(&v2d->mask) + 1); immBegin(GPU_PRIM_POINTS, key_len); -- cgit v1.2.3 From 8f578150eaf494a03bed7389046e44f2bdf7d748 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Thu, 22 Aug 2019 15:40:10 +0300 Subject: Fix T68971: Copy As New Driver from Material node creates a bad reference. NodeTree structures of materials and some other data blocks are effectively node group data block objects that are contained inside the parent block. Thus, direct references to them are only valid while blender is running, and are lost on save. Fix Copy As New Driver to create a reference that goes through the owner data block, by adding a new runtime field to bNodeTree. --- source/blender/editors/animation/drivers.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index e341a16378c..bf2056a7ec6 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -846,6 +846,36 @@ bool ANIM_driver_vars_paste(ReportList *reports, FCurve *fcu, bool replace) /* -------------------------------------------------- */ +/** Compute an ID pointer and path to property valid for use in a driver. + * Corrects for ID references that are not independent (e.g. material NodeTree). */ +bool ANIM_get_target_ID_and_path_to_property( + PointerRNA *ptr, PropertyRNA *prop, int index, ID **r_id, char **r_path) +{ + int dim = RNA_property_array_dimension(ptr, prop, NULL); + char *path = RNA_path_from_ID_to_property_index(ptr, prop, dim, index); + ID *id = ptr->id.data; + + if (!path) { + return false; + } + + if (GS(id->name) == ID_NT) { + bNodeTree *node_tree = (bNodeTree *)id; + + if (node_tree->owner) { + id = node_tree->owner; + + char *new_path = BLI_sprintfN("node_tree%s%s", path[0] == '[' ? "" : ".", path); + MEM_freeN(path); + path = new_path; + } + } + + *r_id = id; + *r_path = path; + return true; +} + /* Create a driver & variable that reads the specified property, * and store it in the buffers for Paste Driver and Paste Variables. */ void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const char *var_name) -- cgit v1.2.3 From e6f3d8b3e1158ebdc89ceae1de5ce7bc5c420f51 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 22 Aug 2019 16:00:59 +0200 Subject: Revert "Fix T68971: Copy As New Driver from Material node creates a bad reference." This reverts commits 54fd8176d7e91, 4c5becb6b1 and 8f578150e. Those kind of commits must be reviewed and approved by project owners. That one: * Broke Collada building by not properly updating all calls to modified function. * Broke *whole* ID management by not properly updating library_query.c. And in general, I am strongly against backward ID pointers, those are *always* a serious PITA for ID management. Sometimes they cannot be avoided, but in general other ways to get that kind of info should be investigated first. --- source/blender/editors/animation/drivers.c | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index bf2056a7ec6..e341a16378c 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -846,36 +846,6 @@ bool ANIM_driver_vars_paste(ReportList *reports, FCurve *fcu, bool replace) /* -------------------------------------------------- */ -/** Compute an ID pointer and path to property valid for use in a driver. - * Corrects for ID references that are not independent (e.g. material NodeTree). */ -bool ANIM_get_target_ID_and_path_to_property( - PointerRNA *ptr, PropertyRNA *prop, int index, ID **r_id, char **r_path) -{ - int dim = RNA_property_array_dimension(ptr, prop, NULL); - char *path = RNA_path_from_ID_to_property_index(ptr, prop, dim, index); - ID *id = ptr->id.data; - - if (!path) { - return false; - } - - if (GS(id->name) == ID_NT) { - bNodeTree *node_tree = (bNodeTree *)id; - - if (node_tree->owner) { - id = node_tree->owner; - - char *new_path = BLI_sprintfN("node_tree%s%s", path[0] == '[' ? "" : ".", path); - MEM_freeN(path); - path = new_path; - } - } - - *r_id = id; - *r_path = path; - return true; -} - /* Create a driver & variable that reads the specified property, * and store it in the buffers for Paste Driver and Paste Variables. */ void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const char *var_name) -- cgit v1.2.3 From a1aa4a259713f26c32a5fac4adbe0751e0479f5b Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 23 Aug 2019 09:52:12 +0200 Subject: RNA: Cleanup PointerRNA struct The old layout of `PointerRNA` was confusing for historic reasons: ``` typedef struct PointerRNA { struct { void *data; } id; struct StructRNA *type; void *data; } PointerRNA; ``` This patch updates it to: ``` typedef struct PointerRNA { struct ID *owner_id; struct StructRNA *type; void *data; } PointerRNA; ``` Throughout the code base `id.data` was replaced with `owner_id`. Furthermore, many explicit pointer type casts were added which were implicit before. Some type casts to `ID *` were removed. Reviewers: brecht, campbellbarton Differential Revision: https://developer.blender.org/D5558 --- .../editors/animation/anim_channels_defines.c | 2 +- source/blender/editors/animation/anim_ipo_utils.c | 2 +- source/blender/editors/animation/drivers.c | 48 +++++++++++----------- source/blender/editors/animation/keyframing.c | 32 +++++++-------- source/blender/editors/animation/keyingsets.c | 12 +++--- 5 files changed, 49 insertions(+), 47 deletions(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 1649744ba8d..d80b96f0d74 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -4847,7 +4847,7 @@ void ANIM_channel_draw_widgets(const bContext *C, /* step 4) draw text - check if renaming widget is in use... */ if (is_being_renamed) { - PointerRNA ptr = {{NULL}}; + PointerRNA ptr = {NULL}; PropertyRNA *prop = NULL; /* draw renaming widget if we can get RNA pointer for it diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index fad9a1a8e49..5b729c856c0 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -122,7 +122,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) MEM_freeN(constName); } } - else if (ptr.data != ptr.id.data) { + else if (ptr.data != ptr.owner_id) { PropertyRNA *nameprop = RNA_struct_name_property(ptr.type); if (nameprop) { /* this gets a string which will need to be freed */ diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index e341a16378c..7b9e6a10f44 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -934,7 +934,7 @@ static const EnumPropertyItem *driver_mapping_type_itemsf(bContext *C, EnumPropertyItem *input = prop_driver_create_mapping_types; EnumPropertyItem *item = NULL; - PointerRNA ptr = {{NULL}}; + PointerRNA ptr = {NULL}; PropertyRNA *prop = NULL; int index; @@ -946,7 +946,7 @@ static const EnumPropertyItem *driver_mapping_type_itemsf(bContext *C, UI_context_active_but_prop_get(C, &ptr, &prop, &index); - if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { + if (ptr.owner_id && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { const bool is_array = RNA_property_array_check(prop); while (input->identifier) { @@ -971,7 +971,7 @@ static const EnumPropertyItem *driver_mapping_type_itemsf(bContext *C, static bool add_driver_button_poll(bContext *C) { - PointerRNA ptr = {{NULL}}; + PointerRNA ptr = {NULL}; PropertyRNA *prop = NULL; int index; bool driven, special; @@ -979,7 +979,7 @@ static bool add_driver_button_poll(bContext *C) /* this operator can only run if there's a property button active, and it can be animated */ UI_context_active_but_prop_get(C, &ptr, &prop, &index); - if (!(ptr.id.data && ptr.data && prop)) { + if (!(ptr.owner_id && ptr.data && prop)) { return false; } if (!RNA_property_animateable(&ptr, prop)) { @@ -995,7 +995,7 @@ static bool add_driver_button_poll(bContext *C) * (i.e. "manual/add later"). */ static int add_driver_button_none(bContext *C, wmOperator *op, short mapping_type) { - PointerRNA ptr = {{NULL}}; + PointerRNA ptr = {NULL}; PropertyRNA *prop = NULL; int index; int success = 0; @@ -1006,12 +1006,13 @@ static int add_driver_button_none(bContext *C, wmOperator *op, short mapping_typ index = -1; } - if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { + if (ptr.owner_id && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); short flags = CREATEDRIVER_WITH_DEFAULT_DVAR; if (path) { - success += ANIM_add_driver(op->reports, ptr.id.data, path, index, flags, DRIVER_TYPE_PYTHON); + success += ANIM_add_driver( + op->reports, ptr.owner_id, path, index, flags, DRIVER_TYPE_PYTHON); MEM_freeN(path); } } @@ -1095,28 +1096,29 @@ static void UNUSED_FUNCTION(ANIM_OT_driver_button_add_menu)(wmOperatorType *ot) static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - PointerRNA ptr = {{NULL}}; + PointerRNA ptr = {NULL}; PropertyRNA *prop = NULL; int index; /* try to find driver using property retrieved from UI */ UI_context_active_but_prop_get(C, &ptr, &prop, &index); - if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { + if (ptr.owner_id && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { /* 1) Create a new "empty" driver for this property */ char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); short flags = CREATEDRIVER_WITH_DEFAULT_DVAR; short success = 0; if (path) { - success += ANIM_add_driver(op->reports, ptr.id.data, path, index, flags, DRIVER_TYPE_PYTHON); + success += ANIM_add_driver( + op->reports, ptr.owner_id, path, index, flags, DRIVER_TYPE_PYTHON); MEM_freeN(path); } if (success) { /* send updates */ UI_context_update_anim_flag(C); - DEG_id_tag_update(ptr.id.data, ID_RECALC_COPY_ON_WRITE); + DEG_id_tag_update(ptr.owner_id, ID_RECALC_COPY_ON_WRITE); DEG_relations_tag_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); } @@ -1149,7 +1151,7 @@ void ANIM_OT_driver_button_add(wmOperatorType *ot) static int remove_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr = {{NULL}}; + PointerRNA ptr = {NULL}; PropertyRNA *prop = NULL; short success = 0; int index; @@ -1162,11 +1164,11 @@ static int remove_driver_button_exec(bContext *C, wmOperator *op) index = -1; } - if (ptr.id.data && ptr.data && prop) { + if (ptr.owner_id && ptr.data && prop) { char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); if (path) { - success = ANIM_remove_driver(op->reports, ptr.id.data, path, index, 0); + success = ANIM_remove_driver(op->reports, ptr.owner_id, path, index, 0); MEM_freeN(path); } @@ -1205,14 +1207,14 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot) static int edit_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr = {{NULL}}; + PointerRNA ptr = {NULL}; PropertyRNA *prop = NULL; int index; /* try to find driver using property retrieved from UI */ UI_context_active_but_prop_get(C, &ptr, &prop, &index); - if (ptr.id.data && ptr.data && prop) { + if (ptr.owner_id && ptr.data && prop) { UI_popover_panel_invoke(C, "GRAPH_PT_drivers_popover", true, op->reports); } @@ -1239,7 +1241,7 @@ void ANIM_OT_driver_button_edit(wmOperatorType *ot) static int copy_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr = {{NULL}}; + PointerRNA ptr = {NULL}; PropertyRNA *prop = NULL; short success = 0; int index; @@ -1247,12 +1249,12 @@ static int copy_driver_button_exec(bContext *C, wmOperator *op) /* try to create driver using property retrieved from UI */ UI_context_active_but_prop_get(C, &ptr, &prop, &index); - if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { + if (ptr.owner_id && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); if (path) { /* only copy the driver for the button that this was involved for */ - success = ANIM_copy_driver(op->reports, ptr.id.data, path, index, 0); + success = ANIM_copy_driver(op->reports, ptr.owner_id, path, index, 0); UI_context_update_anim_flag(C); @@ -1283,7 +1285,7 @@ void ANIM_OT_copy_driver_button(wmOperatorType *ot) static int paste_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr = {{NULL}}; + PointerRNA ptr = {NULL}; PropertyRNA *prop = NULL; short success = 0; int index; @@ -1291,18 +1293,18 @@ static int paste_driver_button_exec(bContext *C, wmOperator *op) /* try to create driver using property retrieved from UI */ UI_context_active_but_prop_get(C, &ptr, &prop, &index); - if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { + if (ptr.owner_id && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); if (path) { /* only copy the driver for the button that this was involved for */ - success = ANIM_paste_driver(op->reports, ptr.id.data, path, index, 0); + success = ANIM_paste_driver(op->reports, ptr.owner_id, path, index, 0); UI_context_update_anim_flag(C); DEG_relations_tag_update(CTX_data_main(C)); - DEG_id_tag_update(ptr.id.data, ID_RECALC_ANIMATION); + DEG_id_tag_update(ptr.owner_id, ID_RECALC_ANIMATION); WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); // XXX diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 7fd2338dbf3..0f8b8742659 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -222,7 +222,7 @@ FCurve *verify_fcurve(Main *bmain, /* sync bone group colors if applicable */ if (ptr && (ptr->type == &RNA_PoseBone)) { - Object *ob = (Object *)ptr->id.data; + Object *ob = (Object *)ptr->owner_id; bPoseChannel *pchan = (bPoseChannel *)ptr->data; bPose *pose = ob->pose; bActionGroup *grp; @@ -286,7 +286,7 @@ void update_autoflags_fcurve(FCurve *fcu, bContext *C, ReportList *reports, Poin PropertyRNA *prop; int old_flag = fcu->flag; - if ((ptr->id.data == NULL) && (ptr->data == NULL)) { + if ((ptr->owner_id == NULL) && (ptr->data == NULL)) { BKE_report(reports, RPT_ERROR, "No RNA pointer available to retrieve values for this fcurve"); return; } @@ -294,7 +294,7 @@ void update_autoflags_fcurve(FCurve *fcu, bContext *C, ReportList *reports, Poin /* try to get property we should be affecting */ if (RNA_path_resolve_property(ptr, fcu->rna_path, &tmp_ptr, &prop) == false) { /* property not found... */ - const char *idname = (ptr->id.data) ? ((ID *)ptr->id.data)->name : TIP_(""); + const char *idname = (ptr->owner_id) ? ptr->owner_id->name : TIP_(""); BKE_reportf(reports, RPT_ERROR, @@ -1203,7 +1203,7 @@ bool insert_keyframe_direct(ReportList *reports, } /* if no property given yet, try to validate from F-Curve info */ - if ((ptr.id.data == NULL) && (ptr.data == NULL)) { + if ((ptr.owner_id == NULL) && (ptr.data == NULL)) { BKE_report( reports, RPT_ERROR, "No RNA pointer available to retrieve values for keyframing from"); return false; @@ -1214,7 +1214,7 @@ bool insert_keyframe_direct(ReportList *reports, /* try to get property we should be affecting */ if (RNA_path_resolve_property(&ptr, fcu->rna_path, &tmp_ptr, &prop) == false) { /* property not found... */ - const char *idname = (ptr.id.data) ? ((ID *)ptr.id.data)->name : TIP_(""); + const char *idname = (ptr.owner_id) ? ptr.owner_id->name : TIP_(""); BKE_reportf(reports, RPT_ERROR, @@ -2350,7 +2350,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; - PointerRNA ptr = {{NULL}}; + PointerRNA ptr = {NULL}; PropertyRNA *prop = NULL; char *path; uiBut *but; @@ -2369,7 +2369,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); } - if ((ptr.id.data && ptr.data && prop) && RNA_property_animateable(&ptr, prop)) { + if ((ptr.owner_id && ptr.data && prop) && RNA_property_animateable(&ptr, prop)) { if (ptr.type == &RNA_NlaStrip) { /* Handle special properties for NLA Strips, whose F-Curves are stored on the * strips themselves. These are stored separately or else the properties will @@ -2435,7 +2435,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) success = insert_keyframe(bmain, op->reports, - ptr.id.data, + ptr.owner_id, NULL, group, path, @@ -2473,7 +2473,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) } if (success) { - ID *id = ptr.id.data; + ID *id = ptr.owner_id; AnimData *adt = BKE_animdata_from_id(id); if (adt->action != NULL) { DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION_NO_FLUSH); @@ -2513,7 +2513,7 @@ void ANIM_OT_keyframe_insert_button(wmOperatorType *ot) static int delete_key_button_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - PointerRNA ptr = {{NULL}}; + PointerRNA ptr = {NULL}; PropertyRNA *prop = NULL; Main *bmain = CTX_data_main(C); char *path; @@ -2528,13 +2528,13 @@ static int delete_key_button_exec(bContext *C, wmOperator *op) return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); } - if (ptr.id.data && ptr.data && prop) { + if (ptr.owner_id && ptr.data && prop) { if (BKE_nlastrip_has_curves_for_property(&ptr, prop)) { /* Handle special properties for NLA Strips, whose F-Curves are stored on the * strips themselves. These are stored separately or else the properties will * not have any effect. */ - ID *id = ptr.id.data; + ID *id = ptr.owner_id; NlaStrip *strip = (NlaStrip *)ptr.data; FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), 0); @@ -2577,7 +2577,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op) } success = delete_keyframe( - bmain, op->reports, ptr.id.data, NULL, NULL, path, index, cfra, 0); + bmain, op->reports, ptr.owner_id, NULL, NULL, path, index, cfra, 0); MEM_freeN(path); } else if (G.debug & G_DEBUG) { @@ -2622,7 +2622,7 @@ void ANIM_OT_keyframe_delete_button(wmOperatorType *ot) static int clear_key_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr = {{NULL}}; + PointerRNA ptr = {NULL}; PropertyRNA *prop = NULL; Main *bmain = CTX_data_main(C); char *path; @@ -2636,7 +2636,7 @@ static int clear_key_button_exec(bContext *C, wmOperator *op) return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); } - if (ptr.id.data && ptr.data && prop) { + if (ptr.owner_id && ptr.data && prop) { path = RNA_path_from_ID_to_property(&ptr, prop); if (path) { @@ -2645,7 +2645,7 @@ static int clear_key_button_exec(bContext *C, wmOperator *op) index = -1; } - success += clear_keyframe(bmain, op->reports, ptr.id.data, NULL, NULL, path, index, 0); + success += clear_keyframe(bmain, op->reports, ptr.owner_id, NULL, NULL, path, index, 0); MEM_freeN(path); } else if (G.debug & G_DEBUG) { diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 7d31c6d3e3a..258c0e4f1f6 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -287,7 +287,7 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); KeyingSet *ks = NULL; PropertyRNA *prop = NULL; - PointerRNA ptr = {{NULL}}; + PointerRNA ptr = {NULL}; char *path = NULL; short success = 0; int index = 0, pflag = 0; @@ -332,7 +332,7 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op) } /* check if property is able to be added */ - if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { + if (ptr.owner_id && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { path = RNA_path_from_ID_to_property(&ptr, prop); if (path) { @@ -348,7 +348,7 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op) } /* add path to this setting */ - BKE_keyingset_add_path(ks, ptr.id.data, NULL, path, index, pflag, KSP_GROUP_KSNAME); + BKE_keyingset_add_path(ks, ptr.owner_id, NULL, path, index, pflag, KSP_GROUP_KSNAME); ks->active_path = BLI_listbase_count(&ks->paths); success = 1; @@ -393,7 +393,7 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); KeyingSet *ks = NULL; PropertyRNA *prop = NULL; - PointerRNA ptr = {{NULL}}; + PointerRNA ptr = {NULL}; char *path = NULL; short success = 0; int index = 0; @@ -420,14 +420,14 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op) ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); } - if (ptr.id.data && ptr.data && prop) { + if (ptr.owner_id && ptr.data && prop) { path = RNA_path_from_ID_to_property(&ptr, prop); if (path) { KS_Path *ksp; /* try to find a path matching this description */ - ksp = BKE_keyingset_find_path(ks, ptr.id.data, ks->name, path, index, KSP_GROUP_KSNAME); + ksp = BKE_keyingset_find_path(ks, ptr.owner_id, ks->name, path, index, KSP_GROUP_KSNAME); if (ksp) { BKE_keyingset_free_path(ks, ksp); -- cgit v1.2.3