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:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-05-31 15:27:37 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-05-31 19:07:55 +0300
commit59a516913e599ce29754d361246a0d8cb92bd314 (patch)
tree326c0babbc13e6168712cf34672b8ce6bc98d332
parentb5b1f9d11c86032fd2b7a61ce39b8d62e1585cef (diff)
Depsgraph: Copy evaluated data to original datablock
Only do it for active dependency graph. Currently covers animation, drivers, object and pose channel matricies.
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c73
-rw-r--r--source/blender/blenkernel/intern/armature_update.c5
-rw-r--r--source/blender/blenkernel/intern/object_update.c6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc12
-rw-r--r--source/blender/makesdna/DNA_action_types.h3
5 files changed, 55 insertions, 44 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 12b85e14cf9..0af61623cdc 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1702,24 +1702,32 @@ bool BKE_animsys_execute_fcurve(PointerRNA *ptr, AnimMapper *remap, FCurve *fcu,
return ok;
}
-/* Evaluate all the F-Curves in the given list
- * This performs a set of standard checks. If extra checks are required, separate code should be used
- */
-static void animsys_evaluate_fcurves(
- Depsgraph *depsgraph, PointerRNA *ptr, ListBase *list, AnimMapper *remap,float ctime, short recalc)
+static void animsys_write_orig_anim_rna(
+ PointerRNA *ptr,
+ AnimMapper *remap,
+ FCurve *fcu,
+ float value)
{
- (void) depsgraph;
- FCurve *fcu;
-
/* Pointer is expected to be an ID pointer, if it's not -- we are doomed. */
PointerRNA orig_ptr = *ptr;
orig_ptr.id.data = ((ID *)orig_ptr.id.data)->orig_id;
orig_ptr.data = orig_ptr.id.data;
+ PathResolvedRNA orig_anim_rna;
+ /* TODO(sergey): Is there a faster way to get anim_rna of original ID? */
+ if (animsys_store_rna_setting(&orig_ptr, remap, fcu->rna_path, fcu->array_index, &orig_anim_rna)) {
+ animsys_write_rna_setting(&orig_anim_rna, value);
+ }
+}
- const bool copy_on_write = orig_ptr.id.data != NULL;
-
+/* Evaluate all the F-Curves in the given list
+ * This performs a set of standard checks. If extra checks are required, separate code should be used
+ */
+static void animsys_evaluate_fcurves(
+ Depsgraph *depsgraph, PointerRNA *ptr, ListBase *list, AnimMapper *remap, float ctime)
+{
+ const bool is_active_depsgraph = DEG_is_active(depsgraph);
/* Calculate then execute each curve. */
- for (fcu = list->first; fcu; fcu = fcu->next) {
+ for (FCurve *fcu = list->first; fcu; fcu = fcu->next) {
/* Check if this F-Curve doesn't belong to a muted group. */
if ((fcu->grp != NULL) && (fcu->grp->flag & AGRP_MUTED)) {
continue;
@@ -1729,37 +1737,11 @@ static void animsys_evaluate_fcurves(
continue;
}
PathResolvedRNA anim_rna;
- /* Read current value from original datablock. */
- float dna_val;
-
- if (copy_on_write) {
- if (animsys_store_rna_setting(&orig_ptr, remap, fcu->rna_path, fcu->array_index, &anim_rna)) {
- if (!animsys_read_rna_setting(&anim_rna, &dna_val)) {
- continue;
- }
- }
- else {
- continue;
- }
- }
-
if (animsys_store_rna_setting(ptr, remap, fcu->rna_path, fcu->array_index, &anim_rna)) {
- if (copy_on_write) {
- const bool check_orig_dna = ((recalc & ADT_RECALC_CHECK_ORIG_DNA) != 0);
- /* If we are tweaking DNA without changing frame, we don't write f-curves,
- * since otherwise we will not be able to change properties which has animation.
- */
- if (check_orig_dna && fcu->orig_dna_val != dna_val) {
- continue;
- }
- }
-
const float curval = calculate_fcurve(&anim_rna, fcu, ctime);
animsys_write_rna_setting(&anim_rna, curval);
-
- if (copy_on_write) {
- /* Store original DNA value f-curve was written for. */
- fcu->orig_dna_val = dna_val;
+ if (is_active_depsgraph) {
+ animsys_write_orig_anim_rna(ptr, remap, fcu, curval);
}
}
}
@@ -1872,7 +1854,7 @@ void animsys_evaluate_action_group(PointerRNA *ptr, bAction *act, bActionGroup *
/* Evaluate Action (F-Curve Bag) */
static void animsys_evaluate_action_ex(
- Depsgraph *depsgraph, PointerRNA *ptr, bAction *act, AnimMapper *remap, float ctime, short recalc)
+ Depsgraph *depsgraph, PointerRNA *ptr, bAction *act, AnimMapper *remap, float ctime)
{
/* check if mapper is appropriate for use here (we set to NULL if it's inappropriate) */
if (act == NULL) return;
@@ -1881,12 +1863,12 @@ static void animsys_evaluate_action_ex(
action_idcode_patch_check(ptr->id.data, act);
/* calculate then execute each curve */
- animsys_evaluate_fcurves(depsgraph, ptr, &act->curves, remap, ctime, recalc);
+ animsys_evaluate_fcurves(depsgraph, ptr, &act->curves, remap, ctime);
}
void animsys_evaluate_action(Depsgraph *depsgraph, PointerRNA *ptr, bAction *act, AnimMapper *remap, float ctime)
{
- animsys_evaluate_action_ex(depsgraph, ptr, act, remap, ctime, 0);
+ animsys_evaluate_action_ex(depsgraph, ptr, act, remap, ctime);
}
/* ***************************************** */
@@ -1925,7 +1907,7 @@ static void nlastrip_evaluate_controls(Depsgraph *depsgraph, NlaStrip *strip, fl
RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr);
/* execute these settings as per normal */
- animsys_evaluate_fcurves(depsgraph, &strip_ptr, &strip->fcurves, NULL, ctime, 0);
+ animsys_evaluate_fcurves(depsgraph, &strip_ptr, &strip->fcurves, NULL, ctime);
}
/* analytically generate values for influence and time (if applicable)
@@ -2794,7 +2776,7 @@ void BKE_animsys_evaluate_animdata(Depsgraph *depsgraph, Scene *scene, ID *id, A
}
/* evaluate Active Action only */
else if (adt->action)
- animsys_evaluate_action_ex(depsgraph, &id_ptr, adt->action, adt->remap, ctime, recalc);
+ animsys_evaluate_action_ex(depsgraph, &id_ptr, adt->action, adt->remap, ctime);
/* reset tag */
adt->recalc &= ~ADT_RECALC_ANIM;
@@ -3044,6 +3026,9 @@ void BKE_animsys_eval_driver(Depsgraph *depsgraph,
const float ctime = DEG_get_ctime(depsgraph);
const float curval = calculate_fcurve(&anim_rna, fcu, ctime);
ok = animsys_write_rna_setting(&anim_rna, curval);
+ if (ok && DEG_is_active(depsgraph)) {
+ animsys_write_orig_anim_rna(&id_ptr, NULL, fcu, curval);
+ }
}
//printf("\tnew val = %f\n", fcu->curval);
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index bf21019a948..9613ec4116a 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -688,6 +688,11 @@ void BKE_pose_bone_done(struct Depsgraph *depsgraph,
invert_m4_m4(imat, pchan->bone->arm_mat);
mul_m4_m4m4(pchan->chan_mat, pchan->pose_mat, imat);
}
+ if (DEG_is_active(depsgraph)) {
+ bPoseChannel *pchan_orig = pchan->orig_pchan;
+ copy_m4_m4(pchan_orig->pose_mat, pchan->pose_mat);
+ copy_m4_m4(pchan_orig->chan_mat, pchan->chan_mat);
+ }
}
void BKE_pose_iktree_evaluate(struct Depsgraph *depsgraph,
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 3420957bb02..852d8197a6c 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -140,6 +140,12 @@ void BKE_object_eval_done(Depsgraph *depsgraph, Object *ob)
/* Set negative scale flag in object. */
if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE;
else ob->transflag &= ~OB_NEG_SCALE;
+
+ if (DEG_is_active(depsgraph)) {
+ Object *ob_orig = DEG_get_original_object(ob);
+ copy_m4_m4(ob_orig->obmat, ob->obmat);
+ ob_orig->transflag = ob->transflag;
+ }
}
void BKE_object_handle_data_update(
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 6bf7e2fe9e5..2789f189f03 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -510,6 +510,17 @@ void update_particle_system_orig_pointers(const Object *object_orig,
}
}
+void update_pose_orig_pointers(const bPose *pose_orig, bPose *pose_cow)
+{
+ bPoseChannel *pchan_cow = (bPoseChannel *) pose_cow->chanbase.first;
+ bPoseChannel *pchan_orig = (bPoseChannel *) pose_orig->chanbase.first;
+ while (pchan_orig != NULL) {
+ pchan_cow->orig_pchan = pchan_orig;
+ pchan_cow = pchan_cow->next;
+ pchan_orig = pchan_orig->next;
+ }
+}
+
/* Do some special treatment of data transfer from original ID to it's
* CoW complementary part.
*
@@ -534,6 +545,7 @@ void update_special_pointers(const Depsgraph *depsgraph,
if (object_cow->type == OB_ARMATURE) {
BKE_pose_remap_bone_pointers((bArmature *)object_cow->data,
object_cow->pose);
+ update_pose_orig_pointers(object_orig->pose, object_cow->pose);
}
update_particle_system_orig_pointers(object_orig, object_cow);
break;
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 2e73f5754d3..4911b21cd2b 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -277,6 +277,9 @@ typedef struct bPoseChannel {
void *temp; /* use for outliner */
/* Runtime data for color and bbone segment matrix. */
bPoseChannelDrawData *draw_data;
+
+ /* Points to an original pose channel. */
+ struct bPoseChannel *orig_pchan;
} bPoseChannel;