2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
* Contributor(s): 2007, Joshua Leung, major recode
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-27 20:40:57 +00:00
|
|
|
/** \file blender/blenkernel/intern/constraint.c
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <stdio.h>
|
2008-01-20 23:53:13 +00:00
|
|
|
#include <stddef.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <string.h>
|
2003-12-24 11:44:57 +00:00
|
|
|
#include <math.h>
|
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
later added in trunk also, but reverted partially, specifically revision
16683. I have left out this reversion in the 2.5 branch since I think it is
needed there.
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
-W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
differently. Since this is changed so much, and I don't think those fixes
would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
initialized when running with -P. The code that initializes the screen there
I had to disable, that can't work in 2.5 anymore but left it commented as a
reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
still use changes that were done in trunk.
2008-11-12 21:16:53 +00:00
|
|
|
#include <float.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2012-01-04 17:20:08 +00:00
|
|
|
#include "BLI_kdopbvh.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-03-20 18:42:09 +00:00
|
|
|
#include "BLF_translation.h"
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_armature_types.h"
|
2011-11-07 12:55:18 +00:00
|
|
|
#include "DNA_camera_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_constraint_types.h"
|
2009-05-23 03:24:15 +00:00
|
|
|
#include "DNA_modifier_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_action_types.h"
|
|
|
|
#include "DNA_curve_types.h"
|
2008-12-31 17:11:42 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
2007-08-17 11:23:48 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2007-08-17 11:23:48 +00:00
|
|
|
#include "DNA_lattice_types.h"
|
2004-01-27 06:08:37 +00:00
|
|
|
#include "DNA_scene_types.h"
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
#include "DNA_text_types.h"
|
2011-11-07 12:55:18 +00:00
|
|
|
#include "DNA_tracking_types.h"
|
|
|
|
#include "DNA_movieclip_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_action.h"
|
2007-08-28 08:43:38 +00:00
|
|
|
#include "BKE_anim.h" /* for the curve calculation part */
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_armature.h"
|
|
|
|
#include "BKE_blender.h"
|
2012-01-04 17:20:08 +00:00
|
|
|
#include "BKE_bvhutils.h"
|
2011-11-07 12:55:18 +00:00
|
|
|
#include "BKE_camera.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_constraint.h"
|
2005-12-21 17:49:43 +00:00
|
|
|
#include "BKE_displist.h"
|
2007-08-17 11:23:48 +00:00
|
|
|
#include "BKE_deform.h"
|
2012-05-06 17:22:54 +00:00
|
|
|
#include "BKE_DerivedMesh.h" /* for geometry targets */
|
2007-08-28 08:43:38 +00:00
|
|
|
#include "BKE_cdderivedmesh.h" /* for geometry targets */
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_object.h"
|
|
|
|
#include "BKE_ipo.h"
|
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_library.h"
|
2007-06-18 07:41:21 +00:00
|
|
|
#include "BKE_idprop.h"
|
2009-05-18 08:46:04 +00:00
|
|
|
#include "BKE_mesh.h"
|
2009-05-23 03:24:15 +00:00
|
|
|
#include "BKE_shrinkwrap.h"
|
|
|
|
#include "BKE_mesh.h"
|
2013-04-13 20:31:52 +00:00
|
|
|
#include "BKE_editmesh.h"
|
2011-11-08 02:57:28 +00:00
|
|
|
#include "BKE_tracking.h"
|
|
|
|
#include "BKE_movieclip.h"
|
2007-06-18 07:41:21 +00:00
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2012-12-04 14:43:42 +00:00
|
|
|
# include "BPY_extern.h"
|
2008-10-28 18:47:13 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* ************************ 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
|
|
|
|
* type-info structs.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* -------------- Naming -------------- */
|
|
|
|
|
|
|
|
/* Find the first available, non-duplicate name for a given constraint */
|
2012-12-23 11:31:15 +00:00
|
|
|
void BKE_unique_constraint_name(bConstraint *con, ListBase *list)
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
{
|
2013-03-25 08:29:06 +00:00
|
|
|
BLI_uniquename(list, con, DATA_("Const"), '.', offsetof(bConstraint, name), sizeof(con->name));
|
2003-10-21 13:22:07 +00:00
|
|
|
}
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* ----------------- Evaluation Loop Preparation --------------- */
|
|
|
|
|
|
|
|
/* package an object/bone for use in constraint evaluation */
|
|
|
|
/* This function MEM_calloc's a bConstraintOb struct, that will need to be freed after evaluation */
|
2012-12-23 11:31:15 +00:00
|
|
|
bConstraintOb *BKE_constraints_make_evalob(Scene *scene, Object *ob, void *subdata, short datatype)
|
2003-10-21 13:22:07 +00:00
|
|
|
{
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
bConstraintOb *cob;
|
|
|
|
|
|
|
|
/* create regardless of whether we have any data! */
|
2012-05-06 17:22:54 +00:00
|
|
|
cob = MEM_callocN(sizeof(bConstraintOb), "bConstraintOb");
|
2003-10-21 13:22:07 +00:00
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
/* for system time, part of deglobalization, code nicer later with local time (ton) */
|
2012-05-06 17:22:54 +00:00
|
|
|
cob->scene = scene;
|
2009-01-04 14:14:06 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* based on type of available data */
|
|
|
|
switch (datatype) {
|
|
|
|
case CONSTRAINT_OBTYPE_OBJECT:
|
2007-06-18 07:41:21 +00:00
|
|
|
{
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* disregard subdata... calloc should set other values right */
|
|
|
|
if (ob) {
|
|
|
|
cob->ob = ob;
|
|
|
|
cob->type = datatype;
|
2009-09-16 17:43:09 +00:00
|
|
|
cob->rotOrder = EULER_ORDER_DEFAULT; // TODO: when objects have rotation order too, use that
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(cob->matrix, ob->obmat);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(cob->matrix);
|
2007-06-18 07:41:21 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(cob->startmat, cob->matrix);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2007-06-18 07:41:21 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
case CONSTRAINT_OBTYPE_BONE:
|
2003-10-21 13:22:07 +00:00
|
|
|
{
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* only set if we have valid bone, otherwise default */
|
|
|
|
if (ob && subdata) {
|
|
|
|
cob->ob = ob;
|
|
|
|
cob->pchan = (bPoseChannel *)subdata;
|
|
|
|
cob->type = datatype;
|
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
if (cob->pchan->rotmode > 0) {
|
|
|
|
/* should be some type of Euler order */
|
2012-05-06 17:22:54 +00:00
|
|
|
cob->rotOrder = cob->pchan->rotmode;
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Quats, so eulers should just use default order */
|
2012-05-06 17:22:54 +00:00
|
|
|
cob->rotOrder = EULER_ORDER_DEFAULT;
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* matrix in world-space */
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(cob->matrix, ob->obmat, cob->pchan->pose_mat);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(cob->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(cob->startmat, cob->matrix);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2003-10-21 13:22:07 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
default: /* other types not yet handled */
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(cob->matrix);
|
|
|
|
unit_m4(cob->startmat);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cob;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup after constraint evaluation */
|
2012-12-23 11:31:15 +00:00
|
|
|
void BKE_constraints_clear_evalob(bConstraintOb *cob)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
float delta[4][4], imat[4][4];
|
|
|
|
|
|
|
|
/* prevent crashes */
|
|
|
|
if (cob == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* calculate delta of constraints evaluation */
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, cob->startmat);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(delta, cob->matrix, imat);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* copy matrices back to source */
|
|
|
|
switch (cob->type) {
|
|
|
|
case CONSTRAINT_OBTYPE_OBJECT:
|
2005-09-07 00:11:39 +00:00
|
|
|
{
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* cob->ob might not exist! */
|
|
|
|
if (cob->ob) {
|
|
|
|
/* copy new ob-matrix back to owner */
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(cob->ob->obmat, cob->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* copy inverse of delta back to owner */
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(cob->ob->constinv, delta);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
case CONSTRAINT_OBTYPE_BONE:
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
{
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* cob->ob or cob->pchan might not exist */
|
|
|
|
if (cob->ob && cob->pchan) {
|
|
|
|
/* copy new pose-matrix back to owner */
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(cob->pchan->pose_mat, cob->ob->imat, cob->matrix);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* copy inverse of delta back to owner */
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(cob->pchan->constinv, delta);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free tempolary struct */
|
|
|
|
MEM_freeN(cob);
|
|
|
|
}
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* -------------- Space-Conversion API -------------- */
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
|
|
|
/* This function is responsible for the correct transformations/conversions
|
|
|
|
* of a matrix from one space to another for constraint evaluation.
|
|
|
|
* For now, this is only implemented for Objects and PoseChannels.
|
|
|
|
*/
|
2012-12-23 11:31:15 +00:00
|
|
|
void BKE_constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[4][4], short from, short to)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
float diff_mat[4][4];
|
|
|
|
float imat[4][4];
|
|
|
|
|
|
|
|
/* prevent crashes in these unlikely events */
|
2012-05-06 17:22:54 +00:00
|
|
|
if (ob == NULL || mat == NULL) return;
|
2012-03-02 16:05:54 +00:00
|
|
|
/* optimize trick - check if need to do anything */
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
if (from == to) return;
|
|
|
|
|
|
|
|
/* are we dealing with pose-channels or objects */
|
|
|
|
if (pchan) {
|
|
|
|
/* pose channels */
|
|
|
|
switch (from) {
|
|
|
|
case CONSTRAINT_SPACE_WORLD: /* ---------- FROM WORLDSPACE ---------- */
|
|
|
|
{
|
|
|
|
/* world to pose */
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, ob->obmat);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(mat, imat, mat);
|
2007-07-28 09:00:15 +00:00
|
|
|
|
2008-09-07 04:43:31 +00:00
|
|
|
/* use pose-space as stepping stone for other spaces... */
|
|
|
|
if (ELEM(to, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_PARLOCAL)) {
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
/* call self with slightly different values */
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
2012-05-06 17:22:54 +00:00
|
|
|
case CONSTRAINT_SPACE_POSE: /* ---------- FROM POSESPACE ---------- */
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
{
|
|
|
|
/* pose to world */
|
|
|
|
if (to == CONSTRAINT_SPACE_WORLD) {
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(mat, ob->obmat, mat);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
|
|
|
/* pose to local */
|
|
|
|
else if (to == CONSTRAINT_SPACE_LOCAL) {
|
|
|
|
if (pchan->bone) {
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_armature_mat_pose_to_bone(pchan, mat, mat);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* pose to local with parent */
|
|
|
|
else if (to == CONSTRAINT_SPACE_PARLOCAL) {
|
|
|
|
if (pchan->bone) {
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, pchan->bone->arm_mat);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(mat, imat, mat);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
|
|
|
case CONSTRAINT_SPACE_LOCAL: /* ------------ FROM LOCALSPACE --------- */
|
|
|
|
{
|
2008-09-07 04:43:31 +00:00
|
|
|
/* local to pose - do inverse procedure that was done for pose to local */
|
|
|
|
if (pchan->bone) {
|
2012-02-02 08:47:46 +00:00
|
|
|
/* we need the posespace_matrix = local_matrix + (parent_posespace_matrix + restpos) */
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_armature_mat_bone_to_pose(pchan, mat, mat);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
2008-09-07 04:43:31 +00:00
|
|
|
|
|
|
|
/* use pose-space as stepping stone for other spaces */
|
|
|
|
if (ELEM(to, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_PARLOCAL)) {
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
/* call self with slightly different values */
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
|
|
|
case CONSTRAINT_SPACE_PARLOCAL: /* -------------- FROM LOCAL WITH PARENT ---------- */
|
|
|
|
{
|
2008-09-07 04:43:31 +00:00
|
|
|
/* local + parent to pose */
|
2012-10-21 05:46:41 +00:00
|
|
|
if (pchan->bone) {
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(diff_mat, pchan->bone->arm_mat);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(mat, mat, diff_mat);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
2008-09-07 04:43:31 +00:00
|
|
|
|
|
|
|
/* use pose-space as stepping stone for other spaces */
|
|
|
|
if (ELEM(to, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL)) {
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
/* call self with slightly different values */
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* objects */
|
2012-05-06 17:22:54 +00:00
|
|
|
if (from == CONSTRAINT_SPACE_WORLD && to == CONSTRAINT_SPACE_LOCAL) {
|
2011-01-26 23:33:08 +00:00
|
|
|
/* check if object has a parent */
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
if (ob->parent) {
|
|
|
|
/* 'subtract' parent's effects from owner */
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, diff_mat);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(mat, imat, mat);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
2011-01-26 23:33:08 +00:00
|
|
|
else {
|
|
|
|
/* Local space in this case will have to be defined as local to the owner's
|
|
|
|
* transform-property-rotated axes. So subtract this rotation component.
|
|
|
|
*/
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_to_mat4(ob, diff_mat);
|
2011-01-26 23:33:08 +00:00
|
|
|
normalize_m4(diff_mat);
|
|
|
|
zero_v3(diff_mat[3]);
|
|
|
|
|
|
|
|
invert_m4_m4(imat, diff_mat);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(mat, imat, mat);
|
2011-01-26 23:33:08 +00:00
|
|
|
}
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
2012-05-06 17:22:54 +00:00
|
|
|
else if (from == CONSTRAINT_SPACE_LOCAL && to == CONSTRAINT_SPACE_WORLD) {
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
/* check that object has a parent - otherwise this won't work */
|
|
|
|
if (ob->parent) {
|
|
|
|
/* 'add' parent's effect back to owner */
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv);
|
|
|
|
mul_m4_m4m4(mat, diff_mat, mat);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
2011-01-26 23:33:08 +00:00
|
|
|
else {
|
|
|
|
/* Local space in this case will have to be defined as local to the owner's
|
|
|
|
* transform-property-rotated axes. So add back this rotation component.
|
|
|
|
*/
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_to_mat4(ob, diff_mat);
|
2011-01-26 23:33:08 +00:00
|
|
|
normalize_m4(diff_mat);
|
|
|
|
zero_v3(diff_mat[3]);
|
|
|
|
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(mat, diff_mat, mat);
|
2011-01-26 23:33:08 +00:00
|
|
|
}
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* ------------ General Target Matrix Tools ---------- */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2007-08-17 11:23:48 +00:00
|
|
|
/* function that sets the given matrix based on given vertex group in mesh */
|
2012-12-11 14:29:01 +00:00
|
|
|
static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[4][4])
|
2007-08-17 11:23:48 +00:00
|
|
|
{
|
2010-03-01 09:42:39 +00:00
|
|
|
DerivedMesh *dm = NULL;
|
2013-04-16 05:59:48 +00:00
|
|
|
BMEditMesh *em = BKE_editmesh_from_object(ob);
|
2010-08-15 15:14:08 +00:00
|
|
|
float vec[3] = {0.0f, 0.0f, 0.0f};
|
2007-08-18 04:03:03 +00:00
|
|
|
float normal[3] = {0.0f, 0.0f, 0.0f}, plane[3];
|
|
|
|
float imat[3][3], tmat[3][3];
|
2012-05-06 17:22:54 +00:00
|
|
|
const int defgroup = defgroup_name_index(ob, substring);
|
2009-05-23 03:24:15 +00:00
|
|
|
short freeDM = 0;
|
2007-08-17 11:23:48 +00:00
|
|
|
|
|
|
|
/* initialize target matrix using target matrix */
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(mat, ob->obmat);
|
2007-08-17 11:23:48 +00:00
|
|
|
|
|
|
|
/* get index of vertex group */
|
2011-12-14 22:54:38 +00:00
|
|
|
if (defgroup == -1) return;
|
|
|
|
|
2007-08-28 08:43:38 +00:00
|
|
|
/* get DerivedMesh */
|
2009-03-30 07:28:37 +00:00
|
|
|
if (em) {
|
2008-07-26 00:43:29 +00:00
|
|
|
/* target is in editmode, so get a special derived mesh */
|
2012-10-24 07:24:11 +00:00
|
|
|
dm = CDDM_from_editbmesh(em, FALSE, FALSE);
|
2012-05-06 17:22:54 +00:00
|
|
|
freeDM = 1;
|
2007-08-28 08:43:38 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-06-15 09:45:26 +00:00
|
|
|
/* when not in EditMode, use the 'final' derived mesh, depsgraph
|
2011-11-04 08:08:47 +00:00
|
|
|
* ensures we build with CD_MDEFORMVERT layer
|
|
|
|
*/
|
2011-06-15 09:45:26 +00:00
|
|
|
dm = (DerivedMesh *)ob->derivedFinal;
|
2007-08-28 08:43:38 +00:00
|
|
|
}
|
|
|
|
|
2007-08-17 11:23:48 +00:00
|
|
|
/* only continue if there's a valid DerivedMesh */
|
|
|
|
if (dm) {
|
|
|
|
MDeformVert *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
|
|
|
|
int numVerts = dm->getNumVerts(dm);
|
2013-05-14 16:22:53 +00:00
|
|
|
int i;
|
2007-08-18 04:03:03 +00:00
|
|
|
float co[3], nor[3];
|
|
|
|
|
2009-11-04 20:23:48 +00:00
|
|
|
/* check that dvert is a valid pointers (just in case) */
|
|
|
|
if (dvert) {
|
2012-05-06 17:22:54 +00:00
|
|
|
MDeformVert *dv = dvert;
|
2013-05-14 16:22:53 +00:00
|
|
|
float weightsum = 0.0f;
|
|
|
|
|
2007-09-27 23:36:17 +00:00
|
|
|
/* get the average of all verts with that are in the vertex-group */
|
2011-12-14 22:54:38 +00:00
|
|
|
for (i = 0; i < numVerts; i++, dv++) {
|
2012-05-06 17:22:54 +00:00
|
|
|
MDeformWeight *dw = defvert_find_index(dv, defgroup);
|
2013-05-14 16:22:53 +00:00
|
|
|
|
|
|
|
if (dw && dw->weight > 0.0f) {
|
2011-12-14 22:54:38 +00:00
|
|
|
dm->getVertCo(dm, i, co);
|
|
|
|
dm->getVertNo(dm, i, nor);
|
2013-05-14 16:22:53 +00:00
|
|
|
madd_v3_v3fl(vec, co, dw->weight);
|
|
|
|
madd_v3_v3fl(normal, nor, dw->weight);
|
|
|
|
weightsum += dw->weight;
|
2007-08-17 11:23:48 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-14 22:54:38 +00:00
|
|
|
|
2007-09-27 23:36:17 +00:00
|
|
|
/* calculate averages of normal and coordinates */
|
2013-05-14 16:22:53 +00:00
|
|
|
if (weightsum > 0) {
|
|
|
|
mul_v3_fl(vec, 1.0f / weightsum);
|
|
|
|
mul_v3_fl(normal, 1.0f / weightsum);
|
2007-09-27 23:36:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* derive the rotation from the average normal:
|
|
|
|
* - code taken from transform_manipulator.c,
|
|
|
|
* calc_manipulator_stats, V3D_MANIP_NORMAL case
|
|
|
|
*/
|
|
|
|
/* we need the transpose of the inverse for a normal... */
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m3_m4(imat, ob->obmat);
|
2007-09-27 23:36:17 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m3_m3(tmat, imat);
|
|
|
|
transpose_m3(tmat);
|
|
|
|
mul_m3_v3(tmat, normal);
|
2007-09-27 23:36:17 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(normal);
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(plane, tmat[1]);
|
2007-09-27 23:36:17 +00:00
|
|
|
|
2012-01-30 19:46:15 +00:00
|
|
|
cross_v3_v3v3(mat[0], normal, plane);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (len_v3(mat[0]) < 1e-3f) {
|
2012-01-30 19:46:15 +00:00
|
|
|
copy_v3_v3(plane, tmat[0]);
|
|
|
|
cross_v3_v3v3(mat[0], normal, plane);
|
|
|
|
}
|
|
|
|
|
|
|
|
copy_v3_v3(mat[2], normal);
|
|
|
|
cross_v3_v3v3(mat[1], mat[2], mat[0]);
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_m4(mat);
|
2012-01-30 19:46:15 +00:00
|
|
|
|
2007-09-27 23:36:17 +00:00
|
|
|
|
|
|
|
/* apply the average coordinate as the new location */
|
2010-08-15 15:14:08 +00:00
|
|
|
mul_v3_m4v3(mat[3], ob->obmat, vec);
|
2007-08-17 11:23:48 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-28 08:43:38 +00:00
|
|
|
|
|
|
|
/* free temporary DerivedMesh created (in EditMode case) */
|
2009-05-23 03:24:15 +00:00
|
|
|
if (dm && freeDM)
|
|
|
|
dm->release(dm);
|
2007-08-17 11:23:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* function that sets the given matrix based on given vertex group in lattice */
|
2012-12-11 14:29:01 +00:00
|
|
|
static void contarget_get_lattice_mat(Object *ob, const char *substring, float mat[4][4])
|
2007-08-17 11:23:48 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
Lattice *lt = (Lattice *)ob->data;
|
2007-08-17 11:23:48 +00:00
|
|
|
|
2012-05-07 06:58:03 +00:00
|
|
|
DispList *dl = BKE_displist_find(&ob->disp, DL_VERTS);
|
2012-05-06 17:22:54 +00:00
|
|
|
float *co = dl ? dl->verts : NULL;
|
2007-08-17 11:23:48 +00:00
|
|
|
BPoint *bp = lt->def;
|
|
|
|
|
2011-12-14 22:54:38 +00:00
|
|
|
MDeformVert *dv = lt->dvert;
|
2012-05-06 17:22:54 +00:00
|
|
|
int tot_verts = lt->pntsu * lt->pntsv * lt->pntsw;
|
|
|
|
float vec[3] = {0.0f, 0.0f, 0.0f}, tvec[3];
|
|
|
|
int grouped = 0;
|
2007-08-17 11:23:48 +00:00
|
|
|
int i, n;
|
2012-05-06 17:22:54 +00:00
|
|
|
const int defgroup = defgroup_name_index(ob, substring);
|
2007-08-17 11:23:48 +00:00
|
|
|
|
|
|
|
/* initialize target matrix using target matrix */
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(mat, ob->obmat);
|
2011-12-14 22:54:38 +00:00
|
|
|
|
2007-08-17 11:23:48 +00:00
|
|
|
/* get index of vertex group */
|
2011-12-14 22:54:38 +00:00
|
|
|
if (defgroup == -1) return;
|
|
|
|
if (dv == NULL) return;
|
2007-08-17 11:23:48 +00:00
|
|
|
|
|
|
|
/* 1. Loop through control-points checking if in nominated vertex-group.
|
|
|
|
* 2. If it is, add it to vec to find the average point.
|
|
|
|
*/
|
2012-05-06 17:22:54 +00:00
|
|
|
for (i = 0; i < tot_verts; i++, dv++) {
|
|
|
|
for (n = 0; n < dv->totweight; n++) {
|
|
|
|
MDeformWeight *dw = defvert_find_index(dv, defgroup);
|
2011-12-14 22:54:38 +00:00
|
|
|
if (dw && dw->weight > 0.0f) {
|
2007-08-17 11:23:48 +00:00
|
|
|
/* copy coordinates of point to temporary vector, then add to find average */
|
2011-12-14 22:54:38 +00:00
|
|
|
memcpy(tvec, co ? co : bp->vec, 3 * sizeof(float));
|
|
|
|
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(vec, tvec);
|
2007-08-17 11:23:48 +00:00
|
|
|
grouped++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* advance pointer to coordinate data */
|
2011-12-14 22:54:38 +00:00
|
|
|
if (co) co += 3;
|
2012-05-06 17:22:54 +00:00
|
|
|
else bp++;
|
2007-08-17 11:23:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* find average location, then multiply by ob->obmat to find world-space location */
|
|
|
|
if (grouped)
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(vec, 1.0f / grouped);
|
|
|
|
mul_v3_m4v3(tvec, ob->obmat, vec);
|
2007-08-17 11:23:48 +00:00
|
|
|
|
|
|
|
/* copy new location to matrix */
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(mat[3], tvec);
|
2007-08-17 11:23:48 +00:00
|
|
|
}
|
|
|
|
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
/* generic function to get the appropriate matrix for most target cases */
|
|
|
|
/* The cases where the target can be object data have not been implemented */
|
2012-12-11 14:29:01 +00:00
|
|
|
static void constraint_target_to_mat4(Object *ob, const char *substring, float mat[4][4], short from, short to, float headtail)
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
/* Case OBJECT */
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
if (!strlen(substring)) {
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(mat, ob->obmat);
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_constraint_mat_convertspace(ob, NULL, mat, from, to);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
2012-05-06 17:22:54 +00:00
|
|
|
/* Case VERTEXGROUP */
|
2007-08-17 11:23:48 +00:00
|
|
|
/* Current method just takes the average location of all the points in the
|
2007-08-18 04:03:03 +00:00
|
|
|
* VertexGroup, and uses that as the location value of the targets. Where
|
|
|
|
* possible, the orientation will also be calculated, by calculating an
|
2012-03-09 00:41:09 +00:00
|
|
|
* 'average' vertex normal, and deriving the rotation from that.
|
2007-08-17 11:23:48 +00:00
|
|
|
*
|
2007-08-18 04:03:03 +00:00
|
|
|
* NOTE: EditMode is not currently supported, and will most likely remain that
|
|
|
|
* way as constraints can only really affect things on object/bone level.
|
2007-08-17 11:23:48 +00:00
|
|
|
*/
|
|
|
|
else if (ob->type == OB_MESH) {
|
2011-06-15 14:06:25 +00:00
|
|
|
contarget_get_mesh_mat(ob, substring, mat);
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_constraint_mat_convertspace(ob, NULL, mat, from, to);
|
2007-08-17 11:23:48 +00:00
|
|
|
}
|
|
|
|
else if (ob->type == OB_LATTICE) {
|
|
|
|
contarget_get_lattice_mat(ob, substring, mat);
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_constraint_mat_convertspace(ob, NULL, mat, from, to);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
/* Case BONE */
|
|
|
|
else {
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
bPoseChannel *pchan;
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
pchan = BKE_pose_channel_find_name(ob->pose, substring);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
if (pchan) {
|
|
|
|
/* Multiply the PoseSpace accumulation/final matrix for this
|
|
|
|
* PoseChannel by the Armature Object's Matrix to get a worldspace
|
|
|
|
* matrix.
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
*/
|
2011-03-27 14:59:55 +00:00
|
|
|
if (headtail < 0.000001f) {
|
Patch #7767: Constraint Subtargets can now target anywhere on a bone, not just the head or tail
Patch by: Roland Hess (harkyman)
For example, a constraint can be sub-targeted at the 50% (or 31.2% or 85% etc.) point of its target bone, giving you enormous rigging flexibility and removing the need for complex contraptions to do such things as:
- A bone whose base slides only between to points on a rig (CopyLoc with a variable, animated subtarget point)
- Bones that attach to multiple points along another bone (CopyLocs, each with a different head/tail percentage)
- Bones that need to stretch to a point midway between specific spots on two other bones (old way: too crazy to mention; new way: stretch bone between points on end bones, then another stretch to the midpoint of the first stretch)
It is only used for the constraint types for which it is relevant: CopyLoc, TrackTo, StretchTo and MinMax, TrackTo, and Floor.
Notes:
- This is accessed by the Head/Tail number-slider.
- This value can be animated per constraint
- The old "Copy Bone Tail" option for the CopyLoc constraint has been automatically converted to 1.0 Head/Bone values for the affected constraints
- In the code, this value is in the bConstraint struct, so it is available for all constraints, even though only a few implement it.
2007-11-12 04:17:03 +00:00
|
|
|
/* skip length interpolation if set to head */
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(mat, ob->obmat, pchan->pose_mat);
|
Patch #7767: Constraint Subtargets can now target anywhere on a bone, not just the head or tail
Patch by: Roland Hess (harkyman)
For example, a constraint can be sub-targeted at the 50% (or 31.2% or 85% etc.) point of its target bone, giving you enormous rigging flexibility and removing the need for complex contraptions to do such things as:
- A bone whose base slides only between to points on a rig (CopyLoc with a variable, animated subtarget point)
- Bones that attach to multiple points along another bone (CopyLocs, each with a different head/tail percentage)
- Bones that need to stretch to a point midway between specific spots on two other bones (old way: too crazy to mention; new way: stretch bone between points on end bones, then another stretch to the midpoint of the first stretch)
It is only used for the constraint types for which it is relevant: CopyLoc, TrackTo, StretchTo and MinMax, TrackTo, and Floor.
Notes:
- This is accessed by the Head/Tail number-slider.
- This value can be animated per constraint
- The old "Copy Bone Tail" option for the CopyLoc constraint has been automatically converted to 1.0 Head/Bone values for the affected constraints
- In the code, this value is in the bConstraint struct, so it is available for all constraints, even though only a few implement it.
2007-11-12 04:17:03 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
float tempmat[4][4], loc[3];
|
|
|
|
|
|
|
|
/* interpolate along length of bone */
|
2012-10-21 05:46:41 +00:00
|
|
|
interp_v3_v3v3(loc, pchan->pose_head, pchan->pose_tail, headtail);
|
Patch #7767: Constraint Subtargets can now target anywhere on a bone, not just the head or tail
Patch by: Roland Hess (harkyman)
For example, a constraint can be sub-targeted at the 50% (or 31.2% or 85% etc.) point of its target bone, giving you enormous rigging flexibility and removing the need for complex contraptions to do such things as:
- A bone whose base slides only between to points on a rig (CopyLoc with a variable, animated subtarget point)
- Bones that attach to multiple points along another bone (CopyLocs, each with a different head/tail percentage)
- Bones that need to stretch to a point midway between specific spots on two other bones (old way: too crazy to mention; new way: stretch bone between points on end bones, then another stretch to the midpoint of the first stretch)
It is only used for the constraint types for which it is relevant: CopyLoc, TrackTo, StretchTo and MinMax, TrackTo, and Floor.
Notes:
- This is accessed by the Head/Tail number-slider.
- This value can be animated per constraint
- The old "Copy Bone Tail" option for the CopyLoc constraint has been automatically converted to 1.0 Head/Bone values for the affected constraints
- In the code, this value is in the bConstraint struct, so it is available for all constraints, even though only a few implement it.
2007-11-12 04:17:03 +00:00
|
|
|
|
|
|
|
/* use interpolated distance for subtarget */
|
2012-10-21 05:46:41 +00:00
|
|
|
copy_m4_m4(tempmat, pchan->pose_mat);
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_v3_v3(tempmat[3], loc);
|
Patch #7767: Constraint Subtargets can now target anywhere on a bone, not just the head or tail
Patch by: Roland Hess (harkyman)
For example, a constraint can be sub-targeted at the 50% (or 31.2% or 85% etc.) point of its target bone, giving you enormous rigging flexibility and removing the need for complex contraptions to do such things as:
- A bone whose base slides only between to points on a rig (CopyLoc with a variable, animated subtarget point)
- Bones that attach to multiple points along another bone (CopyLocs, each with a different head/tail percentage)
- Bones that need to stretch to a point midway between specific spots on two other bones (old way: too crazy to mention; new way: stretch bone between points on end bones, then another stretch to the midpoint of the first stretch)
It is only used for the constraint types for which it is relevant: CopyLoc, TrackTo, StretchTo and MinMax, TrackTo, and Floor.
Notes:
- This is accessed by the Head/Tail number-slider.
- This value can be animated per constraint
- The old "Copy Bone Tail" option for the CopyLoc constraint has been automatically converted to 1.0 Head/Bone values for the affected constraints
- In the code, this value is in the bConstraint struct, so it is available for all constraints, even though only a few implement it.
2007-11-12 04:17:03 +00:00
|
|
|
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(mat, ob->obmat, tempmat);
|
Patch #7767: Constraint Subtargets can now target anywhere on a bone, not just the head or tail
Patch by: Roland Hess (harkyman)
For example, a constraint can be sub-targeted at the 50% (or 31.2% or 85% etc.) point of its target bone, giving you enormous rigging flexibility and removing the need for complex contraptions to do such things as:
- A bone whose base slides only between to points on a rig (CopyLoc with a variable, animated subtarget point)
- Bones that attach to multiple points along another bone (CopyLocs, each with a different head/tail percentage)
- Bones that need to stretch to a point midway between specific spots on two other bones (old way: too crazy to mention; new way: stretch bone between points on end bones, then another stretch to the midpoint of the first stretch)
It is only used for the constraint types for which it is relevant: CopyLoc, TrackTo, StretchTo and MinMax, TrackTo, and Floor.
Notes:
- This is accessed by the Head/Tail number-slider.
- This value can be animated per constraint
- The old "Copy Bone Tail" option for the CopyLoc constraint has been automatically converted to 1.0 Head/Bone values for the affected constraints
- In the code, this value is in the bConstraint struct, so it is available for all constraints, even though only a few implement it.
2007-11-12 04:17:03 +00:00
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(mat, ob->obmat);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
|
|
|
/* convert matrix space as required */
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_constraint_mat_convertspace(ob, pchan, mat, from, to);
|
2004-01-27 06:08:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* ************************* Specific Constraints ***************************** */
|
|
|
|
/* Each constraint defines a set of functions, which will be called at the appropriate
|
|
|
|
* times. In addition to this, each constraint should have a type-info struct, where
|
|
|
|
* its functions are attached for use.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Template for type-info data:
|
2012-05-06 17:22:54 +00:00
|
|
|
* - 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!
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
* - keep this copy #if-def'd so that future constraints can get based off this
|
|
|
|
*/
|
|
|
|
#if 0
|
|
|
|
static bConstraintTypeInfo CTI_CONSTRNAME = {
|
|
|
|
CONSTRAINT_TYPE_CONSTRNAME, /* type */
|
|
|
|
sizeof(bConstrNameConstraint), /* size */
|
|
|
|
"ConstrName", /* name */
|
|
|
|
"bConstrNameConstraint", /* struct name */
|
|
|
|
constrname_free, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
constrname_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
constrname_copy, /* copy data */
|
|
|
|
constrname_new_data, /* new data */
|
|
|
|
constrname_get_tars, /* get constraint targets */
|
|
|
|
constrname_flush_tars, /* flush constraint targets */
|
|
|
|
constrname_get_tarmat, /* get target matrix */
|
|
|
|
constrname_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* This function should be used for the get_target_matrix member of all
|
|
|
|
* constraints that are not picky about what happens to their target matrix.
|
|
|
|
*/
|
2012-05-06 17:22:54 +00:00
|
|
|
static void default_get_tarmat(bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (VALID_CONS_TARGET(ct))
|
2011-06-15 14:06:25 +00:00
|
|
|
constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
else if (ct)
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(ct->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This following macro should be used for all standard single-target *_get_tars functions
|
2012-03-01 12:20:18 +00:00
|
|
|
* to save typing and reduce maintenance woes.
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
* (Hopefully all compilers will be happy with the lines with just a space on them. Those are
|
|
|
|
* really just to help this code easier to read)
|
|
|
|
*/
|
2009-09-16 17:43:09 +00:00
|
|
|
// TODO: cope with getting rotation order...
|
2007-10-24 14:58:31 +00:00
|
|
|
#define SINGLETARGET_GET_TARS(con, datatar, datasubtarget, ct, list) \
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{ \
|
2012-05-06 17:22:54 +00:00
|
|
|
ct = MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
\
|
2012-05-06 17:22:54 +00:00
|
|
|
ct->tar = datatar; \
|
2010-11-05 07:35:21 +00:00
|
|
|
BLI_strncpy(ct->subtarget, datasubtarget, sizeof(ct->subtarget)); \
|
2012-05-06 17:22:54 +00:00
|
|
|
ct->space = con->tarspace; \
|
|
|
|
ct->flag = CONSTRAINT_TAR_TEMP; \
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
\
|
|
|
|
if (ct->tar) { \
|
2012-05-06 17:22:54 +00:00
|
|
|
if ((ct->tar->type == OB_ARMATURE) && (ct->subtarget[0])) { \
|
|
|
|
bPoseChannel *pchan = BKE_pose_channel_find_name(ct->tar->pose, ct->subtarget); \
|
2009-10-22 23:22:05 +00:00
|
|
|
ct->type = CONSTRAINT_OBTYPE_BONE; \
|
2012-05-06 17:22:54 +00:00
|
|
|
ct->rotOrder = (pchan) ? (pchan->rotmode) : EULER_ORDER_DEFAULT; \
|
|
|
|
} \
|
2011-11-01 06:45:36 +00:00
|
|
|
else if (OB_TYPE_SUPPORT_VGROUP(ct->tar->type) && (ct->subtarget[0])) { \
|
2009-10-22 23:22:05 +00:00
|
|
|
ct->type = CONSTRAINT_OBTYPE_VERT; \
|
|
|
|
ct->rotOrder = EULER_ORDER_DEFAULT; \
|
|
|
|
} \
|
2012-05-06 17:22:54 +00:00
|
|
|
else { \
|
2009-10-22 23:22:05 +00:00
|
|
|
ct->type = CONSTRAINT_OBTYPE_OBJECT; \
|
2012-05-06 17:22:54 +00:00
|
|
|
ct->rotOrder = ct->tar->rotmode; \
|
2009-10-22 23:22:05 +00:00
|
|
|
} \
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
BLI_addtail(list, ct); \
|
2012-05-27 20:13:59 +00:00
|
|
|
} (void)0
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* This following macro should be used for all standard single-target *_get_tars functions
|
2012-03-01 12:20:18 +00:00
|
|
|
* to save typing and reduce maintenance woes. It does not do the subtarget related operations
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
* (Hopefully all compilers will be happy with the lines with just a space on them. Those are
|
|
|
|
* really just to help this code easier to read)
|
|
|
|
*/
|
2009-09-16 17:43:09 +00:00
|
|
|
// TODO: cope with getting rotation order...
|
2007-10-24 14:58:31 +00:00
|
|
|
#define SINGLETARGETNS_GET_TARS(con, datatar, ct, list) \
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{ \
|
2012-05-06 17:22:54 +00:00
|
|
|
ct = MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
\
|
2012-05-06 17:22:54 +00:00
|
|
|
ct->tar = datatar; \
|
|
|
|
ct->space = con->tarspace; \
|
|
|
|
ct->flag = CONSTRAINT_TAR_TEMP; \
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
\
|
|
|
|
if (ct->tar) ct->type = CONSTRAINT_OBTYPE_OBJECT; \
|
|
|
|
\
|
|
|
|
BLI_addtail(list, ct); \
|
2012-05-27 20:13:59 +00:00
|
|
|
} (void)0
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* This following macro should be used for all standard single-target *_flush_tars functions
|
2012-03-01 12:20:18 +00:00
|
|
|
* to save typing and reduce maintenance woes.
|
2007-12-06 10:20:03 +00:00
|
|
|
* Note: the pointer to ct will be changed to point to the next in the list (as it gets removed)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
* (Hopefully all compilers will be happy with the lines with just a space on them. Those are
|
|
|
|
* really just to help this code easier to read)
|
|
|
|
*/
|
2007-10-24 14:58:31 +00:00
|
|
|
#define SINGLETARGET_FLUSH_TARS(con, datatar, datasubtarget, ct, list, nocopy) \
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{ \
|
|
|
|
if (ct) { \
|
2007-12-06 10:20:03 +00:00
|
|
|
bConstraintTarget *ctn = ct->next; \
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (nocopy == 0) { \
|
2012-05-06 17:22:54 +00:00
|
|
|
datatar = ct->tar; \
|
2011-02-13 03:21:27 +00:00
|
|
|
BLI_strncpy(datasubtarget, ct->subtarget, sizeof(datasubtarget)); \
|
2012-05-06 17:22:54 +00:00
|
|
|
con->tarspace = (char)ct->space; \
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
} \
|
|
|
|
\
|
2007-10-24 14:58:31 +00:00
|
|
|
BLI_freelinkN(list, ct); \
|
2012-05-06 17:22:54 +00:00
|
|
|
ct = ctn; \
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
} \
|
2012-05-27 20:13:59 +00:00
|
|
|
} (void)0
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* This following macro should be used for all standard single-target *_flush_tars functions
|
2012-03-01 12:20:18 +00:00
|
|
|
* to save typing and reduce maintenance woes. It does not do the subtarget related operations.
|
2007-12-06 10:20:03 +00:00
|
|
|
* Note: the pointer to ct will be changed to point to the next in the list (as it gets removed)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
* (Hopefully all compilers will be happy with the lines with just a space on them. Those are
|
|
|
|
* really just to help this code easier to read)
|
|
|
|
*/
|
2007-10-24 14:58:31 +00:00
|
|
|
#define SINGLETARGETNS_FLUSH_TARS(con, datatar, ct, list, nocopy) \
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{ \
|
|
|
|
if (ct) { \
|
2007-12-06 10:20:03 +00:00
|
|
|
bConstraintTarget *ctn = ct->next; \
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (nocopy == 0) { \
|
2012-05-06 17:22:54 +00:00
|
|
|
datatar = ct->tar; \
|
|
|
|
con->tarspace = (char)ct->space; \
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
} \
|
|
|
|
\
|
2007-10-24 14:58:31 +00:00
|
|
|
BLI_freelinkN(list, ct); \
|
2012-05-06 17:22:54 +00:00
|
|
|
ct = ctn; \
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
} \
|
2012-05-27 20:13:59 +00:00
|
|
|
} (void)0
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* --------- ChildOf Constraint ------------ */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void childof_new_data(void *cdata)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bChildOfConstraint *data = (bChildOfConstraint *)cdata;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
data->flag = (CHILDOF_LOCX | CHILDOF_LOCY | CHILDOF_LOCZ |
|
2012-05-06 17:22:54 +00:00
|
|
|
CHILDOF_ROTX | CHILDOF_ROTY | CHILDOF_ROTZ |
|
|
|
|
CHILDOF_SIZEX | CHILDOF_SIZEY | CHILDOF_SIZEZ);
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(data->invmat);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void childof_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bChildOfConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int childof_get_tars(bConstraint *con, ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bChildOfConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void childof_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bChildOfConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void childof_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bChildOfConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = targets->first;
|
2011-12-15 16:09:57 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* only evaluate if there is a target */
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
2011-02-06 17:36:42 +00:00
|
|
|
float parmat[4][4];
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2011-02-06 17:36:42 +00:00
|
|
|
/* simple matrix parenting */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (data->flag == CHILDOF_ALL) {
|
2011-02-06 17:36:42 +00:00
|
|
|
|
|
|
|
/* multiply target (parent matrix) by offset (parent inverse) to get
|
2012-06-12 08:32:06 +00:00
|
|
|
* the effect of the parent that will be exerted on the owner
|
2011-02-06 17:36:42 +00:00
|
|
|
*/
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(parmat, ct->matrix, data->invmat);
|
2011-02-06 17:36:42 +00:00
|
|
|
|
|
|
|
/* now multiply the parent matrix by the owner matrix to get the
|
2012-06-12 08:32:06 +00:00
|
|
|
* the effect of this constraint (i.e. owner is 'parented' to parent)
|
2011-02-06 17:36:42 +00:00
|
|
|
*/
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(cob->matrix, parmat, cob->matrix);
|
2011-02-06 17:36:42 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
float invmat[4][4], tempmat[4][4];
|
|
|
|
float loc[3], eul[3], size[3];
|
|
|
|
float loco[3], eulo[3], sizo[3];
|
|
|
|
|
|
|
|
/* get offset (parent-inverse) matrix */
|
|
|
|
copy_m4_m4(invmat, data->invmat);
|
|
|
|
|
|
|
|
/* extract components of both matrices */
|
|
|
|
copy_v3_v3(loc, ct->matrix[3]);
|
|
|
|
mat4_to_eulO(eul, ct->rotOrder, ct->matrix);
|
|
|
|
mat4_to_size(size, ct->matrix);
|
|
|
|
|
|
|
|
copy_v3_v3(loco, invmat[3]);
|
|
|
|
mat4_to_eulO(eulo, cob->rotOrder, invmat);
|
|
|
|
mat4_to_size(sizo, invmat);
|
|
|
|
|
|
|
|
/* disable channels not enabled */
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!(data->flag & CHILDOF_LOCX)) loc[0] = loco[0] = 0.0f;
|
|
|
|
if (!(data->flag & CHILDOF_LOCY)) loc[1] = loco[1] = 0.0f;
|
|
|
|
if (!(data->flag & CHILDOF_LOCZ)) loc[2] = loco[2] = 0.0f;
|
|
|
|
if (!(data->flag & CHILDOF_ROTX)) eul[0] = eulo[0] = 0.0f;
|
|
|
|
if (!(data->flag & CHILDOF_ROTY)) eul[1] = eulo[1] = 0.0f;
|
|
|
|
if (!(data->flag & CHILDOF_ROTZ)) eul[2] = eulo[2] = 0.0f;
|
|
|
|
if (!(data->flag & CHILDOF_SIZEX)) size[0] = sizo[0] = 1.0f;
|
|
|
|
if (!(data->flag & CHILDOF_SIZEY)) size[1] = sizo[1] = 1.0f;
|
|
|
|
if (!(data->flag & CHILDOF_SIZEZ)) size[2] = sizo[2] = 1.0f;
|
2011-02-06 17:36:42 +00:00
|
|
|
|
|
|
|
/* make new target mat and offset mat */
|
|
|
|
loc_eulO_size_to_mat4(ct->matrix, loc, eul, size, ct->rotOrder);
|
|
|
|
loc_eulO_size_to_mat4(invmat, loco, eulo, sizo, cob->rotOrder);
|
|
|
|
|
|
|
|
/* multiply target (parent matrix) by offset (parent inverse) to get
|
2012-06-12 08:32:06 +00:00
|
|
|
* the effect of the parent that will be exerted on the owner
|
2011-02-06 17:36:42 +00:00
|
|
|
*/
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(parmat, ct->matrix, invmat);
|
2011-02-06 17:36:42 +00:00
|
|
|
|
|
|
|
/* now multiply the parent matrix by the owner matrix to get the
|
|
|
|
* the effect of this constraint (i.e. owner is 'parented' to parent)
|
|
|
|
*/
|
|
|
|
copy_m4_m4(tempmat, cob->matrix);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(cob->matrix, parmat, tempmat);
|
2012-05-06 01:27:48 +00:00
|
|
|
|
2011-02-06 17:36:42 +00:00
|
|
|
/* without this, changes to scale and rotation can change location
|
|
|
|
* of a parentless bone or a disconnected bone. Even though its set
|
|
|
|
* to zero above. */
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!(data->flag & CHILDOF_LOCX)) cob->matrix[3][0] = tempmat[3][0];
|
|
|
|
if (!(data->flag & CHILDOF_LOCY)) cob->matrix[3][1] = tempmat[3][1];
|
|
|
|
if (!(data->flag & CHILDOF_LOCZ)) cob->matrix[3][2] = tempmat[3][2];
|
2011-02-06 17:36:42 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-23 13:16:56 +00:00
|
|
|
/* XXX note, con->flag should be CONSTRAINT_SPACEONCE for bone-childof, patched in readfile.c */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
static bConstraintTypeInfo CTI_CHILDOF = {
|
|
|
|
CONSTRAINT_TYPE_CHILDOF, /* type */
|
|
|
|
sizeof(bChildOfConstraint), /* size */
|
2013-03-11 09:06:49 +00:00
|
|
|
"Child Of", /* name */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
"bChildOfConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
childof_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
childof_new_data, /* new data */
|
|
|
|
childof_get_tars, /* get constraint targets */
|
|
|
|
childof_flush_tars, /* flush constraint targets */
|
|
|
|
default_get_tarmat, /* get a target matrix */
|
|
|
|
childof_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* -------- TrackTo Constraint ------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void trackto_new_data(void *cdata)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bTrackToConstraint *data = (bTrackToConstraint *)cdata;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
data->reserved1 = TRACK_Y;
|
|
|
|
data->reserved2 = UP_Z;
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void trackto_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bTrackToConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int trackto_get_tars(bConstraint *con, ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bTrackToConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void trackto_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bTrackToConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-03 18:38:51 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int basis_cross(int n, int m)
|
2006-12-03 18:38:51 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
switch (n - m) {
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
case 1:
|
|
|
|
case -2:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case -1:
|
|
|
|
case 2:
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
2006-12-03 18:38:51 +00:00
|
|
|
}
|
|
|
|
|
2012-12-11 14:29:01 +00:00
|
|
|
static void vectomat(const float vec[3], const float target_up[3], short axis, short upflag, short flags, float m[3][3])
|
2006-12-03 18:38:51 +00:00
|
|
|
{
|
|
|
|
float n[3];
|
|
|
|
float u[3]; /* vector specifying the up axis */
|
|
|
|
float proj[3];
|
|
|
|
float right[3];
|
|
|
|
float neg = -1;
|
2006-12-05 02:06:51 +00:00
|
|
|
int right_index;
|
2010-08-15 15:14:08 +00:00
|
|
|
|
2011-03-27 14:59:55 +00:00
|
|
|
if (normalize_v3_v3(n, vec) == 0.0f) {
|
|
|
|
n[0] = 0.0f;
|
|
|
|
n[1] = 0.0f;
|
|
|
|
n[2] = 1.0f;
|
2006-12-03 18:38:51 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (axis > 2) axis -= 3;
|
2009-11-10 20:43:45 +00:00
|
|
|
else negate_v3(n);
|
2006-12-03 18:38:51 +00:00
|
|
|
|
|
|
|
/* n specifies the transformation of the track axis */
|
2012-10-21 05:46:41 +00:00
|
|
|
if (flags & TARGET_Z_UP) {
|
2006-12-03 18:38:51 +00:00
|
|
|
/* target Z axis is the global up axis */
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(u, target_up);
|
2006-12-03 18:38:51 +00:00
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
else {
|
2006-12-03 18:38:51 +00:00
|
|
|
/* world Z axis is the global up axis */
|
|
|
|
u[0] = 0;
|
|
|
|
u[1] = 0;
|
|
|
|
u[2] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* project the up vector onto the plane specified by n */
|
2009-11-10 20:43:45 +00:00
|
|
|
project_v3_v3v3(proj, u, n); /* first u onto n... */
|
|
|
|
sub_v3_v3v3(proj, u, proj); /* then onto the plane */
|
2006-12-03 18:38:51 +00:00
|
|
|
/* proj specifies the transformation of the up axis */
|
|
|
|
|
2011-03-27 14:59:55 +00:00
|
|
|
if (normalize_v3(proj) == 0.0f) { /* degenerate projection */
|
|
|
|
proj[0] = 0.0f;
|
|
|
|
proj[1] = 1.0f;
|
|
|
|
proj[2] = 0.0f;
|
2006-12-03 18:38:51 +00:00
|
|
|
}
|
|
|
|
|
2007-04-04 13:18:41 +00:00
|
|
|
/* Normalized cross product of n and proj specifies transformation of the right axis */
|
2009-11-10 20:43:45 +00:00
|
|
|
cross_v3_v3v3(right, proj, n);
|
|
|
|
normalize_v3(right);
|
2006-12-03 18:38:51 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (axis != upflag) {
|
2006-12-03 18:38:51 +00:00
|
|
|
right_index = 3 - axis - upflag;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
neg = (float)basis_cross(axis, upflag);
|
|
|
|
|
2006-12-03 18:38:51 +00:00
|
|
|
/* account for up direction, track direction */
|
|
|
|
m[right_index][0] = neg * right[0];
|
|
|
|
m[right_index][1] = neg * right[1];
|
|
|
|
m[right_index][2] = neg * right[2];
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(m[upflag], proj);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(m[axis], n);
|
2006-12-03 18:38:51 +00:00
|
|
|
}
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
/* identity matrix - don't do anything if the two axes are the same */
|
2006-12-03 18:38:51 +00:00
|
|
|
else {
|
2010-08-15 15:14:08 +00:00
|
|
|
unit_m3(m);
|
2006-12-03 18:38:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bTrackToConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = targets->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
|
|
|
float size[3], vec[3];
|
|
|
|
float totmat[3][3];
|
|
|
|
|
|
|
|
/* Get size property, since ob->size is only the object's own relative size, not its global one */
|
2010-05-27 11:56:31 +00:00
|
|
|
mat4_to_size(size, cob->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
/* Clear the object's rotation */
|
2012-05-06 17:22:54 +00:00
|
|
|
cob->matrix[0][0] = size[0];
|
|
|
|
cob->matrix[0][1] = 0;
|
|
|
|
cob->matrix[0][2] = 0;
|
|
|
|
cob->matrix[1][0] = 0;
|
|
|
|
cob->matrix[1][1] = size[1];
|
|
|
|
cob->matrix[1][2] = 0;
|
|
|
|
cob->matrix[2][0] = 0;
|
|
|
|
cob->matrix[2][1] = 0;
|
|
|
|
cob->matrix[2][2] = size[2];
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* targetmat[2] instead of ownermat[2] is passed to vectomat
|
2011-10-15 14:14:22 +00:00
|
|
|
* for backwards compatibility it seems... (Aligorith)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
*/
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
vectomat(vec, ct->matrix[2],
|
2012-05-06 17:22:54 +00:00
|
|
|
(short)data->reserved1, (short)data->reserved2,
|
|
|
|
data->flags, totmat);
|
2012-09-16 15:25:28 +00:00
|
|
|
|
|
|
|
mul_m4_m3m4(cob->matrix, totmat, cob->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
static bConstraintTypeInfo CTI_TRACKTO = {
|
|
|
|
CONSTRAINT_TYPE_TRACKTO, /* type */
|
|
|
|
sizeof(bTrackToConstraint), /* size */
|
2013-03-11 09:06:49 +00:00
|
|
|
"Track To", /* name */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
"bTrackToConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
trackto_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
trackto_new_data, /* new data */
|
|
|
|
trackto_get_tars, /* get constraint targets */
|
|
|
|
trackto_flush_tars, /* flush constraint targets */
|
|
|
|
default_get_tarmat, /* get target matrix */
|
|
|
|
trackto_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* --------- Inverse-Kinemetics --------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void kinematic_new_data(void *cdata)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bKinematicConstraint *data = (bKinematicConstraint *)cdata;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
data->weight = 1.0f;
|
|
|
|
data->orientweight = 1.0f;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
data->iterations = 500;
|
2012-05-06 17:22:54 +00:00
|
|
|
data->dist = 1.0f;
|
|
|
|
data->flag = CONSTRAINT_IK_TIP | CONSTRAINT_IK_STRETCH | CONSTRAINT_IK_POS;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void kinematic_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bKinematicConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* chain target */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* poletarget */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->poletar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int kinematic_get_tars(bConstraint *con, ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bKinematicConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
2008-03-08 02:16:37 +00:00
|
|
|
/* standard target-getting macro for single-target constraints is used twice here */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
|
|
|
|
SINGLETARGET_GET_TARS(con, data->poletar, data->polesubtarget, ct, list);
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 2;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void kinematic_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bKinematicConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
|
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->poletar, data->polesubtarget, ct, list, nocopy);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void kinematic_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bKinematicConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
if (VALID_CONS_TARGET(ct))
|
2011-06-15 14:06:25 +00:00
|
|
|
constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
else if (ct) {
|
|
|
|
if (data->flag & CONSTRAINT_IK_AUTO) {
|
2012-05-06 17:22:54 +00:00
|
|
|
Object *ob = cob->ob;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
if (ob == NULL) {
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(ct->matrix);
|
2006-02-19 17:42:20 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
else {
|
|
|
|
float vec[3];
|
|
|
|
/* move grabtarget into world space */
|
2010-07-26 06:34:56 +00:00
|
|
|
mul_v3_m4v3(vec, ob->obmat, data->grabtarget);
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(ct->matrix, ob->obmat);
|
2010-07-26 06:34:56 +00:00
|
|
|
copy_v3_v3(ct->matrix[3], vec);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(ct->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_KINEMATIC = {
|
|
|
|
CONSTRAINT_TYPE_KINEMATIC, /* type */
|
|
|
|
sizeof(bKinematicConstraint), /* size */
|
|
|
|
"IK", /* name */
|
|
|
|
"bKinematicConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
kinematic_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
kinematic_new_data, /* new data */
|
|
|
|
kinematic_get_tars, /* get constraint targets */
|
|
|
|
kinematic_flush_tars, /* flush constraint targets */
|
|
|
|
kinematic_get_tarmat, /* get target matrix */
|
|
|
|
NULL /* evaluate - solved as separate loop */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* -------- Follow-Path Constraint ---------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void followpath_new_data(void *cdata)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bFollowPathConstraint *data = (bFollowPathConstraint *)cdata;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
data->trackflag = TRACK_Y;
|
|
|
|
data->upflag = UP_Z;
|
|
|
|
data->offset = 0;
|
|
|
|
data->followflag = 0;
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void followpath_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bFollowPathConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int followpath_get_tars(bConstraint *con, ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bFollowPathConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints without subtargets */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGETNS_GET_TARS(con, data->tar, ct, list);
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void followpath_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bFollowPathConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bFollowPathConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
2012-05-06 17:22:54 +00:00
|
|
|
Curve *cu = ct->tar->data;
|
2010-10-08 07:29:08 +00:00
|
|
|
float vec[4], dir[3], radius;
|
2012-05-06 17:22:54 +00:00
|
|
|
float totmat[4][4] = MAT4_UNITY;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
float curvetime;
|
2010-11-28 06:03:30 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(ct->matrix);
|
2010-11-28 06:03:30 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* 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)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* only happens on reload file, but violates depsgraph still... fix! */
|
2012-05-06 17:22:54 +00:00
|
|
|
if (cu->path == NULL || cu->path->data == NULL)
|
2012-05-07 06:58:03 +00:00
|
|
|
BKE_displist_make_curveTypes(cob->scene, ct->tar, 0);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
if (cu->path && cu->path->data) {
|
2010-10-08 07:29:08 +00:00
|
|
|
float quat[4];
|
|
|
|
if ((data->followflag & FOLLOWPATH_STATIC) == 0) {
|
2009-09-16 17:43:09 +00:00
|
|
|
/* animated position along curve depending on time */
|
2011-12-30 14:52:03 +00:00
|
|
|
Nurb *nu = cu->nurb.first;
|
2012-05-06 17:22:54 +00:00
|
|
|
curvetime = cu->ctime - data->offset;
|
2009-09-16 17:43:09 +00:00
|
|
|
|
|
|
|
/* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated,
|
|
|
|
* but this will only work if it actually is animated...
|
|
|
|
*
|
2009-12-14 06:25:42 +00:00
|
|
|
* we divide the curvetime calculated in the previous step by the length of the path, to get a time
|
|
|
|
* factor, which then gets clamped to lie within 0.0 - 1.0 range
|
2009-09-16 17:43:09 +00:00
|
|
|
*/
|
2009-12-14 06:25:42 +00:00
|
|
|
curvetime /= cu->pathlen;
|
2011-12-30 14:52:03 +00:00
|
|
|
|
|
|
|
if (nu && nu->flagu & CU_NURB_CYCLIC) {
|
|
|
|
/* If the curve is cyclic, enable looping around if the time is
|
|
|
|
* outside the bounds 0..1 */
|
|
|
|
if ((curvetime < 0.0f) || (curvetime > 1.0f)) {
|
2012-02-04 06:55:29 +00:00
|
|
|
curvetime -= floorf(curvetime);
|
2011-12-30 14:52:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* The curve is not cyclic, so clamp to the begin/end points. */
|
|
|
|
CLAMP(curvetime, 0.0f, 1.0f);
|
|
|
|
}
|
2003-10-21 13:22:07 +00:00
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
else {
|
|
|
|
/* fixed position along curve */
|
2012-05-06 17:22:54 +00:00
|
|
|
curvetime = data->offset_fac;
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
if (where_on_path(ct->tar, curvetime, vec, dir, (data->followflag & FOLLOWPATH_FOLLOW) ? quat : NULL, &radius, NULL) ) { /* quat_pt is quat or NULL*/
|
2009-09-16 17:43:09 +00:00
|
|
|
if (data->followflag & FOLLOWPATH_FOLLOW) {
|
2010-10-08 07:29:08 +00:00
|
|
|
#if 0
|
|
|
|
float x1, q[4];
|
2009-12-14 06:25:42 +00:00
|
|
|
vec_to_quat(quat, dir, (short)data->trackflag, (short)data->upflag);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(dir);
|
2013-04-04 04:22:38 +00:00
|
|
|
q[0] = cosf(0.5 * vec[3]);
|
|
|
|
x1 = sinf(0.5 * vec[3]);
|
2012-05-06 17:22:54 +00:00
|
|
|
q[1] = -x1 * dir[0];
|
|
|
|
q[2] = -x1 * dir[1];
|
|
|
|
q[3] = -x1 * dir[2];
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_qt_qtqt(quat, q, quat);
|
2010-10-08 07:29:08 +00:00
|
|
|
#else
|
|
|
|
quat_apply_track(quat, data->trackflag, data->upflag);
|
|
|
|
#endif
|
|
|
|
|
2009-12-14 06:25:42 +00:00
|
|
|
quat_to_mat4(totmat, quat);
|
2003-10-21 13:22:07 +00:00
|
|
|
}
|
2010-10-08 07:29:08 +00:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
if (data->followflag & FOLLOWPATH_RADIUS) {
|
|
|
|
float tmat[4][4], rmat[4][4];
|
2009-11-10 20:43:45 +00:00
|
|
|
scale_m4_fl(tmat, radius);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(rmat, tmat, totmat);
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(totmat, rmat);
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
2009-11-01 11:29:40 +00:00
|
|
|
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(totmat[3], vec);
|
2007-06-18 07:41:21 +00:00
|
|
|
|
2013-08-06 01:45:29 +00:00
|
|
|
mul_m4_m4m4(ct->matrix, ct->tar->obmat, totmat);
|
2007-06-18 07:41:21 +00:00
|
|
|
}
|
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
else if (ct)
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(ct->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void followpath_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bConstraintTarget *ct = targets->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* only evaluate if there is a target */
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
|
|
|
float obmat[4][4];
|
2009-09-16 17:43:09 +00:00
|
|
|
float size[3];
|
2012-05-06 17:22:54 +00:00
|
|
|
bFollowPathConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2009-12-14 06:25:42 +00:00
|
|
|
/* get Object transform (loc/rot/size) to determine transformation from path */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: this used to be local at one point, but is probably more useful as-is */
|
2009-12-14 06:25:42 +00:00
|
|
|
copy_m4_m4(obmat, cob->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* get scaling of object before applying constraint */
|
2009-12-14 06:25:42 +00:00
|
|
|
mat4_to_size(size, cob->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* apply targetmat - containing location on path, and rotation */
|
2013-08-06 01:45:29 +00:00
|
|
|
mul_m4_m4m4(cob->matrix, ct->matrix, obmat);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* un-apply scaling caused by path */
|
2012-05-06 17:22:54 +00:00
|
|
|
if ((data->followflag & FOLLOWPATH_RADIUS) == 0) { /* XXX - assume that scale correction means that radius will have some scale error in it - Campbell */
|
2009-09-16 17:43:09 +00:00
|
|
|
float obsize[3];
|
2009-11-01 11:29:40 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
mat4_to_size(obsize, cob->matrix);
|
2009-09-16 17:43:09 +00:00
|
|
|
if (obsize[0])
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(cob->matrix[0], size[0] / obsize[0]);
|
2009-09-16 17:43:09 +00:00
|
|
|
if (obsize[1])
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(cob->matrix[1], size[1] / obsize[1]);
|
2009-09-16 17:43:09 +00:00
|
|
|
if (obsize[2])
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(cob->matrix[2], size[2] / obsize[2]);
|
2009-09-16 17:43:09 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_FOLLOWPATH = {
|
|
|
|
CONSTRAINT_TYPE_FOLLOWPATH, /* type */
|
|
|
|
sizeof(bFollowPathConstraint), /* size */
|
|
|
|
"Follow Path", /* name */
|
|
|
|
"bFollowPathConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
followpath_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
followpath_new_data, /* new data */
|
|
|
|
followpath_get_tars, /* get constraint targets */
|
|
|
|
followpath_flush_tars, /* flush constraint targets */
|
|
|
|
followpath_get_tarmat, /* get target matrix */
|
|
|
|
followpath_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* --------- Limit Location --------- */
|
|
|
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void loclimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
bLocLimitConstraint *data = con->data;
|
|
|
|
|
|
|
|
if (data->flag & LIMIT_XMIN) {
|
|
|
|
if (cob->matrix[3][0] < data->xmin)
|
|
|
|
cob->matrix[3][0] = data->xmin;
|
|
|
|
}
|
|
|
|
if (data->flag & LIMIT_XMAX) {
|
|
|
|
if (cob->matrix[3][0] > data->xmax)
|
|
|
|
cob->matrix[3][0] = data->xmax;
|
|
|
|
}
|
|
|
|
if (data->flag & LIMIT_YMIN) {
|
|
|
|
if (cob->matrix[3][1] < data->ymin)
|
|
|
|
cob->matrix[3][1] = data->ymin;
|
|
|
|
}
|
|
|
|
if (data->flag & LIMIT_YMAX) {
|
|
|
|
if (cob->matrix[3][1] > data->ymax)
|
|
|
|
cob->matrix[3][1] = data->ymax;
|
|
|
|
}
|
|
|
|
if (data->flag & LIMIT_ZMIN) {
|
|
|
|
if (cob->matrix[3][2] < data->zmin)
|
|
|
|
cob->matrix[3][2] = data->zmin;
|
|
|
|
}
|
|
|
|
if (data->flag & LIMIT_ZMAX) {
|
|
|
|
if (cob->matrix[3][2] > data->zmax)
|
|
|
|
cob->matrix[3][2] = data->zmax;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_LOCLIMIT = {
|
|
|
|
CONSTRAINT_TYPE_LOCLIMIT, /* type */
|
|
|
|
sizeof(bLocLimitConstraint), /* size */
|
|
|
|
"Limit Location", /* name */
|
|
|
|
"bLocLimitConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
NULL, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
NULL, /* new data */
|
|
|
|
NULL, /* get constraint targets */
|
|
|
|
NULL, /* flush constraint targets */
|
|
|
|
NULL, /* get target matrix */
|
|
|
|
loclimit_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* -------- Limit Rotation --------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void rotlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
bRotLimitConstraint *data = con->data;
|
|
|
|
float loc[3];
|
|
|
|
float eul[3];
|
|
|
|
float size[3];
|
|
|
|
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(loc, cob->matrix[3]);
|
2010-05-27 11:56:31 +00:00
|
|
|
mat4_to_size(size, cob->matrix);
|
2010-10-30 19:29:11 +00:00
|
|
|
|
2010-05-27 11:56:31 +00:00
|
|
|
mat4_to_eulO(eul, cob->rotOrder, cob->matrix);
|
2010-10-26 16:55:38 +00:00
|
|
|
|
2010-01-25 06:24:05 +00:00
|
|
|
/* constraint data uses radians internally */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* limiting of euler values... */
|
|
|
|
if (data->flag & LIMIT_XROT) {
|
|
|
|
if (eul[0] < data->xmin)
|
|
|
|
eul[0] = data->xmin;
|
2007-04-07 03:32:57 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (eul[0] > data->xmax)
|
|
|
|
eul[0] = data->xmax;
|
|
|
|
}
|
|
|
|
if (data->flag & LIMIT_YROT) {
|
|
|
|
if (eul[1] < data->ymin)
|
|
|
|
eul[1] = data->ymin;
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (eul[1] > data->ymax)
|
|
|
|
eul[1] = data->ymax;
|
|
|
|
}
|
|
|
|
if (data->flag & LIMIT_ZROT) {
|
|
|
|
if (eul[2] < data->zmin)
|
|
|
|
eul[2] = data->zmin;
|
2007-07-21 07:26:15 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (eul[2] > data->zmax)
|
|
|
|
eul[2] = data->zmax;
|
|
|
|
}
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2004-09-05 20:21:16 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
static bConstraintTypeInfo CTI_ROTLIMIT = {
|
|
|
|
CONSTRAINT_TYPE_ROTLIMIT, /* type */
|
|
|
|
sizeof(bRotLimitConstraint), /* size */
|
|
|
|
"Limit Rotation", /* name */
|
|
|
|
"bRotLimitConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
NULL, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
NULL, /* new data */
|
|
|
|
NULL, /* get constraint targets */
|
|
|
|
NULL, /* flush constraint targets */
|
|
|
|
NULL, /* get target matrix */
|
|
|
|
rotlimit_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
2012-06-08 21:04:48 +00:00
|
|
|
/* --------- Limit Scale --------- */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void sizelimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
bSizeLimitConstraint *data = con->data;
|
|
|
|
float obsize[3], size[3];
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
mat4_to_size(size, cob->matrix);
|
|
|
|
mat4_to_size(obsize, cob->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
if (data->flag & LIMIT_XMIN) {
|
|
|
|
if (size[0] < data->xmin)
|
2012-10-21 05:46:41 +00:00
|
|
|
size[0] = data->xmin;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
if (data->flag & LIMIT_XMAX) {
|
|
|
|
if (size[0] > data->xmax)
|
|
|
|
size[0] = data->xmax;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (data->flag & LIMIT_YMIN) {
|
|
|
|
if (size[1] < data->ymin)
|
2012-10-21 05:46:41 +00:00
|
|
|
size[1] = data->ymin;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
if (data->flag & LIMIT_YMAX) {
|
|
|
|
if (size[1] > data->ymax)
|
|
|
|
size[1] = data->ymax;
|
|
|
|
}
|
|
|
|
if (data->flag & LIMIT_ZMIN) {
|
|
|
|
if (size[2] < data->zmin)
|
2012-10-21 05:46:41 +00:00
|
|
|
size[2] = data->zmin;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
if (data->flag & LIMIT_ZMAX) {
|
|
|
|
if (size[2] > data->zmax)
|
|
|
|
size[2] = data->zmax;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obsize[0])
|
2012-05-06 17:22:54 +00:00
|
|
|
mul_v3_fl(cob->matrix[0], size[0] / obsize[0]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (obsize[1])
|
2012-05-06 17:22:54 +00:00
|
|
|
mul_v3_fl(cob->matrix[1], size[1] / obsize[1]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (obsize[2])
|
2012-05-06 17:22:54 +00:00
|
|
|
mul_v3_fl(cob->matrix[2], size[2] / obsize[2]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
static bConstraintTypeInfo CTI_SIZELIMIT = {
|
|
|
|
CONSTRAINT_TYPE_SIZELIMIT, /* type */
|
|
|
|
sizeof(bSizeLimitConstraint), /* size */
|
2012-06-08 21:04:48 +00:00
|
|
|
"Limit Scale", /* name */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
"bSizeLimitConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
NULL, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
NULL, /* new data */
|
|
|
|
NULL, /* get constraint targets */
|
|
|
|
NULL, /* flush constraint targets */
|
|
|
|
NULL, /* get target matrix */
|
|
|
|
sizelimit_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ----------- Copy Location ------------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void loclike_new_data(void *cdata)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bLocateLikeConstraint *data = (bLocateLikeConstraint *)cdata;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
data->flag = LOCLIKE_X | LOCLIKE_Y | LOCLIKE_Z;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void loclike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bLocateLikeConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int loclike_get_tars(bConstraint *con, ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bLocateLikeConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void loclike_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bLocateLikeConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void loclike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bLocateLikeConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = targets->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
|
|
|
float offset[3] = {0.0f, 0.0f, 0.0f};
|
|
|
|
|
|
|
|
if (data->flag & LOCLIKE_OFFSET)
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(offset, cob->matrix[3]);
|
2006-09-22 15:57:58 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (data->flag & LOCLIKE_X) {
|
|
|
|
cob->matrix[3][0] = ct->matrix[3][0];
|
2006-09-22 15:57:58 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (data->flag & LOCLIKE_X_INVERT) cob->matrix[3][0] *= -1;
|
|
|
|
cob->matrix[3][0] += offset[0];
|
|
|
|
}
|
|
|
|
if (data->flag & LOCLIKE_Y) {
|
|
|
|
cob->matrix[3][1] = ct->matrix[3][1];
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (data->flag & LOCLIKE_Y_INVERT) cob->matrix[3][1] *= -1;
|
|
|
|
cob->matrix[3][1] += offset[1];
|
|
|
|
}
|
|
|
|
if (data->flag & LOCLIKE_Z) {
|
|
|
|
cob->matrix[3][2] = ct->matrix[3][2];
|
2005-09-07 00:11:39 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (data->flag & LOCLIKE_Z_INVERT) cob->matrix[3][2] *= -1;
|
|
|
|
cob->matrix[3][2] += offset[2];
|
2005-09-07 00:11:39 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
static bConstraintTypeInfo CTI_LOCLIKE = {
|
|
|
|
CONSTRAINT_TYPE_LOCLIKE, /* type */
|
|
|
|
sizeof(bLocateLikeConstraint), /* size */
|
|
|
|
"Copy Location", /* name */
|
|
|
|
"bLocateLikeConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
loclike_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
loclike_new_data, /* new data */
|
|
|
|
loclike_get_tars, /* get constraint targets */
|
|
|
|
loclike_flush_tars, /* flush constraint targets */
|
Patch #7767: Constraint Subtargets can now target anywhere on a bone, not just the head or tail
Patch by: Roland Hess (harkyman)
For example, a constraint can be sub-targeted at the 50% (or 31.2% or 85% etc.) point of its target bone, giving you enormous rigging flexibility and removing the need for complex contraptions to do such things as:
- A bone whose base slides only between to points on a rig (CopyLoc with a variable, animated subtarget point)
- Bones that attach to multiple points along another bone (CopyLocs, each with a different head/tail percentage)
- Bones that need to stretch to a point midway between specific spots on two other bones (old way: too crazy to mention; new way: stretch bone between points on end bones, then another stretch to the midpoint of the first stretch)
It is only used for the constraint types for which it is relevant: CopyLoc, TrackTo, StretchTo and MinMax, TrackTo, and Floor.
Notes:
- This is accessed by the Head/Tail number-slider.
- This value can be animated per constraint
- The old "Copy Bone Tail" option for the CopyLoc constraint has been automatically converted to 1.0 Head/Bone values for the affected constraints
- In the code, this value is in the bConstraint struct, so it is available for all constraints, even though only a few implement it.
2007-11-12 04:17:03 +00:00
|
|
|
default_get_tarmat, /* get target matrix */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
loclike_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ----------- Copy Rotation ------------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void rotlike_new_data(void *cdata)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bRotateLikeConstraint *data = (bRotateLikeConstraint *)cdata;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
data->flag = ROTLIKE_X | ROTLIKE_Y | ROTLIKE_Z;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void rotlike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-06-12 08:32:06 +00:00
|
|
|
bRotateLikeConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int rotlike_get_tars(bConstraint *con, ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bRotateLikeConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void rotlike_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bRotateLikeConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void rotlike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bRotateLikeConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = targets->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
2012-05-06 17:22:54 +00:00
|
|
|
float loc[3];
|
|
|
|
float eul[3], obeul[3];
|
|
|
|
float size[3];
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(loc, cob->matrix[3]);
|
2010-05-27 11:56:31 +00:00
|
|
|
mat4_to_size(size, cob->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
/* to allow compatible rotations, must get both rotations in the order of the owner... */
|
2010-05-27 11:56:31 +00:00
|
|
|
mat4_to_eulO(obeul, cob->rotOrder, cob->matrix);
|
2010-09-24 17:49:33 +00:00
|
|
|
/* we must get compatible eulers from the beginning because some of them can be modified below (see bug #21875) */
|
|
|
|
mat4_to_compatible_eulO(eul, obeul, cob->rotOrder, ct->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
if ((data->flag & ROTLIKE_X) == 0)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
eul[0] = obeul[0];
|
2007-10-30 11:18:50 +00:00
|
|
|
else {
|
|
|
|
if (data->flag & ROTLIKE_OFFSET)
|
2010-04-25 03:34:16 +00:00
|
|
|
rotate_eulO(eul, cob->rotOrder, 'X', obeul[0]);
|
2007-10-30 11:18:50 +00:00
|
|
|
|
|
|
|
if (data->flag & ROTLIKE_X_INVERT)
|
|
|
|
eul[0] *= -1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
if ((data->flag & ROTLIKE_Y) == 0)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
eul[1] = obeul[1];
|
2007-10-30 11:18:50 +00:00
|
|
|
else {
|
|
|
|
if (data->flag & ROTLIKE_OFFSET)
|
2010-04-25 03:34:16 +00:00
|
|
|
rotate_eulO(eul, cob->rotOrder, 'Y', obeul[1]);
|
2007-10-30 11:18:50 +00:00
|
|
|
|
|
|
|
if (data->flag & ROTLIKE_Y_INVERT)
|
|
|
|
eul[1] *= -1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
if ((data->flag & ROTLIKE_Z) == 0)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
eul[2] = obeul[2];
|
2007-10-30 11:18:50 +00:00
|
|
|
else {
|
|
|
|
if (data->flag & ROTLIKE_OFFSET)
|
2010-04-25 03:34:16 +00:00
|
|
|
rotate_eulO(eul, cob->rotOrder, 'Z', obeul[2]);
|
2007-10-30 11:18:50 +00:00
|
|
|
|
|
|
|
if (data->flag & ROTLIKE_Z_INVERT)
|
|
|
|
eul[2] *= -1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2010-09-24 17:49:33 +00:00
|
|
|
/* good to make eulers compatible again, since we don't know how much they were changed above */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
compatible_eul(eul, obeul);
|
2009-11-10 20:43:45 +00:00
|
|
|
loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_ROTLIKE = {
|
|
|
|
CONSTRAINT_TYPE_ROTLIKE, /* type */
|
|
|
|
sizeof(bRotateLikeConstraint), /* size */
|
|
|
|
"Copy Rotation", /* name */
|
|
|
|
"bRotateLikeConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
rotlike_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
rotlike_new_data, /* new data */
|
|
|
|
rotlike_get_tars, /* get constraint targets */
|
|
|
|
rotlike_flush_tars, /* flush constraint targets */
|
|
|
|
default_get_tarmat, /* get target matrix */
|
|
|
|
rotlike_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
2012-06-08 21:04:48 +00:00
|
|
|
/* ---------- Copy Scale ---------- */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void sizelike_new_data(void *cdata)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bSizeLikeConstraint *data = (bSizeLikeConstraint *)cdata;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
data->flag = SIZELIKE_X | SIZELIKE_Y | SIZELIKE_Z;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void sizelike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bSizeLikeConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int sizelike_get_tars(bConstraint *con, ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bSizeLikeConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void sizelike_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bSizeLikeConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void sizelike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bSizeLikeConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = targets->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
|
|
|
float obsize[3], size[3];
|
|
|
|
|
2010-01-02 04:14:17 +00:00
|
|
|
mat4_to_size(size, ct->matrix);
|
|
|
|
mat4_to_size(obsize, cob->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2007-10-31 10:04:57 +00:00
|
|
|
if ((data->flag & SIZELIKE_X) && (obsize[0] != 0)) {
|
|
|
|
if (data->flag & SIZELIKE_OFFSET) {
|
|
|
|
size[0] += (obsize[0] - 1.0f);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(cob->matrix[0], size[0] / obsize[0]);
|
2007-10-31 10:04:57 +00:00
|
|
|
}
|
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(cob->matrix[0], size[0] / obsize[0]);
|
2007-10-31 10:04:57 +00:00
|
|
|
}
|
|
|
|
if ((data->flag & SIZELIKE_Y) && (obsize[1] != 0)) {
|
|
|
|
if (data->flag & SIZELIKE_OFFSET) {
|
|
|
|
size[1] += (obsize[1] - 1.0f);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(cob->matrix[1], size[1] / obsize[1]);
|
2007-10-31 10:04:57 +00:00
|
|
|
}
|
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(cob->matrix[1], size[1] / obsize[1]);
|
2007-10-31 10:04:57 +00:00
|
|
|
}
|
|
|
|
if ((data->flag & SIZELIKE_Z) && (obsize[2] != 0)) {
|
|
|
|
if (data->flag & SIZELIKE_OFFSET) {
|
|
|
|
size[2] += (obsize[2] - 1.0f);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(cob->matrix[2], size[2] / obsize[2]);
|
2007-10-31 10:04:57 +00:00
|
|
|
}
|
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(cob->matrix[2], size[2] / obsize[2]);
|
2007-10-31 10:04:57 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_SIZELIKE = {
|
|
|
|
CONSTRAINT_TYPE_SIZELIKE, /* type */
|
|
|
|
sizeof(bSizeLikeConstraint), /* size */
|
|
|
|
"Copy Scale", /* name */
|
|
|
|
"bSizeLikeConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
sizelike_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
sizelike_new_data, /* new data */
|
|
|
|
sizelike_get_tars, /* get constraint targets */
|
|
|
|
sizelike_flush_tars, /* flush constraint targets */
|
|
|
|
default_get_tarmat, /* get target matrix */
|
|
|
|
sizelike_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
2010-01-02 04:14:17 +00:00
|
|
|
/* ----------- Copy Transforms ------------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void translike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bTransLikeConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int translike_get_tars(bConstraint *con, ListBase *list)
|
2010-01-02 04:14:17 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bTransLikeConstraint *data = con->data;
|
2010-01-02 04:14:17 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
|
2010-01-02 04:14:17 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void translike_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
2010-01-02 04:14:17 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bTransLikeConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
2010-01-02 04:14:17 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
|
2010-01-02 04:14:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void translike_evaluate(bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets)
|
2010-01-02 04:14:17 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bConstraintTarget *ct = targets->first;
|
2010-01-02 04:14:17 +00:00
|
|
|
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
|
|
|
/* just copy the entire transform matrix of the target */
|
|
|
|
copy_m4_m4(cob->matrix, ct->matrix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_TRANSLIKE = {
|
|
|
|
CONSTRAINT_TYPE_TRANSLIKE, /* type */
|
|
|
|
sizeof(bTransLikeConstraint), /* size */
|
|
|
|
"Copy Transforms", /* name */
|
|
|
|
"bTransLikeConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
translike_id_looper, /* id looper */
|
2010-01-02 04:14:17 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
NULL, /* new data */
|
|
|
|
translike_get_tars, /* get constraint targets */
|
|
|
|
translike_flush_tars, /* flush constraint targets */
|
|
|
|
default_get_tarmat, /* get target matrix */
|
|
|
|
translike_evaluate /* evaluate */
|
|
|
|
};
|
2008-10-28 18:47:13 +00:00
|
|
|
|
2010-03-16 12:55:56 +00:00
|
|
|
/* ---------- Maintain Volume ---------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void samevolume_new_data(void *cdata)
|
2010-03-16 12:55:56 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bSameVolumeConstraint *data = (bSameVolumeConstraint *)cdata;
|
2010-03-16 12:55:56 +00:00
|
|
|
|
|
|
|
data->flag = SAMEVOL_Y;
|
|
|
|
data->volume = 1.0f;
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void samevolume_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
2010-03-16 12:55:56 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bSameVolumeConstraint *data = con->data;
|
2010-03-16 12:55:56 +00:00
|
|
|
|
2010-05-27 11:56:31 +00:00
|
|
|
float volume = data->volume;
|
|
|
|
float fac = 1.0f;
|
2010-03-16 12:55:56 +00:00
|
|
|
float obsize[3];
|
|
|
|
|
|
|
|
mat4_to_size(obsize, cob->matrix);
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2012-03-04 04:35:12 +00:00
|
|
|
/* calculate normalizing scale factor for non-essential values */
|
2010-05-27 11:56:31 +00:00
|
|
|
if (obsize[data->flag] != 0)
|
2011-03-27 14:59:55 +00:00
|
|
|
fac = sqrtf(volume / obsize[data->flag]) / obsize[data->flag];
|
2010-05-27 11:56:31 +00:00
|
|
|
|
|
|
|
/* apply scaling factor to the channels not being kept */
|
2010-03-16 12:55:56 +00:00
|
|
|
switch (data->flag) {
|
|
|
|
case SAMEVOL_X:
|
2010-05-27 11:56:31 +00:00
|
|
|
mul_v3_fl(cob->matrix[1], fac);
|
|
|
|
mul_v3_fl(cob->matrix[2], fac);
|
2010-03-16 12:55:56 +00:00
|
|
|
break;
|
|
|
|
case SAMEVOL_Y:
|
2010-05-27 11:56:31 +00:00
|
|
|
mul_v3_fl(cob->matrix[0], fac);
|
|
|
|
mul_v3_fl(cob->matrix[2], fac);
|
2010-03-16 12:55:56 +00:00
|
|
|
break;
|
|
|
|
case SAMEVOL_Z:
|
2010-05-27 11:56:31 +00:00
|
|
|
mul_v3_fl(cob->matrix[0], fac);
|
|
|
|
mul_v3_fl(cob->matrix[1], fac);
|
2010-03-16 12:55:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_SAMEVOL = {
|
|
|
|
CONSTRAINT_TYPE_SAMEVOL, /* type */
|
|
|
|
sizeof(bSameVolumeConstraint), /* size */
|
|
|
|
"Maintain Volume", /* name */
|
|
|
|
"bSameVolumeConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
|
|
|
NULL, /* id looper */
|
|
|
|
NULL, /* copy data */
|
|
|
|
samevolume_new_data, /* new data */
|
|
|
|
NULL, /* get constraint targets */
|
|
|
|
NULL, /* flush constraint targets */
|
|
|
|
NULL, /* get target matrix */
|
|
|
|
samevolume_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* ----------- Python Constraint -------------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void pycon_free(bConstraint *con)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bPythonConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* id-properties */
|
|
|
|
IDP_FreeProperty(data->prop);
|
|
|
|
MEM_freeN(data->prop);
|
|
|
|
|
|
|
|
/* multiple targets */
|
2007-10-23 08:23:57 +00:00
|
|
|
BLI_freelistN(&data->targets);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void pycon_copy(bConstraint *con, bConstraint *srccon)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
bPythonConstraint *pycon = (bPythonConstraint *)con->data;
|
|
|
|
bPythonConstraint *opycon = (bPythonConstraint *)srccon->data;
|
|
|
|
|
|
|
|
pycon->prop = IDP_CopyProperty(opycon->prop);
|
2008-01-01 18:29:19 +00:00
|
|
|
BLI_duplicatelist(&pycon->targets, &opycon->targets);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void pycon_new_data(void *cdata)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bPythonConstraint *data = (bPythonConstraint *)cdata;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* everything should be set correctly by calloc, except for the prop->type constant.*/
|
|
|
|
data->prop = MEM_callocN(sizeof(IDProperty), "PyConstraintProps");
|
|
|
|
data->prop->type = IDP_GROUP;
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int pycon_get_tars(bConstraint *con, ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bPythonConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
list->first = data->targets.first;
|
|
|
|
list->last = data->targets.last;
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return data->tarnum;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void pycon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bPythonConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* targets */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (ct = data->targets.first; ct; ct = ct->next)
|
|
|
|
func(con, (ID **)&ct->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* script */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->text, TRUE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* Whether this approach is maintained remains to be seen (aligorith) */
|
2012-05-06 17:22:54 +00:00
|
|
|
static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2012-05-06 17:22:54 +00:00
|
|
|
bPythonConstraint *data = con->data;
|
2010-04-12 00:36:50 +00:00
|
|
|
#endif
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
|
|
|
/* special exception for curves - depsgraph issues */
|
|
|
|
if (ct->tar->type == OB_CURVE) {
|
2012-05-06 17:22:54 +00:00
|
|
|
Curve *cu = ct->tar->data;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* this check is to make sure curve objects get updated on file load correctly.*/
|
2012-05-06 17:22:54 +00:00
|
|
|
if (cu->path == NULL || cu->path->data == NULL) /* only happens on reload file, but violates depsgraph still... fix! */
|
2012-10-21 05:46:41 +00:00
|
|
|
BKE_displist_make_curveTypes(cob->scene, ct->tar, 0);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* firstly calculate the matrix the normal way, then let the py-function override
|
|
|
|
* this matrix if it needs to do so
|
|
|
|
*/
|
2011-06-15 14:06:25 +00:00
|
|
|
constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
|
2008-09-19 12:43:21 +00:00
|
|
|
|
|
|
|
/* only execute target calculation if allowed */
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2010-02-27 01:47:46 +00:00
|
|
|
if (G.f & G_SCRIPT_AUTOEXEC)
|
2008-09-19 12:43:21 +00:00
|
|
|
BPY_pyconstraint_target(data, ct);
|
2008-10-28 18:47:13 +00:00
|
|
|
#endif
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
else if (ct)
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(ct->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void pycon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifndef WITH_PYTHON
|
2010-10-23 16:03:31 +00:00
|
|
|
(void)con; (void)cob; (void)targets; /* unused */
|
2008-10-28 18:47:13 +00:00
|
|
|
return;
|
|
|
|
#else
|
2012-05-06 17:22:54 +00:00
|
|
|
bPythonConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2008-09-19 12:43:21 +00:00
|
|
|
/* only evaluate in python if we're allowed to do so */
|
2012-05-06 17:22:54 +00:00
|
|
|
if ((G.f & G_SCRIPT_AUTOEXEC) == 0) return;
|
2008-06-01 16:13:04 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* currently removed, until I this can be re-implemented for multiple targets */
|
|
|
|
#if 0
|
|
|
|
/* Firstly, run the 'driver' function which has direct access to the objects involved
|
|
|
|
* Technically, this is potentially dangerous as users may abuse this and cause dependency-problems,
|
|
|
|
* but it also allows certain 'clever' rigging hacks to work.
|
|
|
|
*/
|
|
|
|
BPY_pyconstraint_driver(data, cob, targets);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Now, run the actual 'constraint' function, which should only access the matrices */
|
2011-01-05 02:08:54 +00:00
|
|
|
BPY_pyconstraint_exec(data, cob, targets);
|
2010-10-31 04:11:39 +00:00
|
|
|
#endif /* WITH_PYTHON */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_PYTHON = {
|
|
|
|
CONSTRAINT_TYPE_PYTHON, /* type */
|
|
|
|
sizeof(bPythonConstraint), /* size */
|
|
|
|
"Script", /* name */
|
|
|
|
"bPythonConstraint", /* struct name */
|
|
|
|
pycon_free, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
pycon_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
pycon_copy, /* copy data */
|
|
|
|
pycon_new_data, /* new data */
|
|
|
|
pycon_get_tars, /* get constraint targets */
|
|
|
|
NULL, /* flush constraint targets */
|
|
|
|
pycon_get_tarmat, /* get target matrix */
|
|
|
|
pycon_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* -------- Action Constraint ----------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void actcon_new_data(void *cdata)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bActionConstraint *data = (bActionConstraint *)cdata;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2011-10-15 14:14:22 +00:00
|
|
|
/* set type to 20 (Loc X), as 0 is Rot X for backwards compatibility */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
data->type = 20;
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void actcon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bActionConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* action */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->act, TRUE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int actcon_get_tars(bConstraint *con, ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bActionConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void actcon_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bActionConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
bActionConstraint *data = con->data;
|
|
|
|
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
|
|
|
float tempmat[4][4], vec[3];
|
|
|
|
float s, t;
|
|
|
|
short axis;
|
|
|
|
|
2012-03-02 16:05:54 +00:00
|
|
|
/* initialize return matrix */
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(ct->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* get the transform matrix of the target */
|
2011-06-15 14:06:25 +00:00
|
|
|
constraint_target_to_mat4(ct->tar, ct->subtarget, tempmat, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* determine where in transform range target is */
|
2011-10-15 14:14:22 +00:00
|
|
|
/* data->type is mapped as follows for backwards compatibility:
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
* 00,01,02 - rotation (it used to be like this)
|
2012-05-06 17:22:54 +00:00
|
|
|
* 10,11,12 - scaling
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
* 20,21,22 - location
|
|
|
|
*/
|
|
|
|
if (data->type < 10) {
|
|
|
|
/* extract rotation (is in whatever space target should be in) */
|
2009-11-14 02:50:45 +00:00
|
|
|
mat4_to_eul(vec, tempmat);
|
2011-09-17 09:43:51 +00:00
|
|
|
mul_v3_fl(vec, RAD2DEGF(1.0f)); /* rad -> deg */
|
2012-05-06 17:22:54 +00:00
|
|
|
axis = data->type;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
else if (data->type < 20) {
|
|
|
|
/* extract scaling (is in whatever space target should be in) */
|
2009-11-14 02:50:45 +00:00
|
|
|
mat4_to_size(vec, tempmat);
|
2012-05-06 17:22:54 +00:00
|
|
|
axis = data->type - 10;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* extract location */
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(vec, tempmat[3]);
|
2012-05-06 17:22:54 +00:00
|
|
|
axis = data->type - 20;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2013-08-04 18:12:49 +00:00
|
|
|
BLI_assert((unsigned int)axis < 3);
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* Target defines the animation */
|
2012-05-06 17:22:54 +00:00
|
|
|
s = (vec[axis] - data->min) / (data->max - data->min);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
CLAMP(s, 0, 1);
|
2012-05-06 17:22:54 +00:00
|
|
|
t = (s * (data->end - data->start)) + data->start;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & G_DEBUG)
|
2012-05-06 17:22:54 +00:00
|
|
|
printf("do Action Constraint %s - Ob %s Pchan %s\n", con->name, cob->ob->id.name + 2, (cob->pchan) ? cob->pchan->name : NULL);
|
2009-01-29 11:22:34 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* Get the appropriate information from the action */
|
2012-06-12 11:54:31 +00:00
|
|
|
if (cob->type == CONSTRAINT_OBTYPE_OBJECT || (data->flag & ACTCON_BONE_USE_OBJECT_ACTION)) {
|
2012-06-12 06:22:23 +00:00
|
|
|
Object workob;
|
|
|
|
|
|
|
|
/* evaluate using workob */
|
2012-07-07 22:51:57 +00:00
|
|
|
/* FIXME: we don't have any consistent standards on limiting effects on object... */
|
2012-06-12 06:22:23 +00:00
|
|
|
what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t);
|
|
|
|
BKE_object_to_mat4(&workob, ct->matrix);
|
|
|
|
}
|
|
|
|
else if (cob->type == CONSTRAINT_OBTYPE_BONE) {
|
2009-01-29 11:22:34 +00:00
|
|
|
Object workob;
|
2007-10-22 02:43:07 +00:00
|
|
|
bPose *pose;
|
|
|
|
bPoseChannel *pchan, *tchan;
|
|
|
|
|
|
|
|
/* make a temporary pose and evaluate using that */
|
|
|
|
pose = MEM_callocN(sizeof(bPose), "pose");
|
|
|
|
|
2009-11-14 02:50:45 +00:00
|
|
|
/* 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
|
|
|
|
*/
|
2007-10-22 02:43:07 +00:00
|
|
|
pchan = cob->pchan;
|
2009-11-14 02:50:45 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
tchan = BKE_pose_channel_verify(pose, pchan->name);
|
|
|
|
tchan->rotmode = pchan->rotmode;
|
2007-10-22 02:43:07 +00:00
|
|
|
|
2009-01-29 11:22:34 +00:00
|
|
|
/* evaluate action using workob (it will only set the PoseChannel in question) */
|
2011-06-15 14:06:25 +00:00
|
|
|
what_does_obaction(cob->ob, &workob, pose, data->act, pchan->name, t);
|
2007-10-22 02:43:07 +00:00
|
|
|
|
2009-01-29 11:22:34 +00:00
|
|
|
/* convert animation to matrices for use here */
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pchan_calc_mat(tchan);
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(ct->matrix, tchan->chan_mat);
|
2007-10-22 02:43:07 +00:00
|
|
|
|
|
|
|
/* Clean up */
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pose_free(pose);
|
2007-10-22 02:43:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-01 12:20:18 +00:00
|
|
|
/* behavior undefined... */
|
2007-10-22 02:43:07 +00:00
|
|
|
puts("Error: unknown owner type for Action Constraint");
|
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void actcon_evaluate(bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bConstraintTarget *ct = targets->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
|
|
|
float temp[4][4];
|
|
|
|
|
|
|
|
/* Nice and simple... we just need to multiply the matrices, as the get_target_matrix
|
|
|
|
* function has already taken care of everything else.
|
|
|
|
*/
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(temp, cob->matrix);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(cob->matrix, temp, ct->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_ACTION = {
|
|
|
|
CONSTRAINT_TYPE_ACTION, /* type */
|
|
|
|
sizeof(bActionConstraint), /* size */
|
|
|
|
"Action", /* name */
|
|
|
|
"bActionConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
actcon_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
actcon_new_data, /* new data */
|
|
|
|
actcon_get_tars, /* get constraint targets */
|
|
|
|
actcon_flush_tars, /* flush constraint targets */
|
|
|
|
actcon_get_tarmat, /* get target matrix */
|
|
|
|
actcon_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* --------- Locked Track ---------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void locktrack_new_data(void *cdata)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bLockTrackConstraint *data = (bLockTrackConstraint *)cdata;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
data->trackflag = TRACK_Y;
|
2007-10-26 11:37:29 +00:00
|
|
|
data->lockflag = LOCK_Z;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void locktrack_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bLockTrackConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int locktrack_get_tars(bConstraint *con, ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bLockTrackConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void locktrack_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bLockTrackConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bLockTrackConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = targets->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
2012-04-29 15:47:02 +00:00
|
|
|
float vec[3], vec2[3];
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
float totmat[3][3];
|
|
|
|
float tmpmat[3][3];
|
|
|
|
float invmat[3][3];
|
|
|
|
float mdet;
|
|
|
|
|
|
|
|
/* Vector object -> target */
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(vec, ct->matrix[3], cob->matrix[3]);
|
2012-02-23 02:17:50 +00:00
|
|
|
switch (data->lockflag) {
|
2012-05-06 17:22:54 +00:00
|
|
|
case LOCK_X: /* LOCK X */
|
|
|
|
{
|
|
|
|
switch (data->trackflag) {
|
|
|
|
case TRACK_Y: /* LOCK X TRACK Y */
|
|
|
|
{
|
|
|
|
/* Projection of Vector on the plane */
|
|
|
|
project_v3_v3v3(vec2, vec, cob->matrix[0]);
|
|
|
|
sub_v3_v3v3(totmat[1], vec, vec2);
|
|
|
|
normalize_v3(totmat[1]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the x axis is fixed */
|
|
|
|
normalize_v3_v3(totmat[0], cob->matrix[0]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the z axis gets mapped onto a third orthogonal vector */
|
|
|
|
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
|
|
|
case TRACK_Z: /* LOCK X TRACK Z */
|
|
|
|
{
|
|
|
|
/* Projection of Vector on the plane */
|
|
|
|
project_v3_v3v3(vec2, vec, cob->matrix[0]);
|
|
|
|
sub_v3_v3v3(totmat[2], vec, vec2);
|
|
|
|
normalize_v3(totmat[2]);
|
2007-10-26 11:37:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the x axis is fixed */
|
|
|
|
normalize_v3_v3(totmat[0], cob->matrix[0]);
|
2007-10-26 11:37:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the z axis gets mapped onto a third orthogonal vector */
|
|
|
|
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
|
|
|
case TRACK_nY: /* LOCK X TRACK -Y */
|
|
|
|
{
|
|
|
|
/* Projection of Vector on the plane */
|
|
|
|
project_v3_v3v3(vec2, vec, cob->matrix[0]);
|
|
|
|
sub_v3_v3v3(totmat[1], vec, vec2);
|
|
|
|
normalize_v3(totmat[1]);
|
|
|
|
negate_v3(totmat[1]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the x axis is fixed */
|
|
|
|
normalize_v3_v3(totmat[0], cob->matrix[0]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the z axis gets mapped onto a third orthogonal vector */
|
|
|
|
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
|
|
|
case TRACK_nZ: /* LOCK X TRACK -Z */
|
|
|
|
{
|
|
|
|
/* Projection of Vector on the plane */
|
|
|
|
project_v3_v3v3(vec2, vec, cob->matrix[0]);
|
|
|
|
sub_v3_v3v3(totmat[2], vec, vec2);
|
|
|
|
normalize_v3(totmat[2]);
|
|
|
|
negate_v3(totmat[2]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the x axis is fixed */
|
|
|
|
normalize_v3_v3(totmat[0], cob->matrix[0]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the z axis gets mapped onto a third orthogonal vector */
|
|
|
|
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
unit_m3(totmat);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2012-05-06 17:22:54 +00:00
|
|
|
case LOCK_Y: /* LOCK Y */
|
|
|
|
{
|
|
|
|
switch (data->trackflag) {
|
|
|
|
case TRACK_X: /* LOCK Y TRACK X */
|
|
|
|
{
|
|
|
|
/* Projection of Vector on the plane */
|
|
|
|
project_v3_v3v3(vec2, vec, cob->matrix[1]);
|
|
|
|
sub_v3_v3v3(totmat[0], vec, vec2);
|
|
|
|
normalize_v3(totmat[0]);
|
2007-07-03 00:58:38 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the y axis is fixed */
|
|
|
|
normalize_v3_v3(totmat[1], cob->matrix[1]);
|
2010-08-15 15:14:08 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the z axis gets mapped onto a third orthogonal vector */
|
|
|
|
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
|
|
|
case TRACK_Z: /* LOCK Y TRACK Z */
|
|
|
|
{
|
|
|
|
/* Projection of Vector on the plane */
|
|
|
|
project_v3_v3v3(vec2, vec, cob->matrix[1]);
|
|
|
|
sub_v3_v3v3(totmat[2], vec, vec2);
|
|
|
|
normalize_v3(totmat[2]);
|
2009-10-30 06:33:40 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the y axis is fixed */
|
|
|
|
normalize_v3_v3(totmat[1], cob->matrix[1]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the z axis gets mapped onto a third orthogonal vector */
|
|
|
|
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
|
|
|
case TRACK_nX: /* LOCK Y TRACK -X */
|
|
|
|
{
|
|
|
|
/* Projection of Vector on the plane */
|
|
|
|
project_v3_v3v3(vec2, vec, cob->matrix[1]);
|
|
|
|
sub_v3_v3v3(totmat[0], vec, vec2);
|
|
|
|
normalize_v3(totmat[0]);
|
|
|
|
negate_v3(totmat[0]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the y axis is fixed */
|
|
|
|
normalize_v3_v3(totmat[1], cob->matrix[1]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the z axis gets mapped onto a third orthogonal vector */
|
|
|
|
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
|
|
|
case TRACK_nZ: /* LOCK Y TRACK -Z */
|
|
|
|
{
|
|
|
|
/* Projection of Vector on the plane */
|
|
|
|
project_v3_v3v3(vec2, vec, cob->matrix[1]);
|
|
|
|
sub_v3_v3v3(totmat[2], vec, vec2);
|
|
|
|
normalize_v3(totmat[2]);
|
|
|
|
negate_v3(totmat[2]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the y axis is fixed */
|
|
|
|
normalize_v3_v3(totmat[1], cob->matrix[1]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the z axis gets mapped onto a third orthogonal vector */
|
|
|
|
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
unit_m3(totmat);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2012-05-06 17:22:54 +00:00
|
|
|
case LOCK_Z: /* LOCK Z */
|
|
|
|
{
|
|
|
|
switch (data->trackflag) {
|
|
|
|
case TRACK_X: /* LOCK Z TRACK X */
|
|
|
|
{
|
|
|
|
/* Projection of Vector on the plane */
|
|
|
|
project_v3_v3v3(vec2, vec, cob->matrix[2]);
|
|
|
|
sub_v3_v3v3(totmat[0], vec, vec2);
|
|
|
|
normalize_v3(totmat[0]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the z axis is fixed */
|
|
|
|
normalize_v3_v3(totmat[2], cob->matrix[2]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the x axis gets mapped onto a third orthogonal vector */
|
|
|
|
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
|
|
|
case TRACK_Y: /* LOCK Z TRACK Y */
|
|
|
|
{
|
|
|
|
/* Projection of Vector on the plane */
|
|
|
|
project_v3_v3v3(vec2, vec, cob->matrix[2]);
|
|
|
|
sub_v3_v3v3(totmat[1], vec, vec2);
|
|
|
|
normalize_v3(totmat[1]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the z axis is fixed */
|
|
|
|
normalize_v3_v3(totmat[2], cob->matrix[2]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the x axis gets mapped onto a third orthogonal vector */
|
|
|
|
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
|
|
|
case TRACK_nX: /* LOCK Z TRACK -X */
|
|
|
|
{
|
|
|
|
/* Projection of Vector on the plane */
|
|
|
|
project_v3_v3v3(vec2, vec, cob->matrix[2]);
|
|
|
|
sub_v3_v3v3(totmat[0], vec, vec2);
|
|
|
|
normalize_v3(totmat[0]);
|
|
|
|
negate_v3(totmat[0]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the z axis is fixed */
|
|
|
|
normalize_v3_v3(totmat[2], cob->matrix[2]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the x axis gets mapped onto a third orthogonal vector */
|
|
|
|
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
|
|
|
case TRACK_nY: /* LOCK Z TRACK -Y */
|
|
|
|
{
|
|
|
|
/* Projection of Vector on the plane */
|
|
|
|
project_v3_v3v3(vec2, vec, cob->matrix[2]);
|
|
|
|
sub_v3_v3v3(totmat[1], vec, vec2);
|
|
|
|
normalize_v3(totmat[1]);
|
|
|
|
negate_v3(totmat[1]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the z axis is fixed */
|
|
|
|
normalize_v3_v3(totmat[2], cob->matrix[2]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* the x axis gets mapped onto a third orthogonal vector */
|
|
|
|
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
unit_m3(totmat);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2012-05-06 17:22:54 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
unit_m3(totmat);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-05-06 17:22:54 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
/* Block to keep matrix heading */
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_m3_m4(tmpmat, cob->matrix);
|
|
|
|
normalize_m3(tmpmat);
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m3_m3(invmat, tmpmat);
|
|
|
|
mul_m3_m3m3(tmpmat, totmat, invmat);
|
2012-05-06 17:22:54 +00:00
|
|
|
totmat[0][0] = tmpmat[0][0]; totmat[0][1] = tmpmat[0][1]; totmat[0][2] = tmpmat[0][2];
|
|
|
|
totmat[1][0] = tmpmat[1][0]; totmat[1][1] = tmpmat[1][1]; totmat[1][2] = tmpmat[1][2];
|
|
|
|
totmat[2][0] = tmpmat[2][0]; totmat[2][1] = tmpmat[2][1]; totmat[2][2] = tmpmat[2][2];
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
mdet = determinant_m3(totmat[0][0], totmat[0][1], totmat[0][2],
|
|
|
|
totmat[1][0], totmat[1][1], totmat[1][2],
|
|
|
|
totmat[2][0], totmat[2][1], totmat[2][2]);
|
2012-05-06 17:22:54 +00:00
|
|
|
if (mdet == 0) {
|
2010-08-15 15:14:08 +00:00
|
|
|
unit_m3(totmat);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* apply out transformaton to the object */
|
2012-09-16 15:25:28 +00:00
|
|
|
mul_m4_m3m4(cob->matrix, totmat, cob->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_LOCKTRACK = {
|
|
|
|
CONSTRAINT_TYPE_LOCKTRACK, /* type */
|
|
|
|
sizeof(bLockTrackConstraint), /* size */
|
|
|
|
"Locked Track", /* name */
|
|
|
|
"bLockTrackConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
locktrack_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
locktrack_new_data, /* new data */
|
|
|
|
locktrack_get_tars, /* get constraint targets */
|
|
|
|
locktrack_flush_tars, /* flush constraint targets */
|
|
|
|
default_get_tarmat, /* get target matrix */
|
|
|
|
locktrack_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
2008-01-25 11:23:36 +00:00
|
|
|
/* ---------- Limit Distance Constraint ----------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void distlimit_new_data(void *cdata)
|
2008-01-25 11:23:36 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bDistLimitConstraint *data = (bDistLimitConstraint *)cdata;
|
2008-01-25 11:23:36 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
data->dist = 0.0f;
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void distlimit_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bDistLimitConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2008-01-25 11:23:36 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int distlimit_get_tars(bConstraint *con, ListBase *list)
|
2008-01-25 11:23:36 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bDistLimitConstraint *data = con->data;
|
2008-01-25 11:23:36 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 1;
|
2008-01-25 11:23:36 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
2008-01-25 11:23:36 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void distlimit_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
2008-01-25 11:23:36 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bDistLimitConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
2008-01-25 11:23:36 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
|
2008-01-25 11:23:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
2008-01-25 11:23:36 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bDistLimitConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = targets->first;
|
2008-01-25 11:23:36 +00:00
|
|
|
|
|
|
|
/* only evaluate if there is a target */
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
2013-07-13 16:25:47 +00:00
|
|
|
float dvec[3], dist, sfac = 1.0f;
|
2012-05-06 17:22:54 +00:00
|
|
|
short clamp_surf = 0;
|
2008-01-25 11:23:36 +00:00
|
|
|
|
|
|
|
/* calculate our current distance from the target */
|
2012-05-06 17:22:54 +00:00
|
|
|
dist = len_v3v3(cob->matrix[3], ct->matrix[3]);
|
2008-01-25 11:23:36 +00:00
|
|
|
|
|
|
|
/* set distance (flag is only set when user demands it) */
|
|
|
|
if (data->dist == 0)
|
2012-05-06 17:22:54 +00:00
|
|
|
data->dist = dist;
|
2008-01-25 11:23:36 +00:00
|
|
|
|
|
|
|
/* check if we're which way to clamp from, and calculate interpolation factor (if needed) */
|
|
|
|
if (data->mode == LIMITDIST_OUTSIDE) {
|
|
|
|
/* if inside, then move to surface */
|
|
|
|
if (dist <= data->dist) {
|
2012-05-06 17:22:54 +00:00
|
|
|
clamp_surf = 1;
|
|
|
|
if (dist != 0.0f) sfac = data->dist / dist;
|
2008-01-25 11:23:36 +00:00
|
|
|
}
|
|
|
|
/* if soft-distance is enabled, start fading once owner is dist+softdist from the target */
|
|
|
|
else if (data->flag & LIMITDIST_USESOFT) {
|
|
|
|
if (dist <= (data->dist + data->soft)) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (data->mode == LIMITDIST_INSIDE) {
|
|
|
|
/* if outside, then move to surface */
|
|
|
|
if (dist >= data->dist) {
|
2012-05-06 17:22:54 +00:00
|
|
|
clamp_surf = 1;
|
|
|
|
if (dist != 0.0f) sfac = data->dist / dist;
|
2008-01-25 11:23:36 +00:00
|
|
|
}
|
|
|
|
/* if soft-distance is enabled, start fading once owner is dist-soft from the target */
|
|
|
|
else if (data->flag & LIMITDIST_USESOFT) {
|
2012-07-07 22:51:57 +00:00
|
|
|
/* FIXME: there's a problem with "jumping" when this kicks in */
|
2008-01-25 11:23:36 +00:00
|
|
|
if (dist >= (data->dist - data->soft)) {
|
2012-05-06 17:22:54 +00:00
|
|
|
sfac = (float)(data->soft * (1.0f - expf(-(dist - data->dist) / data->soft)) + data->dist);
|
2011-05-24 12:20:02 +00:00
|
|
|
if (dist != 0.0f) sfac /= dist;
|
2008-01-25 11:23:36 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
clamp_surf = 1;
|
2008-01-25 11:23:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-05-06 17:22:54 +00:00
|
|
|
if (IS_EQF(dist, data->dist) == 0) {
|
|
|
|
clamp_surf = 1;
|
|
|
|
if (dist != 0.0f) sfac = data->dist / dist;
|
2008-01-25 11:23:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clamp to 'surface' (i.e. move owner so that dist == data->dist) */
|
|
|
|
if (clamp_surf) {
|
|
|
|
/* simply interpolate along line formed by target -> owner */
|
2009-11-10 20:43:45 +00:00
|
|
|
interp_v3_v3v3(dvec, ct->matrix[3], cob->matrix[3], sfac);
|
2008-01-25 11:23:36 +00:00
|
|
|
|
|
|
|
/* copy new vector onto owner */
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(cob->matrix[3], dvec);
|
2008-01-25 11:23:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_DISTLIMIT = {
|
|
|
|
CONSTRAINT_TYPE_DISTLIMIT, /* type */
|
|
|
|
sizeof(bDistLimitConstraint), /* size */
|
|
|
|
"Limit Distance", /* name */
|
|
|
|
"bDistLimitConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
distlimit_id_looper, /* id looper */
|
2008-01-25 11:23:36 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
distlimit_new_data, /* new data */
|
|
|
|
distlimit_get_tars, /* get constraint targets */
|
|
|
|
distlimit_flush_tars, /* flush constraint targets */
|
|
|
|
default_get_tarmat, /* get a target matrix */
|
|
|
|
distlimit_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* ---------- Stretch To ------------ */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void stretchto_new_data(void *cdata)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bStretchToConstraint *data = (bStretchToConstraint *)cdata;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
data->volmode = 0;
|
|
|
|
data->plane = 0;
|
|
|
|
data->orglength = 0.0;
|
|
|
|
data->bulge = 1.0;
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void stretchto_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bStretchToConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int stretchto_get_tars(bConstraint *con, ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bStretchToConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void stretchto_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bStretchToConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bStretchToConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = targets->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* only evaluate if there is a target */
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
|
|
|
float size[3], scale[3], vec[3], xx[3], zz[3], orth[3];
|
|
|
|
float totmat[3][3];
|
|
|
|
float dist;
|
|
|
|
|
|
|
|
/* store scaling before destroying obmat */
|
2010-05-27 11:56:31 +00:00
|
|
|
mat4_to_size(size, cob->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* store X orientation before destroying obmat */
|
2010-08-15 15:14:08 +00:00
|
|
|
normalize_v3_v3(xx, cob->matrix[0]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* store Z orientation before destroying obmat */
|
2010-08-15 15:14:08 +00:00
|
|
|
normalize_v3_v3(zz, cob->matrix[2]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-01-24 13:17:32 +00:00
|
|
|
/* XXX That makes the constraint buggy with asymmetrically scaled objects, see #29940. */
|
2012-01-21 09:41:21 +00:00
|
|
|
/* 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);*/
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-01-24 13:17:32 +00:00
|
|
|
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. */
|
|
|
|
dist /= size[1];
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* data->orglength==0 occurs on first run, and after 'R' button is clicked */
|
2012-01-24 13:17:32 +00:00
|
|
|
if (data->orglength == 0)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
data->orglength = dist;
|
2012-01-24 13:17:32 +00:00
|
|
|
if (data->bulge == 0)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
data->bulge = 1.0;
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
scale[1] = dist / data->orglength;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
switch (data->volmode) {
|
2012-05-06 17:22:54 +00:00
|
|
|
/* volume preserving scaling */
|
|
|
|
case VOLUME_XZ:
|
|
|
|
scale[0] = 1.0f - (float)sqrt(data->bulge) + (float)sqrt(data->bulge * (data->orglength / dist));
|
|
|
|
scale[2] = scale[0];
|
|
|
|
break;
|
|
|
|
case VOLUME_X:
|
|
|
|
scale[0] = 1.0f + data->bulge * (data->orglength / dist - 1);
|
|
|
|
scale[2] = 1.0;
|
|
|
|
break;
|
|
|
|
case VOLUME_Z:
|
|
|
|
scale[0] = 1.0;
|
|
|
|
scale[2] = 1.0f + data->bulge * (data->orglength / dist - 1);
|
|
|
|
break;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* don't care for volume */
|
2012-05-06 17:22:54 +00:00
|
|
|
case NO_VOLUME:
|
|
|
|
scale[0] = 1.0;
|
|
|
|
scale[2] = 1.0;
|
|
|
|
break;
|
|
|
|
default: /* should not happen, but in case*/
|
|
|
|
return;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
} /* switch (data->volmode) */
|
2012-10-27 13:22:44 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* Clear the object's rotation and scale */
|
2012-05-06 17:22:54 +00:00
|
|
|
cob->matrix[0][0] = size[0] * scale[0];
|
|
|
|
cob->matrix[0][1] = 0;
|
|
|
|
cob->matrix[0][2] = 0;
|
|
|
|
cob->matrix[1][0] = 0;
|
|
|
|
cob->matrix[1][1] = size[1] * scale[1];
|
|
|
|
cob->matrix[1][2] = 0;
|
|
|
|
cob->matrix[2][0] = 0;
|
|
|
|
cob->matrix[2][1] = 0;
|
|
|
|
cob->matrix[2][2] = size[2] * scale[2];
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]);
|
|
|
|
normalize_v3(vec);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* new Y aligns object target connection*/
|
2010-08-15 15:14:08 +00:00
|
|
|
negate_v3_v3(totmat[1], vec);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
switch (data->plane) {
|
2012-05-06 17:22:54 +00:00
|
|
|
case PLANE_X:
|
|
|
|
/* build new Z vector */
|
|
|
|
/* othogonal to "new Y" "old X! plane */
|
|
|
|
cross_v3_v3v3(orth, vec, xx);
|
|
|
|
normalize_v3(orth);
|
2012-10-27 13:22:44 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* new Z*/
|
|
|
|
copy_v3_v3(totmat[2], orth);
|
2012-10-27 13:22:44 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* we decided to keep X plane*/
|
|
|
|
cross_v3_v3v3(xx, orth, vec);
|
|
|
|
normalize_v3_v3(totmat[0], xx);
|
|
|
|
break;
|
|
|
|
case PLANE_Z:
|
|
|
|
/* build new X vector */
|
|
|
|
/* othogonal to "new Y" "old Z! plane */
|
|
|
|
cross_v3_v3v3(orth, vec, zz);
|
|
|
|
normalize_v3(orth);
|
2012-10-27 13:22:44 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* new X */
|
|
|
|
negate_v3_v3(totmat[0], orth);
|
2012-10-27 13:22:44 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
/* we decided to keep Z */
|
|
|
|
cross_v3_v3v3(zz, orth, vec);
|
|
|
|
normalize_v3_v3(totmat[2], zz);
|
|
|
|
break;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
} /* switch (data->plane) */
|
2012-10-27 13:22:44 +00:00
|
|
|
|
2012-09-16 15:25:28 +00:00
|
|
|
mul_m4_m3m4(cob->matrix, totmat, cob->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_STRETCHTO = {
|
|
|
|
CONSTRAINT_TYPE_STRETCHTO, /* type */
|
|
|
|
sizeof(bStretchToConstraint), /* size */
|
|
|
|
"Stretch To", /* name */
|
|
|
|
"bStretchToConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
stretchto_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
stretchto_new_data, /* new data */
|
|
|
|
stretchto_get_tars, /* get constraint targets */
|
|
|
|
stretchto_flush_tars, /* flush constraint targets */
|
|
|
|
default_get_tarmat, /* get target matrix */
|
|
|
|
stretchto_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ---------- Floor ------------ */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void minmax_new_data(void *cdata)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bMinMaxConstraint *data = (bMinMaxConstraint *)cdata;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
data->minmaxflag = TRACK_Z;
|
|
|
|
data->offset = 0.0f;
|
2012-03-23 20:18:09 +00:00
|
|
|
zero_v3(data->cache);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
data->flag = 0;
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void minmax_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bMinMaxConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int minmax_get_tars(bConstraint *con, ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bMinMaxConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void minmax_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bMinMaxConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void minmax_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bMinMaxConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = targets->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* only evaluate if there is a target */
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
|
|
|
float obmat[4][4], imat[4][4], tarmat[4][4], tmat[4][4];
|
|
|
|
float val1, val2;
|
|
|
|
int index;
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(obmat, cob->matrix);
|
|
|
|
copy_m4_m4(tarmat, ct->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
if (data->flag & MINMAX_USEROT) {
|
|
|
|
/* take rotation of target into account by doing the transaction in target's localspace */
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, tarmat);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(tmat, imat, obmat);
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(obmat, tmat);
|
|
|
|
unit_m4(tarmat);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (data->minmaxflag) {
|
2012-05-06 17:22:54 +00:00
|
|
|
case TRACK_Z:
|
|
|
|
val1 = tarmat[3][2];
|
|
|
|
val2 = obmat[3][2] - data->offset;
|
|
|
|
index = 2;
|
|
|
|
break;
|
|
|
|
case TRACK_Y:
|
|
|
|
val1 = tarmat[3][1];
|
|
|
|
val2 = obmat[3][1] - data->offset;
|
|
|
|
index = 1;
|
|
|
|
break;
|
|
|
|
case TRACK_X:
|
|
|
|
val1 = tarmat[3][0];
|
|
|
|
val2 = obmat[3][0] - data->offset;
|
|
|
|
index = 0;
|
|
|
|
break;
|
|
|
|
case TRACK_nZ:
|
|
|
|
val2 = tarmat[3][2];
|
|
|
|
val1 = obmat[3][2] - data->offset;
|
|
|
|
index = 2;
|
|
|
|
break;
|
|
|
|
case TRACK_nY:
|
|
|
|
val2 = tarmat[3][1];
|
|
|
|
val1 = obmat[3][1] - data->offset;
|
|
|
|
index = 1;
|
|
|
|
break;
|
|
|
|
case TRACK_nX:
|
|
|
|
val2 = tarmat[3][0];
|
|
|
|
val1 = obmat[3][0] - data->offset;
|
|
|
|
index = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (val1 > val2) {
|
|
|
|
obmat[3][index] = tarmat[3][index] + data->offset;
|
|
|
|
if (data->flag & MINMAX_STICKY) {
|
|
|
|
if (data->flag & MINMAX_STUCK) {
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(obmat[3], data->cache);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
else {
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(data->cache, obmat[3]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
data->flag |= MINMAX_STUCK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (data->flag & MINMAX_USEROT) {
|
|
|
|
/* get out of localspace */
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(tmat, ct->matrix, obmat);
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(cob->matrix, tmat);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
|
|
|
else {
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(cob->matrix[3], obmat[3]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
else {
|
|
|
|
data->flag &= ~MINMAX_STUCK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_MINMAX = {
|
|
|
|
CONSTRAINT_TYPE_MINMAX, /* type */
|
|
|
|
sizeof(bMinMaxConstraint), /* size */
|
|
|
|
"Floor", /* name */
|
|
|
|
"bMinMaxConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
minmax_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
minmax_new_data, /* new data */
|
|
|
|
minmax_get_tars, /* get constraint targets */
|
|
|
|
minmax_flush_tars, /* flush constraint targets */
|
|
|
|
default_get_tarmat, /* get target matrix */
|
|
|
|
minmax_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ------- RigidBody Joint ---------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void rbj_new_data(void *cdata)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)cdata;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-07-07 22:51:57 +00:00
|
|
|
/* removed code which set target of this constraint */
|
2012-05-06 17:22:54 +00:00
|
|
|
data->type = 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void rbj_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bRigidBodyJointConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
|
|
|
func(con, (ID **)&data->child, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int rbj_get_tars(bConstraint *con, ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bRigidBodyJointConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints without subtargets */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGETNS_GET_TARS(con, data->tar, ct, list);
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void rbj_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bRigidBodyJointConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_RIGIDBODYJOINT = {
|
|
|
|
CONSTRAINT_TYPE_RIGIDBODYJOINT, /* type */
|
|
|
|
sizeof(bRigidBodyJointConstraint), /* size */
|
2011-02-27 09:21:13 +00:00
|
|
|
"Rigid Body Joint", /* name */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
"bRigidBodyJointConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
rbj_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
rbj_new_data, /* new data */
|
|
|
|
rbj_get_tars, /* get constraint targets */
|
|
|
|
rbj_flush_tars, /* flush constraint targets */
|
|
|
|
default_get_tarmat, /* get target matrix */
|
|
|
|
NULL /* evaluate - this is not solved here... is just an interface for game-engine */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* -------- Clamp To ---------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void clampto_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bClampToConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int clampto_get_tars(bConstraint *con, ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bClampToConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints without subtargets */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGETNS_GET_TARS(con, data->tar, ct, list);
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void clampto_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bClampToConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void clampto_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
2012-05-06 17:22:54 +00:00
|
|
|
Curve *cu = ct->tar->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* 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)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* only happens on reload file, but violates depsgraph still... fix! */
|
2012-05-06 17:22:54 +00:00
|
|
|
if (cu->path == NULL || cu->path->data == NULL)
|
2012-05-07 06:58:03 +00:00
|
|
|
BKE_displist_make_curveTypes(cob->scene, ct->tar, 0);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* technically, this isn't really needed for evaluation, but we don't know what else
|
|
|
|
* might end up calling this...
|
|
|
|
*/
|
|
|
|
if (ct)
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(ct->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bClampToConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = targets->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* only evaluate if there is a target and it is a curve */
|
|
|
|
if (VALID_CONS_TARGET(ct) && (ct->tar->type == OB_CURVE)) {
|
2012-05-06 17:22:54 +00:00
|
|
|
Curve *cu = data->tar->data;
|
2010-11-28 06:03:30 +00:00
|
|
|
float obmat[4][4], ownLoc[3];
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
float curveMin[3], curveMax[3];
|
2012-05-06 17:22:54 +00:00
|
|
|
float targetMatrix[4][4] = MAT4_UNITY;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(obmat, cob->matrix);
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(ownLoc, obmat[3]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-08-08 21:20:10 +00:00
|
|
|
INIT_MINMAX(curveMin, curveMax);
|
2012-08-18 14:27:48 +00:00
|
|
|
/* XXX - don't think this is good calling this here - campbell */
|
|
|
|
BKE_object_minmax(ct->tar, curveMin, curveMax, TRUE);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* get targetmatrix */
|
|
|
|
if (cu->path && cu->path->data) {
|
|
|
|
float vec[4], dir[3], totmat[4][4];
|
|
|
|
float curvetime;
|
|
|
|
short clamp_axis;
|
|
|
|
|
|
|
|
/* find best position on curve */
|
|
|
|
/* 1. determine which axis to sample on? */
|
|
|
|
if (data->flag == CLAMPTO_AUTO) {
|
|
|
|
float size[3];
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(size, curveMax, curveMin);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* find axis along which the bounding box has the greatest
|
|
|
|
* extent. Otherwise, default to the x-axis, as that is quite
|
|
|
|
* frequently used.
|
|
|
|
*/
|
2012-05-06 17:22:54 +00:00
|
|
|
if ((size[2] > size[0]) && (size[2] > size[1]))
|
|
|
|
clamp_axis = CLAMPTO_Z - 1;
|
|
|
|
else if ((size[1] > size[0]) && (size[1] > size[2]))
|
|
|
|
clamp_axis = CLAMPTO_Y - 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
else
|
|
|
|
clamp_axis = CLAMPTO_X - 1;
|
|
|
|
}
|
|
|
|
else
|
2012-05-06 17:22:54 +00:00
|
|
|
clamp_axis = data->flag - 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* 2. determine position relative to curve on a 0-1 scale based on bounding box */
|
|
|
|
if (data->flag2 & CLAMPTO_CYCLIC) {
|
|
|
|
/* cyclic, so offset within relative bounding box is used */
|
2012-05-06 17:22:54 +00:00
|
|
|
float len = (curveMax[clamp_axis] - curveMin[clamp_axis]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
float offset;
|
|
|
|
|
2008-12-19 11:45:46 +00:00
|
|
|
/* check to make sure len is not so close to zero that it'll cause errors */
|
|
|
|
if (IS_EQ(len, 0) == 0) {
|
|
|
|
/* find bounding-box range where target is located */
|
|
|
|
if (ownLoc[clamp_axis] < curveMin[clamp_axis]) {
|
|
|
|
/* bounding-box range is before */
|
2012-05-22 21:16:59 +00:00
|
|
|
offset = curveMin[clamp_axis] - ceilf((curveMin[clamp_axis] - ownLoc[clamp_axis]) / len) * len;
|
2012-03-29 15:41:58 +00:00
|
|
|
|
2008-12-19 11:45:46 +00:00
|
|
|
/* now, we calculate as per normal, except using offset instead of curveMin[clamp_axis] */
|
|
|
|
curvetime = (ownLoc[clamp_axis] - offset) / (len);
|
|
|
|
}
|
|
|
|
else if (ownLoc[clamp_axis] > curveMax[clamp_axis]) {
|
|
|
|
/* bounding-box range is after */
|
2012-05-06 17:22:54 +00:00
|
|
|
offset = curveMax[clamp_axis] + (int)((ownLoc[clamp_axis] - curveMax[clamp_axis]) / len) * len;
|
2012-03-29 15:41:58 +00:00
|
|
|
|
2008-12-19 11:45:46 +00:00
|
|
|
/* now, we calculate as per normal, except using offset instead of curveMax[clamp_axis] */
|
|
|
|
curvetime = (ownLoc[clamp_axis] - offset) / (len);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* as the location falls within bounds, just calculate */
|
|
|
|
curvetime = (ownLoc[clamp_axis] - curveMin[clamp_axis]) / (len);
|
2003-10-21 13:22:07 +00:00
|
|
|
}
|
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
else {
|
2008-12-19 11:45:46 +00:00
|
|
|
/* as length is close to zero, curvetime by default should be 0 (i.e. the start) */
|
2012-05-06 17:22:54 +00:00
|
|
|
curvetime = 0.0f;
|
2003-10-21 13:22:07 +00:00
|
|
|
}
|
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
else {
|
|
|
|
/* no cyclic, so position is clamped to within the bounding box */
|
|
|
|
if (ownLoc[clamp_axis] <= curveMin[clamp_axis])
|
2008-12-19 11:45:46 +00:00
|
|
|
curvetime = 0.0f;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
else if (ownLoc[clamp_axis] >= curveMax[clamp_axis])
|
2008-12-19 11:45:46 +00:00
|
|
|
curvetime = 1.0f;
|
2012-05-06 17:22:54 +00:00
|
|
|
else if (IS_EQ((curveMax[clamp_axis] - curveMin[clamp_axis]), 0) == 0)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
curvetime = (ownLoc[clamp_axis] - curveMin[clamp_axis]) / (curveMax[clamp_axis] - curveMin[clamp_axis]);
|
2008-12-19 11:45:46 +00:00
|
|
|
else
|
|
|
|
curvetime = 0.0f;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* 3. position on curve */
|
2010-04-21 11:59:47 +00:00
|
|
|
if (where_on_path(ct->tar, curvetime, vec, dir, NULL, NULL, NULL) ) {
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(totmat);
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(totmat[3], vec);
|
2007-01-14 23:42:06 +00:00
|
|
|
|
2013-08-06 01:45:29 +00:00
|
|
|
mul_m4_m4m4(targetMatrix, ct->tar->obmat, totmat);
|
2003-10-21 13:22:07 +00:00
|
|
|
}
|
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* obtain final object position */
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(cob->matrix[3], targetMatrix[3]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
2006-08-13 14:18:15 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
static bConstraintTypeInfo CTI_CLAMPTO = {
|
|
|
|
CONSTRAINT_TYPE_CLAMPTO, /* type */
|
|
|
|
sizeof(bClampToConstraint), /* size */
|
|
|
|
"Clamp To", /* name */
|
|
|
|
"bClampToConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
clampto_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
NULL, /* new data */
|
|
|
|
clampto_get_tars, /* get constraint targets */
|
|
|
|
clampto_flush_tars, /* flush constraint targets */
|
|
|
|
clampto_get_tarmat, /* get target matrix */
|
|
|
|
clampto_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ---------- Transform Constraint ----------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void transform_new_data(void *cdata)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bTransformConstraint *data = (bTransformConstraint *)cdata;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
data->map[0] = 0;
|
|
|
|
data->map[1] = 1;
|
|
|
|
data->map[2] = 2;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void transform_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bTransformConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int transform_get_tars(bConstraint *con, ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bTransformConstraint *data = con->data;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 1;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
2008-03-08 02:16:37 +00:00
|
|
|
|
|
|
|
return 0;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void transform_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bTransformConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bTransformConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = targets->first;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* only evaluate if there is a target */
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
|
|
|
float loc[3], eul[3], size[3];
|
|
|
|
float dvec[3], sval[3];
|
2009-06-22 18:19:18 +00:00
|
|
|
int i;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* obtain target effect */
|
|
|
|
switch (data->from) {
|
2008-02-10 10:01:57 +00:00
|
|
|
case 2: /* scale */
|
2012-04-29 15:47:02 +00:00
|
|
|
mat4_to_size(dvec, ct->matrix);
|
2012-06-11 05:05:05 +00:00
|
|
|
|
|
|
|
if (is_negative_m4(ct->matrix)) {
|
|
|
|
/* Bugfix [#27886]
|
|
|
|
* We can't be sure which axis/axes are negative, though we know that something is negative.
|
|
|
|
* Assume we don't care about negativity of separate axes. <--- This is a limitation that
|
|
|
|
* riggers will have to live with for now.
|
|
|
|
*/
|
|
|
|
negate_v3(dvec);
|
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
break;
|
2008-02-15 04:42:48 +00:00
|
|
|
case 1: /* rotation (convert to degrees first) */
|
2010-05-27 11:56:31 +00:00
|
|
|
mat4_to_eulO(dvec, cob->rotOrder, ct->matrix);
|
2011-09-17 09:43:51 +00:00
|
|
|
mul_v3_fl(dvec, RAD2DEGF(1.0f)); /* rad -> deg */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
break;
|
|
|
|
default: /* location */
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_v3_v3(dvec, ct->matrix[3]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
break;
|
2006-08-13 14:18:15 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* extract components of owner's matrix */
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(loc, cob->matrix[3]);
|
2010-05-27 11:56:31 +00:00
|
|
|
mat4_to_eulO(eul, cob->rotOrder, cob->matrix);
|
2012-10-21 05:46:41 +00:00
|
|
|
mat4_to_size(size, cob->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* determine where in range current transforms lie */
|
|
|
|
if (data->expo) {
|
2012-05-06 17:22:54 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (data->from_max[i] - data->from_min[i])
|
2012-05-06 17:22:54 +00:00
|
|
|
sval[i] = (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
else
|
2012-05-06 17:22:54 +00:00
|
|
|
sval[i] = 0.0f;
|
2006-08-13 14:18:15 +00:00
|
|
|
}
|
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
else {
|
|
|
|
/* clamp transforms out of range */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
CLAMP(dvec[i], data->from_min[i], data->from_max[i]);
|
|
|
|
if (data->from_max[i] - data->from_min[i])
|
2012-05-06 17:22:54 +00:00
|
|
|
sval[i] = (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
else
|
2012-05-06 17:22:54 +00:00
|
|
|
sval[i] = 0.0f;
|
2006-08-13 14:18:15 +00:00
|
|
|
}
|
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* apply transforms */
|
|
|
|
switch (data->to) {
|
|
|
|
case 2: /* scaling */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
size[i] = data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i]));
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
break;
|
|
|
|
case 1: /* rotation */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
float tmin, tmax;
|
2013-06-09 12:30:13 +00:00
|
|
|
float val;
|
2007-04-07 03:32:57 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
tmin = data->to_min[i];
|
|
|
|
tmax = data->to_max[i];
|
2007-09-26 07:33:31 +00:00
|
|
|
|
2008-04-16 07:33:54 +00:00
|
|
|
/* all values here should be in degrees */
|
2013-06-09 12:30:13 +00:00
|
|
|
val = tmin + (sval[(int)data->map[i]] * (tmax - tmin));
|
2008-04-16 07:33:54 +00:00
|
|
|
|
2013-06-09 12:30:13 +00:00
|
|
|
/* now convert final value back to radians, and add to original rotation (so that it can still be rotated) */
|
|
|
|
eul[i] += DEG2RADF(val);
|
2007-09-26 07:33:31 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
break;
|
|
|
|
default: /* location */
|
|
|
|
/* get new location */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
loc[i] = (data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i])));
|
2007-04-07 03:32:57 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* add original location back on (so that it can still be moved) */
|
2009-11-10 20:43:45 +00:00
|
|
|
add_v3_v3v3(loc, cob->matrix[3], loc);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
break;
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* apply to matrix */
|
2009-11-10 20:43:45 +00:00
|
|
|
loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_TRANSFORM = {
|
|
|
|
CONSTRAINT_TYPE_TRANSFORM, /* type */
|
|
|
|
sizeof(bTransformConstraint), /* size */
|
2012-06-08 21:04:48 +00:00
|
|
|
"Transformation", /* name */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
"bTransformConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
transform_id_looper, /* id looper */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
transform_new_data, /* new data */
|
|
|
|
transform_get_tars, /* get constraint targets */
|
|
|
|
transform_flush_tars, /* flush constraint targets */
|
|
|
|
default_get_tarmat, /* get a target matrix */
|
|
|
|
transform_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
/* ---------- Shrinkwrap Constraint ----------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void shrinkwrap_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-05 15:54:08 +00:00
|
|
|
bShrinkwrapConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->target, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int shrinkwrap_get_tars(bConstraint *con, ListBase *list)
|
2009-05-23 03:24:15 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
|
|
|
bShrinkwrapConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGETNS_GET_TARS(con, data->target, ct, list);
|
2009-05-23 03:24:15 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void shrinkwrap_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
2009-05-23 03:24:15 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
|
|
|
bShrinkwrapConstraint *data = con->data;
|
2012-05-06 17:22:54 +00:00
|
|
|
bConstraintTarget *ct = list->first;
|
2009-05-23 03:24:15 +00:00
|
|
|
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGETNS_FLUSH_TARS(con, data->target, ct, list, nocopy);
|
2009-05-23 03:24:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void shrinkwrap_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
2009-05-23 03:24:15 +00:00
|
|
|
{
|
|
|
|
bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data;
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
if (VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) ) {
|
2009-05-23 03:24:15 +00:00
|
|
|
int fail = FALSE;
|
|
|
|
float co[3] = {0.0f, 0.0f, 0.0f};
|
|
|
|
float no[3] = {0.0f, 0.0f, 0.0f};
|
|
|
|
float dist;
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
SpaceTransform transform;
|
2010-12-17 20:13:54 +00:00
|
|
|
DerivedMesh *target = object_get_derived_final(ct->tar);
|
2009-05-23 03:24:15 +00:00
|
|
|
BVHTreeRayHit hit;
|
|
|
|
BVHTreeNearest nearest;
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
BVHTreeFromMesh treeData = {NULL};
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
nearest.index = -1;
|
|
|
|
nearest.dist = FLT_MAX;
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
hit.index = -1;
|
|
|
|
hit.dist = 100000.0f; //TODO should use FLT_MAX.. but normal projection doenst yet supports it
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(ct->matrix);
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (target != NULL) {
|
2009-05-23 03:24:15 +00:00
|
|
|
space_transform_from_matrixs(&transform, cob->matrix, ct->tar->obmat);
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (scon->shrinkType) {
|
2009-05-23 03:24:15 +00:00
|
|
|
case MOD_SHRINKWRAP_NEAREST_SURFACE:
|
|
|
|
case MOD_SHRINKWRAP_NEAREST_VERTEX:
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (scon->shrinkType == MOD_SHRINKWRAP_NEAREST_VERTEX)
|
2009-05-23 03:24:15 +00:00
|
|
|
bvhtree_from_mesh_verts(&treeData, target, 0.0, 2, 6);
|
|
|
|
else
|
|
|
|
bvhtree_from_mesh_faces(&treeData, target, 0.0, 2, 6);
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (treeData.tree == NULL) {
|
2009-05-23 03:24:15 +00:00
|
|
|
fail = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
space_transform_apply(&transform, co);
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
BLI_bvhtree_find_nearest(treeData.tree, co, &nearest, treeData.nearest_callback, &treeData);
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
dist = len_v3v3(co, nearest.co);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (dist != 0.0f) {
|
2012-05-06 17:22:54 +00:00
|
|
|
interp_v3_v3v3(co, co, nearest.co, (dist - scon->dist) / dist); /* linear interpolation */
|
2010-11-07 05:59:35 +00:00
|
|
|
}
|
2009-05-23 03:24:15 +00:00
|
|
|
space_transform_invert(&transform, co);
|
2012-05-06 17:22:54 +00:00
|
|
|
break;
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
case MOD_SHRINKWRAP_PROJECT:
|
2012-03-24 06:18:31 +00:00
|
|
|
if (scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) no[0] = 1.0f;
|
|
|
|
if (scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) no[1] = 1.0f;
|
|
|
|
if (scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) no[2] = 1.0f;
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2012-03-09 06:04:17 +00:00
|
|
|
if (dot_v3v3(no, no) < FLT_EPSILON) {
|
2009-05-23 03:24:15 +00:00
|
|
|
fail = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(no);
|
2010-05-27 11:56:31 +00:00
|
|
|
|
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
bvhtree_from_mesh_faces(&treeData, target, scon->dist, 4, 6);
|
2012-04-28 06:31:57 +00:00
|
|
|
if (treeData.tree == NULL) {
|
2009-05-23 03:24:15 +00:00
|
|
|
fail = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (normal_projection_project_vertex(0, co, no, &transform, treeData.tree, &hit, treeData.raycast_callback, &treeData) == FALSE) {
|
2009-05-23 03:24:15 +00:00
|
|
|
fail = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(co, hit.co);
|
2012-05-06 17:22:54 +00:00
|
|
|
break;
|
2009-05-23 03:24:15 +00:00
|
|
|
}
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
free_bvhtree_from_mesh(&treeData);
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
target->release(target);
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2012-03-23 20:18:09 +00:00
|
|
|
if (fail == TRUE) {
|
2009-05-23 03:24:15 +00:00
|
|
|
/* Don't move the point */
|
2012-03-23 20:18:09 +00:00
|
|
|
zero_v3(co);
|
2009-05-23 03:24:15 +00:00
|
|
|
}
|
2010-05-27 11:56:31 +00:00
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
/* co is in local object coordinates, change it to global and update target position */
|
2010-04-12 00:36:50 +00:00
|
|
|
mul_m4_v3(cob->matrix, co);
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(ct->matrix[3], co);
|
2009-05-23 03:24:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void shrinkwrap_evaluate(bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets)
|
2009-05-23 03:24:15 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bConstraintTarget *ct = targets->first;
|
2009-05-23 03:24:15 +00:00
|
|
|
|
|
|
|
/* only evaluate if there is a target */
|
2012-04-28 06:31:57 +00:00
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(cob->matrix[3], ct->matrix[3]);
|
2009-05-23 03:24:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_SHRINKWRAP = {
|
|
|
|
CONSTRAINT_TYPE_SHRINKWRAP, /* type */
|
|
|
|
sizeof(bShrinkwrapConstraint), /* size */
|
|
|
|
"Shrinkwrap", /* name */
|
|
|
|
"bShrinkwrapConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
shrinkwrap_id_looper, /* id looper */
|
2009-05-23 03:24:15 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
NULL, /* new data */
|
|
|
|
shrinkwrap_get_tars, /* get constraint targets */
|
|
|
|
shrinkwrap_flush_tars, /* flush constraint targets */
|
|
|
|
shrinkwrap_get_tarmat, /* get a target matrix */
|
|
|
|
shrinkwrap_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
2009-10-30 06:33:40 +00:00
|
|
|
/* --------- Damped Track ---------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void damptrack_new_data(void *cdata)
|
2009-10-30 06:33:40 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bDampTrackConstraint *data = (bDampTrackConstraint *)cdata;
|
2009-10-30 06:33:40 +00:00
|
|
|
|
|
|
|
data->trackflag = TRACK_Y;
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void damptrack_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bDampTrackConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int damptrack_get_tars(bConstraint *con, ListBase *list)
|
2009-10-30 06:33:40 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bDampTrackConstraint *data = con->data;
|
2009-10-30 06:33:40 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
|
2009-10-30 06:33:40 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-04-20 15:06:46 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void damptrack_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
2009-10-30 06:33:40 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bDampTrackConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
2009-10-30 06:33:40 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
|
2009-10-30 06:33:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* array of direction vectors for the tracking flags */
|
|
|
|
static const float track_dir_vecs[6][3] = {
|
2012-05-06 17:22:54 +00:00
|
|
|
{+1, 0, 0}, {0, +1, 0}, {0, 0, +1}, /* TRACK_X, TRACK_Y, TRACK_Z */
|
|
|
|
{-1, 0, 0}, {0, -1, 0}, {0, 0, -1} /* TRACK_NX, TRACK_NY, TRACK_NZ */
|
2009-10-30 06:33:40 +00:00
|
|
|
};
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
2009-10-30 06:33:40 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bDampTrackConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = targets->first;
|
2009-10-30 06:33:40 +00:00
|
|
|
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
|
|
|
float obvec[3], tarvec[3], obloc[3];
|
|
|
|
float raxis[3], rangle;
|
|
|
|
float rmat[3][3], tmat[4][4];
|
|
|
|
|
|
|
|
/* find the (unit) direction that the axis we're interested in currently points
|
2009-11-10 20:43:45 +00:00
|
|
|
* - mul_mat3_m4_v3() only takes the 3x3 (rotation+scaling) components of the 4x4 matrix
|
2012-03-09 00:41:09 +00:00
|
|
|
* - the normalization step at the end should take care of any unwanted scaling
|
2009-10-30 06:33:40 +00:00
|
|
|
* left over in the 3x3 matrix we used
|
|
|
|
*/
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(obvec, track_dir_vecs[data->trackflag]);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_mat3_m4_v3(cob->matrix, obvec);
|
2009-10-30 06:33:40 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
if (normalize_v3(obvec) == 0.0f) {
|
2009-10-30 06:33:40 +00:00
|
|
|
/* exceptional case - just use the track vector as appropriate */
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(obvec, track_dir_vecs[data->trackflag]);
|
2009-10-30 06:33:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* find the (unit) direction vector going from the owner to the target */
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(obloc, cob->matrix[3]);
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(tarvec, ct->matrix[3], obloc);
|
2009-10-30 06:33:40 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
if (normalize_v3(tarvec) == 0.0f) {
|
2009-10-30 06:33:40 +00:00
|
|
|
/* the target is sitting on the owner, so just make them use the same direction vectors */
|
2012-07-07 22:51:57 +00:00
|
|
|
/* FIXME: or would it be better to use the pure direction vector? */
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(tarvec, obvec);
|
|
|
|
//copy_v3_v3(tarvec, track_dir_vecs[data->trackflag]);
|
2009-10-30 06:33:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
*/
|
2009-11-10 20:43:45 +00:00
|
|
|
cross_v3_v3v3(raxis, obvec, tarvec);
|
2009-10-30 06:33:40 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
rangle = dot_v3v3(obvec, tarvec);
|
2012-10-23 13:28:22 +00:00
|
|
|
rangle = acos(max_ff(-1.0f, min_ff(1.0f, rangle)));
|
2009-10-30 06:33:40 +00:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
*/
|
2010-05-27 11:56:31 +00:00
|
|
|
axis_angle_to_mat3(rmat, raxis, rangle);
|
2009-10-30 06:33:40 +00:00
|
|
|
|
|
|
|
/* rotate the owner in the way defined by this rotation matrix, then reapply the location since
|
|
|
|
* we may have destroyed that in the process of multiplying the matrix
|
|
|
|
*/
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(tmat);
|
|
|
|
mul_m4_m3m4(tmat, rmat, cob->matrix); // m1, m3, m2
|
2009-10-30 06:33:40 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(cob->matrix, tmat);
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(cob->matrix[3], obloc);
|
2009-10-30 06:33:40 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-23 03:24:15 +00:00
|
|
|
|
2009-10-30 06:33:40 +00:00
|
|
|
static bConstraintTypeInfo CTI_DAMPTRACK = {
|
|
|
|
CONSTRAINT_TYPE_DAMPTRACK, /* type */
|
|
|
|
sizeof(bDampTrackConstraint), /* size */
|
|
|
|
"Damped Track", /* name */
|
|
|
|
"bDampTrackConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
damptrack_id_looper, /* id looper */
|
2009-10-30 06:33:40 +00:00
|
|
|
NULL, /* copy data */
|
|
|
|
damptrack_new_data, /* new data */
|
|
|
|
damptrack_get_tars, /* get constraint targets */
|
|
|
|
damptrack_flush_tars, /* flush constraint targets */
|
|
|
|
default_get_tarmat, /* get target matrix */
|
|
|
|
damptrack_evaluate /* evaluate */
|
|
|
|
};
|
2009-04-20 15:06:46 +00:00
|
|
|
|
2009-11-01 11:29:40 +00:00
|
|
|
/* ----------- Spline IK ------------ */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void splineik_free(bConstraint *con)
|
2009-11-01 11:29:40 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bSplineIKConstraint *data = con->data;
|
2009-11-01 11:29:40 +00:00
|
|
|
|
|
|
|
/* binding array */
|
|
|
|
if (data->points)
|
|
|
|
MEM_freeN(data->points);
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void splineik_copy(bConstraint *con, bConstraint *srccon)
|
2009-11-01 11:29:40 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bSplineIKConstraint *src = srccon->data;
|
|
|
|
bSplineIKConstraint *dst = con->data;
|
2009-11-01 11:29:40 +00:00
|
|
|
|
|
|
|
/* copy the binding array */
|
2012-05-06 17:22:54 +00:00
|
|
|
dst->points = MEM_dupallocN(src->points);
|
2009-11-01 11:29:40 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void splineik_new_data(void *cdata)
|
2010-04-25 13:27:52 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bSplineIKConstraint *data = (bSplineIKConstraint *)cdata;
|
2010-04-25 13:27:52 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
data->chainlen = 1;
|
2009-11-01 11:29:40 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void splineik_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bSplineIKConstraint *data = con->data;
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
2010-02-06 11:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int splineik_get_tars(bConstraint *con, ListBase *list)
|
2009-11-01 11:29:40 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bSplineIKConstraint *data = con->data;
|
2009-11-01 11:29:40 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints without subtargets */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGETNS_GET_TARS(con, data->tar, ct, list);
|
2009-11-01 11:29:40 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void splineik_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
2009-11-01 11:29:40 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bSplineIKConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
2009-11-01 11:29:40 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy);
|
2009-11-01 11:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void splineik_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
|
2009-11-01 11:29:40 +00:00
|
|
|
{
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
2012-05-06 17:22:54 +00:00
|
|
|
Curve *cu = ct->tar->data;
|
2009-11-01 11:29:40 +00:00
|
|
|
|
|
|
|
/* 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)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* only happens on reload file, but violates depsgraph still... fix! */
|
2012-05-06 17:22:54 +00:00
|
|
|
if (cu->path == NULL || cu->path->data == NULL)
|
2012-05-07 06:58:03 +00:00
|
|
|
BKE_displist_make_curveTypes(cob->scene, ct->tar, 0);
|
2009-11-01 11:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* technically, this isn't really needed for evaluation, but we don't know what else
|
|
|
|
* might end up calling this...
|
|
|
|
*/
|
|
|
|
if (ct)
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(ct->matrix);
|
2009-11-01 11:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_SPLINEIK = {
|
|
|
|
CONSTRAINT_TYPE_SPLINEIK, /* type */
|
|
|
|
sizeof(bSplineIKConstraint), /* size */
|
|
|
|
"Spline IK", /* name */
|
|
|
|
"bSplineIKConstraint", /* struct name */
|
|
|
|
splineik_free, /* free data */
|
2010-02-06 11:28:22 +00:00
|
|
|
splineik_id_looper, /* id looper */
|
2009-11-01 11:29:40 +00:00
|
|
|
splineik_copy, /* copy data */
|
2010-04-25 13:27:52 +00:00
|
|
|
splineik_new_data, /* new data */
|
2009-11-01 11:29:40 +00:00
|
|
|
splineik_get_tars, /* get constraint targets */
|
|
|
|
splineik_flush_tars, /* flush constraint targets */
|
|
|
|
splineik_get_tarmat, /* get target matrix */
|
|
|
|
NULL /* evaluate - solved as separate loop */
|
|
|
|
};
|
2009-05-23 03:24:15 +00:00
|
|
|
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
/* ----------- Pivot ------------- */
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void pivotcon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bPivotConstraint *data = con->data;
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
|
|
|
|
/* target only */
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->tar, FALSE, userdata);
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static int pivotcon_get_tars(bConstraint *con, ListBase *list)
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bPivotConstraint *data = con->data;
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* standard target-getting macro for single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list);
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void pivotcon_flush_tars(bConstraint *con, ListBase *list, short nocopy)
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
{
|
|
|
|
if (con && list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bPivotConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = list->first;
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
|
|
|
|
/* the following macro is used for all standard single-target constraints */
|
2012-05-27 20:13:59 +00:00
|
|
|
SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy);
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void pivotcon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bPivotConstraint *data = con->data;
|
|
|
|
bConstraintTarget *ct = targets->first;
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
|
|
|
|
float pivot[3], vec[3];
|
|
|
|
float rotMat[3][3];
|
2010-10-30 18:42:11 +00:00
|
|
|
|
|
|
|
/* pivot correction */
|
|
|
|
float axis[3], angle;
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
|
|
|
|
/* firstly, check if pivoting should take place based on the current rotation */
|
|
|
|
if (data->rotAxis != PIVOTCON_AXIS_NONE) {
|
|
|
|
float rot[3];
|
|
|
|
|
|
|
|
/* extract euler-rotation of target */
|
|
|
|
mat4_to_eulO(rot, cob->rotOrder, cob->matrix);
|
|
|
|
|
|
|
|
/* check which range might be violated */
|
|
|
|
if (data->rotAxis < PIVOTCON_AXIS_X) {
|
|
|
|
/* negative rotations (data->rotAxis = 0 -> 2) */
|
|
|
|
if (rot[data->rotAxis] > 0.0f)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* positive rotations (data->rotAxis = 3 -> 5 */
|
|
|
|
if (rot[data->rotAxis - PIVOTCON_AXIS_X] < 0.0f)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find the pivot-point to use */
|
|
|
|
if (VALID_CONS_TARGET(ct)) {
|
|
|
|
/* apply offset to target location */
|
|
|
|
add_v3_v3v3(pivot, ct->matrix[3], data->offset);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* no targets to worry about... */
|
|
|
|
if ((data->flag & PIVOTCON_FLAG_OFFSET_ABS) == 0) {
|
|
|
|
/* offset is relative to owner */
|
|
|
|
add_v3_v3v3(pivot, cob->matrix[3], data->offset);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* directly use the 'offset' specified as an absolute position instead */
|
2010-08-15 15:14:08 +00:00
|
|
|
copy_v3_v3(pivot, data->offset);
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get rotation matrix representing the rotation of the owner */
|
2012-07-07 22:51:57 +00:00
|
|
|
/* TODO: perhaps we might want to include scaling based on the pivot too? */
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
copy_m3_m4(rotMat, cob->matrix);
|
|
|
|
normalize_m3(rotMat);
|
2010-10-30 18:42:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* correct the pivot by the rotation axis otherwise the pivot translates when it shouldnt */
|
|
|
|
mat3_to_axis_angle(axis, &angle, rotMat);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (angle) {
|
2010-11-19 06:21:39 +00:00
|
|
|
float dvec[3];
|
|
|
|
sub_v3_v3v3(vec, pivot, cob->matrix[3]);
|
|
|
|
project_v3_v3v3(dvec, vec, axis);
|
|
|
|
sub_v3_v3(pivot, dvec);
|
|
|
|
}
|
2010-10-30 18:42:11 +00:00
|
|
|
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
/* perform the pivoting... */
|
2012-05-06 17:22:54 +00:00
|
|
|
/* 1. take the vector from owner to the pivot */
|
2010-11-19 06:21:39 +00:00
|
|
|
sub_v3_v3v3(vec, cob->matrix[3], pivot);
|
2012-05-06 17:22:54 +00:00
|
|
|
/* 2. rotate this vector by the rotation of the object... */
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
mul_m3_v3(rotMat, vec);
|
2012-05-06 17:22:54 +00:00
|
|
|
/* 3. make the rotation in terms of the pivot now */
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
add_v3_v3v3(cob->matrix[3], pivot, vec);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_PIVOT = {
|
|
|
|
CONSTRAINT_TYPE_PIVOT, /* type */
|
|
|
|
sizeof(bPivotConstraint), /* size */
|
|
|
|
"Pivot", /* name */
|
|
|
|
"bPivotConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
|
|
|
pivotcon_id_looper, /* id looper */
|
|
|
|
NULL, /* copy data */
|
2012-03-01 12:20:18 +00:00
|
|
|
NULL, /* new data */ // XXX: might be needed to get 'normal' pivot behavior...
|
== Pivot Constraint ==
This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples.
== Usage Examples ==
=== Foot Roll ===
1. Add 'Pivot' Constraint to the bone without any target.
2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head.
3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'.
=== See Saw ===
1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive.
2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied.
3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation.
== Notes ==
* The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this.
* The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again.
* For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment.
2010-05-27 10:50:06 +00:00
|
|
|
pivotcon_get_tars, /* get constraint targets */
|
|
|
|
pivotcon_flush_tars, /* flush constraint targets */
|
|
|
|
default_get_tarmat, /* get target matrix */
|
|
|
|
pivotcon_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
/* ----------- Follow Track ------------- */
|
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
static void followtrack_new_data(void *cdata)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2012-03-25 23:19:21 +00:00
|
|
|
bFollowTrackConstraint *data = (bFollowTrackConstraint *)cdata;
|
|
|
|
|
|
|
|
data->clip = NULL;
|
2011-11-15 11:34:49 +00:00
|
|
|
data->flag |= FOLLOWTRACK_ACTIVECLIP;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
static void followtrack_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2012-03-25 23:19:21 +00:00
|
|
|
bFollowTrackConstraint *data = con->data;
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->clip, TRUE, userdata);
|
|
|
|
func(con, (ID **)&data->camera, FALSE, userdata);
|
|
|
|
func(con, (ID **)&data->depth_ob, FALSE, userdata);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2012-03-25 23:19:21 +00:00
|
|
|
Scene *scene = cob->scene;
|
|
|
|
bFollowTrackConstraint *data = con->data;
|
|
|
|
MovieClip *clip = data->clip;
|
2011-12-05 18:57:17 +00:00
|
|
|
MovieTracking *tracking;
|
2011-11-07 12:55:18 +00:00
|
|
|
MovieTrackingTrack *track;
|
2011-12-05 18:57:17 +00:00
|
|
|
MovieTrackingObject *tracking_object;
|
2012-05-06 17:22:54 +00:00
|
|
|
Object *camob = data->camera ? data->camera : scene->camera;
|
2012-06-06 18:58:30 +00:00
|
|
|
int framenr;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-11-15 11:34:49 +00:00
|
|
|
if (data->flag & FOLLOWTRACK_ACTIVECLIP)
|
2012-05-06 17:22:54 +00:00
|
|
|
clip = scene->clip;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-12-15 20:38:23 +00:00
|
|
|
if (!clip || !data->track[0] || !camob)
|
2011-11-07 12:55:18 +00:00
|
|
|
return;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
tracking = &clip->tracking;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (data->object[0])
|
2012-06-15 11:03:23 +00:00
|
|
|
tracking_object = BKE_tracking_object_get_named(tracking, data->object);
|
2011-12-05 18:57:17 +00:00
|
|
|
else
|
2012-06-15 11:03:23 +00:00
|
|
|
tracking_object = BKE_tracking_object_get_camera(tracking);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!tracking_object)
|
2011-12-05 18:57:17 +00:00
|
|
|
return;
|
|
|
|
|
2012-06-15 11:03:23 +00:00
|
|
|
track = BKE_tracking_track_get_named(tracking, tracking_object, data->track);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-11-15 11:34:49 +00:00
|
|
|
if (!track)
|
2011-11-07 12:55:18 +00:00
|
|
|
return;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-06-06 18:58:30 +00:00
|
|
|
framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, scene->r.cfra);
|
|
|
|
|
2011-11-15 11:34:49 +00:00
|
|
|
if (data->flag & FOLLOWTRACK_USE_3D_POSITION) {
|
|
|
|
if (track->flag & TRACK_HAS_BUNDLE) {
|
2011-12-15 20:38:45 +00:00
|
|
|
float obmat[4][4], mat[4][4];
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
copy_m4_m4(obmat, cob->matrix);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
if ((tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0) {
|
2011-12-15 20:38:45 +00:00
|
|
|
float imat[4][4];
|
2011-12-05 18:57:17 +00:00
|
|
|
|
|
|
|
copy_m4_m4(mat, camob->obmat);
|
|
|
|
|
2012-06-15 11:03:23 +00:00
|
|
|
BKE_tracking_camera_get_reconstructed_interpolate(tracking, tracking_object, framenr, imat);
|
2011-12-15 20:38:45 +00:00
|
|
|
invert_m4(imat);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-12-15 20:38:45 +00:00
|
|
|
mul_serie_m4(cob->matrix, obmat, mat, imat, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
|
2011-12-05 18:57:17 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-06-15 11:03:23 +00:00
|
|
|
BKE_tracking_get_camera_object_matrix(cob->scene, camob, mat);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(cob->matrix, obmat, mat);
|
2011-12-15 20:38:45 +00:00
|
|
|
translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2012-01-04 17:20:08 +00:00
|
|
|
}
|
2011-11-15 11:34:49 +00:00
|
|
|
else {
|
2011-12-15 20:38:23 +00:00
|
|
|
MovieTrackingMarker *marker;
|
|
|
|
float vec[3], disp[3], axis[3], mat[4][4];
|
2012-05-06 17:22:54 +00:00
|
|
|
float aspect = (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp);
|
2011-12-15 20:38:23 +00:00
|
|
|
float len, d;
|
2011-11-18 15:52:00 +00:00
|
|
|
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_where_is_calc_mat4(scene, camob, mat);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-12-15 20:38:23 +00:00
|
|
|
/* camera axis */
|
2012-03-25 23:19:21 +00:00
|
|
|
vec[0] = 0.0f;
|
|
|
|
vec[1] = 0.0f;
|
|
|
|
vec[2] = 1.0f;
|
2011-12-15 20:38:23 +00:00
|
|
|
mul_v3_m4v3(axis, mat, vec);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-12-15 20:38:23 +00:00
|
|
|
/* distance to projection plane */
|
|
|
|
copy_v3_v3(vec, cob->matrix[3]);
|
|
|
|
sub_v3_v3(vec, mat[3]);
|
|
|
|
project_v3_v3v3(disp, vec, axis);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
len = len_v3(disp);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-12-15 20:38:23 +00:00
|
|
|
if (len > FLT_EPSILON) {
|
|
|
|
CameraParams params;
|
|
|
|
float pos[2], rmat[4][4];
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-06-15 11:03:23 +00:00
|
|
|
marker = BKE_tracking_marker_get(track, framenr);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-12-15 20:38:23 +00:00
|
|
|
add_v2_v2v2(pos, marker->pos, track->offset);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-08-09 16:57:02 +00:00
|
|
|
/* aspect correction */
|
|
|
|
if (data->frame_method != FOLLOWTRACK_FRAME_STRETCH) {
|
|
|
|
int width, height;
|
|
|
|
float w_src, h_src, w_dst, h_dst, asp_src, asp_dst;
|
|
|
|
|
|
|
|
BKE_movieclip_get_size(clip, NULL, &width, &height);
|
|
|
|
|
|
|
|
/* apply clip display aspect */
|
|
|
|
w_src = width * clip->aspx;
|
|
|
|
h_src = height * clip->aspy;
|
|
|
|
|
|
|
|
w_dst = scene->r.xsch * scene->r.xasp;
|
|
|
|
h_dst = scene->r.ysch * scene->r.yasp;
|
|
|
|
|
|
|
|
asp_src = w_src / h_src;
|
|
|
|
asp_dst = w_dst / h_dst;
|
|
|
|
|
|
|
|
if (fabsf(asp_src - asp_dst) >= FLT_EPSILON) {
|
|
|
|
if ((asp_src > asp_dst) == (data->frame_method == FOLLOWTRACK_FRAME_CROP)) {
|
|
|
|
/* fit X */
|
|
|
|
float div = asp_src / asp_dst;
|
|
|
|
float cent = (float) width / 2.0f;
|
|
|
|
|
|
|
|
pos[0] = (((pos[0] * width - cent) * div) + cent) / width;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* fit Y */
|
|
|
|
float div = asp_dst / asp_src;
|
|
|
|
float cent = (float) height / 2.0f;
|
|
|
|
|
|
|
|
pos[1] = (((pos[1] * height - cent) * div) + cent) / height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-05 00:58:22 +00:00
|
|
|
BKE_camera_params_init(¶ms);
|
|
|
|
BKE_camera_params_from_object(¶ms, camob);
|
2011-11-18 15:52:00 +00:00
|
|
|
|
2011-12-15 20:38:23 +00:00
|
|
|
if (params.is_ortho) {
|
2012-03-25 23:19:21 +00:00
|
|
|
vec[0] = params.ortho_scale * (pos[0] - 0.5f + params.shiftx);
|
|
|
|
vec[1] = params.ortho_scale * (pos[1] - 0.5f + params.shifty);
|
|
|
|
vec[2] = -len;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
if (aspect > 1.0f)
|
|
|
|
vec[1] /= aspect;
|
|
|
|
else
|
|
|
|
vec[0] *= aspect;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-12-15 20:38:23 +00:00
|
|
|
mul_v3_m4v3(disp, camob->obmat, vec);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-12-15 20:38:23 +00:00
|
|
|
copy_m4_m4(rmat, camob->obmat);
|
|
|
|
zero_v3(rmat[3]);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(cob->matrix, cob->matrix, rmat);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-12-15 20:38:23 +00:00
|
|
|
copy_v3_v3(cob->matrix[3], disp);
|
|
|
|
}
|
|
|
|
else {
|
2012-05-06 17:22:54 +00:00
|
|
|
d = (len * params.sensor_x) / (2.0f * params.lens);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
vec[0] = d * (2.0f * (pos[0] + params.shiftx) - 1.0f);
|
|
|
|
vec[1] = d * (2.0f * (pos[1] + params.shifty) - 1.0f);
|
|
|
|
vec[2] = -len;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
if (aspect > 1.0f)
|
|
|
|
vec[1] /= aspect;
|
|
|
|
else
|
|
|
|
vec[0] *= aspect;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-12-15 20:38:23 +00:00
|
|
|
mul_v3_m4v3(disp, camob->obmat, vec);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-12-15 20:38:23 +00:00
|
|
|
/* apply camera rotation so Z-axis would be co-linear */
|
|
|
|
copy_m4_m4(rmat, camob->obmat);
|
|
|
|
zero_v3(rmat[3]);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(cob->matrix, cob->matrix, rmat);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-12-15 20:38:23 +00:00
|
|
|
copy_v3_v3(cob->matrix[3], disp);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2012-01-04 17:20:08 +00:00
|
|
|
|
2012-09-19 17:19:30 +00:00
|
|
|
if (data->depth_ob) {
|
2012-03-25 23:19:21 +00:00
|
|
|
Object *depth_ob = data->depth_ob;
|
2012-09-19 17:19:30 +00:00
|
|
|
DerivedMesh *target = object_get_derived_final(depth_ob);
|
|
|
|
if (target) {
|
|
|
|
BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
|
|
|
|
BVHTreeRayHit hit;
|
|
|
|
float ray_start[3], ray_end[3], ray_nor[3], imat[4][4];
|
|
|
|
int result;
|
2012-01-04 17:20:08 +00:00
|
|
|
|
2012-09-19 17:19:30 +00:00
|
|
|
invert_m4_m4(imat, depth_ob->obmat);
|
2012-01-04 17:20:08 +00:00
|
|
|
|
2012-09-19 17:19:30 +00:00
|
|
|
mul_v3_m4v3(ray_start, imat, camob->obmat[3]);
|
|
|
|
mul_v3_m4v3(ray_end, imat, cob->matrix[3]);
|
2012-01-04 17:20:08 +00:00
|
|
|
|
2012-09-19 17:19:30 +00:00
|
|
|
sub_v3_v3v3(ray_nor, ray_end, ray_start);
|
2012-01-04 17:20:08 +00:00
|
|
|
|
2012-09-19 17:19:30 +00:00
|
|
|
bvhtree_from_mesh_faces(&treeData, target, 0.0f, 4, 6);
|
2012-01-04 17:20:08 +00:00
|
|
|
|
2012-09-19 17:19:30 +00:00
|
|
|
hit.dist = FLT_MAX;
|
|
|
|
hit.index = -1;
|
2012-01-04 17:20:08 +00:00
|
|
|
|
2012-09-19 17:19:30 +00:00
|
|
|
result = BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit, treeData.raycast_callback, &treeData);
|
2012-01-04 17:20:08 +00:00
|
|
|
|
2012-09-19 17:19:30 +00:00
|
|
|
if (result != -1) {
|
|
|
|
mul_v3_m4v3(cob->matrix[3], depth_ob->obmat, hit.co);
|
|
|
|
}
|
2012-01-04 17:20:08 +00:00
|
|
|
|
2012-09-19 17:19:30 +00:00
|
|
|
free_bvhtree_from_mesh(&treeData);
|
|
|
|
target->release(target);
|
|
|
|
}
|
2012-01-04 17:20:08 +00:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_FOLLOWTRACK = {
|
|
|
|
CONSTRAINT_TYPE_FOLLOWTRACK, /* type */
|
|
|
|
sizeof(bFollowTrackConstraint), /* size */
|
|
|
|
"Follow Track", /* name */
|
|
|
|
"bFollowTrackConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
|
|
|
followtrack_id_looper, /* id looper */
|
|
|
|
NULL, /* copy data */
|
|
|
|
followtrack_new_data, /* new data */
|
|
|
|
NULL, /* get constraint targets */
|
|
|
|
NULL, /* flush constraint targets */
|
|
|
|
NULL, /* get target matrix */
|
|
|
|
followtrack_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ----------- Camre Solver ------------- */
|
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
static void camerasolver_new_data(void *cdata)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2012-03-25 23:19:21 +00:00
|
|
|
bCameraSolverConstraint *data = (bCameraSolverConstraint *)cdata;
|
|
|
|
|
2011-11-15 11:34:49 +00:00
|
|
|
data->clip = NULL;
|
|
|
|
data->flag |= CAMERASOLVER_ACTIVECLIP;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
static void camerasolver_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2012-03-25 23:19:21 +00:00
|
|
|
bCameraSolverConstraint *data = con->data;
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->clip, TRUE, userdata);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
static void camerasolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2012-03-25 23:19:21 +00:00
|
|
|
Scene *scene = cob->scene;
|
|
|
|
bCameraSolverConstraint *data = con->data;
|
|
|
|
MovieClip *clip = data->clip;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-11-15 11:34:49 +00:00
|
|
|
if (data->flag & CAMERASOLVER_ACTIVECLIP)
|
2012-03-25 23:19:21 +00:00
|
|
|
clip = scene->clip;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-11-15 11:34:49 +00:00
|
|
|
if (clip) {
|
2011-11-07 12:55:18 +00:00
|
|
|
float mat[4][4], obmat[4][4];
|
2012-03-25 23:19:21 +00:00
|
|
|
MovieTracking *tracking = &clip->tracking;
|
2012-06-15 11:03:23 +00:00
|
|
|
MovieTrackingObject *object = BKE_tracking_object_get_camera(tracking);
|
2012-06-06 18:58:30 +00:00
|
|
|
int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, scene->r.cfra);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-06-15 11:03:23 +00:00
|
|
|
BKE_tracking_camera_get_reconstructed_interpolate(tracking, object, framenr, mat);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
copy_m4_m4(obmat, cob->matrix);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(cob->matrix, obmat, mat);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_CAMERASOLVER = {
|
|
|
|
CONSTRAINT_TYPE_CAMERASOLVER, /* type */
|
|
|
|
sizeof(bCameraSolverConstraint), /* size */
|
|
|
|
"Camera Solver", /* name */
|
|
|
|
"bCameraSolverConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
|
|
|
camerasolver_id_looper, /* id looper */
|
|
|
|
NULL, /* copy data */
|
|
|
|
camerasolver_new_data, /* new data */
|
|
|
|
NULL, /* get constraint targets */
|
|
|
|
NULL, /* flush constraint targets */
|
|
|
|
NULL, /* get target matrix */
|
|
|
|
camerasolver_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
2011-12-05 18:57:17 +00:00
|
|
|
/* ----------- Object Solver ------------- */
|
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
static void objectsolver_new_data(void *cdata)
|
2011-12-05 18:57:17 +00:00
|
|
|
{
|
2012-03-25 23:19:21 +00:00
|
|
|
bObjectSolverConstraint *data = (bObjectSolverConstraint *)cdata;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
|
|
|
data->clip = NULL;
|
|
|
|
data->flag |= OBJECTSOLVER_ACTIVECLIP;
|
2011-12-18 18:03:20 +00:00
|
|
|
unit_m4(data->invmat);
|
2011-12-05 18:57:17 +00:00
|
|
|
}
|
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
static void objectsolver_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
|
2011-12-05 18:57:17 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bObjectSolverConstraint *data = con->data;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
func(con, (ID **)&data->clip, FALSE, userdata);
|
|
|
|
func(con, (ID **)&data->camera, FALSE, userdata);
|
2011-12-05 18:57:17 +00:00
|
|
|
}
|
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
|
2011-12-05 18:57:17 +00:00
|
|
|
{
|
2012-03-25 23:19:21 +00:00
|
|
|
Scene *scene = cob->scene;
|
|
|
|
bObjectSolverConstraint *data = con->data;
|
|
|
|
MovieClip *clip = data->clip;
|
|
|
|
Object *camob = data->camera ? data->camera : scene->camera;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
|
|
|
if (data->flag & OBJECTSOLVER_ACTIVECLIP)
|
2012-05-06 17:22:54 +00:00
|
|
|
clip = scene->clip;
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!camob || !clip)
|
2011-12-05 18:57:17 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (clip) {
|
2012-03-25 23:19:21 +00:00
|
|
|
MovieTracking *tracking = &clip->tracking;
|
2011-12-05 18:57:17 +00:00
|
|
|
MovieTrackingObject *object;
|
|
|
|
|
2012-06-15 11:03:23 +00:00
|
|
|
object = BKE_tracking_object_get_named(tracking, data->object);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (object) {
|
2011-12-15 16:09:57 +00:00
|
|
|
float mat[4][4], obmat[4][4], imat[4][4], cammat[4][4], camimat[4][4], parmat[4][4];
|
2012-06-06 18:58:30 +00:00
|
|
|
int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, scene->r.cfra);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_where_is_calc_mat4(scene, camob, cammat);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2012-06-15 11:03:23 +00:00
|
|
|
BKE_tracking_camera_get_reconstructed_interpolate(tracking, object, framenr, mat);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
|
|
|
invert_m4_m4(camimat, cammat);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(parmat, cammat, data->invmat);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2011-12-15 20:38:23 +00:00
|
|
|
copy_m4_m4(cammat, camob->obmat);
|
2011-12-05 18:57:17 +00:00
|
|
|
copy_m4_m4(obmat, cob->matrix);
|
|
|
|
|
|
|
|
invert_m4_m4(imat, mat);
|
|
|
|
|
2011-12-15 16:09:57 +00:00
|
|
|
mul_serie_m4(cob->matrix, cammat, imat, camimat, parmat, obmat, NULL, NULL, NULL);
|
2011-12-05 18:57:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bConstraintTypeInfo CTI_OBJECTSOLVER = {
|
|
|
|
CONSTRAINT_TYPE_OBJECTSOLVER, /* type */
|
|
|
|
sizeof(bObjectSolverConstraint), /* size */
|
|
|
|
"Object Solver", /* name */
|
|
|
|
"bObjectSolverConstraint", /* struct name */
|
|
|
|
NULL, /* free data */
|
|
|
|
objectsolver_id_looper, /* id looper */
|
|
|
|
NULL, /* copy data */
|
|
|
|
objectsolver_new_data, /* new data */
|
|
|
|
NULL, /* get constraint targets */
|
|
|
|
NULL, /* flush constraint targets */
|
|
|
|
NULL, /* get target matrix */
|
|
|
|
objectsolver_evaluate /* evaluate */
|
|
|
|
};
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* ************************* Constraints Type-Info *************************** */
|
|
|
|
/* All of the constraints api functions use bConstraintTypeInfo structs to carry out
|
2009-03-28 11:44:07 +00:00
|
|
|
* and operations that involve constraint specific code.
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* These globals only ever get directly accessed in this file */
|
2009-11-01 11:29:40 +00:00
|
|
|
static bConstraintTypeInfo *constraintsTypeInfo[NUM_CONSTRAINT_TYPES];
|
2012-05-06 17:22:54 +00:00
|
|
|
static short CTI_INIT = 1; /* when non-zero, the list needs to be updated */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* This function only gets called when CTI_INIT is non-zero */
|
2012-05-06 17:22:54 +00:00
|
|
|
static void constraints_init_typeinfo(void)
|
|
|
|
{
|
|
|
|
constraintsTypeInfo[0] = NULL; /* 'Null' Constraint */
|
|
|
|
constraintsTypeInfo[1] = &CTI_CHILDOF; /* ChildOf Constraint */
|
|
|
|
constraintsTypeInfo[2] = &CTI_TRACKTO; /* TrackTo Constraint */
|
|
|
|
constraintsTypeInfo[3] = &CTI_KINEMATIC; /* IK Constraint */
|
|
|
|
constraintsTypeInfo[4] = &CTI_FOLLOWPATH; /* Follow-Path Constraint */
|
|
|
|
constraintsTypeInfo[5] = &CTI_ROTLIMIT; /* Limit Rotation Constraint */
|
|
|
|
constraintsTypeInfo[6] = &CTI_LOCLIMIT; /* Limit Location Constraint */
|
2012-06-08 21:04:48 +00:00
|
|
|
constraintsTypeInfo[7] = &CTI_SIZELIMIT; /* Limit Scale Constraint */
|
2012-05-06 17:22:54 +00:00
|
|
|
constraintsTypeInfo[8] = &CTI_ROTLIKE; /* Copy Rotation Constraint */
|
|
|
|
constraintsTypeInfo[9] = &CTI_LOCLIKE; /* Copy Location Constraint */
|
2012-06-08 21:04:48 +00:00
|
|
|
constraintsTypeInfo[10] = &CTI_SIZELIKE; /* Copy Scale Constraint */
|
2012-05-06 17:22:54 +00:00
|
|
|
constraintsTypeInfo[11] = &CTI_PYTHON; /* Python/Script Constraint */
|
|
|
|
constraintsTypeInfo[12] = &CTI_ACTION; /* Action Constraint */
|
|
|
|
constraintsTypeInfo[13] = &CTI_LOCKTRACK; /* Locked-Track Constraint */
|
|
|
|
constraintsTypeInfo[14] = &CTI_DISTLIMIT; /* Limit Distance Constraint */
|
|
|
|
constraintsTypeInfo[15] = &CTI_STRETCHTO; /* StretchTo Constaint */
|
|
|
|
constraintsTypeInfo[16] = &CTI_MINMAX; /* Floor Constraint */
|
|
|
|
constraintsTypeInfo[17] = &CTI_RIGIDBODYJOINT; /* RigidBody Constraint */
|
|
|
|
constraintsTypeInfo[18] = &CTI_CLAMPTO; /* ClampTo Constraint */
|
|
|
|
constraintsTypeInfo[19] = &CTI_TRANSFORM; /* Transformation Constraint */
|
|
|
|
constraintsTypeInfo[20] = &CTI_SHRINKWRAP; /* Shrinkwrap Constraint */
|
|
|
|
constraintsTypeInfo[21] = &CTI_DAMPTRACK; /* Damped TrackTo Constraint */
|
|
|
|
constraintsTypeInfo[22] = &CTI_SPLINEIK; /* Spline IK Constraint */
|
|
|
|
constraintsTypeInfo[23] = &CTI_TRANSLIKE; /* Copy Transforms Constraint */
|
|
|
|
constraintsTypeInfo[24] = &CTI_SAMEVOL; /* Maintain Volume Constraint */
|
|
|
|
constraintsTypeInfo[25] = &CTI_PIVOT; /* Pivot Constraint */
|
|
|
|
constraintsTypeInfo[26] = &CTI_FOLLOWTRACK; /* Follow Track Constraint */
|
|
|
|
constraintsTypeInfo[27] = &CTI_CAMERASOLVER; /* Camera Solver Constraint */
|
|
|
|
constraintsTypeInfo[28] = &CTI_OBJECTSOLVER; /* Object Solver Constraint */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This function should be used for getting the appropriate type-info when only
|
|
|
|
* a constraint type is known
|
|
|
|
*/
|
2012-12-23 11:31:15 +00:00
|
|
|
bConstraintTypeInfo *BKE_get_constraint_typeinfo(int type)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-03-02 16:05:54 +00:00
|
|
|
/* initialize the type-info list? */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (CTI_INIT) {
|
|
|
|
constraints_init_typeinfo();
|
|
|
|
CTI_INIT = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only return for valid types */
|
2012-09-09 00:00:21 +00:00
|
|
|
if ((type >= CONSTRAINT_TYPE_NULL) &&
|
|
|
|
(type < NUM_CONSTRAINT_TYPES))
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
/* there shouldn't be any segfaults here... */
|
|
|
|
return constraintsTypeInfo[type];
|
|
|
|
}
|
|
|
|
else {
|
2012-03-31 00:59:17 +00:00
|
|
|
printf("No valid constraint type-info data available. Type = %i\n", type);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This function should always be used to get the appropriate type-info, as it
|
|
|
|
* has checks which prevent segfaults in some weird cases.
|
|
|
|
*/
|
2012-12-23 11:31:15 +00:00
|
|
|
bConstraintTypeInfo *BKE_constraint_get_typeinfo(bConstraint *con)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
/* only return typeinfo for valid constraints */
|
|
|
|
if (con)
|
2012-12-23 11:31:15 +00:00
|
|
|
return BKE_get_constraint_typeinfo(con->type);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ************************* General Constraints API ************************** */
|
|
|
|
/* The functions here are called by various parts of Blender. Very few (should be none if possible)
|
|
|
|
* constraint-specific code should occur here.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* ---------- Data Management ------- */
|
|
|
|
|
2012-12-23 11:31:15 +00:00
|
|
|
/* helper function for BKE_free_constraint_data() - unlinks references */
|
2012-05-06 01:03:51 +00:00
|
|
|
static void con_unlink_refs_cb(bConstraint *UNUSED(con), ID **idpoin, short isReference, void *UNUSED(userData))
|
|
|
|
{
|
|
|
|
if (*idpoin && isReference)
|
|
|
|
id_us_min(*idpoin);
|
|
|
|
}
|
|
|
|
|
2011-05-04 05:52:14 +00:00
|
|
|
/* Free data of a specific constraint if it has any info.
|
|
|
|
* be sure to run BIK_clear_data() when freeing an IK constraint,
|
2013-02-21 19:33:04 +00:00
|
|
|
* unless DAG_relations_tag_update is called.
|
2012-05-06 01:03:51 +00:00
|
|
|
*/
|
2012-12-23 11:31:15 +00:00
|
|
|
void BKE_free_constraint_data(bConstraint *con)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
if (con->data) {
|
2012-12-23 11:31:15 +00:00
|
|
|
bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 01:03:51 +00:00
|
|
|
if (cti) {
|
|
|
|
/* perform any special freeing constraint may have */
|
|
|
|
if (cti->free_data)
|
|
|
|
cti->free_data(con);
|
|
|
|
|
|
|
|
/* unlink the referenced resources it uses */
|
|
|
|
if (cti->id_looper)
|
|
|
|
cti->id_looper(con, con_unlink_refs_cb, NULL);
|
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* free constraint data now */
|
|
|
|
MEM_freeN(con->data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free all constraints from a constraint-stack */
|
2012-12-23 11:31:15 +00:00
|
|
|
void BKE_free_constraints(ListBase *list)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
bConstraint *con;
|
|
|
|
|
|
|
|
/* Free constraint data and also any extra data */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (con = list->first; con; con = con->next)
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_free_constraint_data(con);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* Free the whole list */
|
2009-05-23 03:24:15 +00:00
|
|
|
BLI_freelistN(list);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2009-11-16 12:33:42 +00:00
|
|
|
|
|
|
|
/* Remove the specified constraint from the given constraint stack */
|
2012-12-23 11:31:15 +00:00
|
|
|
int BKE_remove_constraint(ListBase *list, bConstraint *con)
|
2009-11-16 12:33:42 +00:00
|
|
|
{
|
|
|
|
if (con) {
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_free_constraint_data(con);
|
2009-11-16 12:33:42 +00:00
|
|
|
BLI_freelinkN(list, con);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-02-21 11:05:52 +00:00
|
|
|
/* Remove all the constraints of the specified type from the given constraint stack */
|
2012-12-23 11:31:15 +00:00
|
|
|
void BKE_remove_constraints_type(ListBase *list, short type, short last_only)
|
2010-02-21 11:05:52 +00:00
|
|
|
{
|
|
|
|
bConstraint *con, *conp;
|
|
|
|
|
|
|
|
if (list == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* remove from the end of the list to make it faster to find the last instance */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (con = list->last; con; con = conp) {
|
|
|
|
conp = con->prev;
|
2010-02-21 11:05:52 +00:00
|
|
|
|
|
|
|
if (con->type == type) {
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_remove_constraint(list, con);
|
2010-02-21 11:05:52 +00:00
|
|
|
if (last_only)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-16 12:33:42 +00:00
|
|
|
/* ......... */
|
|
|
|
|
2012-03-09 00:41:09 +00:00
|
|
|
/* Creates a new constraint, initializes its data, and returns it */
|
2012-05-06 17:22:54 +00:00
|
|
|
static bConstraint *add_new_constraint_internal(const char *name, short type)
|
2009-11-16 12:33:42 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
bConstraint *con = MEM_callocN(sizeof(bConstraint), "Constraint");
|
2012-12-23 11:31:15 +00:00
|
|
|
bConstraintTypeInfo *cti = BKE_get_constraint_typeinfo(type);
|
2009-11-16 12:33:42 +00:00
|
|
|
const char *newName;
|
2009-11-11 19:58:30 +00:00
|
|
|
|
|
|
|
/* Set up a generic constraint datablock */
|
|
|
|
con->type = type;
|
|
|
|
con->flag |= CONSTRAINT_EXPAND;
|
|
|
|
con->enforce = 1.0f;
|
|
|
|
|
2009-11-16 12:33:42 +00:00
|
|
|
/* Determine a basic name, and info */
|
2009-11-11 19:58:30 +00:00
|
|
|
if (cti) {
|
2012-03-02 16:05:54 +00:00
|
|
|
/* initialize constraint data */
|
2009-11-11 19:58:30 +00:00
|
|
|
con->data = MEM_callocN(cti->size, cti->structName);
|
2009-11-16 12:33:42 +00:00
|
|
|
|
2009-11-11 19:58:30 +00:00
|
|
|
/* only constraints that change any settings need this */
|
|
|
|
if (cti->new_data)
|
|
|
|
cti->new_data(con->data);
|
2009-11-16 12:33:42 +00:00
|
|
|
|
|
|
|
/* if no name is provided, use the type of the constraint as the name */
|
2013-03-20 18:42:09 +00:00
|
|
|
newName = (name && name[0]) ? name : DATA_(cti->name);
|
2009-11-11 19:58:30 +00:00
|
|
|
}
|
2009-11-16 12:33:42 +00:00
|
|
|
else {
|
|
|
|
/* if no name is provided, use the generic "Const" name */
|
2012-07-07 22:51:57 +00:00
|
|
|
/* NOTE: any constraint type that gets here really shouldn't get added... */
|
2013-03-20 18:42:09 +00:00
|
|
|
newName = (name && name[0]) ? name : DATA_("Const");
|
2009-11-16 12:33:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* copy the name */
|
|
|
|
BLI_strncpy(con->name, newName, sizeof(con->name));
|
|
|
|
|
|
|
|
/* return the new constraint */
|
2009-11-11 19:58:30 +00:00
|
|
|
return con;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if pchan is not NULL then assume we're adding a pose constraint */
|
2012-05-06 17:22:54 +00:00
|
|
|
static bConstraint *add_new_constraint(Object *ob, bPoseChannel *pchan, const char *name, short type)
|
2009-11-11 19:58:30 +00:00
|
|
|
{
|
|
|
|
bConstraint *con;
|
|
|
|
ListBase *list;
|
2009-11-16 12:33:42 +00:00
|
|
|
|
|
|
|
/* add the constraint */
|
2012-05-06 17:22:54 +00:00
|
|
|
con = add_new_constraint_internal(name, type);
|
2009-11-16 12:33:42 +00:00
|
|
|
|
|
|
|
/* find the constraint stack - bone or object? */
|
|
|
|
list = (pchan) ? (&pchan->constraints) : (&ob->constraints);
|
|
|
|
|
2009-11-11 19:58:30 +00:00
|
|
|
if (list) {
|
|
|
|
/* add new constraint to end of list of constraints before ensuring that it has a unique name
|
|
|
|
* (otherwise unique-naming code will fail, since it assumes element exists in list)
|
|
|
|
*/
|
|
|
|
BLI_addtail(list, con);
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_unique_constraint_name(con, list);
|
2009-11-16 12:33:42 +00:00
|
|
|
|
2009-11-11 19:58:30 +00:00
|
|
|
/* if the target list is a list on some PoseChannel belonging to a proxy-protected
|
|
|
|
* Armature layer, we must tag newly added constraints with a flag which allows them
|
|
|
|
* to persist after proxy syncing has been done
|
|
|
|
*/
|
2012-12-23 11:31:15 +00:00
|
|
|
if (BKE_proxylocked_constraints_owner(ob, pchan))
|
2009-11-11 19:58:30 +00:00
|
|
|
con->flag |= CONSTRAINT_PROXY_LOCAL;
|
2009-11-16 12:33:42 +00:00
|
|
|
|
|
|
|
/* make this constraint the active one */
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_constraints_set_active(list, con);
|
2009-11-11 19:58:30 +00:00
|
|
|
}
|
2012-07-06 23:56:59 +00:00
|
|
|
|
2011-02-08 05:51:20 +00:00
|
|
|
/* set type+owner specific immutable settings */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: does action constraint need anything here - i.e. spaceonce? */
|
2011-02-08 05:51:20 +00:00
|
|
|
switch (type) {
|
|
|
|
case CONSTRAINT_TYPE_CHILDOF:
|
|
|
|
{
|
|
|
|
/* if this constraint is being added to a posechannel, make sure
|
|
|
|
* the constraint gets evaluated in pose-space */
|
|
|
|
if (pchan) {
|
|
|
|
con->ownspace = CONSTRAINT_SPACE_POSE;
|
|
|
|
con->flag |= CONSTRAINT_SPACEONCE;
|
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2011-02-08 05:51:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-11 19:58:30 +00:00
|
|
|
return con;
|
|
|
|
}
|
|
|
|
|
2009-11-16 12:33:42 +00:00
|
|
|
/* ......... */
|
|
|
|
|
|
|
|
/* Add new constraint for the given bone */
|
2012-12-23 11:31:15 +00:00
|
|
|
bConstraint *BKE_add_pose_constraint(Object *ob, bPoseChannel *pchan, const char *name, short type)
|
2009-11-11 19:58:30 +00:00
|
|
|
{
|
2009-11-16 12:33:42 +00:00
|
|
|
if (pchan == NULL)
|
2009-11-11 19:58:30 +00:00
|
|
|
return NULL;
|
2009-11-16 12:33:42 +00:00
|
|
|
|
2009-11-11 19:58:30 +00:00
|
|
|
return add_new_constraint(ob, pchan, name, type);
|
|
|
|
}
|
|
|
|
|
2009-11-16 12:33:42 +00:00
|
|
|
/* Add new constraint for the given object */
|
2012-12-23 11:31:15 +00:00
|
|
|
bConstraint *BKE_add_ob_constraint(Object *ob, const char *name, short type)
|
2009-11-11 19:58:30 +00:00
|
|
|
{
|
|
|
|
return add_new_constraint(ob, NULL, name, type);
|
|
|
|
}
|
|
|
|
|
2009-11-16 12:33:42 +00:00
|
|
|
/* ......... */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-12-23 11:31:15 +00:00
|
|
|
/* helper for BKE_relink_constraints() - call ID_NEW() on every ID reference the constraint has */
|
2012-05-06 01:27:48 +00:00
|
|
|
static void con_relink_id_cb(bConstraint *UNUSED(con), ID **idpoin, short UNUSED(isReference), void *UNUSED(userdata))
|
|
|
|
{
|
|
|
|
/* ID_NEW() expects a struct with inline "id" member as first
|
|
|
|
* since we've got the actual ID block, let's just inline this
|
|
|
|
* code.
|
|
|
|
*
|
2012-09-03 22:04:14 +00:00
|
|
|
* See ID_NEW(a) in DNA_ID.h
|
2012-05-06 01:27:48 +00:00
|
|
|
*/
|
|
|
|
if ((*idpoin) && (*idpoin)->newid)
|
|
|
|
(*idpoin) = (void *)(*idpoin)->newid;
|
|
|
|
}
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* Reassign links that constraints have to other data (called during file loading?) */
|
2012-12-23 11:31:15 +00:00
|
|
|
void BKE_relink_constraints(ListBase *conlist)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-05-06 01:27:48 +00:00
|
|
|
/* just a wrapper around ID-loop for just calling ID_NEW() on all ID refs */
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_id_loop_constraints(conlist, con_relink_id_cb, NULL);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 01:27:48 +00:00
|
|
|
|
2010-02-06 11:28:22 +00:00
|
|
|
/* Run the given callback on all ID-blocks in list of constraints */
|
2012-12-23 11:31:15 +00:00
|
|
|
void BKE_id_loop_constraints(ListBase *conlist, ConstraintIDFunc func, void *userdata)
|
2010-02-06 11:28:22 +00:00
|
|
|
{
|
|
|
|
bConstraint *con;
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
for (con = conlist->first; con; con = con->next) {
|
2012-12-23 11:31:15 +00:00
|
|
|
bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
|
2010-02-06 11:28:22 +00:00
|
|
|
|
|
|
|
if (cti) {
|
|
|
|
if (cti->id_looper)
|
|
|
|
cti->id_looper(con, func, userdata);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-16 12:33:42 +00:00
|
|
|
/* ......... */
|
|
|
|
|
2012-12-23 11:31:15 +00:00
|
|
|
/* helper for BKE_copy_constraints(), to be used for making sure that ID's are valid */
|
2012-05-05 15:54:08 +00:00
|
|
|
static void con_extern_cb(bConstraint *UNUSED(con), ID **idpoin, short UNUSED(isReference), void *UNUSED(userData))
|
2010-02-08 17:30:35 +00:00
|
|
|
{
|
2010-02-10 14:47:39 +00:00
|
|
|
if (*idpoin && (*idpoin)->lib)
|
2010-02-08 17:30:35 +00:00
|
|
|
id_lib_extern(*idpoin);
|
|
|
|
}
|
|
|
|
|
2012-12-23 11:31:15 +00:00
|
|
|
/* helper for BKE_copy_constraints(), to be used for making sure that usercounts of copied ID's are fixed up */
|
2012-05-05 16:03:57 +00:00
|
|
|
static void con_fix_copied_refs_cb(bConstraint *UNUSED(con), ID **idpoin, short isReference, void *UNUSED(userData))
|
2012-05-05 15:54:08 +00:00
|
|
|
{
|
|
|
|
/* increment usercount if this is a reference type */
|
|
|
|
if ((*idpoin) && (isReference))
|
|
|
|
id_us_plus(*idpoin);
|
|
|
|
}
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* duplicate all of the constraints in a constraint stack */
|
2012-12-23 11:31:15 +00:00
|
|
|
void BKE_copy_constraints(ListBase *dst, const ListBase *src, int do_extern)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
|
|
|
bConstraint *con, *srccon;
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
dst->first = dst->last = NULL;
|
2008-01-01 18:29:19 +00:00
|
|
|
BLI_duplicatelist(dst, src);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
for (con = dst->first, srccon = src->first; con && srccon; srccon = srccon->next, con = con->next) {
|
2012-12-23 11:31:15 +00:00
|
|
|
bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* make a new copy of the constraint's data */
|
|
|
|
con->data = MEM_dupallocN(con->data);
|
|
|
|
|
|
|
|
/* only do specific constraints if required */
|
2010-02-08 17:30:35 +00:00
|
|
|
if (cti) {
|
2010-02-09 00:02:22 +00:00
|
|
|
/* perform custom copying operations if needed */
|
|
|
|
if (cti->copy_data)
|
2010-02-08 17:30:35 +00:00
|
|
|
cti->copy_data(con, srccon);
|
2012-05-05 15:54:08 +00:00
|
|
|
|
|
|
|
/* fix usercounts for all referenced data in referenced data */
|
|
|
|
if (cti->id_looper)
|
|
|
|
cti->id_looper(con, con_fix_copied_refs_cb, NULL);
|
2010-02-09 00:02:22 +00:00
|
|
|
|
2012-03-18 07:38:51 +00:00
|
|
|
/* for proxies we don't want to make extern */
|
2010-05-27 11:56:31 +00:00
|
|
|
if (do_extern) {
|
2010-04-29 15:31:53 +00:00
|
|
|
/* go over used ID-links for this constraint to ensure that they are valid for proxies */
|
|
|
|
if (cti->id_looper)
|
|
|
|
cti->id_looper(con, con_extern_cb, NULL);
|
|
|
|
}
|
2010-02-08 17:30:35 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-16 12:33:42 +00:00
|
|
|
/* ......... */
|
|
|
|
|
2012-12-23 11:31:15 +00:00
|
|
|
bConstraint *BKE_constraints_findByName(ListBase *list, const char *name)
|
2010-04-26 03:42:38 +00:00
|
|
|
{
|
|
|
|
return BLI_findstring(list, name, offsetof(bConstraint, name));
|
|
|
|
}
|
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
/* finds the 'active' constraint in a constraint stack */
|
2012-12-23 11:31:15 +00:00
|
|
|
bConstraint *BKE_constraints_get_active(ListBase *list)
|
2009-05-23 03:24:15 +00:00
|
|
|
{
|
|
|
|
bConstraint *con;
|
|
|
|
|
|
|
|
/* search for the first constraint with the 'active' flag set */
|
|
|
|
if (list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
for (con = list->first; con; con = con->next) {
|
2009-05-23 03:24:15 +00:00
|
|
|
if (con->flag & CONSTRAINT_ACTIVE)
|
|
|
|
return con;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no active constraint found */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-11-16 12:33:42 +00:00
|
|
|
/* Set the given constraint as the active one (clearing all the others) */
|
2012-12-23 11:31:15 +00:00
|
|
|
void BKE_constraints_set_active(ListBase *list, bConstraint *con)
|
2009-11-16 12:33:42 +00:00
|
|
|
{
|
|
|
|
bConstraint *c;
|
|
|
|
|
2010-02-05 06:05:24 +00:00
|
|
|
if (list) {
|
2012-05-06 17:22:54 +00:00
|
|
|
for (c = list->first; c; c = c->next) {
|
2010-02-05 06:05:24 +00:00
|
|
|
if (c == con)
|
|
|
|
c->flag |= CONSTRAINT_ACTIVE;
|
|
|
|
else
|
|
|
|
c->flag &= ~CONSTRAINT_ACTIVE;
|
|
|
|
}
|
2009-11-16 12:33:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-04 11:21:50 +00:00
|
|
|
/* -------- Constraints and Proxies ------- */
|
|
|
|
|
|
|
|
/* Rescue all constraints tagged as being CONSTRAINT_PROXY_LOCAL (i.e. added to bone that's proxy-synced in this file) */
|
2012-12-23 11:31:15 +00:00
|
|
|
void BKE_extract_proxylocal_constraints(ListBase *dst, ListBase *src)
|
2008-01-04 11:21:50 +00:00
|
|
|
{
|
|
|
|
bConstraint *con, *next;
|
|
|
|
|
|
|
|
/* for each tagged constraint, remove from src and move to dst */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (con = src->first; con; con = next) {
|
|
|
|
next = con->next;
|
2008-01-04 11:21:50 +00:00
|
|
|
|
|
|
|
/* check if tagged */
|
|
|
|
if (con->flag & CONSTRAINT_PROXY_LOCAL) {
|
|
|
|
BLI_remlink(src, con);
|
|
|
|
BLI_addtail(dst, con);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns if the owner of the constraint is proxy-protected */
|
2012-12-23 11:31:15 +00:00
|
|
|
short BKE_proxylocked_constraints_owner(Object *ob, bPoseChannel *pchan)
|
2008-01-04 11:21:50 +00:00
|
|
|
{
|
|
|
|
/* Currently, constraints can only be on object or bone level */
|
|
|
|
if (ob && ob->proxy) {
|
|
|
|
if (ob->pose && pchan) {
|
2012-05-06 17:22:54 +00:00
|
|
|
bArmature *arm = ob->data;
|
2008-01-04 11:21:50 +00:00
|
|
|
|
|
|
|
/* On bone-level, check if bone is on proxy-protected layer */
|
|
|
|
if ((pchan->bone) && (pchan->bone->layer & arm->layer_protected))
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* FIXME: constraints on object-level are not handled well yet */
|
|
|
|
return 1;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2008-01-04 11:21:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* -------- Target-Matrix Stuff ------- */
|
|
|
|
|
|
|
|
/* This function is a relic from the prior implementations of the constraints system, when all
|
|
|
|
* constraints either had one or no targets. It used to be called during the main constraint solving
|
|
|
|
* loop, but is now only used for the remaining cases for a few constraints.
|
|
|
|
*
|
2011-10-17 02:20:53 +00:00
|
|
|
* None of the actual calculations of the matrices should be done here! Also, this function is
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
* not to be used by any new constraints, particularly any that have multiple targets.
|
|
|
|
*/
|
2013-01-02 02:08:43 +00:00
|
|
|
void BKE_get_constraint_target_matrix(Scene *scene, bConstraint *con, int index, short ownertype, void *ownerdata, float mat[4][4], float ctime)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
{
|
2012-12-23 11:31:15 +00:00
|
|
|
bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
ListBase targets = {NULL, NULL};
|
|
|
|
bConstraintOb *cob;
|
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
if (cti && cti->get_constraint_targets) {
|
|
|
|
/* make 'constraint-ob' */
|
2012-05-06 17:22:54 +00:00
|
|
|
cob = MEM_callocN(sizeof(bConstraintOb), "tempConstraintOb");
|
|
|
|
cob->type = ownertype;
|
2009-10-22 23:22:05 +00:00
|
|
|
cob->scene = scene;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
switch (ownertype) {
|
|
|
|
case CONSTRAINT_OBTYPE_OBJECT: /* it is usually this case */
|
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
cob->ob = (Object *)ownerdata;
|
|
|
|
cob->pchan = NULL;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (cob->ob) {
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(cob->matrix, cob->ob->obmat);
|
|
|
|
copy_m4_m4(cob->startmat, cob->matrix);
|
2007-07-21 07:26:15 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(cob->matrix);
|
|
|
|
unit_m4(cob->startmat);
|
2007-07-21 07:26:15 +00:00
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
case CONSTRAINT_OBTYPE_BONE: /* this may occur in some cases */
|
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
cob->ob = NULL; /* this might not work at all :/ */
|
|
|
|
cob->pchan = (bPoseChannel *)ownerdata;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (cob->pchan) {
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(cob->matrix, cob->pchan->pose_mat);
|
|
|
|
copy_m4_m4(cob->startmat, cob->matrix);
|
2007-07-21 07:26:15 +00:00
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
else {
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(cob->matrix);
|
|
|
|
unit_m4(cob->startmat);
|
2007-07-21 07:26:15 +00:00
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2007-07-21 07:26:15 +00:00
|
|
|
}
|
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* get targets - we only need the first one though (and there should only be one) */
|
|
|
|
cti->get_constraint_targets(con, &targets);
|
|
|
|
|
|
|
|
/* only calculate the target matrix on the first target */
|
2013-01-02 02:08:43 +00:00
|
|
|
ct = (bConstraintTarget *)BLI_findlink(&targets, index);
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (ct) {
|
|
|
|
if (cti->get_target_matrix)
|
|
|
|
cti->get_target_matrix(con, cob, ct, ctime);
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(mat, ct->matrix);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* free targets + 'constraint-ob' */
|
|
|
|
if (cti->flush_constraint_targets)
|
|
|
|
cti->flush_constraint_targets(con, &targets, 1);
|
|
|
|
MEM_freeN(cob);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* invalid constraint - perhaps... */
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(mat);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-09-12 04:46:34 +00:00
|
|
|
}
|
2011-05-24 12:12:12 +00:00
|
|
|
|
|
|
|
/* Get the list of targets required for solving a constraint */
|
2012-12-23 11:31:15 +00:00
|
|
|
void BKE_get_constraint_targets_for_solving(bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime)
|
2011-05-24 12:12:12 +00:00
|
|
|
{
|
2012-12-23 11:31:15 +00:00
|
|
|
bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
|
2011-05-24 12:12:12 +00:00
|
|
|
|
|
|
|
if (cti && cti->get_constraint_targets) {
|
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* get targets
|
2012-05-06 17:22:54 +00:00
|
|
|
* - constraints should use ct->matrix, not directly accessing values
|
2011-05-24 12:12:12 +00:00
|
|
|
* - ct->matrix members have not yet been calculated here!
|
|
|
|
*/
|
|
|
|
cti->get_constraint_targets(con, targets);
|
|
|
|
|
|
|
|
/* set matrices
|
2012-05-06 17:22:54 +00:00
|
|
|
* - calculate if possible, otherwise just initialize as identity matrix
|
2011-05-24 12:12:12 +00:00
|
|
|
*/
|
|
|
|
if (cti->get_target_matrix) {
|
2012-05-06 17:22:54 +00:00
|
|
|
for (ct = targets->first; ct; ct = ct->next)
|
2011-05-24 12:12:12 +00:00
|
|
|
cti->get_target_matrix(con, cob, ct, ctime);
|
|
|
|
}
|
|
|
|
else {
|
2012-05-06 17:22:54 +00:00
|
|
|
for (ct = targets->first; ct; ct = ct->next)
|
2011-05-24 12:12:12 +00:00
|
|
|
unit_m4(ct->matrix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
|
|
|
|
/* ---------- Evaluation ----------- */
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* This function is called whenever constraints need to be evaluated. Currently, all
|
2013-05-26 12:02:29 +00:00
|
|
|
* constraints that can be evaluated are every time this gets run.
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
*
|
2012-12-23 11:31:15 +00:00
|
|
|
* BKE_constraints_make_evalob and BKE_constraints_clear_evalob should be called before and
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
* after running this function, to sort out cob
|
|
|
|
*/
|
2012-12-23 11:31:15 +00:00
|
|
|
void BKE_solve_constraints(ListBase *conlist, bConstraintOb *cob, float ctime)
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
{
|
|
|
|
bConstraint *con;
|
2010-09-28 10:03:56 +00:00
|
|
|
float oldmat[4][4];
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
float enf;
|
|
|
|
|
|
|
|
/* check that there is a valid constraint object to evaluate */
|
|
|
|
if (cob == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* loop over available constraints, solving and blending them */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (con = conlist->first; con; con = con->next) {
|
2012-12-23 11:31:15 +00:00
|
|
|
bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
ListBase targets = {NULL, NULL};
|
|
|
|
|
|
|
|
/* these we can skip completely (invalid constraints...) */
|
|
|
|
if (cti == NULL) continue;
|
2012-05-06 17:22:54 +00:00
|
|
|
if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) continue;
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* these constraints can't be evaluated anyway */
|
|
|
|
if (cti->evaluate_constraint == NULL) continue;
|
2007-07-23 11:28:43 +00:00
|
|
|
/* influence == 0 should be ignored */
|
|
|
|
if (con->enforce == 0.0f) continue;
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* influence of constraint
|
2012-05-06 17:22:54 +00:00
|
|
|
* - value should have been set from animation data already
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
*/
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
enf = con->enforce;
|
|
|
|
|
2011-03-24 23:34:43 +00:00
|
|
|
/* make copy of worldspace matrix pre-constraint for use with blending later */
|
|
|
|
copy_m4_m4(oldmat, cob->matrix);
|
|
|
|
|
2007-08-18 06:17:50 +00:00
|
|
|
/* move owner matrix into right space */
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, CONSTRAINT_SPACE_WORLD, con->ownspace);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* prepare targets for constraint solving */
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_get_constraint_targets_for_solving(con, cob, &targets, ctime);
|
2007-08-18 06:17:50 +00:00
|
|
|
|
2010-09-24 17:47:28 +00:00
|
|
|
/* Solve the constraint and put result in cob->matrix */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
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...
|
|
|
|
*/
|
|
|
|
if (cti->flush_constraint_targets) {
|
|
|
|
cti->flush_constraint_targets(con, &targets, 1);
|
|
|
|
}
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
2011-03-24 23:34:43 +00:00
|
|
|
/* move owner back into worldspace for next constraint/other business */
|
|
|
|
if ((con->flag & CONSTRAINT_SPACEONCE) == 0)
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, con->ownspace, CONSTRAINT_SPACE_WORLD);
|
2011-03-24 23:34:43 +00:00
|
|
|
|
|
|
|
/* Interpolate the enforcement, to blend result of constraint into final owner transform
|
2012-05-06 17:22:54 +00:00
|
|
|
* - 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
|
2011-03-24 23:34:43 +00:00
|
|
|
*/
|
2012-10-27 13:22:44 +00:00
|
|
|
/* Note: all kind of stuff here before (caused trouble), much easier to just interpolate, or did I miss something? -jahka (r.32105) */
|
2011-03-27 14:59:55 +00:00
|
|
|
if (enf < 1.0f) {
|
2010-09-24 17:47:28 +00:00
|
|
|
float solution[4][4];
|
|
|
|
copy_m4_m4(solution, cob->matrix);
|
|
|
|
blend_m4_m4m4(cob->matrix, oldmat, solution, enf);
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|