Revision: 15224
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15224
Author:   unclezeiv
Date:     2008-06-14 20:46:39 +0200 (Sat, 14 Jun 2008)

Log Message:
-----------
bugfix: crashed when rendering with lightcuts enabled and no lights (thanks 
marioamb)

Modified Paths:
--------------
    branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c

Modified: 
branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c
===================================================================
--- branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c 
2008-06-14 18:13:02 UTC (rev 15223)
+++ branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c 
2008-06-14 18:46:39 UTC (rev 15224)
@@ -487,11 +487,8 @@
        lcd->error_rate= re->r.lightcuts_max_error;
        lcd->max_cut= MIN2(re->r.lightcuts_max_cut, lcd->light_counter);
        
-       /* TODO: look for a better error condition in case we have no lights */
-       if (pointlights->first) {
-               lightcuts_fill_array(lcd, pointlights);
-               lightcuts_build_tree(lcd);
-       }
+       lightcuts_fill_array(lcd, pointlights);
+       lightcuts_build_tree(lcd);
        
        lcd->cut_nodes_size= (lcd->max_lights * 2 + 1);
        lcd->cut_nodes= MEM_callocN(sizeof(CutNode) * lcd->cut_nodes_size * 
re->r.threads, "cut_nodes");
@@ -632,34 +629,36 @@
                CutNode *root= &cut_nodes[0];
                LightcutsCluster *clus= &lcd->array_local[lcd->root_local];
                
-               root->id= lcd->root_local;
-               root->error_bound= calc_geometric_eb(lcd, lcd->root_local, 
shi->co) * calc_material_eb(tsm, clus) * shi->refl;
+               if (lcd->light_counter > 0) {
+                       root->id= lcd->root_local;
+                       root->error_bound= calc_geometric_eb(lcd, 
lcd->root_local, shi->co) * calc_material_eb(tsm, clus) * shi->refl;
 #ifdef LIGHTCUTS_DEBUG
-               dbg_convert[lcd->root_local]= 0;
+                       dbg_convert[lcd->root_local]= 0;
 #endif
-               if (root->error_bound > FLT_EPSILON) {
-                       get_contrib(clus->lar, shi, &i, &i_noshad);
-                       lcd->stat_rays_shot++;
-                       root->contr_factor= MAX2(i, 0.0f);
-                       root->f_clus= root->contr_factor * clus->intensity;
-                       VECADDFAC(totest, totest, clus->col, root->f_clus);
-               
-                       if(shi->passflag & (SCE_PASS_DIFFUSE|SCE_PASS_SHADOW)) {
-                               root->contr_factor_noshad= MAX2(i_noshad, 0.0f);
-                               root->f_clus_noshad= root->contr_factor_noshad 
* clus->intensity;
-                               VECADDFAC(totest_noshad, totest_noshad, 
clus->col, root->f_clus_noshad);
-                       }
+                       if (root->error_bound > FLT_EPSILON) {
+                               get_contrib(clus->lar, shi, &i, &i_noshad);
+                               lcd->stat_rays_shot++;
+                               root->contr_factor= MAX2(i, 0.0f);
+                               root->f_clus= root->contr_factor * 
clus->intensity;
+                               VECADDFAC(totest, totest, clus->col, 
root->f_clus);
+                       
+                               if(shi->passflag & 
(SCE_PASS_DIFFUSE|SCE_PASS_SHADOW)) {
+                                       root->contr_factor_noshad= 
MAX2(i_noshad, 0.0f);
+                                       root->f_clus_noshad= 
root->contr_factor_noshad * clus->intensity;
+                                       VECADDFAC(totest_noshad, totest_noshad, 
clus->col, root->f_clus_noshad);
+                               }
 #ifdef LIGHTCUTS_DEBUG
-                       dbg_totlum= root->contr_factor * clus->luminance;
+                               dbg_totlum= root->contr_factor * 
clus->luminance;
 #endif
-               
-                       if (!IS_LEAF(clus))
-                               BLI_heap_insert(cut, -root->error_bound * 
clus->luminance, root);
+                       
+                               if (!IS_LEAF(clus))
+                                       BLI_heap_insert(cut, -root->error_bound 
* clus->luminance, root);
+                               else
+                                       used++;
+                       }
                        else
                                used++;
                }
-               else
-                       used++;
        }
        
        /* at each iteration the heap may grow by one, but we have a maximum 
size */


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to