[Bf-committers] Patch to add read only support for named Action ipo curves

bf-committers@blender.org bf-committers@blender.org
Tue, 02 Mar 2004 00:44:19 -0600


This is a multi-part message in MIME format.
--------------040805000804010609010901
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

The attached patch adds support for QuatX, QuatY, QuatZ
and QuatW ipo curves.  It adds this support to
IpoCurve.getName() as well as Ipo.getCurveCurval().
It does this in a read only fashion, i.e. it only adds
support for ID_AC curves for interogation as I wasn't
sure of the implications of supporting it more completely.
A little of the garbage being spewed by string representations
of Ipo objects is eliminated also, although that is a side
effect and wasn't a goal.

I see patches posted to this email list and I've seen comments
in some other places about using the Bug Tracker for patches
and other work scheduling events.  Which is more appropriate
for something like this ?  If the Bug Tracker, or some place
else, is a better place, say the word and I'll drop this there.

--
Todd Koeckeritz, zaz@visi.com

Surfin' the Web with an ActiveX enabled browser is kindof like having
to worry about getting shot everytime you knock on a door.

--------------040805000804010609010901
Content-Type: text/x-patch;
 name="ipo-curvename.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ipo-curvename.patch"

Index: source/blender/python/api2_2x/Ipo.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Ipo.c,v
retrieving revision 1.19
diff -u -r1.19 Ipo.c
--- source/blender/python/api2_2x/Ipo.c	21 Jan 2004 04:42:13 -0000	1.19
+++ source/blender/python/api2_2x/Ipo.c	2 Mar 2004 06:36:34 -0000
@@ -345,7 +345,7 @@
 
 
 
-void GetIpoCurveName(IpoCurve *icu,char*s);
+void GetIpoCurveName(IpoCurve *icu,char*s,int doAction);
 void getname_mat_ei(int nr, char *str);
 void getname_world_ei(int nr, char *str);
 void getname_cam_ei(int nr, char *str);
@@ -360,7 +360,7 @@
 		return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected string argument"));
  for (icu=self->ipo->curve.first; icu; icu=icu->next){
 	 char str1[80];
-	 GetIpoCurveName(icu,str1);
+	 GetIpoCurveName(icu,str1, 0);
 	 if (!strcmp(str1,str))return IpoCurve_CreatePyObject(icu);
         }
 
@@ -369,7 +369,7 @@
 }
 
 
-void GetIpoCurveName(IpoCurve *icu,char*s)
+void GetIpoCurveName(IpoCurve *icu,char*s, int doAction)
 {
 	switch (icu->blocktype)
 				{
@@ -377,6 +377,15 @@
 				case ID_WO : {getname_world_ei(icu->adrcode,s);break;}
 				case ID_CA : {getname_cam_ei(icu->adrcode,s);break;}
 				case ID_OB : {getname_ob_ei(icu->adrcode,s);break;}
+				case ID_AC :
+				   if (doAction) {
+				      getname_ac_ei(icu->adrcode,s);
+				      break;
+				   }
+				   /*FALLTHROUGH*/
+				default:
+				   s[0]= 0;
+				   break;
 				}
 }
 
@@ -576,7 +585,7 @@
 			while (icu)
 				{
 					char str1[10];
-					GetIpoCurveName(icu,str1);
+					GetIpoCurveName(icu,str1, 1);
 					if (!strcmp(str1,stringname))break;
 					icu=icu->next;
 				}
Index: source/blender/python/api2_2x/Ipocurve.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Ipocurve.c,v
retrieving revision 1.10
diff -u -r1.10 Ipocurve.c
--- source/blender/python/api2_2x/Ipocurve.c	3 Jan 2004 03:50:58 -0000	1.10
+++ source/blender/python/api2_2x/Ipocurve.c	2 Mar 2004 06:36:34 -0000
@@ -191,20 +191,20 @@
 
 static PyObject* IpoCurve_getName (C_IpoCurve *self)
 {
-	char * nametab[24] = {"LocX","LocY","LocZ","dLocX","dLocY","dLocZ","RotX","RotY","RotZ","dRotX","dRotY","dRotZ","SizeX","SizeY","SizeZ","dSizeX","dSizeY","dSizeZ","Layer","Time","ColR","ColG","ColB","ColA"};
+	char * nametab[28] = {"LocX","LocY","LocZ","dLocX","dLocY","dLocZ","RotX","RotY","RotZ","dRotX","dRotY","dRotZ","SizeX","SizeY","SizeZ","dSizeX","dSizeY","dSizeZ","Layer","Time","ColR","ColG","ColB","ColA","QuatW","QuatX","QuatY","QuatZ"};
 
-	if (self->ipocurve->blocktype != ID_OB)
+	if (self->ipocurve->blocktype != ID_OB && self->ipocurve->blocktype != ID_AC)
 		return EXPP_ReturnPyObjError (PyExc_TypeError,
-			"This function doesn't support this ipocurve type yet");
+			"This function only supports Action and Object curves.");
 
 	//	printf("IpoCurve_getName %d\n",self->ipocurve->vartype);
 	if (self->ipocurve->adrcode <=0 )
-return PyString_FromString("Index too small");
-	if (self->ipocurve->adrcode >= 25 )
-return PyString_FromString("Index too big");
-
-return PyString_FromString(nametab[self->ipocurve->adrcode-1]);
+	  return PyString_FromString("Index too small");
+	if ((self->ipocurve->blocktype == ID_OB && self->ipocurve->adrcode >= 25) ||
+	    (self->ipocurve->blocktype == ID_AC && self->ipocurve->adrcode >= 29))
+	  return PyString_FromString("Index too big");
 
+	return PyString_FromString(nametab[self->ipocurve->adrcode-1]);
 }
 
 
@@ -274,9 +274,9 @@
 /*****************************************************************************/
 static PyObject *IpoCurveRepr (C_IpoCurve *self)
 {
-	void GetIpoCurveName(IpoCurve *icu,char*s);
+	void GetIpoCurveName(IpoCurve *icu,char*s, int doAction);
 	char s[100],s1[100];
-	GetIpoCurveName(self->ipocurve,s1);
+	GetIpoCurveName(self->ipocurve,s1, 1);
 	sprintf(s,"IpoCurve %s \n",s1);
   return PyString_FromString(s);
 }

--------------040805000804010609010901--