Fix T60578: Crash selecting after hiding vertices
authorCampbell Barton <ideasman42@gmail.com>
Thu, 17 Jan 2019 02:02:07 +0000 (13:02 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 17 Jan 2019 02:05:45 +0000 (13:05 +1100)
source/blender/draw/intern/draw_cache_impl_mesh.c

index 9a3cde9181b278edf7aa9333e45ef2069890d55f..27dcb11b644fcc588976b83a06b201e37ad12ea7 100644 (file)
@@ -2672,10 +2672,29 @@ static void mesh_create_edit_select_id(
                }
                /* Loose edges */
                BM_ITER_MESH (eed, &iter_edge, bm, BM_EDGES_OF_MESH) {
-                       if (eed->l != NULL) {
-                               continue;
+                       if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) &&
+                           (eed->l == NULL || !bm_edge_has_visible_face(eed)))
+                       {
+                               BM_ITER_ELEM (eve, &iter_vert, eed, BM_VERTS_OF_EDGE) {
+                                       if (vbo_pos) {
+                                               copy_v3_v3(GPU_vertbuf_raw_step(&raw_pos), eve->co);
+                                       }
+                                       if (vbo_verts) {
+                                               int vidx = BM_elem_index_get(eve);
+                                               mesh_edit_add_select_index(&raw_verts, vert_comp, vidx);
+                                       }
+                                       if (vbo_edges) {
+                                               int eidx = BM_elem_index_get(eed);
+                                               mesh_edit_add_select_index(&raw_edges, edge_comp, eidx);
+                                       }
+                               }
                        }
-                       BM_ITER_ELEM (eve, &iter_vert, eed, BM_VERTS_OF_EDGE) {
+               }
+               /* Loose verts */
+               BM_ITER_MESH (eve, &iter_vert, bm, BM_VERTS_OF_MESH) {
+                       if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) &&
+                           (eve->e == NULL || !bm_vert_has_visible_edge(eve)))
+                       {
                                if (vbo_pos) {
                                        copy_v3_v3(GPU_vertbuf_raw_step(&raw_pos), eve->co);
                                }
@@ -2683,23 +2702,6 @@ static void mesh_create_edit_select_id(
                                        int vidx = BM_elem_index_get(eve);
                                        mesh_edit_add_select_index(&raw_verts, vert_comp, vidx);
                                }
-                               if (vbo_edges) {
-                                       int eidx = BM_elem_index_get(eed);
-                                       mesh_edit_add_select_index(&raw_edges, edge_comp, eidx);
-                               }
-                       }
-               }
-               /* Loose verts */
-               BM_ITER_MESH (eve, &iter_vert, bm, BM_VERTS_OF_MESH) {
-                       if (eve->e != NULL) {
-                               continue;
-                       }
-                       if (vbo_pos) {
-                               copy_v3_v3(GPU_vertbuf_raw_step(&raw_pos), eve->co);
-                       }
-                       if (vbo_verts) {
-                               int vidx = BM_elem_index_get(eve);
-                               mesh_edit_add_select_index(&raw_verts, vert_comp, vidx);
                        }
                }
        }