diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2018-11-22 13:38:03 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2018-11-23 23:19:23 +0300 |
commit | 1e820898ff4dfc734710a6640ca7bafc0bfc69db (patch) | |
tree | 8f68fba82219df0295d89581e49e105ff907ba80 /source/blender/blenkernel/intern/armature_update.c | |
parent | e49c66efae9d9fb85154ca4b3073ae3733400708 (diff) |
Depsgraph: add a new operation node for computing B-Bone segments.
Computing the shape of a B-Bone is a quite expensive operation, and
there are multiple constraints that can access this information in
a variety of useful ways. This means computing the shape once per
bone and saving it is good for performance.
Since the shape may depend on the position of up to two other bones,
often in a "cyclic" manner, this computation has to be a separate
node with its own dependencies.
Reviewers: sergey
Differential Revision: https://developer.blender.org/D3975
Diffstat (limited to 'source/blender/blenkernel/intern/armature_update.c')
-rw-r--r-- | source/blender/blenkernel/intern/armature_update.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c index 0fba7677479..b917aae08de 100644 --- a/source/blender/blenkernel/intern/armature_update.c +++ b/source/blender/blenkernel/intern/armature_update.c @@ -605,6 +605,11 @@ void BKE_pose_eval_init(struct Depsgraph *depsgraph, /* clear flags */ for (bPoseChannel *pchan = pose->chanbase.first; pchan != NULL; pchan = pchan->next) { pchan->flag &= ~(POSE_DONE | POSE_CHAIN | POSE_IKTREE | POSE_IKSPLINE); + + /* Free B-Bone shape data cache if it's not a B-Bone. */ + if (pchan->bone == NULL || pchan->bone->segments <= 1) { + BKE_pose_channel_free_bbone_cache(pchan); + } } pose_pchan_index_create(pose); @@ -713,6 +718,17 @@ void BKE_pose_bone_done(struct Depsgraph *depsgraph, } } +void BKE_pose_eval_bbone_segments(struct Depsgraph *depsgraph, + struct Object *ob, + int pchan_index) +{ + bPoseChannel *pchan = pose_pchan_get_indexed(ob, pchan_index); + DEG_debug_print_eval(depsgraph, __func__, pchan->name, pchan); + if (pchan->bone != NULL && pchan->bone->segments > 1) { + BKE_pchan_cache_bbone_segments(pchan); + } +} + void BKE_pose_iktree_evaluate(struct Depsgraph *depsgraph, Scene *scene, Object *ob, @@ -834,4 +850,5 @@ void BKE_pose_eval_proxy_copy_bone( BLI_assert(pchan != NULL); BLI_assert(pchan_from != NULL); BKE_pose_copyesult_pchan_result(pchan, pchan_from); + BKE_pchan_copy_bbone_segments_cache(pchan, pchan_from); } |