[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18619] branches/blender2.5/blender/source /blender: Animato - Basic version patching support

Joshua Leung aligorith at gmail.com
Thu Jan 22 11:53:44 CET 2009


Revision: 18619
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18619
Author:   aligorith
Date:     2009-01-22 11:53:22 +0100 (Thu, 22 Jan 2009)

Log Message:
-----------
Animato - Basic version patching support

This is work-in-progress patching support for converting animation saved in old system to work in the new one. 

* Only IPOs/Actions directly attached to Objects + Shapekeys are converted for now. More types will follow...
* This is currently done as a step outside of do_versions() due to problems with various pointers not having been resolved yet, but which are necessary for correct resolution of issues such as drivers... However, the current code does illustrate how the data should be converted to give best results/compat between the two systems.
* Still need to get the converted data working with depsgraph correctly. Currently, some of my testfiles work, but the BBB files still don't.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_ipo.h
    branches/blender2.5/blender/source/blender/blenkernel/SConscript
    branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/blender.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/depsgraph.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/ipo.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/key.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/library.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/object.c
    branches/blender2.5/blender/source/blender/blenloader/SConscript
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_pose.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_ipo.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_ipo.h	2009-01-22 07:06:25 UTC (rev 18618)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_ipo.h	2009-01-22 10:53:22 UTC (rev 18619)
@@ -24,7 +24,7 @@
  *
  * The Original Code is: all of this file.
  *
- * Contributor(s): 2008, Joshua Leung (Animation Cleanup)
+ * Contributor(s): 2008,2009  Joshua Leung (Animation Cleanup, Animation Systme Recode)
  *
  * ***** END GPL LICENSE BLOCK *****
  */
