diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_cdderivedmesh.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 8 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_remesh.c | 28 |
3 files changed, 32 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h index c24db5dd1f8..e275eb1b4f7 100644 --- a/source/blender/blenkernel/BKE_cdderivedmesh.h +++ b/source/blender/blenkernel/BKE_cdderivedmesh.h @@ -119,7 +119,8 @@ void CDDM_recalc_tesselation(struct DerivedMesh *dm); */ void CDDM_lower_num_verts(struct DerivedMesh *dm, int numVerts); void CDDM_lower_num_edges(struct DerivedMesh *dm, int numEdges); -void CDDM_lower_num_faces(struct DerivedMesh *dm, int numFaces); +void CDDM_lower_num_polys(struct DerivedMesh *dm, int numPolys); +void CDDM_lower_num_tessfaces(DerivedMesh *dm, int numTessFaces); /* vertex/edge/face access functions * should always succeed if index is within bounds diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 025fdbc2262..34cff1b9b93 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -2601,6 +2601,14 @@ void CDDM_lower_num_edges(DerivedMesh *dm, int numEdges) dm->numEdgeData = numEdges; } +void CDDM_lower_num_tessfaces(DerivedMesh *dm, int numTessFaces) +{ + if (numTessFaces < dm->numTessFaceData) + CustomData_free_elem(&dm->faceData, numTessFaces, dm->numTessFaceData-numTessFaces); + + dm->numTessFaceData = numTessFaces; +} + void CDDM_lower_num_polys(DerivedMesh *dm, int numPolys) { if (numPolys < dm->numPolyData) diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c index c698985efc3..17e84e28c5f 100644 --- a/source/blender/modifiers/intern/MOD_remesh.c +++ b/source/blender/modifiers/intern/MOD_remesh.c @@ -85,9 +85,9 @@ static void init_dualcon_mesh(DualConInput *mesh, DerivedMesh *dm) mesh->co_stride = sizeof(MVert); mesh->totco = dm->getNumVerts(dm); - mesh->faces = (void*)dm->getFaceArray(dm); + mesh->faces = (void*)dm->getTessFaceArray(dm); mesh->face_stride = sizeof(MFace); - mesh->totface = dm->getNumFaces(dm); + mesh->totface = dm->getNumTessFaces(dm); dm->getMinMax(dm, mesh->min, mesh->max); } @@ -108,7 +108,7 @@ static void *dualcon_alloc_output(int totvert, int totquad) "DualConOutput"))) return NULL; - output->dm = CDDM_new(totvert, 0, totquad); + output->dm = CDDM_new(totvert, 0, totquad, 0, 0); return output; } @@ -129,9 +129,9 @@ static void dualcon_add_quad(void *output_v, const int vert_indices[4]) DerivedMesh *dm = output->dm; MFace *mface; - assert(output->curface < dm->getNumFaces(dm)); + assert(output->curface < dm->getNumTessFaces(dm)); - mface = &CDDM_get_faces(dm)[output->curface]; + mface = &CDDM_get_tessfaces(dm)[output->curface]; mface->v1 = vert_indices[0]; mface->v2 = vert_indices[1]; mface->v3 = vert_indices[2]; @@ -184,13 +184,29 @@ static DerivedMesh *applyModifier(ModifierData *md, rmd->scale, rmd->depth); result = output->dm; - CDDM_lower_num_faces(result, output->curface); + CDDM_lower_num_tessfaces(result, output->curface); MEM_freeN(output); CDDM_calc_edges(result); CDDM_calc_normals(result); + /* BMESH_TODO - create polygons */ + +#if 0 + return result; + +#else /* BMESH ONLY */ + + dm = CDDM_copy(result, 1); /*builds ngon faces from tess (mface) faces*/ + CDDM_calc_normals(dm); + result->needsFree = 1; + result->release(result); + + return dm; + +#endif + } #else /* !WITH_MOD_REMESH */ |