From 750e4e1158bb1bd40c1724e24693cb22c6910f86 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Sun, 11 Oct 2020 21:39:28 +0200 Subject: Fix Multires edge adjacency info returning wrong vertex indices ME_POLY_LOOP_NEXT and ME_POLY_LOOP_PREV expect the offset of the loop in the poly as an argument, in other words, corner index of the poly. This was violated in some places. It didn't cause issues when base mesh consists of only quads due to the way how modulus worked inside of the macro. However, if mesh had non-quad faces adjacency information was returning wrong vertex indices. This was causing multiple brushes to work erratically, including brushes like Face Set, Boundary automasking, mesh relax, and others. Reviewed By: sergey Differential Revision: https://developer.blender.org/D9173 --- source/blender/blenkernel/intern/subdiv_ccg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern/subdiv_ccg.c') diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c index 0997b42a19f..a59f9e0c633 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg.c +++ b/source/blender/blenkernel/intern/subdiv_ccg.c @@ -1878,12 +1878,14 @@ static void adjacet_vertices_index_from_adjacent_edge(const SubdivCCG *subdiv_cc const int poly_index = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, coord->grid_index); const MPoly *p = &mpoly[poly_index]; *r_v1 = mloop[coord->grid_index].v; + + const int corner = poly_find_loop_from_vert(p, &mloop[p->loopstart], *r_v1); if (coord->x == grid_size_1) { - const MLoop *next = ME_POLY_LOOP_NEXT(mloop, p, coord->grid_index); + const MLoop *next = ME_POLY_LOOP_NEXT(mloop, p, corner); *r_v2 = next->v; } if (coord->y == grid_size_1) { - const MLoop *prev = ME_POLY_LOOP_PREV(mloop, p, coord->grid_index); + const MLoop *prev = ME_POLY_LOOP_PREV(mloop, p, corner); *r_v2 = prev->v; } } -- cgit v1.2.3