[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27916] trunk/blender: Assorted animsys fixes/tweaks:

Joshua Leung aligorith at gmail.com
Thu Apr 1 08:26:41 CEST 2010


Revision: 27916
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27916
Author:   aligorith
Date:     2010-04-01 08:26:41 +0200 (Thu, 01 Apr 2010)

Log Message:
-----------
Assorted animsys fixes/tweaks:

* Fixed all the dangerous code added in 27907. Using the code there, scripters could corrupt animation files in ways which would render them useless, with channels not appearing in any animation editors, and others not getting evaluated at all. 

* Partial fix of bug 21818, by disabling destructive replacement of keyframes. Will followup this commit with a more comprehensive commit which gets rid of the rest of the problems, by incorporating some requests from Durian team.

* Fixed problems with users being able to see+edit the name of the active Keying Set in the Scene buttons. There is still a bug though with the list widget given how the indices are now interpreted...

Modified Paths:
--------------
    trunk/blender/release/scripts/keyingsets/keyingsets_utils.py
    trunk/blender/release/scripts/ui/properties_scene.py
    trunk/blender/source/blender/blenkernel/BKE_action.h
    trunk/blender/source/blender/blenkernel/BKE_nla.h
    trunk/blender/source/blender/blenkernel/intern/action.c
    trunk/blender/source/blender/blenkernel/intern/nla.c
    trunk/blender/source/blender/editors/animation/keyframing.c
    trunk/blender/source/blender/editors/space_nla/nla_edit.c
    trunk/blender/source/blender/makesrna/intern/rna_action.c
    trunk/blender/source/blender/makesrna/intern/rna_fcurve.c

Modified: trunk/blender/release/scripts/keyingsets/keyingsets_utils.py
===================================================================
--- trunk/blender/release/scripts/keyingsets/keyingsets_utils.py	2010-04-01 03:58:20 UTC (rev 27915)
+++ trunk/blender/release/scripts/keyingsets/keyingsets_utils.py	2010-04-01 06:26:41 UTC (rev 27916)
@@ -81,7 +81,7 @@
         path = ""
         
         # data on ID-blocks directly should get grouped by the KeyingSet
-        grouping = None;
+        grouping = None
     else:
         # get the path to the ID-block
         path = data.path_to_id()

Modified: trunk/blender/release/scripts/ui/properties_scene.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_scene.py	2010-04-01 03:58:20 UTC (rev 27915)
+++ trunk/blender/release/scripts/ui/properties_scene.py	2010-04-01 06:26:41 UTC (rev 27916)
@@ -89,6 +89,7 @@
         row = layout.row()
 
         col = row.column()
+		# XXX: this fails because index is not what this expects...
         col.template_list(scene, "keying_sets", scene, "active_keying_set_index", rows=2)
 
         col = row.column(align=True)
@@ -96,7 +97,7 @@
         col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="")
 
         ks = scene.active_keying_set
-        if ks:
+        if ks and ks.absolute:
             row = layout.row()
 
             col = row.column()
@@ -310,8 +311,10 @@
             f.write("%s, '%s'" % (id_bpy_path, ksp.data_path))
 
             # array index settings (if applicable)
-            if ksp.entire_array is False:
-                f.write(", entire_array=False, array_index=%d" % ksp.array_index)
+            if ksp.entire_array:
+                f.write(", index=-1")
+            else:
+                f.write(", index=%d" % ksp.array_index)
 
             # grouping settings (if applicable)
             # NOTE: the current default is KEYINGSET, but if this changes, change this code too

Modified: trunk/blender/source/blender/blenkernel/BKE_action.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_action.h	2010-04-01 03:58:20 UTC (rev 27915)
+++ trunk/blender/source/blender/blenkernel/BKE_action.h	2010-04-01 06:26:41 UTC (rev 27916)
@@ -105,6 +105,9 @@
 /* Make the given Action Group the active one */
 void set_active_action_group(struct bAction *act, struct bActionGroup *agrp, short select);
 
+/* Add a new action group with the given name to the action */
+struct bActionGroup *action_groups_add_new(struct bAction *act, const char name[]);
+
 /* Add given channel into (active) group  */
 void action_groups_add_channel(struct bAction *act, struct bActionGroup *agrp, struct FCurve *fcurve);
 

