[Bf-blender-cvs] [908a2742403] blender2.8: Fix T59237: Instancing on a path doesn't do anything

Sergey Sharybin noreply at git.blender.org
Wed Dec 19 12:10:19 CET 2018


Commit: 908a2742403b279cd6dfa5c27acb76d68d3f1523
Author: Sergey Sharybin
Date:   Wed Dec 19 11:20:32 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB908a2742403b279cd6dfa5c27acb76d68d3f1523

Fix T59237: Instancing on a path doesn't do anything

This commit makes it so curve path parent solving accepts an explicit
arguments for both time and curve speed flag, making it so we don't
have to mock around with scene's frame.

One unfortunate issue still is that if the instancing object is used
for something else, we might be running into a threading conflict.
Possible solution would be to create a temp copy of an object, but
then it will be an issue of preventing drivers from modifying other
datablocks.

At least the original issue is fixed now, and things behave same as
in older Blender version. Additionally, the global variable which
was defining curve speed flag behavior is gone now!

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

M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/BKE_tracking.h
M	source/blender/blenkernel/intern/constraint.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/blenkernel/intern/tracking.c
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/draw/modes/object_mode.c
M	source/blender/editors/space_clip/tracking_ops_orient.c
M	source/blender/editors/space_view3d/view3d_snap.c
M	source/blender/editors/transform/transform_snap_object.c

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

diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index fbef5b6485c..0b405b52a17 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -157,8 +157,9 @@ struct Base **BKE_object_pose_base_array_get_unique(struct ViewLayer *view_layer
 struct Base **BKE_object_pose_base_array_get(struct ViewLayer *view_layer, struct View3D *v3d, unsigned int *r_bases_len);
 
 void BKE_object_get_parent_matrix(
-        struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
-        struct Object *par, float parentmat[4][4]);
+        struct Object *ob, struct Object *par, float parentmat[4][4]);
+void BKE_object_get_parent_matrix_for_dupli(
+        struct Object *ob, struct Object *par, float dupli_ctime, int dupli_transflag, float parentmat[4][4]);
 void BKE_object_where_is_calc(
         struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
 void BKE_object_where_is_calc_ex(
@@ -166,11 +167,12 @@ void BKE_object_where_is_calc_ex(
         struct Object *ob, float r_originmat[3][3]);
 void BKE_object_where_is_calc_time(
         struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime);
+void BKE_object_where_is_calc_time_for_dupli(
+        struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime, int dupli_transflag);
 void BKE_object_where_is_calc_time_ex(
-        struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime,
+        struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime, int dupli_transflag,
         struct RigidBodyWorld *rbw, float r_originmat[3][3]);
-void BKE_object_where_is_calc_mat4(
-        struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float obmat[4][4]);
+void BKE_object_where_is_calc_mat4(struct Object *ob, float obmat[4][4]);
 
 /* possibly belong in own moduke? */
 struct BoundBox *BKE_boundbox_alloc_unit(void);
@@ -231,7 +233,6 @@ void BKE_object_eval_local_transform(
         struct Object *ob);
 void BKE_object_eval_parent(
         struct Depsgraph *depsgraph,
-        struct Scene *scene,
         struct Object *ob);
 void BKE_object_eval_constraints(
         struct Depsgraph *depsgraph,
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index 0c3b118d947..7a70f945194 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -63,7 +63,7 @@ struct MovieTrackingReconstruction *BKE_tracking_get_active_reconstruction(struc
 
 /* matrices for constraints and drawing */
 void BKE_tracking_get_camera_object_matrix(
-        struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float mat[4][4]);
+        struct Scene *scene, struct Object *ob, float mat[4][4]);
 void BKE_tracking_get_projection_matrix(struct MovieTracking *tracking, struct MovieTrackingObject *object,
                                         int framenr, int winx, int winy, float mat[4][4]);
 
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index a1bc7aca6e1..57d77f797ee 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -4247,7 +4247,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
 				translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
 			}
 			else {
-				BKE_tracking_get_camera_object_matrix(depsgraph, cob->scene, camob_eval, mat);
+				BKE_tracking_get_camera_object_matrix(cob->scene, camob_eval, mat);
 
 				mul_m4_m4m4(cob->matrix, obmat, mat);
 				translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
@@ -4259,7 +4259,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
 		float aspect = (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp);
 		float len, d;
 
-		BKE_object_where_is_calc_mat4(depsgraph, scene, camob_eval, mat);
+		BKE_object_where_is_calc_mat4(camob_eval, mat);
 
 		/* camera axis */
 		vec[0] = 0.0f;
@@ -4521,7 +4521,7 @@ static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
 			float ctime = DEG_get_ctime(depsgraph);
 			float framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, ctime);
 
-			BKE_object_where_is_calc_mat4(depsgraph, scene, camob, cammat);
+			BKE_object_where_is_calc_mat4(camob, cammat);
 
 			BKE_tracking_camera_get_reconstructed_interpolate(tracking, object, framenr, mat);
 
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 921a3602c08..3d341f5d82f 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1891,7 +1891,7 @@ void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4])
 	if (ob->parent) {
 		float par_imat[4][4];
 
-		BKE_object_get_parent_matrix(NULL, NULL, ob, ob->parent, par_imat);
+		BKE_object_get_parent_matrix(ob, ob->parent, par_imat);
 		invert_m4(par_imat);
 		mul_m4_m4m4(mat, par_imat, ob->obmat);
 	}
@@ -1900,40 +1900,33 @@ void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4])
 	}
 }
 
-/* extern */
-int enable_cu_speed = 1;
-
 /**
  * \param depsgraph: Used for dupli-frame time.
  * \return success if \a mat is set.
  */
