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-04-03 18:23:43 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-04-04 10:48:41 +0300
commit4674e02562637f36a9900bff5f5f4acc9aff482d (patch)
tree4fca4fb97dad7c2e34533950d44faeb5ce94e2c0 /source/blender/blenkernel
parentfa01a1738bd1e3a6750ffbe523a282bc22de3991 (diff)
Depsgraph: Only bind ID-data and indices to depsgraph callbacks
This is a part of copy-on-write sanitization, to avoid all the checks which were attempting to keep sub-data pointers intact. Point is: ID pointers never change for CoW datablocks, but nested data pointers might change when updating existing copy. Solution: Only bind ID data pointers and index of sub-data. This will make CoW datablock 7update function was easier in 2.8. In master we were only using pose channel pointers in callbacks, this is exactly what this commit addresses. A linear lookup array is created on pose evaluation init and is thrown away afterwards. One thing we might consider doing is to keep indexed array of poses, similar to chanhash. Reviewers: campbellbarton Reviewed By: campbellbarton Subscribers: dfelinto Differential Revision: https://developer.blender.org/D3124
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_armature.h20
-rw-r--r--source/blender/blenkernel/intern/armature_update.c58
2 files changed, 49 insertions, 29 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index 60fb79d75d5..f6de39c897e 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -169,41 +169,39 @@ void BKE_splineik_execute_tree(struct Scene *scene, struct Object *ob, struct bP
void BKE_pose_eval_init(struct EvaluationContext *eval_ctx,
struct Scene *scene,
- struct Object *ob,
- struct bPose *pose);
+ struct Object *ob);
void BKE_pose_eval_init_ik(struct EvaluationContext *eval_ctx,
struct Scene *scene,
- struct Object *ob,
- struct bPose *pose);
+ struct Object *ob);
void BKE_pose_eval_bone(struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob,
- struct bPoseChannel *pchan);
+ int pchan_index);
void BKE_pose_constraints_evaluate(struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob,
- struct bPoseChannel *pchan);
+ int pchan_index);
void BKE_pose_bone_done(struct EvaluationContext *eval_ctx,
- struct bPoseChannel *pchan);
+ struct Object *ob,
+ int pchan_index);
void BKE_pose_iktree_evaluate(struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob,
- struct bPoseChannel *rootchan);
+ int rootchan_index);
void BKE_pose_splineik_evaluate(struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob,
- struct bPoseChannel *rootchan);
+ int rootchan_index);
void BKE_pose_eval_flush(struct EvaluationContext *eval_ctx,
struct Scene *scene,
- struct Object *ob,
- struct bPose *pose);
+ struct Object *ob);
void BKE_pose_eval_proxy_copy(struct EvaluationContext *eval_ctx,
struct Object *ob);
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index 56e9cce1825..95a26814e37 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -553,10 +553,10 @@ void BKE_splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_roo
void BKE_pose_eval_init(EvaluationContext *UNUSED(eval_ctx),
Scene *UNUSED(scene),
- Object *ob,
- bPose *pose)
+ Object *ob)
{
- bPoseChannel *pchan;
+ bPose *pose = ob->pose;
+ BLI_assert(pose != NULL);
DEG_debug_print_eval(__func__, ob->id.name, ob);
@@ -569,16 +569,21 @@ void BKE_pose_eval_init(EvaluationContext *UNUSED(eval_ctx),
/* imat is needed for solvers. */
invert_m4_m4(ob->imat, ob->obmat);
- /* 1. clear flags */
- for (pchan = pose->chanbase.first; pchan != NULL; pchan = pchan->next) {
+ const int num_channels = BLI_listbase_count(&pose->chanbase);
+ pose->chan_array = MEM_malloc_arrayN(
+ num_channels, sizeof(bPoseChannel*), "pose->chan_array");
+
+ /* clear flags */
+ int pchan_index = 0;
+ for (bPoseChannel *pchan = pose->chanbase.first; pchan != NULL; pchan = pchan->next) {
pchan->flag &= ~(POSE_DONE | POSE_CHAIN | POSE_IKTREE | POSE_IKSPLINE);
+ pose->chan_array[pchan_index++] = pchan;
}
}
void BKE_pose_eval_init_ik(EvaluationContext *UNUSED(eval_ctx),
Scene *scene,
- Object *ob,
- bPose *UNUSED(pose))
+ Object *ob)
{
DEG_debug_print_eval(__func__, ob->id.name, ob);
BLI_assert(ob->type == OB_ARMATURE);
@@ -587,11 +592,11 @@ void BKE_pose_eval_init_ik(EvaluationContext *UNUSED(eval_ctx),
if (arm->flag & ARM_RESTPOS) {
return;
}
- /* 2a. construct the IK tree (standard IK) */
+ /* construct the IK tree (standard IK) */
BIK_initialize_tree(scene, ob, ctime);
- /* 2b. construct the Spline IK trees
+ /* construct the Spline IK trees
* - this is not integrated as an IK plugin, since it should be able
- * to function in conjunction with standard IK
+ * to function in conjunction with standard IK
*/
BKE_pose_splineik_init_tree(scene, ob, ctime);
}
@@ -599,8 +604,10 @@ void BKE_pose_eval_init_ik(EvaluationContext *UNUSED(eval_ctx),
void BKE_pose_eval_bone(EvaluationContext *UNUSED(eval_ctx),
Scene *scene,
Object *ob,
- bPoseChannel *pchan)
+ int pchan_index)
{
+ BLI_assert(ob->pose != NULL);
+ bPoseChannel *pchan = ob->pose->chan_array[pchan_index];
DEG_debug_print_eval_subdata(
__func__, ob->id.name, ob, "pchan", pchan->name, pchan);
BLI_assert(ob->type == OB_ARMATURE);
@@ -635,8 +642,10 @@ void BKE_pose_eval_bone(EvaluationContext *UNUSED(eval_ctx),
void BKE_pose_constraints_evaluate(EvaluationContext *UNUSED(eval_ctx),
Scene *scene,
Object *ob,
- bPoseChannel *pchan)
+ int pchan_index)
{
+ BLI_assert(ob->pose != NULL);
+ bPoseChannel *pchan = ob->pose->chan_array[pchan_index];
DEG_debug_print_eval_subdata(
__func__, ob->id.name, ob, "pchan", pchan->name, pchan);
bArmature *arm = (bArmature *)ob->data;
@@ -655,8 +664,11 @@ void BKE_pose_constraints_evaluate(EvaluationContext *UNUSED(eval_ctx),
}
void BKE_pose_bone_done(EvaluationContext *UNUSED(eval_ctx),
- bPoseChannel *pchan)
+ struct Object *ob,
+ int pchan_index)
{
+ BLI_assert(ob->pose != NULL);
+ bPoseChannel *pchan = ob->pose->chan_array[pchan_index];
float imat[4][4];
DEG_debug_print_eval(__func__, pchan->name, pchan);
if (pchan->bone) {
@@ -668,8 +680,10 @@ void BKE_pose_bone_done(EvaluationContext *UNUSED(eval_ctx),
void BKE_pose_iktree_evaluate(EvaluationContext *UNUSED(eval_ctx),
Scene *scene,
Object *ob,
- bPoseChannel *rootchan)
+ int rootchan_index)
{
+ BLI_assert(ob->pose != NULL);
+ bPoseChannel *rootchan = ob->pose->chan_array[rootchan_index];
DEG_debug_print_eval_subdata(
__func__, ob->id.name, ob, "rootchan", rootchan->name, rootchan);
BLI_assert(ob->type == OB_ARMATURE);
@@ -684,9 +698,11 @@ void BKE_pose_iktree_evaluate(EvaluationContext *UNUSED(eval_ctx),
void BKE_pose_splineik_evaluate(EvaluationContext *UNUSED(eval_ctx),
Scene *scene,
Object *ob,
- bPoseChannel *rootchan)
+ int rootchan_index)
{
+ BLI_assert(ob->pose != NULL);
+ bPoseChannel *rootchan = ob->pose->chan_array[rootchan_index];
DEG_debug_print_eval_subdata(
__func__, ob->id.name, ob, "rootchan", rootchan->name, rootchan);
BLI_assert(ob->type == OB_ARMATURE);
@@ -700,17 +716,23 @@ void BKE_pose_splineik_evaluate(EvaluationContext *UNUSED(eval_ctx),
void BKE_pose_eval_flush(EvaluationContext *UNUSED(eval_ctx),
Scene *scene,
- Object *ob,
- bPose *UNUSED(pose))
+ Object *ob)
{
+ bPose *pose = ob->pose;
+ BLI_assert(pose != NULL);
+
float ctime = BKE_scene_frame_get(scene); /* not accurate... */
DEG_debug_print_eval(__func__, ob->id.name, ob);
BLI_assert(ob->type == OB_ARMATURE);
- /* 6. release the IK tree */
+ /* release the IK tree */
BIK_release_tree(scene, ob, ctime);
ob->recalc &= ~OB_RECALC_ALL;
+
+ BLI_assert(pose->chan_array != NULL);
+ MEM_freeN(pose->chan_array);
+ pose->chan_array = NULL;
}
void BKE_pose_eval_proxy_copy(EvaluationContext *UNUSED(eval_ctx), Object *ob)