[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11615] trunk/blender/source/blender: == Action Editor Bugfixes (BugReport #7049) ==

Joshua Leung aligorith at gmail.com
Wed Aug 15 12:04:45 CEST 2007


Revision: 11615
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11615
Author:   aligorith
Date:     2007-08-15 12:04:45 +0200 (Wed, 15 Aug 2007)

Log Message:
-----------
== Action Editor Bugfixes (BugReport #7049) ==

This commit fixes several issues related to using the Action Editor with Shapekeys. I've known about most of them for a while, so now's the time to fix that.

1) When the shapekey anim data for an object comes from an Action (key's IPO block is linked to the "Shape" action-channel), the names of the individual shapekeys is now shown. They will only do so if the Action Editor is not pinned though.

2) Slider limits for the case described above should now be sane again

3) "Add New" option from the popup menu in the Action Editor header will now convert shapekey animation data from IPO to Action if the action editor is displaying Shapekey data at the time. Many users have often found the old way of having to toggle the "running man" in the IPO-editor header, too clumsy and confusing.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/ipo.c
    trunk/blender/source/blender/include/BSE_editipo.h
    trunk/blender/source/blender/src/drawaction.c
    trunk/blender/source/blender/src/editaction.c
    trunk/blender/source/blender/src/editipo_lib.c
    trunk/blender/source/blender/src/headerbuttons.c

Modified: trunk/blender/source/blender/blenkernel/intern/ipo.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/ipo.c	2007-08-15 09:41:14 UTC (rev 11614)
+++ trunk/blender/source/blender/blenkernel/intern/ipo.c	2007-08-15 10:04:45 UTC (rev 11615)
@@ -1523,7 +1523,7 @@
 
 void set_icu_vars(IpoCurve *icu)
 {
-	
+	/* defaults. 0.0 for y-extents makes these ignored */
 	icu->ymin= icu->ymax= 0.0;
 	icu->ipo= IPO_BEZ;
 	
@@ -1812,6 +1812,14 @@
 			break;
 		}
 	}
+	else if(icu->blocktype==ID_CO) {
+		icu->ymin= 0.0;
+		icu->ymax= 1.0f;
+	}
+	
+	/* by default, slider limits will be icu->ymin and icu->ymax */
+	icu->slide_min= icu->ymin;
+	icu->slide_max= icu->ymax;
 }
 
 /* not for actions or constraints! */

Modified: trunk/blender/source/blender/include/BSE_editipo.h
===================================================================
--- trunk/blender/source/blender/include/BSE_editipo.h	2007-08-15 09:41:14 UTC (rev 11614)
+++ trunk/blender/source/blender/include/BSE_editipo.h	2007-08-15 10:04:45 UTC (rev 11615)
@@ -60,7 +60,7 @@
 char *getname_snd_ei(int nr);
 char *getname_fluidsim_ei(int nr);
 
-char *getname_ipocurve(struct IpoCurve *icu);
+char *getname_ipocurve(struct IpoCurve *icu, struct Object *ob);
 int geticon_ipo_blocktype(short blocktype);
 
 struct EditIpo *get_active_editipo(void);

