Commit: 992a88b38b40ab09503b579e7e458ef782e524ea
Author: Bastien Montagne
Date:   Thu Oct 22 15:14:28 2020 +0200
Branches: master
https://developer.blender.org/rB992a88b38b40ab09503b579e7e458ef782e524ea

Pose: Add a 'pose_ensure' new utils that only rebuilds if needed.

Avoids having to spread the check logic everywhere in the code.

===================================================================

M       source/blender/blenkernel/BKE_armature.h
M       source/blender/blenkernel/intern/armature.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_armature.h 
b/source/blender/blenkernel/BKE_armature.h
index 4e8775aefb3..db44a771095 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -180,6 +180,10 @@ void BKE_pose_rebuild(struct Main *bmain,
                       struct Object *ob,
                       struct bArmature *arm,
                       const bool do_id_user);
+void BKE_pose_ensure(struct Main *bmain,
+                     struct Object *ob,
+                     struct bArmature *arm,
+                     const bool do_id_user);
 void BKE_pose_where_is(struct Depsgraph *depsgraph, struct Scene *scene, 
struct Object *ob);
 void BKE_pose_where_is_bone(struct Depsgraph *depsgraph,
                             struct Scene *scene,
diff --git a/source/blender/blenkernel/intern/armature.c 
b/source/blender/blenkernel/intern/armature.c
index 7b8ed47c513..4aa328fcb22 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -2573,6 +2573,19 @@ 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->pose == NULL) || (ob->pose->flag & POSE_RECALC)) {
+    BKE_pose_rebuild(bmain, ob, arm, do_id_user);
+  }
+}
+
 /** \} */
 
 /* -------------------------------------------------------------------- */
@@ -2711,11 +2724,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... */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to