creator.c wasn't updated in my last commit, here it is (the change reverts my previou...
authorWillian Padovani Germano <wpgermano@gmail.com>
Wed, 21 Jul 2004 03:19:52 +0000 (03:19 +0000)
committerWillian Padovani Germano <wpgermano@gmail.com>
Wed, 21 Jul 2004 03:19:52 +0000 (03:19 +0000)
- 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.

source/blender/python/api2_2x/Material.c
source/blender/python/api2_2x/NMesh.c
source/blender/python/api2_2x/Object.c
source/creator/creator.c

index f5f22948fec38aa0f0b136ca6d49848f47ad4b3d..7d24aea776c9b92a2dc2da5668edebbebf32a836 100644 (file)
@@ -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)
index db32a964443ef6a0dd00287ee18164183dbde789..7036aca2ba46cc45b2937ffd95ddcba3948e4692 100644 (file)
@@ -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");
 
index 784b832f968585004c8da0adc6df5774bf33ae02..d150af636ef5995caf5925da2a2ade99bd791699 100644 (file)
@@ -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)
index 63a9c0203fc103f1a22e963f86462befc536d201..3aacfe191f2b37901e31aea9792e13ed43c4503e 100644 (file)
@@ -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;