- added "hide" flag for MetaElem. Hidden MetaElem doesn't influence polygonisation.

It is useful for large scenes, when you work with lot of MetaElems. Example:

  http://e-learning.vslib.cz/~hnidek/pics/deer.jpg

  (PildaNovak's model)

- shortcuts for hiding of MetaElems:
   H ......... hide all selected MetaElems
   Shift-H ... hide all unselected MetaElems
   Alt-H ..... unhide all hidden MetaElems

- items in header menu of 3dview
This commit is contained in:
2005-02-21 10:40:30 +00:00
parent 597da98a71
commit c2e6ced9b8
7 changed files with 146 additions and 55 deletions

View File

@@ -338,7 +338,7 @@ Object *find_basis_mball(Object *basis)
} }
while(ml){ while(ml){
totelem++; if(!(ml->flag & MB_HIDE)) totelem++;
ml= ml->next; ml= ml->next;
} }
} }
@@ -1484,57 +1484,59 @@ float init_meta(Object *ob) /* return totsize */
} }
} }
while(ml) { while(ml) {
if(!(ml->flag & MB_HIDE)) {
Mat4One(temp2); Mat4One(temp2);
temp2[3][0]= ml->x; temp2[3][0]= ml->x;
temp2[3][1]= ml->y; temp2[3][1]= ml->y;
temp2[3][2]= ml->z; temp2[3][2]= ml->z;
/* make a copy because of duplicates */
mainb[a]= new_pgn_element(sizeof(MetaElem));
*(mainb[a])= *ml;
mainb[a]->bb = new_pgn_element(sizeof(BoundBox));
mat= new_pgn_element(4*4*sizeof(float)); /* make a copy because of duplicates */
imat= new_pgn_element(4*4*sizeof(float)); mainb[a]= new_pgn_element(sizeof(MetaElem));
*(mainb[a])= *ml;
/* mat is the matrix to transform from mball into the basis-mball */ mainb[a]->bb = new_pgn_element(sizeof(BoundBox));
Mat4Invert(obinv, ob->obmat);
Mat4MulMat4(temp1, bob->obmat, obinv); mat= new_pgn_element(4*4*sizeof(float));
/* MetaBall transformation */ imat= new_pgn_element(4*4*sizeof(float));
Mat4MulMat4(mat, temp2, temp1);
/* mat is the matrix to transform from mball into the basis-mball */
Mat4Invert(imat,mat); Mat4Invert(obinv, ob->obmat);
Mat4MulMat4(temp1, bob->obmat, obinv);
mainb[a]->rad2= ml->rad*ml->rad; /* MetaBall transformation */
Mat4MulMat4(mat, temp2, temp1);
mainb[a]->mat= (float*) mat;
mainb[a]->imat= (float*) imat; Mat4Invert(imat,mat);
if(ml->type==MB_BALL){ mainb[a]->rad2= ml->rad*ml->rad;
max= 0.0;
mainb[a]->mat= (float*) mat;
mainb[a]->imat= (float*) imat;
if(ml->type==MB_BALL){
max= 0.0;
}
else if((ml->type==MB_TUBE)){
max= bob->size[0]*ml->expx;
}
else if((ml->type==MB_PLANE)){
max= MAX2(bob->size[0]*ml->expx, bob->size[1]*ml->expy);
}
else if((ml->type==MB_CUBE)||(ml->type==MB_ELIPSOID)){
max= MAX3(bob->size[0]*ml->expx,
bob->size[1]*ml->expy,
bob->size[2]*ml->expz);
}
mainb[a]->bb->vec[0][0]= mat[3][0] - bob->size[0]*(max+ml->rad)/ob->size[0];
mainb[a]->bb->vec[0][1]= mat[3][1] - bob->size[1]*(max+ml->rad)/ob->size[1];
mainb[a]->bb->vec[0][2]= mat[3][2] - bob->size[2]*(max+ml->rad)/ob->size[2];
mainb[a]->bb->vec[6][0]= mat[3][0] + bob->size[0]*(max+ml->rad)/ob->size[0];
mainb[a]->bb->vec[6][1]= mat[3][1] + bob->size[1]*(max+ml->rad)/ob->size[1];
mainb[a]->bb->vec[6][2]= mat[3][2] + bob->size[2]*(max+ml->rad)/ob->size[2];
a++;
} }
else if((ml->type==MB_TUBE)){
max= bob->size[0]*ml->expx;
}
else if((ml->type==MB_PLANE)){
max= MAX2(bob->size[0]*ml->expx, bob->size[1]*ml->expy);
}
else if((ml->type==MB_CUBE)||(ml->type==MB_ELIPSOID)){
max= MAX3(bob->size[0]*ml->expx, bob->size[1]*ml->expy, bob->size[2]*ml->expz);
}
mainb[a]->bb->vec[0][0]= mat[3][0] - bob->size[0]*(max+ml->rad)/ob->size[0];
mainb[a]->bb->vec[0][1]= mat[3][1] - bob->size[1]*(max+ml->rad)/ob->size[1];
mainb[a]->bb->vec[0][2]= mat[3][2] - bob->size[2]*(max+ml->rad)/ob->size[2];
mainb[a]->bb->vec[6][0]= mat[3][0] + bob->size[0]*(max+ml->rad)/ob->size[0];
mainb[a]->bb->vec[6][1]= mat[3][1] + bob->size[1]*(max+ml->rad)/ob->size[1];
mainb[a]->bb->vec[6][2]= mat[3][2] + bob->size[2]*(max+ml->rad)/ob->size[2];
ml= ml->next; ml= ml->next;
a++;
} }
} }
} }
@@ -1925,6 +1927,7 @@ void metaball_polygonize(Object *ob)
mb= ob->data; mb= ob->data;
if(totelem==0) return;
if(!(R.flag & R_RENDERING) && (mb->flag==MB_UPDATE_NEVER)) return; if(!(R.flag & R_RENDERING) && (mb->flag==MB_UPDATE_NEVER)) return;
if(G.moving && mb->flag==MB_UPDATE_FAST) return; if(G.moving && mb->flag==MB_UPDATE_FAST) return;
@@ -1939,11 +1942,6 @@ void metaball_polygonize(Object *ob)
/* initialize all mainb (MetaElems) */ /* initialize all mainb (MetaElems) */
totsize= init_meta(ob); totsize= init_meta(ob);
if(totelem==0) {
MEM_freeN(mainb);
return;
}
if(metaball_tree){ if(metaball_tree){
free_metaball_octal_node(metaball_tree->first); free_metaball_octal_node(metaball_tree->first);
MEM_freeN(metaball_tree); MEM_freeN(metaball_tree);

View File

@@ -47,6 +47,8 @@ void adduplicate_mball(void);
void delete_mball(void); void delete_mball(void);
void freeMetaElemlist(struct ListBase *lb); void freeMetaElemlist(struct ListBase *lb);
void undo_push_mball(char *name); void undo_push_mball(char *name);
void hide_mball(char hide);
void reveal_mball(void);
#endif /* BDR_EDITMBALL_H */ #endif /* BDR_EDITMBALL_H */

View File

@@ -103,6 +103,7 @@ typedef struct MetaBall {
/* ml->flag */ /* ml->flag */
#define MB_NEGATIVE 2 #define MB_NEGATIVE 2
#define MB_HIDE 4
#endif #endif

View File

@@ -1428,7 +1428,10 @@ static void editing_panel_mball_tools(Object *ob, MetaBall *mb)
uiDefButS(block, ROW, B_RECALCMBALL, "Cube", 938,62,60,19, &lastelem->type, 1.0, 7.0, 0, 0, "Draw active meta as Cube"); uiDefButS(block, ROW, B_RECALCMBALL, "Cube", 938,62,60,19, &lastelem->type, 1.0, 7.0, 0, 0, "Draw active meta as Cube");
uiBlockEndAlign(block); uiBlockEndAlign(block);
uiDefButS(block, TOG|BIT|1, B_RECALCMBALL, "Negative",753,16,250,19, &lastelem->flag, 0, 0, 0, 0, "Make active meta creating holes"); uiBlockBeginAlign(block);
uiDefButS(block, TOG|BIT|1, B_RECALCMBALL, "Negative",753,16,125,19, &lastelem->flag, 0, 0, 0, 0, "Make active meta creating holes");
uiDefButS(block, TOG|BIT|2, B_RECALCMBALL, "Hide",878,16,125,19, &lastelem->flag, 0, 0, 0, 0, "Make active meta invisible");
uiBlockEndAlign(block);
} }

View File

@@ -414,3 +414,48 @@ void undo_push_mball(char *name)
{ {
undo_editmode_push(name, free_undoMball, undoMball_to_editMball, editMball_to_undoMball); undo_editmode_push(name, free_undoMball, undoMball_to_editMball, editMball_to_undoMball);
} }
/* Hide selected/unselected MetaElems */
void hide_mball(char hide)
{
MetaElem *ml;
ml= editelems.first;
while(ml){
if(hide){
if(!(ml->flag & SELECT))
ml->flag |= MB_HIDE;
}
else{
if(ml->flag & SELECT)
ml->flag |= MB_HIDE;
}
ml= ml->next;
}
makeDispList(G.obedit);
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWBUTSEDIT, 0);
BIF_undo_push("Hide MetaElems");
}
/* Unhide all edited MetaElems */
void reveal_mball(void)
{
MetaElem *ml;
ml= editelems.first;
while(ml){
ml->flag &= ~MB_HIDE;
ml= ml->next;
}
makeDispList(G.obedit);
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWBUTSEDIT, 0);
BIF_undo_push("Unhide MetaElems");
}

