Patch from Tom Musgrove to bypass extrude popup on singular selections...

Implementation had some issues though, since:

a) Blender has no stats available that tells amount of selected edges
b) Bypassing the popup should be 100% accurate
b) Once you do that, the popup should actually only show possible
   choices as well.

So! I've added a G.totedge and G.totedgesel, also being printed in the
info header. Using this variable the extrude popups could be limited too.

Also: made 'normal alignment' for edge-only selections work when the
normal wasn't pointing OK. Now it aligns the Z axis with the edge itself
Exact algorithm for choosing a 'normal' and 'plane' still is weak.
This commit is contained in:
Ton Roosendaal 2005-05-07 15:50:09 +00:00
parent 71c2d1e9d6
commit 9a41ac4f70
6 changed files with 64 additions and 29 deletions

@ -87,9 +87,9 @@ typedef struct Global {
/* strings: lastsaved */
char ima[160], sce[160], lib[160];
/* totalen */
/* totals */
short totobj, totlamp, totobjsel, totcurve, totmesh, totmat;
int totvert, totface, totvertsel, totfacesel;
int totvert, totedge, totface, totvertsel, totedgesel, totfacesel;
short machine, afbreek, moving, colact, zbuf;
short qual, background, imagewin, animspeed;

@ -561,30 +561,31 @@ void countall()
BezTriple *bezt;
BPoint *bp;
MetaElem *ml;
struct EditVert *eve;
struct EditFace *efa;
struct EditBone *ebo;
int a;
G.totvert= G.totvertsel= G.totfacesel= G.totface= G.totobj=
G.totvert= G.totvertsel= G.totedge= G.totedgesel= G.totfacesel= G.totface= G.totobj=
G.totmesh= G.totlamp= G.totcurve= G.totobjsel= 0;
if(G.obedit) {
if(G.obedit->type==OB_MESH) {
EditMesh *em = G.editMesh;
eve= em->verts.first;
while(eve) {
EditVert *eve;
EditEdge *eed;
EditFace *efa;
for(eve= em->verts.first; eve; eve= eve->next) {
G.totvert++;
if(eve->f & SELECT) G.totvertsel++;
eve= eve->next;
}
efa= em->faces.first;
while(efa) {
for(eed= em->edges.first; eed; eed= eed->next) {
G.totedge++;
if(eed->f & SELECT) G.totedgesel++;
}
for(efa= em->faces.first; efa; efa= efa->next) {
G.totface++;
if(efa->f & SELECT) G.totfacesel++;
efa= efa->next;
}
}
else if (G.obedit->type==OB_ARMATURE){

@ -952,8 +952,8 @@ static void mouse_mesh_loop(void)
/* frontbuffer draw of last selected only */
unified_select_draw(NULL, eed, NULL);
countall();
EM_selectmode_flush();
countall();
allqueue(REDRAWVIEW3D, 0);
}
@ -997,8 +997,8 @@ void mouse_mesh(void)
/* frontbuffer draw of last selected only */
unified_select_draw(eve, eed, efa);
countall();
EM_selectmode_flush();
countall();
allqueue(REDRAWVIEW3D, 0);
}

@ -538,12 +538,32 @@ void extrude_mesh(void)
TEST_EDITMESH
if(G.scene->selectmode & SCE_SELECT_VERTEX)
nr= pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3|Only Vertices%x4");
else if(G.scene->selectmode & SCE_SELECT_EDGE)
nr= pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3");
else
nr= pupmenu("Extrude %t|Region %x1||Individual Faces %x2");
if(G.scene->selectmode & SCE_SELECT_VERTEX) {
if(G.totvertsel==0) nr= 0;
else if(G.totvertsel==1) nr= 4;
else if(G.totedgesel==0) nr= 4;
else if(G.totfacesel==0)
nr= pupmenu("Extrude %t|Only Edges%x3|Only Vertices%x4");
else if(G.totfacesel==1)
nr= pupmenu("Extrude %t|Region %x1|Only Edges%x3");
else
nr= pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3|Only Vertices%x4");
}
else if(G.scene->selectmode & SCE_SELECT_EDGE) {
if (G.totedgesel==0) nr = 0;
else if (G.totedgesel==1) nr = 3;
else if(G.totfacesel==0) nr = 3;
else if(G.totfacesel==1)
nr= pupmenu("Extrude %t|Region %x1|Only Edges%x3");
else
nr= pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3");
}
else {
if (G.totfacesel == 0) nr = 0;
else if (G.totfacesel == 1) nr = 1;
else
nr= pupmenu("Extrude %t|Region %x1||Individual Faces %x2");
}
if(nr<1) return;

@ -1774,9 +1774,21 @@ static void info_text(int x, int y)
int hsize;
if(G.obedit) {
sprintf(infostr,"Ve:%d-%d | Fa:%d-%d | Mem:%.2fM ",
G.totvertsel, G.totvert, G.totfacesel, G.totface,
(mem_in_use>>10)/1024.0);
if(G.obedit->type==OB_MESH) {
if(G.scene->selectmode & SCE_SELECT_VERTEX)
sprintf(infostr,"Ve:%d-%d | Ed:%d-%d | Fa:%d-%d | Mem:%.2fM ",
G.totvertsel, G.totvert, G.totedgesel, G.totedge, G.totfacesel, G.totface, (mem_in_use>>10)/1024.0);
else if(G.scene->selectmode & SCE_SELECT_EDGE)
sprintf(infostr,"Ed:%d-%d | Fa:%d-%d | Mem:%.2fM ",
G.totedgesel, G.totedge, G.totfacesel, G.totface, (mem_in_use>>10)/1024.0);
else
sprintf(infostr,"Fa:%d-%d | Mem:%.2fM ",
G.totfacesel, G.totface, (mem_in_use>>10)/1024.0);
}
else {
sprintf(infostr,"Ve:%d-%d | Mem:%.2fM ",
G.totvertsel, G.totvert, (mem_in_use>>10)/1024.0);
}
}
else {
sprintf(infostr,"Ve:%d | Fa:%d | Ob:%d-%d | La:%d | Mem:%.2fM | Time:%s | ",

@ -187,38 +187,40 @@ int calc_manipulator_stats(ScrArea *sa)
EditMesh *em = G.editMesh;
EditVert *eve;
float vec[3];
int do_norm= 0;
int no_faces= 1;
if(v3d->twmode == V3D_MANIP_NORMAL) {
EditFace *efa;
for(efa= em->faces.first; efa; efa= efa->next) {
if(efa->f & SELECT) {
no_faces= 1;
VECADD(normal, normal, efa->n);
VecSubf(vec, efa->v2->co, efa->v1->co);
VECADD(plane, plane, vec);
}
}
if(normal[0]==0.0 && normal[1]==0.0 && normal[2]==0.0) do_norm= 1;
}
/* do vertices for center, and if still no normal found, use vertex normals */
for(eve= em->verts.first; eve; eve= eve->next) {
if(eve->f & SELECT) {
if(do_norm) VECADD(normal, normal, eve->no);
if(no_faces) VECADD(normal, normal, eve->no);
totsel++;
calc_tw_center(eve->co);
}
}
/* the edge case... */
if(do_norm && v3d->twmode == V3D_MANIP_NORMAL) {
if(no_faces && v3d->twmode == V3D_MANIP_NORMAL) {
EditEdge *eed;
for(eed= em->edges.first; eed; eed= eed->next) {
if(eed->f & SELECT) {
VecSubf(vec, eed->v2->co, eed->v1->co);
VECADD(plane, plane, vec);
/* ok we got an edge, only use one, and as normal */
VECCOPY(plane, normal);
VecSubf(normal, eed->v2->co, eed->v1->co);
break;
}
}
}