copying texture point density was using inline dupalloc rather then BKE_copy_pointden...
authorCampbell Barton <ideasman42@gmail.com>
Sun, 1 May 2011 05:51:21 +0000 (05:51 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 1 May 2011 05:51:21 +0000 (05:51 +0000)
source/blender/blenkernel/intern/texture.c

index c518403d6631d541bf5d825ec885c9c8057c80ef..866874ee5c86b5acc2fadabb0dcf4b7039bf4a8c 100644 (file)
@@ -486,10 +486,7 @@ void free_texture(Tex *tex)
        
        if(tex->coba) MEM_freeN(tex->coba);
        if(tex->env) BKE_free_envmap(tex->env);
-       if(tex->pd) {
-               curvemapping_free(tex->pd->falloff_curve);
-               BKE_free_pointdensity(tex->pd);
-       }
+       if(tex->pd) BKE_free_pointdensity(tex->pd);
        if(tex->vd) BKE_free_voxeldata(tex->vd);
        BKE_free_animdata((struct ID *)tex);
        
@@ -765,14 +762,7 @@ Tex *copy_texture(Tex *tex)
        
        if(texn->coba) texn->coba= MEM_dupallocN(texn->coba);
        if(texn->env) texn->env= BKE_copy_envmap(texn->env);
-
-       if(texn->pd) {
-               texn->pd= MEM_dupallocN(texn->pd);
-               if(texn->pd->falloff_curve) {
-                       texn->pd->falloff_curve = curvemapping_copy(texn->pd->falloff_curve);
-               }
-       }
-
+       if(texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd);
        if(texn->vd) texn->vd= MEM_dupallocN(texn->vd);
        if(tex->preview) texn->preview = BKE_previewimg_copy(tex->preview);
 
@@ -804,16 +794,7 @@ Tex *localize_texture(Tex *tex)
                texn->env= BKE_copy_envmap(texn->env);
                id_us_min(&texn->env->ima->id);
        }
-       if(texn->pd) {
-               texn->pd= MEM_dupallocN(texn->pd);
-               if(texn->pd->coba) {
-                       texn->pd->point_tree = NULL;
-                       texn->pd->coba= MEM_dupallocN(texn->pd->coba);
-               }
-
-               texn->pd->falloff_curve= curvemapping_copy(texn->pd->falloff_curve);
-
-       }
+       if(texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd);
        if(texn->vd) {
                texn->vd= MEM_dupallocN(texn->vd);
                if(texn->vd->dataset)
@@ -1396,7 +1377,7 @@ PointDensity *BKE_copy_pointdensity(PointDensity *pd)
        pdn->point_tree = NULL;
        pdn->point_data = NULL;
        if(pdn->coba) pdn->coba= MEM_dupallocN(pdn->coba);
-       
+       pdn->falloff_curve = curvemapping_copy(pdn->falloff_curve); /* can be NULL */
        return pdn;
 }
 
@@ -1414,6 +1395,8 @@ void BKE_free_pointdensitydata(PointDensity *pd)
                MEM_freeN(pd->coba);
                pd->coba = NULL;
        }
+
+       curvemapping_free(pd->falloff_curve); /* can be NULL */
 }
 
 void BKE_free_pointdensity(PointDensity *pd)