[Bf-blender-cvs] [5514bd3] depsgraph_refactor: Depsgraph: Changes to pose recalc tagging
Sergey Sharybin
noreply at git.blender.org
Mon Dec 8 11:25:35 CET 2014
Commit: 5514bd3c4eea9a40e429d8694cf7e0bafcf72832
Author: Sergey Sharybin
Date: Mon Dec 8 15:01:02 2014 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rB5514bd3c4eea9a40e429d8694cf7e0bafcf72832
Depsgraph: Changes to pose recalc tagging
Since the new dependency graph needs to have proper pose for building
dependencies the logic now is: if someone changes the pose he should
tag it for update, plus he should tag relations to be updated as well.
===================================================================
M source/blender/blenkernel/BKE_action.h
M source/blender/blenkernel/intern/action.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/versioning_legacy.c
M source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
M source/blender/editors/armature/pose_edit.c
M source/blender/editors/interface/interface_templates.c
M source/blender/editors/object/object_add.c
M source/blender/editors/object/object_constraint.c
M source/blender/makesrna/intern/rna_pose.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index 57ba6fd..c451280 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -197,6 +197,9 @@ bool BKE_pose_copy_result(struct bPose *to, struct bPose *from);
/* clear all transforms */
void BKE_pose_rest(struct bPose *pose);
+/* Tag pose for recalc. Also tag all related data to be recalc. */
+void BKE_pose_tag_recalc(struct Main *bmain, struct bPose *pose);
+
#ifdef __cplusplus
};
#endif
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index c1173cb..2ea3972 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -54,6 +54,7 @@
#include "BKE_animsys.h"
#include "BKE_constraint.h"
#include "BKE_deform.h"
+#include "BKE_depsgraph.h"
#include "BKE_fcurve.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
@@ -1303,6 +1304,16 @@ bool BKE_pose_copy_result(bPose *to, bPose *from)
return true;
}
+/* Tag pose for recalc. Also tag all related data to be recalc. */
+void BKE_pose_tag_recalc(Main *bmain, bPose *pose)
+{
+ pose->flag |= POSE_RECALC;
+ /* Depsgraph components depends on actual pose state,
+ * if pose was changed depsgraph is to be updated as well.
+ */
+ DAG_relations_tag_update(bmain);
+}
+
/* For the calculation of the effects of an Action at the given frame on an object
* This is currently only used for the Action Constraint
*/
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 4a9c74c..06945b2 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -111,6 +111,7 @@
#include "BLF_translation.h"
+#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_brush.h"
#include "BKE_constraint.h"
@@ -2954,7 +2955,7 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose)
if (rebuild) {
DAG_id_tag_update_ex(bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
- pose->flag |= POSE_RECALC;
+ BKE_pose_tag_recalc(bmain, pose);
}
}
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 1a1bc3a..d3b75ca 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -77,6 +77,7 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
+#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_colortools.h"
#include "BKE_constraint.h"
@@ -1924,7 +1925,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
/* btw. armature_rebuild_pose is further only called on leave editmode */
if (ob->type == OB_ARMATURE) {
if (ob->pose)
- ob->pose->flag |= POSE_RECALC;
+ BKE_pose_tag_recalc(main, ob->pose);
/* cannot call stuff now (pointers!), done in setup_app_data */
ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
@@ -2048,7 +2049,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
data->rootbone = -1;
/* update_pose_etc handles rootbone == -1 */
- ob->pose->flag |= POSE_RECALC;
+ BKE_pose_tag_recalc(main, ob->pose);
}
}
}
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
index d3137f8..7c28879 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -541,9 +541,10 @@ void DepsgraphNodeBuilder::build_rig(Scene *scene, Object *ob)
{
bArmature *arm = (bArmature *)ob->data;
- /* We demand having proper pose. */
- BLI_assert(ob->pose != NULL);
- BLI_assert((ob->pose->flag & POSE_RECALC) == 0);
+ /* Rbuild pose if not up to date. */
+ if (ob->pose == NULL || ob->pose->flag & POSE_RECALC) {
+ BKE_pose_rebuild(ob, arm);
+ }
// TODO: bone names?
/* animation and/or drivers linking posebones to base-armature used to define them
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index d8a32f0..313c707 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -436,7 +436,7 @@ static void pose_copy_menu(Scene *scene)
pchan->constflag |= pchanact->constflag;
if (ob->pose)
- ob->pose->flag |= POSE_RECALC;
+ BKE_pose_tag_recalc(bmain, ob->pose);
}
break;
case 6: /* Transform Locks */
@@ -550,7 +550,7 @@ static void pose_copy_menu(Scene *scene)
BKE_pose_update_constraint_flags(ob->pose); /* we could work out the flags but its simpler to do this */
if (ob->pose)
- ob->pose->flag |= POSE_RECALC;
+ BKE_pose_tag_recalc(bmain, ob->pose);
}
DAG_id_tag_update(&ob->id, OB_RECALC_DATA); // and all its relations
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 9e974fe..e2a11c7 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1059,7 +1059,8 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event)
case B_CONSTRAINT_CHANGETARGET:
{
Main *bmain = CTX_data_main(C);
- if (ob->pose) ob->pose->flag |= POSE_RECALC; /* checks & sorts pose channels */
+ if (ob->pose)
+ BKE_pose_tag_recalc(bmain, ob->pose); /* checks & sorts pose channels */
DAG_relations_tag_update(bmain);
break;
}
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 0021f13..5d77eb0 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -57,6 +57,7 @@
#include "BLF_translation.h"
+#include "BKE_action.h"
#include "BKE_anim.h"
#include "BKE_animsys.h"
#include "BKE_armature.h"
@@ -2024,7 +2025,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
case OB_ARMATURE:
DAG_id_tag_update(&obn->id, OB_RECALC_DATA);
if (obn->pose)
- obn->pose->flag |= POSE_RECALC;
+ BKE_pose_tag_recalc(bmain, obn->pose);
if (dupflag & USER_DUP_ARM) {
ID_NEW_US2(obn->data)
else {
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 2596ea0..9f04dae 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -1165,7 +1165,7 @@ void ED_object_constraint_dependency_update(Main *bmain, Object *ob)
{
ED_object_constraint_update(ob);
- if (ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels
+ if (ob->pose) BKE_pose_tag_recalc(bmain, ob->pose); // checks & sorts pose channels
DAG_relations_tag_update(bmain);
}
@@ -1419,8 +1419,8 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op)
BKE_constraints_copy(&chan->constraints, &pchan->constraints, true);
/* update flags (need to add here, not just copy) */
chan->constflag |= pchan->constflag;
-
- ob->pose->flag |= POSE_RECALC;
+
+ BKE_pose_tag_recalc(bmain, ob->pose);
DAG_id_tag_update((ID *)ob, OB_RECALC_DATA);
}
}
@@ -1731,7 +1731,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
DAG_relations_tag_update(bmain);
if ((ob->type == OB_ARMATURE) && (pchan)) {
- ob->pose->flag |= POSE_RECALC; /* sort pose channels */
+ BKE_pose_tag_recalc(bmain, ob->pose); /* sort pose channels */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
}
else
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index f72f97b..66e220a 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -231,7 +231,7 @@ static void rna_Pose_ik_solver_update(Main *bmain, Scene *UNUSED(scene), Pointer
Object *ob = ptr->id.data;
bPose *pose = ptr->data;
- pose->flag |= POSE_RECALC; /* checks & sorts pose channels */
+ BKE_pose_tag_recalc(bmain, pose); /* checks & sorts pose channels */
DAG_relations_tag_update(bmain);
BKE_pose_update_constraint_flags(pose);
@@ -356,7 +356,7 @@ static void rna_Itasc_update_rebuild(Main *bmain, Scene *scene, PointerRNA *ptr)
Object *ob = ptr->id.data;
bPose *pose = ob->pose;
- pose->flag |= POSE_RECALC; /* checks & sorts pose channels */
+ BKE_pose_tag_recalc(bmain, pose); /* checks & sorts pose channels */
rna_Itasc_update(bmain, scene, ptr);
}
More information about the Bf-blender-cvs
mailing list