Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2007-07-24 15:39:40 +0400
committerJoshua Leung <aligorith@gmail.com>2007-07-24 15:39:40 +0400
commitd0dee342b9b2aba87bc4ea936b2786d9979d9ea6 (patch)
tree17a84ef2814c7e04998bd61da29e8dda23a177da /source/blender/src/transform_conversions.c
parentc8273f4f9e30c4144fd10d1cf6f0da64d285c7cf (diff)
Bugfixes for Transform (related to Constraints):
* Reverting a previous commit where I wrongly assumed that the code was not doing things the right way. This makes a few cases work better normally again. * Object-level Transforms should now perform normally again. Now, transforms are only get inverse-corrected for constraints if certain constraints are the first 'active' constraint. * PoseBone-level Transforms still need to be fixed, although I might have done a few tweaks here.
Diffstat (limited to 'source/blender/src/transform_conversions.c')
-rwxr-xr-xsource/blender/src/transform_conversions.c47
1 files changed, 40 insertions, 7 deletions
diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c
index 2d78c9a2322..542d3795d19 100755
--- a/source/blender/src/transform_conversions.c
+++ b/source/blender/src/transform_conversions.c
@@ -2040,6 +2040,36 @@ static void ipokey_to_transdata(IpoKey *ik, TransData *td)
/* *************************** Object Transform data ******************* */
+/* Little helper function for ObjectToTransData used to give certain
+ * constraints (ChildOf, FollowPath, and others that may be added)
+ * inverse corrections for transform, so that they aren't in CrazySpace.
+ * These particular constraints benefit from this, but others don't, hence
+ * this semi-hack ;-) - Aligorith
+ */
+static short ob_constraints_needinv(Object *ob)
+{
+ bConstraint *con;
+
+ /* loop through constraints, checking if there's one of the mentioned
+ * constraints needing special crazyspace corrections
+ */
+ if (ob && ob->constraints.first) {
+ for (con= ob->constraints.first; con; con=con->next) {
+ /* only consider constraint if it is enabled, and has influence on result */
+ if ((con->flag & CONSTRAINT_DISABLE)==0 && (con->enforce!=0.0)) {
+ /* (affirmative) returns for specific constraints here... */
+ if (con->type == CONSTRAINT_TYPE_CHILDOF) return 1;
+ if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) return 1;
+ if (con->type == CONSTRAINT_TYPE_CLAMPTO) return 1;
+ }
+ }
+ }
+
+ /* no appropriate candidates found */
+ return 0;
+}
+
+/* transcribe given object into TransData for Transforming */
static void ObjectToTransData(TransData *td, Object *ob)
{
float obmtx[3][3];
@@ -2065,19 +2095,22 @@ static void ObjectToTransData(TransData *td, Object *ob)
VECCOPY(td->center, ob->obmat[3]);
- if (ob->parent || ob->constraints.first)
- {
+ /* is there a need to set the global<->data space conversion matrices? */
+ if (ob->parent || ob_constraints_needinv(ob)) {
float totmat[3][3], obinv[3][3];
- /* get the effect of parenting, and/or constraints */
+ /* Get the effect of parenting, and/or certain constraints.
+ * NOTE: some Constraints, and also Tracking should never get this
+ * done, as it doesn't work well.
+ */
object_to_mat3(ob, obmtx);
Mat3CpyMat4(totmat, ob->obmat);
- Mat3Inv(obinv, obmtx);
- Mat3MulMat3(td->smtx, totmat, obinv);
+ Mat3Inv(obinv, totmat);
+ Mat3MulMat3(td->smtx, obmtx, obinv);
Mat3Inv(td->mtx, td->smtx);
}
- else
- {
+ else {
+ /* no conversion to/from dataspace */
Mat3One(td->smtx);
Mat3One(td->mtx);
}