@@ -35,128 +35,19 @@
 extern "C" {
 #endif
 
-	
-/* -------- IPO-Curve (Bezier) Calculations ---------- */
-
-// xxx perhaps this should be in curve api not in anim api
-void correct_bezpart(float *v1, float *v2, float *v3, float *v4);
-	
-
-// XXX this file will soon be depreceated...
-#if 0 // XXX old animation system
-
-typedef struct CfraElem {
-	struct CfraElem *next, *prev;
-	float cfra;
-	int sel;
-} CfraElem;
-
+struct Main;
 struct Ipo;
-struct IpoCurve;
-struct MTex;
-struct Material;
-struct Scene;
-struct Object;
-struct Sequence;
-struct ListBase;
-struct BezTriple;
-struct ID;
-struct bPoseChannel;
-struct bActionChannel;
-struct rctf;
 
-/* ------------ Time Management ------------ */
+void do_versions_ipo_to_animato(struct Main *main);
 
-float frame_to_float(struct Scene *scene, int cfra);
+/* --------------------- xxx stuff ------------------------ */
 
-/* ------------ IPO Management ---------- */
-
-void free_ipo_curve(struct IpoCurve *icu);
 void free_ipo(struct Ipo *ipo);
 
-void ipo_default_v2d_cur(struct Scene *scene, int blocktype, struct rctf *cur);
-
-struct Ipo *add_ipo(struct Scene *scene, char *name, int idcode);
-struct Ipo *copy_ipo(struct Ipo *ipo);
-
-void ipo_idnew(struct Ipo *ipo);
-
-struct IpoCurve *find_ipocurve(struct Ipo *ipo, int adrcode);
-short has_ipo_code(struct Ipo *ipo, int code);
-
-/* -------------- Make Local -------------- */
-
-void make_local_obipo(struct Ipo *ipo);
-void make_local_matipo(struct Ipo *ipo);
-void make_local_keyipo(struct Ipo *ipo);
-void make_local_ipo(struct Ipo *ipo);
-
-/* ------------ IPO-Curve Sanity ---------------- */
-
-void calchandles_ipocurve(struct IpoCurve *icu);
-void testhandles_ipocurve(struct IpoCurve *icu);
-void sort_time_ipocurve(struct IpoCurve *icu);
-int test_time_ipocurve(struct IpoCurve *icu);
-
-void set_interpolation_ipocurve(struct IpoCurve *icu, short ipo);
-
-/* -------- IPO-Curve (Bezier) Calculations ---------- */
-
+// xxx perhaps this should be in curve api not in anim api
 void correct_bezpart(float *v1, float *v2, float *v3, float *v4);
-int findzero(float x, float q0, float q1, float q2, float q3, float *o);
-void berekeny(float f1, float f2, float f3, float f4, float *o, int b);
-void berekenx(float *f, float *o, int b);
+	
 
-/* -------- IPO Curve Calculation and Evaluation --------- */
-
-float eval_icu(struct IpoCurve *icu, float ipotime);
-void calc_icu(struct IpoCurve *icu, float ctime);
-float calc_ipo_time(struct Ipo *ipo, float ctime);
-void calc_ipo(struct Ipo *ipo, float ctime);
-
-void calc_ipo_range(struct Ipo *ipo, float *start, float *end);
-
-/* ------------ Keyframe Column Tools -------------- */
-
-void add_to_cfra_elem(struct ListBase *lb, struct BezTriple *bezt);
-void make_cfra_list(struct Ipo *ipo, struct ListBase *elems);
-
-/* ---------------- IPO DataAPI ----------------- */
-
-void write_ipo_poin(void *poin, int type, float val);
-float read_ipo_poin(void *poin, int type);
-
-void *give_mtex_poin(struct MTex *mtex, int adrcode );
-void *get_pchan_ipo_poin(struct bPoseChannel *pchan, int adrcode);
-void *get_ipo_poin(struct ID *id, struct IpoCurve *icu, int *type);
-
-void set_icu_vars(struct IpoCurve *icu);
-
-/* ---------------- IPO Execution --------------- */
-
-void execute_ipo(struct ID *id, struct Ipo *ipo);
-void execute_action_ipo(struct bActionChannel *achan, struct bPoseChannel *pchan);
-
-void do_ipo_nocalc(struct Scene *scene, struct Ipo *ipo);
-void do_ipo(struct Scene *scene, struct Ipo *ipo);
-void do_mat_ipo(struct Scene *scene, struct Material *ma);
-void do_ob_ipo(struct Scene *scene, struct Object *ob);
-void do_seq_ipo(struct Scene *scene, struct Sequence *seq, int cfra);
-void do_ob_ipodrivers(struct Object *ob, struct Ipo *ipo, float ctime);
-
-void do_all_data_ipos(struct Scene *scene);
-short calc_ipo_spec(struct Ipo *ipo, int adrcode, float *ctime);
-void clear_delta_obipo(struct Ipo *ipo);
-
-/* ----------- IPO <-> GameEngine API ---------------- */
-
-/* the short is an IPO_Channel... */
-
-short IPO_GetChannels(struct Ipo *ipo, short *channels);
-float IPO_GetFloatValue(struct Ipo *ipo, short c, float ctime);
-
-#endif // XXX old animation system
-
 #ifdef __cplusplus
 };
 #endif

Modified: branches/blender2.5/blender/source/blender/blenkernel/SConscript
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/SConscript	2009-01-22 07:06:25 UTC (rev 18618)
+++ branches/blender2.5/blender/source/blender/blenkernel/SConscript	2009-01-22 10:53:22 UTC (rev 18619)
@@ -52,4 +52,4 @@
 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross'):
     incs += ' ' + env['BF_PTHREADS_INC']
 
-env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = Split(defs), libtype=['core'], priority = [155] )
+env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = Split(defs), libtype=['core'], priority = [165] )

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c	2009-01-22 07:06:25 UTC (rev 18618)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/anim_sys.c	2009-01-22 10:53:22 UTC (rev 18619)
@@ -86,7 +86,10 @@
 	if (id_has_animdata(id)) {
 		IdAdtTemplate *iat= (IdAdtTemplate *)id;
 		
-		iat->adt= MEM_callocN(sizeof(AnimData), "AnimData");
+		/* check if there's already AnimData, in which case, don't add */
+		if (iat->adt == NULL)
+			iat->adt= MEM_callocN(sizeof(AnimData), "AnimData");
+		
 		return iat->adt;
 	}
 	else 
@@ -232,7 +235,8 @@
 	free_path= animsys_remap_path(remap, fcu->rna_path, &path);
 	
 	/* write value to setting */
-	animsys_write_rna_setting(ptr, path, fcu->array_index, fcu->curval);
+	if (path)
+		animsys_write_rna_setting(ptr, path, fcu->array_index, fcu->curval);
 	
 	/* free temp path-info */
 	if (free_path)
