diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index d0f46bfbaa8..f0bf3672a35 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1182,8 +1182,11 @@ void makebevelcurve(Object *ob, ListBase *disp) int nr, a; cu= ob->data; - disp->first = disp->last = NULL; + + /* if a font object is being edited, then do nothing */ + if( ob == G.obedit && ob->type == OB_FONT ) return; + if(cu->bevobj && cu->bevobj!=ob) { if(cu->bevobj->type==OB_CURVE) { bevcu= cu->bevobj->data; diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c index 62aa663409e..74e8e575fda 100644 --- a/source/blender/blenlib/intern/util.c +++ b/source/blender/blenlib/intern/util.c @@ -437,11 +437,14 @@ void BLI_makestringcode(const char *relfile, char *file) char * q; char * lslash; int len=0; - char temp[FILE_MAXDIR+FILE_MAXFILE]; char res[FILE_MAXDIR+FILE_MAXFILE]; + + /* if file is already relative, bail out */ + if(file[0]=='/' && file[1]=='/') return; + strcpy(temp, relfile); - + #ifdef WIN32 if (strlen(file) > 2) { if ( temp[1] == ':' && file[1] == ':' && temp[0] != file[0] ) diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c index 50390025ee2..e0fe70b54f8 100644 --- a/source/blender/python/api2_2x/Material.c +++ b/source/blender/python/api2_2x/Material.c @@ -2938,6 +2938,34 @@ static PyObject *Matr_oldsetMode( BPy_Material * self, PyObject * args ) NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + static int bitmask = MA_TRACEBLE + | MA_SHADOW + | MA_SHLESS + | MA_WIRE + | MA_VERTEXCOL + | MA_VERTEXCOLP + | MA_HALO + | MA_ZTRA + | MA_ZINV + | MA_HALO_RINGS + | MA_HALO_LINES + | MA_ONLYSHADOW + | MA_HALO_XALPHA + | MA_STAR + | MA_FACETEXTURE + | MA_HALOTEX + | MA_HALOPUNO + | MA_NOMIST + | MA_HALO_SHADE + | MA_HALO_FLARE + | MA_RADIO + | MA_RAYMIRROR + | MA_ZTRA + | MA_RAYTRANSP + | MA_ONLYSHADOW + | MA_NOMIST + | MA_ENV; + /* * check for a single integer argument; do a quick check for now @@ -2947,7 +2975,7 @@ static PyObject *Matr_oldsetMode( BPy_Material * self, PyObject * args ) if ( (PySequence_Size( args ) == 1) && PyInt_Check ( PyTuple_GET_ITEM ( args , 0 ) ) && PyArg_ParseTuple( args, "i", &flag ) - && flag < (MA_RAYMIRROR >> 1) ) { + && (flag & bitmask) == flag ) { ok = 1; /* diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c index ab286b20761..d4ef5b79c0e 100644 --- a/source/blender/python/api2_2x/Mesh.c +++ b/source/blender/python/api2_2x/Mesh.c @@ -1122,6 +1122,11 @@ static PyObject *MVert_repr( BPy_MVert * self ) return PyString_FromString( format ); } +static long MVert_hash( BPy_MVert *self ) +{ + return (long)self->index; +} + /************************************************************************ * * Python MVert_Type structure definition @@ -1153,7 +1158,7 @@ PyTypeObject MVert_Type = { /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ + ( hashfunc ) MVert_hash, /* hashfunc tp_hash; */ NULL, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ NULL, /* getattrofunc tp_getattro; */ @@ -1252,7 +1257,7 @@ PyTypeObject PVert_Type = { /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ + ( hashfunc ) MVert_hash, /* hashfunc tp_hash; */ NULL, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ NULL, /* getattrofunc tp_getattro; */ @@ -2207,6 +2212,11 @@ static PyObject *MEdge_repr( BPy_MEdge * self ) (int)self->index ); } +static long MEdge_hash( BPy_MEdge *self ) +{ + return (long)self->index; +} + /************************************************************************ * * Python MEdge_Type structure definition @@ -2238,7 +2248,7 @@ PyTypeObject MEdge_Type = { /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ + ( hashfunc ) MEdge_hash, /* hashfunc tp_hash; */ NULL, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ NULL, /* getattrofunc tp_getattro; */ @@ -3665,6 +3675,11 @@ static PyObject *MFace_repr( BPy_MFace* self ) (int)face->v3, (int)self->index ); } +static long MFace_hash( BPy_MFace *self ) +{ + return (long)self->index; +} + /************************************************************************ * * Python MFace_Type structure definition @@ -3696,7 +3711,7 @@ PyTypeObject MFace_Type = { /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ + ( hashfunc ) MFace_hash, /* hashfunc tp_hash; */ NULL, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ NULL, /* getattrofunc tp_getattro; */ diff --git a/source/blender/python/api2_2x/Text3d.c b/source/blender/python/api2_2x/Text3d.c index 504ca9252c3..0561245b7c4 100644 --- a/source/blender/python/api2_2x/Text3d.c +++ b/source/blender/python/api2_2x/Text3d.c @@ -39,6 +39,7 @@ #include "BKE_library.h" #include "BKE_global.h" #include "BKE_main.h" +#include "BIF_editfont.h" /* do_textedit() */ #include "Curve.h" #include "constant.h" #include "Types.h" @@ -48,7 +49,6 @@ //no prototypes declared in header files - external linkage outside of python extern VFont *get_builtin_font(void); extern void freedisplist(struct ListBase *lb); -extern VFont *get_builtin_font(void); extern VFont *give_vfontpointer(int); extern VFont *exist_vfont(char *str); extern VFont *load_vfont(char *name); @@ -486,29 +486,46 @@ static PyObject *Text3d_setName( BPy_Text3d * self, PyObject * args ) static PyObject *Text3d_setText( BPy_Text3d * self, PyObject * args ) { char *text; - if( !PyArg_ParseTuple( args, "s", &text ) ) - return ( EXPP_ReturnPyObjError( PyExc_AttributeError, - "expected string argument" ) ); - if( self ) { + + if( !PyArg_ParseTuple( args, "s", &text ) ) + return EXPP_ReturnPyObjError( PyExc_AttributeError, + "expected string argument" ); + + /* + * If the text is currently being edited, then we have to put the + * text into the edit buffer. + */ + + if( G.obedit && G.obedit->data == self->curve ) { + short qual = G.qual; + G.qual = 0; /* save key qualifier, then clear it */ + self->curve->pos = self->curve->len = 0; + while ( *text ) + do_textedit( 0, 0, *text++ ); + G.qual = qual; + } else { + short len = (short)strlen(text); MEM_freeN( self->curve->str ); - if(self->curve->strinfo != NULL) - MEM_freeN(self->curve->strinfo); - self->curve->strinfo = MEM_callocN((strlen(text)+1)*sizeof(CharInfo), "strinfo"); - self->curve->str = MEM_mallocN( strlen (text)+1, "str" ); + self->curve->str = MEM_callocN( len+sizeof(wchar_t), "str" ); strcpy( self->curve->str, text ); - self->curve->pos = (short)strlen ( text ); - self->curve->len = (short)strlen ( text ); + self->curve->pos = len; + self->curve->len = len; + + if( self->curve->strinfo ) + MEM_freeN( self->curve->strinfo ); + /* don't know why this is +4, just duplicating load_editText() */ + self->curve->strinfo = MEM_callocN( (len+4) *sizeof(CharInfo), + "strinfo"); } - Py_INCREF( Py_None ); - return Py_None; + Py_RETURN_NONE; } static PyObject *Text3d_getText( BPy_Text3d * self ) { - if ( strlen(self->curve->str) ) - return PyString_FromString (self->curve->str); - else - return Py_None; + if( self->curve->str ) + return PyString_FromString( self->curve->str ); + + Py_RETURN_NONE; } static PyObject* Text3d_getDrawMode(BPy_Text3d* self) diff --git a/source/blender/python/api2_2x/Texture.c b/source/blender/python/api2_2x/Texture.c index 7f576069795..157f2e19cb7 100644 --- a/source/blender/python/api2_2x/Texture.c +++ b/source/blender/python/api2_2x/Texture.c @@ -1341,12 +1341,12 @@ static PyObject *Texture_getExtend( BPy_Texture * self ) static PyObject *Texture_getImage( BPy_Texture * self ) { /* we need this to be an IMAGE texture, and we must have an image */ - if( ( self->texture->type != TEX_IMAGE ) || !self->texture->ima ) { - Py_INCREF( Py_None ); - return Py_None; - } + if( ( self->texture->type == TEX_IMAGE || + self->texture->type == TEX_ENVMAP ) + && self->texture->ima ) + return Image_CreatePyObject( self->texture->ima ); - return Image_CreatePyObject( self->texture->ima ); + Py_RETURN_NONE; } diff --git a/source/blender/python/api2_2x/doc/Mathutils.py b/source/blender/python/api2_2x/doc/Mathutils.py index 5f552a69494..2d4e0a0c092 100644 --- a/source/blender/python/api2_2x/doc/Mathutils.py +++ b/source/blender/python/api2_2x/doc/Mathutils.py @@ -49,7 +49,7 @@ def Intersect(vec1, vec2, vec3, ray, orig, clip=1): @type vec3: Vector object. @param vec3: A 3d vector, one corner of the triangle. @type ray: Vector object. - @param ray: A 3d vector, the orientation of the ray. + @param ray: A 3d vector, the orientation of the ray. the length of the ray is not used, only the direction. @type orig: Vector object. @param orig: A 3d vector, the origin of the ray. @type clip: integer @@ -117,6 +117,7 @@ def LineIntersect(vec1, vec2, vec3, vec4): def CopyVec(vector): """ Create a copy of the Vector object. + @attention: B{DEPRECATED} use Vector(vector) instead. @type vector: Vector object. @param vector: A 2d,3d or 4d vector to be copied. @rtype: Vector object. @@ -148,7 +149,7 @@ def DotVecs(vec1, vec2): def AngleBetweenVecs(vec1, vec2): """ - Return the angle between two vectors. + Return the angle between two vectors. Zero length vectors raise an error. @type vec1: Vector object. @param vec1: A 2d or 3d vector. @type vec2: Vector object. @@ -437,7 +438,9 @@ class Vector: def __init__(list = None): """ - Create a new 2d, 3d, or 4d Vector object from a list of numbers. + Create a new 2d, 3d, or 4d Vector object from a list of floating point numbers. + @note: that python uses higher precission floating point numbers, so values assigned to a vector may have some rounding error. + Example:: v = Vector(1,0,0) @@ -460,7 +463,9 @@ class Vector: def normalize(): """ - Normalize the vector. + Normalize the vector, making the length of the vector always 1.0 + @note: Normalize works for vectors of all sizes, however 4D Vectors w axis is left untouched. + @note: Normalizing a vector where all values are zero results in all axis having a nan value (not a number). @return: a copy of itself """ @@ -481,13 +486,13 @@ class Vector: def resize3D(): """ - Resize the vector to 3d. + Resize the vector to 3d. New axis will be 0.0. @return: a copy of itself """ def resize4D(): """ - Resize the vector to 4d. + Resize the vector to 4d. New axis will be 0.0. @return: a copy of itself """ @@ -630,8 +635,8 @@ class Quaternion: Example:: quat = Quaternion(1,2,3,4) quat = Quaternion(axis, angle) - quat = Quaternion() - quat = Quaternion(180, list) + quat = Quaternion() + quat = Quaternion(180, list) @type list: PyList of int/float @param list: A 3d or 4d list to initialize quaternion. @@ -757,6 +762,7 @@ class Matrix: def identity(): """ Set the matrix to the identity matrix. + An object with zero location and rotation, a scale of 1, will have an identity matrix. @return: a copy of itself """ diff --git a/source/blender/python/api2_2x/gen_utils.c b/source/blender/python/api2_2x/gen_utils.c index 25d3a7912b8..4e42c06d2a8 100644 --- a/source/blender/python/api2_2x/gen_utils.c +++ b/source/blender/python/api2_2x/gen_utils.c @@ -486,10 +486,10 @@ PyObject *EXPP_clearScriptLinks( ScriptLink * slink, PyObject * args ) char *str; str = PyString_AsString ( PySequence_GetItem( seq, i ) ); for ( j = 0 ; j < slink->totscript ; ++j ) { - if ( slink->scripts[j] && !strcmp ( slink->scripts[j]->name+2, str ) ) { + if ( slink->scripts[j] && !strcmp( slink->scripts[j]->name+2, str ) ) slink->scripts[j] = NULL; + if( !slink->scripts[j] ) ++deleted; - } } } } diff --git a/source/blender/python/api2_2x/sceneTimeLine.c b/source/blender/python/api2_2x/sceneTimeLine.c index f1480347e73..58830d28ab4 100644 --- a/source/blender/python/api2_2x/sceneTimeLine.c +++ b/source/blender/python/api2_2x/sceneTimeLine.c @@ -166,34 +166,56 @@ PyObject *M_TimeLine_Get (PyObject *self, PyObject *args) { static PyObject *TimeLine_getFramesMarked (BPy_TimeLine *self, PyObject *args) { - PyObject *marker_list= PyDict_New (); + PyObject *marker_dict= PyDict_New (); TimeMarker *marker_it= NULL; - PyObject *tmarker= NULL; + PyObject *tmarker= NULL, *pyo= NULL; - if (!PyArg_ParseTuple( args, "|O", &tmarker )) + if (!PyArg_ParseTuple (args, "|O", &tmarker)) return EXPP_ReturnPyObjError (PyExc_TypeError, - "expected nothing, or or two ints as arguments."); + "expected nothing, string or int."); if (tmarker) { - int f; + int f= (int)PyInt_AS_LONG (tmarker); char s[64]; - f = PyInt_AsLong (tmarker); - if (PyInt_Check (tmarker) && f != 0) { - for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next) - if (marker_it->frame==f) PyDict_SetItem (marker_list, PyInt_FromLong ((long int)marker_it->frame), PyString_FromString (marker_it->name)); - } - else if (PyString_Check (tmarker) && (BLI_strncpy(s, PyString_AsString (tmarker), 64)) ) { - for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next) - if (!strcmp (marker_it->name, s)) PyDict_SetItem (marker_list, PyInt_FromLong ((long int)marker_it->frame), PyString_FromString (marker_it->name)); - } + if (PyString_Check (tmarker) && (BLI_strncpy (s, PyString_AsString(tmarker), 64)) ) + for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next) + if (!strcmp (marker_it->name, s)) { + f= (int)marker_it->frame; + tmarker= PyInt_FromLong ((long int)marker_it->frame); + break; + } + if (PyInt_Check (tmarker) && f!=0) + for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next) + if (marker_it->frame==f) { + if ((pyo= PyDict_GetItem ((PyObject*)marker_dict, PyInt_FromLong ((long int)marker_it->frame))) ) + PyList_Append (pyo, PyString_FromString (marker_it->name)); + else { + if (!pyo) pyo= PyList_New (0); + PyList_Append (pyo, PyString_FromString (marker_it->name)); + } + + PyDict_SetItem (marker_dict, PyInt_FromLong ((long int)marker_it->frame), pyo); + } } else - for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next) - PyDict_SetItem (marker_list, PyInt_FromLong ((long int)marker_it->frame), PyString_FromString (marker_it->name)); - - return marker_list; + for (marker_it= self->marker_list->first; marker_it; marker_it= marker_it->next) { + if ((pyo= PyDict_GetItem ((PyObject *)marker_dict, PyInt_FromLong ((long int)marker_it->frame))) ) + PyList_Append (pyo, PyString_FromString (marker_it->name)); + else { + pyo= PyList_New (0); + PyList_Append (pyo, PyString_FromString (marker_it->name)); + } + PyDict_SetItem (marker_dict, PyInt_FromLong ((long int)marker_it->frame), pyo); + } + + if (pyo) { /** because warnings messages **/ + Py_DECREF (pyo); + } + + return marker_dict; } + static PyObject *TimeLine_addMarker (BPy_TimeLine *self, PyObject *args) { int frame= 0; TimeMarker *marker= NULL, *marker_it= NULL; diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index f5b14fccaed..68be4cdbb83 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2314,18 +2314,27 @@ void *shadepixel(float x, float y, int z, int facenr, int mask, float *col, floa shi.co[1]= (0.5 + y - 0.5*R.recty)*fy - R.winmat[3][1]/R.winmat[1][1]; /* using a*x + b*y + c*z = d equation, (a b c) is normal */ - shi.co[2]= (dface - shi.facenor[0]*shi.co[0] - shi.facenor[1]*shi.co[1])/shi.facenor[2]; + if(shi.facenor[2]!=0.0f) + shi.co[2]= (dface - shi.facenor[0]*shi.co[0] - shi.facenor[1]*shi.co[1])/shi.facenor[2]; + else + shi.co[2]= 0.0f; zcor= 1.0; // only to prevent not-initialize if(shi.osatex || (R.r.mode & R_SHADOW) ) { shi.dxco[0]= fx; shi.dxco[1]= 0.0; - shi.dxco[2]= (shi.facenor[0]*fx)/shi.facenor[2]; + if(shi.facenor[2]!=0.0f) + shi.dxco[2]= (shi.facenor[0]*fx)/shi.facenor[2]; + else + shi.dxco[2]= 0.0f; shi.dyco[0]= 0.0; shi.dyco[1]= fy; - shi.dyco[2]= (shi.facenor[1]*fy)/shi.facenor[2]; + if(shi.facenor[2]!=0.0f) + shi.dyco[2]= (shi.facenor[1]*fy)/shi.facenor[2]; + else + shi.dyco[2]= 0.0f; } } else { diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 52e71f7cfa8..f186c286aab 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -1027,12 +1027,14 @@ static void modifiers_setOnCage(void *ob_v, void *md_v) Object *ob = ob_v; ModifierData *md; - for (md=ob->modifiers.first; md; md=md->next) - if (md!=md_v) - md->mode &= ~eModifierMode_OnCage; + int i, cageIndex = modifiers_getCageIndex(ob, NULL ); - md = md_v; - md->mode ^= eModifierMode_OnCage; + for( i = 0, md=ob->modifiers.first; md; ++i, md=md->next ) + if( md == md_v ) { + if( i >= cageIndex ) + md->mode ^= eModifierMode_OnCage; + break; + } } static void modifiers_clearHookOffset(void *ob_v, void *md_v) diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index f56aefbeedd..9933a907897 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -34,10 +34,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #ifndef WIN32 #include #else @@ -714,7 +710,7 @@ static char *actuator_name(int type) case ACT_GAME: return "Game"; case ACT_VISIBILITY: - return "Game"; + return "Visibility"; } return "unknown"; } @@ -1444,14 +1440,14 @@ static int get_col_actuator(int type) case ACT_SOUND: return TH_BUT_SETTING2; case ACT_CD: return TH_BUT_NUM; case ACT_CAMERA: return TH_BUT_TEXTFIELD; - case ACT_EDIT_OBJECT: return TH_BUT_POPUP; + case ACT_EDIT_OBJECT: return TH_BUT_POPUP; case ACT_GROUP: return TH_BUT_ACTION; case ACT_RANDOM: return TH_BUT_NEUTRAL; case ACT_SCENE: return TH_BUT_SETTING; case ACT_MESSAGE: return TH_BUT_SETTING1; case ACT_GAME: return TH_BUT_SETTING2; - case ACT_VISIBILITY: return TH_BUT_NUM; - case ACT_CONSTRAINT: return TH_BUT_ACTION; + case ACT_VISIBILITY: return TH_BUT_NUM; + case ACT_CONSTRAINT: return TH_BUT_ACTION; default: return TH_BUT_NEUTRAL; } } diff --git a/source/blender/src/editfont.c b/source/blender/src/editfont.c index b161538423c..e7b65f15f16 100644 --- a/source/blender/src/editfont.c +++ b/source/blender/src/editfont.c @@ -1157,6 +1157,7 @@ void free_editText(void) { if(oldstr) MEM_freeN(oldstr); if(oldstrinfo) MEM_freeN(oldstrinfo); + if(textbuf) MEM_freeN(textbuf); textbuf = oldstr = NULL; textbufinfo = oldstrinfo = NULL; textediting= 0; diff --git a/source/blender/src/editmesh_loop.c b/source/blender/src/editmesh_loop.c index 83d9c6b80ed..e3d910fef10 100644 --- a/source/blender/src/editmesh_loop.c +++ b/source/blender/src/editmesh_loop.c @@ -384,9 +384,9 @@ void CutEdgeloop(int numcuts) /* now cut the loops */ if(smooth){ - fac= 1.0f; - if(fbutton(&fac, 0.0f, 5.0f, 10, 10, "Smooth:")==0) return; - fac= 0.292f*fac; + fac= 1.0f; + if(fbutton(&fac, 0.0f, 5.0f, 10, 10, "Smooth:")==0) return; + fac= 0.292f*fac; esubdivideflag(SELECT,fac,B_SMOOTH,numcuts,SUBDIV_SELECT_INNER_SEL); } else { esubdivideflag(SELECT,0,0,numcuts,SUBDIV_SELECT_INNER_SEL); diff --git a/source/blender/src/outliner.c b/source/blender/src/outliner.c index 077d43d7a5a..4316c4837cf 100644 --- a/source/blender/src/outliner.c +++ b/source/blender/src/outliner.c @@ -2584,8 +2584,12 @@ static void outliner_buttons(uiBlock *block, SpaceOops *soops, ListBase *lb) // signal for button to open addqueue(curarea->win, BUT_ACTIVATE, OL_NAMEBUTTON); + + /* otherwise keeps open on ESC */ + tselem->flag &= ~TSE_TEXTBUT; } - if((tselem->flag & TSE_CLOSED)==0) outliner_buttons(block, soops, &te->subtree); + else + if((tselem->flag & TSE_CLOSED)==0) outliner_buttons(block, soops, &te->subtree); } }