diff options
Diffstat (limited to 'source/blender/blenkernel/intern/constraint.c')
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 94 |
1 files changed, 48 insertions, 46 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 2f3a18cd163..66147c44352 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -452,10 +452,10 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[ /* derive the rotation from the average normal: - * - code taken from transform_manipulator.c, - * calc_manipulator_stats, V3D_MANIP_NORMAL case + * - code taken from transform_manipulator.c, + * calc_manipulator_stats, V3D_MANIP_NORMAL case */ - /* we need the transpose of the inverse for a normal... */ + /* we need the transpose of the inverse for a normal... */ copy_m3_m4(imat, ob->obmat); invert_m3_m3(tmat, imat); @@ -543,7 +543,7 @@ static void contarget_get_lattice_mat(Object *ob, const char *substring, float m /* The cases where the target can be object data have not been implemented */ static void constraint_target_to_mat4(Object *ob, const char *substring, float mat[4][4], short from, short to, short flag, float headtail) { - /* Case OBJECT */ + /* Case OBJECT */ if (substring[0] == '\0') { copy_m4_m4(mat, ob->obmat); BKE_constraint_mat_convertspace(ob, NULL, mat, from, to, false); @@ -555,7 +555,7 @@ static void constraint_target_to_mat4(Object *ob, const char *substring, float m * 'average' vertex normal, and deriving the rotation from that. * * NOTE: EditMode is not currently supported, and will most likely remain that - * way as constraints can only really affect things on object/bone level. + * way as constraints can only really affect things on object/bone level. */ else if (ob->type == OB_MESH) { contarget_get_mesh_mat(ob, substring, mat); @@ -565,7 +565,7 @@ static void constraint_target_to_mat4(Object *ob, const char *substring, float m contarget_get_lattice_mat(ob, substring, mat); BKE_constraint_mat_convertspace(ob, NULL, mat, from, to, false); } - /* Case BONE */ + /* Case BONE */ else { bPoseChannel *pchan; @@ -659,15 +659,15 @@ static void constraint_target_to_mat4(Object *ob, const char *substring, float m */ /* Template for type-info data: - * - make a copy of this when creating new constraints, and just change the functions - * pointed to as necessary - * - although the naming of functions doesn't matter, it would help for code - * readability, to follow the same naming convention as is presented here - * - any functions that a constraint doesn't need to define, don't define - * for such cases, just use NULL - * - these should be defined after all the functions have been defined, so that - * forward-definitions/prototypes don't need to be used! - * - keep this copy #if-def'd so that future constraints can get based off this + * - make a copy of this when creating new constraints, and just change the functions + * pointed to as necessary + * - although the naming of functions doesn't matter, it would help for code + * readability, to follow the same naming convention as is presented here + * - any functions that a constraint doesn't need to define, don't define + * for such cases, just use NULL + * - these should be defined after all the functions have been defined, so that + * forward-definitions/prototypes don't need to be used! + * - keep this copy #if-def'd so that future constraints can get based off this */ #if 0 static bConstraintTypeInfo CTI_CONSTRNAME = { @@ -1257,7 +1257,7 @@ static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstra unit_m4(ct->matrix); /* note: when creating constraints that follow path, the curve gets the CU_PATH set now, - * currently for paths to work it needs to go through the bevlist/displist system (ton) + * currently for paths to work it needs to go through the bevlist/displist system (ton) */ #ifdef CYCLIC_DEPENDENCY_WORKAROUND @@ -2163,9 +2163,9 @@ static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintT /* determine where in transform range target is */ /* data->type is mapped as follows for backwards compatibility: - * 00,01,02 - rotation (it used to be like this) - * 10,11,12 - scaling - * 20,21,22 - location + * 00,01,02 - rotation (it used to be like this) + * 10,11,12 - scaling + * 20,21,22 - location */ if (data->type < 10) { /* extract rotation (is in whatever space target should be in) */ @@ -2209,7 +2209,7 @@ static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintT bPoseChannel *pchan, *tchan; /* make a copy of the bone of interest in the temp pose before evaluating action, so that it can get set - * - we need to manually copy over a few settings, including rotation order, otherwise this fails + * - we need to manually copy over a few settings, including rotation order, otherwise this fails */ pchan = cob->pchan; @@ -2764,12 +2764,14 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t normalize_v3_v3(zz, cob->matrix[2]); /* XXX That makes the constraint buggy with asymmetrically scaled objects, see #29940. */ -/* sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]);*/ -/* vec[0] /= size[0];*/ -/* vec[1] /= size[1];*/ -/* vec[2] /= size[2];*/ +#if 0 + sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]); + vec[0] /= size[0]; + vec[1] /= size[1]; + vec[2] /= size[2]; -/* dist = normalize_v3(vec);*/ + dist = normalize_v3(vec); +#endif dist = len_v3v3(cob->matrix[3], ct->matrix[3]); /* Only Y constrained object axis scale should be used, to keep same length when scaling it. */ @@ -3678,9 +3680,9 @@ static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t float rmat[3][3], tmat[4][4]; /* find the (unit) direction that the axis we're interested in currently points - * - mul_mat3_m4_v3() only takes the 3x3 (rotation+scaling) components of the 4x4 matrix - * - the normalization step at the end should take care of any unwanted scaling - * left over in the 3x3 matrix we used + * - mul_mat3_m4_v3() only takes the 3x3 (rotation+scaling) components of the 4x4 matrix + * - the normalization step at the end should take care of any unwanted scaling + * left over in the 3x3 matrix we used */ copy_v3_v3(obvec, track_dir_vecs[data->trackflag]); mul_mat3_m4_v3(cob->matrix, obvec); @@ -3703,11 +3705,11 @@ static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t /* determine the axis-angle rotation, which represents the smallest possible rotation * between the two rotation vectors (i.e. the 'damping' referred to in the name) - * - we take this to be the rotation around the normal axis/vector to the plane defined - * by the current and destination vectors, which will 'map' the current axis to the - * destination vector - * - the min/max wrappers around (obvec . tarvec) result (stored temporarily in rangle) - * are used to ensure that the smallest angle is chosen + * - we take this to be the rotation around the normal axis/vector to the plane defined + * by the current and destination vectors, which will 'map' the current axis to the + * destination vector + * - the min/max wrappers around (obvec . tarvec) result (stored temporarily in rangle) + * are used to ensure that the smallest angle is chosen */ cross_v3_v3v3_hi_prec(raxis, obvec, tarvec); @@ -3715,15 +3717,15 @@ static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t rangle = acosf(max_ff(-1.0f, min_ff(1.0f, rangle))); /* construct rotation matrix from the axis-angle rotation found above - * - this call takes care to make sure that the axis provided is a unit vector first + * - this call takes care to make sure that the axis provided is a unit vector first */ float norm = normalize_v3(raxis); if (norm < FLT_EPSILON) { /* if dot product is nonzero, while cross is zero, we have two opposite vectors! - * - this is an ambiguity in the math that needs to be resolved arbitrarily, - * or there will be a case where damped track strangely does nothing - * - to do that, rotate around a different local axis + * - this is an ambiguity in the math that needs to be resolved arbitrarily, + * or there will be a case where damped track strangely does nothing + * - to do that, rotate around a different local axis */ float tmpvec[3]; @@ -4970,13 +4972,13 @@ void BKE_constraint_targets_for_solving_get(bConstraint *con, bConstraintOb *cob bConstraintTarget *ct; /* get targets - * - constraints should use ct->matrix, not directly accessing values - * - ct->matrix members have not yet been calculated here! + * - constraints should use ct->matrix, not directly accessing values + * - ct->matrix members have not yet been calculated here! */ cti->get_constraint_targets(con, targets); /* set matrices - * - calculate if possible, otherwise just initialize as identity matrix + * - calculate if possible, otherwise just initialize as identity matrix */ if (cti->get_target_matrix) { for (ct = targets->first; ct; ct = ct->next) @@ -5021,7 +5023,7 @@ void BKE_constraints_solve(ListBase *conlist, bConstraintOb *cob, float ctime) if (con->enforce == 0.0f) continue; /* influence of constraint - * - value should have been set from animation data already + * - value should have been set from animation data already */ enf = con->enforce; @@ -5038,8 +5040,8 @@ void BKE_constraints_solve(ListBase *conlist, bConstraintOb *cob, float ctime) cti->evaluate_constraint(con, cob, &targets); /* clear targets after use - * - this should free temp targets but no data should be copied back - * as constraints may have done some nasty things to it... + * - this should free temp targets but no data should be copied back + * as constraints may have done some nasty things to it... */ if (cti->flush_constraint_targets) { cti->flush_constraint_targets(con, &targets, 1); @@ -5050,9 +5052,9 @@ void BKE_constraints_solve(ListBase *conlist, bConstraintOb *cob, float ctime) BKE_constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, con->ownspace, CONSTRAINT_SPACE_WORLD, false); /* Interpolate the enforcement, to blend result of constraint into final owner transform - * - all this happens in worldspace to prevent any weirdness creeping in ([#26014] and [#25725]), - * since some constraints may not convert the solution back to the input space before blending - * but all are guaranteed to end up in good "worldspace" result + * - all this happens in worldspace to prevent any weirdness creeping in ([#26014] and [#25725]), + * since some constraints may not convert the solution back to the input space before blending + * but all are guaranteed to end up in good "worldspace" result */ /* Note: all kind of stuff here before (caused trouble), much easier to just interpolate, * or did I miss something? -jahka (r.32105) */ |