@@ -586,7 +590,7 @@
 	 *	  or be layered on top of existing animation data.
 	 *	- Drivers should be in the appropriate order to be evaluated without problems...
 	 */
-	if ((recalc & ADT_RECALC_DRIVERS) && (adt->recalc & ADT_RECALC_DRIVERS))
+	if ((recalc & ADT_RECALC_DRIVERS) /*&& (adt->recalc & ADT_RECALC_DRIVERS)*/) // XXX for now, don't check yet, as depsgraph hasn't been updated
 	{
 		animsys_evaluate_drivers(&id_ptr, adt, ctime);
 	}
@@ -615,7 +619,7 @@
 {
 	ID *id;
 	
-	//printf("Evaluate all animation - %f \n", ctime);
+	printf("Evaluate all animation - %f \n", ctime);
 
 	/* macro for less typing */
 #define EVAL_ANIM_IDS(first) \
@@ -640,7 +644,7 @@
 	EVAL_ANIM_IDS(main->camera.first);
 	
 	/* shapekeys */
-	// TODO...
+	EVAL_ANIM_IDS(main->key.first);
 	
 	/* curves */
 	// TODO...

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/blender.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/blender.c	2009-01-22 07:06:25 UTC (rev 18618)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/blender.c	2009-01-22 10:53:22 UTC (rev 18619)
@@ -74,6 +74,7 @@
 #include "BKE_font.h"
 #include "BKE_global.h"
 #include "BKE_library.h"
+#include "BKE_ipo.h"
 #include "BKE_main.h"
 #include "BKE_node.h"
 #include "BKE_object.h"
@@ -371,12 +372,12 @@
 		//setscreen(G.curscreen);
 	}
 	
+	// XXX is this in the right place?
+	do_versions_ipos_to_animato(G.main); // XXX fixme... complicated versionpatching
+	
 	/* baseflags, groups, make depsgraph, etc */
 	set_scene_bg(CTX_data_scene(C));
 
-	/* clear BONE_UNKEYED flags, these are not valid anymore for proxies */
-	framechange_poses_clear_unkeyed();
-
 	/* last stage of do_versions actually, that sets recalc flags for recalc poses */
 	for(ob= G.main->object.first; ob; ob= ob->id.next) {
 		if(ob->type==OB_ARMATURE)

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/depsgraph.c	2009-01-22 07:06:25 UTC (rev 18618)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/depsgraph.c	2009-01-22 10:53:22 UTC (rev 18619)
@@ -303,50 +303,66 @@
 	return forest;
 }
 
-static void dag_add_driver_relation(Ipo *ipo, DagForest *dag, DagNode *node, int isdata)
+/* isdata = object data... */
+// XXX this needs to be extended to be more flexible (so that not only objects are evaluated via depsgraph)...
+static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node, int isdata)
 {
-	IpoCurve *icu;
+	FCurve *fcu;
 	DagNode *node1;
 	
-	for(icu= ipo->curve.first; icu; icu= icu->next) {
-		if(icu->driver) {
-
-			if (icu->driver->type == IPO_DRIVER_TYPE_PYTHON) {
-
-				if ((icu->driver->flag & IPO_DRIVER_FLAG_INVALID) || (icu->driver->name[0] == '\0'))
-					continue; /* empty or invalid expression */
+	for (fcu= adt->drivers.first; fcu; fcu= fcu->next) {
+		ChannelDriver *driver= fcu->driver;
+		
+		if (driver->type == DRIVER_TYPE_PYTHON) {
+			/* PyDriver / 'Expression' */
+			
+			/* skip if invalid in some way */
+			if ((driver->flag & DRIVER_FLAG_INVALID) || (driver->expression[0] == '\0'))
+				continue;
 #ifndef DISABLE_PYTHON
-				else {
-					/* now we need refs to all objects mentioned in this
-					 * pydriver expression, to call 'dag_add_relation'
-					 * for each of them */
-					Object **obarray = BPY_pydriver_get_objects(icu->driver);
-					if (obarray) {
-						Object *ob, **oba = obarray;
-
-						while (*oba) {
-							ob = *oba;
-							node1 = dag_get_node(dag, ob);
-							if (ob->type == OB_ARMATURE)
-								dag_add_relation(dag, node1, node, isdata?DAG_RL_DATA_DATA:DAG_RL_DATA_OB, "Python Ipo Driver");
-							else

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list