diff options
author | Daniel Dunbar <daniel@zuster.org> | 2005-08-21 11:19:20 +0400 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2005-08-21 11:19:20 +0400 |
commit | 7804860cf61b8fc522405740180d10181d174187 (patch) | |
tree | 6331ac308c233fca06416e95d0c0473d3606aa20 /source | |
parent | d29f7c2c8489442bbca4a76774d4f961dad0173b (diff) |
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
Diffstat (limited to 'source')
35 files changed, 825 insertions, 1530 deletions
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index f3d878d5341..90c5dec19b4 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -67,7 +67,6 @@ struct Mesh *get_mesh(struct Object *ob); void set_mesh(struct Object *ob, struct Mesh *me); void mball_to_mesh(struct ListBase *lb, struct Mesh *me); void nurbs_to_mesh(struct Object *ob); -void edge_drawflags_mesh(struct Mesh *me); void mcol_to_tface(struct Mesh *me, int freedata); void tface_to_mcol(struct Mesh *me); void free_dverts(struct MDeformVert *dvert, int totvert); @@ -80,6 +79,7 @@ struct BoundBox *mesh_get_bb(struct Mesh *me); void mesh_get_texspace(struct Mesh *me, float *loc_r, float *rot_r, float *size_r); void make_edges(struct Mesh *me); +void mesh_strip_loose_faces(struct Mesh *me); /* Calculate vertex and face normals, face normals are returned in *faceNors_r if non-NULL * and vertex normals are stored in actual mverts. diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 56415dd816b..b323377bb84 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -172,26 +172,24 @@ static void meshDM_drawUVEdges(DerivedMesh *dm) if (me->tface) { glBegin(GL_LINES); for (i=0; i<me->totface; i++) { - if (me->mface[i].v3) { - TFace *tf = &me->tface[i]; + TFace *tf = &me->tface[i]; - if (!(tf->flag&TF_HIDE)) { - glVertex2fv(tf->uv[0]); - glVertex2fv(tf->uv[1]); + if (!(tf->flag&TF_HIDE)) { + glVertex2fv(tf->uv[0]); + glVertex2fv(tf->uv[1]); - glVertex2fv(tf->uv[1]); - glVertex2fv(tf->uv[2]); + glVertex2fv(tf->uv[1]); + glVertex2fv(tf->uv[2]); - if (!me->mface[i].v4) { - glVertex2fv(tf->uv[2]); - glVertex2fv(tf->uv[0]); - } else { - glVertex2fv(tf->uv[2]); - glVertex2fv(tf->uv[3]); + if (!me->mface[i].v4) { + glVertex2fv(tf->uv[2]); + glVertex2fv(tf->uv[0]); + } else { + glVertex2fv(tf->uv[2]); + glVertex2fv(tf->uv[3]); - glVertex2fv(tf->uv[3]); - glVertex2fv(tf->uv[0]); - } + glVertex2fv(tf->uv[3]); + glVertex2fv(tf->uv[0]); } } } @@ -202,150 +200,34 @@ static void meshDM_drawEdges(DerivedMesh *dm, int drawLooseEdges) { MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm; Mesh *me= mdm->me; + MEdge *medge= me->medge; int a; - MFace *mface = me->mface; - - if(me->medge) { - MEdge *medge= me->medge; - glBegin(GL_LINES); - for(a=me->totedge; a>0; a--, medge++) { - if ((medge->flag&ME_EDGEDRAW) && (drawLooseEdges || !(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++) { - int test= mface->edcode; - - if(test) { - if((test&ME_V1V2) && (drawLooseEdges || mface->v3)) { - glVertex3fv(mdm->verts[mface->v1].co); - glVertex3fv(mdm->verts[mface->v2].co); - } - - if(mface->v3) { - if(test&ME_V2V3){ - glVertex3fv(mdm->verts[mface->v2].co); - glVertex3fv(mdm->verts[mface->v3].co); - } - - if (mface->v4) { - if(test&ME_V3V4){ - glVertex3fv(mdm->verts[mface->v3].co); - glVertex3fv(mdm->verts[mface->v4].co); - } - if(test&ME_V4V1){ - glVertex3fv(mdm->verts[mface->v4].co); - glVertex3fv(mdm->verts[mface->v1].co); - } - } else { - if(test&ME_V3V1){ - glVertex3fv(mdm->verts[mface->v3].co); - glVertex3fv(mdm->verts[mface->v1].co); - } - } - } - } + glBegin(GL_LINES); + for(a=me->totedge; a>0; a--, medge++) { + if ((medge->flag&ME_EDGEDRAW) && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) { + glVertex3fv(mdm->verts[ medge->v1].co); + glVertex3fv(mdm->verts[ medge->v2].co); } - glEnd(); } + glEnd(); } static void meshDM_drawEdgesFlag(DerivedMesh *dm, unsigned int mask, unsigned int value) { MeshDerivedMesh *mdm = (MeshDerivedMesh*) dm; Mesh *me= mdm->me; - int a; MFace *mface = me->mface; - int tfaceFlags = (ME_EDGE_TFSEL|ME_EDGE_TFACT|ME_EDGE_TFVISIBLE|ME_EDGE_TFACTFIRST|ME_EDGE_TFACTLAST); - - if ((mask&tfaceFlags) && me->tface) { - TFace *tface = me->tface; - - glBegin(GL_LINES); - for(a=0; a<me->totface; a++, mface++, tface++) { - if (mface->v3) { - unsigned int flags = ME_EDGEDRAW|ME_EDGEMAPPED; - unsigned int flag0, flag1, flag2, flag3; - - if (tface->flag&TF_SELECT) flags |= ME_EDGE_TFSEL; - if (!(tface->flag&TF_HIDE)) flags |= ME_EDGE_TFVISIBLE; - - if (tface->flag&TF_ACTIVE) { - flags |= ME_EDGE_TFACT; - flag0 = flag1 = flag2 = flag3 = flags; - - flag0 |= ME_EDGE_TFACTFIRST; - flag3 |= ME_EDGE_TFACTLAST; - } else { - flag0 = flag1 = flag2 = flag3 = flags; - } - - if (mask&ME_SEAM) { - if (tface->unwrap&TF_SEAM1) flag0 |= ME_SEAM; - if (tface->unwrap&TF_SEAM2) flag1 |= ME_SEAM; - if (tface->unwrap&TF_SEAM3) flag2 |= ME_SEAM; - if (tface->unwrap&TF_SEAM4) flag3 |= ME_SEAM; - } - - if ((flag0&mask)==value) { - glVertex3fv(mdm->verts[mface->v1].co); - glVertex3fv(mdm->verts[mface->v2].co); - } - - if ((flag1&mask)==value) { - glVertex3fv(mdm->verts[mface->v2].co); - glVertex3fv(mdm->verts[mface->v3].co); - } - - if (mface->v4) { - if ((flag2&mask)==value) { - glVertex3fv(mdm->verts[mface->v3].co); - glVertex3fv(mdm->verts[mface->v4].co); - } + MEdge *medge= me->medge; + int a; - if ((flag3&mask)==value) { - glVertex3fv(mdm->verts[mface->v4].co); - glVertex3fv(mdm->verts[mface->v1].co); - } - } else { - if ((flag3&mask)==value) { - glVertex3fv(mdm->verts[mface->v3].co); - glVertex3fv(mdm->verts[mface->v1].co); - } - } - } - } - glEnd(); - } - else if(me->medge) { - MEdge *medge= me->medge; - - glBegin(GL_LINES); - for(a=me->totedge; a>0; a--, medge++) { - if (((medge->flag|ME_EDGEMAPPED)&mask)==value) { - 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) { - if (((ME_EDGEDRAW|ME_LOOSEEDGE|ME_EDGEMAPPED)&mask)==value) { - glVertex3fv(mdm->verts[mface->v1].co); - glVertex3fv(mdm->verts[mface->v2].co); - } - } + glBegin(GL_LINES); + for(a=me->totedge; a>0; a--, medge++) { + if (((medge->flag|ME_EDGEMAPPED)&mask)==value) { + glVertex3fv(mdm->verts[medge->v1].co); + glVertex3fv(mdm->verts[medge->v2].co); } - glEnd(); } + glEnd(); } static void meshDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int)) { @@ -367,32 +249,30 @@ static void meshDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int)) glBegin(glmode=GL_QUADS); for(a=0; a<me->totface; a++, mface++, nors+=3) { - if(mface->v3) { - int new_glmode, new_matnr, new_shademodel; - - new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES; - new_matnr = mface->mat_nr+1; - new_shademodel = (!(me->flag&ME_AUTOSMOOTH) && (mface->flag & ME_SMOOTH))?GL_SMOOTH:GL_FLAT; + int new_glmode, new_matnr, new_shademodel; - if (new_glmode!=glmode || new_matnr!=matnr || new_shademodel!=shademodel) { - glEnd(); + new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES; + new_matnr = mface->mat_nr+1; + new_shademodel = (!(me->flag&ME_AUTOSMOOTH) && (mface->flag & ME_SMOOTH))?GL_SMOOTH:GL_FLAT; + + if (new_glmode!=glmode || new_matnr!=matnr || new_shademodel!=shademodel) { + glEnd(); - drawCurrentMat = setMaterial(matnr=new_matnr); + drawCurrentMat = setMaterial(matnr=new_matnr); - glShadeModel(shademodel=new_shademodel); - glBegin(glmode=new_glmode); - } - - if (drawCurrentMat) { - if(shademodel==GL_FLAT) - glNormal3fv(nors); - - PASSVERT(mface->v1); - PASSVERT(mface->v2); - PASSVERT(mface->v3); - if (mface->v4) { - PASSVERT(mface->v4); - } + glShadeModel(shademodel=new_shademodel); + glBegin(glmode=new_glmode); + } + + if (drawCurrentMat) { + if(shademodel==GL_FLAT) + glNormal3fv(nors); + + PASSVERT(mface->v1); + PASSVERT(mface->v2); + PASSVERT(mface->v3); + if (mface->v4) { + PASSVERT(mface->v4); } } } @@ -427,37 +307,35 @@ static void meshDM_drawFacesColored(DerivedMesh *dm, int useTwoSide, unsigned ch glShadeModel(GL_SMOOTH); glBegin(glmode=GL_QUADS); for(a=0; a<me->totface; a++, mface++, cp1+= 16) { - if(mface->v3) { - int new_glmode= mface->v4?GL_QUADS:GL_TRIANGLES; + int new_glmode= mface->v4?GL_QUADS:GL_TRIANGLES; - if (new_glmode!=glmode) { - glEnd(); - glBegin(glmode= new_glmode); - } - - glColor3ub(cp1[3], cp1[2], cp1[1]); - glVertex3fv( mdm->verts[mface->v1].co ); - glColor3ub(cp1[7], cp1[6], cp1[5]); - glVertex3fv( mdm->verts[mface->v2].co ); - glColor3ub(cp1[11], cp1[10], cp1[9]); + if (new_glmode!=glmode) { + glEnd(); + glBegin(glmode= new_glmode); + } + + glColor3ub(cp1[3], cp1[2], cp1[1]); + glVertex3fv( mdm->verts[mface->v1].co ); + glColor3ub(cp1[7], cp1[6], cp1[5]); + glVertex3fv( mdm->verts[mface->v2].co ); + glColor3ub(cp1[11], cp1[10], cp1[9]); + glVertex3fv( mdm->verts[mface->v3].co ); + if(mface->v4) { + glColor3ub(cp1[15], cp1[14], cp1[13]); + glVertex3fv( mdm->verts[mface->v4].co ); + } + + if(useTwoSide) { + glColor3ub(cp2[11], cp2[10], cp2[9]); glVertex3fv( mdm->verts[mface->v3].co ); + glColor3ub(cp2[7], cp2[6], cp2[5]); + glVertex3fv( mdm->verts[mface->v2].co ); + glColor3ub(cp2[3], cp2[2], cp2[1]); + glVertex3fv( mdm->verts[mface->v1].co ); if(mface->v4) { - glColor3ub(cp1[15], cp1[14], cp1[13]); + glColor3ub(cp2[15], cp2[14], cp2[13]); glVertex3fv( mdm->verts[mface->v4].co ); } - - if(useTwoSide) { - glColor3ub(cp2[11], cp2[10], cp2[9]); - glVertex3fv( mdm->verts[mface->v3].co ); - glColor3ub(cp2[7], cp2[6], cp2[5]); - glVertex3fv( mdm->verts[mface->v2].co ); - glColor3ub(cp2[3], cp2[2], cp2[1]); - glVertex3fv( mdm->verts[mface->v1].co ); - if(mface->v4) { - glColor3ub(cp2[15], cp2[14], cp2[13]); - glVertex3fv( mdm->verts[mface->v4].co ); - } - } } if(col2) cp2+= 16; } @@ -482,8 +360,6 @@ static void meshDM_drawFacesTex(DerivedMesh *dm, int (*setDrawParams)(TFace *tf, int flag; unsigned char *cp= NULL; - if (mf->v3==0) continue; - flag = setDrawParams(tf, mf->mat_nr); if (flag==0) { @@ -538,7 +414,7 @@ static void meshDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void * MFace *mf= &mface[a]; int drawSmooth = 1; - if (mf->v3 && setDrawOptions(userData, a, &drawSmooth)) { + if (!setDrawOptions || setDrawOptions(userData, a, &drawSmooth)) { glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT); glBegin(mf->v4?GL_QUADS:GL_TRIANGLES); @@ -1070,7 +946,7 @@ static void ssDM_foreachMappedFaceCenter(DerivedMesh *dm, void (*func)(void *use if (mf->flag&ME_FACE_STEPINDEX) index++; - if(index!=-1 && mf->v3) { + if(index!=-1) { float cent[3]; float no[3]; @@ -1113,26 +989,24 @@ static void ssDM_drawUVEdges(DerivedMesh *dm) if (dlm->tface) { glBegin(GL_LINES); for (i=0; i<dlm->totface; i++) { - if (dlm->mface[i].v3) { - TFace *tf = &dlm->tface[i]; + TFace *tf = &dlm->tface[i]; - if (!(tf->flag&TF_HIDE)) { - glVertex2fv(tf->uv[0]); - glVertex2fv(tf->uv[1]); + if (!(tf->flag&TF_HIDE)) { + glVertex2fv(tf->uv[0]); + glVertex2fv(tf->uv[1]); - glVertex2fv(tf->uv[1]); - glVertex2fv(tf->uv[2]); + glVertex2fv(tf->uv[1]); + glVertex2fv(tf->uv[2]); - if (!dlm->mface[i].v4) { - glVertex2fv(tf->uv[2]); - glVertex2fv(tf->uv[0]); - } else { - glVertex2fv(tf->uv[2]); - glVertex2fv(tf->uv[3]); + if (!dlm->mface[i].v4) { + glVertex2fv(tf->uv[2]); + glVertex2fv(tf->uv[0]); + } else { + glVertex2fv(tf->uv[2]); + glVertex2fv(tf->uv[3]); - glVertex2fv(tf->uv[3]); - glVertex2fv(tf->uv[0]); - } + glVertex2fv(tf->uv[3]); + glVertex2fv(tf->uv[0]); } } } @@ -1144,135 +1018,35 @@ static void ssDM_drawEdgesFlag(DerivedMesh *dm, unsigned int mask, unsigned int SSDerivedMesh *ssdm = (SSDerivedMesh*) dm; DispListMesh *dlm = ssdm->dlm; MVert *mvert = dlm->mvert; + MEdge *medge= dlm->medge; int tfaceFlags = (ME_EDGE_TFSEL|ME_EDGE_TFACT|ME_EDGE_TFVISIBLE|ME_EDGE_TFACTFIRST|ME_EDGE_TFACTLAST); int i; - if (dlm->medge) { - MEdge *medge= dlm->medge; - - glBegin(GL_LINES); - for (i=0; i<dlm->totedge; i++, medge++) { - if ((medge->flag&mask)==value) { - glVertex3fv(mvert[medge->v1].co); - glVertex3fv(mvert[medge->v2].co); - } - } - glEnd(); - } else if ((mask&tfaceFlags) && dlm->tface) { - MFace *mface = dlm->mface; - TFace *tface = dlm->tface; - - glBegin(GL_LINES); - for(i=0; i<dlm->totface; i++, mface++, tface++) { - if (mface->v3) { - unsigned int flags = ME_EDGEDRAW|ME_EDGEMAPPED; - unsigned int flag0, flag1, flag2, flag3; - - if (tface->flag&TF_SELECT) flags |= ME_EDGE_TFSEL; - if (!(tface->flag&TF_HIDE)) flags |= ME_EDGE_TFVISIBLE; - - if (tface->flag&TF_ACTIVE) { - flags |= ME_EDGE_TFACT; - flag0 = flag1 = flag2 = flag3 = flags; - - flag0 |= ME_EDGE_TFACTFIRST; - flag3 |= ME_EDGE_TFACTLAST; - } else { - flag0 = flag1 = flag2 = flag3 = flags; - } - - if (mask&ME_SEAM) { - if (tface->unwrap&TF_SEAM1) flag0 |= ME_SEAM; - if (tface->unwrap&TF_SEAM2) flag1 |= ME_SEAM; - if (tface->unwrap&TF_SEAM3) flag2 |= ME_SEAM; - if (tface->unwrap&TF_SEAM4) flag3 |= ME_SEAM; - } - - if ((flag0&mask)==value) { - glVertex3fv(mvert[mface->v1].co); - glVertex3fv(mvert[mface->v2].co); - } - - if ((flag1&mask)==value) { - glVertex3fv(mvert[mface->v2].co); - glVertex3fv(mvert[mface->v3].co); - } - - if (mface->v4) { - if ((flag2&mask)==value) { - glVertex3fv(mvert[mface->v3].co); - glVertex3fv(mvert[mface->v4].co); - } - - if ((flag3&mask)==value) { - glVertex3fv(mvert[mface->v4].co); - glVertex3fv(mvert[mface->v1].co); - } - } else { - if ((flag3&mask)==value) { - glVertex3fv(mvert[mface->v3].co); - glVertex3fv(mvert[mface->v1].co); - } - } - } - } - glEnd(); - } else { - MFace *mface = dlm->mface; - - glBegin(GL_LINES); - for(i=0; i<dlm->totface; i++, mface++) { - if (!mface->v3) { - if (((ME_EDGEDRAW|ME_LOOSEEDGE|ME_EDGEMAPPED)&mask)==value) { - glVertex3fv(mvert[mface->v1].co); - glVertex3fv(mvert[mface->v2].co); - } - } + glBegin(GL_LINES); + for (i=0; i<dlm->totedge; i++, medge++) { + if ((medge->flag&mask)==value) { + glVertex3fv(mvert[medge->v1].co); + glVertex3fv(mvert[medge->v2].co); } - glEnd(); } + glEnd(); } static void ssDM_drawEdges(DerivedMesh *dm, int drawLooseEdges) { SSDerivedMesh *ssdm = (SSDerivedMesh*) dm; DispListMesh *dlm = ssdm->dlm; MVert *mvert= dlm->mvert; + MEdge *medge= dlm->medge; int i; - - if (dlm->medge) { - MEdge *medge= dlm->medge; - glBegin(GL_LINES); - for (i=0; i<dlm->totedge; i++, medge++) { - if ((medge->flag&ME_EDGEDRAW) && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) { - glVertex3fv(mvert[medge->v1].co); - glVertex3fv(mvert[medge->v2].co); - } - } - glEnd(); - } else { - MFace *mface= dlm->mface; - - glBegin(GL_LINES); - for (i=0; i<dlm->totface; i++, mface++) { - glVertex3fv(mvert[mface->v1].co); - glVertex3fv(mvert[mface->v2].co); - - if (mface->v3) { - glVertex3fv(mvert[mface->v2].co); - glVertex3fv(mvert[mface->v3].co); - - glVertex3fv(mvert[mface->v3].co); - if (mface->v4) { - glVertex3fv(mvert[mface->v4].co); - - glVertex3fv(mvert[mface->v4].co); - } - glVertex3fv(mvert[mface->v1].co); - } + glBegin(GL_LINES); + for (i=0; i<dlm->totedge; i++, medge++) { + if ((medge->flag&ME_EDGEDRAW) && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) { + glVertex3fv(mvert[medge->v1].co); + glVertex3fv(mvert[medge->v2].co); } - glEnd(); } + glEnd(); } static void ssDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int)) { @@ -1291,31 +1065,28 @@ static void ssDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int)) glBegin(glmode=GL_QUADS); for (i=0; i<dlm->totface; i++) { MFace *mf= &dlm->mface[i]; + int new_glmode = mf->v4?GL_QUADS:GL_TRIANGLES; + int new_shademodel = (mf->flag&ME_SMOOTH)?GL_SMOOTH:GL_FLAT; + int new_matnr = mf->mat_nr+1; - if (mf->v3) { - int new_glmode = mf->v4?GL_QUADS:GL_TRIANGLES; - int new_shademodel = (mf->flag&ME_SMOOTH)?GL_SMOOTH:GL_FLAT; - int new_matnr = mf->mat_nr+1; - - if(new_glmode!=glmode || new_shademodel!=shademodel || new_matnr!=matnr) { - glEnd(); + if(new_glmode!=glmode || new_shademodel!=shademodel || new_matnr!=matnr) { + glEnd(); - drawCurrentMat = setMaterial(matnr=new_matnr); + drawCurrentMat = setMaterial(matnr=new_matnr); - glShadeModel(shademodel=new_shademodel); - glBegin(glmode=new_glmode); - } - - if (drawCurrentMat) { - if (shademodel==GL_FLAT) - glNormal3fv(&nors[i*3]); - - PASSVERT(mf->v1); - PASSVERT(mf->v2); - PASSVERT(mf->v3); - if (mf->v4) - PASSVERT(mf->v4); - } + glShadeModel(shademodel=new_shademodel); + glBegin(glmode=new_glmode); + } + + if (drawCurrentMat) { + if (shademodel==GL_FLAT) + glNormal3fv(&nors[i*3]); + + PASSVERT(mf->v1); + PASSVERT(mf->v2); + PASSVERT(mf->v3); + if (mf->v4) + PASSVERT(mf->v4); } } glEnd(); @@ -1344,31 +1115,28 @@ static void ssDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned cha glBegin(lmode= GL_QUADS); for (i=0; i<dlm->totface; i++) { MFace *mf= &dlm->mface[i]; + int nmode= mf->v4?GL_QUADS:GL_TRIANGLES; + unsigned char *colbase= &vcols1[i*16]; - if (mf->v3) { - int nmode= mf->v4?GL_QUADS:GL_TRIANGLES; - unsigned char *colbase= &vcols1[i*16]; - - if (nmode!=lmode) { - glEnd(); - glBegin(lmode= nmode); - } - - PASSVERT(mf->v1, 0); - PASSVERT(mf->v2, 1); - PASSVERT(mf->v3, 2); + if (nmode!=lmode) { + glEnd(); + glBegin(lmode= nmode); + } + + PASSVERT(mf->v1, 0); + PASSVERT(mf->v2, 1); + PASSVERT(mf->v3, 2); + if (mf->v4) + PASSVERT(mf->v4, 3); + + if (useTwoSided) { + unsigned char *colbase= &vcols2[i*16]; + if (mf->v4) PASSVERT(mf->v4, 3); - - if (useTwoSided) { - unsigned char *colbase= &vcols2[i*16]; - - if (mf->v4) - PASSVERT(mf->v4, 3); - PASSVERT(mf->v3, 2); - PASSVERT(mf->v2, 1); - PASSVERT(mf->v1, 0); - } + PASSVERT(mf->v3, 2); + PASSVERT(mf->v2, 1); + PASSVERT(mf->v1, 0); } } glEnd(); @@ -1394,8 +1162,6 @@ static void ssDM_drawFacesTex(DerivedMesh *dm, int (*setDrawParams)(TFace *tf, i int flag; unsigned char *cp= NULL; - if (mf->v3==0) continue; - flag = setDrawParams(tf, mf->mat_nr); if (flag==0) { @@ -1452,7 +1218,7 @@ static void ssDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us if (mf->flag&ME_FACE_STEPINDEX) index++; - if (index!=-1 && mf->v3 && (!setDrawOptions || setDrawOptions(userData, index, &drawSmooth))) { + if (index!=-1 && (!setDrawOptions || setDrawOptions(userData, index, &drawSmooth))) { glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT); glBegin(mf->v4?GL_QUADS:GL_TRIANGLES); if (!drawSmooth) { diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index c2aa614dc71..96930e78408 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -788,55 +788,52 @@ void mesh_create_shadedColors(Object *ob, int onlyForMesh, unsigned int **col1_r for (i=0; i<dlm->totface; i++) { MFace *mf= &dlm->mface[i]; + int j, vidx[4], nverts= mf->v4?4:3; + unsigned char *col1base= (unsigned char*) &col1[i*4]; + unsigned char *col2base= (unsigned char*) (col2?&col2[i*4]:NULL); + unsigned char *mcolbase; + Material *ma= give_current_material(ob, mf->mat_nr+1); + float nor[3], n1[3]; + + if(ma==0) ma= &defmaterial; + + if (dlm->tface) { + mcolbase = (unsigned char*) dlm->tface[i].col; + } else if (dlm->mcol) { + mcolbase = (unsigned char*) &dlm->mcol[i*4]; + } else { + mcolbase = NULL; + } - if (mf->v3) { - int j, vidx[4], nverts= mf->v4?4:3; - unsigned char *col1base= (unsigned char*) &col1[i*4]; - unsigned char *col2base= (unsigned char*) (col2?&col2[i*4]:NULL); - unsigned char *mcolbase; - Material *ma= give_current_material(ob, mf->mat_nr+1); - float nor[3], n1[3]; - - if(ma==0) ma= &defmaterial; - - if (dlm->tface) { - mcolbase = (unsigned char*) dlm->tface[i].col; - } else if (dlm->mcol) { - mcolbase = (unsigned char*) &dlm->mcol[i*4]; - } else { - mcolbase = NULL; - } - - vidx[0]= mf->v1; - vidx[1]= mf->v2; - vidx[2]= mf->v3; - vidx[3]= mf->v4; - - if (dlm->nors) { - VECCOPY(nor, &dlm->nors[i*3]); - } else { - if (mf->v4) - CalcNormFloat4(dlm->mvert[mf->v1].co, dlm->mvert[mf->v2].co, dlm->mvert[mf->v3].co, dlm->mvert[mf->v4].co, nor); - else - CalcNormFloat(dlm->mvert[mf->v1].co, dlm->mvert[mf->v2].co, dlm->mvert[mf->v3].co, nor); - } + vidx[0]= mf->v1; + vidx[1]= mf->v2; + vidx[2]= mf->v3; + vidx[3]= mf->v4; + + if (dlm->nors) { + VECCOPY(nor, &dlm->nors[i*3]); + } else { + if (mf->v4) + CalcNormFloat4(dlm->mvert[mf->v1].co, dlm->mvert[mf->v2].co, dlm->mvert[mf->v3].co, dlm->mvert[mf->v4].co, nor); + else + CalcNormFloat(dlm->mvert[mf->v1].co, dlm->mvert[mf->v2].co, dlm->mvert[mf->v3].co, nor); + } - n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; - n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; - n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - Normalise(n1); - - for (j=0; j<nverts; j++) { - MVert *mv= &dlm->mvert[vidx[j]]; - unsigned char *col1= &col1base[j*4]; - unsigned char *col2= col2base?&col2base[j*4]:NULL; - unsigned char *mcol= mcolbase?&mcolbase[j*4]:NULL; - float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1; - - VECCOPY(vec, mv->co); - Mat4MulVecfl(mat, vec); - fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2, mcol); - } + n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; + n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; + n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; + Normalise(n1); + + for (j=0; j<nverts; j++) { + MVert *mv= &dlm->mvert[vidx[j]]; + unsigned char *col1= &col1base[j*4]; + unsigned char *col2= col2base?&col2base[j*4]:NULL; + unsigned char *mcol= mcolbase?&mcolbase[j*4]:NULL; + float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1; + + VECCOPY(vec, mv->co); + Mat4MulVecfl(mat, vec); + fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2, mcol); } } MEM_freeN(vnors); diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 75bb86d2f22..94273be182a 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -1039,22 +1039,14 @@ static void give_mesh_mvert(Mesh *me, DispListMesh *dlm, int nr, float *co, shor v2= (mvertbase+(mface->v2))->co; n1= (mvertbase+(mface->v1))->no; n2= (mvertbase+(mface->v2))->no; - if(mface->v3==0) { - v3= (mvertbase+(mface->v2))->co; + v3= (mvertbase+(mface->v3))->co; + n3= (mvertbase+(mface->v3))->no; + if(mface->v4==0) { v4= (mvertbase+(mface->v1))->co; - n3= (mvertbase+(mface->v2))->no; - n4= (mvertbase+(mface->v1))->no; - } - else if(mface->v4==0) { - v3= (mvertbase+(mface->v3))->co; - v4= (mvertbase+(mface->v1))->co; - n3= (mvertbase+(mface->v3))->no; n4= (mvertbase+(mface->v1))->no; } else { - v3= (mvertbase+(mface->v3))->co; v4= (mvertbase+(mface->v4))->co; - n3= (mvertbase+(mface->v3))->no; n4= (mvertbase+(mface->v4))->no; } diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 85b3b3a7954..063ee717df7 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -213,25 +213,21 @@ static void mesh_add_normals_flags(Mesh *me) mface= me->mface; for(a=0; a<me->totface; a++, mface++) { - if(mface->v3) { - mface->edcode= ME_V1V2 | ME_V2V3; // only draw 2 for speed - - v1= me->mvert+mface->v1; - v2= me->mvert+mface->v2; - v3= me->mvert+mface->v3; - v4= me->mvert+mface->v4; - - CalcNormFloat(v1->co, v2->co, v3->co, nor); - sno[0]= 32767.0*nor[0]; - sno[1]= 32767.0*nor[1]; - sno[2]= 32767.0*nor[2]; - - simple_vertex_normal_blend(v1->no, sno); - simple_vertex_normal_blend(v2->no, sno); - simple_vertex_normal_blend(v3->no, sno); - if(mface->v4) { - simple_vertex_normal_blend(v4->no, sno); - } + v1= me->mvert+mface->v1; + v2= me->mvert+mface->v2; + v3= me->mvert+mface->v3; + v4= me->mvert+mface->v4; + + CalcNormFloat(v1->co, v2->co, v3->co, nor); + sno[0]= 32767.0*nor[0]; + sno[1]= 32767.0*nor[1]; + sno[2]= 32767.0*nor[2]; + + simple_vertex_normal_blend(v1->no, sno); + simple_vertex_normal_blend(v2->no, sno); + simple_vertex_normal_blend(v3->no, sno); + if(mface->v4) { + simple_vertex_normal_blend(v4->no, sno); } } } @@ -306,6 +302,8 @@ static void read_stl_mesh_binary(char *str) me->totvert = totvert; mesh_add_normals_flags(me); + make_edges(me); + mesh_strip_loose_faces(me); } waitcursor(1); } @@ -470,6 +468,8 @@ static void read_stl_mesh_ascii(char *str) free(vertdata); mesh_add_normals_flags(me); + make_edges(me); + mesh_strip_loose_faces(me); waitcursor(1); } @@ -551,15 +551,7 @@ static void read_videoscape_mesh(char *str) totcol++; } } - - if(totedge+tottria+totquad>MESH_MAX_VERTS) { - printf(" var1: %d, var2: %d, var3: %d \n", totedge, tottria, totquad); - error("too many faces"); - MEM_freeN(vertdata); - fclose(fp); - return; - } - + /* new object */ ob= add_object(OB_MESH); me= ob->data; @@ -647,7 +639,6 @@ static void read_videoscape_mesh(char *str) if( fscanf(fp,"%d", &nr) <=0 ) break; mface->v4= MIN2(nr, me->totvert-1); } - mface->edcode= 3; test_index_face(mface, NULL, NULL, poly); @@ -668,7 +659,6 @@ static void read_videoscape_mesh(char *str) } mface->v1= first; mface->v2= nr; - mface->edcode= 1; mface++; if(end<=0) break; } @@ -688,11 +678,9 @@ static void read_videoscape_mesh(char *str) fclose(fp); MEM_freeN(vertdata); - G.obedit= ob; - make_editMesh(); - load_editMesh(); - free_editMesh(G.editMesh); - G.obedit= 0; + mesh_add_normals_flags(me); + make_edges(me); + mesh_strip_loose_faces(me); waitcursor(1); } @@ -821,7 +809,6 @@ static void read_radiogour(char *str) if( fscanf(fp,"%d", &nr) <=0 ) break; mface->v4= MIN2(nr, me->totvert-1); } - mface->edcode= 3; test_index_face(mface, NULL, NULL, poly); @@ -842,7 +829,6 @@ static void read_radiogour(char *str) } mface->v1= first; mface->v2= nr; - mface->edcode= 1; mface->flag= ME_SMOOTH; mface++; @@ -873,12 +859,9 @@ static void read_radiogour(char *str) fclose(fp); MEM_freeN(vertdata); - G.obedit= ob; - make_editMesh(); - load_editMesh(); - free_editMesh(G.editMesh); - - G.obedit= 0; + mesh_add_normals_flags(me); + make_edges(me); + mesh_strip_loose_faces(me); waitcursor(1); } @@ -2022,15 +2005,6 @@ static void displist_to_mesh(DispList *dlfirst) if(totvert==0) { return; } - if(totvert>MESH_MAX_VERTS || tottria>=MESH_MAX_VERTS) { - if (totvert>=MESH_MAX_VERTS) { - error("Too many vertices (%d)", totvert); - } else { - error("Too many faces (%d)", tottria); - } - - return; - } if(totcol>16) { error("Found more than 16 different colors"); @@ -2196,7 +2170,6 @@ static void displist_to_mesh(DispList *dlfirst) else mface->v2= startve+a+1; mface->mat_nr= colnr; - test_index_face(mface, NULL, NULL, 2); mface++; } @@ -2248,7 +2221,6 @@ static void displist_to_mesh(DispList *dlfirst) mface->v1= startve+a; mface->v2= startve+a+1; mface->mat_nr= colnr; - test_index_face(mface, NULL, NULL, 2); mface++; } startve += dl->nr; @@ -2258,6 +2230,8 @@ static void displist_to_mesh(DispList *dlfirst) } mesh_add_normals_flags(me); + make_edges(me); + mesh_strip_loose_faces(me); } static void displist_to_objects(ListBase *lbase) @@ -2673,10 +2647,7 @@ static void write_videoscape_mesh(Object *ob, char *str) fprintf(fp, "%f %f %f\n", co[0], co[1], co[2] ); } for(a=0; a<me->totface; a++, mface++) { - if(mface->v3==0) { - fprintf(fp, "2 %d %d 0x%x\n", mface->v1, mface->v2, kleur[mface->mat_nr]); - } - else if(mface->v4==0) { + if(mface->v4==0) { fprintf(fp, "3 %d %d %d 0x%x\n", mface->v1, mface->v2, mface->v3, kleur[mface->mat_nr]); } else { @@ -2790,7 +2761,7 @@ unsigned int *mcol_to_vcol(Mesh *me) for(a=me->totface; a>0; a--, mface++) { mcoln[mface->v1]= mcol[0]; mcoln[mface->v2]= mcol[1]; - if(mface->v3) mcoln[mface->v3]= mcol[2]; + mcoln[mface->v3]= mcol[2]; if(mface->v4) mcoln[mface->v4]= mcol[3]; mcol+= 4; @@ -2910,7 +2881,7 @@ static void write_mesh_vrml(FILE *fp, Mesh *me) if(mface->mat_nr==b) { fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[0][0], tface->uv[0][1]); fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[1][0], tface->uv[1][1]); - if(mface->v3) fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[2][0], tface->uv[2][1]); + fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[2][0], tface->uv[2][1]); if(mface->v4) fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[3][0], tface->uv[3][1]); } mface++; @@ -2928,7 +2899,7 @@ static void write_mesh_vrml(FILE *fp, Mesh *me) while(a--) { if(mface->mat_nr==b) { if(mface->v4) fprintf(fp, "\t\t\t\t %d, %d, %d, %d, -1,\n", mface->v1, mface->v2, mface->v3, mface->v4); - else if(mface->v3) fprintf(fp, "\t\t\t\t %d, %d, %d, -1,\n", mface->v1, mface->v2, mface->v3); + else fprintf(fp, "\t\t\t\t %d, %d, %d, -1,\n", mface->v1, mface->v2, mface->v3); } mface++; } @@ -2945,7 +2916,7 @@ static void write_mesh_vrml(FILE *fp, Mesh *me) fprintf(fp, "\t\t\t\t %d, %d, %d, %d, -1,\n", texind, texind+1, texind+2, texind+3); texind+= 4; } - else if(mface->v3) { + else { fprintf(fp, "\t\t\t\t %d, %d, %d, -1,\n", texind, texind+1, texind+2); texind+= 3; } @@ -3260,37 +3231,35 @@ static void write_mesh_dxf(FILE *fp, Mesh *me) a= me->totface; mface= me->mface; while(a--) { - if (mface->v4 || mface->v3) { - write_group(0, "VERTEX"); /* Start a new face */ - write_group(8, "Meshes"); - - /* Write a face color */ - if (me->totcol) { - ma= me->mat[mface->mat_nr]; - if(ma) { - sprintf(str,"%d",rgb_to_dxf_col(ma->r,ma->g,ma->b)); - write_group(62, str); /* Color index */ - } + write_group(0, "VERTEX"); /* Start a new face */ + write_group(8, "Meshes"); + + /* Write a face color */ + if (me->totcol) { + ma= me->mat[mface->mat_nr]; + if(ma) { + sprintf(str,"%d",rgb_to_dxf_col(ma->r,ma->g,ma->b)); + write_group(62, str); /* Color index */ } - else write_group(62, "254"); /* Color Index */ + } + else write_group(62, "254"); /* Color Index */ - /* Not sure what this really corresponds too */ - write_group(10, "0.0"); /* X of base */ - write_group(20, "0.0"); /* Y of base */ - write_group(30, "0.0"); /* Z of base */ - - write_group(70, "128"); /* Polymesh face flag */ - - if(mface->v4) { - fprintf (fp, "71\n%d\n", mface->v1+1); - fprintf (fp, "72\n%d\n", mface->v2+1); - fprintf (fp, "73\n%d\n", mface->v3+1); - fprintf (fp, "74\n%d\n", mface->v4+1); - } else if(mface->v3) { - fprintf (fp, "71\n%d\n", mface->v1+1); - fprintf (fp, "72\n%d\n", mface->v2+1); - fprintf (fp, "73\n%d\n", mface->v3+1); - } + /* Not sure what this really corresponds too */ + write_group(10, "0.0"); /* X of base */ + write_group(20, "0.0"); /* Y of base */ + write_group(30, "0.0"); /* Z of base */ + + write_group(70, "128"); /* Polymesh face flag */ + + if(mface->v4) { + fprintf (fp, "71\n%d\n", mface->v1+1); + fprintf (fp, "72\n%d\n", mface->v2+1); + fprintf (fp, "73\n%d\n", mface->v3+1); + fprintf (fp, "74\n%d\n", mface->v4+1); + } else { + fprintf (fp, "71\n%d\n", mface->v1+1); + fprintf (fp, "72\n%d\n", mface->v2+1); + fprintf (fp, "73\n%d\n", mface->v3+1); } mface++; } @@ -3707,17 +3676,7 @@ static void dxf_read_point(int noob) { mvert->co[0]= mvert->co[1]= mvert->co[2]= 0; if (ob) VECCOPY(ob->loc, cent); - - if (!noob) { - G.obedit= ob; - make_editMesh(); - load_editMesh(); - free_editMesh(G.editMesh); - waitcursor(1); /* patch yah... */ - G.obedit= 0; - } - hasbumped=1; } @@ -3733,14 +3692,6 @@ static void dxf_close_line(void) linemhold=NULL; if (linehold==NULL) return; - G.obedit= linehold; - make_editMesh(); - load_editMesh(); - free_editMesh(G.editMesh); - waitcursor(1); /* patch yah... */ - - G.obedit= 0; - linehold=NULL; } @@ -3837,10 +3788,8 @@ static void dxf_read_line(int noob) { mface= &(((MFace*)me->mface)[me->totface-1]); mface->v1= me->totvert-2; mface->v2= me->totvert-1; - - mface->edcode= 1; mface->mat_nr= 0; - + hasbumped=1; } @@ -3855,14 +3804,6 @@ static void dxf_close_2dpoly(void) p2dmhold= NULL; if (p2dhold==NULL) return; - G.obedit= p2dhold; - make_editMesh(); - load_editMesh(); - free_editMesh(G.editMesh); - waitcursor(1); /* patch yah... */ - - G.obedit= 0; - p2dhold=NULL; } @@ -4033,11 +3974,11 @@ static void dxf_read_ellipse(int noob) x = a * sin(phi); y = b * cos(phi); - epoint[0] = center[0] + x*cos(theta) - y*sin(theta); - epoint[1] = center[1] + x*sin(theta) + y*cos(theta); - epoint[2] = center[2]; + epoint[0] = center[0] + x*cos(theta) - y*sin(theta); + epoint[1] = center[1] + x*sin(theta) + y*cos(theta); + epoint[2] = center[2]; - mvert= &me->mvert[v]; + mvert= &me->mvert[v]; if (vspace) { VECCOPY(mvert->co, epoint); @@ -4049,14 +3990,13 @@ static void dxf_read_ellipse(int noob) mface= &(((MFace*)me->mface)[v-1]); mface->v1 = v-1; mface->v2 = v; - mface->edcode = 1; - mface->mat_nr = 0; + mface->mat_nr = 0; } - hasbumped = 1; + hasbumped = 1; - VECCOPY(cent, epoint); - phi+=phid; + VECCOPY(cent, epoint); + phi+=phid; } } @@ -4154,15 +4094,15 @@ static void dxf_read_arc(int noob) for(v = 0; v <= tot; v++) { - epoint[0]= center[0]+dia*sin(phi); - epoint[1]= center[1]+dia*cos(phi); - epoint[2]= center[2]; + epoint[0]= center[0]+dia*sin(phi); + epoint[1]= center[1]+dia*cos(phi); + epoint[2]= center[2]; mvert= &me->mvert[v]; if (vspace) { VECCOPY(mvert->co, epoint); - } else { + } else { VecSubf(mvert->co, epoint, vcenter); } @@ -4170,14 +4110,13 @@ static void dxf_read_arc(int noob) mface= &(((MFace*)me->mface)[v-1]); mface->v1 = v-1; mface->v2 = v; - mface->edcode = 1; - mface->mat_nr = 0; + mface->mat_nr = 0; } - hasbumped=1; + hasbumped=1; - VECCOPY(cent, epoint); - phi+=phid; + VECCOPY(cent, epoint); + phi+=phid; } } @@ -4324,16 +4263,11 @@ static void dxf_read_polyline(int noob) { for(a=1; a<nverts; a++, mface++) { mface->v1= (me->totvert-nverts)+a-1; mface->v2= (me->totvert-nverts)+a; - - mface->edcode= 3; mface->mat_nr= 0; - - test_index_face(mface, NULL, NULL, 2); } } lwasp2d=1; - } else if (flag&64) { if (noob) { @@ -4449,7 +4383,6 @@ static void dxf_read_polyline(int noob) { } else test_index_face(mface, NULL, NULL, 3); - mface->edcode= 3; mface->mat_nr= 0; } else { @@ -4461,15 +4394,6 @@ static void dxf_read_polyline(int noob) { } } - - if (!noob) { - G.obedit= ob; - make_editMesh(); - load_editMesh(); - free_editMesh(G.editMesh); - waitcursor(1); /* patch yah... */ - G.obedit= 0; - } } } @@ -4560,8 +4484,7 @@ static void dxf_read_lwpolyline(int noob) { mface= &(((MFace*)me->mface)[v-1]); mface->v1 = v-1; mface->v2 = v; - mface->edcode = 1; - mface->mat_nr = 0; + mface->mat_nr = 0; } } @@ -4573,7 +4496,6 @@ static void dxf_read_lwpolyline(int noob) { mface= &(((MFace*)me->mface)[nverts - 1]); mface->v1 = nverts-1; mface->v2 = 0; - mface->edcode = 1; mface->mat_nr = 0; } } @@ -4591,13 +4513,6 @@ static void dxf_close_3dface(void) f3dmhold= NULL; if (f3dhold==NULL) return; - G.obedit= f3dhold; - make_editMesh(); - load_editMesh(); - free_editMesh(G.editMesh); - waitcursor(1); /* patch yah... */ - G.obedit= 0; - f3dhold=NULL; } @@ -4783,7 +4698,6 @@ static void dxf_read_3dface(int noob) if (nverts==4) mface->v4= (me->totvert-nverts)+3; - mface->edcode= 3; mface->mat_nr= 0; test_index_face(mface, NULL, NULL, nverts); @@ -4793,6 +4707,8 @@ static void dxf_read_3dface(int noob) static void dxf_read(char *filename) { + Mesh *lastMe = G.main->mesh.last; + dxf_line=0; dxf_fp= fopen(filename, "r"); @@ -4982,13 +4898,6 @@ static void dxf_read(char *filename) base->lay= ob->lay; base->object= ob; - - G.obedit= ob; - make_editMesh(); - load_editMesh(); - free_editMesh(G.editMesh); - waitcursor(1); /* patch yah... */ - G.obedit= 0; } hasbumped=1; @@ -5054,4 +4963,15 @@ static void dxf_read(char *filename) dxf_close_3dface(); dxf_close_2dpoly(); dxf_close_line(); + + if (lastMe) { + lastMe = lastMe->id.next; + } else { + lastMe = G.main->mesh.first; + } + for (; lastMe; lastMe=lastMe->id.next) { + mesh_add_normals_flags(lastMe); + make_edges(lastMe); + mesh_strip_loose_faces(lastMe); + } } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index b91b2356cc3..04cf6a732c5 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -513,10 +513,7 @@ void test_index_face(MFace *mface, MCol *mc, TFace *tface, int nr) } /* prevent a zero at wrong index location */ - if(nr==2) { - if(mface->v2==0) SWAP(int, mface->v1, mface->v2); - } - else if(nr==3) { + if(nr==3) { if(mface->v3==0) { SWAP(int, mface->v1, mface->v2); SWAP(int, mface->v2, mface->v3); @@ -532,12 +529,6 @@ void test_index_face(MFace *mface, MCol *mc, TFace *tface, int nr) SWAP(MCol, mc[0], mc[1]); SWAP(MCol, mc[1], mc[2]); } - - a= mface->edcode; - mface->edcode= 0; - if(a & ME_V1V2) mface->edcode |= ME_V3V1; - if(a & ME_V2V3) mface->edcode |= ME_V1V2; - if(a & ME_V3V1) mface->edcode |= ME_V2V3; } } else if(nr==4) { @@ -557,13 +548,6 @@ void test_index_face(MFace *mface, MCol *mc, TFace *tface, int nr) SWAP(MCol, mc[0], mc[2]); SWAP(MCol, mc[1], mc[3]); } - - a= mface->edcode; - mface->edcode= 0; - if(a & ME_V1V2) mface->edcode |= ME_V3V4; - if(a & ME_V2V3) mface->edcode |= ME_V2V3; - if(a & ME_V3V4) mface->edcode |= ME_V1V2; - if(a & ME_V4V1) mface->edcode |= ME_V4V1; } } } @@ -596,12 +580,11 @@ void set_mesh(Object *ob, Mesh *me) struct edgesort { int v1, v2; - int flag; int is_loose; }; /* edges have to be added with lowest index first for sorting */ -static void to_edgesort(struct edgesort *ed, int v1, int v2, int flag, int is_loose) +static void to_edgesort(struct edgesort *ed, int v1, int v2, int is_loose) { if(v1<v2) { ed->v1= v1; ed->v2= v2; @@ -609,7 +592,6 @@ static void to_edgesort(struct edgesort *ed, int v1, int v2, int flag, int is_lo else { ed->v1= v2; ed->v2= v1; } - ed->flag= flag; ed->is_loose= is_loose; } @@ -651,21 +633,15 @@ void make_edges(Mesh *me) ed= edsort= MEM_mallocN(totedge*sizeof(struct edgesort), "edgesort"); for(a= me->totface, mface= me->mface; a>0; a--, mface++) { - to_edgesort(ed, mface->v1, mface->v2, mface->edcode & ME_V1V2, !mface->v3); - ed++; + to_edgesort(ed++, mface->v1, mface->v2, !mface->v3); if(mface->v4) { - to_edgesort(ed, mface->v2, mface->v3, mface->edcode & ME_V2V3, 0); - ed++; - to_edgesort(ed, mface->v3, mface->v4, mface->edcode & ME_V3V4, 0); - ed++; - to_edgesort(ed, mface->v4, mface->v1, mface->edcode & ME_V4V1, 0); - ed++; + to_edgesort(ed++, mface->v2, mface->v3, 0); + to_edgesort(ed++, mface->v3, mface->v4, 0); + to_edgesort(ed++, mface->v4, mface->v1, 0); } else if(mface->v3) { - to_edgesort(ed, mface->v2, mface->v3, mface->edcode & ME_V2V3, 0); - ed++; - to_edgesort(ed, mface->v3, mface->v1, mface->edcode & ME_V3V1, 0); - ed++; + to_edgesort(ed++, mface->v2, mface->v3, 0); + to_edgesort(ed++, mface->v3, mface->v1, 0); } } @@ -675,11 +651,6 @@ void make_edges(Mesh *me) for(a=totedge, ed=edsort; a>1; a--, ed++) { /* edge is unique when it differs from next edge, or is last */ if(ed->v1 != (ed+1)->v1 || ed->v2 != (ed+1)->v2) final++; - else { - /* this makes sure identical edges both get draw flag */ - if(ed->flag) (ed+1)->flag= 1; - else if((ed+1)->flag) ed->flag= 1; - } } final++; @@ -691,7 +662,7 @@ void make_edges(Mesh *me) if(ed->v1 != (ed+1)->v1 || ed->v2 != (ed+1)->v2) { medge->v1= ed->v1; medge->v2= ed->v2; - if(ed->flag) medge->flag= ME_EDGEDRAW; + medge->flag= ME_EDGEDRAW; if(ed->is_loose) medge->flag|= ME_LOOSEEDGE; medge->flag |= ME_EDGERENDER; medge++; @@ -700,13 +671,31 @@ void make_edges(Mesh *me) /* last edge */ medge->v1= ed->v1; medge->v2= ed->v2; - if(ed->flag) medge->flag= ME_EDGEDRAW; if(ed->is_loose) medge->flag|= ME_LOOSEEDGE; medge->flag |= ME_EDGERENDER; MEM_freeN(edsort); + + mesh_strip_loose_faces(me); } +void mesh_strip_loose_faces(Mesh *me) +{ + int a,b; + + for (a=b=0; a<me->totface; a++) { + if (!me->mface[a].v3) { + if (a!=b) { + memcpy(&me->mface[b],&me->mface[a],sizeof(me->mface[b])); + if (me->tface) memcpy(&me->tface[b],&me->tface[a],sizeof(me->tface[b])); + if (me->mcol) memcpy(&me->mcol[b],&me->mcol[a],sizeof(me->mcol[b])*4); + } + } else { + b++; + } + } + me->totface = b; +} void mball_to_mesh(ListBase *lb, Mesh *me) @@ -747,8 +736,6 @@ void mball_to_mesh(ListBase *lb, Mesh *me) mface->v2= index[1]; mface->v3= index[2]; mface->v4= index[3]; - - mface->edcode= ME_V1V2+ME_V2V3; mface->flag = ME_SMOOTH; mface++; @@ -834,8 +821,6 @@ void nurbs_to_mesh(Object *ob) for(b=1; b<dl->nr; b++) { mface->v1= startvert+ofs+b-1; mface->v2= startvert+ofs+b; - mface->edcode= ME_V1V2; - test_index_face(mface, NULL, NULL, 2); mface++; } } @@ -860,8 +845,6 @@ void nurbs_to_mesh(Object *ob) mface->v1= startvert+ofs+b; if(b==dl->nr-1) mface->v2= startvert+ofs; else mface->v2= startvert+ofs+b+1; - mface->edcode= ME_V1V2; - test_index_face(mface, NULL, NULL, 2); mface++; } } @@ -885,8 +868,6 @@ void nurbs_to_mesh(Object *ob) mface->v2= startvert+index[1]; mface->v3= startvert+index[2]; mface->v4= 0; - - mface->edcode= ME_V1V2+ME_V2V3; test_index_face(mface, NULL, NULL, 3); mface++; @@ -935,7 +916,6 @@ void nurbs_to_mesh(Object *ob) mface->v3= p4; mface->v4= p2; mface->mat_nr= (unsigned char)dl->col; - mface->edcode= ME_V1V2+ME_V2V3; test_index_face(mface, NULL, NULL, 4); mface++; @@ -951,6 +931,9 @@ void nurbs_to_mesh(Object *ob) dl= dl->next; } + make_edges(me); + mesh_strip_loose_faces(me); + if(ob->data) { free_libblock(&G.main->curve, ob->data); } @@ -971,17 +954,6 @@ void nurbs_to_mesh(Object *ob) } -void edge_drawflags_mesh(Mesh *me) -{ - MFace *mface; - int a; - - mface= me->mface; - for(a=0; a<me->totface; a++, mface++) { - mface->edcode= ME_V1V2|ME_V2V3|ME_V3V4|ME_V4V1; - } -} - void tface_to_mcol(Mesh *me) { TFace *tface; @@ -1056,21 +1028,18 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, for (i=0; i<numFaces; i++) { MFace *mf= &mfaces[i]; + float *f_no= &fnors[i*3]; - if (mf->v3) { - float *f_no= &fnors[i*3]; - - if (mf->v4) - CalcNormFloat4(mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co, f_no); - else - CalcNormFloat(mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, f_no); - - VecAddf(tnorms[mf->v1], tnorms[mf->v1], f_no); - VecAddf(tnorms[mf->v2], tnorms[mf->v2], f_no); - VecAddf(tnorms[mf->v3], tnorms[mf->v3], f_no); - if (mf->v4) - VecAddf(tnorms[mf->v4], tnorms[mf->v4], f_no); - } + if (mf->v4) + CalcNormFloat4(mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co, f_no); + else + CalcNormFloat(mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, f_no); + + VecAddf(tnorms[mf->v1], tnorms[mf->v1], f_no); + VecAddf(tnorms[mf->v2], tnorms[mf->v2], f_no); + VecAddf(tnorms[mf->v3], tnorms[mf->v3], f_no); + if (mf->v4) + VecAddf(tnorms[mf->v4], tnorms[mf->v4], f_no); } for (i=0; i<numVerts; i++) { MVert *mv= &mverts[i]; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 1453fcab5fb..db2cfe7c2d2 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -321,10 +321,8 @@ static void *buildModifier_applyModifier(ModifierData *md, Object *ob, void *der ndlm->mvert[mf->v1].flag = 1; ndlm->mvert[mf->v2].flag = 1; - if (mf->v3) { - ndlm->mvert[mf->v3].flag = 1; - if (mf->v4) ndlm->mvert[mf->v4].flag = 1; - } + ndlm->mvert[mf->v3].flag = 1; + if (mf->v4) ndlm->mvert[mf->v4].flag = 1; } /* Store remapped indices in *((int*) mv->no) */ @@ -342,10 +340,8 @@ static void *buildModifier_applyModifier(ModifierData *md, Object *ob, void *der mf->v1 = *((int*) ndlm->mvert[mf->v1].no); mf->v2 = *((int*) ndlm->mvert[mf->v2].no); - if (mf->v3) { - mf->v3 = *((int*) ndlm->mvert[mf->v3].no); - if (mf->v4) mf->v4 = *((int*) ndlm->mvert[mf->v4].no); - } + mf->v3 = *((int*) ndlm->mvert[mf->v3].no); + if (mf->v4) mf->v4 = *((int*) ndlm->mvert[mf->v4].no); } /* Copy in all edges that have both vertices (remap in process) */ if (totedge) { @@ -560,7 +556,7 @@ static DispListMesh *mirrorModifier__doMirror(MirrorModifierData *mmd, DispListM mc[3] = inMC[3]; } - if (indexMap[inMF->v1][1] || indexMap[inMF->v2][1] || (mf->v3 && indexMap[inMF->v3][1]) || (mf->v4 && indexMap[inMF->v4][1])) { + if (indexMap[inMF->v1][1] || indexMap[inMF->v2][1] || indexMap[inMF->v3][1] || (mf->v4 && indexMap[inMF->v4][1])) { MFace *mf2 = &dlm->mface[dlm->totface++]; TFace *tf = NULL; MCol *mc = NULL; @@ -568,7 +564,7 @@ static DispListMesh *mirrorModifier__doMirror(MirrorModifierData *mmd, DispListM *mf2 = *mf; mf2->v1 += indexMap[inMF->v1][1]; mf2->v2 += indexMap[inMF->v2][1]; - if (inMF->v3) mf2->v3 += indexMap[inMF->v3][1]; + mf2->v3 += indexMap[inMF->v3][1]; if (inMF->v4) mf2->v4 += indexMap[inMF->v4][1]; mf2->flag &= ~ME_FACE_STEPINDEX; @@ -587,19 +583,17 @@ static DispListMesh *mirrorModifier__doMirror(MirrorModifierData *mmd, DispListM mc[3] = inMC[3]; } - if (mf2->v3) { - /* Flip face normal */ - SWAP(int, mf2->v1, mf2->v3); - if (tf) { - SWAP(unsigned int, tf->col[0], tf->col[2]); - SWAP(float, tf->uv[0][0], tf->uv[2][0]); - SWAP(float, tf->uv[0][1], tf->uv[2][1]); - } else if (mc) { - SWAP(MCol, mc[0], mc[2]); - } - - test_index_face(mf2, mc, tf, inMF->v4?4:3); + /* Flip face normal */ + SWAP(int, mf2->v1, mf2->v3); + if (tf) { + SWAP(unsigned int, tf->col[0], tf->col[2]); + SWAP(float, tf->uv[0][0], tf->uv[2][0]); + SWAP(float, tf->uv[0][1], tf->uv[2][1]); + } else if (mc) { + SWAP(MCol, mc[0], mc[2]); } + + test_index_face(mf2, mc, tf, inMF->v4?4:3); } } @@ -706,8 +700,6 @@ static void *mirrorModifier_applyModifierEM(ModifierData *md, Object *ob, void * mf->v4 = efa->v4?(int) efa->v4->prev:0; mf->mat_nr = efa->mat_nr; mf->flag = efa->flag|ME_FACE_STEPINDEX; - mf->edcode = 0; - test_index_face(mf, NULL, NULL, efa->v4?4:3); } @@ -761,10 +753,8 @@ static void *decimateModifier_applyModifier(ModifierData *md, Object *ob, void * numTris = 0; for (a=0; a<totface; a++) { MFace *mf = &mface[a]; - if (mf->v3) { - numTris++; - if (mf->v4) numTris++; - } + numTris++; + if (mf->v4) numTris++; } if(numTris<3) { @@ -797,19 +787,16 @@ static void *decimateModifier_applyModifier(ModifierData *md, Object *ob, void * numTris = 0; for(a=0; a<totface; a++) { MFace *mf = &mface[a]; + int *tri = &lod.triangle_index_buffer[3*numTris++]; + tri[0]= mf->v1; + tri[1]= mf->v2; + tri[2]= mf->v3; - if(mf->v3) { - int *tri = &lod.triangle_index_buffer[3*numTris++]; + if(mf->v4) { + tri = &lod.triangle_index_buffer[3*numTris++]; tri[0]= mf->v1; - tri[1]= mf->v2; - tri[2]= mf->v3; - - if(mf->v4) { - tri = &lod.triangle_index_buffer[3*numTris++]; - tri[0]= mf->v1; - tri[1]= mf->v3; - tri[2]= mf->v4; - } + tri[1]= mf->v3; + tri[2]= mf->v4; } } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 429c4596781..1865b6345a6 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1381,8 +1381,7 @@ void sbObjectToSoftbody(Object *ob) static int object_has_edges(Object *ob) { if(ob->type==OB_MESH) { - Mesh *me= ob->data; - return (me->medge && me->totedge); + return ((Mesh*) ob->data)->totedge; } else if(ob->type==OB_LATTICE) { return 1; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index dab0ddd5d8b..745c64103ba 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -90,7 +90,7 @@ static void arena_release(CCGAllocatorHDL a) { BLI_memarena_free(a); } -static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int useAging, int useArena, int useEdgeCreation, int useFlatSubdiv) { +static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int useAging, int useArena, int useFlatSubdiv) { CCGMeshIFC ifc; CCGSubSurf *ccgSS; @@ -136,11 +136,6 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int useAgin if (useAging) { ccgSubSurf_setUseAgeCounts(ccgSS, 1, 8, 8, 8); } - if (useEdgeCreation) { - int defaultUserData[3] = {0, -1, 0}; - - ccgSubSurf_setAllowEdgeCreation(ccgSS, 1, useFlatSubdiv?subdivLevels:0.0f, defaultUserData); - } ccgSubSurf_setCalcVertexNormals(ccgSS, 1, BLI_STRUCT_OFFSET(VertData, no)); @@ -283,10 +278,8 @@ static DispListMesh *ss_to_displistmesh(CCGSubSurf *ss, CCGDerivedMesh *ccgdm, i CCGFace **faceMap2; CCGEdge **edgeMap2; CCGVert **vertMap2; - int totvert, totedge, totface, useEdgeCreation; + int totvert, totedge, totface; - ccgSubSurf_getAllowEdgeCreation(ss, &useEdgeCreation, NULL, NULL); - totvert = ccgSubSurf_getNumVerts(ss); vertMap2 = MEM_mallocN(totvert*sizeof(*vertMap2), "vertmap"); vi = ccgSubSurf_getVertIterator(ss); @@ -307,9 +300,7 @@ static DispListMesh *ss_to_displistmesh(CCGSubSurf *ss, CCGDerivedMesh *ccgdm, i for (i=0; !ccgEdgeIterator_isStopped(ei); i++,ccgEdgeIterator_next(ei)) { CCGEdge *e = ccgEdgeIterator_getCurrent(ei); - if (useEdgeCreation) { - edgeMap2[i] = e; - } else if (ssFromEditmesh) { + if (ssFromEditmesh) { edgeMap2[ccgDM_getEdgeMapIndex(ccgdm,ss,e)] = e; } else { edgeMap2[(int) ccgSubSurf_getEdgeEdgeHandle(ss, e)] = e; @@ -460,6 +451,7 @@ static DispListMesh *ss_to_displistmesh(CCGSubSurf *ss, CCGDerivedMesh *ccgdm, i for (index=0; index<totedge; index++) { CCGEdge *e= edgeMap2[index]; unsigned int flags = ss_getEdgeFlags(ss, e, ssFromEditmesh, inDLM, medge, tface); + int mapIndex = ccgDM_getEdgeMapIndex(ccgdm, ss, e); int edgeStart = i; for (x=0; x<edgeSize-1; x++) { @@ -470,12 +462,9 @@ static DispListMesh *ss_to_displistmesh(CCGSubSurf *ss, CCGDerivedMesh *ccgdm, i i++; } - if (!useEdgeCreation) { - int mapIndex = ccgDM_getEdgeMapIndex(ccgdm, ss, e); - if (mapIndex!=lastIndex) - dlm->medge[edgeStart].flag |= ME_EDGE_STEPINDEX; - lastIndex = mapIndex; - } + if (mapIndex!=lastIndex) + dlm->medge[edgeStart].flag |= ME_EDGE_STEPINDEX; + lastIndex = mapIndex; } // load faces @@ -554,7 +543,6 @@ static DispListMesh *ss_to_displistmesh(CCGSubSurf *ss, CCGDerivedMesh *ccgdm, i mf->v4 = getFaceIndex(ss, f, S, x+1, y+0, edgeSize, gridSize); mf->mat_nr = mat_nr; mf->flag = flag&~ME_FACE_STEPINDEX; - mf->edcode = 0; if (S==0 && x==0 && y==0) { if (mapIndex!=lastIndex) @@ -562,11 +550,6 @@ static DispListMesh *ss_to_displistmesh(CCGSubSurf *ss, CCGDerivedMesh *ccgdm, i lastIndex = mapIndex; } - if (x+1==gridSize-1) - mf->edcode|= ME_V3V4; - if (y+1==gridSize-1) - mf->edcode|= ME_V2V3; - for (j=0; j<4; j++) { int fx = x + (j==2||j==3); int fy = y + (j==1||j==2); @@ -654,34 +637,21 @@ static void ss_sync_from_mesh(CCGSubSurf *ss, Mesh *me, DispListMesh *dlm, float if (!dlm || (med->flag&ME_EDGE_STEPINDEX)) index++; ((int*) ccgSubSurf_getEdgeUserData(ss, e))[1] = index; } - } else { - for (i=0; i<totface; i++) { - CCGEdge *e; - MFace *mf = &((MFace*) mface)[i]; - - if (!mf->v3) { - ccgSubSurf_syncEdge(ss, (CCGEdgeHDL) i, (CCGVertHDL) mf->v1, (CCGVertHDL) mf->v2, useFlatSubdiv?creaseFactor:0.0f, &e); - - ((int*) ccgSubSurf_getEdgeUserData(ss, e))[1] = -1; - } - } } for (i=0, index=-1; i<totface; i++) { MFace *mf = &((MFace*) mface)[i]; + CCGFace *f; if (!dlm || (mf->flag&ME_FACE_STEPINDEX)) index++; - if (mf->v3) { - CCGFace *f; - fVerts[0] = (CCGVertHDL) mf->v1; - fVerts[1] = (CCGVertHDL) mf->v2; - fVerts[2] = (CCGVertHDL) mf->v3; - fVerts[3] = (CCGVertHDL) mf->v4; + fVerts[0] = (CCGVertHDL) mf->v1; + fVerts[1] = (CCGVertHDL) mf->v2; + fVerts[2] = (CCGVertHDL) mf->v3; + fVerts[3] = (CCGVertHDL) mf->v4; - ccgSubSurf_syncFace(ss, (CCGFaceHDL) i, fVerts[3]?4:3, fVerts, &f); - ((int*) ccgSubSurf_getFaceUserData(ss, f))[1] = index; - } + ccgSubSurf_syncFace(ss, (CCGFaceHDL) i, fVerts[3]?4:3, fVerts, &f); + ((int*) ccgSubSurf_getFaceUserData(ss, f))[1] = index; } ccgSubSurf_processSync(ss); @@ -1474,7 +1444,7 @@ DerivedMesh *subsurf_make_derived_from_editmesh(EditMesh *em, SubsurfModifierDat int useAging = smd->flags&eSubsurfModifierFlag_DebugIncr; int drawInteriorEdges = !(smd->flags&eSubsurfModifierFlag_ControlEdges); - smd->emCache = _getSubSurf(smd->emCache, smd->levels, useAging, 0, 0, useSimple); + smd->emCache = _getSubSurf(smd->emCache, smd->levels, useAging, 0, useSimple); ss_sync_from_editmesh(smd->emCache, em, vertCos, useSimple); return (DerivedMesh*) getCCGDerivedMesh(smd->emCache, 1, drawInteriorEdges, NULL, NULL); @@ -1485,7 +1455,7 @@ DerivedMesh *subsurf_make_derived_from_dlm_em(DispListMesh *dlm, SubsurfModifier int useAging = smd->flags&eSubsurfModifierFlag_DebugIncr; int drawInteriorEdges = !(smd->flags&eSubsurfModifierFlag_ControlEdges); - smd->emCache = _getSubSurf(smd->emCache, smd->levels, useAging, 0, 0, useSimple); + smd->emCache = _getSubSurf(smd->emCache, smd->levels, useAging, 0, useSimple); ss_sync_from_mesh(smd->emCache, NULL, dlm, vertCos, useSimple); @@ -1499,7 +1469,7 @@ DerivedMesh *subsurf_make_derived_from_mesh(Mesh *me, DispListMesh *dlm, Subsurf /* Do not use cache in render mode. */ if (useRenderParams) { - CCGSubSurf *ss = _getSubSurf(NULL, smd->renderLevels, 0, 1, 1, useSimple); + CCGSubSurf *ss = _getSubSurf(NULL, smd->renderLevels, 0, 1, useSimple); ss_sync_from_mesh(ss, me, dlm, vertCos, useSimple); @@ -1510,8 +1480,7 @@ DerivedMesh *subsurf_make_derived_from_mesh(Mesh *me, DispListMesh *dlm, Subsurf return derivedmesh_from_displistmesh(ndlm, NULL); } else { - int useEdgeCreation = !(dlm?dlm->medge:me->medge); - int useIncremental = (smd->flags&eSubsurfModifierFlag_Incremental) && !useEdgeCreation; + int useIncremental = (smd->flags&eSubsurfModifierFlag_Incremental); int useAging = smd->flags&eSubsurfModifierFlag_DebugIncr; CCGSubSurf *ss; @@ -1529,7 +1498,7 @@ DerivedMesh *subsurf_make_derived_from_mesh(Mesh *me, DispListMesh *dlm, Subsurf } if (useIncremental && isFinalCalc) { - smd->mCache = ss = _getSubSurf(smd->mCache, smd->levels, useAging, 0, 0, useSimple); + smd->mCache = ss = _getSubSurf(smd->mCache, smd->levels, useAging, 0, useSimple); ss_sync_from_mesh(ss, me, dlm, vertCos, useSimple); @@ -1540,7 +1509,7 @@ DerivedMesh *subsurf_make_derived_from_mesh(Mesh *me, DispListMesh *dlm, Subsurf smd->mCache = NULL; } - ss = _getSubSurf(NULL, smd->levels, 0, 1, useEdgeCreation, useSimple); + ss = _getSubSurf(NULL, smd->levels, 0, 1, useSimple); ss_sync_from_mesh(ss, me, dlm, vertCos, useSimple); ndlm = ss_to_displistmesh(ss, NULL, 0, drawInteriorEdges, me, dlm); @@ -1560,7 +1529,7 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]) * calculated vert positions is incorrect for the verts * on the boundary of the mesh. */ - CCGSubSurf *ss = _getSubSurf(NULL, 1, 0, 1, 0, 0); + CCGSubSurf *ss = _getSubSurf(NULL, 1, 0, 1, 0); float edge_sum[3], face_sum[3]; CCGVertIterator *vi; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 754b30b4afa..061bfdb912b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3527,26 +3527,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ma= ma->id.next; } } - if(main->versionfile <= 114) { - Mesh *me= main->mesh.first; - MFace *mface; - int a_int; - - /* edge drawflags changed */ - while(me) { - a_int= me->totface; - mface= me->mface; - while(a_int--) { - if(mface->edcode & 16) { - mface->edcode -= 16; - mface->edcode |= ME_V3V1; - } - mface++; - } - me= me->id.next; - } - } - if(main->versionfile <= 134) { Tex *tex = main->tex.first; @@ -4872,6 +4852,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Lattice *lt; Object *ob; bArmature *arm; + Mesh *me; for (lt=main->latt.first; lt; lt=lt->id.next) { if (lt->fu==0.0 && lt->fv==0.0 && lt->fw==0.0) { @@ -4902,6 +4883,14 @@ static void do_versions(FileData *fd, Library *lib, Main *main) for(arm=main->armature.first; arm; arm= arm->id.next) { bone_version_238(&arm->bonebase); } + + for(me=main->mesh.first; me; me= me->id.next) { + if (!me->medge) { + make_edges(me); + } else { + mesh_strip_loose_faces(me); + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */ diff --git a/source/blender/include/butspace.h b/source/blender/include/butspace.h index 679edbe7683..f3a4b4cad4c 100644 --- a/source/blender/include/butspace.h +++ b/source/blender/include/butspace.h @@ -356,8 +356,6 @@ enum { #define B_MAKESTICKY 2082 #define B_MAKEVERTCOL 2083 #define B_CHROMADEPTH 2084 -#define B_MAKEEDGES 2085 -#define B_DELEDGES 2086 #define B_DRAWEDGES 2087 #define B_DRAWCREASES 2088 diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index decb52ec1fc..eb46a146ad3 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -37,7 +37,7 @@ struct Bone; typedef struct MFace { unsigned int v1, v2, v3, v4; char pad, mat_nr; - char edcode, flag; + char pad2, flag; } MFace; typedef struct MEdge { diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c index 6e11883b16c..024933e33a1 100644 --- a/source/blender/python/api2_2x/NMesh.c +++ b/source/blender/python/api2_2x/NMesh.c @@ -94,7 +94,6 @@ static PyObject *NMesh_printDebug( PyObject * self ); static PyObject *NMesh_addEdge( PyObject * self, PyObject * args ); static PyObject *NMesh_findEdge( PyObject * self, PyObject * args ); static PyObject *NMesh_removeEdge( PyObject * self, PyObject * args ); -static PyObject *NMesh_addEdgesData( PyObject * self ); static PyObject *NMesh_addFace( PyObject * self, PyObject * args ); static PyObject *NMesh_removeFace( PyObject * self, PyObject * args ); static PyObject *NMesh_addVertGroup( PyObject * self, PyObject * args ); @@ -122,9 +121,6 @@ static char NMesh_removeEdge_doc[] = "remove an edge between two vertices.\n\ All faces using this edge are removed from faces list."; -static char NMesh_addEdgesData_doc[] = - "add edges data to the mesh."; - static char NMesh_addFace_doc[] = "add a face to face list and add to edge list (if edge data exists) necessary edges."; @@ -301,8 +297,6 @@ vertex coordinatess.\n"; void mesh_update( Mesh * mesh, Object * ob ) { - edge_drawflags_mesh( mesh ); - if (ob) { DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); } @@ -1038,7 +1032,7 @@ static void NMesh_dealloc( PyObject * self ) Py_DECREF( me->verts ); Py_DECREF( me->faces ); Py_DECREF( me->materials ); - Py_XDECREF( me->edges ); + Py_DECREF( me->edges ); PyObject_DEL( self ); } @@ -1606,7 +1600,6 @@ static struct PyMethodDef NMesh_methods[] = { NMesh_##func##_doc} MethodDef( printDebug ), - MethodDef( addEdgesData ), MethodDef( getVertGroupNames ), MethodDef( getActiveFace ), MethodDef( getMode ), @@ -1661,10 +1654,7 @@ static PyObject *NMesh_getattr( PyObject * self, char *name ) else if( strcmp( name, "edges" ) == 0 ) { - if (me->edges) - return EXPP_incr_ret( me->edges ); - else - return EXPP_incr_ret( Py_None ); + return EXPP_incr_ret( me->edges ); } else if (strcmp(name, "oopsLoc") == 0) { if (G.soops) { @@ -1806,17 +1796,11 @@ static int NMesh_setattr( PyObject * self, char *name, PyObject * v ) } else if( strcmp( name, "edges" ) == 0 ) { - if (me->edges) + if (PySequence_Check(v)) { - if (PySequence_Check(v)) - { - Py_DECREF(me->edges); - me->edges = EXPP_incr_ret( v ); - } + Py_DECREF(me->edges); + me->edges = EXPP_incr_ret( v ); } - else - return EXPP_ReturnIntError( PyExc_RuntimeError, - "mesh has no edge information" ); } else if (!strcmp(name, "oopsLoc")) { if (G.soops) { @@ -1881,10 +1865,8 @@ static BPy_NMFace *nmface_from_data( BPy_NMesh * mesh, int vidxs[4], if( vidxs[3] ) len = 4; - else if( vidxs[2] ) + else len = 3; - else - len = 2; newf->v = PyList_New( len ); @@ -1935,6 +1917,13 @@ static BPy_NMFace *nmface_from_data( BPy_NMesh * mesh, int vidxs[4], return newf; } +static BPy_NMEdge *nmedge_from_index( BPy_NMesh * mesh, int v0idx, int v1idx) +{ + BPy_NMVert *v1=(BPy_NMVert *)PyList_GetItem( mesh->verts, v0idx); + BPy_NMVert *v2=(BPy_NMVert *)PyList_GetItem( mesh->verts, v1idx); + return new_NMEdge(v1, v2, 0.0, 0); +} + static BPy_NMEdge *nmedge_from_data( BPy_NMesh * mesh, MEdge *edge ) { BPy_NMVert *v1=(BPy_NMVert *)PyList_GetItem( mesh->verts, edge->v1 ); @@ -2092,6 +2081,10 @@ static PyObject *new_NMesh_displist(ListBase *lb, Object *ob) int parts, p1, p2, p3, p4, a, b, one_normal=0, ioffset=0; int *index; + /* Note: This routine does not create new edges for the faces + * it adds... should be fixed for consistency. + */ + if (ob->type == OB_CURVE || ob->type == OB_FONT) one_normal = 1; @@ -2102,7 +2095,7 @@ static PyObject *new_NMesh_displist(ListBase *lb, Object *ob) me->subdiv[0] = NMESH_SUBDIV; me->subdiv[1] = NMESH_SUBDIV; me->smoothresh = NMESH_SMOOTHRESH; - me->edges = NULL; + me->edges = PyList_New( 0 ); me->object = ob; me->materials = EXPP_PyList_fromMaterialList( ob->mat, ob->totcol, 0 ); @@ -2127,9 +2120,9 @@ static PyObject *new_NMesh_displist(ListBase *lb, Object *ob) for(a=0; a<dl->parts; a++) { for(b=1; b<dl->nr; b++) { - vidx[0] = ioffset + a * dl->nr + b-1; - vidx[1] = ioffset + a * dl->nr + b; - PyList_Append(me->faces, ( PyObject * ) nmface_from_index(me, vidx, 0)); + int v0 = ioffset + a * dl->nr + b-1; + int v1 = ioffset + a * dl->nr + b; + PyList_Append(me->edges, ( PyObject * ) nmedge_from_index(me, v0, v1)); } } ioffset += dl->parts * dl->nr; @@ -2143,10 +2136,10 @@ static PyObject *new_NMesh_displist(ListBase *lb, Object *ob) for(a=0; a<dl->parts; a++) { for(b=0; b<dl->nr; b++) { - vidx[0] = ioffset + a * dl->nr + b; - if(b==dl->nr-1) vidx[1] = ioffset + a * dl->nr; - else vidx[1]= ioffset + a * dl->nr + b+1; - PyList_Append(me->faces, ( PyObject * ) nmface_from_index(me, vidx, 0)); + int v1, v0 = ioffset + a * dl->nr + b; + if(b==dl->nr-1) v1 = ioffset + a * dl->nr; + else v1= ioffset + a * dl->nr + b+1; + PyList_Append(me->edges, ( PyObject * ) nmedge_from_index(me, v0, v1)); } } ioffset += dl->parts * dl->nr; @@ -2234,7 +2227,6 @@ static PyObject *new_NMesh_internal( Mesh * oldmesh, me->subdiv[0] = NMESH_SUBDIV; me->subdiv[1] = NMESH_SUBDIV; me->smoothresh = NMESH_SMOOTHRESH; - me->edges = NULL; /* no edge data by default */ me->object = NULL; /* not linked to any object yet */ @@ -2242,6 +2234,7 @@ static PyObject *new_NMesh_internal( Mesh * oldmesh, me->name = EXPP_incr_ret( Py_None ); me->materials = PyList_New( 0 ); me->verts = PyList_New( 0 ); + me->edges = PyList_New( 0 ); me->faces = PyList_New( 0 ); me->mesh = 0; } else { @@ -2329,14 +2322,11 @@ static PyObject *new_NMesh_internal( Mesh * oldmesh, oldmc ) ); } - if (medges) + me->edges = PyList_New( totedge ); + for( i = 0; i < totedge; i++ ) { - me->edges = PyList_New( totedge ); - for( i = 0; i < totedge; i++ ) - { - MEdge *edge = &medges[i]; - PyList_SetItem( me->edges, i, (PyObject*)nmedge_from_data ( me, edge ) ); - } + MEdge *edge = &medges[i]; + PyList_SetItem( me->edges, i, (PyObject*)nmedge_from_data ( me, edge ) ); } me->materials = EXPP_PyList_fromMaterialList( oldmesh->mat, oldmesh->totcol, 0 ); @@ -2576,27 +2566,28 @@ static void mface_from_data( MFace * mf, TFace * tf, MCol * col, BPy_NMVert *nmv; int i = PyList_Size( from->v ); - if( i >= 1 ) { - nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 0 ); - if( BPy_NMVert_Check( nmv ) && nmv->index != -1 ) - mf->v1 = nmv->index; - else - mf->v1 = 0; - } - if( i >= 2 ) { - nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 1 ); - if( BPy_NMVert_Check( nmv ) && nmv->index != -1 ) - mf->v2 = nmv->index; - else - mf->v2 = 0; - } - if( i >= 3 ) { - nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 2 ); - if( BPy_NMVert_Check( nmv ) && nmv->index != -1 ) - mf->v3 = nmv->index; - else - mf->v3 = 0; + if (i<3) { + return; /* XXX, need to raise error here instead of just failing */ } + + nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 0 ); + if( BPy_NMVert_Check( nmv ) && nmv->index != -1 ) + mf->v1 = nmv->index; + else + mf->v1 = 0; + + nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 1 ); + if( BPy_NMVert_Check( nmv ) && nmv->index != -1 ) + mf->v2 = nmv->index; + else + mf->v2 = 0; + + nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 2 ); + if( BPy_NMVert_Check( nmv ) && nmv->index != -1 ) + mf->v3 = nmv->index; + else + mf->v3 = 0; + if( i >= 4 ) { nmv = ( BPy_NMVert * ) PyList_GetItem( from->v, 3 ); if( BPy_NMVert_Check( nmv ) && nmv->index != -1 ) @@ -2611,14 +2602,11 @@ static void mface_from_data( MFace * mf, TFace * tf, MCol * col, PyErr_Print( ); return; } - - test_index_face(mf, NULL, tf, i ); - } else { - test_index_face(mf, NULL, NULL, i ); } + test_index_face(mf, NULL, tf, mf->v4?4:3); + mf->mat_nr = from->mat_nr; - mf->edcode = 0; mf->flag = from->mf_flag; if( col ) { @@ -2923,7 +2911,7 @@ static int convert_NMeshToMesh( Mesh * mesh, BPy_NMesh * nmesh, int store_edges) MVert *newmv; MSticky *newst; MCol *newmc; - + int nmeshtotedges; int i, j; mesh->mvert = NULL; @@ -2933,7 +2921,6 @@ static int convert_NMeshToMesh( Mesh * mesh, BPy_NMesh * nmesh, int store_edges) mesh->msticky = NULL; mesh->tface = NULL; mesh->mat = NULL; - mesh->medge = NULL; /* Minor note: we used 'mode' because 'flag' was already used internally * by nmesh */ @@ -3005,9 +2992,7 @@ static int convert_NMeshToMesh( Mesh * mesh, BPy_NMesh * nmesh, int store_edges) Py_DECREF( mf ); } /* do the same for edges if there is edge data */ - if (nmesh->edges) - { - int nmeshtotedges=PyList_Size(nmesh->edges); + nmeshtotedges=PyList_Size(nmesh->edges); for( i = 0; i < nmeshtotedges; ++i ) { BPy_NMEdge *edge=( BPy_NMEdge *) PyList_GetItem(nmesh->edges, i); @@ -3016,7 +3001,6 @@ static int convert_NMeshToMesh( Mesh * mesh, BPy_NMesh * nmesh, int store_edges) v=(BPy_NMVert *)edge->v2; v->index=-1; } - } for( i = 0; i < mesh->totvert; i++ ) { BPy_NMVert *mv = @@ -3077,14 +3061,8 @@ static int convert_NMeshToMesh( Mesh * mesh, BPy_NMesh * nmesh, int store_edges) } } - /* After face data has been written, write edge data. - * Edge data are not stored before face ones since we need - * mesh->mface to be correctly initialized. - */ - if (nmesh->edges && store_edges) - { + /* Always do this to ensure no loose edges in faces */ fill_medge_from_nmesh(mesh, nmesh); - } return 1; } @@ -3482,10 +3460,6 @@ static PyObject *NMesh_addEdge( PyObject * self, PyObject * args ) BPy_NMesh *bmesh=(BPy_NMesh *)self; BPy_NMVert *v1=NULL, *v2=NULL; - if (!bmesh->edges) - return EXPP_ReturnPyObjError( PyExc_RuntimeError, - "NMesh has no edge data." ); - if (!PyArg_ParseTuple ( args, "O!O!", &NMVert_Type, &v1, &NMVert_Type, &v2 ) ) { return EXPP_ReturnPyObjError( PyExc_TypeError, @@ -3504,10 +3478,6 @@ static PyObject *NMesh_findEdge( PyObject * self, PyObject * args ) BPy_NMesh *bmesh=(BPy_NMesh *)self; BPy_NMVert *v1=NULL, *v2=NULL; - if (!bmesh->edges) - return EXPP_ReturnPyObjError( PyExc_RuntimeError, - "NMesh has no edge data." ); - if (!PyArg_ParseTuple ( args, "O!O!", &NMVert_Type, &v1, &NMVert_Type, &v2 ) ) { return EXPP_ReturnPyObjError( PyExc_TypeError, @@ -3526,10 +3496,6 @@ static PyObject *NMesh_removeEdge( PyObject * self, PyObject * args ) BPy_NMesh *bmesh=(BPy_NMesh *)self; BPy_NMVert *v1=NULL, *v2=NULL; - if (!bmesh->edges) - return EXPP_ReturnPyObjError( PyExc_RuntimeError, - "NMesh has no edge data." ); - if (!PyArg_ParseTuple ( args, "O!O!", &NMVert_Type, &v1, &NMVert_Type, &v2 ) ) { return EXPP_ReturnPyObjError( PyExc_TypeError, @@ -3545,48 +3511,6 @@ static PyObject *NMesh_removeEdge( PyObject * self, PyObject * args ) } -static PyObject *NMesh_addEdgesData( PyObject * self ) -{ - /* Here we uses make_edges to create edges data. - * Since Mesh corresponding to NMesh may not content the same data as - * the NMesh and since maybe the NMesh has been created from scratch, - * we creates a temporary Mesh to use to call make_edges - */ - BPy_NMesh *nmesh=(BPy_NMesh *)self; - Mesh *tempMesh=NULL; - int i; - - if (nmesh->edges) - return EXPP_ReturnPyObjError( PyExc_RuntimeError, - "NMesh has already edge data." ); - - tempMesh=MEM_callocN(sizeof(Mesh), "temp mesh"); - convert_NMeshToMesh(tempMesh, nmesh, 0); - - make_edges(tempMesh); - - nmesh->edges = PyList_New( tempMesh->totedge ); - for( i = 0; i < tempMesh->totedge; ++i ) - { - MEdge *edge = (tempMesh->medge) + i; - /* By using nmedge_from_data, an important assumption is made: - * every vertex in nmesh has been written in tempMesh in the same order - * than in nmesh->verts. - * Actually this assumption is needed since nmedge_from_data get the - * two NMVert for the newly created edge by using a PyList_GetItem with - * the indices stored in edge. Those indices are valid for nmesh only if - * nmesh->verts and tempMesh->mvert are identical (same number of vertices - * in same order). - */ - PyList_SetItem( nmesh->edges, i, (PyObject*)nmedge_from_data ( nmesh, edge ) ); - } - - unlink_existingMeshData(tempMesh); - MEM_freeN(tempMesh); - - return EXPP_incr_ret( Py_None ); -} - static PyObject *NMesh_addFace( PyObject * self, PyObject * args ) { BPy_NMesh *nmesh=(BPy_NMesh *)self; @@ -3606,12 +3530,9 @@ static PyObject *NMesh_addFace( PyObject * self, PyObject * args ) * Before edges data exists, having faces with two vertices was * the only way of storing edges not attached to any face. */ - if (totv!=2 || !nmesh->edges) + if (totv!=2) PyList_Append(nmesh->faces, (PyObject*)face); - if (nmesh->edges) - { - if (totv>=2) { /* when totv==2, there is only one edge, when totv==3 there is three edges @@ -3638,7 +3559,6 @@ static PyObject *NMesh_addFace( PyObject * self, PyObject * args ) } return edges; } - } return EXPP_incr_ret( Py_None ); } @@ -3664,9 +3584,6 @@ static PyObject *NMesh_removeFace( PyObject * self, PyObject * args ) PySequence_DelItem(nmesh->faces, index); } - if (nmesh->edges) - { - if (totv>=2) { /* when totv==2, there is only one edge, when totv==3 there is three edges @@ -3689,7 +3606,6 @@ static PyObject *NMesh_removeFace( PyObject * self, PyObject * args ) } } } - } return EXPP_incr_ret( Py_None ); } @@ -3714,7 +3630,6 @@ static PyObject *NMesh_printDebug( PyObject * self ) } printf("**Edges\n"); - if (mesh->medge) { int i; for (i=0; i<mesh->totedge; ++i) @@ -3726,8 +3641,6 @@ static PyObject *NMesh_printDebug( PyObject * self ) printf(" %2d : %2d %2d flag=%d\n", i, v1, v2, flag); } } - else - printf(" No edge informations\n"); printf("**Faces\n"); { diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index 9cec69b2d1c..4864cba1506 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -4044,11 +4044,6 @@ PyObject *Object_setSBStiffQuads( BPy_Object * self, PyObject * args ) int setupSB(Object* ob){ ob->soft= sbNew(); ob->softflag |= OB_SB_GOAL|OB_SB_EDGES; - // default add edges for softbody - if(ob->type==OB_MESH) { - Mesh *me= ob->data; - if(me->medge==NULL) make_edges(me); - } if(ob->soft){ ob->soft->nodemass = 1.0f; diff --git a/source/blender/radiosity/intern/source/radpostprocess.c b/source/blender/radiosity/intern/source/radpostprocess.c index a722d881200..49ff4183780 100644 --- a/source/blender/radiosity/intern/source/radpostprocess.c +++ b/source/blender/radiosity/intern/source/radpostprocess.c @@ -979,8 +979,6 @@ void rad_addmesh(void) mface->v2= *((unsigned int *)face->v2+3); mface->v3= *((unsigned int *)face->v3+3); if(face->v4) mface->v4= *((unsigned int *)face->v4+3); - - mface->edcode= 3; test_index_face(mface, NULL, NULL, face->v4 ? 4 : 3); mface->mat_nr= face->matindex; diff --git a/source/blender/radiosity/intern/source/radpreprocess.c b/source/blender/radiosity/intern/source/radpreprocess.c index f343db2cee8..cf7385edd0c 100644 --- a/source/blender/radiosity/intern/source/radpreprocess.c +++ b/source/blender/radiosity/intern/source/radpreprocess.c @@ -420,103 +420,101 @@ void rad_collect_meshes() index= -1; for(a=0; a<me->totface; a++, mface++) { - if(mface->v3) { - TFace *tface = me->tface ? &((TFace*)me->tface)[a] : NULL; - - if (tface == NULL || (tface->mode & TF_INVISIBLE)==0) { - - rp= callocPatch(); - BLI_addtail(&(RG.patchbase), rp); - rp->from= ob; - - if(mface->v4) rp->type= 4; - else rp->type= 3; - - rp->first= rn= callocNode(); - - if(mface->flag & ME_SMOOTH) rp->f1= RAD_NO_SPLIT; - - /* temporal: we store the venoco in the node */ - rn->v1= (float *)(RG.verts+mface->v1+offs); - v1= (RG.verts+mface->v1+offs)->v; - rn->v2= (float *)(RG.verts+mface->v2+offs); - v2= (RG.verts+mface->v2+offs)->v; - rn->v3= (float *)(RG.verts+mface->v3+offs); - v3= (RG.verts+mface->v3+offs)->v; - - if(mface->v4) { - rn->v4= (float *)(RG.verts+mface->v4+offs); - v4= (RG.verts+mface->v4+offs)->v; - } - rn->par= rp; - rn->f= RAD_PATCH; /* this node is a Patch */ - rn->type= rp->type; - - if(rn->type==4) { - rp->area= AreaQ3Dfl(v1, v2, v3, v4); - CalcNormFloat4(v1, v2, v3, v4, rp->norm); - } - else { - rp->area= AreaT3Dfl(v1, v2, v3); - CalcNormFloat(v1, v2, v3, rp->norm); - } - - if (tface) { - memcpy(rn->uv, tface->uv, sizeof(float) * 4 * 2); - rn->tface = tface; - } - else { - rn->uv[0][0] = 0.0f; - rn->uv[0][1] = 0.0f; - rn->uv[1][0] = 1.0f; - rn->uv[1][1] = 0.0f; - rn->uv[2][0] = 1.0f; - rn->uv[2][1] = 1.0f; - rn->uv[3][0] = 0.0f; - rn->uv[3][1] = 1.0f; - rn->tface = NULL; - } - - rn->area= rp->area; - - /* color and emit */ - if(mface->mat_nr != index) { - index= mface->mat_nr; - ma= give_current_material(ob, index+1); - if(ma==0) ma= &defmaterial; - } - rp->ref[0]= ma->r; - rp->ref[1]= ma->g; - rp->ref[2]= ma->b; - - if(ma->emit) RG.totlamp++; - - rp->emit[0]= rp->emit[1]= rp->emit[2]= ma->emit; - rp->emit[0]*= rp->ref[0]; - rp->emit[1]*= rp->ref[1]; - rp->emit[2]*= rp->ref[2]; - - // uncommented, this is not satisfying, but i leave it in code for now (ton) - // if(ma->translucency!=0.0) rn->f |= RAD_TWOSIDED; - - nodevert= (VeNoCo **)&(rn->v1); - for(b=0; b<rp->type; b++) { - rp->cent[0]+= (*nodevert)->v[0]; - rp->cent[1]+= (*nodevert)->v[1]; - rp->cent[2]+= (*nodevert)->v[2]; - nodevert++; - } - rp->cent[0]/= (float)rp->type; - rp->cent[1]/= (float)rp->type; - rp->cent[2]/= (float)rp->type; - - /* for reconstruction materials */ - rp->matindex= materialIndex(ma); - if(rp->matindex==-1) rp->matindex= 1; - - RG.totelem++; - RG.totpatch++; + TFace *tface = me->tface ? &((TFace*)me->tface)[a] : NULL; + + if (tface == NULL || (tface->mode & TF_INVISIBLE)==0) { + + rp= callocPatch(); + BLI_addtail(&(RG.patchbase), rp); + rp->from= ob; + + if(mface->v4) rp->type= 4; + else rp->type= 3; + + rp->first= rn= callocNode(); + + if(mface->flag & ME_SMOOTH) rp->f1= RAD_NO_SPLIT; + + /* temporal: we store the venoco in the node */ + rn->v1= (float *)(RG.verts+mface->v1+offs); + v1= (RG.verts+mface->v1+offs)->v; + rn->v2= (float *)(RG.verts+mface->v2+offs); + v2= (RG.verts+mface->v2+offs)->v; + rn->v3= (float *)(RG.verts+mface->v3+offs); + v3= (RG.verts+mface->v3+offs)->v; + + if(mface->v4) { + rn->v4= (float *)(RG.verts+mface->v4+offs); + v4= (RG.verts+mface->v4+offs)->v; + } + rn->par= rp; + rn->f= RAD_PATCH; /* this node is a Patch */ + rn->type= rp->type; + + if(rn->type==4) { + rp->area= AreaQ3Dfl(v1, v2, v3, v4); + CalcNormFloat4(v1, v2, v3, v4, rp->norm); + } + else { + rp->area= AreaT3Dfl(v1, v2, v3); + CalcNormFloat(v1, v2, v3, rp->norm); + } + + if (tface) { + memcpy(rn->uv, tface->uv, sizeof(float) * 4 * 2); + rn->tface = tface; + } + else { + rn->uv[0][0] = 0.0f; + rn->uv[0][1] = 0.0f; + rn->uv[1][0] = 1.0f; + rn->uv[1][1] = 0.0f; + rn->uv[2][0] = 1.0f; + rn->uv[2][1] = 1.0f; + rn->uv[3][0] = 0.0f; + rn->uv[3][1] = 1.0f; + rn->tface = NULL; + } + + rn->area= rp->area; + + /* color and emit */ + if(mface->mat_nr != index) { + index= mface->mat_nr; + ma= give_current_material(ob, index+1); + if(ma==0) ma= &defmaterial; + } + rp->ref[0]= ma->r; + rp->ref[1]= ma->g; + rp->ref[2]= ma->b; + + if(ma->emit) RG.totlamp++; + + rp->emit[0]= rp->emit[1]= rp->emit[2]= ma->emit; + rp->emit[0]*= rp->ref[0]; + rp->emit[1]*= rp->ref[1]; + rp->emit[2]*= rp->ref[2]; + +// uncommented, this is not satisfying, but i leave it in code for now (ton) +// if(ma->translucency!=0.0) rn->f |= RAD_TWOSIDED; + + nodevert= (VeNoCo **)&(rn->v1); + for(b=0; b<rp->type; b++) { + rp->cent[0]+= (*nodevert)->v[0]; + rp->cent[1]+= (*nodevert)->v[1]; + rp->cent[2]+= (*nodevert)->v[2]; + nodevert++; } + rp->cent[0]/= (float)rp->type; + rp->cent[1]/= (float)rp->type; + rp->cent[2]/= (float)rp->type; + + /* for reconstruction materials */ + rp->matindex= materialIndex(ma); + if(rp->matindex==-1) rp->matindex= 1; + + RG.totelem++; + RG.totpatch++; } } offs+= me->totvert; diff --git a/source/blender/renderconverter/intern/convertBlenderScene.c b/source/blender/renderconverter/intern/convertBlenderScene.c index 40af2793c82..bc9aceb9ad5 100644 --- a/source/blender/renderconverter/intern/convertBlenderScene.c +++ b/source/blender/renderconverter/intern/convertBlenderScene.c @@ -392,26 +392,23 @@ static void DBG_show_shared_render_faces(int firstvert, int firstface) for (i=firstface; i<R.totvlak; i++) { VlakRen *vlr = RE_findOrAddVlak(i); + float cent[3]; - if (vlr->v3) { - float cent[3]; - - if (vlr->v4) { - CalcCent4f(cent, vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co); - VecAddf(vlr->v4->n, vlr->v4->n, cent); - vlr->v4->sticky = (float*) (((int) vlr->v4->sticky) + 1); - } else { - CalcCent3f(cent, vlr->v1->co, vlr->v2->co, vlr->v3->co); - } + if (vlr->v4) { + CalcCent4f(cent, vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co); + VecAddf(vlr->v4->n, vlr->v4->n, cent); + vlr->v4->sticky = (float*) (((int) vlr->v4->sticky) + 1); + } else { + CalcCent3f(cent, vlr->v1->co, vlr->v2->co, vlr->v3->co); + } - VecAddf(vlr->v1->n, vlr->v1->n, cent); - VecAddf(vlr->v2->n, vlr->v2->n, cent); - VecAddf(vlr->v3->n, vlr->v3->n, cent); + VecAddf(vlr->v1->n, vlr->v1->n, cent); + VecAddf(vlr->v2->n, vlr->v2->n, cent); + VecAddf(vlr->v3->n, vlr->v3->n, cent); - vlr->v1->sticky = (float*) (((int) vlr->v1->sticky) + 1); - vlr->v2->sticky = (float*) (((int) vlr->v2->sticky) + 1); - vlr->v3->sticky = (float*) (((int) vlr->v3->sticky) + 1); - } + vlr->v1->sticky = (float*) (((int) vlr->v1->sticky) + 1); + vlr->v2->sticky = (float*) (((int) vlr->v2->sticky) + 1); + vlr->v3->sticky = (float*) (((int) vlr->v3->sticky) + 1); } for (i=firstvert; i<R.totvert; i++) { @@ -1397,79 +1394,61 @@ static void init_render_mesh(Object *ob) } for(a=0; a<end; a++) { - int v1, v2, v3, v4, edcode, flag; + int v1, v2, v3, v4, flag; if( mface->mat_nr==a1 ) { + float len; + v1= mface->v1; v2= mface->v2; v3= mface->v3; v4= mface->v4; flag= mface->flag; - edcode= mface->edcode; - if(v3) { - float len; - - vlr= RE_findOrAddVlak(R.totvlak++); - vlr->ob= vlr_set_ob(ob); - vlr->v1= RE_findOrAddVert(vertofs+v1); - vlr->v2= RE_findOrAddVert(vertofs+v2); - vlr->v3= RE_findOrAddVert(vertofs+v3); - if(v4) vlr->v4= RE_findOrAddVert(vertofs+v4); - else vlr->v4= 0; - - /* render normals are inverted in render */ - if(vlr->v4) len= CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, - vlr->v1->co, vlr->n); - else len= CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, - vlr->n); - - vlr->mat= ma; - vlr->flag= flag; - if((me->flag & ME_NOPUNOFLIP) ) { - vlr->flag |= R_NOPUNOFLIP; - } - vlr->ec= edcode; - vlr->lay= ob->lay; - - if(len==0) R.totvlak--; - else { - if(dlm) { - if(tface) { - vlr->tface= BLI_memarena_alloc(R.memArena, sizeof(*vlr->tface)); - vlr->vcol= vlr->tface->col; - memcpy(vlr->tface, tface, sizeof(*tface)); - } - else if (vertcol) { - vlr->vcol= BLI_memarena_alloc(R.memArena, sizeof(int)*16); - memcpy(vlr->vcol, vertcol+4*a, sizeof(int)*16); - } - } else { - if(tface) { - vlr->vcol= tface->col; - vlr->tface= tface; - } - else if (vertcol) { - vlr->vcol= vertcol+4*a; - } + vlr= RE_findOrAddVlak(R.totvlak++); + vlr->ob= vlr_set_ob(ob); + vlr->v1= RE_findOrAddVert(vertofs+v1); + vlr->v2= RE_findOrAddVert(vertofs+v2); + vlr->v3= RE_findOrAddVert(vertofs+v3); + if(v4) vlr->v4= RE_findOrAddVert(vertofs+v4); + else vlr->v4= 0; + + /* render normals are inverted in render */ + if(vlr->v4) len= CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, + vlr->v1->co, vlr->n); + else len= CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, + vlr->n); + + vlr->mat= ma; + vlr->flag= flag; + if((me->flag & ME_NOPUNOFLIP) ) { + vlr->flag |= R_NOPUNOFLIP; + } + vlr->ec= 0; /* mesh edges rendered separately */ + vlr->lay= ob->lay; + + if(len==0) R.totvlak--; + else { + if(dlm) { + if(tface) { + vlr->tface= BLI_memarena_alloc(R.memArena, sizeof(*vlr->tface)); + vlr->vcol= vlr->tface->col; + memcpy(vlr->tface, tface, sizeof(*tface)); + } + else if (vertcol) { + vlr->vcol= BLI_memarena_alloc(R.memArena, sizeof(int)*16); + memcpy(vlr->vcol, vertcol+4*a, sizeof(int)*16); + } + } else { + if(tface) { + vlr->vcol= tface->col; + vlr->tface= tface; + } + else if (vertcol) { + vlr->vcol= vertcol+4*a; } } } - else if(v2 && (ma->mode & MA_WIRE)) { - vlr= RE_findOrAddVlak(R.totvlak++); - vlr->ob= vlr_set_ob(ob); - vlr->v1= RE_findOrAddVert(vertofs+v1); - vlr->v2= RE_findOrAddVert(vertofs+v2); - vlr->v3= vlr->v2; - vlr->v4= 0; - - vlr->n[0]=vlr->n[1]=vlr->n[2]= 0.0; - - vlr->mat= ma; - vlr->flag= flag; - vlr->ec= ME_V1V2; - vlr->lay= ob->lay; - } } mface++; diff --git a/source/blender/src/booleanops.c b/source/blender/src/booleanops.c index 4097c76dd11..6a7a5ced25e 100644 --- a/source/blender/src/booleanops.c +++ b/source/blender/src/booleanops.c @@ -69,9 +69,6 @@ #include <config.h> #endif -/** check if passed mesh has faces, return zero if only edges, 1 if faces have been found */ -int has_faces(Mesh *me); - /** * Here's the vertex iterator structure used to walk through * the blender vertex structure. @@ -236,18 +233,16 @@ FaceIt_Fill( MFace *mface = &mfaces[f_index]; FaceData *fdata = face->user_face_data; - if (mface->v3) { - // ignore lines (faces with mface->v3==0) - face->vertex_index[0] = mface->v1; - face->vertex_index[1] = mface->v2; - face->vertex_index[2] = mface->v3; - if (mface->v4) { - face->vertex_index[3] = mface->v4; - face->vertex_number = 4; - } else { - face->vertex_number = 3; - } - } + // ignore lines (faces with mface->v3==0) + face->vertex_index[0] = mface->v1; + face->vertex_index[1] = mface->v2; + face->vertex_index[2] = mface->v3; + if (mface->v4) { + face->vertex_index[3] = mface->v4; + face->vertex_number = 4; + } else { + face->vertex_number = 3; + } fdata->faceflag = mface->flag; fdata->material = give_current_material(ob, mface->mat_nr+1); @@ -364,18 +359,6 @@ InterpFaceVertexData( return 0; } -int has_faces(Mesh *me) -{ - MFace *mface; - int a; - - mface= me->mface; - for(a=0; a<me->totface; a++, mface++) { - if(mface->v3) return 1; - } - return 0; -} - /** * Assumes mesh is valid and forms part of a fresh * blender object. @@ -410,10 +393,7 @@ NewBooleanMesh( if (me == NULL || me2 == NULL) return 0; - success = has_faces(me); - if(success==0) return -1; - success = has_faces(me2); - if(success==0) return -1; + if(!me->totface || !me2->totface) return -1; success = 0; @@ -730,8 +710,6 @@ ConvertCSGDescriptorsToMeshObject( mface->v2 = face.vertex_index[1]; mface->v3 = face.vertex_index[2]; mface->v4 = 0; - - mface->edcode = ME_V1V2|ME_V2V3|ME_V3V4|ME_V4V1; mface->mat_nr = 0; mface->flag = fdata->faceflag; diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index cc3597c2cf6..7d68f1bec8a 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -429,7 +429,6 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an /* *************************** MESH ******************************** */ - static void editing_panel_mesh_type(Object *ob, Mesh *me) { uiBlock *block; @@ -445,13 +444,6 @@ static void editing_panel_mesh_type(Object *ob, Mesh *me) uiBlockBeginAlign(block); uiBlockSetCol(block, TH_AUTO); - if(me->medge) val= 1.0; else val= 0.0; - uiDefBut(block, LABEL, 0, "Edges", 10,70,70,20, 0, val, 0, 0, 0, ""); - if(me->medge==NULL) { - uiDefBut(block, BUT, B_MAKEEDGES, "Make", 80,70,84,19, 0, 0, 0, 0, 0, "Adds edges data to active Mesh, enables creases/seams and faster wireframe draw"); - } - else uiDefBut(block, BUT, B_DELEDGES, "Delete", 80,70,84,19, 0, 0, 0, 0, 0, "Deletes edges data from active Mesh"); - if(me->mcol) val= 1.0; else val= 0.0; uiDefBut(block, LABEL, 0, "VertCol", 10,50,70,20, 0, val, 0, 0, 0, ""); if(me->mcol==NULL) { @@ -796,23 +788,6 @@ static void modifiers_setOnCage(void *ob_v, void *md_v) md->mode ^= eModifierMode_OnCage; } -static void modifiers_setSubsurfIncremental(void *ob_v, void *md_v) -{ - Object *ob = ob_v; - ModifierData *md = md_v; - SubsurfModifierData *smd = (SubsurfModifierData*) md; - - if ((smd->flags&eSubsurfModifierFlag_Incremental) && ob->type==OB_MESH) { - Mesh *me = ob->data; - - if (!me->medge) { - if (okee("Requires mesh edges, create now?")) { - make_edges(me); - } - } - } -} - static void modifiers_clearHookOffset(void *ob_v, void *md_v) { Object *ob = ob_v; @@ -1034,9 +1009,7 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco uiDefButS(block, NUM, B_MODIFIER_RECALC, "Levels:", lx, (cy-=19), buttonWidth,19, &smd->levels, 1, 6, 0, 0, "Number subdivisions to perform"); uiDefButS(block, NUM, B_MODIFIER_RECALC, "Render Levels:", lx, (cy-=19), buttonWidth,19, &smd->renderLevels, 1, 6, 0, 0, "Number subdivisions to perform when rendering"); - but = uiDefButBitS(block, TOG, eSubsurfModifierFlag_Incremental, B_MODIFIER_RECALC, "Incremental", lx, (cy-=19),90,19,&smd->flags, 0, 0, 0, 0, "Use incremental calculation, even outside of mesh mode"); - uiButSetFunc(but, modifiers_setSubsurfIncremental, ob, md); - + uiDefButBitS(block, TOG, eSubsurfModifierFlag_Incremental, B_MODIFIER_RECALC, "Incremental", lx, (cy-=19),90,19,&smd->flags, 0, 0, 0, 0, "Use incremental calculation, even outside of mesh mode"); uiDefButBitS(block, TOG, eSubsurfModifierFlag_DebugIncr, B_MODIFIER_RECALC, "Debug", lx+90, cy,buttonWidth-90,19,&smd->flags, 0, 0, 0, 0, "Visualize the subsurf incremental calculation, for debugging effect of other modifiers"); uiDefButBitS(block, TOG, eSubsurfModifierFlag_ControlEdges, B_MODIFIER_RECALC, "Optimal Draw", lx, (cy-=19), buttonWidth,19,&smd->flags, 0, 0, 0, 0, "Skip drawing/rendering of interior subdivided edges"); @@ -2419,25 +2392,6 @@ void do_meshbuts(unsigned short event) allqueue(REDRAWBUTSEDIT, 0); break; - case B_MAKEEDGES: - /* in editmode we only have to set edge pointer */ - if(ob==G.obedit) { - me->medge= MEM_callocN(sizeof(MEdge), "fake mesh edge"); - me->totedge= 1; - } - else make_edges(me); - DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); - allqueue(REDRAWBUTSEDIT, 0); - break; - case B_DELEDGES: - if(me->medge) MEM_freeN(me->medge); - me->medge= NULL; - me->totedge= 0; - DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); - allqueue(REDRAWBUTSEDIT, 0); - allqueue(REDRAWVIEW3D, 0); - break; - case B_MAKEVERTCOL: make_vertexcol(); break; diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 44dd81150a1..7b564195161 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -1448,10 +1448,6 @@ static void object_softbodies__enable(void *ob_v, void *arg2) if (!ob->soft) { ob->soft= sbNew(); ob->softflag |= OB_SB_GOAL|OB_SB_EDGES; - if(ob->type==OB_MESH) { - Mesh *me= ob->data; - if(me->medge==NULL) make_edges(me); - } } } @@ -1490,11 +1486,6 @@ static void object_softbodies(Object *ob) if(sb==NULL) { sb= ob->soft= sbNew(); ob->softflag |= OB_SB_GOAL|OB_SB_EDGES; - // default add edges for softbody - if(ob->type==OB_MESH) { - Mesh *me= ob->data; - if(me->medge==NULL) make_edges(me); - } } uiDefButBitS(block, TOG, OB_SB_BAKESET, REDRAWBUTSOBJECT, "Bake settings", 180,200,130,20, &ob->softflag, 0, 0, 0, 0, "To convert simulation into baked (cached) result"); diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c index eb264cf2e17..3fac54390b4 100644 --- a/source/blender/src/drawimage.c +++ b/source/blender/src/drawimage.c @@ -286,8 +286,7 @@ void draw_tfaces(void) mface= me->mface; a= me->totface; while(a--) { - if(tface->flag & TF_HIDE); - else if(mface->v3) { + if(!(tface->flag & TF_HIDE)) { glColor3ub(112, 112, 112); glBegin(GL_LINE_LOOP); glVertex2fv(tface->uv[0]); @@ -311,7 +310,7 @@ void draw_tfaces(void) mface= me->mface; a= me->totface; while(a--) { - if(mface->v3 && (tface->flag & TF_SELECT)) { + if(tface->flag & TF_SELECT) { if(!(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) && (!mface->v4 || tface->flag & TF_SEL4)) glColor4ubv(col2); @@ -336,7 +335,7 @@ void draw_tfaces(void) mface= me->mface; a= me->totface; while(a--) { - if(mface->v3 && (tface->flag & TF_SELECT) ) { + if(tface->flag & TF_SELECT) { if(tface->flag & TF_ACTIVE){ activetface= tface; activemface= mface; @@ -423,7 +422,7 @@ void draw_tfaces(void) mface= me->mface; a= me->totface; while(a--) { - if(mface->v3 && (tface->flag & TF_SELECT) ) { + if(tface->flag & TF_SELECT) { if(tface->flag & TF_SEL1); else bglVertex2fv(tface->uv[0]); if(tface->flag & TF_SEL2); else bglVertex2fv(tface->uv[1]); @@ -447,7 +446,7 @@ void draw_tfaces(void) mface= me->mface; a= me->totface; while(a--) { - if(mface->v3 && (tface->flag & TF_SELECT) ) { + if(tface->flag & TF_SELECT) { if(tface->unwrap & TF_PIN1) bglVertex2fv(tface->uv[0]); if(tface->unwrap & TF_PIN2) bglVertex2fv(tface->uv[1]); @@ -470,7 +469,7 @@ void draw_tfaces(void) mface= me->mface; a= me->totface; while(a--) { - if(mface->v3 && (tface->flag & TF_SELECT) ) { + if(tface->flag & TF_SELECT) { if(tface->flag & TF_SEL1) bglVertex2fv(tface->uv[0]); if(tface->flag & TF_SEL2) bglVertex2fv(tface->uv[1]); @@ -602,7 +601,7 @@ static void image_editvertex_buts(uiBlock *block) MFace *mf= &((MFace*) me->mface)[i]; TFace *tf= &((TFace*) me->tface)[i]; - if (!mf->v3 || !(tf->flag & TF_SELECT)) + if (!(tf->flag & TF_SELECT)) continue; if (tf->flag & TF_SEL1) { @@ -674,7 +673,7 @@ static void image_editvertex_buts(uiBlock *block) MFace *mf= &((MFace*) me->mface)[i]; TFace *tf= &((TFace*) me->tface)[i]; - if (!mf->v3 || !(tf->flag & TF_SELECT)) + if (!(tf->flag & TF_SELECT)) continue; if (tf->flag & TF_SEL1) { diff --git a/source/blender/src/drawmesh.c b/source/blender/src/drawmesh.c index f22379fcabe..c33588d0dff 100644 --- a/source/blender/src/drawmesh.c +++ b/source/blender/src/drawmesh.c @@ -818,7 +818,7 @@ void draw_tface_mesh(Object *ob, Mesh *me, int dt) int matnr= mf->mat_nr; int mf_smooth= mf->flag & ME_SMOOTH; - if (mf->v3 && !(tface->flag&TF_HIDE) && !(mode&TF_INVISIBLE) && (mode&TF_BMFONT)) { + if (!(tface->flag&TF_HIDE) && !(mode&TF_INVISIBLE) && (mode&TF_BMFONT)) { int badtex= set_draw_settings_cached(0, g_draw_tface_mesh_istex, tface, g_draw_tface_mesh_islight, g_draw_tface_mesh_ob, matnr, TF_TWOSIDE); float v1[3], v2[3], v3[3], v4[3]; char string[MAX_PROPSTRING]; diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 7cc1443ce44..45c165c95ff 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -1088,8 +1088,7 @@ static unsigned char *calc_weightpaint_colors(Object *ob) for (i=0; i<me->totface; i++, mf++){ calc_weightpaint_vert_color(ob, mf->v1, &wtcol[(i*4 + 0)*4]); calc_weightpaint_vert_color(ob, mf->v2, &wtcol[(i*4 + 1)*4]); - if (mf->v3) - calc_weightpaint_vert_color(ob, mf->v3, &wtcol[(i*4 + 2)*4]); + calc_weightpaint_vert_color(ob, mf->v3, &wtcol[(i*4 + 2)*4]); if (mf->v4) calc_weightpaint_vert_color(ob, mf->v4, &wtcol[(i*4 + 3)*4]); } @@ -1697,7 +1696,7 @@ static void draw_mesh_fancy(Object *ob, DerivedMesh *baseDM, DerivedMesh *dm, in if(dt==OB_BOUNDBOX) { draw_bounding_volume(ob); } - else if(hasHaloMat || (me->totface==0 && (!me->medge || me->totedge==0))) { + else if(hasHaloMat || (me->totface==0 && me->totedge==0)) { glPointSize(1.5); dm->drawVerts(dm); glPointSize(1.0); diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 3885dd5c155..7de9ed966e2 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -1190,15 +1190,13 @@ static void v3d_editvertex_buts(uiBlock *block, Object *ob, float lim) } eve= eve->next; } - if(me->medge) { - eed= em->edges.first; - while(eed) { - if((eed->f & SELECT)) { - totedge++; - median[3]+= eed->crease; - } - eed= eed->next; + eed= em->edges.first; + while(eed) { + if((eed->f & SELECT)) { + totedge++; + median[3]+= eed->crease; } + eed= eed->next; } /* check for defgroups */ if(tot==1 && evedef->totweight) { diff --git a/source/blender/src/editface.c b/source/blender/src/editface.c index e735f9c1254..0a084afe4f8 100644 --- a/source/blender/src/editface.c +++ b/source/blender/src/editface.c @@ -117,7 +117,7 @@ static void uv_calc_center_vector(float *result, Object *ob, Mesh *me) tface= me->tface; mface= me->mface; for(a=0; a<me->totface; a++, mface++, tface++) { - if(tface->flag & TF_SELECT && mface->v3) { + if(tface->flag & TF_SELECT) { DO_MINMAX((me->mvert+mface->v1)->co, min, max); DO_MINMAX((me->mvert+mface->v2)->co, min, max); DO_MINMAX((me->mvert+mface->v3)->co, min, max); @@ -311,7 +311,7 @@ void calculate_uv_map(unsigned short mapmode) tface= me->tface; mface= me->mface; for(a=0; a<me->totface; a++, mface++, tface++) { - if(tface->flag & TF_SELECT && mface->v3) { + if(tface->flag & TF_SELECT) { uv_calc_shift_project(tface->uv[0],cent,rotatematrix,3,(me->mvert+mface->v1)->co,min,max); uv_calc_shift_project(tface->uv[1],cent,rotatematrix,3,(me->mvert+mface->v2)->co,min,max); uv_calc_shift_project(tface->uv[2],cent,rotatematrix,3,(me->mvert+mface->v3)->co,min,max); @@ -327,7 +327,7 @@ void calculate_uv_map(unsigned short mapmode) tface= me->tface; mface= me->mface; for(a=0; a<me->totface; a++, mface++, tface++) { - if(tface->flag & TF_SELECT && mface->v3) { + if(tface->flag & TF_SELECT) { if(mface->v4) b= 3; else b= 2; for(; b>=0; b--) { tface->uv[b][0]= ((tface->uv[b][0]-min[0])*fac)/dx; @@ -344,7 +344,7 @@ void calculate_uv_map(unsigned short mapmode) tface= me->tface; mface= me->mface; for(a=0; a<me->totface; a++, mface++, tface++) { - if(tface->flag & TF_SELECT && mface->v3) { + if(tface->flag & TF_SELECT) { uv_calc_shift_project(tface->uv[0],cent,rotatematrix,4,(me->mvert+mface->v1)->co,NULL,NULL); uv_calc_shift_project(tface->uv[1],cent,rotatematrix,4,(me->mvert+mface->v2)->co,NULL,NULL); uv_calc_shift_project(tface->uv[2],cent,rotatematrix,4,(me->mvert+mface->v3)->co,NULL,NULL); @@ -385,7 +385,7 @@ void calculate_uv_map(unsigned short mapmode) tface= me->tface; mface= me->mface; for(a=0; a<me->totface; a++, mface++, tface++) { - if(tface->flag & TF_SELECT && mface->v3) { + if(tface->flag & TF_SELECT) { uv_calc_shift_project(tface->uv[0],cent,rotatematrix,mapmode,(me->mvert+mface->v1)->co,NULL,NULL); uv_calc_shift_project(tface->uv[1],cent,rotatematrix,mapmode,(me->mvert+mface->v2)->co,NULL,NULL); uv_calc_shift_project(tface->uv[2],cent,rotatematrix,mapmode,(me->mvert+mface->v3)->co,NULL,NULL); @@ -422,7 +422,7 @@ void calculate_uv_map(unsigned short mapmode) tface= me->tface; mface= me->mface; for(a=0; a<me->totface; a++, mface++, tface++) { - if(tface->flag & TF_SELECT && mface->v3) { + if(tface->flag & TF_SELECT) { CalcNormFloat((mv+mface->v1)->co, (mv+mface->v2)->co, (mv+mface->v3)->co, no); no[0]= fabs(no[0]); @@ -467,7 +467,7 @@ void calculate_uv_map(unsigned short mapmode) tface= me->tface; mface= me->mface; for(a=0; a<me->totface; a++, mface++, tface++) { - if(!(tface->flag & TF_SELECT && mface->v3)) continue; + if(!(tface->flag & TF_SELECT)) continue; dx= dy= 0; if(mface->v4) b= 3; else b= 2; @@ -656,10 +656,6 @@ void select_linked_tfaces(int mode) { Object *ob; Mesh *me; - TFace *tf; - MFace *mf; - int a, doit=1, mark=0; - char *cpmain, *linkflag; short mval[2]; unsigned int index=0; @@ -675,96 +671,7 @@ void select_linked_tfaces(int mode) if (!face_pick(me, mval[0], mval[1], &index)) return; } - if(me->medge) { - select_linked_tfaces_with_seams(mode, me, index); - return; - } - - cpmain= MEM_callocN(me->totvert, "cpmain"); - linkflag= MEM_callocN(sizeof(char)*me->totface, "linkflaguv"); - - if (mode==0 || mode==1) { - /* only put face under cursor in array */ - mf= ((MFace*)me->mface) + index; - cpmain[mf->v1]= cpmain[mf->v2]= cpmain[mf->v3]= 1; - if (mf->v4) cpmain[mf->v4]= 1; - linkflag[index]= 1; - } - else { - /* fill array by selection */ - tf= me->tface; - mf= me->mface; - for(a=0; a<me->totface; a++, tf++, mf++) { - if(tf->flag & TF_HIDE); - else if(tf->flag & TF_SELECT) { - if(mf->v3) { - cpmain[mf->v1]= 1; - cpmain[mf->v2]= 1; - cpmain[mf->v3]= 1; - if(mf->v4) cpmain[mf->v4]= 1; - linkflag[a]= 1; - } - } - } - } - - while(doit) { - doit= 0; - - /* expand selection */ - tf= me->tface; - mf= me->mface; - for(a=0; a<me->totface; a++, tf++, mf++) { - if(tf->flag & TF_HIDE); - else if(mf->v3 && !linkflag[a]) { - mark= 0; - - if(cpmain[mf->v1] || cpmain[mf->v2] || cpmain[mf->v3]) - mark= 1; - else if(mf->v4 && cpmain[mf->v4]) - mark= 1; - - if(mark) { - linkflag[a]= 1; - cpmain[mf->v1]= cpmain[mf->v2]= cpmain[mf->v3]= 1; - if(mf->v4) cpmain[mf->v4]= 1; - doit= 1; - } - } - } - - } - - if(mode==0 || mode==2) { - for(a=0, tf=me->tface; a<me->totface; a++, tf++) - if(linkflag[a]) - tf->flag |= TF_SELECT; - else - tf->flag &= ~TF_SELECT; - } - else if(mode==1) { - for(a=0, tf=me->tface; a<me->totface; a++, tf++) - if(linkflag[a] && (tf->flag & TF_SELECT)) - break; - - if (a<me->totface) { - for(a=0, tf=me->tface; a<me->totface; a++, tf++) - if(linkflag[a]) - tf->flag &= ~TF_SELECT; - } - else { - for(a=0, tf=me->tface; a<me->totface; a++, tf++) - if(linkflag[a]) - tf->flag |= TF_SELECT; - } - } - - MEM_freeN(cpmain); - MEM_freeN(linkflag); - - BIF_undo_push("Select linked UV face"); - - object_tface_flags_changed(OBACT, 0); + select_linked_tfaces_with_seams(mode, me, index); } void deselectall_tface() @@ -984,7 +891,7 @@ void minmax_tface(float *min, float *max) mf= me->mface; tf= me->tface; for (a=me->totface; a>0; a--, mf++, tf++) { - if (!mf->v3 || tf->flag & TF_HIDE || !(tf->flag & TF_SELECT)) + if (tf->flag & TF_HIDE || !(tf->flag & TF_SELECT)) continue; VECCOPY(vec, (mv+mf->v1)->co); diff --git a/source/blender/src/editmesh.c b/source/blender/src/editmesh.c index 4d850a6e14d..dceae0ec76a 100644 --- a/source/blender/src/editmesh.c +++ b/source/blender/src/editmesh.c @@ -60,6 +60,7 @@ #include "BLI_arithb.h" #include "BLI_editVert.h" #include "BLI_dynstr.h" +#include "BLI_rand.h" #include "BKE_DerivedMesh.h" #include "BKE_depsgraph.h" @@ -581,6 +582,22 @@ static void edge_normal_compare(EditEdge *eed, EditFace *efa1) if(inp < -0.001 ) eed->f1= 1; } +typedef struct { + EditEdge *eed; + float noLen,no[3]; + int adjCount; +} EdgeDrawFlagInfo; + +static int edgeDrawFlagInfo_cmp(const void *av, const void *bv) +{ + const EdgeDrawFlagInfo *a = av; + const EdgeDrawFlagInfo *b = bv; + + if (a->noLen<b->noLen) return -1; + else if (a->noLen>b->noLen) return 1; + else return 0; +} + static void edge_drawflags(void) { EditMesh *em = G.editMesh; @@ -653,19 +670,87 @@ static void edge_drawflags(void) } /* all faces, all edges with flag==2: compare normal */ - efa= em->faces.first; - while(efa) { - if(efa->e1->f2==2) edge_normal_compare(efa->e1, efa); - else efa->e1->f2= 1; - if(efa->e2->f2==2) edge_normal_compare(efa->e2, efa); - else efa->e2->f2= 1; - if(efa->e3->f2==2) edge_normal_compare(efa->e3, efa); - else efa->e3->f2= 1; - if(efa->e4) { - if(efa->e4->f2==2) edge_normal_compare(efa->e4, efa); - else efa->e4->f2= 1; + if (G.rt) { + float drawEdgePercent = G.rt/1000.0; + EdgeDrawFlagInfo *info = MEM_callocN(sizeof(*info)*G.totedge, "info"); + EditEdge *preveed; + int i, numDrawn, numToDraw; + + for (i=0,eed=em->edges.first; eed; i++,eed=eed->next) { + info[i].eed = eed; + eed->prev = (EditEdge*) i; + } + + for (efa=em->faces.first; efa; efa=efa->next) { + EdgeDrawFlagInfo *ei; + + ei = &info[(int) efa->e1->prev]; + VecAddf(ei->no, ei->no, efa->n); ei->adjCount++; + + ei = &info[(int) efa->e2->prev]; + VecAddf(ei->no, ei->no, efa->n); ei->adjCount++; + + ei = &info[(int) efa->e3->prev]; + VecAddf(ei->no, ei->no, efa->n); ei->adjCount++; + + if (efa->e4) { + ei = &info[(int) efa->e4->prev]; + VecAddf(ei->no, ei->no, efa->n); ei->adjCount++; + } + } + + for (i=0; i<G.totedge; i++) { + if (info[i].adjCount==0) { + info[i].noLen = -1; + } else { + info[i].noLen = VecLength(info[i].no)/info[i].adjCount + BLI_frand()*.0001; + } + } + + qsort(info, G.totedge, sizeof(*info), edgeDrawFlagInfo_cmp); + + numToDraw = drawEdgePercent*G.totedge; + if (numToDraw<1) numToDraw = 1; + + numDrawn = 0; + for (i=0; i<G.totedge; i++) { + EdgeDrawFlagInfo *ei = &info[i]; + + if (ei->eed->f2==2) { + if (G.rt==1000) { + if (ei->noLen<0.999 || numDrawn<(G.totedge*.1)) { + ei->eed->f2 = 1; + numDrawn++; + } + } else if (numDrawn<numToDraw) { + ei->eed->f2 = 1; + numDrawn++; + } + } else { + ei->eed->f2 = 1; + } + } + + for (preveed=NULL,eed=em->edges.first; eed; preveed=eed,eed=eed->next) { + eed->prev = preveed; + } + + MEM_freeN(info); + } else { + efa= em->faces.first; + while(efa) { + if(efa->e1->f2==2) edge_normal_compare(efa->e1, efa); + else efa->e1->f2= 1; + if(efa->e2->f2==2) edge_normal_compare(efa->e2, efa); + else efa->e2->f2= 1; + if(efa->e3->f2==2) edge_normal_compare(efa->e3, efa); + else efa->e3->f2= 1; + if(efa->e4) { + if(efa->e4->f2==2) edge_normal_compare(efa->e4, efa); + else efa->e4->f2= 1; + } + efa= efa->next; } - efa= efa->next; } /* sphere collision flag */ @@ -753,23 +838,19 @@ void make_editMesh() if(actkey && actkey->totelem!=me->totvert); else { unsigned int *mcol; + MEdge *medge= me->medge; /* make edges */ - if(me->medge) { - MEdge *medge= me->medge; + for(a=0; a<me->totedge; a++, medge++) { + eed= addedgelist(evlist[medge->v1], evlist[medge->v2], NULL); + eed->crease= ((float)medge->crease)/255.0; - for(a=0; a<me->totedge; a++, medge++) { - eed= addedgelist(evlist[medge->v1], evlist[medge->v2], NULL); - eed->crease= ((float)medge->crease)/255.0; - - if(medge->flag & ME_SEAM) eed->seam= 1; - if(medge->flag & SELECT) eed->f |= SELECT; - if(medge->flag & ME_FGON) eed->h= EM_FGON; // 2 different defines! - if(medge->flag & ME_HIDE) eed->h |= 1; - if(G.scene->selectmode & SCE_SELECT_EDGE) - EM_select_edge(eed, eed->f & SELECT); // force edge selection to vertices, seems to be needed ... - } - + if(medge->flag & ME_SEAM) eed->seam= 1; + if(medge->flag & SELECT) eed->f |= SELECT; + if(medge->flag & ME_FGON) eed->h= EM_FGON; // 2 different defines! + if(medge->flag & ME_HIDE) eed->h |= 1; + if(G.scene->selectmode & SCE_SELECT_EDGE) + EM_select_edge(eed, eed->f & SELECT); // force edge selection to vertices, seems to be needed ... } /* make faces */ @@ -780,7 +861,8 @@ void make_editMesh() for(a=0; a<me->totface; a++, mface++) { eve1= evlist[mface->v1]; eve2= evlist[mface->v2]; - if(mface->v3) eve3= evlist[mface->v3]; else eve3= NULL; + if(!mface->v3) error("Eeekadoodle! An MFACE-EDGE! Tell Zr!!!!"); + eve3= evlist[mface->v3]; if(mface->v4) eve4= evlist[mface->v4]; else eve4= NULL; efa= addfacelist(eve1, eve2, eve3, eve4, NULL, NULL); @@ -800,7 +882,6 @@ void make_editMesh() /* select face flag, if no edges we flush down */ if(mface->flag & ME_FACE_SEL) { efa->f |= SELECT; - if(me->medge==NULL) EM_select_face(efa, 1); } if(mface->flag & ME_HIDE) efa->h= 1; } @@ -818,14 +899,6 @@ void make_editMesh() } } - /* flush hide flags when no medge */ - if(me->medge==NULL) { - for(eed= em->edges.first; eed; eed= eed->next) { - if(eed->v1->h || eed->v2->h) eed->h |= 1; - else eed->h &= ~1; - } - } - MEM_freeN(evlist); end_editmesh_fastmalloc(); // resets global function pointers @@ -848,7 +921,7 @@ void load_editMesh(void) EditMesh *em = G.editMesh; Mesh *me= G.obedit->data; MVert *mvert, *oldverts; - MEdge *medge=NULL; + MEdge *medge; MFace *mface; MSticky *ms; EditVert *eve; @@ -871,7 +944,6 @@ void load_editMesh(void) eed= em->edges.first; while(eed) { totedge++; - if(me->medge==NULL && (eed->f2==0)) G.totface++; eed= eed->next; } @@ -880,7 +952,7 @@ void load_editMesh(void) else mvert= MEM_callocN(G.totvert*sizeof(MVert), "loadeditMesh vert"); /* new Edge block */ - if(me->medge==NULL) totedge= 0; // if edges get added is defined by orig mesh + if(totedge==0) medge= NULL; else medge= MEM_callocN(totedge*sizeof(MEdge), "loadeditMesh edge"); /* new Face block */ @@ -906,7 +978,7 @@ void load_editMesh(void) if(me->medge) MEM_freeN(me->medge); me->medge= medge; - if(medge) me->totedge= totedge; else me->totedge= 0; + me->totedge= totedge; if(me->mface) MEM_freeN(me->mface); me->mface= mface; @@ -949,24 +1021,22 @@ void load_editMesh(void) } /* the edges */ - if(medge) { - eed= em->edges.first; - while(eed) { - medge->v1= (unsigned int) eed->v1->vn; - medge->v2= (unsigned int) eed->v2->vn; - - 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; - - medge->crease= (char)(255.0*eed->crease); + eed= em->edges.first; + while(eed) { + medge->v1= (unsigned int) eed->v1->vn; + medge->v2= (unsigned int) eed->v2->vn; + + 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; + + medge->crease= (char)(255.0*eed->crease); - medge++; - eed= eed->next; - } + medge++; + eed= eed->next; } /* the faces */ @@ -1005,24 +1075,15 @@ void load_editMesh(void) /* watch: efa->e1->f2==0 means loose edge */ if(efa->e1->f2==1) { - mface->edcode |= ME_V1V2; efa->e1->f2= 2; } if(efa->e2->f2==1) { - mface->edcode |= ME_V2V3; efa->e2->f2= 2; } if(efa->e3->f2==1) { - if(efa->v4) { - mface->edcode |= ME_V3V4; - } - else { - mface->edcode |= ME_V3V1; - } efa->e3->f2= 2; } if(efa->e4 && efa->e4->f2==1) { - mface->edcode |= ME_V4V1; efa->e4->f2= 2; } @@ -1033,22 +1094,6 @@ void load_editMesh(void) i++; efa= efa->next; } - - /* add loose edges as a face */ - if(medge==NULL) { - eed= em->edges.first; - while(eed) { - if( eed->f2==0 ) { - mface= &((MFace *) me->mface)[i]; - mface->v1= (unsigned int) eed->v1->vn; - mface->v2= (unsigned int) eed->v2->vn; - test_index_face(mface, NULL, NULL, 2); - mface->edcode= ME_V1V2; - i++; - } - eed= eed->next; - } - } /* tface block */ if( me->tface && me->totface ) { diff --git a/source/blender/src/editmesh_add.c b/source/blender/src/editmesh_add.c index cd94b12feec..d028abf6931 100644 --- a/source/blender/src/editmesh_add.c +++ b/source/blender/src/editmesh_add.c @@ -264,9 +264,6 @@ static void make_fgon(void) } else { Mesh *me= G.obedit->data; - // signal to save edges with ngon flags - if(!me->medge) - me->medge= MEM_callocN(sizeof(MEdge), "fake mesh edge"); EM_fgon_flags(); // redo flags and indices for fgons diff --git a/source/blender/src/editmesh_lib.c b/source/blender/src/editmesh_lib.c index 94be79e2967..dc9e7455112 100644 --- a/source/blender/src/editmesh_lib.c +++ b/source/blender/src/editmesh_lib.c @@ -137,31 +137,23 @@ void EM_select_face_fgon(EditFace *efa, int val) /* only vertices */ int faceselectedOR(EditFace *efa, int flag) { - - if(efa->v1->f & flag) return 1; - if(efa->v2->f & flag) return 1; - if(efa->v3->f & flag) return 1; - if(efa->v4 && (efa->v4->f & 1)) return 1; - return 0; + if ((efa->v1->f | efa->v2->f | efa->v3->f | (efa->v4?efa->v4->f:0))&flag) { + return 1; + } else { + return 0; + } } // replace with (efa->f & SELECT) int faceselectedAND(EditFace *efa, int flag) { - if(efa->v1->f & flag) { - if(efa->v2->f & flag) { - if(efa->v3->f & flag) { - if(efa->v4) { - if(efa->v4->f & flag) return 1; - } - else return 1; - } - } + if ((efa->v1->f & efa->v2->f & efa->v3->f & (efa->v4?efa->v4->f:flag))&flag) { + return 1; + } else { + return 0; } - return 0; } - int EM_nfaces_selected(void) { EditMesh *em = G.editMesh; diff --git a/source/blender/src/editmesh_mods.c b/source/blender/src/editmesh_mods.c index fb3d8942ee9..c719f1bcd83 100644 --- a/source/blender/src/editmesh_mods.c +++ b/source/blender/src/editmesh_mods.c @@ -1797,8 +1797,6 @@ void editmesh_mark_seam(int clear) G.f |= G_DRAWSEAMS; allqueue(REDRAWBUTSEDIT, 0); } - if(!me->medge) - me->medge= MEM_callocN(sizeof(MEdge), "fake mesh edge"); } if(clear) { @@ -2107,13 +2105,9 @@ static int faceselect_nfaces_selected(Mesh *me) { int i, count= 0; - for (i=0; i<me->totface; i++) { - MFace *mf= ((MFace*) me->mface) + i; - TFace *tf= ((TFace*) me->tface) + i; - - if (mf->v3 && tface_is_selected(tf)) + for (i=0; i<me->totface; i++) + if (tface_is_selected(&me->tface[i])) count++; - } return count; } @@ -2136,7 +2130,7 @@ void faceselect_align_view_to_selected(View3D *v3d, Mesh *me, int axis) MFace *mf= ((MFace*) me->mface) + i; TFace *tf= ((TFace*) me->tface) + i; - if (mf->v3 && tface_is_selected(tf)) { + if (tface_is_selected(tf)) { float *v1, *v2, *v3, fno[3]; v1= me->mvert[mf->v1].co; diff --git a/source/blender/src/editmesh_tools.c b/source/blender/src/editmesh_tools.c index 6aacb034b12..19ae029f30a 100644 --- a/source/blender/src/editmesh_tools.c +++ b/source/blender/src/editmesh_tools.c @@ -2115,7 +2115,7 @@ static EditVert *subdivideedgenum(EditEdge *edge,int curpoint,int totpoint,float alter_co(co,edge,rad,beauty,curpoint/(float)(totpoint+1)); ev = addvertlist(co); ev->f = edge->v1->f; - + return ev; } diff --git a/source/blender/src/editsima.c b/source/blender/src/editsima.c index c3a5ed0b5ad..4c241290d78 100644 --- a/source/blender/src/editsima.c +++ b/source/blender/src/editsima.c @@ -175,7 +175,7 @@ void clever_numbuts_sima(void) MFace *mf= &((MFace*) me->mface)[i]; TFace *tf= &((TFace*) me->tface)[i]; - if (!mf->v3 || !(tf->flag & TF_SELECT)) + if (!(tf->flag & TF_SELECT)) continue; if (tf->flag & TF_SEL1) { @@ -219,7 +219,7 @@ void clever_numbuts_sima(void) MFace *mf= &((MFace*) me->mface)[i]; TFace *tf= &((TFace*) me->tface)[i]; - if (!mf->v3 || !(tf->flag & TF_SELECT)) + if (!(tf->flag & TF_SELECT)) continue; if (tf->flag & TF_SEL1) { @@ -404,7 +404,7 @@ void transform_tface_uv(int mode, int context) // 2 args, for callback tface= me->tface; mface= me->mface; for(a=me->totface; a>0; a--, tface++, mface++) { - if(mface->v3 && tface->flag & TF_SELECT) { + if(tface->flag & TF_SELECT) { if(tface->flag & TF_SEL1) tot++; if(tface->flag & TF_SEL2) tot++; if(tface->flag & TF_SEL3) tot++; @@ -426,7 +426,7 @@ void transform_tface_uv(int mode, int context) // 2 args, for callback tface= me->tface; mface= me->mface; for(a=me->totface; a>0; a--, tface++, mface++) { - if(mface->v3 && tface->flag & TF_SELECT) { + if(tface->flag & TF_SELECT) { if (tface->flag & TF_SEL1 || propmode) { tv->loc= tface->uv[0]; if(tface->flag & TF_SEL1) tv->flag= 1; @@ -968,7 +968,7 @@ void select_swap_tface_uv(void) if(sel) tface->flag &= ~(TF_SEL1+TF_SEL2+TF_SEL3+TF_SEL4); else tface->flag |= (TF_SEL1+TF_SEL2+TF_SEL3+TF_SEL4); } - else if(mface->v3) { + else { if(sel) tface->flag &= ~(TF_SEL1+TF_SEL2+TF_SEL3+TF_SEL4); else tface->flag |= (TF_SEL1+TF_SEL2+TF_SEL3); } @@ -1015,7 +1015,7 @@ static void find_nearest_tface(TFace **nearesttf, MFace **nearestmf) tf= (TFace*)me->tface; for(a=me->totface; a>0; a--, tf++, mf++) { - if(tf->flag & TF_SELECT && mf->v3) { + if(tf->flag & TF_SELECT) { fcenter[0]= fcenter[1]= 0; nverts= mf->v4? 4: 3; @@ -1083,7 +1083,7 @@ static void find_nearest_uv(TFace **nearesttf, unsigned int *nearestv, int *near tf= (TFace*)me->tface; for(a=me->totface; a>0; a--, tf++, mf++) { - if(tf->flag & TF_SELECT && mf->v3) { + if(tf->flag & TF_SELECT) { nverts= mf->v4? 4: 3; for(i=0; i<nverts; i++) { @@ -1190,7 +1190,7 @@ void mouse_select_sima(void) /* deselect */ if(selectsticky==0) { for(a=me->totface; a>0; a--, tf++, mf++) { - if(!(tf->flag & TF_SELECT && mf->v3)) continue; + if(!(tf->flag & TF_SELECT)) continue; if(nearesttf && tf!=nearesttf) tf->flag &=~ TF_ACTIVE; if (!sticky) continue; @@ -1208,7 +1208,7 @@ void mouse_select_sima(void) /* select */ else { for(a=me->totface; a>0; a--, tf++, mf++) { - if(!(tf->flag & TF_SELECT && mf->v3)) continue; + if(!(tf->flag & TF_SELECT)) continue; if(nearesttf && tf!=nearesttf) tf->flag &=~ TF_ACTIVE; if (!sticky) continue; @@ -1244,7 +1244,7 @@ void mouse_select_sima(void) mf= (MFace*)me->mface; tf= (TFace*)me->tface; for(a=me->totface; a>0; a--, tf++, mf++) { - if(tf->flag & TF_SELECT && mf->v3) { + if(tf->flag & TF_SELECT) { if(!actface) tf->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4); if(!sticky) continue; @@ -1472,7 +1472,7 @@ void hide_tface_uv(int swap) if(swap) { mface= me->mface; for(a=me->totface, tface= me->tface; a>0; a--, tface++, mface++) { - if(mface->v3 && tface->flag & TF_SELECT) { + if(tface->flag & TF_SELECT) { if((tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3))==0) { if(!mface->v4) tface->flag &= ~TF_SELECT; @@ -1484,7 +1484,7 @@ void hide_tface_uv(int swap) } else { mface= me->mface; for(a=me->totface, tface= me->tface; a>0; a--, tface++, mface++) { - if(mface->v3 && tface->flag & TF_SELECT) { + if(tface->flag & TF_SELECT) { if(tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) tface->flag &= ~TF_SELECT; else if(mface->v4 && tface->flag & TF_SEL4) @@ -1510,7 +1510,7 @@ void reveal_tface_uv(void) mface= me->mface; for(a=me->totface, tface= me->tface; a>0; a--, tface++, mface++) - if(mface->v3 && !(tface->flag & TF_HIDE)) + if(!(tface->flag & TF_HIDE)) if(!(tface->flag & TF_SELECT)) tface->flag |= (TF_SELECT|TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4); @@ -1552,7 +1552,7 @@ void stitch_uv_tface(int mode) mf= (MFace*)me->mface; tf= (TFace*)me->tface; for(a=me->totface; a>0; a--, tf++, mf++) { - if((tf->flag & TF_SELECT) && mf->v3) { + if((tf->flag & TF_SELECT)) { if(tf->flag & TF_SEL1) tot++; if(tf->flag & TF_SEL2) tot++; if(tf->flag & TF_SEL3) tot++; @@ -1566,7 +1566,7 @@ void stitch_uv_tface(int mode) mf= (MFace*)me->mface; tf= (TFace*)me->tface; for(a=0; a<me->totface; a++, tf++, mf++) { - if((tf->flag & TF_SELECT) && mf->v3) { + if((tf->flag & TF_SELECT)) { if(tf->flag & TF_SEL1) { sb->v= mf->v1; sb->f= a; @@ -1681,7 +1681,7 @@ void select_linked_tface_uv(int mode) mf= (MFace*)me->mface; tf= (TFace*)me->tface; for(a=me->totface; a>0; a--, tf++, mf++) - if((tf->flag & TF_SELECT) && mf->v3) + if(tf->flag & TF_SELECT) tot += mf->v4? 4: 3; if(tot==0) return; @@ -1703,7 +1703,7 @@ void select_linked_tface_uv(int mode) mf= (MFace*)me->mface; tf= (TFace*)me->tface; for(a=0; a<me->totface; a++, tf++, mf++) { - if(!(tf->flag & TF_HIDE) && (tf->flag & TF_SELECT) && mf->v3) { + if(!(tf->flag & TF_HIDE) && (tf->flag & TF_SELECT)) { sel= 0; sb1= sb; nverts= mf->v4? 4: 3; @@ -1807,7 +1807,7 @@ void unlink_selection(void) mface= me->mface; for(a=me->totface, tface= me->tface; a>0; a--, tface++, mface++) { - if(mface->v3 && tface->flag & TF_SELECT) { + if(tface->flag & TF_SELECT) { if(mface->v4) { if(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4)) tface->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4); @@ -1857,7 +1857,7 @@ void pin_tface_uv(int mode) mface= me->mface; tface= me->tface; for(a=me->totface; a>0; a--, tface++, mface++) { - if(mface->v3 && tface->flag & TF_SELECT) { + if(tface->flag & TF_SELECT) { if(mode ==1){ if(tface->flag & TF_SEL1) tface->unwrap |= TF_PIN1; if(tface->flag & TF_SEL2) tface->unwrap |= TF_PIN2; @@ -1896,7 +1896,7 @@ int minmax_tface_uv(float *min, float *max) tf= (TFace*)me->tface; for(a=me->totface; a>0; a--, tf++, mf++) { if(tf->flag & TF_HIDE); - else if(mf->v3 && (tf->flag & TF_SELECT)) { + else if(tf->flag & TF_SELECT) { if (tf->flag & TF_SEL1) { DO_MINMAX2(tf->uv[0], min, max); diff --git a/source/blender/src/meshtools.c b/source/blender/src/meshtools.c index 24badcd1211..d4e4ffbbadd 100644 --- a/source/blender/src/meshtools.c +++ b/source/blender/src/meshtools.c @@ -126,7 +126,6 @@ void join_mesh(void) unsigned int *mcol=NULL, *mcolmain; float imat[4][4], cmat[4][4]; int a, b, totcol, totedge=0, totvert=0, totface=0, ok=0, vertofs, map[MAXMAT]; - int hasedges=0; int i, j, index, haskey=0, hasdefgroup=0; bDeformGroup *dg, *odg; MDeformVert *dvert, *dvertmain; @@ -144,7 +143,6 @@ void join_mesh(void) me= base->object->data; totvert+= me->totvert; totface+= me->totface; - if(me->medge) hasedges= 1; if(base->object == ob) ok= 1; @@ -170,14 +168,11 @@ void join_mesh(void) /* if needed add edges to other meshes */ - if(hasedges) { - for(base= FIRSTBASE; base; base= base->next) { - if TESTBASELIB(base) { - if(base->object->type==OB_MESH) { - me= base->object->data; - if(me->medge==NULL) make_edges(me); - totedge += me->totedge; - } + for(base= FIRSTBASE; base; base= base->next) { + if TESTBASELIB(base) { + if(base->object->type==OB_MESH) { + me= base->object->data; + totedge += me->totedge; } } } @@ -341,7 +336,7 @@ void join_mesh(void) while(a--) { mface->v1+= vertofs; mface->v2+= vertofs; - if(mface->v3) mface->v3+= vertofs; + mface->v3+= vertofs; if(mface->v4) mface->v4+= vertofs; mface->mat_nr= map[(int)mface->mat_nr]; @@ -470,6 +465,8 @@ void fasterdraw(void) mface= me->mface; toggle= 0; for(a=0; a<me->totface; a++) { + /* XXX, rewrite to work with MEdge */ +/* if( (mface->edcode & ME_V1V2) && ( (toggle++) & 1) ) { mface->edcode-= ME_V1V2; } @@ -485,6 +482,7 @@ void fasterdraw(void) if( (mface->edcode & ME_V3V4) && ( (toggle++) & 1)) { mface->edcode-= ME_V3V4; } +*/ mface++; } } @@ -516,13 +514,8 @@ void slowerdraw(void) /* reset fasterdraw */ if( TESTBASELIB(base) && (base->object->type==OB_MESH)) { me= base->object->data; if(me->id.lib==0) { - - mface= me->mface; - - for(a=0; a<me->totface; a++) { - - mface->edcode |= ME_V1V2|ME_V2V3; - mface++; + for(a=0; a<me->totedge; a++) { + me->medge[a].flag |= ME_EDGEDRAW; } } } diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c index eda6c03554e..6c623a23d82 100755 --- a/source/blender/src/transform_conversions.c +++ b/source/blender/src/transform_conversions.c @@ -316,14 +316,6 @@ static void createTransEdge(TransInfo *t) { int count=0, countsel=0; int propmode = t->flag & T_PROP_EDIT; - /* THIS IS A REALLY STUPID HACK, MUST BE A BETTER WAY TO DO IT */ - /* 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); - } - for(eed= em->edges.first; eed; eed= eed->next) { if(eed->h==0) { if (eed->f & SELECT) countsel++; diff --git a/source/blender/src/unwrapper.c b/source/blender/src/unwrapper.c index 5b044ec6f00..950042a201f 100644 --- a/source/blender/src/unwrapper.c +++ b/source/blender/src/unwrapper.c @@ -50,6 +50,7 @@ #include "BLI_arithb.h" +#include "BIF_editsima.h" #include "BIF_space.h" #include "blendef.h" @@ -175,9 +176,6 @@ static HashEdge *make_hash_edge_table(Mesh *me, short fill) MEdge *medge; unsigned int a; - if(fill && (me->medge==NULL)) - return NULL; - htable= MEM_callocN(EDHASHSIZE*sizeof(HashEdge), "lscmedgehashtable"); if(fill) { @@ -264,7 +262,7 @@ static int make_seam_groups(Mesh *me, int **seamgroups) a= b; while(a--) { if(tf->flag & TF_HIDE); - else if(tf->flag & TF_SELECT && *gf==gid && mf->v3) { + else if(tf->flag & TF_SELECT && *gf==gid) { hash_add_face(htable, mf); } tf++; mf++; gf++; @@ -278,7 +276,7 @@ static int make_seam_groups(Mesh *me, int **seamgroups) a= b; while(a--) { if(tf->flag & TF_HIDE); - else if(tf->flag & TF_SELECT && mf->v3 && *gf==0) { + else if(tf->flag & TF_SELECT && *gf==0) { mark= 0; if(!(tf->unwrap & TF_SEAM1)) @@ -1294,7 +1292,6 @@ void set_seamtface() mf= me->mface; tf= me->tface; for(a=me->totface; a>0; a--, mf++, tf++) { - if(mf->v3==0) continue; tf->unwrap &= ~(TF_SEAM1|TF_SEAM2|TF_SEAM3|TF_SEAM4); if(!htable) continue; @@ -1350,7 +1347,7 @@ void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index) mf= me->mface; for(a=0; a<me->totface; a++, tf++, mf++) { if(tf->flag & TF_HIDE); - else if(mf->v3 && !linkflag[a]) { + else if(!linkflag[a]) { mark= 0; if(!(tf->unwrap & TF_SEAM1)) @@ -1409,7 +1406,6 @@ void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index) MEM_freeN(linkflag); BIF_undo_push("Select linked UV face"); - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWIMAGE, 0); + object_tface_flags_changed(OBACT, 0); } diff --git a/source/blender/src/vpaint.c b/source/blender/src/vpaint.c index 044373d10f7..ea20b1f9956 100644 --- a/source/blender/src/vpaint.c +++ b/source/blender/src/vpaint.c @@ -159,19 +159,16 @@ void do_shared_vertexcol(Mesh *me) mface= me->mface; mcol= (char *)me->mcol; for(a=me->totface; a>0; a--, mface++, mcol+=16) { - if(mface->v3) { - if(tface==0 || (tface->mode & TF_SHAREDCOL) || (G.f & G_FACESELECT)==0) { - - scol= scolmain+4*mface->v1; - scol[0]++; scol[1]+= mcol[1]; scol[2]+= mcol[2]; scol[3]+= mcol[3]; - scol= scolmain+4*mface->v2; - scol[0]++; scol[1]+= mcol[5]; scol[2]+= mcol[6]; scol[3]+= mcol[7]; - scol= scolmain+4*mface->v3; - scol[0]++; scol[1]+= mcol[9]; scol[2]+= mcol[10]; scol[3]+= mcol[11]; - if(mface->v4) { - scol= scolmain+4*mface->v4; - scol[0]++; scol[1]+= mcol[13]; scol[2]+= mcol[14]; scol[3]+= mcol[15]; - } + if(tface==0 || (tface->mode & TF_SHAREDCOL) || (G.f & G_FACESELECT)==0) { + scol= scolmain+4*mface->v1; + scol[0]++; scol[1]+= mcol[1]; scol[2]+= mcol[2]; scol[3]+= mcol[3]; + scol= scolmain+4*mface->v2; + scol[0]++; scol[1]+= mcol[5]; scol[2]+= mcol[6]; scol[3]+= mcol[7]; + scol= scolmain+4*mface->v3; + scol[0]++; scol[1]+= mcol[9]; scol[2]+= mcol[10]; scol[3]+= mcol[11]; + if(mface->v4) { + scol= scolmain+4*mface->v4; + scol[0]++; scol[1]+= mcol[13]; scol[2]+= mcol[14]; scol[3]+= mcol[15]; } } if(tface) tface++; @@ -192,22 +189,16 @@ void do_shared_vertexcol(Mesh *me) mface= me->mface; mcol= (char *)me->mcol; for(a=me->totface; a>0; a--, mface++, mcol+=16) { - if(mface->v3) { - if(tface==0 || (tface->mode & TF_SHAREDCOL) || (G.f & G_FACESELECT)==0) { - - scol= scolmain+4*mface->v1; - mcol[1]= scol[1]; mcol[2]= scol[2]; mcol[3]= scol[3]; - - scol= scolmain+4*mface->v2; - mcol[5]= scol[1]; mcol[6]= scol[2]; mcol[7]= scol[3]; - - scol= scolmain+4*mface->v3; - mcol[9]= scol[1]; mcol[10]= scol[2]; mcol[11]= scol[3]; - - if(mface->v4) { - scol= scolmain+4*mface->v4; - mcol[13]= scol[1]; mcol[14]= scol[2]; mcol[15]= scol[3]; - } + if(tface==0 || (tface->mode & TF_SHAREDCOL) || (G.f & G_FACESELECT)==0) { + scol= scolmain+4*mface->v1; + mcol[1]= scol[1]; mcol[2]= scol[2]; mcol[3]= scol[3]; + scol= scolmain+4*mface->v2; + mcol[5]= scol[1]; mcol[6]= scol[2]; mcol[7]= scol[3]; + scol= scolmain+4*mface->v3; + mcol[9]= scol[1]; mcol[10]= scol[2]; mcol[11]= scol[3]; + if(mface->v4) { + scol= scolmain+4*mface->v4; + mcol[13]= scol[1]; mcol[14]= scol[2]; mcol[15]= scol[3]; } } if(tface) tface++; |