[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12703] trunk/blender/source/blender: Tiny feature, but loadsa code, and big impact for the Blender riggers:

Ton Roosendaal ton at blender.org
Wed Nov 28 13:11:06 CET 2007


Revision: 12703
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12703
Author:   ton
Date:     2007-11-28 13:11:06 +0100 (Wed, 28 Nov 2007)

Log Message:
-----------
Tiny feature, but loadsa code, and big impact for the Blender riggers:

-> Constraint Influence Ipo now can be local, linked to constraint itself

You enable this in the IpoWindow header, with the Action icon to the left
of the Ipo Type menu. The button tooltips give the clue as well.

Tech note: the Ipo now can get directly linked to a constraint, and is
being called during regular pose constraint solving.
Actions (and drivers in actions) are being calculated *before* pose 
constraint solving. Result of actions then is written in bones, which
then solves the entire pose.
This means you can have a driver on both the constraint, as on the action
channel for the constraint! Not that I'm going to debug that easily :)

Additional fix: Joshua added a copy/paste IpoCurve feature, but he broke
the functionality to be able to paste in an empty ipo channel. That now
works again

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/armature.c
    trunk/blender/source/blender/blenkernel/intern/constraint.c
    trunk/blender/source/blender/blenkernel/intern/depsgraph.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/include/BSE_editipo.h
    trunk/blender/source/blender/include/blendef.h
    trunk/blender/source/blender/include/butspace.h
    trunk/blender/source/blender/makesdna/DNA_constraint_types.h
    trunk/blender/source/blender/makesdna/DNA_space_types.h
    trunk/blender/source/blender/src/buttons_object.c
    trunk/blender/source/blender/src/drawipo.c
    trunk/blender/source/blender/src/drawnode.c
    trunk/blender/source/blender/src/editipo.c
    trunk/blender/source/blender/src/editkey.c
    trunk/blender/source/blender/src/header_ipo.c

Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/armature.c	2007-11-27 23:15:51 UTC (rev 12702)
+++ trunk/blender/source/blender/blenkernel/intern/armature.c	2007-11-28 12:11:06 UTC (rev 12703)
@@ -2083,6 +2083,9 @@
 	if (pchan->constraints.first) {
 		bConstraintOb *cob;
 		
+		/* local constraints */
+		do_constraint_channels(&pchan->constraints, NULL, ctime, 0);
+		
 		/* make a copy of location of PoseChannel for later */
 		VECCOPY(vec, pchan->pose_mat[3]);
 		

Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c	2007-11-27 23:15:51 UTC (rev 12702)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2007-11-28 12:11:06 UTC (rev 12703)
@@ -142,9 +142,11 @@
 {
 	bConstraintChannel *chan;
 
-	for (chan = list->first; chan; chan=chan->next) {
-		if (!strcmp(name, chan->name)) {
-			return chan;
+	if(list) {
+		for (chan = list->first; chan; chan=chan->next) {
+			if (!strcmp(name, chan->name)) {
+				return chan;
+			}
 		}
 	}
 	
@@ -175,17 +177,24 @@
 void do_constraint_channels (ListBase *conbase, ListBase *chanbase, float ctime, short onlydrivers)
 {
 	bConstraint *con;
-	bConstraintChannel *chan;
-	IpoCurve *icu= NULL;
 	
 	/* for each Constraint, calculate its Influence from the corresponding ConstraintChannel */
 	for (con=conbase->first; con; con=con->next) {
-		chan = get_constraint_channel(chanbase, con->name);
+		Ipo *ipo= NULL;
 		
-		if (chan && chan->ipo) {
-			calc_ipo(chan->ipo, ctime);
+		if(con->flag & CONSTRAINT_OWN_IPO)
+			ipo= con->ipo;
+		else {
+			bConstraintChannel *chan = get_constraint_channel(chanbase, con->name);
+			if(chan) ipo= chan->ipo;
+		}
+		
+		if (ipo) {
+			IpoCurve *icu;
 			
-			for (icu=chan->ipo->curve.first; icu; icu=icu->next) {
+			calc_ipo(ipo, ctime);
+			
+			for (icu=ipo->curve.first; icu; icu=icu->next) {
 				if (!onlydrivers || icu->driver) {
 					switch (icu->adrcode) {
 						case CO_ENFORCE:

Modified: trunk/blender/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/depsgraph.c	2007-11-27 23:15:51 UTC (rev 12702)
+++ trunk/blender/source/blender/blenkernel/intern/depsgraph.c	2007-11-28 12:11:06 UTC (rev 12703)
@@ -2180,6 +2180,21 @@
 			ListBase targets = {NULL, NULL};
 			bConstraintTarget *ct;
 			
+			if(con->ipo) {
+				IpoCurve *icu;
+				for(icu= con->ipo->curve.first; icu; icu= icu->next) {
+					if(icu->driver && icu->driver->ob==ob) {
+						bPoseChannel *target= get_pose_channel(ob->pose, icu->driver->name);
+						if(target) {
+							node2 = dag_get_node(dag, target);
+							dag_add_relation(dag, node2, node, 0);
+							dag_add_parent_relation(dag, node2, node, 0);
+							cti= NULL;	/* trick to get next loop skipped */
+						}
+					}
+				}
+			}
+			
 			if (cti && cti->get_constraint_targets) {
 				cti->get_constraint_targets(con, &targets);
 				

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2007-11-27 23:15:51 UTC (rev 12702)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2007-11-28 12:11:06 UTC (rev 12703)
@@ -1619,7 +1619,9 @@
 		if(con->data==NULL) {
 			con->type= CONSTRAINT_TYPE_NULL;
 		}
-
+		/* own ipo, all constraints have it */
+		con->ipo= newlibadr(fd, id->lib, con->ipo);
+		
 		switch (con->type) {
 		case CONSTRAINT_TYPE_PYTHON:
 			{

Modified: trunk/blender/source/blender/include/BSE_editipo.h
===================================================================
--- trunk/blender/source/blender/include/BSE_editipo.h	2007-11-27 23:15:51 UTC (rev 12702)
+++ trunk/blender/source/blender/include/BSE_editipo.h	2007-11-28 12:11:06 UTC (rev 12703)
@@ -89,8 +89,8 @@
 
 
 /* gets ipo curve, creates if needed */
-struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, int);
-struct Ipo *verify_ipo(struct ID *, short, char *, char *);
+struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int);
+struct Ipo *verify_ipo(struct ID *, short, char *, char *, char *);
 int texchannel_to_adrcode(int channel);
 
 int insert_bezt_icu(struct IpoCurve *icu, struct BezTriple *bezt);

Modified: trunk/blender/source/blender/include/blendef.h
===================================================================
--- trunk/blender/source/blender/include/blendef.h	2007-11-27 23:15:51 UTC (rev 12702)
+++ trunk/blender/source/blender/include/blendef.h	2007-11-28 12:11:06 UTC (rev 12703)
@@ -254,8 +254,8 @@
 #define B_IPO_ACTION_KEY	214
 #define B_IPOVIEWCENTER		215
 #define B_IPOVIEWALL		216
+#define B_IPOREDRAW			217
 
-
 /* OOPS: 250 */
 #define B_OOPSHOME		251
 #define B_OOPSBORDER		252

Modified: trunk/blender/source/blender/include/butspace.h
===================================================================
--- trunk/blender/source/blender/include/butspace.h	2007-11-27 23:15:51 UTC (rev 12702)
+++ trunk/blender/source/blender/include/butspace.h	2007-11-28 12:11:06 UTC (rev 12703)
@@ -87,7 +87,6 @@
 extern void const_moveUp(void *ob_v, void *con_v);
 extern void const_moveDown(void *ob_v, void *con_v);
 extern void del_constr_func (void *ob_v, void *con_v);
-extern void get_constraint_ipo_context(void *ob_v, char *actname);
 
 /* editing */
 extern void editing_panels(void);

Modified: trunk/blender/source/blender/makesdna/DNA_constraint_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_constraint_types.h	2007-11-27 23:15:51 UTC (rev 12702)
+++ trunk/blender/source/blender/makesdna/DNA_constraint_types.h	2007-11-28 12:11:06 UTC (rev 12703)
@@ -41,6 +41,7 @@
 
 struct Action;
 struct Text;
+struct Ipo;
 
 /* channels reside in Object or Action (ListBase) constraintChannels */
 typedef struct bConstraintChannel {
@@ -66,6 +67,7 @@
 	float		enforce;	/* 	Amount of influence exherted by constraint (0.0-1.0) */
 	float		headtail;	/*	Point along subtarget bone where the actual target is. 0=head (default for all), 1=tail*/
 	int			pad;
+	struct Ipo *ipo;		/* local influence ipo or driver */
 } bConstraint;
 
 
@@ -347,7 +349,9 @@
 		/* to indicate which Ipo should be shown, maybe for 3d access later too */	
 	CONSTRAINT_ACTIVE = 	(1<<4), 
 		/* to indicate that the owner's space should only be changed into ownspace, but not out of it */
-	CONSTRAINT_SPACEONCE = 	(1<<6)  
+	CONSTRAINT_SPACEONCE = 	(1<<6),
+		/* influence ipo is on constraint itself, not in action channel */
+	CONSTRAINT_OWN_IPO	= (1<<7)
 } B_CONSTRAINT_FLAG;
 
 /* bConstraint->ownspace/tarspace */

Modified: trunk/blender/source/blender/makesdna/DNA_space_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_space_types.h	2007-11-27 23:15:51 UTC (rev 12702)
+++ trunk/blender/source/blender/makesdna/DNA_space_types.h	2007-11-28 12:11:06 UTC (rev 12703)
@@ -94,7 +94,7 @@
 	/* the ipo context we need to store */
 	struct Ipo *ipo;
 	struct ID *from;
-	char actname[32], constname[32];
+	char actname[32], constname[32], bonename[32];
 
 	short totipo, pin;
 	short butofs, channel;

Modified: trunk/blender/source/blender/src/buttons_object.c
===================================================================
--- trunk/blender/source/blender/src/buttons_object.c	2007-11-27 23:15:51 UTC (rev 12702)
+++ trunk/blender/source/blender/src/buttons_object.c	2007-11-28 12:11:06 UTC (rev 12703)
@@ -205,7 +205,7 @@
 
 /* returns base ID for Ipo, sets actname to channel if appropriate */
 /* should not make action... */
-void get_constraint_ipo_context(void *ob_v, char *actname)
+static void get_constraint_ipo_context(void *ob_v, char *actname)
 {
 	Object *ob= ob_v;
 	
@@ -237,8 +237,11 @@
 	get_constraint_ipo_context(ob, actname);
 	
 	/* adds ipo & channels & curve if needed */
-	verify_ipo((ID *)ob, ID_CO, actname, con->name);
-	
+	if(con->flag & CONSTRAINT_OWN_IPO)
+		verify_ipo((ID *)ob, ID_CO, NULL, con->name, actname);
+	else
+		verify_ipo((ID *)ob, ID_CO, actname, con->name, NULL);
+		
 	/* make sure ipowin shows it */
 	ob->ipowin= ID_CO;
 	allqueue(REDRAWIPO, ID_CO);
@@ -261,8 +264,11 @@
 	get_constraint_ipo_context(ob, actname);
 
 	/* adds ipo & channels & curve if needed */
-	icu= verify_ipocurve((ID *)ob, ID_CO, actname, con->name, CO_ENFORCE);
-	
+	if(con->flag & CONSTRAINT_OWN_IPO)
+		icu= verify_ipocurve((ID *)ob, ID_CO, NULL, con->name, actname, CO_ENFORCE);
+	else
+		icu= verify_ipocurve((ID *)ob, ID_CO, actname, con->name, NULL, CO_ENFORCE);
+		
 	if (!icu) {
 		error("Cannot get a curve from this IPO, may be dealing with linked data");
 		return;

Modified: trunk/blender/source/blender/src/drawipo.c
===================================================================
--- trunk/blender/source/blender/src/drawipo.c	2007-11-27 23:15:51 UTC (rev 12702)
+++ trunk/blender/source/blender/src/drawipo.c	2007-11-28 12:11:06 UTC (rev 12703)
@@ -1899,7 +1899,7 @@
 		ei= get_active_editipo();
 		if(ei) {
 			if(ei->icu==NULL) {
-				ei->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, ei->adrcode);
+				ei->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, G.sipo->bonename, ei->adrcode);
 				if (!ei->icu) {
 					error("Could not add a driver to this curve, may be linked data!");
 					break;
@@ -1966,7 +1966,7 @@
 				}
 				else {
 					if(driver->ob) {
-						if(ob==driver->ob) {
+						if(ob==driver->ob && G.sipo->bonename[0]==0) {
 							error("Cannot assign a Driver to own Object");
 							driver->ob= NULL;
 						}

Modified: trunk/blender/source/blender/src/drawnode.c
===================================================================
--- trunk/blender/source/blender/src/drawnode.c	2007-11-27 23:15:51 UTC (rev 12702)
+++ trunk/blender/source/blender/src/drawnode.c	2007-11-28 12:11:06 UTC (rev 12703)
@@ -269,7 +269,7 @@
 			sprintf(str1, "%d", node->id->us);
 			bt= uiDefBut(block, BUT, B_NOP, str1, 
 						 butr->xmax-19, butr->ymin, 19, 19, 
-						 NULL, 0, 0, 0, 0, "Displays number of users. Click to make a single-user copy.");

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list