Merge from trunk

svn merge -r 15104:15202 https://svn.blender.org/svnroot/bf-blender/trunk/blender
This commit is contained in:
Andre Susano Pinto
2008-06-11 22:53:52 +00:00
parent b5432c6780
commit 39d35edbe6
59 changed files with 3998 additions and 3031 deletions

View File

@@ -1154,13 +1154,17 @@ static void unlink_script( Script * script )
if( sl->spacetype == SPACE_SCRIPT ) {
SpaceScript *sc = ( SpaceScript * ) sl;
if( sc->script == script ) {
if( sc->script == script ) {
sc->script = NULL;
if( sc ==
area->spacedata.first ) {
scrarea_queue_redraw
( area );
if( sc == area->spacedata.first ) {
scrarea_queue_redraw( area );
}
if (sc->but_refs) {
BPy_Set_DrawButtonsList(sc->but_refs);
BPy_Free_DrawButtonsList();
sc->but_refs = NULL;
}
}
}
@@ -1222,7 +1226,7 @@ static int bpy_pydriver_create_dict(void)
{
PyObject *d, *mod;
if (bpy_pydriver_Dict || (G.f&G_DOSCRIPTLINKS)==0) return -1;
if (bpy_pydriver_Dict) return -1;
d = PyDict_New();
if (!d) return -1;
@@ -1259,15 +1263,16 @@ static int bpy_pydriver_create_dict(void)
/* If there's a Blender text called pydrivers.py, import it.
* Users can add their own functions to this module. */
mod = importText("pydrivers"); /* can also use PyImport_Import() */
if (mod) {
PyDict_SetItemString(d, "pydrivers", mod);
PyDict_SetItemString(d, "p", mod);
Py_DECREF(mod);
if (G.f&G_DOSCRIPTLINKS) {
mod = importText("pydrivers"); /* can also use PyImport_Import() */
if (mod) {
PyDict_SetItemString(d, "pydrivers", mod);
PyDict_SetItemString(d, "p", mod);
Py_DECREF(mod);
} else {
PyErr_Clear();
}
}
else
PyErr_Clear();
/* short aliases for some Get() functions: */
/* ob(obname) == Blender.Object.Get(obname) */

View File

@@ -936,6 +936,7 @@ static PyObject *Blender_GetPaths( PyObject * self, PyObject *args, PyObject *ke
PyObject *list = PyList_New(0), *st; /* stupidly big string to be safe */
/* be sure there is low chance of the path being too short */
char filepath_expanded[FILE_MAXDIR*2];
char *lib;
int absolute = 0;
static char *kwlist[] = {"absolute", NULL};
@@ -952,7 +953,12 @@ static PyObject *Blender_GetPaths( PyObject * self, PyObject *args, PyObject *ke
if (absolute) {
BLI_bpathIterator_getPathExpanded( &bpi, filepath_expanded );
} else {
BLI_bpathIterator_getPathExpanded( &bpi, filepath_expanded );
lib = BLI_bpathIterator_getLib( &bpi );
if ( lib && ( strcmp(lib, G.sce) ) ) { /* relative path to the library is NOT the same as our blendfile path, return an absolute path */
BLI_bpathIterator_getPathExpanded( &bpi, filepath_expanded );
} else {
BLI_bpathIterator_getPath( &bpi, filepath_expanded );
}
}
st = PyString_FromString(filepath_expanded);

View File

@@ -360,6 +360,8 @@ static PyObject *Object_getMatrix( BPy_Object * self, PyObject * args );
static PyObject *Object_getParent( BPy_Object * self );
static PyObject *Object_getParentBoneName( BPy_Object * self );
static int Object_setParentBoneName( BPy_Object * self, PyObject * value );
static PyObject *Object_getParentVertexIndex( BPy_Object * self );
static int Object_setParentVertexIndex( BPy_Object * self, PyObject * value );
static PyObject *Object_getSize( BPy_Object * self, PyObject * args );
static PyObject *Object_getTimeOffset( BPy_Object * self );
static PyObject *Object_getTracked( BPy_Object * self );
@@ -1054,10 +1056,12 @@ PyObject *Object_getParticleSys( BPy_Object * self ){
/* fixme: for(;;) */
current = ParticleSys_CreatePyObject( blparticlesys, ob );
PyList_Append(partsyslist,current);
Py_DECREF(current);
while((blparticlesys = blparticlesys->next)){
current = ParticleSys_CreatePyObject( blparticlesys, ob );
PyList_Append(partsyslist,current);
Py_DECREF(current);
}
return partsyslist;
@@ -1491,6 +1495,92 @@ static int Object_setParentBoneName( BPy_Object * self, PyObject *value )
return 0;
}
static PyObject *Object_getParentVertexIndex( BPy_Object * self )
{
PyObject *pyls = NULL;
if( self->object->parent) {
if (self->object->partype==PARVERT1) {
pyls = PyList_New(1);
PyList_SET_ITEM( pyls, 0, PyInt_FromLong( self->object->par1 ));
return pyls;
} else if (self->object->partype==PARVERT3) {
pyls = PyList_New(3);
PyList_SET_ITEM( pyls, 0, PyInt_FromLong( self->object->par1 ));
PyList_SET_ITEM( pyls, 1, PyInt_FromLong( self->object->par2 ));
PyList_SET_ITEM( pyls, 2, PyInt_FromLong( self->object->par3 ));
return pyls;
}
}
return PyList_New(0);
}
static int Object_setParentVertexIndex( BPy_Object * self, PyObject *value )
{
PyObject *item;
int val[3] = {0,0,0};
if( !self->object->parent) {
return EXPP_ReturnIntError( PyExc_RuntimeError,
"This object has no vertex parent, cant set the vertex parent indicies" );
}
if (self->object->partype==PARVERT1) {
if (PySequence_Length(value) != 1)
return EXPP_ReturnIntError( PyExc_RuntimeError,
"Vertex parented to 1 vertex, can only assign a sequence with 1 vertex parent index" );
item = PySequence_GetItem(value, 0);
if (item) {
val[0] = PyInt_AsLong(item);
Py_DECREF(item);
}
} else if (self->object->partype==PARVERT3) {
int i;
if (PySequence_Length(value) != 3)
return EXPP_ReturnIntError( PyExc_RuntimeError,
"Vertex parented to 3 verts, can only assign a sequence with 3 verts parent index" );
for (i=0; i<3; i++) {
item = PySequence_GetItem(value, i);
if (item) {
val[i] = PyInt_AsLong(item);
Py_DECREF(item);
}
}
} else {
return EXPP_ReturnIntError( PyExc_RuntimeError,
"This object has no vertex parent, cant set the vertex parent indicies" );
}
if (PyErr_Occurred()) {
return EXPP_ReturnIntError( PyExc_RuntimeError,
"This object has no vertex parent, cant set the vertex parent indicies" );
} else {
if (self->object->partype==PARVERT1) {
if (val[0] < 0) {
return EXPP_ReturnIntError( PyExc_RuntimeError,
"vertex index less then zero" );
}
self->object->par1 = val[0];
} else if (self->object->partype==PARVERT3) {
if (val[0]==val[1] || val[0]==val[2] || val[1]==val[2]) {
return EXPP_ReturnIntError( PyExc_RuntimeError,
"duplicate indicies in vertex parent assignment" );
}
if (val[0] < 0 || val[1] < 0 || val[2] < 0) {
return EXPP_ReturnIntError( PyExc_RuntimeError,
"vertex index less then zero" );
}
self->object->par1 = val[0];
self->object->par2 = val[1];
self->object->par3 = val[2];
}
}
return 0;
}
static PyObject *Object_getSize( BPy_Object * self, PyObject * args )
{
char *space = "localspace"; /* default to local */
@@ -4916,6 +5006,10 @@ static PyGetSetDef BPy_Object_getseters[] = {
(getter)Object_getParentBoneName, (setter)Object_setParentBoneName,
"The object's parent object's sub name",
NULL},
{"parentVertexIndex",
(getter)Object_getParentVertexIndex, (setter)Object_setParentVertexIndex,
"Indicies used for vertex parents",
NULL},
{"track",
(getter)Object_getTracked, (setter)Object_setTracked,
"The object's tracked object",

View File

@@ -854,7 +854,7 @@ static PyObject *Part_GetLoc( BPy_PartSys * self, PyObject * args ){
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Couldn't append item to PyList" );
}
Py_DECREF(loc); /* PyList_Append increfs */
path++;
}
@@ -864,6 +864,7 @@ static PyObject *Part_GetLoc( BPy_PartSys * self, PyObject * args ){
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Couldn't append item to PyList" );
}
Py_DECREF(seglist); /* PyList_Append increfs */
}
cache=psys->childcache;
@@ -885,7 +886,7 @@ static PyObject *Part_GetLoc( BPy_PartSys * self, PyObject * args ){
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Couldn't append item to PyList" );
}
Py_DECREF(loc);/* PyList_Append increfs */
path++;
}
@@ -895,6 +896,7 @@ static PyObject *Part_GetLoc( BPy_PartSys * self, PyObject * args ){
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Couldn't append item to PyList" );
}
Py_DECREF(seglist); /* PyList_Append increfs */
}
} else {
@@ -933,6 +935,7 @@ static PyObject *Part_GetLoc( BPy_PartSys * self, PyObject * args ){
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Couldn't append item to PyList" );
}
Py_DECREF(loc);/* PyList_Append increfs */
}
else {
if ( all ){
@@ -941,6 +944,7 @@ static PyObject *Part_GetLoc( BPy_PartSys * self, PyObject * args ){
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Couldn't append item to PyList" );
}
Py_DECREF(Py_None); /* PyList_Append increfs */
}
}
}
@@ -985,6 +989,7 @@ static PyObject *Part_GetRot( BPy_PartSys * self, PyObject * args ){
if(psys_get_particle_state(ob,psys,i,&state,0)==0){
if ( all ){
PyList_Append(partlist,Py_None);
Py_DECREF(Py_None); /* PyList_Append increfs */
continue;
} else {
continue;
@@ -1001,6 +1006,7 @@ static PyObject *Part_GetRot( BPy_PartSys * self, PyObject * args ){
if (id)
PyTuple_SetItem(loc,4,PyInt_FromLong(i));
PyList_Append(partlist,loc);
Py_DECREF(loc); /* PyList_Append increfs */
}
}
return partlist;
@@ -1060,9 +1066,11 @@ static PyObject *Part_GetSize( BPy_PartSys * self, PyObject * args ){
PyTuple_SetItem(tuple,0,PyFloat_FromDouble((double)size));
PyTuple_SetItem(tuple,1,PyInt_FromLong(i));
PyList_Append(partlist,tuple);
Py_DECREF(tuple);
} else {
siz = PyFloat_FromDouble((double)size);
PyList_Append(partlist,siz);
Py_DECREF(siz);
}
}
}
@@ -1125,9 +1133,11 @@ static PyObject *Part_GetAge( BPy_PartSys * self, PyObject * args ){
PyTuple_SetItem(tuple,0,PyFloat_FromDouble((double)life));
PyTuple_SetItem(tuple,1,PyInt_FromLong(i));
PyList_Append(partlist,tuple);
Py_DECREF(tuple);
} else {
lif = PyFloat_FromDouble((double)life);
PyList_Append(partlist,lif);
Py_DECREF(lif);
}
}
}

