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-01-09 23:45:53 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-01-13 13:57:51 +0400
commitf00f959d523dc9ae0fe60cf28367dbbe1464e232 (patch)
tree9fbdacd6b0885ac52607a03acdfa4c42000e58a8 /source/blender/blenkernel/intern
parentf86fbc4ea31f743b8a28d4f91dc2eff209740507 (diff)
Remove direct displist creation from curve deform
This solves threading conflict which happens when having multiple objects using Curve Deform modifier with the same curve datablock. This conflict was caused by the fact that curve_deform_verts() used to temporary override curve's flags to make it path is there. Actually, it was setting CU_FOLLOW flag temporary which was only used where_on_path() (only in terms that this temporary assignment only affected this function) but it is now commented out for a while, so no reason to set this flag temporary, If it's ever to be done, we'll need to pass flags as an additional function argument. For the path creation i've extended DegNode structure which now holds extra bits which indicates what additional data depending on the graph topology is to be evaluated. Currently this is only used to indicate that curve needs path to be evaluated regardless to cu->flag state. This is so Curve Deform modifier is always happy. In the future this flag might also be used to indicate whether bmesh verts are to update (see recent commit to 3-vertex parent crash fix) or to indicate that the object is the motherball etc.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/anim.c7
-rw-r--r--source/blender/blenkernel/intern/armature.c2
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c7
-rw-r--r--source/blender/blenkernel/intern/displist.c9
-rw-r--r--source/blender/blenkernel/intern/lattice.c27
5 files changed, 32 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 0d7a1f9b46c..4278adc2ae9 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -654,7 +654,12 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
p2 = pp + s2;
p3 = pp + s3;
- /* note, commented out for follow constraint */
+ /* NOTE: commented out for follow constraint
+ *
+ * If it's ever be uncommented watch out for curve_deform_verts()
+ * which used to temporary set CU_FOLLOW flag for the curve and no
+ * longer does it (because of threading issues of such a thing.
+ */
//if (cu->flag & CU_FOLLOW) {
key_curve_tangent_weights(1.0f - fac, data, KEY_BSPLINE);
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 0267c9a6122..b0e720fc845 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -2310,7 +2310,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha
if (strcmp(pchan->name, amod->channel) == 0) {
float mat4[4][4], mat3[3][3];
- curve_deform_vector(scene, amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis);
+ curve_deform_vector(amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis);
copy_m4_m4(mat4, pchan->pose_mat);
mul_m4_m3m4(pchan->pose_mat, mat3, mat4);
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index d52752c364c..13f0c2977c2 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -2844,3 +2844,10 @@ const char *DAG_get_node_name(void *node_v)
return dag_node_name(node);
}
+
+short DAG_get_eval_flags_for_object(struct Scene *scene, void *object)
+{
+ DagNode *node = dag_get_node(scene->theDag, object);
+ return node->eval_flags;
+}
+
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 402acf5806c..88791930e0e 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -1566,8 +1566,13 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
curve_to_filledpoly(cu, &nubase, dispbase);
}
- if ((cu->flag & CU_PATH) && !forOrco)
- calc_curvepath(ob, &nubase);
+ if (!forOrco) {
+ if ((cu->flag & CU_PATH) ||
+ DAG_get_eval_flags_for_object(scene, ob) & DAG_EVAL_NEED_CURVE_PATH)
+ {
+ calc_curvepath(ob, &nubase);
+ }
+ }
if (!forOrco)
curve_calc_modifiers_post(scene, ob, &nubase, dispbase, derivedFinal, forRender, renderResolution);
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 850636e986c..8f7942f543a 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -614,7 +614,7 @@ static int where_on_path_deform(Object *ob, float ctime, float vec[4], float dir
/* co: local coord, result local too */
/* returns quaternion for rotation, using cd->no_rot_axis */
/* axis is using another define!!! */
-static int calc_curve_deform(Scene *scene, Object *par, float co[3],
+static int calc_curve_deform(Object *par, float co[3],
const short axis, CurveDeform *cd, float quat_r[4])
{
Curve *cu = par->data;
@@ -623,9 +623,8 @@ static int calc_curve_deform(Scene *scene, Object *par, float co[3],
const int is_neg_axis = (axis > 2);
/* to be sure, mostly after file load */
- if (ELEM(NULL, par->curve_cache, par->curve_cache->path)) {
- BKE_displist_make_curveTypes(scene, par, 0);
- if (par->curve_cache->path == NULL) return 0; // happens on append...
+ if (par->curve_cache->path == NULL) {
+ return 0; // happens on append...
}
/* options */
@@ -705,12 +704,11 @@ static int calc_curve_deform(Scene *scene, Object *par, float co[3],
return 0;
}
-void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
- DerivedMesh *dm, float (*vertexCos)[3],
+void curve_deform_verts(Object *cuOb, Object *target, DerivedMesh *dm, float (*vertexCos)[3],
int numVerts, const char *vgroup, short defaxis)
{
Curve *cu;
- int a, flag;
+ int a;
CurveDeform cd;
int use_vgroups;
const int is_neg_axis = (defaxis > 2);
@@ -719,8 +717,6 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
return;
cu = cuOb->data;
- flag = cu->flag;
- cu->flag |= (CU_PATH | CU_FOLLOW); // needed for path & bevlist
init_curve_deform(cuOb, target, &cd);
@@ -772,7 +768,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
if (weight > 0.0f) {
mul_m4_v3(cd.curvespace, vertexCos[a]);
copy_v3_v3(vec, vertexCos[a]);
- calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
+ calc_curve_deform(cuOb, vec, defaxis, &cd, NULL);
interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
mul_m4_v3(cd.objectspace, vertexCos[a]);
}
@@ -800,7 +796,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
if (weight > 0.0f) {
/* already in 'cd.curvespace', prev for loop */
copy_v3_v3(vec, vertexCos[a]);
- calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
+ calc_curve_deform(cuOb, vec, defaxis, &cd, NULL);
interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
mul_m4_v3(cd.objectspace, vertexCos[a]);
}
@@ -812,7 +808,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
if (cu->flag & CU_DEFORM_BOUNDS_OFF) {
for (a = 0; a < numVerts; a++) {
mul_m4_v3(cd.curvespace, vertexCos[a]);
- calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
+ calc_curve_deform(cuOb, vertexCos[a], defaxis, &cd, NULL);
mul_m4_v3(cd.objectspace, vertexCos[a]);
}
}
@@ -827,18 +823,17 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
for (a = 0; a < numVerts; a++) {
/* already in 'cd.curvespace', prev for loop */
- calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
+ calc_curve_deform(cuOb, vertexCos[a], defaxis, &cd, NULL);
mul_m4_v3(cd.objectspace, vertexCos[a]);
}
}
}
- cu->flag = flag;
}
/* input vec and orco = local coord in armature space */
/* orco is original not-animated or deformed reference point */
/* result written in vec and mat */
-void curve_deform_vector(Scene *scene, Object *cuOb, Object *target,
+void curve_deform_vector(Object *cuOb, Object *target,
float orco[3], float vec[3], float mat[3][3], int no_rot_axis)
{
CurveDeform cd;
@@ -857,7 +852,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target,
mul_m4_v3(cd.curvespace, vec);
- if (calc_curve_deform(scene, cuOb, vec, target->trackflag, &cd, quat)) {
+ if (calc_curve_deform(cuOb, vec, target->trackflag, &cd, quat)) {
float qmat[3][3];
quat_to_mat3(qmat, quat);