diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-01-09 23:45:53 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-01-13 13:57:51 +0400 |
commit | f00f959d523dc9ae0fe60cf28367dbbe1464e232 (patch) | |
tree | 9fbdacd6b0885ac52607a03acdfa4c42000e58a8 /source/blender/blenkernel/intern/lattice.c | |
parent | f86fbc4ea31f743b8a28d4f91dc2eff209740507 (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/lattice.c')
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 27 |
1 files changed, 11 insertions, 16 deletions
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); |