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:
authorJoshua Leung <aligorith@gmail.com>2011-05-24 16:12:12 +0400
committerJoshua Leung <aligorith@gmail.com>2011-05-24 16:12:12 +0400
commit1788bc298c7afc202346477ac14456f6f208359b (patch)
tree5b0bf523f5efc247665db105dac66126e7478843 /source/blender/blenkernel
parenta5b07c09349978ab7ecf319e6345d7c98177521c (diff)
= Limit Distance Constraint - 'For Transform' Option =
The Limit Distance Constraint now has a "For Transform" option just like all the other Limit constraints. This option controls whether the constraint gets applied to interactive transforms in the 3D View too, preventing controllers from getting large values without the animator knowing. Additional code changes: * Split code to get constraint targets and grab their matrices for solving out to a separate helper function: get_constraint_targets_for_solving() * Fixed a bug where "found constraint ...." prints would appear in the console. Looks like some warning print that was forgotten TODO: * While coding this, I noticed potential division by zero bugs with the Limit Distance constraint. Looking into these after this commit.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_constraint.h1
-rw-r--r--source/blender/blenkernel/intern/constraint.c52
2 files changed, 32 insertions, 21 deletions
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h
index 7c0e7050a9f..ddff45c5422 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -154,6 +154,7 @@ void constraints_clear_evalob(struct bConstraintOb *cob);
void constraint_mat_convertspace(struct Object *ob, struct bPoseChannel *pchan, float mat[][4], short from, short to);
void get_constraint_target_matrix(struct Scene *scene, struct bConstraint *con, int n, short ownertype, void *ownerdata, float mat[][4], float ctime);
+void get_constraint_targets_for_solving(struct bConstraint *con, struct bConstraintOb *ob, struct ListBase *targets, float ctime);
void solve_constraints(struct ListBase *conlist, struct bConstraintOb *cob, float ctime);
#ifdef __cplusplus
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index d3c14a9dd12..35e1cae0523 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -2642,6 +2642,8 @@ static void distlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
/* set distance (flag is only set when user demands it) */
if (data->dist == 0)
data->dist= dist;
+
+ // FIXME: dist may be 0!
/* check if we're which way to clamp from, and calculate interpolation factor (if needed) */
if (data->mode == LIMITDIST_OUTSIDE) {
@@ -4427,6 +4429,34 @@ void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n,
unit_m4(mat);
}
}
+
+/* Get the list of targets required for solving a constraint */
+void get_constraint_targets_for_solving (bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime)
+{
+ bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+
+ if (cti && cti->get_constraint_targets) {
+ bConstraintTarget *ct;
+
+ /* get targets
+ * - 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 initialise as identity matrix
+ */
+ if (cti->get_target_matrix) {
+ for (ct= targets->first; ct; ct= ct->next)
+ cti->get_target_matrix(con, cob, ct, ctime);
+ }
+ else {
+ for (ct= targets->first; ct; ct= ct->next)
+ unit_m4(ct->matrix);
+ }
+ }
+}
/* ---------- Evaluation ----------- */
@@ -4471,27 +4501,7 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime)
constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, CONSTRAINT_SPACE_WORLD, con->ownspace);
/* prepare targets for constraint solving */
- if (cti->get_constraint_targets) {
- bConstraintTarget *ct;
-
- /* get targets
- * - 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 initialise as identity matrix
- */
- if (cti->get_target_matrix) {
- for (ct= targets.first; ct; ct= ct->next)
- cti->get_target_matrix(con, cob, ct, ctime);
- }
- else {
- for (ct= targets.first; ct; ct= ct->next)
- unit_m4(ct->matrix);
- }
- }
+ get_constraint_targets_for_solving(con, cob, &targets, ctime);
/* Solve the constraint and put result in cob->matrix */
cti->evaluate_constraint(con, cob, &targets);