[Bf-blender-cvs] [07def55] master: Fix T44745 non manifold edges of mesh do not work when smoothing in multires.

Antony Riakiotakis noreply at git.blender.org
Wed May 27 19:52:34 CEST 2015


Commit: 07def553d2ad948f128a6be390abbab726dc89f0
Author: Antony Riakiotakis
Date:   Wed May 27 19:52:12 2015 +0200
Branches: master
https://developer.blender.org/rB07def553d2ad948f128a6be390abbab726dc89f0

Fix T44745 non manifold edges of mesh do not work when smoothing in
multires.

Code had special guards for such edges to stop this from happening. I
don't see why this is needed though since code above assigns smoothed
positions for all vertices in the grid.

After removing the guards I saw that this in fact was the only place
where grd adjacency was used, so I completely removed it.

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

M	source/blender/blenkernel/BKE_DerivedMesh.h
M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/BKE_subsurf.h
M	source/blender/blenkernel/intern/pbvh.c
M	source/blender/blenkernel/intern/pbvh_intern.h
M	source/blender/blenkernel/intern/subsurf_ccg.c
M	source/blender/editors/sculpt_paint/paint_hide.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_undo.c

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

diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 836c94b..789d86b 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -114,11 +114,6 @@ typedef struct DMCoNo {
 	float no[3];
 } DMCoNo;
 
-typedef struct DMGridAdjacency {
-	int index[4];
-	int rotation[4];
-} DMGridAdjacency;
-
 /* keep in sync with MFace/MPoly types */
 typedef struct DMFlagMat {
 	short mat_nr;
@@ -289,7 +284,6 @@ struct DerivedMesh {
 	int (*getNumGrids)(DerivedMesh *dm);
 	int (*getGridSize)(DerivedMesh *dm);
 	struct CCGElem **(*getGridData)(DerivedMesh * dm);
-	DMGridAdjacency *(*getGridAdjacency)(DerivedMesh * dm);
 	int *(*getGridOffset)(DerivedMesh * dm);
 	void (*getGridKey)(DerivedMesh *dm, struct CCGKey *key);
 	DMFlagMat *(*getGridFlagMats)(DerivedMesh * dm);
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index c7ef535..227994b 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -34,7 +34,6 @@ struct CCGElem;
 struct CCGKey;
 struct CustomData;
 struct DMFlagMat;
-struct DMGridAdjacency;
 struct MFace;
 struct MVert;
 struct PBVH;
@@ -63,7 +62,7 @@ PBVH *BKE_pbvh_new(void);
 void BKE_pbvh_build_mesh(PBVH *bvh, struct MFace *faces, struct MVert *verts,
                          int totface, int totvert, struct CustomData *vdata);
 void BKE_pbvh_build_grids(PBVH *bvh, struct CCGElem **grid_elems,
-                          struct DMGridAdjacency *gridadj, int totgrid,
+                          int totgrid,
                           struct CCGKey *key, void **gridfaces, struct DMFlagMat *flagmats,
                           unsigned int **grid_hidden);
 void BKE_pbvh_build_bmesh(PBVH *bvh, struct BMesh *bm, bool smooth_shading, struct BMLog *log, const int cd_vert_node_offset, const int cd_face_node_offset);
@@ -176,7 +175,7 @@ void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden);
 
 void BKE_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node,
                              int **grid_indices, int *totgrid, int *maxgrid, int *gridsize,
-                             struct CCGElem ***grid_elems, struct DMGridAdjacency **gridadj);
+                             struct CCGElem ***grid_elems);
 void BKE_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node,
                              int *uniquevert, int *totvert);
 void BKE_pbvh_node_get_verts(PBVH *bvh, PBVHNode *node,
@@ -204,7 +203,7 @@ void BKE_pbvh_update(PBVH *bvh, int flags, float (*face_nors)[3]);
 void BKE_pbvh_redraw_BB(PBVH *bvh, float bb_min[3], float bb_max[3]);
 void BKE_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***r_gridfaces, int *r_totface);
 void BKE_pbvh_grids_update(PBVH *bvh, struct CCGElem **grid_elems,
-                           struct DMGridAdjacency *gridadj, void **gridfaces,
+                           void **gridfaces,
                            struct DMFlagMat *flagmats, unsigned int **grid_hidden);
 
 /* Layer displacement */
diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h
index 5190d25..c1c96c8 100644
--- a/source/blender/blenkernel/BKE_subsurf.h
+++ b/source/blender/blenkernel/BKE_subsurf.h
@@ -49,7 +49,6 @@ struct CCGFace;
 struct CCGVert;
 struct EdgeHash;
 struct PBVH;
-struct DMGridAdjacency;
 
 /**************************** External *****************************/
 
@@ -118,7 +117,6 @@ typedef struct CCGDerivedMesh {
 	int *pmap_mem;
 
 	struct CCGElem **gridData;
-	struct DMGridAdjacency *gridAdjacency;
 	int *gridOffset;
 	struct CCGFace **gridFaces;
 	struct DMFlagMat *gridFlagMats;
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index bcbf3b8..95d8e37 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -570,7 +570,7 @@ void BKE_pbvh_build_mesh(PBVH *bvh, MFace *faces, MVert *verts, int totface, int
 }
 
 /* Do a full rebuild with on Grids data structure */
-void BKE_pbvh_build_grids(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj,
+void BKE_pbvh_build_grids(PBVH *bvh, CCGElem **grids,
                           int totgrid, CCGKey *key, void **gridfaces, DMFlagMat *flagmats, BLI_bitmap **grid_hidden)
 {
 	BBC *prim_bbc = NULL;
@@ -580,7 +580,6 @@ void BKE_pbvh_build_grids(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj,
 
 	bvh->type = PBVH_GRIDS;
 	bvh->grids = grids;
-	bvh->gridadj = gridadj;
 	bvh->gridfaces = gridfaces;
 	bvh->grid_flag_mats = flagmats;
 	bvh->totgrid = totgrid;
@@ -1383,7 +1382,7 @@ void BKE_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node, int *uniquevert, int *to
 	}
 }
 
-void BKE_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node, int **grid_indices, int *totgrid, int *maxgrid, int *gridsize, CCGElem ***griddata, DMGridAdjacency **gridadj)
+void BKE_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node, int **grid_indices, int *totgrid, int *maxgrid, int *gridsize, CCGElem ***griddata)
 {
 	switch (bvh->type) {
 		case PBVH_GRIDS:
@@ -1392,7 +1391,6 @@ void BKE_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node, int **grid_indices, int
 			if (maxgrid) *maxgrid = bvh->totgrid;
 			if (gridsize) *gridsize = bvh->gridkey.grid_size;
 			if (griddata) *griddata = bvh->grids;
-			if (gridadj) *gridadj = bvh->gridadj;
 			break;
 		case PBVH_FACES:
 		case PBVH_BMESH:
@@ -1401,7 +1399,6 @@ void BKE_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node, int **grid_indices, int
 			if (maxgrid) *maxgrid = 0;
 			if (gridsize) *gridsize = 0;
 			if (griddata) *griddata = NULL;
-			if (gridadj) *gridadj = NULL;
 			break;
 	}
 }
@@ -1787,13 +1784,12 @@ void BKE_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3],
 		pbvh_draw_BB(bvh);
 }
 
