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
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')
-rw-r--r--source/blender/blenkernel/intern/constraint.c6
-rw-r--r--source/blender/blenkernel/intern/object.c88
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c27
-rw-r--r--source/blender/blenkernel/intern/object_update.c8
-rw-r--r--source/blender/blenkernel/intern/tracking.c4
5 files changed, 59 insertions, 74 deletions
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 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);
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 882ec07f56a..6cd0f412d06 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -317,9 +317,7 @@ static void make_duplis_frames(const DupliContext *ctx)
Depsgraph *depsgraph = ctx->depsgraph;
Scene *scene = ctx->scene;
Object *ob = ctx->object;
- extern int enable_cu_speed; /* object.c */
Object copyob;
- int cfrao = scene->r.cfra;
int dupend = ob->dupend;
/* dupliframes not supported inside collections */
@@ -339,16 +337,15 @@ static void make_duplis_frames(const DupliContext *ctx)
copyob = *ob;
/* duplicate over the required range */
- if (ob->transflag & OB_DUPLINOSPEED) enable_cu_speed = 0;
-
- for (scene->r.cfra = ob->dupsta; scene->r.cfra <= dupend; scene->r.cfra++) {
+ const int dupli_transflag = (ob->transflag & OB_DUPLINOSPEED);
+ for (int frame = ob->dupsta; frame <= dupend; frame++) {
int ok = 1;
/* - dupoff = how often a frames within the range shouldn't be made into duplis
* - dupon = the length of each "skipping" block in frames
*/
if (ob->dupoff) {
- ok = scene->r.cfra - ob->dupsta;
+ ok = frame - ob->dupsta;
ok = ok % (ob->dupon + ob->dupoff);
ok = (ok < ob->dupon);
}
@@ -359,23 +356,17 @@ static void make_duplis_frames(const DupliContext *ctx)
* However, this has always been the way that this worked (i.e. pre 2.5), so I guess that it'll be fine!
*/
/* ob-eval will do drivers, so we don't need to do them */
- BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM);
- BKE_object_where_is_calc_time(depsgraph, scene, ob, (float)scene->r.cfra);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, (float)frame, ADT_RECALC_ANIM);
+ BKE_object_where_is_calc_time_for_dupli(depsgraph, scene, ob, (float)frame, dupli_transflag);
- make_dupli(ctx, ob, ob->obmat, scene->r.cfra);
+ make_dupli(ctx, ob, ob->obmat, frame);
}
}
- enable_cu_speed = 1;
-
- /* reset frame to original frame, then re-evaluate animation as above
- * as 2.5 animation data may have far-reaching consequences
- */
- scene->r.cfra = cfrao;
-
/* ob-eval will do drivers, so we don't need to do them */
- BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM);
- BKE_object_where_is_calc_time(depsgraph, scene, ob, (float)scene->r.cfra);
+ const float original_ctime = DEG_get_ctime(depsgraph);
+ BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, original_ctime, ADT_RECALC_ANIM);
+ BKE_object_where_is_calc_time(depsgraph, scene, ob, original_ctime);
/* but, to make sure unkeyed object transforms are still sane,
* let's copy object's original data back over
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index cbc67e23d66..a159e713d01 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -92,9 +92,7 @@ void BKE_object_eval_local_transform(Depsgraph *depsgraph, Object *ob)
/* Evaluate parent */
/* NOTE: based on solve_parenting(), but with the cruft stripped out */
-void BKE_object_eval_parent(Depsgraph *depsgraph,
- Scene *scene,
- Object *ob)
+void BKE_object_eval_parent(Depsgraph *depsgraph, Object *ob)
{
Object *par = ob->parent;
@@ -109,7 +107,7 @@ void BKE_object_eval_parent(Depsgraph *depsgraph,
copy_m4_m4(locmat, ob->obmat);
/* get parent effect matrix */
- BKE_object_get_parent_matrix(depsgraph, scene, ob, par, totmat);
+ BKE_object_get_parent_matrix(ob, par, totmat);
/* total */
mul_m4_m4m4(tmat, totmat, ob->parentinv);
@@ -397,7 +395,7 @@ void BKE_object_eval_transform_all(Depsgraph *depsgraph,
/* This mimics full transform update chain from new depsgraph. */
BKE_object_eval_local_transform(depsgraph, object);
if (object->parent != NULL) {
- BKE_object_eval_parent(depsgraph, scene, object);
+ BKE_object_eval_parent(depsgraph, object);
}
if (!BLI_listbase_is_empty(&object->constraints)) {
BKE_object_eval_constraints(depsgraph, scene, object);
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index f19f27c85a7..70f217aa6c2 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -399,7 +399,7 @@ MovieTrackingReconstruction *BKE_tracking_get_active_reconstruction(MovieTrackin
/* Get transformation matrix for a given object which is used
* for parenting motion tracker reconstruction to 3D world.
*/
-void BKE_tracking_get_camera_object_matrix(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float mat[4][4])
+void BKE_tracking_get_camera_object_matrix(Scene *scene, Object *ob, float mat[4][4])
{
if (!ob) {
if (scene->camera)
@@ -409,7 +409,7 @@ void BKE_tracking_get_camera_object_matrix(struct Depsgraph *depsgraph, Scene *s
}
if (ob)
- BKE_object_where_is_calc_mat4(depsgraph, scene, ob, mat);
+ BKE_object_where_is_calc_mat4(ob, mat);
else
unit_m4(mat);
}