skip allocating texture coords for the displace modifier when they are unused.
authorCampbell Barton <ideasman42@gmail.com>
Sat, 18 Aug 2012 11:48:35 +0000 (11:48 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 18 Aug 2012 11:48:35 +0000 (11:48 +0000)
source/blender/modifiers/intern/MOD_displace.c

index 21cbc2b766ceba4f9fbab722e7fcb7dc264a0440..1d84dbc78f9dde6abed316069704a72d36eb081e 100644 (file)
@@ -183,11 +183,16 @@ static void displaceModifier_do(
        mvert = CDDM_get_verts(dm);
        modifier_get_vgroup(ob, dm, dmd->defgrp_name, &dvert, &defgrp_index);
 
-       tex_co = MEM_callocN(sizeof(*tex_co) * numVerts,
-                            "displaceModifier_do tex_co");
-       get_texture_coords((MappingInfoModifierData *)dmd, ob, dm, vertexCos, tex_co, numVerts);
+       if (dmd->texture) {
+               tex_co = MEM_callocN(sizeof(*tex_co) * numVerts,
+                                                        "displaceModifier_do tex_co");
+               get_texture_coords((MappingInfoModifierData *)dmd, ob, dm, vertexCos, tex_co, numVerts);
 
-       modifier_init_texture(dmd->modifier.scene, dmd->texture);
+               modifier_init_texture(dmd->modifier.scene, dmd->texture);
+       }
+       else {
+               tex_co = NULL;
+       }
 
        for (i = 0; i < numVerts; i++) {
                TexResult texres;
@@ -236,7 +241,9 @@ static void displaceModifier_do(
                }
        }
 
-       MEM_freeN(tex_co);
+       if (tex_co) {
+               MEM_freeN(tex_co);
+       }
 }
 
 static void deformVerts(ModifierData *md, Object *ob,