Long on the wishlist!

- CTRL+click in EditMesh now extrudes selection. If no selection, it adds
  a new vertex. Try it on a full selected monkey. Fun! :)
- CTRL+click now also adds the new stuff aligned with the view, as if you
  had translated it to the mouse cursor. Only new vertices are added with
  respect to 3D cursor location.
This commit is contained in:
Ton Roosendaal 2005-10-22 19:34:31 +00:00
parent 9e19739944
commit ac3e3eceba
3 changed files with 72 additions and 34 deletions

@ -66,7 +66,7 @@ extern void separate_mesh_loose(void);
/* ******************* editmesh_add.c */ /* ******************* editmesh_add.c */
extern void add_primitiveMesh(int type); extern void add_primitiveMesh(int type);
extern void adduplicate_mesh(void); extern void adduplicate_mesh(void);
extern void addvert_mesh(void); extern void add_click_mesh(void);
extern void addedgeface_mesh(void); extern void addedgeface_mesh(void);
/* ******************* editmesh_lib.c */ /* ******************* editmesh_lib.c */

@ -116,46 +116,84 @@ static short icoface[20][3] = {
{10,9,11} {10,9,11}
}; };
void addvert_mesh(void) static void get_view_aligned_coordinate(float *fp)
{
float dvec[3];
short mx, my, mval[0];
getmouseco_areawin(mval);
mx= mval[0];
my= mval[1];
project_short_noclip(fp, mval);
initgrabz(fp[0], fp[1], fp[2]);
if(mval[0]!=IS_CLIPPED) {
window_to_3d(dvec, mval[0]-mx, mval[1]-my);
VecSubf(fp, fp, dvec);
}
}
void add_click_mesh(void)
{ {
EditMesh *em = G.editMesh; EditMesh *em = G.editMesh;
EditVert *eve,*v1=0; EditVert *eve, *v1;
float *curs, mat[3][3],imat[3][3]; float min[3], max[3];
int done= 0;
// hurms, yah...
if(G.scene->selectmode==SCE_SELECT_FACE) return;
TEST_EDITMESH TEST_EDITMESH
INIT_MINMAX(min, max);
for(v1= em->verts.first;v1; v1=v1->next) {
if(v1->f & SELECT) {
DO_MINMAX(v1->co, min, max);
done= 1;
}
}
/* call extrude? */
if(done) {
float vec[3];
float nor[3]= {0.0, 0.0, 0.0};
/* centre */
VecAddf(min, min, max);
VecMulf(min, 0.5f);
VECCOPY(vec, min);
Mat4MulVecfl(G.obedit->obmat, min); // view space
get_view_aligned_coordinate(min);
Mat4Invert(G.obedit->imat, G.obedit->obmat);
Mat4MulVecfl(G.obedit->imat, min); // back in object space
VecSubf(min, min, vec);
extrudeflag(SELECT, nor);
translateflag(SELECT, min);
recalc_editnormals();
}
else {
float mat[3][3],imat[3][3];
float *curs= give_cursor();
eve= addvertlist(0);
Mat3CpyMat4(mat, G.obedit->obmat); Mat3CpyMat4(mat, G.obedit->obmat);
Mat3Inv(imat, mat); Mat3Inv(imat, mat);
v1= em->verts.first;
while(v1) {
if(v1->f & SELECT) break;
v1= v1->next;
}
eve= v1;
/* prevent there are more selected */
EM_clear_flag_all(SELECT);
eve= addvertlist(0);
curs= give_cursor();
VECCOPY(eve->co, curs); VECCOPY(eve->co, curs);
VecSubf(eve->co, eve->co, G.obedit->obmat[3]); VecSubf(eve->co, eve->co, G.obedit->obmat[3]);
Mat3MulVecfl(imat, eve->co); Mat3MulVecfl(imat, eve->co);
eve->f= SELECT;
if(v1) { eve->f= SELECT;
addedgelist(v1, eve, NULL);
v1->f= 0;
} }
countall(); countall();
BIF_undo_push("Add vertex"); BIF_undo_push("Add vertex/edge/face");
allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWVIEW3D, 0);
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);

@ -853,7 +853,7 @@ void mouse_cursor(void)
allqueue(REDRAWVIEW3D, 1); allqueue(REDRAWVIEW3D, 1);
if(lr_click) { if(lr_click) {
if(G.obedit->type==OB_MESH) addvert_mesh(); if(G.obedit->type==OB_MESH) add_click_mesh();
else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) addvert_Nurb(0); else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) addvert_Nurb(0);
else if (G.obedit->type==OB_ARMATURE) addvert_armature(); else if (G.obedit->type==OB_ARMATURE) addvert_armature();
VECCOPY(fp, oldcurs); VECCOPY(fp, oldcurs);