diff options
author | Bastien Montagne <bastien@blender.org> | 2020-10-22 16:14:28 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-10-26 13:26:55 +0300 |
commit | fff08e81ea74c66858c550109d33a59603d20c32 (patch) | |
tree | 398efae03c59011fc8d396ef36b4f5d7ec1bebae /source/blender/blenkernel/intern/armature.c | |
parent | cf6c0760464faf0308ca8d3b52fc0a7aaf91a214 (diff) |
Pose: Add a 'pose_ensure' new utils that only rebuilds if needed.
Avoids having to spread the check logic everywhere in the code.
Diffstat (limited to 'source/blender/blenkernel/intern/armature.c')
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 7b8ed47c513..bad2ed53436 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2573,6 +2573,20 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_ } } +/** + * Ensures object's pose is rebuilt if needed. + * + * \param bmain: May be NULL, only used to tag depsgraph as being dirty... + */ +void BKE_pose_ensure(Main *bmain, Object *ob, bArmature *arm, const bool do_id_user) +{ + BLI_assert(!ELEM(NULL, arm, ob)); + if (ob->type == OB_ARMATURE && ((ob->pose == NULL) || (ob->pose->flag & POSE_RECALC))) { + BLI_assert(GS(arm->id.name) == ID_AR); + BKE_pose_rebuild(bmain, ob, arm, do_id_user); + } +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -2711,11 +2725,9 @@ void BKE_pose_where_is(struct Depsgraph *depsgraph, Scene *scene, Object *ob) if (ELEM(NULL, arm, scene)) { return; } - if ((ob->pose == NULL) || (ob->pose->flag & POSE_RECALC)) { - /* WARNING! passing NULL bmain here means we won't tag depsgraph's as dirty - - * hopefully this is OK. */ - BKE_pose_rebuild(NULL, ob, arm, true); - } + /* WARNING! passing NULL bmain here means we won't tag depsgraph's as dirty - + * hopefully this is OK. */ + BKE_pose_ensure(NULL, ob, arm, true); ctime = BKE_scene_frame_get(scene); /* not accurate... */ |