View File

@@ -2528,6 +2528,38 @@ static uiBlock *view3d_edit_curvemenu(void *arg_unused)
return block; return block;
} }
void do_view3d_edit_mball_showhidemenu(void *arg, int event)
{
switch(event) {
case 10: /* show hidden control points */
reveal_mball();
break;
case 11: /* hide selected control points */
hide_mball(0);
break;
case 12: /* hide deselected control points */
hide_mball(1);
break;
}
allqueue(REDRAWVIEW3D, 0);
}
static uiBlock *view3d_edit_mball_showhidemenu(void *arg_unused)
{
uiBlock *block;
short yco = 20, menuwidth = 120;
block= uiNewBlock(&curarea->uiblocks, "view3d_edit_mball_showhidemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
uiBlockSetButmFunc(block, do_view3d_edit_mball_showhidemenu, NULL);
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Hidden|Alt H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Hide Selected|H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Hide Deselected|Shift H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 12, "");
uiBlockSetDirection(block, UI_RIGHT);
uiTextBoundsBlock(block, 60);
return block;
}
static void do_view3d_edit_metaballmenu(void *arg, int event) static void do_view3d_edit_metaballmenu(void *arg, int event)
{ {
switch(event) { switch(event) {
@@ -2582,6 +2614,8 @@ static uiBlock *view3d_edit_metaballmenu(void *arg_unused)
uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, ""); uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Shear|Ctrl S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Shear|Ctrl S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Warp|Shift W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Warp|Shift W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBlockBut(block, view3d_edit_mball_showhidemenu, NULL, ICON_RIGHTARROW_THIN, "Hide MetaElems", 0, yco-=20, 120, 19, "");
if(curarea->headertype==HEADERTOP) { if(curarea->headertype==HEADERTOP) {
uiBlockSetDirection(block, UI_DOWN); uiBlockSetDirection(block, UI_DOWN);

View File

@@ -1262,6 +1262,14 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
else if(G.obedit->type==OB_LATTICE) { else if(G.obedit->type==OB_LATTICE) {
if(G.qual==LR_CTRLKEY) add_hook(); if(G.qual==LR_CTRLKEY) add_hook();
} }
else if(G.obedit->type==OB_MBALL) {
if(G.qual==LR_ALTKEY)
reveal_mball();
else if((G.qual==LR_SHIFTKEY))
hide_mball(1);
else if((G.qual==0))
hide_mball(0);
}
} }
else if(G.f & G_FACESELECT) else if(G.f & G_FACESELECT)
hide_tface(); hide_tface();