creator.c wasn't updated in my last commit, here it is (the change reverts my previous change to it, since it was made unnecessary by handling onload scriptlinks a little differently, as can be checked in blender.c and editscreen.c).
- BPython: finishing object and nmesh .setMaterials commit, fixing two bugs. Also fixed a crash with object.track (pointer wasn't checked for validity). All based on reports and patch by Yann Vernier, thanks again.
This commit is contained in:
@@ -1835,26 +1835,26 @@ int EXPP_synchronizeMaterialLists (Object *object)
|
||||
{
|
||||
Material *** p_dataMaterials = give_matarar (object);
|
||||
short * nmaterials = give_totcolp (object);
|
||||
int result = 0;
|
||||
|
||||
if (object->totcol > *nmaterials) {
|
||||
/* More object mats than data mats */
|
||||
*nmaterials = object->totcol;
|
||||
return expandPtrArray ((void *) p_dataMaterials,
|
||||
result = expandPtrArray ((void *) p_dataMaterials,
|
||||
*nmaterials,
|
||||
object->totcol);
|
||||
*nmaterials = object->totcol;
|
||||
}
|
||||
else {
|
||||
if (object->totcol < *nmaterials) {
|
||||
/* More data mats than object mats */
|
||||
object->totcol = *nmaterials;
|
||||
return expandPtrArray ((void *) &object->mat,
|
||||
result = expandPtrArray ((void *) &object->mat,
|
||||
object->totcol,
|
||||
*nmaterials);
|
||||
object->totcol = *nmaterials;
|
||||
}
|
||||
}
|
||||
} /* else no synchronization needed, they are of equal length */
|
||||
|
||||
/* No synchronization is needed; they're of equal length */
|
||||
return 1;
|
||||
return result; /* 1 if changed, 0 otherwise */
|
||||
}
|
||||
|
||||
void EXPP_incr_mats_us (Material **matlist, int len)
|
||||
|
||||
@@ -818,7 +818,7 @@ static PyObject *NMesh_setMaterials (PyObject *self, PyObject *args)
|
||||
BPy_NMesh *me = (BPy_NMesh *)self;
|
||||
PyObject *pymats = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "O!", &PyList_Type, pymats))
|
||||
if (!PyArg_ParseTuple (args, "O!", &PyList_Type, &pymats))
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"expected a list of materials (None's also accepted) as argument");
|
||||
|
||||
|
||||
@@ -1570,21 +1570,21 @@ static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args)
|
||||
if ((len < 0) || (len > MAXMAT))
|
||||
{
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"illegal material index!"));
|
||||
"material list should have at least 1, at most 16 entries"));
|
||||
}
|
||||
|
||||
if (self->object->mat)
|
||||
{
|
||||
EXPP_releaseMaterialList (self->object->mat, len);
|
||||
EXPP_releaseMaterialList (self->object->mat, self->object->totcol);
|
||||
}
|
||||
/* Increase the user count on all materials */
|
||||
for (i=0 ; i<len ; i++)
|
||||
{
|
||||
id_us_plus ((ID *) matlist[i]);
|
||||
if (matlist[i]) id_us_plus ((ID *) matlist[i]);
|
||||
}
|
||||
self->object->mat = matlist;
|
||||
self->object->totcol = len;
|
||||
self->object->actcol = -1;
|
||||
self->object->actcol = len;
|
||||
|
||||
switch (self->object->type)
|
||||
{
|
||||
@@ -1993,6 +1993,8 @@ PyObject* Object_CreatePyObject (struct Object *obj)
|
||||
{
|
||||
BPy_Object * blen_object;
|
||||
|
||||
if (!obj) return EXPP_incr_ret (Py_None);
|
||||
|
||||
blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);
|
||||
|
||||
if (blen_object == NULL)
|
||||
|
||||
@@ -197,7 +197,6 @@ int main(int argc, char **argv)
|
||||
int a, i, stax, stay, sizx, sizy;
|
||||
SYS_SystemHandle syshandle;
|
||||
Scene *sce;
|
||||
short onload_script = 0;
|
||||
|
||||
#if defined(WIN32) || defined (__linux__)
|
||||
int audio = 1;
|
||||
@@ -257,7 +256,7 @@ int main(int argc, char **argv)
|
||||
|
||||
/* first test for background */
|
||||
|
||||
onload_script = 1; /* scenescript always set! */
|
||||
G.f |= G_SCENESCRIPT; /* scenescript always set! */
|
||||
|
||||
for(a=1; a<argc; a++) {
|
||||
|
||||
@@ -294,7 +293,7 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
onload_script = 0;
|
||||
G.f &= ~G_SCENESCRIPT;
|
||||
break;
|
||||
|
||||
case 'Y':
|
||||
@@ -576,11 +575,6 @@ int main(int argc, char **argv)
|
||||
set_scene(sce);
|
||||
}
|
||||
|
||||
/* We set the ONLOAD script global flag here, when the screen has already
|
||||
* been set and the rendering context initialized. If there's an onload
|
||||
* script it will be executed in screenmain. */
|
||||
if (onload_script) G.f |= G_SCENESCRIPT;
|
||||
|
||||
screenmain();
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user