Dupliverts: avoid calculating normals if not used
authorCampbell Barton <ideasman42@gmail.com>
Sun, 22 Dec 2013 23:53:46 +0000 (10:53 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 22 Dec 2013 23:55:40 +0000 (10:55 +1100)
source/blender/blenkernel/intern/anim.c

index 9226538910c43fd1dc2eb11d95c24b3ce3f5a4d1..1624a02e773127fc28fefeb636bfd0097c3da685 100644 (file)
@@ -943,6 +943,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3],
 static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[4][4], int persistent_id[MAX_DUPLI_RECUR],
                              int level, short flag)
 {
+       const bool use_rotation = (par->transflag & OB_DUPLIROT) != 0;
        Object *ob, *ob_iter;
        Mesh *me = par->data;
        Base *base = NULL;
@@ -1034,14 +1035,19 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
                                        if (ob->type != OB_MBALL) ob->flag |= OB_DONE;  /* doesnt render */
 
                                        if (me->edit_btmesh) {
-                                               dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void *) &vdd, DM_FOREACH_USE_NORMAL);
+                                               dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void *) &vdd,
+                                                                     use_rotation ? DM_FOREACH_USE_NORMAL : 0);
                                        }
                                        else {
+                                               const float *no_pt = use_rotation ? no : NULL;
                                                for (a = 0; a < totvert; a++) {
                                                        dm->getVertCo(dm, a, vec);
-                                                       dm->getVertNo(dm, a, no);
+
+                                                       if (use_rotation) {
+                                                               dm->getVertNo(dm, a, no);
+                                                       }
                                                        
-                                                       vertex_dupli__mapFunc(&vdd, a, vec, no, NULL);
+                                                       vertex_dupli__mapFunc(&vdd, a, vec, no_pt, NULL);
                                                }
                                        }
                                        if (sce) {