diff options
-rw-r--r-- | source/blender/blenkernel/BKE_lattice.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 55 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 26 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_array.c | 19 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_curve.c | 4 |
6 files changed, 33 insertions, 78 deletions
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index 52d6dc53808..1cdf193f054 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -63,11 +63,10 @@ bool object_deform_mball(struct Object *ob, struct ListBase *dispbase); void outside_lattice(struct Lattice *lt); void curve_deform_verts( - const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *cuOb, struct Object *target, struct DerivedMesh *dm, float (*vertexCos)[3], - int numVerts, const char *vgroup, short defaxis); -void curve_deform_vector(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *cuOb, struct Object *target, + int numVerts, const char *vgroup, short defaxis); +void curve_deform_vector(struct Object *cuOb, struct Object *target, float orco[3], float vec[3], float mat[3][3], int no_rot_axis); void lattice_deform_verts(struct Object *laOb, struct Object *target, diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index e45e0596f3a..953fef067b4 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2112,7 +2112,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha if (STREQ(pchan->name, amod->channel)) { 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/constraint.c b/source/blender/blenkernel/intern/constraint.c index f7265f0dd9e..d429149f0c4 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -98,11 +98,6 @@ /* Constraint Target Macros */ #define VALID_CONS_TARGET(ct) ((ct) && (ct->tar)) -/* 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 @@ -1242,7 +1237,9 @@ static void followpath_flush_tars(bConstraint *con, ListBase *list, bool no_copy } } -static void followpath_get_tarmat(const struct EvaluationContext *eval_ctx, bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void followpath_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx), + bConstraint *con, bConstraintOb *UNUSED(cob), + bConstraintTarget *ct, float UNUSED(ctime)) { bFollowPathConstraint *data = con->data; @@ -1257,13 +1254,7 @@ static void followpath_get_tarmat(const struct EvaluationContext *eval_ctx, bCon * 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(eval_ctx, cob->scene, ct->tar, false); - } -#endif - - if (ct->tar->curve_cache->path && ct->tar->curve_cache->path->data) { + if (ct->tar->curve_cache && ct->tar->curve_cache->path && ct->tar->curve_cache->path->data) { float quat[4]; if ((data->followflag & FOLLOWPATH_STATIC) == 0) { /* animated position along curve depending on time */ @@ -2024,21 +2015,19 @@ 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(const struct EvaluationContext *eval_ctx, bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void pycon_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx), + bConstraint *con, bConstraintOb *UNUSED(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(eval_ctx, cob->scene, ct->tar, false); - } + if (ct->tar->type == OB_CURVE && ct->tar->curve_cache == NULL) { + unit_m4(ct->matrix); + return; } -#endif /* firstly calculate the matrix the normal way, then let the py-function override * this matrix if it needs to do so @@ -3131,16 +3120,10 @@ static void clampto_flush_tars(bConstraint *con, ListBase *list, bool no_copy) } } -static void clampto_get_tarmat(const struct EvaluationContext *eval_ctx, bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void clampto_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx), + bConstraint *UNUSED(con), bConstraintOb *UNUSED(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(eval_ctx, 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... */ @@ -3806,16 +3789,10 @@ static void splineik_flush_tars(bConstraint *con, ListBase *list, bool no_copy) } } -static void splineik_get_tarmat(const struct EvaluationContext *eval_ctx, bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void splineik_get_tarmat(const struct EvaluationContext *UNUSED(eval_ctx), + bConstraint *UNUSED(con), bConstraintOb *UNUSED(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(eval_ctx, 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... */ diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 0f26f53113f..d92d0d9edbf 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -66,11 +66,6 @@ #include "BKE_deform.h" -/* Workaround for cyclic dependency with curves. - * In such case curve_cache might not be ready yet, - */ -#define CYCLIC_DEPENDENCY_WORKAROUND - int BKE_lattice_index_from_uvw(Lattice *lt, const int u, const int v, const int w) { @@ -603,7 +598,7 @@ static bool where_on_path_deform(Object *ob, float ctime, float vec[4], float di /* co: local coord, result local too */ /* returns quaternion for rotation, using cd->no_rot_axis */ /* axis is using another define!!! */ -static bool calc_curve_deform(const struct EvaluationContext *eval_ctx, Scene *scene, Object *par, float co[3], +static bool calc_curve_deform(Object *par, float co[3], const short axis, CurveDeform *cd, float r_quat[4]) { Curve *cu = par->data; @@ -611,12 +606,10 @@ static bool calc_curve_deform(const struct EvaluationContext *eval_ctx, Scene *s short index; const bool is_neg_axis = (axis > 2); - /* to be sure, mostly after file load, also cyclic dependencies */ -#ifdef CYCLIC_DEPENDENCY_WORKAROUND if (par->curve_cache == NULL) { - BKE_displist_make_curveTypes(eval_ctx, scene, par, false); + /* Happens with a cyclic dependencies. */ + return false; } -#endif if (par->curve_cache->path == NULL) { return false; /* happens on append, cyclic dependencies and empty curves */ @@ -707,7 +700,6 @@ static bool calc_curve_deform(const struct EvaluationContext *eval_ctx, Scene *s } void curve_deform_verts( - const struct EvaluationContext *eval_ctx, Scene *scene, Object *cuOb, Object *target, DerivedMesh *dm, float (*vertexCos)[3], int numVerts, const char *vgroup, short defaxis) { @@ -767,7 +759,7 @@ void curve_deform_verts( if (weight > 0.0f) { mul_m4_v3(cd.curvespace, vertexCos[a]); copy_v3_v3(vec, vertexCos[a]); - calc_curve_deform(eval_ctx, 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]); } @@ -790,7 +782,7 @@ void curve_deform_verts( if (weight > 0.0f) { /* already in 'cd.curvespace', prev for loop */ copy_v3_v3(vec, vertexCos[a]); - calc_curve_deform(eval_ctx, 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]); } @@ -801,7 +793,7 @@ void curve_deform_verts( if (cu->flag & CU_DEFORM_BOUNDS_OFF) { for (a = 0; a < numVerts; a++) { mul_m4_v3(cd.curvespace, vertexCos[a]); - calc_curve_deform(eval_ctx, scene, cuOb, vertexCos[a], defaxis, &cd, NULL); + calc_curve_deform(cuOb, vertexCos[a], defaxis, &cd, NULL); mul_m4_v3(cd.objectspace, vertexCos[a]); } } @@ -816,7 +808,7 @@ void curve_deform_verts( for (a = 0; a < numVerts; a++) { /* already in 'cd.curvespace', prev for loop */ - calc_curve_deform(eval_ctx, scene, cuOb, vertexCos[a], defaxis, &cd, NULL); + calc_curve_deform(cuOb, vertexCos[a], defaxis, &cd, NULL); mul_m4_v3(cd.objectspace, vertexCos[a]); } } @@ -826,7 +818,7 @@ void curve_deform_verts( /* 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(const struct EvaluationContext *eval_ctx, 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; @@ -845,7 +837,7 @@ void curve_deform_vector(const struct EvaluationContext *eval_ctx, Scene *scene, mul_m4_v3(cd.curvespace, vec); - if (calc_curve_deform(eval_ctx, 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); diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 66ff1fe0a85..81ace75f2b1 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -56,12 +56,6 @@ #include "DEG_depsgraph.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; @@ -356,8 +350,7 @@ static void dm_merge_transform( } static DerivedMesh *arrayModifier_doArray( - ArrayModifierData *amd, const EvaluationContext *eval_ctx, - Scene *scene, Object *ob, DerivedMesh *dm, + ArrayModifierData *amd, Object *ob, DerivedMesh *dm, ModifierApplyFlag flag) { const float eps = 1e-6f; @@ -460,12 +453,6 @@ static DerivedMesh *arrayModifier_doArray( if (amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) { Curve *cu = amd->curve_ob->data; if (cu) { -#ifdef CYCLIC_DEPENDENCY_WORKAROUND - if (amd->curve_ob->curve_cache == NULL) { - BKE_displist_make_curveTypes(eval_ctx, scene, amd->curve_ob, false); - } -#endif - if (amd->curve_ob->curve_cache && amd->curve_ob->curve_cache->path) { float scale_fac = mat4_to_scale(amd->curve_ob->obmat); length = scale_fac * amd->curve_ob->curve_cache->path->totdist; @@ -725,12 +712,12 @@ static DerivedMesh *arrayModifier_doArray( } -static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *eval_ctx, +static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *dm, ModifierApplyFlag flag) { ArrayModifierData *amd = (ArrayModifierData *) md; - return arrayModifier_doArray(amd, eval_ctx, md->scene, ob, dm, flag); + return arrayModifier_doArray(amd, ob, dm, flag); } diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c index 198f08334f0..62c9f8796a0 100644 --- a/source/blender/modifiers/intern/MOD_curve.c +++ b/source/blender/modifiers/intern/MOD_curve.c @@ -115,7 +115,7 @@ static void updateDepsgraph(ModifierData *md, DEG_add_object_relation(node, object, DEG_OB_COMP_TRANSFORM, "Curve Modifier"); } -static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_ctx, +static void deformVerts(ModifierData *md, const struct EvaluationContext *UNUSED(eval_ctx), Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, @@ -125,7 +125,7 @@ static void deformVerts(ModifierData *md, const struct EvaluationContext *eval_c /* 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(eval_ctx, md->scene, cmd->object, ob, derivedData, vertexCos, numVerts, + curve_deform_verts(cmd->object, ob, derivedData, vertexCos, numVerts, cmd->name, cmd->defaxis - 1); } |