[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16305] branches/soc-2008-unclezeiv/source /blender/render/intern/source/lightcuts.c: Fixed several memory-related bugs introduced by previous commit.
Davide Vercelli
davide.vercelli at gmail.com
Sat Aug 30 01:57:04 CEST 2008
Revision: 16305
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16305
Author: unclezeiv
Date: 2008-08-30 01:57:04 +0200 (Sat, 30 Aug 2008)
Log Message:
-----------
Fixed several memory-related bugs introduced by previous commit.
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-08-29 20:09:25 UTC (rev 16304)
+++ branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c 2008-08-29 23:57:04 UTC (rev 16305)
@@ -985,10 +985,8 @@
add_virtual_point_light(re, lcd, lar, col, lev);
}
- if (lcd->do_indir > 0 && (lcd->options & LC_OPT_ONLY_INDIR)) {
- lamp_delete(lar);
+ if (lcd->do_indir > 0 && (lcd->options & LC_OPT_ONLY_INDIR))
continue;
- }
lcd->pointlights[lcd->light_counter++]= lar;
lcd->trees[TREE_SUN].counter++;
@@ -1532,10 +1530,8 @@
add_virtual_point_light(re, lcd, lar, col, lev);
}
- if (lcd->do_indir > 0 && (lcd->options & LC_OPT_ONLY_INDIR)) {
- lamp_delete(lar);
+ if (lcd->do_indir > 0 && (lcd->options & LC_OPT_ONLY_INDIR))
continue;
- }
lcd->pointlights[lcd->light_counter++]= lar;
lcd->trees[TREE_SPOT].counter++;
@@ -1601,8 +1597,9 @@
{
int n_orig= 0;
+ int n_area= 0;
int n_vpl= 0;
- int n_generated= re->r.lightcuts_area_lights + re->r.lightcuts_env_map;
+ int n_generated= 0;
for(go=lights->first; go; go= go->next) {
lar= go->lampren;
@@ -1610,8 +1607,17 @@
if (ELEM3(lar->type, LA_LOCAL, LA_SUN, LA_SPOT))
n_orig++;
+
+ if (lar->type == LA_AREA)
+ n_area++;
}
+ if (n_area)
+ n_generated+= re->r.lightcuts_area_lights;
+
+ if (lcd->options & LC_OPT_ENV_LIGHT)
+ n_generated+= re->r.lightcuts_env_map;
+
if (lcd->do_indir > 0) {
n_vpl= (n_orig + n_generated) * lcd->do_indir;
@@ -1625,9 +1631,11 @@
n_generated+= n_vpl;
}
- /* here we create our (conservative) arrays for holding LampRens and pointers to them */
- lcd->pointlights= MEM_callocN(sizeof(LampRen*) * n_generated, "lc_pointlights");
- lcd->lampren_pool= MEM_callocN(sizeof(LampRen) * n_generated, "lc_lampren_pool");
+ if (n_generated > 0) {
+ /* here we create our (conservative) arrays for holding LampRens and pointers to them */
+ lcd->lampren_pool= MEM_callocN(sizeof(LampRen) * n_generated, "lc_lampren_pool");
+ }
+ lcd->pointlights= MEM_callocN(sizeof(LampRen*) * (n_orig + n_generated), "lc_pointlights");
}
/* TODO: we could do some form of importance sampling here */
@@ -2432,7 +2440,8 @@
MEM_freeN(lcd->trees[i].array);
for (i= 0; i < lcd->pool_counter; i++)
lamp_delete(&lcd->lampren_pool[i]);
- MEM_freeN(lcd->lampren_pool);
+ if (lcd->lampren_pool)
+ MEM_freeN(lcd->lampren_pool);
MEM_freeN(lcd->pointlights);
MEM_freeN(lcd->cut_nodes);
if (lcd->dbg_vis_vpl)
More information about the Bf-blender-cvs
mailing list