[Bf-committers] Patch: fixes and additions to python IpoCurve

Ken Hughes khughes at pacific.edu
Fri Jan 7 20:20:43 CET 2005


Here is a patch to source/blender/python/api2_2x/Ipo.c and 
source/blender/src/editipo.c which do the following:

* allow IPOs for material texture channels and world channels to
   be added ('addCurve()') and retrived ('getCurve() and getCurves()')
* cleaned up the search for named IPO curves (use a binary search,
   and uses string/attribute structures instead of individual
   strcmp() calls)
* fixed inconsistency between Lamp Energy IpoCurve names (you could
   add 'Energy' but get 'Energ')
* fixed bug in naming of World.MistSta IpoCurve

I think the patch in editipo.c is safe; it uses a temporary buffer
to store the name of material/world channels, which I believe should
then be copied into a Python string by PyString_FromString().  If
not, then can someone suggest a better way?

-----

I needed the ability to create and retrieve material texture IPOs for
some animations, hence my motivation for jumping into this.

Ken

-------------- next part --------------
? blender
? config.opts
? cvs-compile.tcsh
? cvs-patch.tcsh
? ipo-bugs
? kfg
? pulse.py
? untitled.blend
? untitled.blend1
? untitled2.blend
? obj/linux-glibc2.3.2-i386
? source/blender/python/api2_2x/Ipo.c.ken
? source/blender/src/editipo.c.ken
? tools/__init__.pyc
? tools/scons/__init__.pyc
? tools/scons/bs/__init__.pyc
? tools/scons/bs/bs_arc.pyc
? tools/scons/bs/bs_bincopy.pyc
? tools/scons/bs/bs_clean.pyc
? tools/scons/bs/bs_config.pyc
? tools/scons/bs/bs_default.pyc
? tools/scons/bs/bs_dirs.pyc
? tools/scons/bs/bs_globals.pyc
? tools/scons/bs/bs_libs.pyc
? tools/scons/bs/bs_nsis.pyc
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.35
diff -u -r1.35 Ipo.c
--- source/blender/python/api2_2x/Ipo.c	7 Jan 2005 01:38:14 -0000	1.35
+++ source/blender/python/api2_2x/Ipo.c	7 Jan 2005 19:06:44 -0000
@@ -450,257 +450,170 @@
 	return ( PyInt_FromLong( i ) );
 }
 
-/* 
-   fixme:  all these name validation routines need attention.
-   I just hacked in lots of 'return 1;'s as a temp fix.
-   stiv 6-jan-2004
-*/
+struct Ipo_CurveNames {
+    char * name;
+    int   adrcode;
+};
+
+static int ob_maps[10] = {
+	    MA_MAP1, MA_MAP2, MA_MAP3, MA_MAP4, MA_MAP5,
+	    MA_MAP6, MA_MAP7, MA_MAP8, MA_MAP9, MA_MAP10};
+
+static int searchCurveNames ( char *s, struct Ipo_CurveNames * curves, 
+		int end , int *param )
+{
+	int begin = 0;
+	int cmp;
+
+	end = (end/sizeof(struct Ipo_CurveNames))-1;
+	while (begin <= end) {
+		int mid = (begin+end)/2;
+		cmp = strcmp( s, curves[mid].name );
+		if ( cmp == 0 ) {
+			*param = curves[mid].adrcode;
+			return 1;
+		} else if ( cmp < 0 ) {
+			end = mid-1;
+		} else {
+			begin = mid+1;
+		}
+	}
+	return 0;
+}
+
+static int searchChannelCurveNames ( char *s, struct Ipo_CurveNames * curves, 
+		int end , int *param )
+{
+	int len;
+	char tmpname[16];
+	int origParam = *param;
+
+	len = strlen(s)-1;
+	if ( len > 15 ) return 0;
+	strncpy (tmpname,s,len);
+	tmpname[len]=0;
+	if ( searchCurveNames ( tmpname, curves, end, param ) && isdigit(s[len]) ) {
+		*param |= ob_maps[s[len]-'0'];
+		return 1;
+	}
+	*param = origParam;
+	return 0;
+}
+
+static struct Ipo_CurveNames LA_Types[] =  {
+	{"B", LA_COL_B},
+	{"Dist", LA_DIST},
+	{"Energ", LA_ENERGY},
+	{"G", LA_COL_G},
+	{"HaInt", LA_HALOINT},
+	{"Quad1", LA_QUAD1},
+	{"Quad2", LA_QUAD2},
+	{"R", LA_COL_R},
+	{"SpoBl", LA_SPOTBL},
+	{"SpoSi", LA_SPOTSI}
+};
 
 int Ipo_laIcuName( char *s, int *param )
 {
-	int ok = 0;
-	if( !strcmp( s, "Energy" ) ) {
-		*param = LA_ENERGY;
-		return 1;
-	}
-	if( !strcmp( s, "R" ) ) {
-		*param = LA_COL_R;
-		return 1;
-	}
-	if( !strcmp( s, "G" ) ) {
-		*param = LA_COL_G;
-		return 1;
-	}
-	if( !strcmp( s, "B" ) ) {
-		*param = LA_COL_B;
-		return 1;
-	}
-	if( !strcmp( s, "Dist" ) ) {
-		*param = LA_DIST;
-		return 1;
-	}
-	if( !strcmp( s, "SpoSi" ) ) {
-		*param = LA_SPOTSI;
-		return 1;
-	}
-	if( !strcmp( s, "SpoBl" ) ) {
-		*param = LA_SPOTBL;
-		return 1;
-	}
-	if( !strcmp( s, "Quad1" ) ) {
-		*param = LA_QUAD1;
-		return 1;
-	}
-	if( !strcmp( s, "Quad2" ) ) {
-		*param = LA_QUAD2;
-		return 1;
-	}
-	if( !strcmp( s, "HaInt" ) ) {
-		*param = LA_HALOINT;
-		return 1;
-	}
-	return ok;
+	return searchCurveNames ( s, &LA_Types, sizeof(LA_Types), param );
 }
 
