[Bf-blender-cvs] [5e4ed2793b9] blender2.8: Depsgraph: Move boundbox sync to the post-geometry evaluation

Sergey Sharybin noreply at git.blender.org
Wed Nov 21 15:04:34 CET 2018


Commit: 5e4ed2793b9bec3b45830106f83c5bfffa810453
Author: Sergey Sharybin
Date:   Wed Nov 21 15:02:36 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB5e4ed2793b9bec3b45830106f83c5bfffa810453

Depsgraph: Move boundbox sync to the post-geometry evaluation

Boundbox does not depend on transform and only need geometry
component.

This change solves possible race condition accessing geometry
data and allocating/assigning pointers.

Based on disacussion in IRC with @mano-wii and @brecht.

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

M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/intern/armature_update.c
M	source/blender/blenkernel/intern/object_update.c

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

diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index c07ccdf8ee2..f0f99c9cac5 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -247,6 +247,8 @@ void BKE_object_eval_uber_data(
         struct Scene *scene,
         struct Object *ob);
 
+void BKE_object_eval_boundbox(struct Depsgraph *depsgraph, struct Object *object);
+
 void BKE_object_eval_ptcache_reset(
         struct Depsgraph *depsgraph,
         struct Scene *scene,
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index e882b64e8cc..01f1a3f7b55 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -47,6 +47,7 @@
 #include "BKE_curve.h"
 #include "BKE_displist.h"
 #include "BKE_fcurve.h"
+#include "BKE_object.h"
 #include "BKE_scene.h"
 
 #include "BIK_api.h"
@@ -748,12 +749,13 @@ void BKE_pose_splineik_evaluate(struct Depsgraph *depsgraph,
 }
 
 /* Common part for both original and proxy armatrues. */
-static void pose_eval_done_common(Object *object)
+static void pose_eval_done_common(struct Depsgraph *depsgraph, Object *object)
 {
 	bPose *pose = object->pose;
 	UNUSED_VARS_NDEBUG(pose);
 	BLI_assert(pose != NULL);
 	armature_cached_bbone_deformation_update(object);
+	BKE_object_eval_boundbox(depsgraph, object);
 }
 static void pose_eval_cleanup_common(Object *object)
 {
@@ -770,7 +772,7 @@ void BKE_pose_eval_done(struct Depsgraph *depsgraph, Object *object)
 	UNUSED_VARS_NDEBUG(pose);
 	DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
 	BLI_assert(object->type == OB_ARMATURE);
-	pose_eval_done_common(object);
+	pose_eval_done_common(depsgraph, object);
 }
 
 void BKE_pose_eval_cleanup(struct Depsgraph *depsgraph,
@@ -801,7 +803,7 @@ void BKE_pose_eval_proxy_done(struct Depsgraph *depsgraph, Object *object)
 {
 	BLI_assert(ID_IS_LINKED(object) && object->proxy_from != NULL);
 	DEG_debug_print_eval(depsgraph, __func__, object->id.name, object);
-	pose_eval_done_common(object);
+	pose_eval_done_common(depsgraph, object);
 }
 
 void BKE_pose_eval_proxy_cleanup(struct Depsgraph *depsgraph, Object *object)
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index ea6466bf80e..dc144f48b05 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -149,14 +149,6 @@ void BKE_object_eval_transform_final(Depsgraph *depsgraph, Object *ob)
 		copy_m4_m4(ob_orig->constinv, ob->constinv);
 		ob_orig->transflag = ob->transflag;
 		ob_orig->flag = ob->flag;
-
-		BoundBox *bb = BKE_object_boundbox_get(ob);
-		if (bb != NULL) {
-			if (ob_orig->bb == NULL) {
-				ob_orig->bb = MEM_mallocN(sizeof(*ob_orig->bb), __func__);
-			}
-			*ob_orig->bb = *bb;
-		}
 	}
 }
 
@@ -276,8 +268,22 @@ void BKE_object_handle_data_update(
 				psys = psys->next;
 		}
 	}
+	BKE_object_eval_boundbox(depsgraph, ob);
+}
 
-	/* quick cache removed */
+void BKE_object_eval_boundbox(Depsgraph *depsgraph, Object *object)
+{
+	if (!DEG_is_active(depsgraph)) {
+		return;
+	}
+	Object *ob_orig = DEG_get_original_object(object);
+	BoundBox *bb = BKE_object_boundbox_get(object);
+	if (bb != NULL) {
+		if (ob_orig->bb == NULL) {
+			ob_orig->bb = MEM_mallocN(sizeof(*ob_orig->bb), __func__);
+		}
+		*ob_orig->bb = *bb;
+	}
 }
 
 bool BKE_object_eval_proxy_copy(Depsgraph *depsgraph,



More information about the Bf-blender-cvs mailing list