Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-12-19 13:20:32 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-12-19 13:59:47 +0300
commit908a2742403b279cd6dfa5c27acb76d68d3f1523 (patch)
tree8a236ae1edaccb9730aa8099388f2eb7c6175da1 /source/blender/blenkernel/intern/object.c
parentbc8f2e9ee42be09ff196c2e427f52042cff97197 (diff)
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!
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r--source/blender/blenkernel/intern/object.c88
1 files changed, 42 insertions, 46 deletions
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 actual_scene is the scene the object resides in */
void BKE_object_where_is_calc_time_ex(
- Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime,
+ Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime, int dupli_transflag,
RigidBodyWorld *rbw, float r_originmat[3][3])
{
if (ob == NULL) return;
@@ -2269,7 +2257,8 @@ void BKE_object_where_is_calc_time_ex(
float slowmat[4][4];
/* calculate parent matrix */
- solve_parenting(depsgraph, scene, ob, par, ob->obmat, slowmat, r_originmat, true);
+ solve_parenting(ob, par, ob->obmat, slowmat, r_originmat, true,
+ ctime, dupli_transflag);
/* "slow parent" is definitely not threadsafe, and may also give bad results jumping around
* An old-fashioned hack which probably doesn't really cut it anymore
@@ -2303,14 +2292,21 @@ void BKE_object_where_is_calc_time_ex(
void BKE_object_where_is_calc_time(Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime)
{
- BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, ctime, NULL, NULL);
+ BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, ctime, 0, NULL, NULL);
+}
+
+void BKE_object_where_is_calc_time_for_dupli(
+ Depsgraph *depsgraph, Scene *scene, struct Object *ob, float ctime, int dupli_transflag)
+{
+ BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, ctime, dupli_transflag, NULL, NULL);
}
+
/* get object transformation matrix without recalculating dependencies and
* constraints -- assume dependencies are already solved by depsgraph.
* no changes to object and it's parent would be done.
* used for bundles orientation in 3d space relative to parented blender camera */
-void BKE_object_where_is_calc_mat4(Depsgraph *depsgraph, Scene *scene, Object *ob, float obmat[4][4])
+void BKE_object_where_is_calc_mat4(Object *ob, float obmat[4][4])
{
if (ob->parent) {
@@ -2318,7 +2314,7 @@ void BKE_object_where_is_calc_mat4(Depsgraph *depsgraph, Scene *scene, Object *o
Object *par = ob->parent;
- solve_parenting(depsgraph, scene, ob, par, obmat, slowmat, NULL, false);
+ solve_parenting(ob, par, obmat, slowmat, NULL, false, 0.0f, 0);
if (ob->partype & PARSLOW)
where_is_object_parslow(ob, obmat, slowmat);
@@ -2330,11 +2326,11 @@ void BKE_object_where_is_calc_mat4(Depsgraph *depsgraph, Scene *scene, Object *o
void BKE_object_where_is_calc_ex(Depsgraph *depsgraph, Scene *scene, RigidBodyWorld *rbw, Object *ob, float r_originmat[3][3])
{
- BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, DEG_get_ctime(depsgraph), rbw, r_originmat);
+ BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, DEG_get_ctime(depsgraph), 0, rbw, r_originmat);
}
void BKE_object_where_is_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
- BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, DEG_get_ctime(depsgraph), NULL, NULL);
+ BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, DEG_get_ctime(depsgraph), 0, NULL, NULL);
}
/**
@@ -2388,7 +2384,7 @@ void BKE_object_apply_mat4_ex(Object *ob, float mat[4][4], Object *parent, float
if (parent != NULL) {
float rmat[4][4], diff_mat[4][4], imat[4][4], parent_mat[4][4];
- BKE_object_get_parent_matrix(NULL, NULL, ob, parent, parent_mat);
+ BKE_object_get_parent_matrix(ob, parent, parent_mat);
mul_m4_m4m4(diff_mat, parent_mat, parentinv);
invert_m4_m4(imat, diff_mat);