[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12852] branches/animsys-aligorith/source/ blender: == AnimSys Branch ==

Joshua Leung aligorith at gmail.com
Wed Dec 12 12:02:36 CET 2007


Revision: 12852
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12852
Author:   aligorith
Date:     2007-12-12 12:02:36 +0100 (Wed, 12 Dec 2007)

Log Message:
-----------
== AnimSys Branch ==

- Some compiling/syntax-error fixes
- Start of IPO-Generators (i.e. procedural ipo's). These will be used for NLA control curves, so are important.

Modified Paths:
--------------
    branches/animsys-aligorith/source/blender/blenkernel/intern/ipo.c
    branches/animsys-aligorith/source/blender/blenkernel/intern/keyabletypes.c
    branches/animsys-aligorith/source/blender/blenkernel/intern/nla.c
    branches/animsys-aligorith/source/blender/makesdna/DNA_constraint_types.h
    branches/animsys-aligorith/source/blender/makesdna/DNA_ipo_types.h
    branches/animsys-aligorith/source/blender/makesdna/DNA_nla_types.h
    branches/animsys-aligorith/source/blender/makesdna/intern/_sdna2kt_extras.py
    branches/animsys-aligorith/source/blender/python/BPY_extern.h
    branches/animsys-aligorith/source/blender/src/keyframing.c

Modified: branches/animsys-aligorith/source/blender/blenkernel/intern/ipo.c
===================================================================
--- branches/animsys-aligorith/source/blender/blenkernel/intern/ipo.c	2007-12-12 11:00:39 UTC (rev 12851)
+++ branches/animsys-aligorith/source/blender/blenkernel/intern/ipo.c	2007-12-12 11:02:36 UTC (rev 12852)
@@ -1301,18 +1301,52 @@
  */
 float eval_icu (IpoCurve *icu, float ipotime) 
 {
-	BezTriple *bezt, *prevbezt;
-	float v1[2], v2[2], v3[2], v4[2], opl[32], dx, fac;
-	float cycdx, cycdy, ofs, cycyofs, cvalue = 0.0;
-	int a, b;
+	float cvalue = 0.0f;
 	
-	cycyofs= 0.0;
-	
+	/* evaluate the driver first, so that the driver's value can serve as input for the curve */
 	if (icu->driver) {
 		/* ipotime now serves as input for the curve */
 		ipotime= cvalue= eval_driver(icu->driver, ipotime);
 	}
-	if (icu->bezt) {
+	
+	/* evaluate the curve now - Ipo-Generator's take priority over keyframes for now */
+	if (icu->generator) {
+		/* evaluate value using generator */
+		IpoGenerator *icg= icu->generator;
+		
+		/* invalid generator? */
+		if ((icg->eval_func == NULL) && (icg->expr[0] == 0)) {
+			/* hack warning:
+			 * 	1. Disable generator and driver to prevent double-calc/recursive exec.
+			 *	2. Run eval_icu on the ipo-curve again so that normal keyframe eval occurs.
+			 *	3. Restore generator and driver
+			 */
+			IpoDriver *driver= icu->driver;
+			
+			icu->driver= NULL;
+			icu->generator= NULL;
+			
+			cvalue= eval_icu(icu, ipotime);
+			 
+			icu->driver= driver;
+			icu->generator= icg;
+		}
+		else if (icg->eval_func) {
+			/* simply run the evaluation function - assume it is valid */
+			cvalue= icg->eval_func(icg, ipotime);
+		}
+		else {
+			/* evaluate py-exression */
+			cvalue= BPY_ipogen(icg, ipotime);
+		}		
+	}
+	else if (icu->bezt) {
+		/* evaluate using keyframes of curve */
+		BezTriple *bezt, *prevbezt;
+		float v1[2], v2[2], v3[2], v4[2], opl[32], dx, fac;
+		float cycdx, cycdy, ofs, cycyofs=0.0f;
+		int a, b;
+		
 		prevbezt= icu->bezt;
 		bezt= prevbezt+1;
 		a= icu->totvert-1;
@@ -1414,7 +1448,7 @@
 	}
 
 	/* clamp values to ymin->ymax range if they do define a range */
-	if(icu->ymin < icu->ymax) {
+	if (icu->ymin < icu->ymax) {
 		CLAMP(cvalue, icu->ymin, icu->ymax);
 	}
 	

Modified: branches/animsys-aligorith/source/blender/blenkernel/intern/keyabletypes.c
===================================================================
--- branches/animsys-aligorith/source/blender/blenkernel/intern/keyabletypes.c	2007-12-12 11:00:39 UTC (rev 12851)
+++ branches/animsys-aligorith/source/blender/blenkernel/intern/keyabletypes.c	2007-12-12 11:02:36 UTC (rev 12852)
@@ -302,6 +302,7 @@
 {NULL,NULL, "Copy LocY-Inv", "CopyLocYInv", 0.0, LOCLIKE_Y_INVERT, offsetof(bLocateLikeConstraint, flag), IPO_INT_BIT, "", "", kt_read_constraint, kt_write_constraint},
 {NULL,NULL, "Copy LocZ-Inv", "CopyLocZInv", 0.0, LOCLIKE_Z_INVERT, offsetof(bLocateLikeConstraint, flag), IPO_INT_BIT, "", "", kt_read_constraint, kt_write_constraint},
 {NULL,NULL, "Copy Loc-Offset", "CopyLocOffs", 0.0, LOCLIKE_OFFSET, offsetof(bLocateLikeConstraint, flag), IPO_INT_BIT, "", "", kt_read_constraint, kt_write_constraint},
+{NULL,NULL, "ClampTo Axis", "ClampAxis", CLAMPTO_AUTO, CLAMPTO_Z, offsetof(bClampToConstraint, flag), IPO_INT_BIT, "", "", kt_read_constraint, kt_write_constraint},
 {NULL,NULL, "ClampCyclic", "ClampCyclic", 0.0, CLAMPTO_CYCLIC, offsetof(bClampToConstraint, flag2), IPO_INT_BIT, "", "", kt_read_constraint, kt_write_constraint},
 {NULL,NULL, "Parent LocX", "ParLocX", 0.0, CHILDOF_LOCX, offsetof(bChildOfConstraint, flag), IPO_INT_BIT, "", "", kt_read_constraint, kt_write_constraint},
 {NULL,NULL, "Parent LocY", "ParLocY", 0.0, CHILDOF_LOCY, offsetof(bChildOfConstraint, flag), IPO_INT_BIT, "", "", kt_read_constraint, kt_write_constraint},
@@ -392,7 +393,7 @@
 	bKeyableType *kt;
 	
 	/* try to find keyable types in default data sets */
-	if (IN_RANGE(blocktype, 0, (IPOB_TOTAL+1)))
+	if (VALID_IPOBLOCKTYPE(blocktype))
 		typeslist= all_keytypes[blocktype];
 	
 	/* is there a valid typeslist to start with? */
@@ -409,6 +410,20 @@
 	return NULL;
 }
 
+/* This function returns all the built-in keyable types available
+ * for a blocktype (un-filtered)
+ */
+ListBase *find_kts_blocktype (short blocktype)
+{
+	ListBase *typeslist= NULL;
+	
+	/* try to find keyable types in default data sets */
+	if (VALID_IPOBLOCKTYPE(blocktype))
+		typeslist= all_keytypes[blocktype];
+		
+	return typeslist;
+}
+
 /* ------------------- */
 
 /* Register all the keytypes for a blocktype */

Modified: branches/animsys-aligorith/source/blender/blenkernel/intern/nla.c
===================================================================
--- branches/animsys-aligorith/source/blender/blenkernel/intern/nla.c	2007-12-12 11:00:39 UTC (rev 12851)
+++ branches/animsys-aligorith/source/blender/blenkernel/intern/nla.c	2007-12-12 11:02:36 UTC (rev 12852)
@@ -212,7 +212,7 @@
 		return;
 	
 	
-	/* calculate/set the influence of this strip - don't consider if 0 influence */
+	/* calculate/set the influence+act_time of this strip - don't consider if 0 influence */
 	calc_ipo(astrip->ipo, ctime);
 	apply_anim_ipo(astrip->ipo, astrip);
 	

Modified: branches/animsys-aligorith/source/blender/makesdna/DNA_constraint_types.h
===================================================================
--- branches/animsys-aligorith/source/blender/makesdna/DNA_constraint_types.h	2007-12-12 11:00:39 UTC (rev 12851)
+++ branches/animsys-aligorith/source/blender/makesdna/DNA_constraint_types.h	2007-12-12 11:02:36 UTC (rev 12852)
@@ -263,7 +263,7 @@
 /*	<<< bt("IPOB_CONS", getter="kt_read_constraint", setter="kt_write_constraint") >>> */
 typedef struct bClampToConstraint {
 	Object 		*tar;			/* 'target' must be a curve */
-	int			flag;			/* which axis/plane to compare owner's location on  <<< kv(lname="ClampTo Axis", sname="ClampAxis", minv=CLAMPTO_AUTO, maxv=CLAMPTO_Z) >>> */
+	int			flag;			/* which axis/plane to compare owner's location on  <<< kv(lname="ClampTo Axis", sname="ClampAxis", minv="CLAMPTO_AUTO", maxv="CLAMPTO_Z") >>> */
 	int			flag2;			/* for legacy reasons, this is flag2. used for any extra settings   <<< ev("eClampToConstraint_Flag") >>> */
 } bClampToConstraint;
 

Modified: branches/animsys-aligorith/source/blender/makesdna/DNA_ipo_types.h
===================================================================
--- branches/animsys-aligorith/source/blender/makesdna/DNA_ipo_types.h	2007-12-12 11:00:39 UTC (rev 12851)
+++ branches/animsys-aligorith/source/blender/makesdna/DNA_ipo_types.h	2007-12-12 11:02:36 UTC (rev 12852)
@@ -115,6 +115,34 @@
 
 /* *************************** IPO System Data ************************* */
 
+/* ---------------------- IPO Generator -------------------- */
+
+/* variable for IPO-Curve Generator */
+typedef struct IcuGenVar {
+	struct bIcuGenVar *next, *prev;
+	
+	float val;
+	char name[32];
+	
+	int pad;
+} bIcuGenVar;
+
+/* IPO-Curve Generator:
+ *	- Generates a 'procedural' IPO-Curve when evaluated, instead of evaluating
+ *	  the curve between keyframes
+ *	- Keyframes override generated curves. However, a curve firstly has to be
+ *	  made editable (CHECKME: maybe this changes...)
+ */
+typedef struct IpoGenerator {
+	ListBase 	vars;		/* list of bIcuGenVars */
+	char 		expr[128]; 	/* custom expression to use as generator */
+	
+	/* special callback function - for finding value at a given frame */
+	float (*eval_func)(struct IpoGenerator *icg, float ctime);
+} bIpoGenerator;
+
+/* ---------------------- IPO Driver -------------------- */
+ 
 /* IPO-Curve Driver:
  *	- Defines an IPO-Driver relationship 
  *	- Drivers currently can either refer to a transform channel of a target
@@ -129,6 +157,9 @@
 	char name[128];				/* bone or python expression here */
 } IpoDriver;
 
+
+/* ---------------------- IPO Curve -------------------- */
+
 /* IPO-Curve:
  *   - An IPO curve contains keyframes, which define the value (y) of the channel
  *	  that it's attached to over time (x) in frames.
@@ -161,6 +192,7 @@
 	float curval;						/* value of ipo-curve for current frame/point-in-time */
 	
 	IpoDriver *driver;					/* pointer to ipo-driver for this curve */
+	IpoGenerator *generator;			/* pointer to ipo-generator for this curve */
 } IpoCurve;
 
 

Modified: branches/animsys-aligorith/source/blender/makesdna/DNA_nla_types.h
===================================================================
--- branches/animsys-aligorith/source/blender/makesdna/DNA_nla_types.h	2007-12-12 11:00:39 UTC (rev 12851)
+++ branches/animsys-aligorith/source/blender/makesdna/DNA_nla_types.h	2007-12-12 11:02:36 UTC (rev 12852)
@@ -55,7 +55,7 @@
 } bActionModifier;
 
 /* NLA-Modifier Types */
