soc-2008-mxcurioni: merged changes to revision 15163
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -613,6 +613,8 @@ static void exit_pydraw( SpaceScript * sc, short err )
|
||||
PyErr_Print( );
|
||||
script->flags = 0; /* mark script struct for deletion */
|
||||
SCRIPT_SET_NULL(script);
|
||||
script->scriptname[0] = '\0';
|
||||
script->scriptarg[0] = '\0';
|
||||
error_pyscript();
|
||||
scrarea_queue_redraw( sc->area );
|
||||
}
|
||||
|
||||
@@ -1179,7 +1179,7 @@ static PyGetSetDef BPy_Material_getseters[] = {
|
||||
{"sssRadiusBlue",
|
||||
(getter)Material_getSssRadius, (setter)Material_setSssRadius,
|
||||
"Mean red scattering path length",
|
||||
(void *) 0},
|
||||
(void *) 2},
|
||||
{"sssIOR",
|
||||
(getter)Material_getSssIOR, (setter)Material_setSssIOR,
|
||||
"index of refraction",
|
||||
@@ -1196,7 +1196,7 @@ static PyGetSetDef BPy_Material_getseters[] = {
|
||||
(getter)Material_getSssTexScatter, (setter)Material_setSssTexScatter,
|
||||
"Texture scattering factor",
|
||||
NULL},
|
||||
{"sssFont",
|
||||
{"sssFront",
|
||||
(getter)Material_getSssFront, (setter)Material_setSssFront,
|
||||
"Front scattering weight",
|
||||
NULL},
|
||||
|
||||
@@ -848,7 +848,7 @@ static int Sockoutmap_assign_subscript(BPy_SockMap *self, PyObject *pyidx, PyObj
|
||||
|
||||
if (PyInt_Check(pyidx)) {
|
||||
idx = (int)PyInt_AsLong(pyidx);
|
||||
if (idx < 0 || idx >= Sockinmap_len(self))
|
||||
if (idx < 0 || idx >= Sockoutmap_len(self))
|
||||
return EXPP_ReturnIntError(PyExc_IndexError, "index out of range");
|
||||
}
|
||||
else if (PyString_Check(pyidx)) {
|
||||
|
||||
@@ -341,6 +341,7 @@ static int setupPI(Object* ob);
|
||||
|
||||
static PyObject *Object_getParticleSys( BPy_Object * self );
|
||||
/* fixme Object_newParticleSys( self, default-partsys-name ) */
|
||||
static PyObject *Object_addVertexGroupsFromArmature( BPy_Object * self, PyObject * args);
|
||||
static PyObject *Object_newParticleSys( BPy_Object * self );
|
||||
static PyObject *Object_buildParts( BPy_Object * self );
|
||||
static PyObject *Object_clearIpo( BPy_Object * self );
|
||||
@@ -359,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 );
|
||||
@@ -475,6 +478,8 @@ static PyMethodDef BPy_Object_methods[] = {
|
||||
"Return a list of particle systems"},
|
||||
{"newParticleSystem", ( PyCFunction ) Object_newParticleSys, METH_NOARGS,
|
||||
"Create and link a new particle system"},
|
||||
{"addVertexGroupsFromArmature" , ( PyCFunction ) Object_addVertexGroupsFromArmature, METH_VARARGS,
|
||||
"Add vertex groups from armature using the bone heat method"},
|
||||
{"buildParts", ( PyCFunction ) Object_buildParts, METH_NOARGS,
|
||||
"Recalcs particle system (if any), (depricated, will always return an empty list in version 2.46)"},
|
||||
{"getIpo", ( PyCFunction ) Object_getIpo, METH_NOARGS,
|
||||
@@ -1051,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;
|
||||
@@ -1109,6 +1116,42 @@ PyObject *Object_newParticleSys( BPy_Object * self ){
|
||||
return ParticleSys_CreatePyObject(rpsys,ob);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* attribute: addVertexGroupsFromArmature */
|
||||
/* Description: evaluate and add vertex groups to the current object */
|
||||
/* for each bone of the selected armature */
|
||||
/* Data: self Object, Bpy armature */
|
||||
/* Return: nothing */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Object_addVertexGroupsFromArmature( BPy_Object * self, PyObject * args)
|
||||
{
|
||||
|
||||
Object *ob = self->object;
|
||||
BPy_Object *arm;
|
||||
|
||||
if( ob->type != OB_MESH )
|
||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"Only useable on Mesh type Objects" );
|
||||
|
||||
if( G.obedit != NULL)
|
||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"Not useable when inside edit mode" );
|
||||
|
||||
/* Check if the arguments passed to makeParent are valid. */
|
||||
if( !PyArg_ParseTuple( args, "O!",&Object_Type, &arm ) )
|
||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"An armature object is expected." );
|
||||
|
||||
if( arm->object->type != OB_ARMATURE )
|
||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"An armature object is expected." );
|
||||
|
||||
add_verts_to_dgroups(ob, arm->object, 1, 0);
|
||||
ob->recalc |= OB_RECALC_OB;
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *Object_buildParts( BPy_Object * self )
|
||||
{
|
||||
/* This is now handles by modifiers */
|
||||
@@ -1452,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 */
|
||||
@@ -4877,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",
|
||||
|
||||
@@ -828,7 +828,7 @@ static PyObject *Part_GetLoc( BPy_PartSys * self, PyObject * args ){
|
||||
/* little hack to calculate hair steps in render mode */
|
||||
psys->renderdata = (void*)(int)1;
|
||||
|
||||
psys_cache_paths(ob, psys, cfra, 0);
|
||||
psys_cache_paths(ob, psys, cfra, 1);
|
||||
|
||||
psys->renderdata = NULL;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1355,16 +1355,29 @@ static PyObject *SceneObSeq_item( BPy_SceneObSeq * self, int i )
|
||||
for (base= scene->base.first; base && i!=index; base= base->next, index++) {}
|
||||
/* selected */
|
||||
else if (self->mode==EXPP_OBSEQ_SELECTED) {
|
||||
for (base= scene->base.first; base && i!=index; base= base->next)
|
||||
if (base->flag & SELECT)
|
||||
index++;
|
||||
for (base= scene->base.first; base; base= base->next) {
|
||||
if (base->flag & SELECT) {
|
||||
if (i==index) {
|
||||
break;
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* context */
|
||||
else if (self->mode==EXPP_OBSEQ_CONTEXT) {
|
||||
if (G.vd)
|
||||
for (base= scene->base.first; base && i!=index; base= base->next)
|
||||
if TESTBASE(base)
|
||||
index++;
|
||||
if (G.vd) {
|
||||
for (base= scene->base.first; base; base= base->next) {
|
||||
if (TESTBASE(base)) {
|
||||
if (i==index) {
|
||||
break;
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!(base))
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
@@ -651,6 +653,13 @@ class Object:
|
||||
Link a new particle system (see Blender.Particle).
|
||||
"""
|
||||
|
||||
def addVertexGroupsFromArmature(object):
|
||||
"""
|
||||
Add vertex groups from armature using the bone heat method
|
||||
This method can be only used with an Object of the type Mesh when NOT in edit mode.
|
||||
@type object: a bpy armature
|
||||
"""
|
||||
|
||||
def buildParts():
|
||||
"""
|
||||
Recomputes the particle system. This method only applies to an Object of
|
||||
|
||||
@@ -478,9 +478,11 @@ PyObject *RenderData_Render( BPy_RenderData * self )
|
||||
}
|
||||
|
||||
else { /* background mode (blender -b file.blend -P script) */
|
||||
Render *re= RE_NewRender("Render");
|
||||
Render *re= RE_NewRender(G.scene->id.name);
|
||||
|
||||
int end_frame = G.scene->r.efra; /* is of type short currently */
|
||||
|
||||
|
||||
int end_frame = G.scene->r.efra;
|
||||
|
||||
if (G.scene != self->scene)
|
||||
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
@@ -490,7 +492,7 @@ PyObject *RenderData_Render( BPy_RenderData * self )
|
||||
|
||||
RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
|
||||
|
||||
G.scene->r.efra = (short)end_frame;
|
||||
G.scene->r.efra = end_frame;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
@@ -571,7 +573,7 @@ PyObject *RenderData_RenderAnim( BPy_RenderData * self )
|
||||
set_scene( oldsce );
|
||||
}
|
||||
else { /* background mode (blender -b file.blend -P script) */
|
||||
Render *re= RE_NewRender("Render");
|
||||
Render *re= RE_NewRender(G.scene->id.name);
|
||||
|
||||
if (G.scene != self->scene)
|
||||
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
@@ -2048,7 +2050,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 +3783,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user