diff options
-rw-r--r-- | source/blender/blenkernel/BKE_DerivedMesh.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 42 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 106 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/editderivedbmesh.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/navmesh_conversion.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 15 | ||||
-rw-r--r-- | source/blender/bmesh/intern/in-progress/BME_conversions.c | 4 | ||||
-rw-r--r-- | source/blender/collada/GeometryExporter.cpp | 4 | ||||
-rw-r--r-- | source/blender/editors/armature/meshlaplacian.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawmesh.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_buffers.c | 2 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_ngoninterp.c | 2 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_ocean.c | 2 |
14 files changed, 109 insertions, 87 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 7a6f43b7846..031eb0d2b69 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -122,7 +122,7 @@ typedef struct DerivedMesh DerivedMesh; struct DerivedMesh { /* Private DerivedMesh data, only for internal DerivedMesh use */ CustomData vertData, edgeData, faceData, loopData, polyData; - int numVertData, numEdgeData, numFaceData, numLoopData, numPolyData; + int numVertData, numEdgeData, numTessFaceData, numLoopData, numPolyData; int needsFree; /* checked on ->release, is set to 0 for cached results */ int deformedOnly; /* set by modifier stack if only deformed from original */ BVHCache bvhCache; @@ -141,6 +141,7 @@ struct DerivedMesh { int (*getNumVerts)(DerivedMesh *dm); int (*getNumEdges)(DerivedMesh *dm); int (*getNumTessFaces)(DerivedMesh *dm); + int (*getNumLoops)(DerivedMesh *dm); int (*getNumPolys)(DerivedMesh *dm); /* copy a single vert/edge/tesselated face from the derived mesh into diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index c701e0a52f3..ad154a44980 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -115,7 +115,7 @@ static MEdge *dm_getEdgeArray(DerivedMesh *dm) return medge; } -static MFace *dm_getFaceArray(DerivedMesh *dm) +static MFace *dm_getTessFaceArray(DerivedMesh *dm) { MFace *mface = CustomData_get_layer(&dm->faceData, CD_MFACE); @@ -189,7 +189,7 @@ static MFace *dm_dupFaceArray(DerivedMesh *dm) static MLoop *dm_dupLoopArray(DerivedMesh *dm) { - MLoop *tmp = MEM_callocN(sizeof(*tmp) * dm->numLoopData, + MLoop *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumLoops(dm), "dm_dupLoopArray tmp"); if(tmp) dm->copyLoopArray(dm, tmp); @@ -199,7 +199,7 @@ static MLoop *dm_dupLoopArray(DerivedMesh *dm) static MPoly *dm_dupPolyArray(DerivedMesh *dm) { - MPoly *tmp = MEM_callocN(sizeof(*tmp) * dm->numFaceData, + MPoly *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumPolys(dm), "dm_dupPolyArray tmp"); if(tmp) dm->copyPolyArray(dm, tmp); @@ -217,7 +217,7 @@ static CustomData *dm_getEdgeCData(DerivedMesh *dm) return &dm->edgeData; } -static CustomData *dm_getFaceCData(DerivedMesh *dm) +static CustomData *dm_getTessFaceCData(DerivedMesh *dm) { return &dm->faceData; } @@ -237,7 +237,7 @@ void DM_init_funcs(DerivedMesh *dm) /* default function implementations */ dm->getVertArray = dm_getVertArray; dm->getEdgeArray = dm_getEdgeArray; - dm->getTessFaceArray = dm_getFaceArray; + dm->getTessFaceArray = dm_getTessFaceArray; dm->getLoopArray = dm_getLoopArray; dm->getPolyArray = dm_getPolyArray; dm->dupVertArray = dm_dupVertArray; @@ -248,7 +248,7 @@ void DM_init_funcs(DerivedMesh *dm) dm->getVertDataLayout = dm_getVertCData; dm->getEdgeDataLayout = dm_getEdgeCData; - dm->getTessFaceDataLayout = dm_getFaceCData; + dm->getTessFaceDataLayout = dm_getTessFaceCData; dm->getLoopDataLayout = dm_getLoopCData; dm->getPolyDataLayout = dm_getPolyCData; @@ -263,14 +263,14 @@ void DM_init_funcs(DerivedMesh *dm) } void DM_init(DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges, - int numFaces, int numLoops, int numPoly) + int numTessFaces, int numLoops, int numPolys) { dm->type = type; dm->numVertData = numVerts; dm->numEdgeData = numEdges; - dm->numFaceData = numFaces; + dm->numTessFaceData = numTessFaces; dm->numLoopData = numLoops; - dm->numPolyData = numPoly; + dm->numPolyData = numPolys; DM_init_funcs(dm); @@ -278,15 +278,15 @@ void DM_init(DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges, } void DM_from_template(DerivedMesh *dm, DerivedMesh *source, DerivedMeshType type, - int numVerts, int numEdges, int numFaces, - int numLoops, int numPolys) + int numVerts, int numEdges, int numTessFaces, + int numLoops, int numPolys) { CustomData_copy(&source->vertData, &dm->vertData, CD_MASK_DERIVEDMESH, CD_CALLOC, numVerts); CustomData_copy(&source->edgeData, &dm->edgeData, CD_MASK_DERIVEDMESH, CD_CALLOC, numEdges); CustomData_copy(&source->faceData, &dm->faceData, CD_MASK_DERIVEDMESH, - CD_CALLOC, numFaces); + CD_CALLOC, numTessFaces); CustomData_copy(&source->loopData, &dm->loopData, CD_MASK_DERIVEDMESH, CD_CALLOC, numLoops); CustomData_copy(&source->polyData, &dm->polyData, CD_MASK_DERIVEDMESH, @@ -295,7 +295,7 @@ void DM_from_template(DerivedMesh *dm, DerivedMesh *source, DerivedMeshType type dm->type = type; dm->numVertData = numVerts; dm->numEdgeData = numEdges; - dm->numFaceData = numFaces; + dm->numTessFaceData = numTessFaces; dm->numLoopData = numLoops; dm->numPolyData = numPolys; @@ -311,7 +311,7 @@ int DM_release(DerivedMesh *dm) GPU_drawobject_free( dm ); CustomData_free(&dm->vertData, dm->numVertData); CustomData_free(&dm->edgeData, dm->numEdgeData); - CustomData_free(&dm->faceData, dm->numFaceData); + CustomData_free(&dm->faceData, dm->numTessFaceData); CustomData_free(&dm->loopData, dm->numLoopData); CustomData_free(&dm->polyData, dm->numPolyData); @@ -320,7 +320,7 @@ int DM_release(DerivedMesh *dm) else { CustomData_free_temporary(&dm->vertData, dm->numVertData); CustomData_free_temporary(&dm->edgeData, dm->numEdgeData); - CustomData_free_temporary(&dm->faceData, dm->numFaceData); + CustomData_free_temporary(&dm->faceData, dm->numTessFaceData); CustomData_free_temporary(&dm->loopData, dm->numLoopData); CustomData_free_temporary(&dm->polyData, dm->numPolyData); @@ -488,7 +488,7 @@ void DM_add_edge_layer(DerivedMesh *dm, int type, int alloctype, void *layer) void DM_add_tessface_layer(DerivedMesh *dm, int type, int alloctype, void *layer) { - CustomData_add_layer(&dm->faceData, type, alloctype, layer, dm->numFaceData); + CustomData_add_layer(&dm->faceData, type, alloctype, layer, dm->numTessFaceData); } void DM_add_loop_layer(DerivedMesh *dm, int type, int alloctype, void *layer) @@ -1979,7 +1979,7 @@ typedef struct MVert * mvert; // vertices & normals float (*orco)[3]; float (*tangent)[4]; // destination - int numFaces; + int numTessFaces; } SGLSLMeshToTangent; @@ -1989,7 +1989,7 @@ typedef struct static int GetNumFaces(const SMikkTSpaceContext * pContext) { SGLSLMeshToTangent * pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData; - return pMesh->numFaces; + return pMesh->numTessFaces; } static int GetNumVertsOfFace(const SMikkTSpaceContext * pContext, const int face_num) @@ -2116,7 +2116,7 @@ void DM_add_tangent_layer(DerivedMesh *dm) mesh2tangent.mvert = mvert; mesh2tangent.orco = orco; mesh2tangent.tangent = tangent; - mesh2tangent.numFaces = totface; + mesh2tangent.numTessFaces = totface; sContext.m_pUserData = &mesh2tangent; sContext.m_pInterface = &sInterface; @@ -2242,7 +2242,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, attribs->tface[a].glIndex = gattribs->layer[b].glindex; } /*else { int player; - CustomData *pdata = dm->getFaceDataLayout(dm); + CustomData *pdata = dm->getPolyDataLayout(dm); if(gattribs->layer[b].name[0]) player = CustomData_get_named_layer_index(pdata, CD_MTEXPOLY, @@ -2362,7 +2362,7 @@ static void navmesh_drawColored(DerivedMesh *dm) DEBUG_VBO( "Using legacy code. drawNavMeshColored\n" ); //glShadeModel(GL_SMOOTH); glBegin(glmode = GL_QUADS); - for(a = 0; a < dm->numFaceData; a++, mface++) { + for(a = 0; a < dm->numTessFaceData; a++, mface++) { int new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES; int pi = polygonIdx[a]; if (pi <= 0) { diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 1d4e594c8ef..470f6a09d65 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -109,7 +109,12 @@ static int cdDM_getNumEdges(DerivedMesh *dm) static int cdDM_getNumTessFaces(DerivedMesh *dm) { - return dm->numFaceData; + return dm->numTessFaceData; +} + +static int cdDM_getNumLoops(DerivedMesh *dm) +{ + return dm->numLoopData; } static int cdDM_getNumPolys(DerivedMesh *dm) @@ -150,7 +155,7 @@ static void cdDM_copyEdgeArray(DerivedMesh *dm, MEdge *edge_r) static void cdDM_copyTessFaceArray(DerivedMesh *dm, MFace *face_r) { CDDerivedMesh *cddm = (CDDerivedMesh *)dm; - memcpy(face_r, cddm->mface, sizeof(*face_r) * dm->numFaceData); + memcpy(face_r, cddm->mface, sizeof(*face_r) * dm->numTessFaceData); } static void cdDM_copyLoopArray(DerivedMesh *dm, MLoop *loop_r) @@ -287,7 +292,7 @@ static void cdDM_update_normals_from_pbvh(DerivedMesh *dm) CDDerivedMesh *cddm = (CDDerivedMesh*) dm; float (*face_nors)[3]; - if(!cddm->pbvh || !cddm->pbvh_draw || !dm->numFaceData) + if(!cddm->pbvh || !cddm->pbvh_draw || !dm->numTessFaceData) return; face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL); @@ -329,7 +334,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) if(mf) { if( GPU_buffer_legacy(dm) ) { glBegin(GL_LINES); - for(i = 0; i < dm->numFaceData; i++, mf++, tf++) { + for(i = 0; i < dm->numTessFaceData; i++, mf++, tf++) { if(!(mf->flag&ME_HIDE)) { glVertex2fv(tf->uv[0]); glVertex2fv(tf->uv[1]); @@ -359,7 +364,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) GPU_uvedge_setup(dm); if( !GPU_buffer_legacy(dm) ) { - for(i = 0; i < dm->numFaceData; i++, mf++) { + for(i = 0; i < dm->numTessFaceData; i++, mf++) { if(!(mf->flag&ME_HIDE)) { draw = 1; } @@ -506,7 +511,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, } if(cddm->pbvh && cddm->pbvh_draw) { - if(dm->numFaceData) { + if(dm->numTessFaceData) { float (*face_nors)[3] = CustomData_get_layer(&dm->faceData, CD_NORMAL); /* should be per face */ @@ -524,7 +529,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, if( GPU_buffer_legacy(dm) ) { DEBUG_VBO( "Using legacy code. cdDM_drawFacesSolid\n" ); glBegin(glmode = GL_QUADS); - for(a = 0; a < dm->numFaceData; a++, mface++) { + for(a = 0; a < dm->numTessFaceData; a++, mface++) { int new_glmode, new_matnr, new_shademodel; new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES; @@ -617,7 +622,7 @@ static void cdDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned cha DEBUG_VBO( "Using legacy code. cdDM_drawFacesColored\n" ); glShadeModel(GL_SMOOTH); glBegin(glmode = GL_QUADS); - for(a = 0; a < dm->numFaceData; a++, mface++, cp1 += 16) { + for(a = 0; a < dm->numTessFaceData; a++, mface++, cp1 += 16) { int new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES; if(new_glmode != glmode) { @@ -696,7 +701,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, if( GPU_buffer_legacy(dm) ) { DEBUG_VBO( "Using legacy code. cdDM_drawFacesTex_common\n" ); - for(i = 0; i < dm->numFaceData; i++, mf++) { + for(i = 0; i < dm->numTessFaceData; i++, mf++) { MVert *mvert; int flag; unsigned char *cp = NULL; @@ -892,7 +897,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us * color array temporarily overwritten for drawing, then reset. */ if( GPU_buffer_legacy(dm) || G.f & G_BACKBUFSEL) { DEBUG_VBO( "Using legacy code. cdDM_drawMappedFaces\n" ); - for(i = 0; i < dm->numFaceData; i++, mf++) { + for(i = 0; i < dm->numTessFaceData; i++, mf++) { int drawSmooth = (mf->flag & ME_SMOOTH); int draw= 1; @@ -1116,7 +1121,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo glBegin(GL_QUADS); - for(a = 0; a < dm->numFaceData; a++, mface++) { + for(a = 0; a < dm->numTessFaceData; a++, mface++) { const int smoothnormal = (mface->flag & ME_SMOOTH); new_matnr = mface->mat_nr + 1; @@ -1409,7 +1414,7 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm, glBegin(GL_QUADS); - for(a = 0; a < dm->numFaceData; a++, mf++) { + for(a = 0; a < dm->numTessFaceData; a++, mf++) { const int smoothnormal = (mf->flag & ME_SMOOTH); /* material */ @@ -1580,13 +1585,13 @@ void CDDM_recalc_tesselation(DerivedMesh *dm) { CDDerivedMesh *cddm = (CDDerivedMesh*)dm; - dm->numFaceData = mesh_recalcTesselation(&dm->faceData, &dm->loopData, - &dm->polyData, cddm->mvert, dm->numFaceData, dm->numLoopData, + dm->numTessFaceData = mesh_recalcTesselation(&dm->faceData, &dm->loopData, + &dm->polyData, cddm->mvert, dm->numTessFaceData, dm->numLoopData, dm->numPolyData); if (!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX)) { int *polyIndex = CustomData_get_layer(&dm->faceData, CD_POLYINDEX); - CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_REFERENCE, polyIndex, dm->numFaceData); + CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_REFERENCE, polyIndex, dm->numTessFaceData); } cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE); @@ -1627,6 +1632,7 @@ static CDDerivedMesh *cdDM_create(const char *desc) dm->getNumVerts = cdDM_getNumVerts; dm->getNumEdges = cdDM_getNumEdges; dm->getNumTessFaces = cdDM_getNumTessFaces; + dm->getNumLoops = cdDM_getNumLoops; dm->getNumPolys = cdDM_getNumPolys; dm->getVert = cdDM_getVert; @@ -1681,22 +1687,22 @@ static CDDerivedMesh *cdDM_create(const char *desc) return cddm; } -DerivedMesh *CDDM_new(int numVerts, int numEdges, int numFaces, int numLoops, int numPolys) +DerivedMesh *CDDM_new(int numVerts, int numEdges, int numTessFaces, int numLoops, int numPolys) { CDDerivedMesh *cddm = cdDM_create("CDDM_new dm"); DerivedMesh *dm = &cddm->dm; - DM_init(dm, DM_TYPE_CDDM, numVerts, numEdges, numFaces, numLoops, numPolys); + DM_init(dm, DM_TYPE_CDDM, numVerts, numEdges, numTessFaces, numLoops, numPolys); CustomData_add_layer(&dm->vertData, CD_ORIGINDEX, CD_CALLOC, NULL, numVerts); CustomData_add_layer(&dm->edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges); - CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_CALLOC, NULL, numFaces); - CustomData_add_layer(&dm->faceData, CD_POLYINDEX, CD_CALLOC, NULL, numFaces); + CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_CALLOC, NULL, numTessFaces); + CustomData_add_layer(&dm->faceData, CD_POLYINDEX, CD_CALLOC, NULL, numTessFaces); CustomData_add_layer(&dm->polyData, CD_ORIGINDEX, CD_CALLOC, NULL, numPolys); CustomData_add_layer(&dm->vertData, CD_MVERT, CD_CALLOC, NULL, numVerts); CustomData_add_layer(&dm->edgeData, CD_MEDGE, CD_CALLOC, NULL, numEdges); - CustomData_add_layer(&dm->faceData, CD_MFACE, CD_CALLOC, NULL, numFaces); + CustomData_add_layer(&dm->faceData, CD_MFACE, CD_CALLOC, NULL, numTessFaces); CustomData_add_layer(&dm->loopData, CD_MLOOP, CD_CALLOC, NULL, numLoops); CustomData_add_layer(&dm->polyData, CD_MPOLY, CD_CALLOC, NULL, numPolys); @@ -1778,9 +1784,9 @@ static DerivedMesh *UNUSED_FUNCTION(CDDM_from_editmesh)(EditMesh *em, Mesh *UNUS /* CustomData_merge(&em->edata, &dm->edgeData, CD_MASK_DERIVEDMESH, CD_CALLOC, dm->numEdgeData); */ CustomData_merge(&em->fdata, &dm->faceData, CD_MASK_DERIVEDMESH, - CD_CALLOC, dm->numFaceData); + CD_CALLOC, dm->numTessFaceData); CustomData_merge(&em->fdata, &dm->faceData, CD_MASK_DERIVEDMESH, - CD_CALLOC, dm->numFaceData); + CD_CALLOC, dm->numTessFaceData); /* set eve->hash to vert index */ for(i = 0, eve = em->verts.first; eve; eve = eve->next, ++i) @@ -1835,7 +1841,7 @@ static DerivedMesh *UNUSED_FUNCTION(CDDM_from_editmesh)(EditMesh *em, Mesh *UNUS } index = dm->getTessFaceDataArray(dm, CD_POLYINDEX); - for(i = 0, efa = em->faces.first; i < dm->numFaceData; + for(i = 0, efa = em->faces.first; i < dm->numTessFaceData; i++, efa = efa->next, index++) { MFace *mf = &mface[i]; @@ -2052,7 +2058,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis polyindex = dm->getTessFaceDataArray(dm, CD_POLYINDEX); index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); - for(i = 0; i < dm->numFaceData; i++, index++, polyindex++) { + for(i = 0; i < dm->numTessFaceData; i++, index++, polyindex++) { MFace *mf = &mface[i]; BMLoop **l = em->looptris[i]; efa = l[0]->f; @@ -2106,7 +2112,7 @@ DerivedMesh *CDDM_copy(DerivedMesh *source, int faces_from_tessfaces) DerivedMesh *dm = &cddm->dm; int numVerts = source->numVertData; int numEdges = source->numEdgeData; - int numFaces = source->numFaceData; + int numTessFaces = source->numTessFaceData; int numLoops = source->numLoopData; int numPolys = source->numPolyData; @@ -2116,13 +2122,13 @@ DerivedMesh *CDDM_copy(DerivedMesh *source, int faces_from_tessfaces) source->getTessFaceDataArray(source, CD_ORIGINDEX); /* this initializes dm, and copies all non mvert/medge/mface layers */ - DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, numFaces, + DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, numTessFaces, numLoops, numPolys); dm->deformedOnly = source->deformedOnly; CustomData_copy_data(&source->vertData, &dm->vertData, 0, 0, numVerts); CustomData_copy_data(&source->edgeData, &dm->edgeData, 0, 0, numEdges); - CustomData_copy_data(&source->faceData, &dm->faceData, 0, 0, numFaces); + CustomData_copy_data(&source->faceData, &dm->faceData, 0, 0, numTessFaces); /* now add mvert/medge/mface layers */ cddm->mvert = source->dupVertArray(source); @@ -2131,7 +2137,7 @@ DerivedMesh *CDDM_copy(DerivedMesh *source, int faces_from_tessfaces) CustomData_add_layer(&dm->vertData, CD_MVERT, CD_ASSIGN, cddm->mvert, numVerts); CustomData_add_layer(&dm->edgeData, CD_MEDGE, CD_ASSIGN, cddm->medge, numEdges); - CustomData_add_layer(&dm->faceData, CD_MFACE, CD_ASSIGN, cddm->mface, numFaces); + CustomData_add_layer(&dm->faceData, CD_MFACE, CD_ASSIGN, cddm->mface, numTessFaces); if (!faces_from_tessfaces) DM_DupPolys(source, dm); @@ -2151,8 +2157,8 @@ DerivedMesh *CDDM_copy(DerivedMesh *source, int faces_from_tessfaces) /* note, the CD_ORIGINDEX layers are all 0, so if there is a direct * relationship betwen mesh data this needs to be set by the caller. */ DerivedMesh *CDDM_from_template(DerivedMesh *source, - int numVerts, int numEdges, int numFaces, - int numLoops, int numPolys) + int numVerts, int numEdges, int numTessFaces, + int numLoops, int numPolys) { CDDerivedMesh *cddm = cdDM_create("CDDM_from_template dest"); DerivedMesh *dm = &cddm->dm; @@ -2163,12 +2169,12 @@ DerivedMesh *CDDM_from_template(DerivedMesh *source, source->getTessFaceDataArray(source, CD_ORIGINDEX); /* this does a copy of all non mvert/medge/mface layers */ - DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, numFaces, numLoops, numPolys); + DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, numTessFaces, numLoops, numPolys); /* now add mvert/medge/mface layers */ CustomData_add_layer(&dm->vertData, CD_MVERT, CD_CALLOC, NULL, numVerts); CustomData_add_layer(&dm->edgeData, CD_MEDGE, CD_CALLOC, NULL, numEdges); - CustomData_add_layer(&dm->faceData, CD_MFACE, CD_CALLOC, NULL, numFaces); + CustomData_add_layer(&dm->faceData, CD_MFACE, CD_CALLOC, NULL, numTessFaces); CustomData_add_layer(&dm->loopData, CD_MLOOP, CD_CALLOC, NULL, numLoops); CustomData_add_layer(&dm->polyData, CD_MPOLY, CD_CALLOC, NULL, numPolys); @@ -2177,9 +2183,9 @@ DerivedMesh *CDDM_from_template(DerivedMesh *source, if(!CustomData_get_layer(&dm->edgeData, CD_ORIGINDEX)) CustomData_add_layer(&dm->edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges); if(!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX)) - CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_CALLOC, NULL, numFaces); + CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_CALLOC, NULL, numTessFaces); if(!CustomData_get_layer(&dm->faceData, CD_POLYINDEX)) - CustomData_add_layer(&dm->faceData, CD_POLYINDEX, CD_CALLOC, NULL, numFaces); + CustomData_add_layer(&dm->faceData, CD_POLYINDEX, CD_CALLOC, NULL, numTessFaces); cddm->mvert = CustomData_get_layer(&dm->vertData, CD_MVERT); cddm->medge = CustomData_get_layer(&dm->edgeData, CD_MEDGE); @@ -2228,25 +2234,25 @@ void CDDM_calc_normals(DerivedMesh *dm) /* we don't want to overwrite any referenced layers */ cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT); - if (dm->numFaceData == 0) { + if (dm->numTessFaceData == 0) { /* No tesselation on this mesh yet, need to calculate one */ CDDM_recalc_tesselation(dm); } else { /* A tesselation already exists, it should always have a CD_POLYINDEX */ BLI_assert(CustomData_has_layer(&dm->faceData, CD_POLYINDEX)); - CustomData_free_layers(&dm->faceData, CD_NORMAL, dm->numFaceData); + CustomData_free_layers(&dm->faceData, CD_NORMAL, dm->numTessFaceData); } - face_nors = MEM_mallocN(sizeof(float)*3*dm->numFaceData, "face_nors"); + face_nors = MEM_mallocN(sizeof(float)*3*dm->numTessFaceData, "face_nors"); /* calculate face normals */ mesh_calc_normals(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm), - dm->numLoopData, dm->numPolyData, NULL, cddm->mface, dm->numFaceData, + dm->numLoopData, dm->numPolyData, NULL, cddm->mface, dm->numTessFaceData, CustomData_get_layer(&dm->faceData, CD_POLYINDEX), face_nors); CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN, - face_nors, dm->numFaceData); + face_nors, dm->numTessFaceData); } #if 1 @@ -2455,7 +2461,7 @@ void CDDM_calc_edges(DerivedMesh *dm) MFace *mf = cddm->mface; MEdge *med; EdgeHash *eh = BLI_edgehash_new(); - int i, *index, numEdges, maxFaces = dm->numFaceData; + int i, *index, numEdges, maxFaces = dm->numTessFaceData; for (i = 0; i < maxFaces; i++, mf++) { if (!BLI_edgehash_haskey(eh, mf->v1, mf->v2)) @@ -2595,12 +2601,12 @@ void CDDM_lower_num_edges(DerivedMesh *dm, int numEdges) dm->numEdgeData = numEdges; } -void CDDM_lower_num_faces(DerivedMesh *dm, int numFaces) +void CDDM_lower_num_polys(DerivedMesh *dm, int numPolys) { - if (numFaces < dm->numFaceData) - CustomData_free_elem(&dm->faceData, numFaces, dm->numFaceData-numFaces); + if (numPolys < dm->numPolyData) + CustomData_free_elem(&dm->polyData, numPolys, dm->numPolyData-numPolys); - dm->numFaceData = numFaces; + dm->numPolyData = numPolys; } MVert *CDDM_get_vert(DerivedMesh *dm, int index) @@ -2663,7 +2669,7 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm) mf = cddm->mface; totloop = 0; - for (i=0; i<cddm->dm.numFaceData; i++, mf++) { + for (i=0; i<cddm->dm.numTessFaceData; i++, mf++) { totloop += mf->v4 ? 4 : 3; } @@ -2671,7 +2677,7 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm) CustomData_free(&cddm->dm.loopData, cddm->dm.numLoopData); cddm->dm.numLoopData = totloop; - cddm->dm.numPolyData = cddm->dm.numFaceData; + cddm->dm.numPolyData = cddm->dm.numTessFaceData; if (totloop) { MLoop *ml; @@ -2679,12 +2685,12 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm) int l, *polyindex; cddm->mloop = MEM_callocN(sizeof(MLoop)*totloop, "cddm->mloop in CDDM_tessfaces_to_faces"); - cddm->mpoly = MEM_callocN(sizeof(MPoly)*cddm->dm.numFaceData, "cddm->mpoly in CDDM_tessfaces_to_faces"); + cddm->mpoly = MEM_callocN(sizeof(MPoly)*cddm->dm.numTessFaceData, "cddm->mpoly in CDDM_tessfaces_to_faces"); CustomData_add_layer(&cddm->dm.loopData, CD_MLOOP, CD_ASSIGN, cddm->mloop, totloop); CustomData_add_layer(&cddm->dm.polyData, CD_MPOLY, CD_ASSIGN, cddm->mpoly, cddm->dm.numPolyData); CustomData_merge(&cddm->dm.faceData, &cddm->dm.polyData, - CD_MASK_ORIGINDEX, CD_DUPLICATE, cddm->dm.numFaceData); + CD_MASK_ORIGINDEX, CD_DUPLICATE, cddm->dm.numTessFaceData); polyindex = CustomData_get_layer(&cddm->dm.faceData, CD_POLYINDEX); @@ -2692,7 +2698,7 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm) mp = cddm->mpoly; ml = cddm->mloop; l = 0; - for (i=0; i<cddm->dm.numFaceData; i++, mf++, mp++) { + for (i=0; i<cddm->dm.numTessFaceData; i++, mf++, mp++) { mp->flag = mf->flag; mp->loopstart = l; mp->mat_nr = mf->mat_nr; @@ -2748,7 +2754,7 @@ void CDDM_set_mface(DerivedMesh *dm, MFace *mface) CDDerivedMesh *cddm = (CDDerivedMesh*)dm; if (!CustomData_has_layer(&dm->faceData, CD_MFACE)) - CustomData_add_layer(&dm->faceData, CD_MFACE, CD_ASSIGN, mface, dm->numFaceData); + CustomData_add_layer(&dm->faceData, CD_MFACE, CD_ASSIGN, mface, dm->numTessFaceData); cddm->mface = mface; } diff --git a/source/blender/blenkernel/intern/editderivedbmesh.c b/source/blender/blenkernel/intern/editderivedbmesh.c index 55dd20061d8..08c4ea5fa00 100644 --- a/source/blender/blenkernel/intern/editderivedbmesh.c +++ b/source/blender/blenkernel/intern/editderivedbmesh.c @@ -1276,6 +1276,13 @@ static int bmDM_getNumTessFaces(DerivedMesh *dm) return bmdm->tc->tottri; } +static int bmDM_getNumLoops(DerivedMesh *dm) +{ + EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + + return bmdm->tc->bm->totloop; +} + static int bmDM_getNumPolys(DerivedMesh *dm) { EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; @@ -1625,6 +1632,7 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em, Object *UNUSED(ob), bmdm->dm.getNumVerts = bmDM_getNumVerts; bmdm->dm.getNumEdges = bmDM_getNumEdges; bmdm->dm.getNumTessFaces = bmDM_getNumTessFaces; + bmdm->dm.getNumLoops = bmDM_getNumLoops; bmdm->dm.getNumPolys = bmDM_getNumPolys; bmdm->dm.getVert = bmDM_getVert; diff --git a/source/blender/blenkernel/intern/navmesh_conversion.c b/source/blender/blenkernel/intern/navmesh_conversion.c index 53eee35de3a..72523ae54e0 100644 --- a/source/blender/blenkernel/intern/navmesh_conversion.c +++ b/source/blender/blenkernel/intern/navmesh_conversion.c @@ -134,7 +134,7 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r, } //calculate number of tris - nfaces = dm->getNumFaces(dm); + nfaces = dm->getNumTessFaces(dm); faces = dm->getTessFaceArray(dm); ntris = nfaces; for (fi=0; fi<nfaces; fi++) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 3c5674f0b0f..7a5f5524fbd 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1271,7 +1271,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D COMPARE_ORIG_INDEX= dm->getVertDataArray(dm, CD_ORIGINDEX); } else { - if(dm->numFaceData) + if(dm->numTessFaceData) COMPARE_ORIG_INDEX= dm->getTessFaceDataArray(dm, CD_ORIGINDEX); } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index de1818475ef..74664963988 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -673,6 +673,12 @@ static int cgdm_getNumTessFaces(DerivedMesh *dm) { return ccgSubSurf_getNumFinalFaces(cgdm->ss); } +static int cgdm_getNumLoops(DerivedMesh *dm) { + CCGDerivedMesh *cgdm = (CCGDerivedMesh*) dm; + + /* All subsurf faces are quads */ + return 4 * ccgSubSurf_getNumFinalFaces(cgdm->ss); +} static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv) { @@ -901,7 +907,7 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf) char *faceFlags = cgdm->faceFlags; memset(mf, 0, sizeof(*mf)); - if (faceNum >= cgdm->dm.numFaceData) + if (faceNum >= cgdm->dm.numTessFaceData) return; i = cgdm->reverseFaceMap[faceNum]; @@ -1526,7 +1532,7 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes) ccgdm_pbvh_update(ccgdm); if(ccgdm->pbvh && ccgdm->multires.mmd && !fast) { - if(dm->numFaceData) { + if(dm->numTessFaceData) { /* should be per face */ if(!setMaterial(faceFlags[1]+1, NULL)) return; @@ -2123,7 +2129,7 @@ static void cgdm_drawUVEdges(DerivedMesh *dm) if (tf) { glBegin(GL_LINES); - for(i = 0; i < dm->numFaceData; i++, mf++, tf++) { + for(i = 0; i < dm->numTessFaceData; i++, mf++, tf++) { if(!(mf->flag&ME_HIDE)) { glVertex2fv(tf->uv[0]); glVertex2fv(tf->uv[1]); @@ -2861,6 +2867,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, ccgdm->dm.getNumVerts = cgdm_getNumVerts; ccgdm->dm.getNumEdges = cgdm_getNumEdges; ccgdm->dm.getNumTessFaces = cgdm_getNumTessFaces; + ccgdm->dm.getNumLoops = cgdm_getNumLoops; /* reuse of cgdm_getNumTessFaces is intentional here: subsurf polys are just created from tessfaces */ ccgdm->dm.getNumPolys = cgdm_getNumTessFaces; @@ -3218,7 +3225,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, ccgdm->dm.numVertData = vertNum; ccgdm->dm.numEdgeData = edgeNum; - ccgdm->dm.numFaceData = faceNum; + ccgdm->dm.numTessFaceData = faceNum; ccgdm->dm.numLoopData = loopindex2; ccgdm->dm.numPolyData = faceNum; diff --git a/source/blender/bmesh/intern/in-progress/BME_conversions.c b/source/blender/bmesh/intern/in-progress/BME_conversions.c index 2ed91c736fc..5e6d0019d32 100644 --- a/source/blender/bmesh/intern/in-progress/BME_conversions.c +++ b/source/blender/bmesh/intern/in-progress/BME_conversions.c @@ -304,10 +304,10 @@ BMMesh *derivedmesh_to_bmesh(DerivedMesh *dm) totvert = dm->getNumVerts(dm); totedge = dm->getNumEdges(dm); - totface = dm->getNumFaces(dm); + totface = dm->getNumTessFaces(dm); mvert = dm->getVertArray(dm); medge = dm->getEdgeArray(dm); - mface = dm->getFaceArray(dm); + mface = dm->getTessFaceArray(dm); vert_array = MEM_mallocN(sizeof(BMVert *)* totvert,"derivedmesh to bmesh vertex pointer array"); diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 8bc9755faae..c4eacff11c5 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -321,8 +321,8 @@ std::string GeometryExporter::makeTexcoordSourceId(std::string& geom_id, int lay void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me) { #if 0 - int totfaces = dm->getNumFaces(dm); - MFace *mfaces = dm->getFaceArray(dm); + int totfaces = dm->getNumTessFaces(dm); + MFace *mfaces = dm->getTessFaceArray(dm); #endif int totfaces = me->totface; MFace *mfaces = me->mface; diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index ed37f2056ad..333cd2ef7ca 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -1883,7 +1883,7 @@ static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifie LaplacianSystem *sys; MFace *mface= dm->getTessFaceArray(dm), *mf; int totvert= dm->getNumVerts(dm); - int totface= dm->getNumFaces(dm); + int totface= dm->getNumTessFaces(dm); float solution, weight; int a, tottri, j, thrownerror = 0; diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index d3d43581c90..d448de139a6 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -501,7 +501,7 @@ static void add_tface_color_layer(DerivedMesh *dm) } } } - CustomData_add_layer( &dm->faceData, CD_TEXTURE_MCOL, CD_ASSIGN, finalCol, dm->numFaceData ); + CustomData_add_layer( &dm->faceData, CD_TEXTURE_MCOL, CD_ASSIGN, finalCol, dm->numTessFaceData ); } static int draw_tface_mapped__set_draw(void *userData, int index) diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 25347cc54c6..0cbe5d72bfd 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -783,7 +783,7 @@ static void GPU_buffer_copy_uvedge(DerivedMesh *dm, float *varray, int *UNUSED(i if(!tf) return; - for(i = 0; i < dm->numFaceData; i++, tf++) { + for(i = 0; i < dm->numTessFaceData; i++, tf++) { MFace mf; dm->getTessFace(dm,i,&mf); diff --git a/source/blender/modifiers/intern/MOD_ngoninterp.c b/source/blender/modifiers/intern/MOD_ngoninterp.c index 2f06bb5cea4..0c5995fa3d4 100644 --- a/source/blender/modifiers/intern/MOD_ngoninterp.c +++ b/source/blender/modifiers/intern/MOD_ngoninterp.c @@ -120,7 +120,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), BLI_array_append(origv, ov ? ov[i] : i); } - for (i=0; i<dm->numFaceData; i++, mf++, of++) { + for (i=0; i<dm->numTessFaceData; i++, mf++, of++) { int x, y, x2; float fac; diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index 0b02cadfa4a..f5e5c175972 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -445,7 +445,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, cfra -= omd->bakestart; // shift to 0 based num_verts = dm->getNumVerts(dm); - num_faces = dm->getNumFaces(dm); + num_faces = dm->getNumPolys(dm); mverts = dm->getVertArray(dm); mloops = dm->getLoopArray(dm); |