More fixes in object drawing:
authorTon Roosendaal <ton@blender.org>
Wed, 22 Oct 2003 09:06:30 +0000 (09:06 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 22 Oct 2003 09:06:30 +0000 (09:06 +0000)
- transparent faces in editmode don't write in zbuffer anymore (prevents
  drawing errors) but still read (so behind the subsurf faces for example)
- improved drawing 'handles' for subsurf editing
- going in editmode to Solid view, will draw extra wire always, including
  transparent faces when set
- works in all combos... http://www.blender.org/docs/ton/subsurf.html

- fixed error; padplus/padminus didnt work in buttonswindow anymore
- improved buttonswin: when dragging window edge, the buttons dont
  rescale, but stay same size

source/blender/blenkernel/intern/subsurf.c
source/blender/makesdna/DNA_view2d_types.h
source/blender/src/drawipo.c
source/blender/src/drawobject.c
source/blender/src/drawview.c
source/blender/src/interface.c

index 7ca60982d5d57abe41c659f94f28bd682352cd8c..bc1ea3fc478b280484843f67a92b63455bcf9358 100644 (file)
@@ -697,7 +697,8 @@ static int hypermesh_get_nhidden(HyperMesh *hme) {
        return count;
 }
 
-static DispList *hypermesh_to_displist(HyperMesh *hme) {
+/* flag is me->flag, for handles and 'optim' */
+static DispList *hypermesh_to_displist(HyperMesh *hme, short flag) {
        int nverts= hypermesh_get_nverts(hme);
        int nfaces= hypermesh_get_nfaces(hme) + hypermesh_get_nlines(hme) - hypermesh_get_nhidden(hme);
        DispList *dl= MEM_callocN(sizeof(*dl), "dl");
@@ -720,7 +721,7 @@ static DispList *hypermesh_to_displist(HyperMesh *hme) {
        }
 
        /* added: handles for editmode */
-       if (hme->orig_me==NULL) {
+       if (hme->orig_me==NULL && (flag & ME_OPT_EDGES)) {
                handles= hypermesh_get_nverts_handles(hme);
        }
 
@@ -885,7 +886,8 @@ static DispList *hypermesh_to_displist(HyperMesh *hme) {
        return dl;
 }
 
-static DispList *subsurf_subdivide_to_displist(HyperMesh *hme, short subdiv) {
+/* flag is me->flag, for handles and 'optim' */
+static DispList *subsurf_subdivide_to_displist(HyperMesh *hme, short subdiv, short flag) {
        DispList *dl;
        int i;
 
@@ -901,7 +903,7 @@ static DispList *subsurf_subdivide_to_displist(HyperMesh *hme, short subdiv) {
                hme= tmp;
        }
 
-       dl= hypermesh_to_displist(hme);
+       dl= hypermesh_to_displist(hme, flag);
        hypermesh_free(hme);
        
        return dl;
@@ -915,7 +917,7 @@ void subsurf_make_editmesh(Object *ob) {
                HyperMesh *hme= hypermesh_from_editmesh(G.edve.first, G.eded.first, G.edvl.first);
 
                free_displist_by_type(&me->disp, DL_MESH);
-               BLI_addtail(&me->disp, subsurf_subdivide_to_displist(hme, me->subdiv));
+               BLI_addtail(&me->disp, subsurf_subdivide_to_displist(hme, me->subdiv, me->flag));
                
                dl= me->disp.first;
                if(dl && dl->mesh) dl->mesh->flag= me->flag;
@@ -930,7 +932,7 @@ void subsurf_make_mesh(Object *ob, short subdiv) {
                HyperMesh *hme= hypermesh_from_mesh(me, find_displist(&ob->disp, DL_VERTS));
 
                free_displist_by_type(&me->disp, DL_MESH);
-               BLI_addtail(&me->disp, subsurf_subdivide_to_displist(hme, subdiv));
+               BLI_addtail(&me->disp, subsurf_subdivide_to_displist(hme, subdiv, me->flag));
        }
 }
 
@@ -939,7 +941,7 @@ void subsurf_to_mesh(Object *oldob, Mesh *me) {
        
        if (oldme->totface) {
                HyperMesh *hme= hypermesh_from_mesh(oldme, NULL);
-               DispList *dl= subsurf_subdivide_to_displist(hme, oldme->subdiv);
+               DispList *dl= subsurf_subdivide_to_displist(hme, oldme->subdiv, oldme->flag);
                DispListMesh *dlm= dl->mesh;
                MFace *mfaces;
                int i;
@@ -980,7 +982,7 @@ DispList* subsurf_mesh_to_displist(Mesh *me, DispList *dl, short subdiv)
        
        hme= hypermesh_from_mesh(me, dl);
 
-       return subsurf_subdivide_to_displist(hme, subdiv);
+       return subsurf_subdivide_to_displist(hme, subdiv, me->flag);
 }
 
 void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]) 
index a0d9bf53b7aff75f13834ce41d3bae2414a25426..797df42c5a37a9e126b850d6bad226eabe79516f 100644 (file)
@@ -43,6 +43,8 @@ typedef struct View2D {
        float minzoom, maxzoom;
        short scroll, keeptot;
        short keepaspect, keepzoom;
+       short oldwinx, oldwiny;
+       int pad;
 } View2D;
 
 #define V2D_KEEPZOOM   0x0001  
index 24b43bc15c917025b454b930ce8f3c5c8a60f42b..16cf0d4a36ef02dd19c03209ba9e88a7b871624d 100644 (file)
@@ -417,12 +417,23 @@ void test_view2d(View2D *v2d, int winx, int winy)
        }
 
        if(v2d->keepaspect) {
+               short do_x=0, do_y=0;
+               
+               /* when a window edge changes, the aspect ratio can't be used to
+                  find which is the best new 'cur' rect. thats why it stores 'old' */
+               if(winx!=v2d->oldwinx) do_x= 1;
+               if(winy!=v2d->oldwiny) do_y= 1;
+               v2d->oldwinx= winx; 
+               v2d->oldwiny= winy;
+               
                dx= (cur->ymax-cur->ymin)/(cur->xmax-cur->xmin);
                dy= ((float)winy)/((float)winx);
                
-               /* dx/dy is the total aspect */
+               if(do_x==do_y) {
+                       if( dy > 1.0) do_x= 1; else do_x= 0;
+               }
 
-               if( dx/dy > 1.0) {
+               if( do_x ) {
                        
                        /* portrait window: correct for x */
                        dx= cur->ymax-cur->ymin;
index a2bfc701b64f52a175e2bba3a9b371b88e24ee1b..e9d1a93830957efd27d9c4779040e0547ac6773d 100644 (file)
@@ -2387,7 +2387,8 @@ static void drawmeshwire(Object *ob)
                        
                        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                        glEnable(GL_BLEND);
-
+                       glDepthMask(0);         // disable write in zbuffer, needed for nice transp
+                       
                        evl= G.edvl.first;
                        while(evl) {
                                if(evl->v1->h==0 && evl->v2->h==0 && evl->v3->h==0) {
@@ -2431,13 +2432,18 @@ static void drawmeshwire(Object *ob)
                                evl= evl->next;
                        }
                        glDisable(GL_BLEND);
+                       glDepthMask(1);         // restore write in zbuffer
                }
 
                if(mesh_uses_displist(me)) {
-                       if(handles) BIF_ThemeColor(TH_WIRE);
-                       else BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.5);
-                       
-                       drawDispListwire(&me->disp);
+                       /* dont draw the subsurf when solid... then this is a 'drawextra' */
+                       if(handles==0 && ob->dt>OB_WIRE && G.vd->drawtype>OB_WIRE);
+                       else {
+                               if(handles) BIF_ThemeColor(TH_WIRE);
+                               else BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.7);
+                                       
+                               drawDispListwire(&me->disp);
+                       }
                }
                cpack(0x0);
                
index 1d9c58f3ca88b08c93798f653117001167e7fe4e..738415d272424223698a6254c37f98bc0caa5eed 100644 (file)
@@ -458,7 +458,9 @@ static void drawgrid(void)
 
        dx= fabs(x-(wx)*fx/fw);
        if(dx==0) dx= fabs(y-(wy)*fy/fw);
-
+       
+       glDepthMask(0);         // disable write in zbuffer
+       
        /* check zoom out */
        BIF_ThemeColor(TH_GRID);
        persp(PERSP_WIN);
@@ -539,8 +541,8 @@ static void drawgrid(void)
 
        fdrawline(x, 0.0, x, (float)curarea->winy); 
 
+       glDepthMask(1);         // enable write in zbuffer
        persp(PERSP_VIEW);
-       setlinestyle(0);
 }
 
 
@@ -1058,6 +1060,7 @@ void do_viewbuts(unsigned short event)
        case B_OBJECTPANELMEDIAN:
                if(ob) {
                        v3d_editvertex_buts(NULL, ob, 1.0);
+                       makeDispList(ob);
                        allqueue(REDRAWVIEW3D, 1);
                }
                break;
index 81a26f68ea3855858d2a73a4c92a7d7a5693d97d..da825cbbdc04250e961faa52187abf9d883fc782 100644 (file)
@@ -2416,12 +2416,13 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent)
                                }
                                else if(uevent->event==PADPLUSKEY || uevent->event==PADMINUS) {
                                        SpaceLink *sl= curarea->spacedata.first;
-                                       
-                                       if(uevent->event==PADPLUSKEY) sl->blockscale+= 0.1;
-                                       else sl->blockscale-= 0.1;
-                                       CLAMP(sl->blockscale, 0.6, 1.0);
-                                       addqueue(block->winq, REDRAW, 1);
-                                       retval= UI_CONT;
+                                       if(curarea->spacetype!=SPACE_BUTS) {
+                                               if(uevent->event==PADPLUSKEY) sl->blockscale+= 0.1;
+                                               else sl->blockscale-= 0.1;
+                                               CLAMP(sl->blockscale, 0.6, 1.0);
+                                               addqueue(block->winq, REDRAW, 1);
+                                               retval= UI_CONT;
+                                       }
                                }
                        }
                }