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/modifiers
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/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_array.c18
-rw-r--r--source/blender/modifiers/intern/MOD_curve.c2
2 files changed, 16 insertions, 4 deletions
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index d2c44cd1281..1f233cc5492 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -65,6 +65,12 @@
#include <stdlib.h>
#include <string.h>
+/* Due to cyclic dependencies it's possible that curve used for
+ * deformation here is not evaluated at the time of evaluating
+ * this modifier.
+ */
+#define CYCLIC_DEPENDENCY_WORKAROUND
+
static void initData(ModifierData *md)
{
ArrayModifierData *amd = (ArrayModifierData *) md;
@@ -322,7 +328,7 @@ static void merge_first_last(BMesh *bm,
}
static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
- Object *ob, DerivedMesh *dm,
+ Scene *scene, Object *ob, DerivedMesh *dm,
ModifierApplyFlag flag)
{
DerivedMesh *result;
@@ -377,7 +383,13 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
if (amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) {
Curve *cu = amd->curve_ob->data;
if (cu) {
- if (amd->curve_ob->curve_cache->path) {
+#ifdef CYCLIC_DEPENDENCY_WORKAROUND
+ if (amd->curve_ob->curve_cache == NULL) {
+ BKE_displist_make_curveTypes(scene, amd->curve_ob, FALSE);
+ }
+#endif
+
+ if (amd->curve_ob->curve_cache && amd->curve_ob->curve_cache->path) {
float scale = mat4_to_scale(amd->curve_ob->obmat);
length = scale * amd->curve_ob->curve_cache->path->totdist;
}
@@ -575,7 +587,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
DerivedMesh *result;
ArrayModifierData *amd = (ArrayModifierData *) md;
- result = arrayModifier_doArray(amd, ob, dm, flag);
+ result = arrayModifier_doArray(amd, md->scene, ob, dm, flag);
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index 760fa8ffbe8..792fc7e7cf8 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -120,7 +120,7 @@ static void deformVerts(ModifierData *md, Object *ob,
/* silly that defaxis and curve_deform_verts are off by 1
* but leave for now to save having to call do_versions */
- curve_deform_verts(cmd->object, ob, derivedData, vertexCos, numVerts,
+ curve_deform_verts(md->scene, cmd->object, ob, derivedData, vertexCos, numVerts,
cmd->name, cmd->defaxis - 1);
}