[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12792] trunk/blender/source/blender: Two transform tweaks:
Joshua Leung
aligorith at gmail.com
Wed Dec 5 12:19:36 CET 2007
Revision: 12792
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12792
Author: aligorith
Date: 2007-12-05 12:19:36 +0100 (Wed, 05 Dec 2007)
Log Message:
-----------
Two transform tweaks:
* [Peach Request] AutoIK now respects axis locking (rotation locks).
- Temporary DOF-Locks are turned on for those bones that are part of an AutoIK chain while transforming. These locks get cleared after transforming.
- This works for all bones except the root bone of the chain, which doesn't seem to be able to be locked.
* Limit Location constraint can now optionally affect Translations too (i.e. NKEY panel values won't change).
- LimitRot,LimitScale support (for their respective transforms) will be done at a later date
- This only works if the constraint is using World/Local space (the other spaces are not supported yet).
- I've added a temporary button in the LimitLoc panel to enable this option (it is disabled by default). This button will be properly assigned a place in that panel sometime.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/armature.c
trunk/blender/source/blender/include/transform.h
trunk/blender/source/blender/makesdna/DNA_action_types.h
trunk/blender/source/blender/makesdna/DNA_constraint_types.h
trunk/blender/source/blender/src/buttons_object.c
trunk/blender/source/blender/src/transform.c
trunk/blender/source/blender/src/transform_conversions.c
Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/armature.c 2007-12-05 10:52:14 UTC (rev 12791)
+++ trunk/blender/source/blender/blenkernel/intern/armature.c 2007-12-05 11:19:36 UTC (rev 12792)
@@ -1589,11 +1589,11 @@
/* set DoF flag */
flag= 0;
- if((pchan->ikflag & BONE_IK_NO_XDOF) == 0)
+ if(!(pchan->ikflag & BONE_IK_NO_XDOF) && !(pchan->ikflag & BONE_IK_NO_XDOF_TEMP))
flag |= IK_XDOF;
- if((pchan->ikflag & BONE_IK_NO_YDOF) == 0)
+ if(!(pchan->ikflag & BONE_IK_NO_YDOF) && !(pchan->ikflag & BONE_IK_NO_YDOF_TEMP))
flag |= IK_YDOF;
- if((pchan->ikflag & BONE_IK_NO_ZDOF) == 0)
+ if(!(pchan->ikflag & BONE_IK_NO_ZDOF) && !(pchan->ikflag & BONE_IK_NO_ZDOF_TEMP))
flag |= IK_ZDOF;
if(tree->stretch && (pchan->ikstretch > 0.0)) {
Modified: trunk/blender/source/blender/include/transform.h
===================================================================
--- trunk/blender/source/blender/include/transform.h 2007-12-05 10:52:14 UTC (rev 12791)
+++ trunk/blender/source/blender/include/transform.h 2007-12-05 11:19:36 UTC (rev 12792)
@@ -45,6 +45,7 @@
struct View3D;
struct ScrArea;
struct bPose;
+struct bConstraint;
typedef struct NumInput {
@@ -142,6 +143,7 @@
float smtx[3][3]; /* Transformation matrix from global space to data space */
float axismtx[3][3];/* Axis orientation matrix of the data */
struct Object *ob;
+ struct bConstraint *con; /* for objects/bones, the first constraint in its constraint stack */
TransDataExtension *ext; /* for objects, poses. 1 single malloc per TransInfo! */
TransDataIpokey *tdi; /* for objects, ipo keys. per transdata a malloc */
void *tdmir; /* mirrored element pointer, in editmode mesh to EditVert */
Modified: trunk/blender/source/blender/makesdna/DNA_action_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_action_types.h 2007-12-05 10:52:14 UTC (rev 12791)
+++ trunk/blender/source/blender/makesdna/DNA_action_types.h 2007-12-05 11:19:36 UTC (rev 12792)
@@ -39,7 +39,6 @@
/* PoseChannel stores the results of Actions (ipos) and transform information
with respect to the restposition of Armature bones */
-
typedef struct bPoseChannel {
struct bPoseChannel *next, *prev;
ListBase constraints;/* Constraints that act on this PoseChannel */
@@ -50,7 +49,7 @@
short ikflag; /* settings for IK bones */
short selectflag; /* copy of bone flag, so you can work with library armatures */
short protectflag; /* protect channels from being transformed */
- short pad2;
+ short customCol; /* index of custom color set to use (0=default - used for all old files) */
int pathlen; /* for drawing paths, the amount of frames */
int pathsf; /* for drawing paths, the start frame number */
@@ -84,7 +83,6 @@
float *path; /* totpath x 3 x float */
struct Object *custom; /* draws custom object instead of this channel */
-
} bPoseChannel;
/* Pose-Object. It is only found under ob->pose. It is not library data, even
@@ -217,7 +215,11 @@
BONE_IK_XLIMIT = (1<<3),
BONE_IK_YLIMIT = (1<<4),
- BONE_IK_ZLIMIT = (1<<5)
+ BONE_IK_ZLIMIT = (1<<5),
+
+ BONE_IK_NO_XDOF_TEMP = (1<<10),
+ BONE_IK_NO_YDOF_TEMP = (1<<11),
+ BONE_IK_NO_ZDOF_TEMP = (1<<12)
} PCHAN_IKFLAG;
Modified: trunk/blender/source/blender/makesdna/DNA_constraint_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_constraint_types.h 2007-12-05 10:52:14 UTC (rev 12791)
+++ trunk/blender/source/blender/makesdna/DNA_constraint_types.h 2007-12-05 11:19:36 UTC (rev 12792)
@@ -294,7 +294,7 @@
float ymin, ymax;
float zmin, zmax;
short flag;
- short pad1;
+ short flag2;
} bRotLimitConstraint;
/* Limit Scaling Constraint */
@@ -303,7 +303,7 @@
float ymin, ymax;
float zmin, zmax;
short flag;
- short pad1;
+ short flag2;
} bSizeLimitConstraint;
/* ------------------------------------------ */
@@ -471,9 +471,11 @@
#define LIMIT_YROT 0x02
#define LIMIT_ZROT 0x04
-/* not used anymore - for older Limit Location constraints only */
+ /* not used anymore - for older Limit Location constraints only */
#define LIMIT_NOPARENT 0x01
-
+ /* for all Limit constraints - allow to be used during transform? */
+#define LIMIT_TRANSFORM 0x02
+
/* python constraint -> flag */
#define PYCON_USETARGETS 0x01
#define PYCON_SCRIPTERROR 0x02
Modified: trunk/blender/source/blender/src/buttons_object.c
===================================================================
--- trunk/blender/source/blender/src/buttons_object.c 2007-12-05 10:52:14 UTC (rev 12791)
+++ trunk/blender/source/blender/src/buttons_object.c 2007-12-05 11:19:36 UTC (rev 12792)
@@ -459,7 +459,6 @@
bwidth = 125;
tarx = 120;
ownx = 0;
-
}
else if (target == -1) {
bwidth = 125;
@@ -1284,6 +1283,9 @@
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-72, (textButWidth-5), 18, &(data->zmax), -1000, 1000, 0.1,0.5,"Highest z value to allow");
uiBlockEndAlign(block);
+ // temp placement!!!
+ uiDefButBitS(block, TOG, LIMIT_TRANSFORM, B_CONSTRAINT_TEST, "Trans", *xco+245, *yco-100, 50, 18, &data->flag2, 0, 24, 0, 0, "Only use during transform");
+
/* constraint space settings */
draw_constraint_spaceselect(block, con, *xco, *yco-100, is_armature_owner(ob), -1);
}
Modified: trunk/blender/source/blender/src/transform.c
===================================================================
--- trunk/blender/source/blender/src/transform.c 2007-12-05 10:52:14 UTC (rev 12791)
+++ trunk/blender/source/blender/src/transform.c 2007-12-05 11:19:36 UTC (rev 12792)
@@ -49,6 +49,7 @@
#include "DNA_armature_types.h"
#include "DNA_action_types.h" /* for some special action-editor settings */
+#include "DNA_constraint_types.h"
#include "DNA_ipo_types.h" /* some silly ipo flag */
#include "DNA_listBase.h"
#include "DNA_meshdata_types.h"
@@ -80,6 +81,7 @@
#include "BIF_editaction.h"
#include "BKE_action.h" /* get_action_frame */
+#include "BKE_constraint.h"
#include "BKE_global.h"
#include "BKE_utildefines.h"
#include "BKE_bad_level_calls.h"/* popmenu and error */
@@ -1251,7 +1253,7 @@
}
-/* ************************** TRANSFORMATIONS **************************** */
+/* ************************** TRANSFORM LOCKS **************************** */
static void protectedTransBits(short protectflag, float *vec)
{
@@ -1310,6 +1312,79 @@
}
}
+/* ******************* TRANSFORM LIMITS ********************** */
+
+static void constraintTransLim(TransInfo *t, TransData *td)
+{
+ if (td->con) {
+ bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_LOCLIMIT);
+ bConstraintOb *cob;
+ bConstraint *con;
+
+ /* Make a temporary bConstraintOb for using these limit constraints
+ * - they only care that cob->matrix is correctly set ;-)
+ * - current space should be local
+ */
+ cob= MEM_callocN(sizeof(bConstraintOb), "bConstraintOb-Transform");
+ Mat4One(cob->matrix);
+ if (td->tdi) {
+ TransDataIpokey *tdi= td->tdi;
+ cob->matrix[3][0]= tdi->locx[0];
+ cob->matrix[3][1]= tdi->locy[0];
+ cob->matrix[3][2]= tdi->locz[0];
+ }
+ else {
+ VECCOPY(cob->matrix[3], td->loc);
+ }
+
+ /* Evaluate valid constraints */
+ for (con= td->con; con; con= con->next) {
+ /* we're only interested in Limit-Location constraints */
+ if (con->type == CONSTRAINT_TYPE_LOCLIMIT) {
+ bLocLimitConstraint *data= con->data;
+ float tmat[4][4];
+
+ /* only use it if it's tagged for this purpose */
+ if ((data->flag2 & LIMIT_TRANSFORM)==0)
+ continue;
+
+ /* do space conversions */
+ if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
+ /* just multiply by td->mtx (this should be ok) */
+ Mat4CpyMat4(tmat, cob->matrix);
+ Mat4MulMat34(cob->matrix, td->mtx, tmat); // checkme
+ }
+ else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) {
+ /* skip... incompatable spacetype */
+ continue;
+ }
+
+ /* do constraint */
+ cti->evaluate_constraint(con, cob, NULL);
+
+ /* convert spaces again */
+ if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
+ /* just multiply by td->mtx (this should be ok) */
+ Mat4CpyMat4(tmat, cob->matrix);
+ Mat4MulMat34(cob->matrix, td->smtx, tmat); // checkme
+ }
+ }
+ }
+
+ /* copy results from cob->matrix, and free */
+ if (td->tdi) {
+ TransDataIpokey *tdi= td->tdi;
+ tdi->locx[0]= cob->matrix[3][0];
+ tdi->locy[0]= cob->matrix[3][1];
+ tdi->locz[0]= cob->matrix[3][2];
+ }
+ else {
+ VECCOPY(td->loc, cob->matrix[3]);
+ }
+ MEM_freeN(cob);
+ }
+}
+
/* ************************** WARP *************************** */
void initWarp(TransInfo *t)
@@ -2484,10 +2559,10 @@
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
-
+
if (td->flag & TD_SKIP)
continue;
-
+
if (t->con.applyVec) {
float pvec[3];
t->con.applyVec(t, td, vec, tvec, pvec);
@@ -2495,7 +2570,7 @@
else {
VECCOPY(tvec, vec);
}
-
+
Mat3MulVecfl(td->smtx, tvec);
VecMulf(tvec, td->factor);
@@ -2509,6 +2584,8 @@
add_tdi_poin(tdi->locz, tdi->oldloc+2, tvec[2]);
}
else VecAddf(td->loc, td->iloc, tvec);
+
+ constraintTransLim(t, td);
}
}
Modified: trunk/blender/source/blender/src/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/src/transform_conversions.c 2007-12-05 10:52:14 UTC (rev 12791)
+++ trunk/blender/source/blender/src/transform_conversions.c 2007-12-05 11:19:36 UTC (rev 12792)
@@ -616,6 +616,9 @@
Mat3Inv (td->smtx, td->mtx);
}
}
+
+ /* store reference to first constraint */
+ td->con= pchan->constraints.first;
}
static void bone_children_clear_transflag(ListBase *lb)
@@ -689,11 +692,15 @@
bPoseChannel *pchan;
bConstraint *con;
- for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- for(con= pchan->constraints.first; con; con= con->next) {
- if(con->type==CONSTRAINT_TYPE_KINEMATIC) {
+ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ /* clear all temporary lock flags */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list