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
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-10-22 18:13:19 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-10-22 18:13:19 +0300
commit0628fe7a6cf33bec370a4db53bb9d5980fa40162 (patch)
treea0eb7f542cf5d5d8bce9baf4f892ed2220754659 /source
parent3c655fd37274acff80fbc07dd68d4fc08ce65787 (diff)
Followup to previous change, reduce number of relations updates
Only tag relations update when new f-curve was allocated. This solves possible too slow keyframe insertion when doing character animation, but still does proper relation update when new ID component became animated.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c2
-rw-r--r--source/blender/editors/animation/keyframing.c35
-rw-r--r--source/blender/editors/animation/keyingsets.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c2
-rw-r--r--source/blender/editors/include/ED_keyframing.h6
-rw-r--r--source/blender/editors/object/object_constraint.c4
-rw-r--r--source/blender/editors/object/object_relations.c2
-rw-r--r--source/blender/makesrna/intern/rna_action.c8
-rw-r--r--source/blender/python/intern/bpy_rna_anim.c2
9 files changed, 36 insertions, 27 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index b80667a011a..1dcf0a13055 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -4186,7 +4186,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi
/* find or create new F-Curve */
// XXX is the group name for this ok?
bAction *act = verify_adt_action(bmain, (ID *)key, 1);
- FCurve *fcu = verify_fcurve(act, NULL, &ptr, rna_path, 0, 1);
+ FCurve *fcu = verify_fcurve(bmain, act, NULL, &ptr, rna_path, 0, 1);
/* set the special 'replace' flag if on a keyframe */
if (fcurve_frame_has_keyframe(fcu, cfra, 0))
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index f453c306cc7..4199213d219 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -157,14 +157,10 @@ bAction *verify_adt_action(Main *bmain, ID *id, short add)
*/
adt->action->idroot = GS(id->name);
+ /* Tag depsgraph to be rebuilt to include time dependency. */
+ DEG_relations_tag_update(bmain);
}
- /* Tag depsgraph to be rebuilt to include time dependency.
- *
- * NOTE: Do it for all animation data modification, since existing animation
- * data might not include relations to the newly animated components.
- */
- DEG_relations_tag_update(bmain);
DEG_id_tag_update(&adt->action->id, DEG_TAG_COPY_ON_WRITE);
/* return the action */
@@ -174,7 +170,7 @@ bAction *verify_adt_action(Main *bmain, ID *id, short add)
/* Get (or add relevant data to be able to do so) F-Curve from the Active Action,
* for the given Animation Data block. This assumes that all the destinations are valid.
*/
-FCurve *verify_fcurve(bAction *act, const char group[], PointerRNA *ptr,
+FCurve *verify_fcurve(Main *bmain, bAction *act, const char group[], PointerRNA *ptr,
const char rna_path[], const int array_index, short add)
{
bActionGroup *agrp;
@@ -235,6 +231,11 @@ FCurve *verify_fcurve(bAction *act, const char group[], PointerRNA *ptr,
/* just add F-Curve to end of Action's list */
BLI_addtail(&act->curves, fcu);
}
+
+ /* New f-curve was added, meaning it's possible that it affects
+ * dependency graph component which wasn't previously animated.
+ */
+ DEG_relations_tag_update(bmain);
}
/* return the F-Curve */
@@ -1086,7 +1087,7 @@ short insert_keyframe(
* - if we're replacing keyframes only, DO NOT create new F-Curves if they do not exist yet
* but still try to get the F-Curve if it exists...
*/
- fcu = verify_fcurve(act, group, &ptr, rna_path, array_index, (flag & INSERTKEY_REPLACE) == 0);
+ fcu = verify_fcurve(bmain, act, group, &ptr, rna_path, array_index, (flag & INSERTKEY_REPLACE) == 0);
/* we may not have a F-Curve when we're replacing only... */
if (fcu) {
@@ -1159,7 +1160,9 @@ static bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra)
return false;
}
-short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eInsertKeyFlags UNUSED(flag))
+short delete_keyframe(Main *bmain, ReportList *reports, ID *id, bAction *act,
+ const char group[], const char rna_path[], int array_index, float cfra,
+ eInsertKeyFlags UNUSED(flag))
{
AnimData *adt = BKE_animdata_from_id(id);
PointerRNA id_ptr, ptr;
@@ -1217,7 +1220,7 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
/* will only loop once unless the array index was -1 */
for (; array_index < array_index_max; array_index++) {
- FCurve *fcu = verify_fcurve(act, group, &ptr, rna_path, array_index, 0);
+ FCurve *fcu = verify_fcurve(bmain, act, group, &ptr, rna_path, array_index, 0);
/* check if F-Curve exists and/or whether it can be edited */
if (fcu == NULL)
@@ -1248,7 +1251,9 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou
* The flag argument is used for special settings that alter the behavior of
* the keyframe deletion. These include the quick refresh options.
*/
-static short clear_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, eInsertKeyFlags UNUSED(flag))
+static short clear_keyframe(Main *bmain, ReportList *reports, ID *id, bAction *act,
+ const char group[], const char rna_path[], int array_index,
+ eInsertKeyFlags UNUSED(flag))
{
AnimData *adt = BKE_animdata_from_id(id);
PointerRNA id_ptr, ptr;
@@ -1303,7 +1308,7 @@ static short clear_keyframe(ReportList *reports, ID *id, bAction *act, const cha
/* will only loop once unless the array index was -1 */
for (; array_index < array_index_max; array_index++) {
- FCurve *fcu = verify_fcurve(act, group, &ptr, rna_path, array_index, 0);
+ FCurve *fcu = verify_fcurve(bmain, act, group, &ptr, rna_path, array_index, 0);
/* check if F-Curve exists and/or whether it can be edited */
if (fcu == NULL)
@@ -1932,6 +1937,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
PointerRNA ptr = {{NULL}};
PropertyRNA *prop = NULL;
+ Main *bmain = CTX_data_main(C);
char *path;
float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
short success = 0;
@@ -1988,7 +1994,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
index = -1;
}
- success = delete_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index, cfra, 0);
+ success = delete_keyframe(bmain, op->reports, ptr.id.data, NULL, NULL, path, index, cfra, 0);
MEM_freeN(path);
}
else if (G.debug & G_DEBUG)
@@ -2036,6 +2042,7 @@ static int clear_key_button_exec(bContext *C, wmOperator *op)
{
PointerRNA ptr = {{NULL}};
PropertyRNA *prop = NULL;
+ Main *bmain = CTX_data_main(C);
char *path;
short success = 0;
int index;
@@ -2056,7 +2063,7 @@ static int clear_key_button_exec(bContext *C, wmOperator *op)
index = -1;
}
- success += clear_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index, 0);
+ success += clear_keyframe(bmain, op->reports, ptr.id.data, 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 d159636756a..1d6ced02332 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -1042,7 +1042,7 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe
if (mode == MODIFYKEY_MODE_INSERT)
success += insert_keyframe(bmain, depsgraph, reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, keytype, kflag2);
else if (mode == MODIFYKEY_MODE_DELETE)
- success += delete_keyframe(reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag2);
+ success += delete_keyframe(bmain, reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag2);
}
/* set recalc-flags */
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 72165b04a05..e6246bb8fd4 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -483,7 +483,7 @@ static void gp_stroke_path_animation(bContext *C, ReportList *reports, Curve *cu
/* Ensure we have an F-Curve to add keyframes to */
act = verify_adt_action(bmain, (ID *)cu, true);
- fcu = verify_fcurve(act, NULL, &ptr, "eval_time", 0, true);
+ fcu = verify_fcurve(bmain, act, NULL, &ptr, "eval_time", 0, true);
if (G.debug & G_DEBUG) {
printf("%s: tot len: %f\t\ttot time: %f\n", __func__, gtd->tot_dist, gtd->tot_time);
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index 08a039841f8..22e82d6b9ef 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -76,7 +76,7 @@ struct bAction *verify_adt_action(struct Main *bmain, struct ID *id, short add);
/* Get (or add relevant data to be able to do so) F-Curve from the given Action.
* This assumes that all the destinations are valid.
*/
-struct FCurve *verify_fcurve(struct bAction *act, const char group[], struct PointerRNA *ptr,
+struct FCurve *verify_fcurve(struct Main *bmain, struct bAction *act, const char group[], struct PointerRNA *ptr,
const char rna_path[], const int array_index, short add);
/* -------- */
@@ -124,7 +124,9 @@ short insert_keyframe(
/* Main Keyframing API call:
* Use this to delete keyframe on current frame for relevant channel. Will perform checks just in case.
*/
-short delete_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eInsertKeyFlags flag);
+short delete_keyframe(
+ struct Main *bmain, struct ReportList *reports, struct ID *id, struct bAction *act,
+ const char group[], const char rna_path[], int array_index, float cfra, eInsertKeyFlags flag);
/* ************ Keying Sets ********************** */
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 7b72b1eb80e..4081c005132 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -998,7 +998,7 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op)
{
/* create F-Curve for path animation */
act = verify_adt_action(bmain, &cu->id, 1);
- fcu = verify_fcurve(act, NULL, NULL, "eval_time", 0, 1);
+ fcu = verify_fcurve(bmain, act, NULL, NULL, "eval_time", 0, 1);
/* standard vertical range - 1:1 = 100 frames */
standardRange = 100.0f;
@@ -1023,7 +1023,7 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op)
/* create F-Curve for constraint */
act = verify_adt_action(bmain, &ob->id, 1);
- fcu = verify_fcurve(act, NULL, NULL, path, 0, 1);
+ fcu = verify_fcurve(bmain, act, NULL, NULL, path, 0, 1);
/* standard vertical range - 0.0 to 1.0 */
standardRange = 1.0f;
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index d239b1f25dc..306cdc9472a 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -641,7 +641,7 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene,
if (partype == PAR_FOLLOW) {
/* get or create F-Curve */
bAction *act = verify_adt_action(bmain, &cu->id, 1);
- FCurve *fcu = verify_fcurve(act, NULL, NULL, "eval_time", 0, 1);
+ FCurve *fcu = verify_fcurve(bmain, act, NULL, NULL, "eval_time", 0, 1);
/* setup dummy 'generator' modifier here to get 1-1 correspondence still working */
if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first)
diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c
index fe4c92b9163..76297320511 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -102,7 +102,7 @@ static void rna_Action_groups_remove(bAction *act, ReportList *reports, PointerR
RNA_POINTER_INVALIDATE(agrp_ptr);
}
-static FCurve *rna_Action_fcurve_new(bAction *act, ReportList *reports, const char *data_path,
+static FCurve *rna_Action_fcurve_new(bAction *act, Main *bmain, ReportList *reports, const char *data_path,
int index, const char *group)
{
if (group && group[0] == '\0') group = NULL;
@@ -113,12 +113,12 @@ static FCurve *rna_Action_fcurve_new(bAction *act, ReportList *reports, const ch
}
/* annoying, check if this exists */
- if (verify_fcurve(act, group, NULL, data_path, index, 0)) {
+ if (verify_fcurve(bmain, act, group, NULL, data_path, index, 0)) {
BKE_reportf(reports, RPT_ERROR, "F-Curve '%s[%d]' already exists in action '%s'", data_path,
index, act->id.name + 2);
return NULL;
}
- return verify_fcurve(act, group, NULL, data_path, index, 1);
+ return verify_fcurve(bmain, act, group, NULL, data_path, index, 1);
}
static FCurve *rna_Action_fcurve_find(bAction *act, ReportList *reports, const char *data_path, int index)
@@ -598,7 +598,7 @@ static void rna_def_action_fcurves(BlenderRNA *brna, PropertyRNA *cprop)
/* Action.fcurves.new(...) */
func = RNA_def_function(srna, "new", "rna_Action_fcurve_new");
RNA_def_function_ui_description(func, "Add an F-Curve to the action");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_MAIN);
parm = RNA_def_string(func, "data_path", NULL, 0, "Data Path", "F-Curve data path to use");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Array index", 0, INT_MAX);
diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c
index 7012e04628c..ffc56fdf62c 100644
--- a/source/blender/python/intern/bpy_rna_anim.c
+++ b/source/blender/python/intern/bpy_rna_anim.c
@@ -386,7 +386,7 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
BKE_reports_init(&reports, RPT_STORE);
- result = delete_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0);
+ result = delete_keyframe(G.main, &reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0);
MEM_freeN((void *)path_full);
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)