From 1e820898ff4dfc734710a6640ca7bafc0bfc69db Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Thu, 22 Nov 2018 13:38:03 +0300 Subject: 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 --- source/blender/blenkernel/intern/armature_update.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source/blender/blenkernel/intern/armature_update.c') 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); } -- cgit v1.2.3