Modified: trunk/blender/source/blender/src/drawaction.c
===================================================================
--- trunk/blender/source/blender/src/drawaction.c	2007-08-15 09:41:14 UTC (rev 11614)
+++ trunk/blender/source/blender/src/drawaction.c	2007-08-15 10:04:45 UTC (rev 11615)
@@ -228,8 +228,8 @@
 	
 	if (IS_EQ(icu->slide_max, icu->slide_min)) {
 		if (IS_EQ(icu->ymax, icu->ymin)) {
-			if (icu->blocktype == ID_CO) {
-				/* hack for constraints (and maybe a few others) */
+			if (ELEM(icu->blocktype, ID_CO, ID_KE)) {
+				/* hack for constraints and shapekeys (and maybe a few others) */
 				icu->slide_min= 0.0;
 				icu->slide_max= 1.0;
 			}
@@ -491,7 +491,10 @@
 					mute = ICON_MUTE_IPO_OFF;
 				
 				sel = SEL_ICU(icu);
-				sprintf(name, getname_ipocurve(icu));
+				if (G.saction->pin)
+					sprintf(name, getname_ipocurve(icu, NULL));
+				else
+					sprintf(name, getname_ipocurve(icu, OBACT));
 			}
 				break;
 			case ACTTYPE_SHAPEKEY: /* shapekey channel */
@@ -827,18 +830,20 @@
 	short ofsx = 0, ofsy = 0;
 	float col[3];
 
-	if (!G.saction)
+	/* this is unlikely to occur, but it may */
+	if (G.saction == NULL)
 		return;
 
 	/* warning: blocks need to be freed each time, handlers dont remove  */
 	uiFreeBlocksWin(&sa->uiblocks, sa->win);
 
-	if (!G.saction->pin) {
+	/* only try to refresh action that's displayed if not pinned */
+	if (G.saction->pin==0) {
 		/* TODO: allow more than one active action sometime? */
 		if (OBACT)
 			G.saction->action = OBACT->action;
 		else
-			G.saction->action=NULL;
+			G.saction->action= NULL;
 	}
 	
 	/* get data */

Modified: trunk/blender/source/blender/src/editaction.c
===================================================================
--- trunk/blender/source/blender/src/editaction.c	2007-08-15 09:41:14 UTC (rev 11614)
+++ trunk/blender/source/blender/src/editaction.c	2007-08-15 10:04:45 UTC (rev 11615)
@@ -480,6 +480,7 @@
  * returns key data for RVK type meshes). If there
  * is an action that is pinned, return null
  */
+/* Note: there's a similar function in key.c (ob_get_key) */
 Key *get_action_mesh_key(void) 
 {
     Object *ob;
@@ -1720,7 +1721,10 @@
 	else if (chantype == ACTTYPE_ICU) {
 		icu= (IpoCurve *)act_channel;
 		
-		strcpy(str, getname_ipocurve(icu));
+		if (G.saction->pin)
+			sprintf(str, getname_ipocurve(icu, NULL));
+		else
+			sprintf(str, getname_ipocurve(icu, OBACT));
 		
 		if (IS_EQ(icu->slide_max, icu->slide_min)) {
 			if (IS_EQ(icu->ymax, icu->ymin)) {

Modified: trunk/blender/source/blender/src/editipo_lib.c
===================================================================
--- trunk/blender/source/blender/src/editipo_lib.c	2007-08-15 09:41:14 UTC (rev 11614)
+++ trunk/blender/source/blender/src/editipo_lib.c	2007-08-15 10:04:45 UTC (rev 11615)
@@ -34,12 +34,15 @@
 
 #include "DNA_curve_types.h"
 #include "DNA_ipo_types.h"
+#include "DNA_key_types.h"
+#include "DNA_object_types.h"
 #include "DNA_space_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_view3d_types.h"
 
 #include "BKE_global.h"
 #include "BKE_ipo.h"
+#include "BKE_key.h"
 #include "BKE_utildefines.h"
 
 #include "BIF_resources.h"
@@ -130,8 +133,11 @@
 	}
 }
 
-/* get name of ipo-curve (icu should be valid pointer) */
-char *getname_ipocurve(IpoCurve *icu)
+/* get name of ipo-curve
+ * 	- icu should be valid pointer
+ *	- ob is only needed for a shapekey-related hack
+ */
+char *getname_ipocurve(IpoCurve *icu, Object *ob)
 {
 	switch (icu->blocktype) {
 		case ID_OB: 
@@ -140,11 +146,29 @@
 			return getname_ac_ei(icu->adrcode);
 		case ID_KE:
 			{
-				/* quick 'hack' - must find a better solution to this
-				 * although shapekey ipo-curves can have names,
-				 * we don't have access to that info yet.
-				 */
 				static char name[32];
+				Key *key= ob_get_key(ob);
+				
+				if (key) {
+					KeyBlock *kb= key->block.first;
+					int i;
+					
+					for (i= 1; i < key->totkey; i++) {
+						kb= kb->next;
+						
+						if (icu->adrcode == i) {
+							/* only return name if it has been set, otherwise use 
+							 * default method using static string (Key #)
+							 */
+							if (kb->name[0] == '\0')
+								break; /* stop looping through keyblocks */
+							else
+								return kb->name; /* return keyblock's name  */
+						}
+					}
+				}
+				
+				/* in case keyblock is not named or no key/keyblock was found */
 				sprintf(name, "Key %d", icu->adrcode);
 				return name;
 			}

Modified: trunk/blender/source/blender/src/headerbuttons.c
===================================================================
--- trunk/blender/source/blender/src/headerbuttons.c	2007-08-15 09:41:14 UTC (rev 11614)
+++ trunk/blender/source/blender/src/headerbuttons.c	2007-08-15 10:04:45 UTC (rev 11615)
@@ -949,13 +949,43 @@
 		else {
 
 			/* Store current action */
-			if (!idtest){
+			if (!idtest) {
+				/* 'Add New' option: 
+				 * 	- make a copy of an exisiting action
+				 *	- or make a new empty action if no existing action
+				 */
 				if (act) {
 					idtest= (ID *)copy_action(act);
-				} else { 
+				} 
+				else { 
 					if (ID_OB==ob->type) {
+						/* for empties */
 						idtest=(ID *)add_empty_action("ObAction");
-					} else {
+					} 
+					else if (ELEM(ob->type, OB_MESH, OB_LATTICE) && ob_get_key(ob)) {
+						/* shapekey - like if B_IPO_ACTION_KEY is triggered */
+						bActionChannel *achan;
+						Key *key= ob_get_key(ob);
+						
+						ob->ipoflag |= OB_ACTION_KEY;
+						
+						act = add_empty_action("ShapeAction");
+						idtest=(ID *)act;
+						
+						achan= verify_action_channel(act, "Shape");
+						achan->flag = (ACHAN_HILIGHTED|ACHAN_SELECTED|ACHAN_EXPANDED|ACHAN_SHOWIPO);
+						
+						if(achan->ipo==NULL && key->ipo) {
+							achan->ipo= key->ipo;
+							key->ipo= NULL;
+							
+							allqueue(REDRAWVIEW3D, 0);
+							allqueue(REDRAWIPO, 0);
+							allqueue(REDRAWOOPS, 0);
+						}
+					}
+					else {
+						/* a plain action */
 						idtest=(ID *)add_empty_action("Action");
 					}
 				}





More information about the Bf-blender-cvs mailing list