Modified: trunk/blender/source/blender/blenkernel/BKE_nla.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_nla.h	2010-04-01 03:58:20 UTC (rev 27915)
+++ trunk/blender/source/blender/blenkernel/BKE_nla.h	2010-04-01 06:26:41 UTC (rev 27916)
@@ -77,6 +77,8 @@
 
 short BKE_nlatrack_add_strip(struct NlaTrack *nlt, struct NlaStrip *strip);
 
+short BKE_nlatrack_get_bounds(struct NlaTrack *nlt, float bounds[2]);
+
 /* ............ */
 
 struct NlaStrip *BKE_nlastrip_find_active(struct NlaTrack *nlt);

Modified: trunk/blender/source/blender/blenkernel/intern/action.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/action.c	2010-04-01 03:58:20 UTC (rev 27915)
+++ trunk/blender/source/blender/blenkernel/intern/action.c	2010-04-01 06:26:41 UTC (rev 27916)
@@ -238,6 +238,30 @@
 	}
 }
 
+/* Add a new action group with the given name to the action */
+bActionGroup *action_groups_add_new (bAction *act, const char name[])
+{
+	bActionGroup *agrp;
+	
+	/* sanity check: must have action and name */
+	if (ELEM(NULL, act, name) || (name[0] == 0))
+		return NULL;
+	
+	/* allocate a new one */
+	agrp = MEM_callocN(sizeof(bActionGroup), "bActionGroup");
+	
+	/* make it selected, with default name */
+	agrp->flag = AGRP_SELECTED;
+	strncpy(agrp->name, name, sizeof(agrp->name));
+	
+	/* add to action, and validate */
+	BLI_addtail(&act->groups, agrp);
+	BLI_uniquename(&act->groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name));	
+	
+	/* return the new group */
+	return agrp;
+}
+
 /* Add given channel into (active) group 
  *	- assumes that channel is not linked to anything anymore
  *	- always adds at the end of the group 

Modified: trunk/blender/source/blender/blenkernel/intern/nla.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/nla.c	2010-04-01 03:58:20 UTC (rev 27915)
+++ trunk/blender/source/blender/blenkernel/intern/nla.c	2010-04-01 06:26:41 UTC (rev 27916)
@@ -39,10 +39,12 @@
 #include "BLI_ghash.h"
 
 #include "DNA_anim_types.h"
+#include "DNA_scene_types.h"
 
 #include "BKE_action.h"
 #include "BKE_fcurve.h"
 #include "BKE_nla.h"
+#include "BKE_global.h"
 #include "BKE_library.h"
 #include "BKE_utildefines.h"
 
@@ -956,6 +958,35 @@
 	return BKE_nlastrips_add_strip(&nlt->strips, strip);
 }
 
+/* Get the extents of the given NLA-Track including gaps between strips,
+ * returning whether this succeeded or not
+ */
+short BKE_nlatrack_get_bounds (NlaTrack *nlt, float bounds[2])
+{
+	NlaStrip *strip;
+	
+	/* initialise bounds */
+	if (bounds)
+		bounds[0] = bounds[1] = 0.0f;
+	else
+		return 0;
+	
+	/* sanity checks */
+	if ELEM(NULL, nlt, nlt->strips.first)
+		return 0;
+		
+	/* lower bound is first strip's start frame */
+	strip = nlt->strips.first;
+	bounds[0] = strip->start;
+	
+	/* upper bound is last strip's end frame */
+	strip = nlt->strips.last;
+	bounds[1] = strip->end;
+	
+	/* done */
+	return 1;
+}
+
 /* NLA Strips -------------------------------------- */
 
 /* Find the active NLA-strip within the given track */
@@ -1474,7 +1505,10 @@
 		}	
 	}
 	if ELEM3(NULL, activeTrack, activeStrip, activeStrip->act) {
-		printf("NLA tweakmode enter - neither active requirement found \n");
+		if (G.f & G_DEBUG) {
+			printf("NLA tweakmode enter - neither active requirement found \n");
+			printf("\tactiveTrack = %p, activeStrip = %p \n", activeTrack, activeStrip);
+		}
 		return 0;
 	}
 		
@@ -1553,4 +1587,29 @@
 	adt->flag &= ~ADT_NLA_EDIT_ON;
 }
 
