- cleaned up edge drawing a tad, there were issues with mesh's
authorDaniel Dunbar <daniel@zuster.org>
Sun, 14 Aug 2005 10:35:58 +0000 (10:35 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sun, 14 Aug 2005 10:35:58 +0000 (10:35 +0000)
   with "loose" edges (edges without a face) and drawing in
   solid mode. they would either not draw, or draw with a nasty
   selection outline. Added a ME_LOOSEEDGE flag to mark such
   edges in displists/mesh and editmode sets it.
 - changed DerivedMesh drawEdges to take an argument whether
   it should draw loose edges or not

source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/makesdna/DNA_meshdata_types.h
source/blender/src/drawobject.c
source/blender/src/editmesh.c

index b6b1cb69c8e6dd53ecb2f47f6682261ff0f64bb6..f221391d6f04fd3cf326c29f8745f55e26f8861c 100644 (file)
@@ -131,7 +131,7 @@ struct DerivedMesh {
                         *
                         * Also called for *final* editmode DerivedMeshes
                         */
-       void (*drawEdges)(DerivedMesh *dm);
+       void (*drawEdges)(DerivedMesh *dm, int drawLooseEdges);
                        
                        /* Draw all edges without faces as lines (no options) */
        void (*drawLooseEdges)(DerivedMesh *dm);
index 08c7b55659c1ebc47ce460ef025ff97853496f7d..e27a4277ffaa3d1e96ac82fd1f5afab4cc8037f5 100644 (file)
@@ -163,7 +163,7 @@ static void meshDM_drawVerts(DerivedMesh *dm)
        }
        glEnd();
 }
