[Bf-blender-cvs] [750e4e1158b] master: Fix Multires edge adjacency info returning wrong vertex indices

Pablo Dobarro noreply at git.blender.org
Thu Oct 15 19:38:12 CEST 2020


Commit: 750e4e1158bb1bd40c1724e24693cb22c6910f86
Author: Pablo Dobarro
Date:   Sun Oct 11 21:39:28 2020 +0200
Branches: master
https://developer.blender.org/rB750e4e1158bb1bd40c1724e24693cb22c6910f86

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

===================================================================

M	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;
   }
 }



More information about the Bf-blender-cvs mailing list