Fix crash & performance regression w/ base lookup
authorCampbell Barton <ideasman42@gmail.com>
Thu, 29 Jun 2017 02:04:43 +0000 (12:04 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 29 Jun 2017 02:19:22 +0000 (12:19 +1000)
Was doing O(n^2) list lookups with blender-render drawing & transform.
Also missing NULL checks would crash.

Use Object.base_flag (already used by new draw manager in places)
to avoid list lookup.

Note, transform still performs inefficient lookups,
but only for selected parents (like 2.7x), not all parents.

source/blender/editors/space_outliner/outliner_select.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/transform/transform_conversions.c

index 9bdc6cb59f3209849f0c11fdc2f4c7186fee1e19..459af31b921cee529f6174d700a3f7ce8b153609 100644 (file)
@@ -917,8 +917,11 @@ static void outliner_item_activate(
 
                                for (gob = gr->gobject.first; gob; gob = gob->next) {
                                        Base *base = BKE_scene_layer_base_find(sl, gob->ob);
-                                       if ((base->flag & BASE_SELECTED) == 0) {
-                                               ED_object_base_select(base, BA_SELECT);
+                                       /* Object may not be in this scene */
+                                       if (base != NULL) {
+                                               if ((base->flag & BASE_SELECTED) == 0) {
+                                                       ED_object_base_select(base, BA_SELECT);
+                                               }
                                        }
                                }
                        }
index f41602f78993f60467a551798844223a19951b23..8b1f44557e4229e4698e017d7b6a7cdadce471cf 100644 (file)
@@ -9195,8 +9195,7 @@ afterdraw:
 
                /* help lines and so */
                if (ob != scene->obedit && ob->parent) {
-                       Base *base_parent = BKE_scene_layer_base_find(sl, ob->parent);
-                       if ((base_parent->flag & BASE_VISIBLED) != 0) {
+                       if ((ob->parent->base_flag & BASE_VISIBLED) != 0) {
                                setlinestyle(3);
                                immBegin(GWN_PRIM_LINES, 2);
                                immVertex3fv(pos, ob->obmat[3]);
index 243788c20b3b272bad7ca3142b8e735adf57491d..2b25581e2b34c3a27348d719dab2ad54a05502d6 100644 (file)
@@ -5467,8 +5467,8 @@ static void set_trans_object_base_flags(TransInfo *t)
 
                        /* if parent selected, deselect */
                        while (parsel) {
-                               Base *parbase = BKE_scene_layer_base_find(sl, parsel);
-                               if (parbase->flag & BASE_SELECTED) {
+                               if (parsel->base_flag & BASE_SELECTED) {
+                                       Base *parbase = BKE_scene_layer_base_find(sl, parsel);
                                        if (parbase) { /* in rare cases this can fail */
                                                if (TESTBASELIB_BGMODE_NEW(parbase)) {
                                                        break;