View File

@@ -406,11 +406,12 @@ static PyObject *M_sys_cleanpath( PyObject * self, PyObject * value )
{
char *path = PyString_AsString(value);
char cleaned[FILE_MAXDIR + FILE_MAXFILE];
int trailing_slash = 0;
int trailing_slash = 0, last;
if (!path)
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" );
if (strstr(path, "/") || strstr(path, "\\")) {
last = strlen(path)-1;
if ((last >= 0) && ((path[last]=='/') || (path[last]=='\\'))) {
trailing_slash = 1;
}
BLI_strncpy(cleaned, path, FILE_MAXDIR + FILE_MAXFILE);

View File

@@ -389,6 +389,8 @@ class Object:
@ivar parentbonename: The string name of the parent bone (if defined).
This can be set to another bone in the armature if the object already has a bone parent.
@type parentbonename: string or None
@ivar parentVertexIndex: A list of vertex parent indicies, with a length of 0, 1 or 3. When there are 1 or 3 vertex parents, the indicies can be assigned to a sequence of the same length.
@type parentVertexIndex: list
@ivar protectFlags: The "transform locking" bitfield flags for the object.
See L{ProtectFlags} const dict for values.
@type protectFlags: int

View File

@@ -2048,7 +2048,7 @@ static int RenderData_setIValueAttrClamp( BPy_RenderData *self, PyObject *value,
break;
case EXPP_RENDER_ATTR_BAKEMODE:
min = RE_BAKE_LIGHT;
max = RE_BAKE_DISPLACEMENT;
max = RE_BAKE_SHADOW;
size = 'h';
param = &self->renderContext->bake_mode;
break;
@@ -3781,6 +3781,7 @@ static PyObject *M_Render_BakeModesDict( void )
PyConstant_Insert( d, "NORMALS", PyInt_FromLong( RE_BAKE_NORMALS ) );
PyConstant_Insert( d, "TEXTURE", PyInt_FromLong( RE_BAKE_TEXTURE ) );
PyConstant_Insert( d, "DISPLACEMENT", PyInt_FromLong( RE_BAKE_DISPLACEMENT ) );
PyConstant_Insert( d, "SHADOW", PyInt_FromLong( RE_BAKE_SHADOW ) );
}
return M;
}