Page Menu
Home
Search
Configure Global Search
Log In
Files
F1508
texchannel-patch2.txt
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Ken Hughes (khughes)
Nov 13 2013, 12:58 PM
Size
16 KB
Subscribers
None
texchannel-patch2.txt
View Options
Index: blender/source/blender/python/api2_2x/Ipo.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Ipo.c,v
retrieving revision 1.36
diff -u -u -r1.36 Ipo.c
--- blender/source/blender/python/api2_2x/Ipo.c 9 Mar 2005 19:45:55 -0000 1.36
+++ blender/source/blender/python/api2_2x/Ipo.c 16 Mar 2005 03:11:03 -0000
@@ -1,5 +1,5 @@
/*
- * $Id: Ipo.c,v 1.36 2005/03/09 19:45:55 lukep Exp $
+ * $Id: Ipo.c,v 1.2 2005/03/15 17:59:39 khughes Exp khughes $
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -46,11 +46,7 @@
#include "Ipocurve.h"
#include "constant.h"
#include "gen_utils.h"
-
-
-
-/* forward declarations */
-char *GetIpoCurveName( IpoCurve * icu );
+#include "MEM_guardedalloc.h"
/*****************************************************************************/
/* Python API function prototypes for the Ipo module. */
@@ -95,6 +91,7 @@
static PyObject *Ipo_getCurve( BPy_Ipo * self, PyObject * args );
static PyObject *Ipo_getCurves( BPy_Ipo * self );
static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * args );
+static PyObject *Ipo_delCurve( BPy_Ipo * self, PyObject * args );
static PyObject *Ipo_getNcurves( BPy_Ipo * self );
static PyObject *Ipo_getNBezPoints( BPy_Ipo * self, PyObject * args );
static PyObject *Ipo_DeleteBezPoints( BPy_Ipo * self, PyObject * args );
@@ -125,6 +122,8 @@
"(str) - Change Ipo rctf"},
{"addCurve", ( PyCFunction ) Ipo_addCurve, METH_VARARGS,
"() - Return Ipo ncurves"},
+ {"delCurve", ( PyCFunction ) Ipo_delCurve, METH_VARARGS,
+ "() - Delete Ipo curves"},
{"getNcurves", ( PyCFunction ) Ipo_getNcurves, METH_NOARGS,
"() - Return Ipo ncurves"},
{"getNBezPoints", ( PyCFunction ) Ipo_getNBezPoints, METH_VARARGS,
@@ -450,257 +449,112 @@
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
+/*
+ a look-up table to map texture channel numbers to their bitmapping
*/
-static int Ipo_laIcuName( char *s, int *param )
+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};
+
+/*
+ search through a list of IPO Curve name strings for a match
+ s: string from user
+ curves: array of name strings
+ end: array length
+ baseValue: constant offset to add to array index
+ *param: returned parameter value
+*/
+
+static int searchCurveNames ( char *s, char *curves[],
+ int end, int baseValue, 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;
+ int i;
+ for ( i = 0 ; i < end; ++i ) {
+ if ( !strcmp( s, curves[i] ) ) {
+ *param = i+baseValue;
+ return 1;
+ }
}
- return ok;
+ return 0;
}
-static int Ipo_woIcuName( char *s, int *param )
+/*
+ search through a list of IPO channel curve names for a match
+*/
+
+static int searchChannelCurveNames ( char *s, char *curves[],
+ int end , 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;
+ int len;
+ char tmpname[32];
+
+ /* if string is longer than temp string size, definitely not a match */
+ len = strlen(s)-1;
+ if ( len > sizeof(tmpname)-1 ) return 0;
+
+ /* make a local copy of the string, and clear the last char */
+
+ strncpy (tmpname,s,len);
+ tmpname[len]=0;
+
+ /*
+ if last char is numeric and the rest of the string matches a channel
+ name, we have a match
+ */
+ if ( isdigit(s[len]) && searchCurveNames ( tmpname, curves, end, 1, param ) ) {
+ *param |= ob_maps[s[len]-'0']; /* merge channel number with param */
return 1;
}
- return ok;
+ return 0;
+}
+
+static int Ipo_laIcuName( char *s, int *param )
+{
+ extern char *la_ic_names[], *mtex_ic_names[];
+ return searchCurveNames ( s, la_ic_names, LA_TOTNAM, LA_ENERGY, param ) ||
+ searchChannelCurveNames ( s, mtex_ic_names, MAP_COLF, param );
+}
+
+static int Ipo_woIcuName( char *s, int *param )
+{
+ extern char *wo_ic_names[], *mtex_ic_names[];
+ return searchCurveNames ( s, wo_ic_names, WO_TOTNAM, WO_HOR_R, param ) ||
+ searchChannelCurveNames ( s, mtex_ic_names, MAP_VARF, param );
}
static int Ipo_maIcuName( 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;
+ extern char *ma_ic_names[], *mtex_ic_names[];
+ return searchCurveNames ( s, ma_ic_names, MA_TOTNAM, MA_COL_R, param ) ||
+ searchChannelCurveNames ( s, mtex_ic_names, MAP_DISP, param );
}
static 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;
+ /*
+ Valid keys are "Key 1" through "Key 63". So check that:
+ (1) string length is 5 or 6
+ (2) string starts with "Key "
+ (3) last 1 or 2 chars are digits
+ (4) key number is between 0 and 64, exclusive
+ */
+ 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;
}
static int Ipo_seqIcuName( char *s, int *param )
@@ -738,286 +592,36 @@
static 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;
+ extern char *ac_ic_names[];
+ return searchCurveNames ( s, ac_ic_names, 3, AC_LOC_X, param ) ||
+ searchCurveNames ( s, ac_ic_names+3, 3, AC_SIZE_X, param ) ||
+ searchCurveNames ( s, ac_ic_names+6, 4, AC_QUAT_W, param );
}
static int Ipo_caIcuName( char *s, int *param )
{
- int ok = 0;
- if( !strcmp( s, "Lens" ) ) {
- *param = CAM_LENS;
- return 1;
- }
- if( !strcmp( s, "ClSta" ) ) {
- *param = CAM_STA;
- return 1;
- }
- if( !strcmp( s, "ClEnd" ) ) {
- *param = CAM_END;
- return 1;
- }
- return ok;
+ extern char *cam_ic_names[];
+ return searchCurveNames ( s, cam_ic_names, CAM_TOTNAM, CAM_LENS, param );
}
static 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;
+ extern char *tex_ic_names[];
+ return searchCurveNames ( s, tex_ic_names, TE_TOTNAM, TE_NSIZE, param );
}
static 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;
- }
+ extern char *ob_ic_names[], *obeff_ic_names[];
- 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;
+ if ( searchCurveNames ( s, ob_ic_names, OB_TOTNAM, OB_LOC_X, param ) ) {
return 1;
- }
-
- return ok;
+ } else
+ /* don't know how to handle EffX, EffY, EffZ */
+ /* return searchCurveNames ( s, obeff_ic_names, 3, OB_EFF_X, param ); */
+ return 0;
}
-
/*
Function: Ipo_addCurve
Bpy: Blender.Ipo.addCurve( 'curname')
@@ -1125,6 +729,46 @@
return IpoCurve_CreatePyObject( icu );
}
+/*
+ Function: Ipo_delCurve
+ Bpy: Blender.Ipo.delCurve(curtype)
+
+ delete an existing curve from IPO.
+ example:
+ ipo = Blender.Ipo.New('Object','ObIpo')
+ cu = ipo.delCurve('LocX')
+*/
+
+void del_ipoCurve ( IpoCurve * icu);
+
+static PyObject *Ipo_delCurve( BPy_Ipo * self, PyObject * args )
+{
+ IpoCurve *icu;
+ int num;
+ int i;
+
+ char *strname;
+ if( !PyArg_ParseTuple( args, "s", &strname ) )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_TypeError,
+ "expected int or string argument" ) );
+
+ for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
+ char *str1 = GetIpoCurveName( icu );
+ if( !strcmp( str1, strname ) ) {
+ BLI_remlink( &(self->ipo->curve), icu);
+ if(icu->bezt) MEM_freeN(icu->bezt);
+ MEM_freeN(icu);
+ del_ipoCurve ( icu );
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
+ }
+
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_RuntimeError, "IpoCurve not found" ) );
+}
+
static PyObject *Ipo_getCurve( BPy_Ipo * self, PyObject * args )
@@ -1144,57 +788,6 @@
Py_INCREF( Py_None );
return Py_None;
-}
-
-char *GetIpoCurveName( IpoCurve * icu )
-{
- switch ( icu->blocktype ) {
- case ID_MA:
- {
- return getname_mat_ei( icu->adrcode );
- }
- case ID_WO:
- {
- return getname_world_ei( icu->adrcode );
- }
- case ID_CA:
- {
- return getname_cam_ei( icu->adrcode );
- }
- case ID_OB:
- {
- return getname_ob_ei( icu->adrcode, 1 ); /* solve: what if EffX/Y/Z are wanted? */
- }
- case ID_TE:
- {
- return getname_tex_ei( icu->adrcode );
- }
- case ID_LA:
- {
- return getname_la_ei( icu->adrcode );
- }
- case ID_AC:
- {
- return getname_ac_ei( icu->adrcode );
- }
- case ID_CU:
- {
- return getname_cu_ei( icu->adrcode );
- }
- case ID_KE:
- {
- return getname_key_ei( icu->adrcode );
- }
- case ID_SEQ:
- {
- return getname_seq_ei( icu->adrcode );
- }
- case IPO_CO:
- {
- return getname_co_ei( icu->adrcode );
- }
- }
- return NULL;
}
static PyObject *Ipo_getCurves( BPy_Ipo * self )
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
05/c6/01cedf7c94cde1ac35810673a3d5
Event Timeline
Log In to Comment