diff options
author | Ton Roosendaal <ton@blender.org> | 2004-07-25 17:36:44 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2004-07-25 17:36:44 +0400 |
commit | fe9336eb880a1a97121e5f2a6a94c93870d4549b (patch) | |
tree | e5ea68c135af88036d392b031065aba78f4715d3 | |
parent | 5881af930604fe978da16c72a821ff429ad8631d (diff) |
Work on creases editing.
- while editing creases (SHIFT+E) it works like scaling now (towards or
away from center selection).
- ESC while crease edit now works.
(note; doesnt fit in Trans structs...)
- button 'draw edges' and 'draw creases' now exclude each other
-rw-r--r-- | source/blender/include/butspace.h | 3 | ||||
-rw-r--r-- | source/blender/src/buttons_editing.c | 14 | ||||
-rw-r--r-- | source/blender/src/editobject.c | 75 |
3 files changed, 68 insertions, 24 deletions
diff --git a/source/blender/include/butspace.h b/source/blender/include/butspace.h index eb9e7455baf..878f9491052 100644 --- a/source/blender/include/butspace.h +++ b/source/blender/include/butspace.h @@ -339,6 +339,9 @@ enum { #define B_CHROMADEPTH 2084 #define B_MAKEEDGES 2085 #define B_DELEDGES 2086 +#define B_DRAWEDGES 2087 +#define B_DRAWCREASES 2088 + /* *********************** */ #define B_CURVEBUTS 2200 diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index d2a967f74ba..635c24d8ce0 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -1997,6 +1997,16 @@ void do_meshbuts(unsigned short event) case B_VERTEXSMOOTH: vertexsmooth(); break; + case B_DRAWEDGES: + G.f &= ~G_DRAWCREASES; + allqueue(REDRAWBUTSEDIT, 0); + allqueue(REDRAWVIEW3D, 0); + break; + case B_DRAWCREASES: + G.f &= ~G_DRAWEDGES; + allqueue(REDRAWBUTSEDIT, 0); + allqueue(REDRAWVIEW3D, 0); + break; } /* WATCH IT: previous events only in editmode! */ } @@ -2071,8 +2081,8 @@ static void editing_panel_mesh_tools1(Object *ob, Mesh *me) uiDefButF(block, NUM, REDRAWVIEW3D, "NSize:", 1090, 131, 166, 19, &editbutsize, 0.001, 2.0, 10, 0, "Sets the length to use when displaying face normals"); uiDefButI(block, TOG|BIT|6, REDRAWVIEW3D, "Draw Normals", 1090,110,166,19, &G.f, 0, 0, 0, 0, "Displays face normals as lines"); uiDefButI(block, TOG|BIT|7, REDRAWVIEW3D, "Draw Faces", 1090,88,166,19, &G.f, 0, 0, 0, 0, "Displays all faces as shades"); - uiDefButI(block, TOG|BIT|18, REDRAWVIEW3D, "Draw Edges", 1090,66,166,19, &G.f, 0, 0, 0, 0, "Displays selected edges using hilights"); - uiDefButI(block, TOG|BIT|19, REDRAWVIEW3D, "Draw Creases", 1090,44,166,19, &G.f, 0, 0, 0, 0, "Displays creased edges using hilights"); + uiDefButI(block, TOG|BIT|18, B_DRAWEDGES, "Draw Edges", 1090,66,166,19, &G.f, 0, 0, 0, 0, "Displays selected edges using hilights"); + uiDefButI(block, TOG|BIT|19, B_DRAWCREASES, "Draw Creases", 1090,44,166,19, &G.f, 0, 0, 0, 0, "Displays creased edges using hilights"); uiDefButI(block, TOG|BIT|20, REDRAWVIEW3D, "Draw Seams", 1090,22,166,19, &G.f, 0, 0, 0, 0, "Displays UV unwrapping seams"); uiDefButI(block, TOG|BIT|11, 0, "All Edges", 1090, 0,166,19, &G.f, 0, 0, 0, 0, "Displays all edges in object mode without optimization"); uiBlockEndAlign(block); diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 209258326e5..b4a0e8d5f07 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -4469,6 +4469,7 @@ void transform(int mode) short canceled = 0; TransOb *tob; TransVert *tv; + float *edge_creases=NULL; /* edge transform isnt really supported... */ float vec[3], min[3], max[3], dvec[3], d_dvec[3], dvecp[3], rot0[3], rot1[3], rot2[3], axis[3]; float totmat[3][3], omat[3][3], imat[3][3], mat[3][3], tmat[3][3], phi, dphi; float oldcurs[3]; @@ -5551,31 +5552,50 @@ void transform(int mode) EditEdge *ee; Mesh *me= G.obedit->data; float mincr=10.0, maxcr= 0.0; - + int tot= 0; + + /* for esc and calculus */ + if(edge_creases==NULL) { + + for(ee = em->edges.first; ee; ee= ee->next, tot++); + edge_creases= MEM_mallocN(sizeof(float)*tot, "transform creases"); + + for(tot= 0, ee = em->edges.first; ee; ee= ee->next, tot++) + edge_creases[tot]= ee->crease; + } + /* this is sufficient to invoke edges added in mesh, but only in editmode */ if(me->medge==NULL) { me->medge= MEM_callocN(sizeof(MEdge), "fake medge"); me->totedge= 1; allqueue(REDRAWBUTSEDIT, 0); } - - dist= (0.005 * (mval[1] - yo)); - - ee = em->edges.first; - while (ee) { + + /* we use input method like scaling, but map effictive range to: + scale 1.0-0.5 : crease no change to full sharp + scale 1.0-2.0 : crease no change to full round */ + dist= (sqrt( (float)((yc-mval[1])*(yc-mval[1])+(mval[0]-xc)*(mval[0]-xc)) ))/sizefac; + CLAMP(dist, 0.5, 2.0); + if(dist<1.0) dist= 2.0*(dist-0.5); + + for(tot= 0, ee = em->edges.first; ee; ee= ee->next, tot++) { if ((ee->v1->f & 1) && (ee->v2->f & 1)) { /* this edge is selected */ - ee->crease += dist; + if(dist<1.0) + ee->crease = (1.0 - dist) + dist*edge_creases[tot]; + else + ee->crease = (2.0-dist)*edge_creases[tot]; + CLAMP(ee->crease, 0.0, 1.0); if(mincr>ee->crease) mincr= ee->crease; if(maxcr<ee->crease) maxcr= ee->crease; } - ee = ee->next; } if(mincr==10.0) wrong= 1; else { - sprintf(str, "Edge sharpness range: %.3f - %.3f", mincr, maxcr); + if(mincr==maxcr) sprintf(str, "Edge sharpness: %.3f", mincr); + else sprintf(str, "Edge sharpness range: %.3f - %.3f", mincr, maxcr); headerprint(str); if(G.obedit) calc_trans_verts(); @@ -6062,18 +6082,28 @@ void transform(int mode) if(event==ESCKEY || event==RIGHTMOUSE) { canceled=1; G.undo_edit_level--; - tv= transvmain; - tob= transmain; - for(a=0; a<tottrans; a++, tob++, tv++) { - if(transmain) { - restore_tob(tob); - } - else { - VECCOPY(tv->loc, tv->oldloc); - if(tv->val) *(tv->val)= tv->oldval; + + if(edge_creases) { // exception case, edges dont fit in Trans structs... + EditEdge *ee; + int tot; + for(tot= 0, ee = G.editMesh->edges.first; ee; ee= ee->next, tot++) + ee->crease= edge_creases[tot]; + } + else { + + tv= transvmain; + tob= transmain; + for(a=0; a<tottrans; a++, tob++, tv++) { + if(transmain) { + restore_tob(tob); + } + else { + VECCOPY(tv->loc, tv->oldloc); + if(tv->val) *(tv->val)= tv->oldval; + } } + if(G.obedit) calc_trans_verts(); } - if(G.obedit) calc_trans_verts(); special_trans_update(keyflags); if (mode == '0') VECCOPY(curs, oldcurs); } @@ -6090,10 +6120,11 @@ void transform(int mode) clearbaseflags_for_editing(); if(transmain) MEM_freeN(transmain); - transmain= 0; + transmain= NULL; if(transvmain) MEM_freeN(transvmain); - transvmain= 0; - + transvmain= NULL; + if(edge_creases) MEM_freeN(edge_creases); + tottrans= 0; } |