-static bool ob_parcurve(Depsgraph *depsgraph, Scene *UNUSED(scene), Object *ob, Object *par, float mat[4][4])
+static bool ob_parcurve(Object *ob, Object *par,
+                        float dupli_ctime, int dupli_transflag, float mat[4][4])
 {
 	Curve *cu = par->data;
 	float vec[4], dir[3], quat[4], radius, ctime;
 
-	/* TODO: Make sure this doesn't crash. */
-#if 0
-	/* only happens on reload file, but violates depsgraph still... fix! */
-	if (par->curve_cache == NULL) {
-		if (scene == NULL) {
-			return false;
-		}
-		BKE_displist_make_curveTypes(depsgraph, scene, par, 0);
-	}
-#else
-	/* See: T56619 */
+	/* NOTE: Curve cache is supposed to be evaluated here already, however there
+	 * are cases where we can not guarantee that. This includes, for example,
+	 * dependency cycles. We can't correct anything from here, since that would
+	 * cause a threading conflicts.
+	 *
+	 * TODO(sergey): Somce of the legit looking cases like T56619 need to be
+	 * looked into, and maybe curve cache (and other dependencies) are to be
+	 * evaluated prior to conversion. */
 	if (par->runtime.curve_cache == NULL) {
 		return false;
 	}
-#endif
-
 	if (par->runtime.curve_cache->path == NULL) {
 		return false;
 	}
 
 	/* catch exceptions: curve paths used as a duplicator */
-	if (enable_cu_speed) {
+	if ((dupli_transflag & OB_DUPLINOSPEED) == 0) {
 		/* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated,
 		 * but this will only work if it actually is animated...
 		 *
@@ -1946,20 +1939,13 @@ static bool ob_parcurve(Depsgraph *depsgraph, Scene *UNUSED(scene), Object *ob,
 		else {
 			ctime = cu->ctime;
 		}
-
 		CLAMP(ctime, 0.0f, 1.0f);
 	}
 	else {
-		/* For dupli-frames only */
-		if (depsgraph == NULL) {
-			return false;
-		}
-
-		ctime = DEG_get_ctime(depsgraph);
+		ctime = dupli_ctime;
 		if (cu->pathlen) {
 			ctime /= cu->pathlen;
 		}
-
 		CLAMP(ctime, 0.0f, 1.0f);
 	}
 
@@ -1967,22 +1953,18 @@ static bool ob_parcurve(Depsgraph *depsgraph, Scene *UNUSED(scene), Object *ob,
 
 	/* vec: 4 items! */
 	if (where_on_path(par, ctime, vec, dir, (cu->flag & CU_FOLLOW) ? quat : NULL, &radius, NULL)) {
-
 		if (cu->flag & CU_FOLLOW) {
 			quat_apply_track(quat, ob->trackflag, ob->upflag);
 			normalize_qt(quat);
 			quat_to_mat4(mat, quat);
 		}
-
 		if (cu->flag & CU_PATH_RADIUS) {
 			float tmat[4][4], rmat[4][4];
 			scale_m4_fl(tmat, radius);
 			mul_m4_m4m4(rmat, tmat, mat);
 			copy_m4_m4(mat, rmat);
 		}
-
 		copy_v3_v3(mat[3], vec);
-
 	}
 
 	return true;
@@ -2152,8 +2134,9 @@ static void ob_parvert3(Object *ob, Object *par, float mat[4][4])
 	}
 }
 
-
-void BKE_object_get_parent_matrix(Depsgraph *depsgraph, Scene *scene, Object *ob, Object *par, float parentmat[4][4])
+void BKE_object_get_parent_matrix_for_dupli(Object *ob, Object *par,
+                                            float dupli_ctime, int dupli_transflag,
+                                            float parentmat[4][4])
 {
 	float tmat[4][4];
 	float vec[3];
@@ -2164,7 +2147,7 @@ void BKE_object_get_parent_matrix(Depsgraph *depsgraph, Scene *scene, Object *ob
 			ok = 0;
 			if (par->type == OB_CURVE) {
 				if ((((Curve *)par->data)->flag & CU_PATH) &&
-				    (ob_parcurve(depsgraph, scene, ob, par, tmat)))
+				    (ob_parcurve(ob, par, dupli_ctime, dupli_transflag, tmat)))
 				{
 					ok = 1;
 				}
@@ -2197,12 +2180,17 @@ void BKE_object_get_parent_matrix(Depsgraph *depsgraph, Scene *scene, Object *ob
 
 }
 
+void BKE_object_get_parent_matrix(Object *ob, Object *par, float parentmat[4][4])
+{
+	BKE_object_get_parent_matrix_for_dupli(ob, par, 0, 0, parentmat);
+}
+
 /**
  * \param r_originmat: Optional matrix that stores the space the object is in (without its own matrix applied)
  */
-static void solve_parenting(Depsgraph *depsgraph,
-                            Scene *scene, Object *ob, Object *par, float obmat[4][4], float slowmat[4][4],
-                            float r_originmat[3][3], const bool set_origin)
+static void solve_parenting(Object *ob, Object *par, float obmat[4][4], float slowmat[4][4],
+                            float r_originmat[3][3], const bool set_origin,
+                            float dupli_ctime, int dupli_transflag)
 {
 	float totmat[4][4];
 	float tmat[4][4];
@@ -2212,7 +2200,7 @@ static void solve_parenting(Depsgraph *depsgraph,
 
 	if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat);
 
-	BKE_object_get_parent_matrix(depsgraph, scene, ob, par, totmat);
+	BKE_object_get_parent_matrix_for_dupli(ob, par, dupli_ctime, dupli_transflag, totmat);
 
 	/* total */
 	mul_m4_m4m4(tmat, totmat, ob->parentinv);
@@ -2256,7 +2244,7 @@ static bool where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat
 
 /* note, scene is the active scene while actua

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list