Fix render baking crashing on windows/mac. Problem was increased
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 9 Mar 2010 16:34:28 +0000 (16:34 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 9 Mar 2010 16:34:28 +0000 (16:34 +0000)
max number of threads caused Blender to run out of stack space,
now just does dynamic allocation.

source/blender/render/intern/source/rendercore.c

index 9afd750..52dee6b 100644 (file)
@@ -2627,7 +2627,7 @@ static void *do_bake_thread(void *bs_v)
 /* returns 0 if nothing was handled */
 int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_update)
 {
-       BakeShade handles[BLENDER_MAX_THREADS];
+       BakeShade *handles;
        ListBase threads;
        Image *ima;
        int a, vdone=0, usemask=0;
@@ -2653,11 +2653,11 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up
        
        BLI_init_threads(&threads, do_bake_thread, re->r.threads);
 
+       handles= MEM_callocN(sizeof(BakeShade)*re->r.threads, "BakeShade");
+
        /* get the threads running */
        for(a=0; a<re->r.threads; a++) {
                /* set defaults in handles */
-               memset(&handles[a], 0, sizeof(BakeShade));
-               
                handles[a].ssamp.shi[0].lay= re->scene->lay;
                
                if (type==RE_BAKE_SHADOW) {
@@ -2737,8 +2737,11 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up
                zbuf_free_span(handles[a].zspan);
                MEM_freeN(handles[a].zspan);
        }
+
+       MEM_freeN(handles);
        
        BLI_end_threads(&threads);
+
        return vdone;
 }