-static void meshDM_drawEdges(DerivedMesh *dm)
+static void meshDM_drawEdges(DerivedMesh *dm, int drawLooseEdges)
 {
        MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
        Mesh *me= mdm->me;
@@ -175,7 +175,7 @@ static void meshDM_drawEdges(DerivedMesh *dm)
                
                glBegin(GL_LINES);
                for(a=me->totedge; a>0; a--, medge++) {
-                       if(medge->flag&ME_EDGEDRAW) {
+                       if ((medge->flag&ME_EDGEDRAW) && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) {
                                glVertex3fv(mdm->verts[ medge->v1].co);
                                glVertex3fv(mdm->verts[ medge->v2].co);
                        }
@@ -188,7 +188,7 @@ static void meshDM_drawEdges(DerivedMesh *dm)
                        int test= mface->edcode;
                        
                        if(test) {
-                               if(test&ME_V1V2){
+                               if((test&ME_V1V2) && (drawLooseEdges || mface->v3)) {
                                        glVertex3fv(mdm->verts[mface->v1].co);
                                        glVertex3fv(mdm->verts[mface->v2].co);
                                }
@@ -225,16 +225,28 @@ static void meshDM_drawLooseEdges(DerivedMesh *dm)
        MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm;
        Mesh *me = mdm->me;
        MFace *mface= me->mface;
+       MEdge *medge= me->medge;
        int a;
 
-       glBegin(GL_LINES);
-       for(a=0; a<me->totface; a++, mface++) {
-               if(!mface->v3) {
-                       glVertex3fv(mdm->verts[mface->v3].co);
-                       glVertex3fv(mdm->verts[mface->v4].co);
-               } 
+       if (medge) {
+               glBegin(GL_LINES);
+               for(a=0; a<me->totedge; a++, medge++) {
+                       if ((medge->flag&ME_EDGEDRAW) && (medge->flag&ME_LOOSEEDGE)) {
+                               glVertex3fv(mdm->verts[medge->v1].co);
+                               glVertex3fv(mdm->verts[medge->v2].co);
+                       }
+               }
+               glEnd();
+       } else {
+               glBegin(GL_LINES);
+               for(a=0; a<me->totface; a++, mface++) {
+                       if(!mface->v3) {
+                               glVertex3fv(mdm->verts[mface->v1].co);
+                               glVertex3fv(mdm->verts[mface->v2].co);
+                       } 
+               }
+               glEnd();
        }
-       glEnd();
 }
 static void meshDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int))
 {
@@ -571,7 +583,7 @@ static void emDM_drawMappedEdgesEM(DerivedMesh *dm, int (*setDrawOptions)(void *
                glEnd();
        }
 }
-static void emDM_drawEdges(DerivedMesh *dm)
+static void emDM_drawEdges(DerivedMesh *dm, int drawLooseEdges)
 {
        emDM_drawMappedEdgesEM(dm, NULL, NULL);
 }
@@ -979,7 +991,22 @@ static void ssDM_drawMappedFacesEM(DerivedMesh *dm, int (*setDrawOptions)(void *
 
 static void ssDM_drawLooseEdges(DerivedMesh *dm)
 {
-       /* Can't implement currently */ 
+       SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
+       DispListMesh *dlm = ssdm->dlm;
+       int i;
+
+       if (dlm->medge) {
+               MEdge *medge= dlm->medge;
+       
+               glBegin(GL_LINES);
+               for (i=0; i<dlm->totedge; i++, medge++) {
+                       if (medge->flag&ME_LOOSEEDGE) {
+                               glVertex3fv(dlm->mvert[medge->v1].co); 
+                               glVertex3fv(dlm->mvert[medge->v2].co);
+                       }
+               }
+               glEnd();
+       }
 }
 
 static void ssDM_drawVerts(DerivedMesh *dm)
@@ -995,7 +1022,7 @@ static void ssDM_drawVerts(DerivedMesh *dm)
        }
        bglEnd();
 }
-static void ssDM_drawEdges(DerivedMesh *dm) 
+static void ssDM_drawEdges(DerivedMesh *dm, int drawLooseEdges
 {
        SSDerivedMesh *ssdm = (SSDerivedMesh*) dm;
        DispListMesh *dlm = ssdm->dlm;
@@ -1007,7 +1034,7 @@ static void ssDM_drawEdges(DerivedMesh *dm)
        
                glBegin(GL_LINES);
                for (i=0; i<dlm->totedge; i++, medge++) {
-                       if (medge->flag&ME_EDGEDRAW) {
+                       if ((medge->flag&ME_EDGEDRAW) && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) {
                                glVertex3fv(mvert[medge->v1].co); 
                                glVertex3fv(mvert[medge->v2].co);
                        }
index a073e9749da2cae777e411134f8f5e5f8627ddd9..5a7883122447ae541801760aec3e2c746f4215c3 100644 (file)
@@ -1221,7 +1221,7 @@ void build_particle_system(Object *ob)
        
        if( paf->flag & PAF_STATIC ) deform= 0;
        else {
-               deform= (ob->parent && ob->parent->type==OB_LATTICE);
+               deform= (ob->parent && ob->parent->type==OB_LATTICE && ob->partype==PARSKEL);
                if(deform) init_latt_deform(ob->parent, 0);
        }
        
index 3887fa205bd54227bdf370b0de96e9132800796f..5c4a89ce76da3cac471883347f1a19d43673726e 100644 (file)
@@ -320,6 +320,8 @@ static DispListMesh *ss_to_displistmesh(CCGSubSurf *ss, CCGDerivedMesh *ccgdm, i
                        med->v2 = getEdgeIndex(ss, e, x+1, edgeSize);
                        med->flag = ME_EDGEDRAW|ME_EDGERENDER;
 
+                       if (!ccgSubSurf_getEdgeNumFaces(ss, e)) med->flag |= ME_LOOSEEDGE;
+
                        if (ssFromEditmesh) {
                                EditEdge *eed = ccgSubSurf_getEdgeEdgeHandle(ss, e);
 
@@ -839,7 +841,7 @@ static void ccgDM_drawVerts(DerivedMesh *dm) {
        ccgFaceIterator_free(fi);
        glEnd();
 }
-static void ccgDM_drawEdges(DerivedMesh *dm) {
+static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges) {
        CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
        CCGSubSurf *ss = ccgdm->ss;
        CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss);
@@ -859,6 +861,8 @@ static void ccgDM_drawEdges(DerivedMesh *dm) {
                        if (eed && eed->h!=0)
                                continue;
                }
+               if (!drawLooseEdges && !ccgSubSurf_getEdgeNumFaces(ss, e))
+                       continue;
 
                if (useAging && !(G.f&G_BACKBUFSEL)) {
                        int ageCol = 255-ccgSubSurf_getEdgeAge(ss, e)*4;
index 558e25869bd168017c0e575cfcea8ca908429444..479626ba692c0973777f173e5e8aab68e3da8136 100644 (file)
@@ -82,6 +82,7 @@ typedef struct MSticky {
 #define ME_FGON                        8
                                                // reserve 16 for ME_HIDE
 #define ME_EDGERENDER  32
+#define ME_LOOSEEDGE   64
 
 /* puno = vertexnormal (mface) */
 #define ME_FLIPV1              1
index 846893090027b8c1b9a0452f74f286abc48ba7bd..268eaaf9323800ad5480e32aed1df63cfb4239b2 100644 (file)
@@ -1699,7 +1699,7 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived
        else {
                if (cageDM!=finalDM) {
                        BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.7);
-                       finalDM->drawEdges(finalDM);
+                       finalDM->drawEdges(finalDM, 1);
                }
        }
        
@@ -1775,8 +1775,9 @@ static void draw_mesh_object_outline(Object *ob, DerivedMesh *dm)
                        dm->drawFacesSolid(dm, set_gl_material);
                        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
                }
-               else
-                       dm->drawEdges(dm);
+               else {
+                       dm->drawEdges(dm, 0);
+               }
                                        
                glLineWidth(1.0);
                glDepthMask(1);
@@ -1831,7 +1832,11 @@ static void draw_mesh_fancy(Object *ob, DerivedMesh *baseDM, DerivedMesh *dm, in
                glFrontFace(GL_CCW);
                glDisable(GL_LIGHTING);
 
-               BIF_ThemeColor(TH_WIRE);
+               if(ob->flag & SELECT) {
+                       BIF_ThemeColor((ob==OBACT)?TH_ACTIVE:TH_SELECT);
+               } else {
+                       BIF_ThemeColor(TH_WIRE);
+               }
                dm->drawLooseEdges(dm);
        }
        else if(dt==OB_SHADED) {
@@ -1883,7 +1888,7 @@ static void draw_mesh_fancy(Object *ob, DerivedMesh *baseDM, DerivedMesh *dm, in
                        glDepthMask(0); // disable write in zbuffer, selected edge wires show better
                }
 
-               dm->drawEdges(dm);
+               dm->drawEdges(dm, dt==OB_WIRE);
 
                if (dt!=OB_WIRE) {
                        glDepthMask(1);
index 9f2e23a93a0b6d97abf453d4d07595d6b39ba131..698fc4618a2334a3ad76898f42a8e984b7eb7f2e 100644 (file)
@@ -1053,6 +1053,7 @@ void load_editMesh(void)
                        
                        medge->flag= (eed->f & SELECT) | ME_EDGERENDER;
                        if(eed->f2<2) medge->flag |= ME_EDGEDRAW;
+                       if(eed->f2==0) medge->flag |= ME_LOOSEEDGE;
                        if(eed->seam) medge->flag |= ME_SEAM;
                        if(eed->h & EM_FGON) medge->flag |= ME_FGON;    // different defines yes
                        if(eed->h & 1) medge->flag |= ME_HIDE;