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>2007-08-18 10:17:50 +0400
committerJoshua Leung <aligorith@gmail.com>2007-08-18 10:17:50 +0400
commit982d45162b5bf02127b16a9ede693bca99431427 (patch)
tree958adbe216df049c92269b731f552f0617bcbea0 /source/blender/blenkernel/intern
parent373ac35c71337cb45e3aaefd333c599b80fcf91e (diff)
== PyConstraints ==
I've added the ability for PyConstraints to define a function (doDriver) that is able to directly modify values of the owner/target, so that certain setups can be created reliably. Users should take note that this is against the basic concept of what a constraint does, and that under no circumstances may they set the values of any variables controlling the transforms. For more details, check out the information in the PyConstraint template script. I've also updated PyConstraints to be aware of geometry targets. The script template has been updated with this information.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/constraint.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 7f736a644f9..5ed729fbd37 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -2815,16 +2815,29 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime)
/* value should have been set from IPO's/Constraint Channels already */
enf = con->enforce;
- /* move owner into right space */
+ /* move owner matrix into right space */
constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, CONSTRAINT_SPACE_WORLD, con->ownspace);
+ Mat4CpyMat4(oldmat, cob->matrix);
- /* Get the target matrix - in right space to be used */
+ /* get the target matrix - in right space to be used */
ownerdata= ((cob->pchan)? (void *)cob->pchan : (void *)cob->ob);
get_constraint_target_matrix(con, cob->type, ownerdata, tarmat, ctime);
- Mat4CpyMat4(oldmat, cob->matrix);
- /* solve the constraint */
+ /* Special Hack for PyConstraints to be able to set settings on the owner and/or
+ * target. Technically, this violates the design of constraints (as constraints should
+ * only act on matrices to alter the final transform of an owner), but on the other
+ * hand, this makes PyConstraints more powerful as it enables certain setups to be created
+ * and work reliably.
+ */
+ if (con->type == CONSTRAINT_TYPE_PYTHON) {
+ bPythonConstraint *pycon= (bPythonConstraint *)con->data;
+
+ /* as usual, the function for this is defined in BPY_interface.c */
+ BPY_pyconstraint_driver(pycon, cob, pycon->tar, pycon->subtarget);
+ }
+
+ /* Solve the constraint */
evaluate_constraint(con, cob->matrix, tarmat);
/* Interpolate the enforcement, to blend result of constraint into final owner transform */