[Bf-committers] Blender -- per face based beveling.
Kenney Phillis Jr
dandel at gmail.com
Sun Nov 20 19:16:46 CET 2005
i know this has bugs with various things, but to bevel a single edge you
need to select 2 faces that are on the edge you want to modify... and
also it will generate 1 or 2 mesh holes due to the improper calculations
i know it does with the modifying of vertexies.
-------------- next part --------------
Index: blender/source/blender/src/editmesh_tools.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/editmesh_tools.c,v
retrieving revision 1.130
diff -u -r1.130 editmesh_tools.c
--- blender/source/blender/src/editmesh_tools.c 3 Nov 2005 15:57:31 -0000 1.130
+++ blender/source/blender/src/editmesh_tools.c 20 Nov 2005 07:53:30 -0000
@@ -127,7 +127,7 @@
static int vergface(const void *v1, const void *v2)
{
const struct facesort *x1=v1, *x2=v2;
-
+
if( x1->x > x2->x ) return 1;
else if( x1->x < x2->x) return -1;
return 0;
@@ -3606,7 +3606,7 @@
for(srchedge=em->edges.first;srchedge;srchedge = srchedge->next) {
srchedge->f1 = -1;
}
-
+
/*for(efa = em->faces.first;efa;efa = efa->next) {
if(efa->h == 0) {
efa->e1->f1 = 1;
@@ -3692,7 +3692,7 @@
}
}
else error("Select one edge or two adjacent faces");
-
+
/* flush selected vertices (again) to edges/faces */
EM_select_flush();
@@ -3890,14 +3890,14 @@
while (efa) {
if (efa->f1 & flag) {
VECCOPY(v1, efa->v1->co);
- VECCOPY(v2, efa->v2->co);
- VECCOPY(v3, efa->v3->co);
+ VECCOPY(v2, efa->v2->co);
+ VECCOPY(v3, efa->v3->co);
VECCOPY(no, efa->n);
if (efa->v4 == NULL) {
bevel_displace_vec(vec, v1, v2, v3, d, no);
VECCOPY(efa->v2->co, vec);
bevel_displace_vec(vec, v2, v3, v1, d, no);
- VECCOPY(efa->v3->co, vec);
+ VECCOPY(efa->v3->co, vec);
bevel_displace_vec(vec, v3, v1, v2, d, no);
VECCOPY(efa->v1->co, vec);
@@ -3907,7 +3907,7 @@
bevel_displace_vec(vec, v1, v2, v3, d, no);
VECCOPY(efa->v2->co, vec);
bevel_displace_vec(vec, v2, v3, v4, d, no);
- VECCOPY(efa->v3->co, vec);
+ VECCOPY(efa->v3->co, vec);
bevel_displace_vec(vec, v3, v4, v1, d, no);
VECCOPY(efa->v4->co, vec);
bevel_displace_vec(vec, v4, v1, v2, d, no);
@@ -3929,64 +3929,67 @@
/* move edges of all faces with efa->f1 & flag closer towards their centres */
efa= em->faces.first;
while (efa) {
- VECCOPY(v1, efa->v1->co);
- VECCOPY(v2, efa->v2->co);
- VECCOPY(v3, efa->v3->co);
- VECCOPY(no, efa->n);
- if (efa->v4 == NULL) {
- bevel_displace_vec(vec, v1, v2, v3, d, no);
- VECCOPY(fv2, vec);
- bevel_displace_vec(vec, v2, v3, v1, d, no);
- VECCOPY(fv3, vec);
- bevel_displace_vec(vec, v3, v1, v2, d, no);
- VECCOPY(fv1, vec);
-
- fix_bevel_tri_wrap(v1, v2, v3, fv1, fv2, fv3, no);
-
- glBegin(GL_LINES);
- glVertex3fv(fv1);
- glVertex3fv(fv2);
- glEnd();
- glBegin(GL_LINES);
- glVertex3fv(fv2);
- glVertex3fv(fv3);
- glEnd();
- glBegin(GL_LINES);
- glVertex3fv(fv1);
- glVertex3fv(fv3);
- glEnd();
- } else {
- VECCOPY(v4, efa->v4->co);
- bevel_displace_vec(vec, v4, v1, v2, d, no);
- VECCOPY(fv1, vec);
- bevel_displace_vec(vec, v1, v2, v3, d, no);
- VECCOPY(fv2, vec);
- bevel_displace_vec(vec, v2, v3, v4, d, no);
- VECCOPY(fv3, vec);
- bevel_displace_vec(vec, v3, v4, v1, d, no);
- VECCOPY(fv4, vec);
-
- fix_bevel_quad_wrap(v1, v2, v3, v4, fv1, fv2, fv3, fv4, d, no);
-
- glBegin(GL_LINES);
- glVertex3fv(fv1);
- glVertex3fv(fv2);
- glEnd();
- glBegin(GL_LINES);
- glVertex3fv(fv2);
- glVertex3fv(fv3);
- glEnd();
- glBegin(GL_LINES);
- glVertex3fv(fv3);
- glVertex3fv(fv4);
- glEnd();
- glBegin(GL_LINES);
- glVertex3fv(fv1);
- glVertex3fv(fv4);
- glEnd();
+ if (efa->f1 & 1 || flag)
+ {
+ VECCOPY(v1, efa->v1->co);
+ VECCOPY(v2, efa->v2->co);
+ VECCOPY(v3, efa->v3->co);
+ VECCOPY(no, efa->n);
+ if (efa->v4 == NULL) {
+ bevel_displace_vec(vec, v1, v2, v3, d, no);
+ VECCOPY(fv2, vec);
+ bevel_displace_vec(vec, v2, v3, v1, d, no);
+ VECCOPY(fv3, vec);
+ bevel_displace_vec(vec, v3, v1, v2, d, no);
+ VECCOPY(fv1, vec);
+
+ fix_bevel_tri_wrap(v1, v2, v3, fv1, fv2, fv3, no);
+
+ glBegin(GL_LINES);
+ glVertex3fv(fv1);
+ glVertex3fv(fv2);
+ glEnd();
+ glBegin(GL_LINES);
+ glVertex3fv(fv2);
+ glVertex3fv(fv3);
+ glEnd();
+ glBegin(GL_LINES);
+ glVertex3fv(fv1);
+ glVertex3fv(fv3);
+ glEnd();
+ } else {
+ VECCOPY(v4, efa->v4->co);
+ bevel_displace_vec(vec, v4, v1, v2, d, no);
+ VECCOPY(fv1, vec);
+ bevel_displace_vec(vec, v1, v2, v3, d, no);
+ VECCOPY(fv2, vec);
+ bevel_displace_vec(vec, v2, v3, v4, d, no);
+ VECCOPY(fv3, vec);
+ bevel_displace_vec(vec, v3, v4, v1, d, no);
+ VECCOPY(fv4, vec);
+
+ fix_bevel_quad_wrap(v1, v2, v3, v4, fv1, fv2, fv3, fv4, d, no);
+
+ glBegin(GL_LINES);
+ glVertex3fv(fv1);
+ glVertex3fv(fv2);
+ glEnd();
+ glBegin(GL_LINES);
+ glVertex3fv(fv2);
+ glVertex3fv(fv3);
+ glEnd();
+ glBegin(GL_LINES);
+ glVertex3fv(fv3);
+ glVertex3fv(fv4);
+ glEnd();
+ glBegin(GL_LINES);
+ glVertex3fv(fv1);
+ glVertex3fv(fv4);
+ glEnd();
+ }
}
efa= efa->next;
- }
+ }
}
static void bevel_mesh(float bsize, int allfaces)
@@ -4009,30 +4012,28 @@
waitcursor(1);
removedoublesflag(1, limit);
-
/* tag all original faces */
efa= em->faces.first;
while (efa) {
- efa->f1= 0;
- if (faceselectedAND(efa, 1)||allfaces) {
+ if (efa->f1 & 1 || allfaces & 1)
+ {
efa->f1= 1;
- efa->v1->f |= 128;
- efa->v2->f |= 128;
- efa->v3->f |= 128;
- if (efa->v4) efa->v4->f |= 128;
- }
- efa->v1->f &= ~64;
- efa->v2->f &= ~64;
- efa->v3->f &= ~64;
- if (efa->v4) efa->v4->f &= ~64;
-
+ if (faceselectedAND(efa, 1) || allfaces & 1 ) {
+ efa->v1->f |= 128;
+ efa->v2->f |= 128;
+ efa->v3->f |= 128;
+ if (efa->v4) efa->v4->f |= 128;
+ }
+ efa->v1->f &= ~64;
+ efa->v2->f &= ~64;
+ efa->v3->f &= ~64;
+ if (efa->v4) efa->v4->f &= ~64;
+ }
efa= efa->next;
- }
-
+ }
#ifdef BEV_DEBUG
fprintf(stderr,"bevel_mesh: split\n");
#endif
-
efa= em->faces.first;
while (efa) {
if (efa->f1 & 1) {
@@ -4112,19 +4113,20 @@
efa= efa->next;
}
}
-
for(efa= em->faces.first; efa; efa= efa->next) {
if( (efa->v1->f & 128) && (efa->v2->f & 128) && (efa->v3->f & 128) ) {
if(efa->v4==NULL || (efa->v4->f & 128)) efa->f |= 128;
+
}
}
delfaceflag(128); // works with face flag now
/* tag all faces for shrink*/
+
efa= em->faces.first;
while (efa) {
- if (faceselectedAND(efa, 1)||allfaces) {
+ if (faceselectedAND(efa, 1)||allfaces & 1) {
efa->f1= 2;
}
efa= efa->next;
@@ -4135,15 +4137,13 @@
#endif
/* find edges that are on each other and make quads between them */
-
eed= em->edges.first;
while(eed) {
eed->f2= eed->f1= 0;
- if ( ((eed->v1->f & eed->v2->f) & 1) || allfaces) eed->f1 |= 4; /* original edges */
+ if ( ((eed->v1->f & eed->v2->f) & 1) || allfaces & 1) eed->f1 |= 4; /* original edges */
eed->vn= 0;
eed= eed->next;
- }
-
+ }
eed= em->edges.first;
while (eed) {
if ( ((eed->f1 & 2)==0) && (eed->f1 & 4) ) {
@@ -4211,13 +4211,12 @@
}
eed= eed->next;
}
-
eed= em->edges.first;
while(eed) {
eed->f2= eed->f1= 0;
eed->f1= 0;
eed->v1->f1 &= ~1;
- eed->v2->f1 &= ~1;
+ eed->v2->f1 &= ~1;
eed->vn= 0;
eed= eed->next;
}
@@ -4412,7 +4411,7 @@
char Finished = 0, Canceled = 0, str[100], Recalc = 0;
short mval[2], oval[2], curval[2], event = 0, recurs = 1, nr;
float vec[3], d, drawd=0.0, centre[3], fac = 1;
-
+ int BevelMode = (int*) pupmenu("Bevel %t|whole object%x1|selected Faces%x0");
getmouseco_areawin(mval);
oval[0] = mval[0]; oval[1] = mval[1];
@@ -4464,7 +4463,7 @@
glColor3ub(255, 255, 0);
// PREVIEW CODE GOES HERE
- bevel_shrink_draw(drawd, 2);
+ bevel_shrink_draw(drawd, BevelMode);
/* restore matrix transform */
glPopMatrix();
@@ -4517,7 +4516,7 @@
}
if (Canceled==0) {
SetBlenderCursor(BC_WAITCURSOR);
- bevel_mesh_recurs(drawd/fac, recurs, 1);
+ bevel_mesh_recurs(drawd/fac, recurs, BevelMode);
righthandfaces(1);
SetBlenderCursor(SYSCURSOR);
BIF_undo_push("Bevel");
@@ -5346,4 +5345,5 @@
initTransform(TFM_TRANSLATION, 0);
Transform();
}
+
More information about the Bf-committers
mailing list