[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24245] branches/bmesh/blender/source/ blender/ikplugin/intern: fix working copy <-> server mismatch

Joseph Eagar joeedh at gmail.com
Mon Nov 2 17:07:27 CET 2009


Revision: 24245
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24245
Author:   joeedh
Date:     2009-11-02 17:07:27 +0100 (Mon, 02 Nov 2009)

Log Message:
-----------
fix working copy <-> server mismatch

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/ikplugin/intern/iksolver_plugin.c
    branches/bmesh/blender/source/blender/ikplugin/intern/itasc_plugin.cpp

Modified: branches/bmesh/blender/source/blender/ikplugin/intern/iksolver_plugin.c
===================================================================
--- branches/bmesh/blender/source/blender/ikplugin/intern/iksolver_plugin.c	2009-11-02 16:01:24 UTC (rev 24244)
+++ branches/bmesh/blender/source/blender/ikplugin/intern/iksolver_plugin.c	2009-11-02 16:07:27 UTC (rev 24245)
@@ -210,7 +210,7 @@
 
 /* called from within the core where_is_pose loop, all animsystems and constraints
 were executed & assigned. Now as last we do an IK pass */
-static void execute_posetree(Object *ob, PoseTree *tree)
+static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
 {
 	float R_parmat[3][3], identity[3][3];
 	float iR_parmat[3][3];
@@ -347,7 +347,7 @@
 		/* 1.0=ctime, we pass on object for auto-ik (owner-type here is object, even though
 		 * strictly speaking, it is a posechannel)
 		 */
-		get_constraint_target_matrix(target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
+		get_constraint_target_matrix(scene, target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
 		
 		/* and set and transform goal */
 		Mat4MulMat4(goal, rootmat, goalinv);
@@ -357,7 +357,7 @@
 		
 		/* same for pole vector target */
 		if(data->poletar) {
-			get_constraint_target_matrix(target->con, 1, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
+			get_constraint_target_matrix(scene, target->con, 1, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
 			
 			if(data->flag & CONSTRAINT_IK_SETANGLE) {
 				/* don't solve IK when we are setting the pole angle */
@@ -511,7 +511,7 @@
 			tree->pchan[a]->flag |= POSE_CHAIN;
 		}
 		/* 5. execute the IK solver */
-		execute_posetree(ob, tree);
+		execute_posetree(scene, ob, tree);
 		
 		/* 6. apply the differences to the channels, 
 			  we need to calculate the original differences first */

Modified: branches/bmesh/blender/source/blender/ikplugin/intern/itasc_plugin.cpp
===================================================================
--- branches/bmesh/blender/source/blender/ikplugin/intern/itasc_plugin.cpp	2009-11-02 16:01:24 UTC (rev 24244)
+++ branches/bmesh/blender/source/blender/ikplugin/intern/itasc_plugin.cpp	2009-11-02 16:07:27 UTC (rev 24245)
@@ -89,6 +89,7 @@
 // one structure for each target in the scene
 struct IK_Target
 {
+	struct Scene			*blscene;
 	iTaSC::MovingFrame*		target;
 	iTaSC::ConstraintSet*	constraint;
 	struct bConstraint*		blenderConstraint;
@@ -105,6 +106,7 @@
 	float					eeRest[4][4];	//end effector initial pose relative to armature
 
 	IK_Target() {
+		blscene = NULL;
 		target = NULL;
 		constraint = NULL;
 		blenderConstraint = NULL;
@@ -155,6 +157,7 @@
 
 struct IK_Scene
 {
+	struct Scene		*blscene;
 	IK_Scene*			next;
 	int					numchan;	// number of channel in pchan
 	int					numjoint;	// number of joint in jointArray
@@ -172,6 +175,7 @@
 	std::vector<IK_Target*>		targets;
 
 	IK_Scene() {
+		blscene = NULL;
 		next = NULL;
 		channels = NULL;
 		armature = NULL;
@@ -533,7 +537,7 @@
 	bConstraint* constraint = (bConstraint*)target->blenderConstraint;
 	float tarmat[4][4];
 
-	get_constraint_target_matrix(constraint, 0, CONSTRAINT_OBTYPE_OBJECT, target->owner, tarmat, 1.0);
+	get_constraint_target_matrix(target->blscene, constraint, 0, CONSTRAINT_OBTYPE_OBJECT, target->owner, tarmat, 1.0);
 
 	// rootmat contains the target pose in world coordinate
 	// if enforce is != 1.0, blend the target position with the end effector position
@@ -601,7 +605,7 @@
 		IK_Channel &rootchan = ikscene->channels[0];
 
 		// get polar target matrix in world space
-		get_constraint_target_matrix(ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0);
+		get_constraint_target_matrix(ikscene->blscene, ikscene->polarConstraint, 1, CONSTRAINT_OBTYPE_OBJECT, ikscene->blArmature, mat, 1.0);
 		// convert to armature space
 		Mat4MulMat4(polemat, mat, imat);
 		// get the target in world space (was computed before as target object are defined before base object)
@@ -1050,6 +1054,7 @@
 		return NULL;
 
 	ikscene = new IK_Scene;
+	ikscene->blscene = blscene;
 	arm = new iTaSC::Armature();
 	scene = new iTaSC::Scene();
 	ikscene->channels = new IK_Channel[tree->totchannel];
@@ -1382,6 +1387,7 @@
 	// finally add the constraint
 	for (t=0; t<ikscene->targets.size(); t++) {
 		IK_Target* iktarget = ikscene->targets[t];
+		iktarget->blscene = blscene;
 		condata= (bKinematicConstraint*)iktarget->blenderConstraint->data;
 		pchan = tree->pchan[iktarget->channel];
 		unsigned int controltype, bonecnt;
@@ -1411,10 +1417,22 @@
 		switch (condata->type) {
 		case CONSTRAINT_IK_COPYPOSE:
 			controltype = 0;
-			if ((condata->flag & CONSTRAINT_IK_ROT) && (condata->orientweight != 0.0))
-				controltype |= iTaSC::CopyPose::CTL_ROTATION;
-			if ((condata->weight != 0.0))
-				controltype |= iTaSC::CopyPose::CTL_POSITION;
+			if (condata->flag & CONSTRAINT_IK_ROT) {
+				if (!(condata->flag & CONSTRAINT_IK_NO_ROT_X))
+					controltype |= iTaSC::CopyPose::CTL_ROTATIONX;
+				if (!(condata->flag & CONSTRAINT_IK_NO_ROT_Y))
+					controltype |= iTaSC::CopyPose::CTL_ROTATIONY;
+				if (!(condata->flag & CONSTRAINT_IK_NO_ROT_Z))
+					controltype |= iTaSC::CopyPose::CTL_ROTATIONZ;
+			}
+			if (condata->flag & CONSTRAINT_IK_POS) {
+				if (!(condata->flag & CONSTRAINT_IK_NO_POS_X))
+					controltype |= iTaSC::CopyPose::CTL_POSITIONX;
+				if (!(condata->flag & CONSTRAINT_IK_NO_POS_Y))
+					controltype |= iTaSC::CopyPose::CTL_POSITIONY;
+				if (!(condata->flag & CONSTRAINT_IK_NO_POS_Z))
+					controltype |= iTaSC::CopyPose::CTL_POSITIONZ;
+			}
 			if (controltype) {
 				iktarget->constraint = new iTaSC::CopyPose(controltype, controltype, bonelen);
 				// set the gain
@@ -1426,7 +1444,10 @@
 				iktarget->errorCallback = copypose_error;
 				iktarget->controlType = controltype;
 				// add the constraint
-				ret = scene->addConstraintSet(iktarget->constraintName, iktarget->constraint, armname, iktarget->targetName, ikscene->channels[iktarget->channel].tail);
+				if (condata->flag & CONSTRAINT_IK_TARGETAXIS)
+					ret = scene->addConstraintSet(iktarget->constraintName, iktarget->constraint, iktarget->targetName, armname, "", ikscene->channels[iktarget->channel].tail);
+				else
+					ret = scene->addConstraintSet(iktarget->constraintName, iktarget->constraint, armname, iktarget->targetName, ikscene->channels[iktarget->channel].tail);
 			}
 			break;
 		case CONSTRAINT_IK_DISTANCE:





More information about the Bf-blender-cvs mailing list