-typedef eNLA_Modifier_Types {
+typedef enum eNLA_Modifier_Types {
 	ACTSTRIP_MOD_DEFORM	= 0,
 	ACTSTRIP_MOD_NOISE,
 	ACTSTRIP_MOD_OOMPH
@@ -72,14 +72,15 @@
 
 	struct	Ipo *ipo;			/* Blending ipo - has influence and actoffs */
 	struct	bAction *act;		/* The action referenced by this strip */
-	struct  Object *object;		/* For groups, the actual object being nla'ed */
+	struct  Object *object;		/* For groups, the actual object being nla'ed (where's this set?) */
 	
 	float	start, end;			/* The range of frames covered by this strip */
 	float	actstart, actend;	/* The range of frames taken from the action */
 	
 	float 	influence;			/* The amount of influence the strip has */
+	float	act_time;			/* Current time in action used for strip */	
 	
-	float	actoffs;			/* Offset within action, for cycles and striding */
+	float	actoffs;			/* Offset within action, for cycles and striding (only set for ACT_USESTRIDE) */
 	float	stridelen;			/* The stridelength (considered when flag & ACT_USESTRIDE) */
 	
 	float	repeat;				/* The number of times to repeat the action range */
@@ -95,8 +96,8 @@
 
 /* strip->mode (these defines aren't really used, but are here for reference) */
 typedef enum eActStrip_Mode {
-	ACTSTRIPMODE_BLEND = 0
-	ACTSTRIPMODE_ADD,
+	ACTSTRIPMODE_BLEND = 0,
+	ACTSTRIPMODE_ADD
 } eActStrip_Mode;
 
 /* strip->flag */

Modified: branches/animsys-aligorith/source/blender/makesdna/intern/_sdna2kt_extras.py
===================================================================
--- branches/animsys-aligorith/source/blender/makesdna/intern/_sdna2kt_extras.py	2007-12-12 11:00:39 UTC (rev 12851)
+++ branches/animsys-aligorith/source/blender/makesdna/intern/_sdna2kt_extras.py	2007-12-12 11:02:36 UTC (rev 12852)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list