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>2014-02-24 17:12:40 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-02-24 17:15:52 +0400
commit1130c53cdb24b68d1871a03bad59fad9e6418f29 (patch)
tree0e299fee380152e7101e783d0240afead80a3d56 /source/blender/blenkernel/intern/constraint.c
parentb5aef37c27f5fb2a4bb4227253f81d886ddd796c (diff)
Fix T38755: Crash when having cyclic dependency and curve deform
Issue was caused by undefined object update order and in some cases NULL pointer will be de-referenced. Added on-demand curve path calculation, just the same creepy call of BKE_displist_make_curveTypes(). This violates DAG and might end up in a difficult to troubleshoot race condition if there'll be some issues with how dependencies are calculated in DAG, but this is the easiest and safest way to solve the bug at this stage,
Diffstat (limited to 'source/blender/blenkernel/intern/constraint.c')
-rw-r--r--source/blender/blenkernel/intern/constraint.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 1397a7d4824..30e0c311503 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -89,6 +89,11 @@
# include "BPY_extern.h"
#endif
+/* Workaround for cyclic depenndnecy with curves.
+ * In such case curve_cache might not be ready yet,
+ */
+#define CYCLIC_DEPENDENCY_WORKAROUND
+
/* ************************ Constraints - General Utilities *************************** */
/* These functions here don't act on any specific constraints, and are therefore should/will
* not require any of the special function-pointers afforded by the relevant constraint
@@ -1146,7 +1151,7 @@ static void followpath_flush_tars(bConstraint *con, ListBase *list, short nocopy
}
}
-static void followpath_get_tarmat(bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
+static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{
bFollowPathConstraint *data = con->data;
@@ -1162,6 +1167,12 @@ static void followpath_get_tarmat(bConstraint *con, bConstraintOb *UNUSED(cob),
* currently for paths to work it needs to go through the bevlist/displist system (ton)
*/
+#ifdef CYCLIC_DEPENDENCY_WORKAROUND
+ if (ct->tar->curve_cache == NULL) {
+ BKE_displist_make_curveTypes(cob->scene, ct->tar, FALSE);
+ }
+#endif
+
if (ct->tar->curve_cache->path && ct->tar->curve_cache->path->data) {
float quat[4];
if ((data->followflag & FOLLOWPATH_STATIC) == 0) {
@@ -1920,13 +1931,22 @@ static void pycon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userd
}
/* Whether this approach is maintained remains to be seen (aligorith) */
-static void pycon_get_tarmat(bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
+static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{
#ifdef WITH_PYTHON
bPythonConstraint *data = con->data;
#endif
if (VALID_CONS_TARGET(ct)) {
+#ifdef CYCLIC_DEPENDENCY_WORKAROUND
+ /* special exception for curves - depsgraph issues */
+ if (ct->tar->type == OB_CURVE) {
+ if (ct->tar->curve_cache == NULL) {
+ BKE_displist_make_curveTypes(cob->scene, ct->tar, FALSE);
+ }
+ }
+#endif
+
/* firstly calculate the matrix the normal way, then let the py-function override
* this matrix if it needs to do so
*/
@@ -2993,8 +3013,16 @@ static void clampto_flush_tars(bConstraint *con, ListBase *list, short nocopy)
}
}
-static void clampto_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
+static void clampto_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{
+#ifdef CYCLIC_DEPENDENCY_WORKAROUND
+ if (VALID_CONS_TARGET(ct)) {
+ if (ct->tar->curve_cache == NULL) {
+ BKE_displist_make_curveTypes(cob->scene, ct->tar, FALSE);
+ }
+ }
+#endif
+
/* technically, this isn't really needed for evaluation, but we don't know what else
* might end up calling this...
*/
@@ -3648,8 +3676,16 @@ static void splineik_flush_tars(bConstraint *con, ListBase *list, short nocopy)
}
}
-static void splineik_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
+static void splineik_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{
+#ifdef CYCLIC_DEPENDENCY_WORKAROUND
+ if (VALID_CONS_TARGET(ct)) {
+ if (ct->tar->curve_cache == NULL) {
+ BKE_displist_make_curveTypes(cob->scene, ct->tar, FALSE);
+ }
+ }
+#endif
+
/* technically, this isn't really needed for evaluation, but we don't know what else
* might end up calling this...
*/