-void BKE_pbvh_grids_update(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj, void **gridfaces,
+void BKE_pbvh_grids_update(PBVH *bvh, CCGElem **grids, void **gridfaces,
                            DMFlagMat *flagmats, BLI_bitmap **grid_hidden)
 {
 	int a;
 
 	bvh->grids = grids;
-	bvh->gridadj = gridadj;
 	bvh->gridfaces = gridfaces;
 
 	if (flagmats != bvh->grid_flag_mats || bvh->grid_hidden != grid_hidden) {
@@ -1972,7 +1968,7 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node,
 	vi->fno = NULL;
 	vi->mvert = NULL;
 	
-	BKE_pbvh_node_get_grids(bvh, node, &grid_indices, &totgrid, NULL, &gridsize, &grids, NULL);
+	BKE_pbvh_node_get_grids(bvh, node, &grid_indices, &totgrid, NULL, &gridsize, &grids);
 	BKE_pbvh_node_num_verts(bvh, node, &uniq_verts, &totvert);
 	BKE_pbvh_node_get_verts(bvh, node, &vert_indices, &verts);
 	vi->key = &bvh->gridkey;
diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h
index a2b08a1..7daccb4 100644
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@ -139,7 +139,6 @@ struct PBVH {
 	/* Grid Data */
 	CCGKey gridkey;
 	CCGElem **grids;
-	DMGridAdjacency *gridadj;
 	void **gridfaces;
 	const DMFlagMat *grid_flag_mats;
 	int totgrid;
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index b640591..402674c 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -2800,7 +2800,6 @@ static void ccgDM_release(DerivedMesh *dm)
 		if (ccgdm->reverseFaceMap) MEM_freeN(ccgdm->reverseFaceMap);
 		if (ccgdm->gridFaces) MEM_freeN(ccgdm->gridFaces);
 		if (ccgdm->gridData) MEM_freeN(ccgdm->gridData);
-		if (ccgdm->gridAdjacency) MEM_freeN(ccgdm->gridAdjacency);
 		if (ccgdm->gridOffset) MEM_freeN(ccgdm->gridOffset);
 		if (ccgdm->gridFlagMats) MEM_freeN(ccgdm->gridFlagMats);
 		if (ccgdm->gridHidden) {
@@ -3111,46 +3110,11 @@ static int ccgDM_getGridSize(DerivedMesh *dm)
 	return ccgSubSurf_getGridSize(ccgdm->ss);
 }
 
-static int ccgdm_adjacent_grid(int *gridOffset, CCGFace *f, int S, int offset)
-{
-	CCGFace *adjf;
-	CCGEdge *e;
-	int i, j = 0, numFaces, fIndex, numEdges = 0;
-
-	e = ccgSubSurf_getFaceEdge(f, S);
-	numFaces = ccgSubSurf_getEdgeNumFaces(e);
-
-	if (numFaces != 2)
-		return -1;
-
-	for (i = 0; i < numFaces; i++) {
-		adjf = ccgSubSurf_getEdgeFace(e, i);
-
-		if (adjf != f) {
-			numEdges = ccgSubSurf_getFaceNumVerts(adjf);
-			for (j = 0; j < numEdges; j++)
-				if (ccgSubSurf_getFaceEdge(adjf, j) == e)
-					break;
-
-			if (j != numEdges)
-				break;
-		}
-	}
-
-	if (numEdges == 0)
-		return -1;
-	
-	fIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(adjf));
-
-	return gridOffset[fIndex] + (j + offset) % numEdges;
-}
-
 static void ccgdm_create_grids(DerivedMesh *dm)
 {
 	CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
 	CCGSubSurf *ss = ccgdm->ss;
 	CCGElem **gridData;
-	DMGridAdjacency *gridAdjacency, *adj;
 	DMFlagMat *gridFlagMats;
 	CCGFace **gridFaces;
 	int *gridOffset;
@@ -3176,7 +3140,6 @@ static void ccgdm_create_grids(DerivedMesh *dm)
 
 	/* compute grid data */
 	gridData = MEM_mallocN(sizeof(CCGElem *) * numGrids, "ccgdm.gridData");
-	gridAdjacency = MEM_mallocN(sizeof(DMGridAdjacency) * numGrids, "ccgdm.gridAdjacency");
 	gridFaces = MEM_mallocN(sizeof(CCGFace *) * numGrids, "ccgdm.gridFaces");
 	gridFlagMats = MEM_mallocN(sizeof(DMFlagMat) * numGrids, "ccgdm.gridFlagMats");
 
@@ -3187,29 +3150,14 @@ static void ccgdm_create_grids(DerivedMesh *dm)
 		int numVerts = ccgSubSurf_getFaceNumVerts(f);
 
 		for (S = 0; S < numVerts; S++, gIndex++) {
-			int prevS = (S - 1 + numVerts) % numVerts;
-			int nextS = (S + 1 + numVerts) % numVerts;
-
 			gridData[gIndex] = ccgSubSurf_getFaceGridDataArray(ss, f, S);
 			gridFaces[gIndex] = f;
 			gridFlagMats[gIndex] = ccgdm->faceFlags[index];
-
-			adj = &gridAdjacency[gIndex];
-
-			adj->index[0] = gIndex - S + nextS;
-			adj->rotation[0] = 3;
-			adj->index[1] = ccgdm_adjacent_grid(gridOffset, f, prevS, 0);
-			adj->rotation[1] = 1;
-			adj->index[2] = ccgdm_adjacent_grid(gridOffset, f, S, 1);
-			adj->rotation[2] = 3;
-			adj->index[3] = gIndex - S + prevS;
-			adj->rotation[3] = 1;
 		}
 	}
 
 	ccgdm->gridData = gridData;
 	ccgdm->gridFaces = gridFaces;
-	ccgdm->gridAdjacency = gridAdjacency;
 	ccgdm->gridOffset = gridOffset;
 	ccgdm->gridFlagMats = grid

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list