Texture Paint: fix face selection with subsurface.
authorAlexander Gavrilov <angavrilov@gmail.com>
Sat, 1 Dec 2018 11:38:11 +0000 (14:38 +0300)
committerAlexander Gavrilov <angavrilov@gmail.com>
Sat, 1 Dec 2018 11:38:11 +0000 (14:38 +0300)
source/blender/draw/intern/draw_cache_impl_mesh.c
source/blender/editors/space_view3d/drawobject.c

index 5ee91f523424182f4c3d5f96c9f1addc9e3256e7..9902f241efd6f57ec697e5cc487854c26a8e5856 100644 (file)
@@ -3549,14 +3549,22 @@ static GPUVertBuf *mesh_create_tri_select_id(
                                }
                        }
                        else {
+                               const int *p_origindex = NULL;
+                               if (rdata->me != NULL) {
+                                       p_origindex = CustomData_get_layer(&rdata->me->pdata, CD_ORIGINDEX);
+                               }
+
                                for (int i = 0; i < tri_len; i++) {
                                        const MLoopTri *mlt = &rdata->mlooptri[i];
                                        const int poly_index = mlt->poly;
                                        if (!(use_hide && (rdata->mpoly[poly_index].flag & ME_HIDE))) {
-                                               int select_id;
-                                               GPU_select_index_get(poly_index + select_id_offset, &select_id);
-                                               for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
-                                                       GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id);
+                                               int orig_index = p_origindex ? p_origindex[poly_index] : poly_index;
+                                               if (orig_index != ORIGINDEX_NONE) {
+                                                       int select_id;
+                                                       GPU_select_index_get(orig_index + select_id_offset, &select_id);
+                                                       for (uint tri_corner = 0; tri_corner < 3; tri_corner++) {
+                                                               GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id);
+                                                       }
                                                }
                                        }
                                }
index 9a73ef25819936338bb2c3e4167d1c05a4950460..bb574874cad5b084df60ee2dd65075b2ad4d0f08 100644 (file)
@@ -295,8 +295,9 @@ static void bbs_mesh_solid_verts(Depsgraph *UNUSED(depsgraph), Scene *UNUSED(sce
 static void bbs_mesh_solid_faces(Scene *UNUSED(scene), Object *ob)
 {
        Mesh *me = ob->data;
+       Mesh *me_orig = DEG_get_original_object(ob)->data;
        GPUBatch *batch;
-       if ((me->editflag & ME_EDIT_PAINT_FACE_SEL)) {
+       if ((me_orig->editflag & ME_EDIT_PAINT_FACE_SEL)) {
                batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, true, 1);
        }
        else {