-int Ipo_woIcuName( char *s, int *param )
+
+static struct Ipo_CurveNames MA_Types[] =  {
+	{"Alpha" , MA_ALPHA},
+	{"Amb" , MA_AMB},
+	{"B" , MA_COL_B},
+	{"Emit" , MA_EMIT},
+	{"FresMir" , MA_FRESMIR},
+	{"FresMirI" , MA_FRESMIRI},
+	{"FresTra" , MA_FRESTRA},
+	{"FresTraI" , MA_FRESTRAI},
+	{"G" , MA_COL_G},
+	{"HaSize" , MA_HASIZE},
+	{"Hard" , MA_HARD},
+	{"Ior" , MA_IOR},
+	{"MirB" , MA_MIR_B},
+	{"MirG" , MA_MIR_G},
+	{"MirR" , MA_MIR_R},
+	{"Mode" , MA_MODE},
+	{"R" , MA_COL_R},
+	{"RayMir" , MA_RAYM},
+	{"Ref" , MA_REF},
+	{"SpTra" , MA_SPTR},
+	{"Spec" , MA_SPEC},
+	{"SpecB" , MA_SPEC_B},
+	{"SpecG" , MA_SPEC_G},
+	{"SpecR" , MA_SPEC_R},
+	{"TraGlow" , MA_ADD},
+	{"Translu" , MA_TRANSLU}
+};
+
+static struct Ipo_CurveNames MTex_Types[] =  {
+	{"Col", MAP_COLF},
+	{"DefVar", MAP_DVAR},
+	{"Disp", MAP_DISP},
+	{"Nor", MAP_NORF},
+	{"OfsX", MAP_OFS_X},
+	{"OfsY", MAP_OFS_Y},
+	{"OfsZ", MAP_OFS_Z},
+	{"SizeX", MAP_SIZE_X},
+	{"SizeY", MAP_SIZE_Y},
+	{"SizeZ", MAP_SIZE_Z},
+	{"Var", MAP_VARF},
+	{"texB", MAP_B},
+	{"texG", MAP_G},
+	{"texR", MAP_R}
+};
+
+int Ipo_maIcuName( char *s, int *param )
 {
-	int ok = 0;
-	if( !strcmp( s, "HorR" ) ) {
-		*param = WO_HOR_R;
-		return 1;
-	}
-	if( !strcmp( s, "HorG" ) ) {
-		*param = WO_HOR_G;
-		return 1;
-	}
-	if( !strcmp( s, "HorB" ) ) {
-		*param = WO_HOR_B;
-		return 1;
-	}
-	if( !strcmp( s, "ZenR" ) ) {
-		*param = WO_ZEN_R;
-		return 1;
-	}
-	if( !strcmp( s, "ZenG" ) ) {
-		*param = WO_ZEN_G;
-		return 1;
-	}
-	if( !strcmp( s, "ZenB" ) ) {
-		*param = WO_ZEN_B;
-		return 1;
-	}
-	if( !strcmp( s, "Expos" ) ) {
-		*param = WO_EXPOS;
-		return 1;
-	}
-	if( !strcmp( s, "Misi" ) ) {
-		*param = WO_MISI;
-		return 1;
-	}
-	if( !strcmp( s, "MisDi" ) ) {
-		*param = WO_MISTDI;
-		return 1;
-	}
-	if( !strcmp( s, "MisHi" ) ) {
-		*param = WO_MISTHI;
-		return 1;
-	}
-	if( !strcmp( s, "StarR" ) ) {
-		*param = WO_STAR_R;
-		return 1;
-	}
-	if( !strcmp( s, "StarB" ) ) {
-		*param = WO_STAR_B;
-		return 1;
-	}
-	if( !strcmp( s, "StarG" ) ) {
-		*param = WO_STAR_G;
-		return 1;
-	}
-	if( !strcmp( s, "ClSta" ) ) {
-		*param = WO_MISTSTA;
-		return 1;
-	}
-	if( !strcmp( s, "StarDi" ) ) {
-		*param = WO_STARDIST;
-		return 1;
-	}
-	if( !strcmp( s, "StarSi" ) ) {
-		*param = WO_STARSIZE;
-		return 1;
-	}
-	return ok;
+	return searchCurveNames ( s, &MA_Types, sizeof(MA_Types), param ) ||
+		searchChannelCurveNames ( s, &MTex_Types, sizeof(MTex_Types), param ) ;
 }
 
