diff options
-rw-r--r-- | source/blender/blenkernel/intern/mball.c | 106 | ||||
-rw-r--r-- | source/blender/include/BDR_editmball.h | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_meta_types.h | 1 | ||||
-rw-r--r-- | source/blender/src/buttons_editing.c | 5 | ||||
-rw-r--r-- | source/blender/src/editmball.c | 45 | ||||
-rw-r--r-- | source/blender/src/header_view3d.c | 34 | ||||
-rw-r--r-- | source/blender/src/space.c | 8 |
7 files changed, 146 insertions, 55 deletions
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 1f870f47be2..b2ed5f22c29 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -338,7 +338,7 @@ Object *find_basis_mball(Object *basis) } while(ml){ - totelem++; + if(!(ml->flag & MB_HIDE)) totelem++; ml= ml->next; } } @@ -1484,57 +1484,59 @@ float init_meta(Object *ob) /* return totsize */ } } while(ml) { - - Mat4One(temp2); - temp2[3][0]= ml->x; - temp2[3][1]= ml->y; - 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)); - imat= new_pgn_element(4*4*sizeof(float)); + if(!(ml->flag & MB_HIDE)) { + Mat4One(temp2); + temp2[3][0]= ml->x; + temp2[3][1]= ml->y; + temp2[3][2]= ml->z; - /* mat is the matrix to transform from mball into the basis-mball */ - Mat4Invert(obinv, ob->obmat); - Mat4MulMat4(temp1, bob->obmat, obinv); - /* MetaBall transformation */ - Mat4MulMat4(mat, temp2, temp1); - - Mat4Invert(imat,mat); - - mainb[a]->rad2= ml->rad*ml->rad; - - 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); + /* 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)); + imat= new_pgn_element(4*4*sizeof(float)); + + /* mat is the matrix to transform from mball into the basis-mball */ + Mat4Invert(obinv, ob->obmat); + Mat4MulMat4(temp1, bob->obmat, obinv); + /* MetaBall transformation */ + Mat4MulMat4(mat, temp2, temp1); + + Mat4Invert(imat,mat); + + mainb[a]->rad2= ml->rad*ml->rad; + + 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++; } - - 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; - a++; - } } } @@ -1925,6 +1927,7 @@ void metaball_polygonize(Object *ob) mb= ob->data; + if(totelem==0) return; if(!(R.flag & R_RENDERING) && (mb->flag==MB_UPDATE_NEVER)) return; if(G.moving && mb->flag==MB_UPDATE_FAST) return; @@ -1939,11 +1942,6 @@ void metaball_polygonize(Object *ob) /* initialize all mainb (MetaElems) */ totsize= init_meta(ob); - if(totelem==0) { - MEM_freeN(mainb); - return; - } - if(metaball_tree){ free_metaball_octal_node(metaball_tree->first); MEM_freeN(metaball_tree); diff --git a/source/blender/include/BDR_editmball.h b/source/blender/include/BDR_editmball.h index 71bc598042a..c3e9eaaf66c 100644 --- a/source/blender/include/BDR_editmball.h +++ b/source/blender/include/BDR_editmball.h @@ -47,6 +47,8 @@ void adduplicate_mball(void); void delete_mball(void); void freeMetaElemlist(struct ListBase *lb); void undo_push_mball(char *name); +void hide_mball(char hide); +void reveal_mball(void); #endif /* BDR_EDITMBALL_H */ diff --git a/source/blender/makesdna/DNA_meta_types.h b/source/blender/makesdna/DNA_meta_types.h index e9d0c841b53..4562080a7c0 100644 --- a/source/blender/makesdna/DNA_meta_types.h +++ b/source/blender/makesdna/DNA_meta_types.h @@ -103,6 +103,7 @@ typedef struct MetaBall { /* ml->flag */ #define MB_NEGATIVE 2 +#define MB_HIDE 4 #endif diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 26cef1b645e..40e3ff37e4a 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -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"); 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); } diff --git a/source/blender/src/editmball.c b/source/blender/src/editmball.c index 096c5049c71..1d9e7082dd4 100644 --- a/source/blender/src/editmball.c +++ b/source/blender/src/editmball.c @@ -414,3 +414,48 @@ void undo_push_mball(char *name) { 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"); +} diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index 55fe696c453..35a012fd79d 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -2528,6 +2528,38 @@ static uiBlock *view3d_edit_curvemenu(void *arg_unused) 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) { 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, ""); 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, ""); + 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) { uiBlockSetDirection(block, UI_DOWN); diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 649a45814a8..6cd90134a86 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -1262,6 +1262,14 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) else if(G.obedit->type==OB_LATTICE) { 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) hide_tface(); |