diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2004-07-21 07:19:52 +0400 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2004-07-21 07:19:52 +0400 |
commit | c04bec851cebc017ba6b144b879919fd1f1967a2 (patch) | |
tree | 78c249bf7b75dde60e3f6f56fd16a1a75bf860a9 /source | |
parent | df36d4c8e5ac74a15ceafaa93ad1b62c98a8f9fc (diff) |
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.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/api2_2x/Material.c | 14 | ||||
-rw-r--r-- | source/blender/python/api2_2x/NMesh.c | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Object.c | 10 | ||||
-rw-r--r-- | source/creator/creator.c | 10 |
4 files changed, 16 insertions, 20 deletions
diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c index f5f22948fec..7d24aea776c 100644 --- a/source/blender/python/api2_2x/Material.c +++ b/source/blender/python/api2_2x/Material.c @@ -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) diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c index db32a964443..7036aca2ba4 100644 --- a/source/blender/python/api2_2x/NMesh.c +++ b/source/blender/python/api2_2x/NMesh.c @@ -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"); diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index 784b832f968..d150af636ef 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -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) diff --git a/source/creator/creator.c b/source/creator/creator.c index 63a9c0203fc..3aacfe191f2 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -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; |