-int Ipo_maIcuName( char *s, int *param )
+static struct Ipo_CurveNames WO_Types[] =  {
+	{"Expos", WO_EXPOS},
+	{"HorB", WO_HOR_B},
+	{"HorG", WO_HOR_G},
+	{"HorR", WO_HOR_R},
+	{"MisDi", WO_MISTDI},
+	{"MisHi", WO_MISTHI},
+	{"MisSta", WO_MISTSTA},
+	{"Misi", WO_MISI},
+	{"StarB", WO_STAR_B},
+	{"StarDi", WO_STARDIST},
+	{"StarG", WO_STAR_G},
+	{"StarR", WO_STAR_R},
+	{"StarSi", WO_STARSIZE},
+	{"ZenB", WO_ZEN_B},
+	{"ZenG", WO_ZEN_G},
+	{"ZenR", WO_ZEN_R}
+};
+
+int Ipo_woIcuName( char *s, int *param )
 {
-	int ok = 0;
-	if( !strcmp( s, "R" ) ) {
-		*param = MA_COL_R;
-		return 1;
-	}
-	if( !strcmp( s, "G" ) ) {
-		*param = MA_COL_G;
-		return 1;
-	}
-	if( !strcmp( s, "B" ) ) {
-		*param = MA_COL_B;
-		return 1;
-	}
-	if( !strcmp( s, "SpecR" ) ) {
-		*param = MA_SPEC_R;
-		return 1;
-	}
-	if( !strcmp( s, "SpecG" ) ) {
-		*param = MA_SPEC_G;
-		return 1;
-	}
-	if( !strcmp( s, "SpecB" ) ) {
-		*param = MA_SPEC_B;
-		return 1;
-	}
-	if( !strcmp( s, "MirR" ) ) {
-		*param = MA_MIR_R;
-		return 1;
-	}
-	if( !strcmp( s, "MirG" ) ) {
-		*param = MA_MIR_G;
-		return 1;
-	}
-	if( !strcmp( s, "MirB" ) ) {
-		*param = MA_MIR_B;
-		return 1;
-	}
-	if( !strcmp( s, "Ref" ) ) {
-		*param = MA_REF;
-		return 1;
-	}
-	if( !strcmp( s, "Alpha" ) ) {
-		*param = MA_ALPHA;
-		return 1;
-	}
-	if( !strcmp( s, "Emit" ) ) {
-		*param = MA_EMIT;
-		return 1;
-	}
-	if( !strcmp( s, "Amb" ) ) {
-		*param = MA_AMB;
-		return 1;
-	}
-	if( !strcmp( s, "Spec" ) ) {
-		*param = MA_SPEC;
-		return 1;
-	}
-	if( !strcmp( s, "Hard" ) ) {
-		*param = MA_HARD;
-		return 1;
-	}
-	if( !strcmp( s, "SpTra" ) ) {
-		*param = MA_SPTR;
-		return 1;
-	}
-	if( !strcmp( s, "Ior" ) ) {
-		*param = MA_IOR;
-		return 1;
-	}
-	if( !strcmp( s, "Mode" ) ) {
-		*param = MA_MODE;
-		return 1;
-	}
-	if( !strcmp( s, "HaSize" ) ) {
-		*param = MA_HASIZE;
-		return 1;
-	}
-	if( !strcmp( s, "Translu" ) ) {
-		*param = MA_TRANSLU;
-		return 1;
-	}
-	if( !strcmp( s, "RayMir" ) ) {
-		*param = MA_RAYM;
-		return 1;
-	}
-	if( !strcmp( s, "FresMir" ) ) {
-		*param = MA_FRESMIR;
-		return 1;
-	}
-	if( !strcmp( s, "FresMirI" ) ) {
-		*param = MA_FRESMIRI;
-		return 1;
-	}
-	if( !strcmp( s, "FresTra" ) ) {
-		*param = MA_FRESTRA;
-		return 1;
-	}
-	if( !strcmp( s, "FresTraI" ) ) {
-		*param = MA_FRESTRAI;
-		return 1;
-	}
-	if( !strcmp( s, "TraGlow" ) ) {
-		*param = MA_ADD;
-		return 1;
-	}
-	return ok;
+	return searchCurveNames ( s, &WO_Types, sizeof(WO_Types), param ) ||
+		searchChannelCurveNames ( s, &MTex_Types, sizeof(MTex_Types), param ) ;
 }
 
 int Ipo_keIcuName( char *s, int *param )
 {
-	char key[10];
-	int ok = 0;
-	int nr = 0;
+	int len = strlen(s);
 	if( !strcmp( s, "Speed" ) ) {
 		*param = KEY_SPEED;
-		ok = 1;
+		return 1;
 	}
-	for( nr = 1; nr < 64; nr++ ) {
-		sprintf( key, "Key %d", nr );
-		if( !strcmp( s, key ) ) {
-			*param = nr;
-			ok = 1;
-			break;
+	if( ( len == 5 || len == 6 ) && !strncmp( s, "Key ", 4 ) ) {
+		if ( isdigit(s[4]) && isdigit(s[len-1]) ) {
+			short val = strtol(&s[4],(char **)NULL,10);
+			if ( val > 0 && val < 64 ) {
+				*param = val;
+				return 1;
+			}
+			else return 0;
 		}
 	}
-
-	return ok;
+	return 0;
 }
 
 int Ipo_seqIcuName( char *s, int *param )
@@ -736,55 +649,26 @@
 	return ok;
 }
 
+static struct Ipo_CurveNames AC_Types[] =  {
+	{"LocX", AC_LOC_X},
+	{"LocY", AC_LOC_Y},
+	{"LocZ", AC_LOC_Z},
+	{"QuatW", AC_QUAT_W},
+	{"QuatX", AC_QUAT_X},
+	{"QuatY", AC_QUAT_Y},
+	{"QuatZ", AC_QUAT_Z},
+	{"SizeX", AC_SIZE_X},
+	{"SizeY", AC_SIZE_Y},
+	{"SizeZ", AC_SIZE_Z}
+};
+
 int Ipo_acIcuName( char *s, int *param )
 {
-	int ok = 0;
-	if( !strcmp( s, "LocX" ) ) {
-		*param = AC_LOC_X;
-		return 1;
-	}
-	if( !strcmp( s, "LocY" ) ) {
-		*param = AC_LOC_Y;
-		return 1;
-	}
-	if( !strcmp( s, "LocZ" ) ) {
-		*param = AC_LOC_Z;
-		return 1;
-	}
-	if( !strcmp( s, "SizeX" ) ) {
-		*param = AC_SIZE_X;
-		return 1;
-	}
-	if( !strcmp( s, "SizeY" ) ) {
-		*param = AC_SIZE_Y;
-		return 1;
-	}
-	if( !strcmp( s, "SizeZ" ) ) {
-		*param = AC_SIZE_Z;
-		return 1;
-	}
-	if( !strcmp( s, "QuatX" ) ) {
-		*param = AC_QUAT_X;
-		return 1;
-	}
-	if( !strcmp( s, "QuatY" ) ) {
-		*param = AC_QUAT_Y;
-		return 1;
-	}
-	if( !strcmp( s, "QuatZ" ) ) {
-		*param = AC_QUAT_Z;
-		return 1;
-	}
-	if( !strcmp( s, "QuatW" ) ) {
-		*param = AC_QUAT_W;
-		return 1;
-	}
-	return ok;
+	return searchCurveNames ( s, &AC_Types, sizeof(AC_Types), param );
 }
 
 int Ipo_caIcuName( char *s, int *param )
 {
-	int ok = 0;
 	if( !strcmp( s, "Lens" ) ) {
 		*param = CAM_LENS;
 		return 1;
@@ -797,226 +681,74 @@
 		*param = CAM_END;
 		return 1;
 	}
-	return ok;
+	return 0;
 }
 
+static struct Ipo_CurveNames TE_Types[] =  {
+	{"ColT", TE_VN_COLT},
+	{"DistA", TE_DISTA},
+	{"DistM", TE_VN_DISTM},
+	{"Lacu", TE_MG_LAC},
+	{"MgGain", TE_MG_GAIN},
+	{"MgH", TE_MGH},
+	{"MgOff", TE_MG_OFF},
+	{"MgType", TE_MG_TYP},
+	{"MinkMExp", TE_VNMEXP},
+	{"NBase1", TE_N_BAS1},
+	{"NBase2", TE_N_BAS2},
+	{"NDepth", TE_NDEPTH},
+	{"NSize", TE_NSIZE},
+	{"NType", TE_NTYPE},
+	{"Oct", TE_MG_OCT},
+	{"Turb", TE_TURB},
+	{"Vnw1", TE_VNW1},
+	{"Vnw2", TE_VNW2},
+	{"Vnw3", TE_VNW3},
+	{"Vnw4", TE_VNW4},
+	{"iScale", TE_ISCA}
+};
+
 int Ipo_texIcuName( char *s, int *param )
 {
-	int ok = 0;
-	if( !strcmp( s, "NSize" ) ) {
-		*param = TE_NSIZE;
-		return 1;
-	}
-	if( !strcmp( s, "NDepth" ) ) {
-		*param = TE_NDEPTH;
-		return 1;
-	}
-	if( !strcmp( s, "NType" ) ) {
-		*param = TE_NTYPE;
-		return 1;
-	}
-	if( !strcmp( s, "Turb" ) ) {
-		*param = TE_TURB;
-		return 1;
-	}
-	if( !strcmp( s, "Vnw1" ) ) {
-		*param = TE_VNW1;
-		return 1;
-	}
-	if( !strcmp( s, "Vnw2" ) ) {
-		*param = TE_VNW2;
-		return 1;
-	}
-	if( !strcmp( s, "Vnw3" ) ) {
-		*param = TE_VNW3;
-		return 1;
-	}
-	if( !strcmp( s, "Vnw4" ) ) {
-		*param = TE_VNW4;
-		return 1;
-	}
-	if( !strcmp( s, "MinkMExp" ) ) {
-		*param = TE_VNMEXP;
-		return 1;
-	}
-	if( !strcmp( s, "DistM" ) ) {
-		*param = TE_VN_DISTM;
-		return 1;
-	}
-	if( !strcmp( s, "ColT" ) ) {
-		*param = TE_VN_COLT;
-		return 1;
-	}
-	if( !strcmp( s, "iScale" ) ) {
-		*param = TE_ISCA;
-		return 1;
-	}
-	if( !strcmp( s, "DistA" ) ) {
-		*param = TE_DISTA;
-		return 1;
-	}
-	if( !strcmp( s, "MgType" ) ) {
-		*param = TE_MG_TYP;
-		return 1;
-	}
-	if( !strcmp( s, "MgH" ) ) {
-		*param = TE_MGH;
-		return 1;
-	}
-	if( !strcmp( s, "Lacu" ) ) {
-		*param = TE_MG_LAC;
-		return 1;
-	}
-	if( !strcmp( s, "Oct" ) ) {
-		*param = TE_MG_OCT;
-		return 1;
-	}
-	if( !strcmp( s, "MgOff" ) ) {
-		*param = TE_MG_OFF;
-		return 1;
-	}
-	if( !strcmp( s, "MgGain" ) ) {
-		*param = TE_MG_GAIN;
-		return 1;
-	}
-	if( !strcmp( s, "NBase1" ) ) {
-		*param = TE_N_BAS1;
-		return 1;
-	}
-	if( !strcmp( s, "NBase2" ) ) {
-		*param = TE_N_BAS2;
-		return 1;
-	}
-
-	return ok;
+	return searchCurveNames ( s, &TE_Types, sizeof(TE_Types), param );
 }
 
+static struct Ipo_CurveNames OB_Types[] =  {
+	{"ColA", OB_COL_A},
+	{"ColB", OB_COL_B},
+	{"ColG", OB_COL_G},
+	{"ColR", OB_COL_R},
+	{"Damping", OB_PD_SDAMP},
+	{"FFall", OB_PD_FFALL},
+	{"FStreng", OB_PD_FSTR},
+	{"Layer", OB_LAY},
+	{"LocX", OB_LOC_X},
+	{"LocY", OB_LOC_Y},
+	{"LocZ", OB_LOC_Z},
+	{"Perm", OB_PD_PERM},
+	{"RDamp", OB_PD_RDAMP},
+	{"RotX", OB_ROT_X},
+	{"RotY", OB_ROT_Y},
+	{"RotZ", OB_ROT_Z},
+	{"SizeX", OB_SIZE_X},
+	{"SizeY", OB_SIZE_Y},
+	{"SizeZ", OB_SIZE_Z},
+	{"Time", OB_TIME},
+	{"dLocX", OB_DLOC_X},
+	{"dLocY", OB_DLOC_Y},
+	{"dLocZ", OB_DLOC_Z},
+	{"dRotX", OB_DROT_X},
+	{"dRotY", OB_DROT_Y},
+	{"dRotZ", OB_DROT_Z},
+	{"dSizeX", OB_DSIZE_X},
+	{"dSizeY", OB_DSIZE_Y},
+	{"dSizeZ", OB_DSIZE_Z}
+};
+
 int Ipo_obIcuName( char *s, int *param )
 {
-	int ok = 0;
-	if( !strcmp( s, "LocX" ) ) {
-		*param = OB_LOC_X;
-		return 1;
-	}
-	if( !strcmp( s, "LocY" ) ) {
-		*param = OB_LOC_Y;
-		return 1;
-	}
-	if( !strcmp( s, "LocZ" ) ) {
-		*param = OB_LOC_Z;
-		return 1;
-	}
-	if( !strcmp( s, "RotX" ) ) {
-		*param = OB_ROT_X;
-		return 1;
-	}
-	if( !strcmp( s, "RotY" ) ) {
-		*param = OB_ROT_Y;
-		return 1;
-	}
-	if( !strcmp( s, "RotZ" ) ) {
-		*param = OB_ROT_Z;
-		return 1;
-	}
-	if( !strcmp( s, "SizeX" ) ) {
-		*param = OB_SIZE_X;
-		return 1;
-	}
-	if( !strcmp( s, "SizeY" ) ) {
-		*param = OB_SIZE_Y;
-		return 1;
-	}
-	if( !strcmp( s, "SizeZ" ) ) {
-		*param = OB_SIZE_Z;
-		return 1;
-	}
-
-	if( !strcmp( s, "dLocX" ) ) {
-		*param = OB_DLOC_X;
-		return 1;
-	}
-	if( !strcmp( s, "dLocY" ) ) {
-		*param = OB_DLOC_Y;
-		return 1;
-	}
-	if( !strcmp( s, "dLocZ" ) ) {
-		*param = OB_DLOC_Z;
-		return 1;
-	}
-	if( !strcmp( s, "dRotX" ) ) {
-		*param = OB_DROT_X;
-		return 1;
-	}
-	if( !strcmp( s, "dRotY" ) ) {
-		*param = OB_DROT_Y;
-		return 1;
-	}
-	if( !strcmp( s, "dRotZ" ) ) {
-		*param = OB_DROT_Z;
-		return 1;
-	}
-	if( !strcmp( s, "dSizeX" ) ) {
-		*param = OB_DSIZE_X;
-		return 1;
-	}
-	if( !strcmp( s, "dSizeY" ) ) {
-		*param = OB_DSIZE_Y;
-		return 1;
-	}
-	if( !strcmp( s, "dSizeZ" ) ) {
-		*param = OB_DSIZE_Z;
-		return 1;
-	}
-
-	if( !strcmp( s, "Layer" ) ) {
-		*param = OB_LAY;
-		return 1;
-	}
-	if( !strcmp( s, "Time" ) ) {
-		*param = OB_TIME;
-		return 1;
-	}
-
-	if( !strcmp( s, "ColR" ) ) {
-		*param = OB_COL_R;
-		return 1;
-	}
-	if( !strcmp( s, "ColG" ) ) {
-		*param = OB_COL_G;
-		return 1;
-	}
-	if( !strcmp( s, "ColB" ) ) {
-		*param = OB_COL_B;
-		return 1;
-	}
-	if( !strcmp( s, "ColA" ) ) {
-		*param = OB_COL_A;
-		return 1;
-	}
-	if( !strcmp( s, "FStreng" ) ) {
-		*param = OB_PD_FSTR;
-		return 1;
-	}
-	if( !strcmp( s, "FFall" ) ) {
-		*param = OB_PD_FFALL;
-		return 1;
-	}
-	if( !strcmp( s, "Damping" ) ) {
-		*param = OB_PD_SDAMP;
-		return 1;
-	}
-	if( !strcmp( s, "RDamp" ) ) {
-		*param = OB_PD_RDAMP;
-		return 1;
-	}
-	if( !strcmp( s, "Perm" ) ) {
-		*param = OB_PD_PERM;
-		return 1;
-	}
-
-	return ok;
+	return searchCurveNames ( s, &OB_Types, sizeof(OB_Types), param );
 }
-
 
 /* 
    Function:  Ipo_addCurve
Index: source/blender/src/editipo.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/editipo.c,v
retrieving revision 1.44
diff -u -r1.44 editipo.c
--- source/blender/src/editipo.c	27 Dec 2004 19:28:51 -0000	1.44
+++ source/blender/src/editipo.c	7 Jan 2005 19:06:45 -0000
@@ -240,9 +240,22 @@
 	return ic_name_empty[0];
 }
 
+static char mtex_ic_name[16];
+
 char *getname_mat_ei(int nr)
 {
-	if(nr>=MA_MAP1) return getname_mtex_ei((nr & (MA_MAP1-1)));
+	if(nr>=MA_MAP1) {
+	    int mapno = 0;
+	    strncpy (mtex_ic_name, getname_mtex_ei((nr & (MA_MAP1-1))), 10);
+	    mtex_ic_name[strlen(mtex_ic_name)+1] = 0;
+	    while ((nr & MA_MAP1) == 0)
+	    {
+		++mapno;
+		nr >>= 1;
+	    }
+	    mtex_ic_name[strlen(mtex_ic_name)] = '0'+mapno;
+	    return mtex_ic_name;
+	}
 	else {
 		if(nr>=MA_COL_R && nr<=MA_ADD) return ma_ic_names[nr-1];
 	}
@@ -251,7 +264,19 @@
 
 char *getname_world_ei(int nr)
 {
-	if(nr>=MA_MAP1) return getname_mtex_ei((nr & (MA_MAP1-1)));
+	if(nr>=MA_MAP1) {
+	    int mapno = 0;
+	    strncpy (mtex_ic_name, getname_mtex_ei((nr & (MA_MAP1-1))), 10);
+	    mtex_ic_name[strlen(mtex_ic_name)+1] = 0;
+	    while ((nr & MA_MAP1) == 0)
+	    {
+		++mapno;
+		nr >>= 1;
+	    }
+	    mtex_ic_name[strlen(mtex_ic_name)] = '0'+mapno;
+	    return mtex_ic_name;
+	}
+	/* if(nr>=MA_MAP1) return getname_mtex_ei((nr & (MA_MAP1-1))); */
 	else {
 		if(nr>=WO_HOR_R && nr<=WO_STARSIZE) return wo_ic_names[nr-1];
 	}


More information about the Bf-committers mailing list