[Bf-blender-cvs] [c4be1f861b3] master: Fix T60408: Loose edge distort vertex on a surface

Sergey Sharybin noreply at git.blender.org
Thu Jan 24 12:15:19 CET 2019


Commit: c4be1f861b39b2432a2777d48d38b3ce317e1638
Author: Sergey Sharybin
Date:   Thu Jan 24 12:05:32 2019 +0100
Branches: master
https://developer.blender.org/rBc4be1f861b39b2432a2777d48d38b3ce317e1638

Fix T60408: Loose edge distort vertex on a surface

Treat those vertices as infinitely sharp. This matches the way
how OpenSubdiv's topology is being created.

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

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 13ade957839..e05fe5533e3 100644
--- a/source/blender/blenkernel/intern/subdiv_mesh.c
+++ b/source/blender/blenkernel/intern/subdiv_mesh.c
@@ -1034,6 +1034,7 @@ static void find_edge_neighbors(const SubdivMeshContext *ctx,
 	const MEdge *coarse_medge = coarse_mesh->medge;
 	neighbors[0] = NULL;
 	neighbors[1] = NULL;
+	int neighbor_counters[2] = {0, 0};
 	for (int edge_index = 0; edge_index < coarse_mesh->totedge; edge_index++) {
 		const MEdge *current_edge = &coarse_medge[edge_index];
 		if (current_edge == edge) {
@@ -1041,11 +1042,22 @@ static void find_edge_neighbors(const SubdivMeshContext *ctx,
 		}
 		if (ELEM(edge->v1, current_edge->v1, current_edge->v2)) {
 			neighbors[0] = current_edge;
+			++neighbor_counters[0];
 		}
 		if (ELEM(edge->v2, current_edge->v1, current_edge->v2)) {
 			neighbors[1] = current_edge;
+			++neighbor_counters[1];
 		}
 	}
+	/* Vertices which has more than one neighbor are considered infinitely
+	 * sharp. This is also how topology factory treats vertices of a surface
+	 * which are adjacent to a loose edge. */
+	if (neighbor_counters[0] > 1) {
+		neighbors[0] = NULL;
+	}
+	if (neighbor_counters[1] > 1) {
+		neighbors[1] = NULL;
+	}
 }
 
 static void points_for_loose_edges_interpolation_get(
@@ -1144,7 +1156,6 @@ static void subdiv_mesh_vertex_of_loose_edge(
 	/* Perform interpolation. */
 	float weights[4];
 	key_curve_position_weights(u, weights, KEY_BSPLINE);
-
 	/* Interpolate custom data. */
 	subdiv_mesh_vertex_of_loose_edge_interpolate(
 	        ctx, coarse_edge, u, subdiv_vertex_index);



More information about the Bf-blender-cvs mailing list