Fix for bug #17580: crash rendering instanced objects with
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 9 Sep 2008 14:16:54 +0000 (14:16 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 9 Sep 2008 14:16:54 +0000 (14:16 +0000)
halo material attach to the object instead of the mesh.

Also for bug #13489: avoid a crash rendering with invalid
active vcol layer, most likely caused by a bug that was
already fixed.

source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/renderdatabase.c

index 9ee6f873f3f441477d0fcd56b0b89b0eb3e00bf6..322d2066a6cc5fea220af68447692a16e703aa0a 100644 (file)
@@ -4578,17 +4578,19 @@ static int allow_render_object(Object *ob, int nolamps, int onlyselected, Object
 static int allow_render_dupli_instance(Render *re, DupliObject *dob, Object *obd)
 {
        ParticleSystem *psys;
-       Material ***material;
+       Material *ma;
        short a, *totmaterial;
 
-       /* don't allow objects with halos */
+       /* don't allow objects with halos. we need to have
+        * all halo's to sort them globally in advance */
        totmaterial= give_totcolp(obd);
-       material= give_matarar(obd);
 
-       if(totmaterial && material) {
-               for(a= 0; a<*totmaterial; a++)
-                       if((*material)[a] && (*material)[a]->mode & MA_HALO)
+       if(totmaterial) {
+               for(a= 0; a<*totmaterial; a++) {
+                       ma= give_current_material(obd, a);
+                       if(ma && (ma->mode & MA_HALO))
                                return 0;
+               }
        }
 
        for(psys=obd->particlesystem.first; psys; psys=psys->next)
index 98b1426e8ff2a6b41c3aba19295ff0818b95575e..d44b49cc7065a812d603db7928141e2f247235b9 100644 (file)
@@ -483,16 +483,16 @@ void RE_set_customdata_names(ObjectRen *obr, CustomData *data)
           DerivedMesh which stores the layers is freed */
        
        CustomDataLayer *layer;
-       int numlayers, i, mtfn, mcn;
+       int numtf = 0, numcol = 0, i, mtfn, mcn;
 
        if (CustomData_has_layer(data, CD_MTFACE)) {
-               numlayers= CustomData_number_of_layers(data, CD_MTFACE);
-               obr->mtface= MEM_callocN(sizeof(*obr->mtface)*numlayers, "mtfacenames");
+               numtf= CustomData_number_of_layers(data, CD_MTFACE);
+               obr->mtface= MEM_callocN(sizeof(*obr->mtface)*numtf, "mtfacenames");
        }
 
        if (CustomData_has_layer(data, CD_MCOL)) {
-               numlayers= CustomData_number_of_layers(data, CD_MCOL);
-               obr->mcol= MEM_callocN(sizeof(*obr->mcol)*numlayers, "mcolnames");
+               numcol= CustomData_number_of_layers(data, CD_MCOL);
+               obr->mcol= MEM_callocN(sizeof(*obr->mcol)*numcol, "mcolnames");
        }
 
        for (i=0, mtfn=0, mcn=0; i < data->totlayer; i++) {
@@ -500,12 +500,12 @@ void RE_set_customdata_names(ObjectRen *obr, CustomData *data)
 
                if (layer->type == CD_MTFACE) {
                        strcpy(obr->mtface[mtfn++], layer->name);
-                       obr->actmtface= layer->active_rnd;
+                       obr->actmtface= CLAMPIS(layer->active_rnd, 0, numtf);
                        obr->bakemtface= layer->active;
                }
                else if (layer->type == CD_MCOL) {
                        strcpy(obr->mcol[mcn++], layer->name);
-                       obr->actmcol= layer->active_rnd;
+                       obr->actmcol= CLAMPIS(layer->active_rnd, 0, numcol);
                }
        }
 }