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/action.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/action.c')
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 87f821130c7..79230ad9e94 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -594,6 +594,9 @@ void BKE_pose_copy_data_ex(bPose **dst, const bPose *src, const int flag, const } pchan->draw_data = NULL; /* Drawing cache, no need to copy. */ + + /* Runtime data, no need to copy. */ + memset(&pchan->runtime, 0, sizeof(pchan->runtime)); } /* for now, duplicate Bone Groups too when doing this */ @@ -790,6 +793,21 @@ void BKE_pose_channel_free_ex(bPoseChannel *pchan, bool do_id_user) /* Cached data, for new draw manager rendering code. */ MEM_SAFE_FREE(pchan->draw_data); + + /* Cached B-Bone shape data. */ + BKE_pose_channel_free_bbone_cache(pchan); +} + +/** Deallocates runtime cache of a pose channel's B-Bone shape. */ +void BKE_pose_channel_free_bbone_cache(bPoseChannel *pchan) +{ + bPoseChannelRuntime *runtime = &pchan->runtime; + + runtime->bbone_segments = 0; + MEM_SAFE_FREE(runtime->bbone_rest_mats); + MEM_SAFE_FREE(runtime->bbone_pose_mats); + MEM_SAFE_FREE(runtime->bbone_deform_mats); + MEM_SAFE_FREE(runtime->bbone_dual_quats); } void BKE_pose_channel_free(bPoseChannel *pchan) |