diff options
author | Daniel Dunbar <daniel@zuster.org> | 2005-04-04 08:50:41 +0400 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2005-04-04 08:50:41 +0400 |
commit | 93c66febd7f1e632eaeafda3e07053bc4bcbdc24 (patch) | |
tree | 140f0718f601701e77ceab6fc97ef09946400287 /source/blender | |
parent | 876d8ef7b5d76cafbbf8eea8ce69acd793f5daf6 (diff) |
- removed DispListMesh.{editedge,editface}
- removed displistmesh_from_{mesh,editmesh}
- removed EditVert.ssco
- removed unused functions for DispListMesh DerivedMesh
Still need lots more testing for this stuff.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_DerivedMesh.h | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_displist.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 128 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/displist.c | 118 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 9 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_editVert.h | 1 |
6 files changed, 14 insertions, 258 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 1c21a4f7d7b..b80a1220b98 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -129,17 +129,23 @@ struct DerivedMesh { }; /* Internal function, just temporarily exposed */ -DerivedMesh *derivedmesh_from_displistmesh(struct EditMesh *em, struct DispListMesh *dlm); +DerivedMesh *derivedmesh_from_displistmesh(struct DispListMesh *dlm); DerivedMesh *mesh_get_derived(struct Object *ob); -DerivedMesh *mesh_get_base_derived(struct Object *ob); - DerivedMesh *mesh_get_derived_render(struct Object *ob, int *needsFree_r); + /* IMPORTANT: The functions below do not return "true" DerivedMesh + * objects, rather they are just proxies for the mesh or editmesh + * objects and are used to keep the drawing code consistent. They + * should not be used as general purpose objects (access the Mesh + * or EditMesh directly). + */ + /* Utility function, just chooses appropriate DerivedMesh based * on mesh flags. Release result if *needsFree_r is true. */ DerivedMesh *mesh_get_cage_derived(struct Object *ob, int *needsFree_r); +DerivedMesh *mesh_get_base_derived(struct Object *ob); #endif diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index 0bdcf4da834..ebae7d9bd31 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -97,8 +97,6 @@ struct DispListMesh { struct MCol *mcol; struct MFace *mface; struct TFace *tface; - struct EditEdge **editedge; // added for subsurf, drawobject.c - struct EditFace **editface; // added for subsurf, drawobject.c float *nors; // facenormals }; @@ -107,8 +105,6 @@ void displistmesh_calc_normals(DispListMesh *dlm); void displistmesh_to_mesh(DispListMesh *dlm, struct Mesh *me); -DispListMesh *displistmesh_from_editmesh(struct EditMesh *em); -DispListMesh *displistmesh_from_mesh(struct Mesh *mesh, float *extverts); DispListMesh *displistmesh_copy(DispListMesh *odlm); /* diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 566a6004a07..99adb03b3fd 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -369,35 +369,22 @@ static int meshDM_getNumFaces(DerivedMesh *dm) return me->totface; } -static DispListMesh *meshDM_convertToDispListMesh(DerivedMesh *dm) -{ - MeshDerivedMesh *mdm= (MeshDerivedMesh*) dm; - - return displistmesh_from_mesh(mdm->ob->data, mdm->extverts); -} - - static DerivedMesh *getMeshDerivedMesh(Object *ob, float *extverts, float *nors) { - MeshDerivedMesh *mdm = MEM_mallocN(sizeof(*mdm), "dm"); + MeshDerivedMesh *mdm = MEM_callocN(sizeof(*mdm), "dm"); mdm->dm.getNumVerts = meshDM_getNumVerts; mdm->dm.getNumFaces = meshDM_getNumFaces; - mdm->dm.convertToDispListMesh = meshDM_convertToDispListMesh; mdm->dm.drawVerts = meshDM_drawVerts; - mdm->dm.drawMappedVertsEM = NULL; mdm->dm.drawEdges = meshDM_drawEdges; mdm->dm.drawMappedEdges = meshDM_drawEdges; mdm->dm.drawLooseEdges = meshDM_drawLooseEdges; - mdm->dm.drawMappedEdgeEM = NULL; - mdm->dm.drawMappedEdgesEM = NULL; mdm->dm.drawFacesSolid = meshDM_drawFacesSolid; mdm->dm.drawFacesColored = meshDM_drawFacesColored; mdm->dm.drawFacesTex = meshDM_drawFacesTex; - mdm->dm.drawMappedFacesEM = NULL; mdm->dm.release = (void(*)(DerivedMesh*)) MEM_freeN; @@ -524,35 +511,21 @@ static int emDM_getNumFaces(DerivedMesh *dm) return BLI_countlist(&emdm->em->faces); } -static DispListMesh *emDM_convertToDispListMesh(DerivedMesh *dm) -{ - EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm; - - return displistmesh_from_editmesh(emdm->em); -} - static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em) { - EditMeshDerivedMesh *emdm = MEM_mallocN(sizeof(*emdm), "dm"); + EditMeshDerivedMesh *emdm = MEM_callocN(sizeof(*emdm), "dm"); emdm->dm.getNumVerts = emDM_getNumVerts; emdm->dm.getNumFaces = emDM_getNumFaces; emdm->dm.getMappedVertCoEM = emDM_getMappedVertCoEM; - emdm->dm.convertToDispListMesh = emDM_convertToDispListMesh; - emdm->dm.drawVerts = NULL; emdm->dm.drawMappedVertsEM = emDM_drawMappedVertsEM; - emdm->dm.drawEdges = NULL; - emdm->dm.drawMappedEdges = NULL; - emdm->dm.drawLooseEdges = NULL; emdm->dm.drawMappedEdgeEM = emDM_drawMappedEdgeEM; emdm->dm.drawMappedEdgesEM = emDM_drawMappedEdgesEM; emdm->dm.drawMappedEdgesInterpEM = emDM_drawMappedEdgesInterpEM; emdm->dm.drawFacesSolid = emDM_drawFacesSolid; - emdm->dm.drawFacesColored = NULL; - emdm->dm.drawFacesTex = NULL; emdm->dm.drawMappedFacesEM = emDM_drawMappedFacesEM; emdm->dm.release = (void(*)(DerivedMesh*)) MEM_freeN; @@ -568,33 +541,8 @@ typedef struct { DerivedMesh dm; DispListMesh *dlm; - EditMesh *em; } SSDerivedMesh; -static void ssDM_getMappedVertCoEM(DerivedMesh *dm, void *vert, float co_r[3]) -{ - EditVert *eve = vert; - - // !eve->ssco happens for old subsurf, verts w/ unattached faces - if (eve->ssco) { - co_r[0] = eve->ssco[0]; - co_r[1] = eve->ssco[1]; - co_r[2] = eve->ssco[2]; - } -} -static void ssDM_drawMappedVertsEM(DerivedMesh *dm, int (*setDrawOptions)(void *userData, EditVert *vert), void *userData) -{ - SSDerivedMesh *ssdm = (SSDerivedMesh*) dm; - EditVert *eve; - - bglBegin(GL_POINTS); - for (eve=ssdm->em->verts.first; eve; eve=eve->next) { - if(eve->ssco && (!setDrawOptions || setDrawOptions(userData, eve))) - bglVertex3fv(eve->ssco); - } - bglEnd(); -} - static void ssDM_drawMappedEdges(DerivedMesh *dm) { SSDerivedMesh *ssdm = (SSDerivedMesh*) dm; @@ -618,46 +566,6 @@ static void ssDM_drawLooseEdges(DerivedMesh *dm) /* Can't implement currently */ } -static void ssDM_drawMappedEdgeEM(DerivedMesh *dm, void *edge) -{ - SSDerivedMesh *ssdm = (SSDerivedMesh*) dm; - DispListMesh *dlm = ssdm->dlm; - MEdge *medge= dlm->medge; - MVert *mvert= dlm->mvert; - int a; - - glBegin(GL_LINES); - for (a=0; a<dlm->totedge; a++, medge++) { - if (medge->flag&ME_EDGEDRAW) { - if (edge==dlm->editedge[a]) { - glVertex3fv(mvert[medge->v1].co); - glVertex3fv(mvert[medge->v2].co); - } - } - } - glEnd(); -} -static void ssDM_drawMappedEdgesEM(DerivedMesh *dm, int (*setDrawOptions)(void *userData, EditEdge *edge), void *userData) -{ - SSDerivedMesh *ssdm = (SSDerivedMesh*) dm; - DispListMesh *dlm = ssdm->dlm; - MEdge *medge= dlm->medge; - MVert *mvert= dlm->mvert; - int a; - - glBegin(GL_LINES); - for (a=0; a<dlm->totedge; a++, medge++) { - if (medge->flag&ME_EDGEDRAW) { - EditEdge *eed = dlm->editedge[a]; - - if (eed && (!setDrawOptions || setDrawOptions(userData, eed))) { - glVertex3fv(mvert[medge->v1].co); - glVertex3fv(mvert[medge->v2].co); - } - } - } - glEnd(); -} static void ssDM_drawVerts(DerivedMesh *dm) { SSDerivedMesh *ssdm = (SSDerivedMesh*) dm; @@ -813,27 +721,6 @@ static void ssDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned cha #undef PASSVERT } -static void ssDM_drawMappedFacesEM(DerivedMesh *dm, int (*setDrawOptions)(void *userData, EditFace *face), void *userData) -{ - SSDerivedMesh *ssdm = (SSDerivedMesh*) dm; - DispListMesh *dlm = ssdm->dlm; - MFace *mface= dlm->mface; - int a; - - for(a=0; a<dlm->totface; a++, mface++) { - if(mface->v3) { - if (!setDrawOptions || setDrawOptions(userData, dlm->editface[a])) { - glBegin(mface->v4?GL_QUADS:GL_TRIANGLES); - glVertex3fv(dlm->mvert[mface->v1].co); - glVertex3fv(dlm->mvert[mface->v2].co); - glVertex3fv(dlm->mvert[mface->v3].co); - if (mface->v4) glVertex3fv(dlm->mvert[mface->v4].co); - glEnd(); - } - } - } -} - static void ssDM_drawFacesTex(DerivedMesh *dm, int (*setDrawParams)(TFace *tf, int matnr)) { SSDerivedMesh *ssdm = (SSDerivedMesh*) dm; @@ -920,34 +807,27 @@ static void ssDM_release(DerivedMesh *dm) MEM_freeN(dm); } -DerivedMesh *derivedmesh_from_displistmesh(EditMesh *em, DispListMesh *dlm) +DerivedMesh *derivedmesh_from_displistmesh(DispListMesh *dlm) { - SSDerivedMesh *ssdm = MEM_mallocN(sizeof(*ssdm), "dm"); + SSDerivedMesh *ssdm = MEM_callocN(sizeof(*ssdm), "dm"); ssdm->dm.getNumVerts = ssDM_getNumVerts; ssdm->dm.getNumFaces = ssDM_getNumFaces; - ssdm->dm.getMappedVertCoEM = ssDM_getMappedVertCoEM; ssdm->dm.convertToDispListMesh = ssDM_convertToDispListMesh; ssdm->dm.drawVerts = ssDM_drawVerts; - ssdm->dm.drawMappedVertsEM = ssDM_drawMappedVertsEM; ssdm->dm.drawEdges = ssDM_drawEdges; ssdm->dm.drawMappedEdges = ssDM_drawMappedEdges; ssdm->dm.drawLooseEdges = ssDM_drawLooseEdges; - ssdm->dm.drawMappedEdgeEM = ssDM_drawMappedEdgeEM; - ssdm->dm.drawMappedEdgesEM = ssDM_drawMappedEdgesEM; - ssdm->dm.drawMappedEdgesInterpEM = NULL; ssdm->dm.drawFacesSolid = ssDM_drawFacesSolid; ssdm->dm.drawFacesColored = ssDM_drawFacesColored; ssdm->dm.drawFacesTex = ssDM_drawFacesTex; - ssdm->dm.drawMappedFacesEM = ssDM_drawMappedFacesEM; ssdm->dm.release = ssDM_release; ssdm->dlm = dlm; - ssdm->em = em; return (DerivedMesh*) ssdm; } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 7602bcb48e6..6fc0077d275 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -107,120 +107,6 @@ struct _FastLamp { static FastLamp *fastlamplist= NULL; static float fviewmat[4][4]; -/* only called from subsurf.c when levels is zero */ -DispListMesh *displistmesh_from_editmesh(EditMesh *em) -{ - DispListMesh *dlm= MEM_callocN(sizeof(*dlm),"dlm"); - EditVert *eve, *evePrev; - EditEdge *eed; - EditFace *efa; - MFace *mfNew; - int i; - - dlm->totvert= BLI_countlist(&em->verts); - dlm->totedge= BLI_countlist(&em->edges); - dlm->totface= BLI_countlist(&em->faces); - dlm->editedge= MEM_mallocN(sizeof(*dlm->editedge)*dlm->totedge, "dlm->editedge"); - dlm->editface= MEM_mallocN(sizeof(*dlm->editface)*dlm->totface, "dlm->editface"); - dlm->mvert= MEM_callocN(sizeof(*dlm->mface)*dlm->totvert, "dlm->mvert"); - dlm->mcol= NULL; - dlm->tface= NULL; - dlm->medge= MEM_mallocN(sizeof(*dlm->medge)*dlm->totedge, "dlm->mface"); - dlm->mface= MEM_mallocN(sizeof(*dlm->mface)*dlm->totface, "dlm->mface"); - - i=0; - for (eve= em->verts.first; eve; eve= eve->next, i++) { - MVert *mvNew= &dlm->mvert[i]; - VECCOPY(mvNew->co, eve->co); - eve->ssco= eve->co; /* no subsurf coordinate, but we add a save pointer in it */ - eve->prev= (void*) i; /* hack to fetch indices */ - } - - mfNew= dlm->mface; - for (i=0,efa= em->faces.first; efa; efa= efa->next) { - // we skip hidden faces - if(efa->v1->h || efa->v2->h || efa->v3->h || (efa->v4 && efa->v4->h)) dlm->totface--; - else { - dlm->editface[i++] = efa; - mfNew->v1= (int) efa->v1->prev; - mfNew->v2= (int) efa->v2->prev; - mfNew->v3= (int) efa->v3->prev; - mfNew->v4= efa->v4?(int) efa->v4->prev:0; - mfNew->flag= efa->flag; - mfNew->mat_nr= efa->mat_nr; - mfNew->puno= 0; - mfNew->edcode= 0; - - if (efa->v4 && !mfNew->v4) { - mfNew->v1^= mfNew->v3^= mfNew->v1^= mfNew->v3; - mfNew->v2^= mfNew->v4^= mfNew->v2^= mfNew->v4; - } - mfNew++; - } - } - for (i=0,eed= em->edges.first; eed; eed= eed->next) { - MEdge *medge = &dlm->medge[i]; - dlm->editedge[i++] = eed; - medge->v1 = (int) eed->v1->prev; - medge->v2 = (int) eed->v2->prev; - medge->crease = eed->crease; - medge->flag = ME_EDGEDRAW; - } - - /* restore prev links */ - for (evePrev=NULL, eve= em->verts.first; eve; evePrev=eve, eve= eve->next) - eve->prev= evePrev; - - displistmesh_calc_normals(dlm); - - return dlm; -} -DispListMesh *displistmesh_from_mesh(Mesh *me, float *extverts) -{ - DispListMesh *dlm= MEM_callocN(sizeof(*dlm),"dlm"); - int i; - - if (!me->medge) { - make_edges(me); - } - - dlm->totvert= me->totvert; - dlm->totedge= me->totedge; - dlm->totface= me->totface; - dlm->mvert= MEM_dupallocN(me->mvert); - dlm->mcol= me->mcol?MEM_dupallocN(me->mcol):NULL; - dlm->tface= me->tface?MEM_dupallocN(me->tface):NULL; - dlm->medge= MEM_mallocN(sizeof(*dlm->medge)*dlm->totedge, "dlm->totedge"); - dlm->mface= MEM_mallocN(sizeof(*dlm->mface)*dlm->totface, "dlm->mface"); - - if (extverts) { - for (i=0; i<dlm->totvert; i++) { - VECCOPY(dlm->mvert[i].co, &extverts[i*3]); - } - } - for (i=0; i<dlm->totface; i++) { - MFace *mfOld= &((MFace*) me->mface)[i]; - MFace *mfNew= &dlm->mface[i]; - - mfNew->v1= mfOld->v1; - mfNew->v2= mfOld->v2; - mfNew->v3= mfOld->v3; - mfNew->v4= mfOld->v4; - mfNew->flag= mfOld->flag; - mfNew->mat_nr= mfOld->mat_nr; - mfNew->puno= 0; - mfNew->edcode= 0; - } - for (i=0; i<dlm->totedge; i++) { - dlm->medge[i] = me->medge[i]; - dlm->medge[i].flag |= ME_EDGEDRAW; - } - - displistmesh_calc_normals(dlm); - - return dlm; -} - void displistmesh_free(DispListMesh *dlm) { // also check on mvert and mface, can be NULL after decimator (ton) @@ -229,8 +115,6 @@ void displistmesh_free(DispListMesh *dlm) if (dlm->mface) MEM_freeN(dlm->mface); if (dlm->mcol) MEM_freeN(dlm->mcol); if (dlm->tface) MEM_freeN(dlm->tface); - if (dlm->editedge) MEM_freeN(dlm->editedge); - if (dlm->editface) MEM_freeN(dlm->editface); if (dlm->nors) MEM_freeN(dlm->nors); MEM_freeN(dlm); } @@ -238,8 +122,6 @@ void displistmesh_free(DispListMesh *dlm) DispListMesh *displistmesh_copy(DispListMesh *odlm) { DispListMesh *ndlm= MEM_dupallocN(odlm); - ndlm->editedge= NULL; - ndlm->editface= NULL; ndlm->mvert= MEM_dupallocN(odlm->mvert); ndlm->medge= MEM_dupallocN(odlm->medge); ndlm->mface= MEM_dupallocN(odlm->mface); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 7c5ca9583b3..2f22bce550b 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -293,13 +293,6 @@ static DispListMesh *subSurf_createDispListMesh(SubSurf *ssm) { for (; !ccgVertIterator_isStopped(vi); ccgVertIterator_next(vi)) { CCGVert *v = ccgVertIterator_getCurrent(vi); VecCopyf(dlm->mvert[i].co, ccgSubSurf_getVertData(ss, v)); - - if (ssm->controlType==SUBSURF_CONTROLTYPE_EDITMESH) { - EditVert *ev = ccgSubSurf_getVertVertHandle(ss, v); - - ev->ssco = dlm->mvert[i].co; - } - *((int*) ccgSubSurf_getVertUserData(ss, v)) = i++; } ccgVertIterator_free(vi); @@ -1014,7 +1007,7 @@ DerivedMesh *subsurf_make_derived_from_mesh(Mesh *me, int subdivLevels) { subSurf_free(ss); - return derivedmesh_from_displistmesh(NULL, dlm); + return derivedmesh_from_displistmesh(dlm); } void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]) diff --git a/source/blender/blenlib/BLI_editVert.h b/source/blender/blenlib/BLI_editVert.h index ffc2a3b424e..54d2098ee1a 100644 --- a/source/blender/blenlib/BLI_editVert.h +++ b/source/blender/blenlib/BLI_editVert.h @@ -46,7 +46,6 @@ typedef struct EditVert struct EditVert *next, *prev, *vn; float no[3]; float co[3]; - float *ssco; /* subsurfed coordinate, dont use for temporal storage! it points to DispListMesh */ short xs, ys; unsigned char f, h, f1, f2; short fast; /* only 0 or 1, for editmesh_fastmalloc */ |