+/* Baking Tools ------------------------------------------- */
+
+void BKE_nla_bake (Scene *scene, ID *id, AnimData *adt, int flag)
+{
+
+	/* verify that data is valid 
+	 *	1) Scene and AnimData must be provided 
+	 *	2) there must be tracks to merge...
+	 */
+	if ELEM3(NULL, scene, adt, adt->nla_tracks.first)
+		return;
+	
+	/* if animdata currently has an action, 'push down' this onto the stack first */
+	if (adt->action)
+		BKE_nla_action_pushdown(adt);
+	
+	/* get range of motion to bake, and the channels involved... */
+	
+	/* temporarily mute the action, and start keying to it */
+	
+	/* start keying... */
+	
+	/* unmute the action */
+}
+
 /* *************************************************** */

Modified: trunk/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframing.c	2010-04-01 03:58:20 UTC (rev 27915)
+++ trunk/blender/source/blender/editors/animation/keyframing.c	2010-04-01 06:26:41 UTC (rev 27916)
@@ -176,16 +176,8 @@
 			grp= action_groups_find_named(act, group);
 			
 			/* no matching groups, so add one */
-			if (grp == NULL) {
-				/* Add a new group, and make it active */
-				grp= MEM_callocN(sizeof(bActionGroup), "bActionGroup");
-				
-				grp->flag = AGRP_SELECTED;
-				strncpy(grp->name, group, sizeof(grp->name));
-
-				BLI_addtail(&act->groups, grp);
-				BLI_uniquename(&act->groups, grp, "Group", '.', offsetof(bActionGroup, name), sizeof(grp->name));
-			}
+			if (grp == NULL)
+				grp= action_groups_add_new(act, group);
 			
 			/* add F-Curve to group */
 			action_groups_add_channel(act, grp, fcu);
@@ -226,7 +218,8 @@
 			/* sanity check: 'i' may in rare cases exceed arraylen */
 			if ((i >= 0) && (i < fcu->totvert)) {
 				/* take care with the handletypes and other info if the replacement flags are set */
-				if (flag & INSERTKEY_REPLACE) {
+				// NOTE: for now, always do non-destructive replace... if everybody likes this, just keep it as default
+				if (1/*flag & INSERTKEY_REPLACE*/) {
 					BezTriple *dst= (fcu->bezt + i);
 					float dy= bezt->vec[1][1] - dst->vec[1][1];
 					

Modified: trunk/blender/source/blender/editors/space_nla/nla_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_nla/nla_edit.c	2010-04-01 03:58:20 UTC (rev 27915)
+++ trunk/blender/source/blender/editors/space_nla/nla_edit.c	2010-04-01 06:26:41 UTC (rev 27916)
@@ -903,6 +903,7 @@
 	ListBase anim_data = {NULL, NULL};
 	bAnimListElem *ale;
 	int filter;
+	int flag = 0;
 	
 	/* get editor data */
 	if (ANIM_animdata_get_context(C, &ac) == 0)
@@ -914,16 +915,7 @@
 	
 	/* for each AnimData block, bake strips to animdata... */
 	for (ale= anim_data.first; ale; ale= ale->next) {
-		AnimData *adt = (AnimData *)ale->data;
-		
-		/* if animdata currently has an action, 'push down' this onto the stack first */
-		BKE_nla_action_pushdown(adt);
-		
-		/* temporarily mute the action, and start keying to it */
-		
-		/* start keying... */
-		
-		/* unmute the action */
+		//BKE_nla_bake(ac.scene, ale->id, ale->data, flag);
 	}
 	
 	/* free temp data */

Modified: trunk/blender/source/blender/makesrna/intern/rna_action.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_action.c	2010-04-01 03:58:20 UTC (rev 27915)
+++ trunk/blender/source/blender/makesrna/intern/rna_action.c	2010-04-01 06:26:41 UTC (rev 27916)
@@ -34,6 +34,8 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "BKE_action.h"
+
 #include "WM_types.h"
 
 
@@ -54,32 +56,34 @@
 	iter->valid= (internal->link != NULL);
 }
 
-static bActionGroup *rna_Action_groups_add(bAction *act, char *name)
+static bActionGroup *rna_Action_groups_add(bAction *act, char name[])
 {
-	bActionGroup *agrp= MEM_callocN(sizeof(bActionGroup), "bActionGroup");
-	strncpy(agrp->name, name, sizeof(agrp->name));
-	BLI_addtail(&act->groups, agrp);
-	BLI_uniquename(&act->groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name));
-	return agrp;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list