diff options
author | Ton Roosendaal <ton@blender.org> | 2004-10-01 00:38:35 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2004-10-01 00:38:35 +0400 |
commit | 8ae56af0cf3af36d4f0a9b21575e773ba678bb49 (patch) | |
tree | bccb08b605bc21001d11a25e22ffa84a30285be1 /source/blender/blenkernel/intern | |
parent | 742e00db3f92eb43449027bd2ece97bbfd5b4aa5 (diff) |
Recoded how 'handles' were implemented; these were extra wireframe edges
actually, adding vertices and edges to displist.
Now the subsurfer gives editvertices a pointer to the subsurfed vertex
location; allowing not only vertices in 'optimal' draw to show correct, but
also gives proper handling of borderselect and lasso for edges. :)
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/displist.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf.c | 56 |
2 files changed, 17 insertions, 41 deletions
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index a9e2e879c51..d1542165686 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -109,6 +109,7 @@ 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"); @@ -130,6 +131,7 @@ DispListMesh *displistmesh_from_editmesh(EditMesh *em) 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 */ } diff --git a/source/blender/blenkernel/intern/subsurf.c b/source/blender/blenkernel/intern/subsurf.c index 00070fef72c..6e29f1b4add 100644 --- a/source/blender/blenkernel/intern/subsurf.c +++ b/source/blender/blenkernel/intern/subsurf.c @@ -171,7 +171,7 @@ struct _HyperVert { HyperVert *next; float co[3]; - float *orig; // if set, pointer to original vertex, for handles + EditVert *orig; // if set, pointer to original vertex HyperVert *nmv; LinkNode *edges, *faces; }; @@ -256,7 +256,7 @@ static HyperVert *hyperedge_other_vert(HyperEdge *e, HyperVert *a) { return (a==e->v[0])?e->v[1]:e->v[0]; } -static HyperVert *hypermesh_add_vert(HyperMesh *hme, float *co, float *orig) { +static HyperVert *hypermesh_add_vert(HyperMesh *hme, float *co, EditVert *orig) { HyperVert *hv= BLI_memarena_alloc(hme->arena, sizeof(*hv)); hv->nmv= NULL; @@ -454,11 +454,11 @@ static HyperMesh *hypermesh_from_editmesh(EditMesh *em, int subdivLevels) { for (ee= em->edges.first; ee; ee= ee->next) { if(ee->v1->f1) { - ee->v1->prev= (EditVert*) hypermesh_add_vert(hme, ee->v1->co, ee->v1->co); + ee->v1->prev= (EditVert*) hypermesh_add_vert(hme, ee->v1->co, ee->v1); ee->v1->f1= 0; } if(ee->v2->f1) { - ee->v2->prev= (EditVert*) hypermesh_add_vert(hme, ee->v2->co, ee->v2->co); + ee->v2->prev= (EditVert*) hypermesh_add_vert(hme, ee->v2->co, ee->v2); ee->v2->f1= 0; } if((ee->h & 1)==0) { @@ -899,16 +899,6 @@ static int hypermesh_get_nverts(HyperMesh *hme) { return count; } -static int hypermesh_get_nverts_handles(HyperMesh *hme) { - HyperVert *v; - int count= 0; - - for (v= hme->verts; v; v= v->next) - if(v->orig) count++; - - return count; -} - static int hypermesh_get_nfaces(HyperMesh *hme) { HyperFace *f; int count= 0; @@ -929,7 +919,7 @@ static int hypermesh_get_nedges(HyperMesh *hme) { return count; } -/* flag is me->flag, for handles and 'optim' */ +/* flag is me->flag, for 'optim' */ static DispListMesh *hypermesh_to_displistmesh(HyperMesh *hme, short flag) { int nverts= hypermesh_get_nverts(hme); int nedges= hypermesh_get_nedges(hme); @@ -941,7 +931,7 @@ static DispListMesh *hypermesh_to_displistmesh(HyperMesh *hme, short flag) { TFace *tfaces; MEdge *med; MFace *mfaces, *mf; - int i, j, handles=0; + int i, j; /* hme->orig_me==NULL if we are working on an editmesh */ if (hme->orig_me) { @@ -952,14 +942,10 @@ static DispListMesh *hypermesh_to_displistmesh(HyperMesh *hme, short flag) { mfaces= NULL; } - /* added: handles for editmode */ - if (hme->orig_me==NULL && (flag & ME_OPT_EDGES)) { - handles= hypermesh_get_nverts_handles(hme); - } - - dlm->totvert= nverts+handles; + /* removed: handles for editmode. it now stores pointer to subsurfed vertex in editvert */ + dlm->totvert= nverts; dlm->totface= nfaces; - dlm->totedge= nedges+handles; + dlm->totedge= nedges; /* calloc for clear flag and nor in mvert */ dlm->mvert= MEM_callocN(dlm->totvert*sizeof(*dlm->mvert), "dlm->mvert"); @@ -999,23 +985,11 @@ static DispListMesh *hypermesh_to_displistmesh(HyperMesh *hme, short flag) { if(e->flag & HE_SEAM) med->flag |= ME_SEAM; } - /* and we add the handles (med is re-used) */ - if(handles) { - MVert *mv= dlm->mvert+nverts; - - i= nverts; - for (v= hme->verts; v; v= v->next) { - if(v->orig) { - /* new vertex */ - Vec3Cpy(mv->co, v->orig); - - /* new edge */ - med->v1= (int) v->nmv; - med->v2= i; - med->flag = ME_EDGEDRAW; - - med++; i++; mv++; - } + /* and we add pointer to subsurfed vertex in editvert */ + if(hme->orig_me==NULL) { + MVert *mv= dlm->mvert; + for (v= hme->verts; v; v= v->next, mv++) { + if(v->orig) v->orig->ssco= mv->co; } } @@ -1094,7 +1068,7 @@ static DispListMesh *hypermesh_to_displistmesh(HyperMesh *hme, short flag) { return dlm; } -/* flag is me->flag, for handles and 'optim' */ +/* flag is me->flag, and 'optim' */ static DispListMesh *subsurf_subdivide_to_displistmesh(HyperMesh *hme, short subdiv, short flag, short type) { DispListMesh *dlm; |