From 07def553d2ad948f128a6be390abbab726dc89f0 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 27 May 2015 19:52:12 +0200 Subject: 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. --- source/blender/blenkernel/BKE_DerivedMesh.h | 6 --- source/blender/blenkernel/BKE_pbvh.h | 7 ++- source/blender/blenkernel/BKE_subsurf.h | 2 - source/blender/blenkernel/intern/pbvh.c | 12 ++--- source/blender/blenkernel/intern/pbvh_intern.h | 1 - source/blender/blenkernel/intern/subsurf_ccg.c | 65 +---------------------- source/blender/editors/sculpt_paint/paint_hide.c | 2 +- source/blender/editors/sculpt_paint/sculpt.c | 18 +------ source/blender/editors/sculpt_paint/sculpt_undo.c | 6 +-- 9 files changed, 15 insertions(+), 104 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 836c94b6271..789d86b7816 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 c7ef53589aa..227994b73ee 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 5190d254306..c1c96c8228c 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 bcbf3b8e77b..95d8e37d1c7 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 a2b08a1f6d3..7daccb47c92 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 b6405913c2a..402674c0389 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 = gridFlagMats; } @@ -3222,14 +3170,6 @@ static CCGElem **ccgDM_getGridData(DerivedMesh *dm) return ccgdm->gridData; } -static DMGridAdjacency *ccgDM_getGridAdjacency(DerivedMesh *dm) -{ - CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; - - ccgdm_create_grids(dm); - return ccgdm->gridAdjacency; -} - static int *ccgDM_getGridOffset(DerivedMesh *dm) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; @@ -3312,7 +3252,7 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) * when the ccgdm gets remade, the assumption is that the topology * does not change. */ ccgdm_create_grids(dm); - BKE_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, (void **)ccgdm->gridFaces, + BKE_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, (void **)ccgdm->gridFaces, ccgdm->gridFlagMats, ccgdm->gridHidden); } @@ -3331,7 +3271,7 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) numGrids = ccgDM_getNumGrids(dm); ob->sculpt->pbvh = ccgdm->pbvh = BKE_pbvh_new(); - BKE_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, + BKE_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, numGrids, &key, (void **) ccgdm->gridFaces, ccgdm->gridFlagMats, ccgdm->gridHidden); } else if (ob->type == OB_MESH) { @@ -3459,7 +3399,6 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, ccgdm->dm.getNumGrids = ccgDM_getNumGrids; ccgdm->dm.getGridSize = ccgDM_getGridSize; ccgdm->dm.getGridData = ccgDM_getGridData; - ccgdm->dm.getGridAdjacency = ccgDM_getGridAdjacency; ccgdm->dm.getGridOffset = ccgDM_getGridOffset; ccgdm->dm.getGridKey = ccgDM_getGridKey; ccgdm->dm.getGridFlagMats = ccgDM_getGridFlagMats; diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index f1c91d0fcb5..52a60347f9f 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -150,7 +150,7 @@ static void partialvis_update_grids(Object *ob, /* get PBVH data */ BKE_pbvh_node_get_grids(pbvh, node, &grid_indices, &totgrid, NULL, NULL, - &grids, NULL); + &grids); grid_hidden = BKE_pbvh_grid_hidden(pbvh); BKE_pbvh_get_grid_key(pbvh, &key); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 19777e0093c..0e75a344699 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1764,7 +1764,6 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no SculptBrushTest test; CCGElem **griddata, *data; CCGKey key; - DMGridAdjacency *gridadj, *adj; float (*tmpgrid_co)[3], (*tmprow_co)[3]; float *tmpgrid_mask, *tmprow_mask; int v1, v2, v3, v4; @@ -1777,7 +1776,7 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no CLAMP(bstrength, 0.0f, 1.0f); BKE_pbvh_node_get_grids(ss->pbvh, node, &grid_indices, &totgrid, - NULL, &gridsize, &griddata, &gridadj); + NULL, &gridsize, &griddata); BKE_pbvh_get_grid_key(ss->pbvh, &key); grid_hidden = BKE_pbvh_grid_hidden(ss->pbvh); @@ -1796,7 +1795,6 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no int gi = grid_indices[i]; const BLI_bitmap *gh = grid_hidden[gi]; data = griddata[gi]; - adj = &gridadj[gi]; if (smooth_mask) memset(tmpgrid_mask, 0, sizeof(float) * gridsize * gridsize); @@ -1862,18 +1860,6 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no continue; } - if (x == 0 && adj->index[0] == -1) - continue; - - if (x == gridsize - 1 && adj->index[2] == -1) - continue; - - if (y == 0 && adj->index[3] == -1) - continue; - - if (y == gridsize - 1 && adj->index[1] == -1) - continue; - index = x + y * gridsize; co = CCG_elem_offset_co(&key, data, index); fno = CCG_elem_offset_no(&key, data, index); @@ -3701,7 +3687,7 @@ static void sculpt_omp_start(Sculpt *sd, SculptSession *ss) if (ss->multires) { int i, gridsize, array_mem_size; BKE_pbvh_node_get_grids(ss->pbvh, NULL, NULL, NULL, NULL, - &gridsize, NULL, NULL); + &gridsize, NULL); array_mem_size = cache->num_threads * sizeof(void *); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 7b4e6109f1a..2f0957c3b60 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -581,7 +581,7 @@ static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh, grid_hidden = BKE_pbvh_grid_hidden(pbvh); BKE_pbvh_node_get_grids(pbvh, node, &grid_indices, &totgrid, - NULL, NULL, NULL, NULL); + NULL, NULL, NULL); unode->grid_hidden = MEM_mapallocN(sizeof(*unode->grid_hidden) * totgrid, "unode->grid_hidden"); @@ -610,7 +610,7 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, if (node) { BKE_pbvh_node_num_verts(ss->pbvh, node, &totvert, &allvert); BKE_pbvh_node_get_grids(ss->pbvh, node, &grids, &totgrid, - &maxgrid, &gridsize, NULL, NULL); + &maxgrid, &gridsize, NULL); unode->totvert = totvert; } @@ -842,7 +842,7 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, if (unode->grids) { int totgrid, *grids; BKE_pbvh_node_get_grids(ss->pbvh, node, &grids, &totgrid, - NULL, NULL, NULL, NULL); + NULL, NULL, NULL); memcpy(unode->grids, grids, sizeof(int) * totgrid); } else { -- cgit v1.2.3