[Bf-blender-cvs] [b466c09c305] blender2.8: Subsurf: Fix wrong vertices index in vertex data interpolation

Sergey Sharybin noreply at git.blender.org
Mon Jul 23 19:17:16 CEST 2018


Commit: b466c09c305dfafbe3d15d6564c34f9f874ac0ad
Author: Sergey Sharybin
Date:   Mon Jul 23 19:09:16 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBb466c09c305dfafbe3d15d6564c34f9f874ac0ad

Subsurf: Fix wrong vertices index in vertex data interpolation

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

M	source/blender/blenkernel/intern/subdiv_mesh.c

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

diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c
index eb47d9158d3..ad2e094fa48 100644
--- a/source/blender/blenkernel/intern/subdiv_mesh.c
+++ b/source/blender/blenkernel/intern/subdiv_mesh.c
@@ -355,7 +355,7 @@ static void vertex_interpolation_init(
 		int *indices = BLI_array_alloca(indices, coarse_poly->totloop);
 		for (int i = 0; i < coarse_poly->totloop; ++i) {
 			weights[i] = weight;
-			indices[i] = coarse_poly->loopstart + i;
+			indices[i] = coarse_mloop[coarse_poly->loopstart + i].v;
 		}
 		CustomData_interp(&coarse_mesh->vdata,
 		                  &vertex_interpolation->vertex_data_storage,
@@ -395,13 +395,15 @@ static void vertex_interpolation_from_ptex(
 		 * iteration.
 		 */
 		const float weights[2] = {0.5f, 0.5f};
+		const int first_loop_index = loops_of_ptex.first_loop - coarse_mloop;
+		const int last_loop_index = loops_of_ptex.last_loop - coarse_mloop;
 		const int first_indices[2] = {
-		        coarse_mloop[loops_of_ptex.first_loop - coarse_mloop].v,
-		        coarse_mloop[(loops_of_ptex.first_loop + 1 - coarse_mloop) %
-		                coarse_poly->totloop].v};
-		const int last_indices[2] = {
-		        coarse_mloop[loops_of_ptex.last_loop - coarse_mloop].v,
-		        coarse_mloop[loops_of_ptex.first_loop - coarse_mloop].v};
+		        coarse_mloop[first_loop_index].v,
+		        coarse_mloop[coarse_poly->loopstart +
+		                (first_loop_index - coarse_poly->loopstart + 1) %
+		                        coarse_poly->totloop].v};
+		const int last_indices[2] = {coarse_mloop[first_loop_index].v,
+		                             coarse_mloop[last_loop_index].v};
 		CustomData_interp(vertex_data,
 		                  &vertex_interpolation->vertex_data_storage,
 		                  first_indices,



More information about the Bf-blender-cvs mailing list