merge with trunk at r31523
[blender.git] / source / blender / render / intern / source / pointdensity.c
index 4f23df3c18cafb915e50a44942137f05fa78ce14..67f1fee4f41d5420a3cd1f39e32bfdf50171f8ac 100644 (file)
@@ -226,6 +226,9 @@ static void pointdensity_cache_object(Render *re, PointDensity *pd, Object *ob)
 static void cache_pointdensity(Render *re, Tex *tex)
 {
        PointDensity *pd = tex->pd;
+       
+       if(!pd)
+               return;
 
        if (pd->point_tree) {
                BLI_bvhtree_free(pd->point_tree);
@@ -279,7 +282,7 @@ void make_pointdensities(Render *re)
        re->i.infostr= "Caching Point Densities";
        re->stats_draw(re->sdh, &re->i);
 
-       for (tex= G.main->tex.first; tex; tex= tex->id.next) {
+       for (tex= re->main->tex.first; tex; tex= tex->id.next) {
                if(tex->id.us && tex->type==TEX_POINTDENSITY) {
                        cache_pointdensity(re, tex);
                }
@@ -296,7 +299,7 @@ void free_pointdensities(Render *re)
        if(re->scene->r.scemode & R_PREVIEWBUTS)
                return;
        
-       for (tex= G.main->tex.first; tex; tex= tex->id.next) {
+       for (tex= re->main->tex.first; tex; tex= tex->id.next) {
                if(tex->id.us && tex->type==TEX_POINTDENSITY) {
                        free_pointdensity(re, tex);
                }