forked from bartvdbraak/blender
Patch [#6729] from Juho Vepsäläinen. It adds inverse and random select for metaelems. I simplified random select a little.
This commit is contained in:
parent
dc8a10bf58
commit
d1711b3972
@ -42,6 +42,8 @@ void load_editMball(void);
|
||||
*/
|
||||
void add_primitiveMball(int);
|
||||
void deselectall_mball(void);
|
||||
void selectinverse_mball(void);
|
||||
void selectrandom_mball(void);
|
||||
void mouse_mball(void);
|
||||
void adduplicate_mball(void);
|
||||
void delete_mball(void);
|
||||
|
@ -141,6 +141,7 @@ void do_view3d_select_object_typemenu(void *arg, int event);
|
||||
void do_view3d_select_faceselmenu(void *arg, int event);
|
||||
void do_view3d_select_meshmenu(void *arg, int event);
|
||||
void do_view3d_select_curvemenu(void *arg, int event);
|
||||
void do_view3d_select_metaballmenu(void *arg, int event);
|
||||
void do_view3d_edit_snapmenu(void *arg, int event);
|
||||
void do_view3d_edit_mirrormenu(void *arg, int event);
|
||||
void do_view3d_transform_moveaxismenu(void *arg, int event);
|
||||
|
@ -30,6 +30,7 @@
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -40,6 +41,7 @@
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_arithb.h"
|
||||
#include "BLI_rand.h"
|
||||
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
@ -251,6 +253,43 @@ void deselectall_mball()
|
||||
BIF_undo_push("Deselect MetaElem");
|
||||
}
|
||||
|
||||
/* inverts metaball selection */
|
||||
void selectinverse_mball()
|
||||
{
|
||||
MetaElem *ml;
|
||||
|
||||
ml= editelems.first;
|
||||
while(ml) {
|
||||
if(ml->flag & SELECT) ml->flag &= ~SELECT;
|
||||
else ml->flag |= SELECT;
|
||||
ml= ml->next;
|
||||
}
|
||||
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
countall();
|
||||
BIF_undo_push("Invert MetaElem");
|
||||
}
|
||||
|
||||
/* select random metaball selection */
|
||||
void selectrandom_mball()
|
||||
{
|
||||
MetaElem *ml;
|
||||
static short randfac= 50;
|
||||
|
||||
if(!button(&randfac,0, 100,"Percentage:")) return;
|
||||
|
||||
ml= editelems.first;
|
||||
BLI_srand( BLI_rand() ); /* random seed */
|
||||
while(ml) {
|
||||
if((BLI_frand() * 100) < randfac) ml->flag |= SELECT;
|
||||
ml= ml->next;
|
||||
}
|
||||
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
countall();
|
||||
BIF_undo_push("Random MetaElem");
|
||||
}
|
||||
|
||||
/* select MetaElement with mouse click (user can select radius circle or
|
||||
* stiffness circle) */
|
||||
void mouse_mball()
|
||||
|
@ -1181,7 +1181,7 @@ static uiBlock *view3d_select_curvemenu(void *arg_unused)
|
||||
return block;
|
||||
}
|
||||
|
||||
static void do_view3d_select_metaballmenu(void *arg, int event)
|
||||
void do_view3d_select_metaballmenu(void *arg, int event)
|
||||
{
|
||||
|
||||
switch(event) {
|
||||
@ -1191,6 +1191,12 @@ static void do_view3d_select_metaballmenu(void *arg, int event)
|
||||
case 2: /* Select/Deselect all */
|
||||
deselectall_mball();
|
||||
break;
|
||||
case 3: /* Inverse */
|
||||
selectinverse_mball();
|
||||
break;
|
||||
case 4: /* Select Random */
|
||||
selectrandom_mball();
|
||||
break;
|
||||
}
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
}
|
||||
@ -1209,7 +1215,13 @@ static uiBlock *view3d_select_metaballmenu(void *arg_unused)
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Inverse", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Random...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
|
||||
|
||||
if(curarea->headertype==HEADERTOP) {
|
||||
uiBlockSetDirection(block, UI_DOWN);
|
||||
}
|
||||
|
@ -960,6 +960,15 @@ static TBitem tb_curve_select[]= {
|
||||
{ 0, "Less|Ctrl NumPad -", 10, NULL},
|
||||
{ -1, "", 0, do_view3d_select_curvemenu}};
|
||||
|
||||
static TBitem tb_mball_select[]= {
|
||||
{ 0, "Border Select|B", 0, NULL},
|
||||
{ 0, "SEPR", 0, NULL},
|
||||
{ 0, "(De)select All|A", 2, NULL},
|
||||
{ 0, "Inverse", 3, NULL},
|
||||
{ 0, "SEPR", 0, NULL},
|
||||
{ 0, "Random...", 4, NULL},
|
||||
{ -1, "", 0, do_view3d_select_metaballmenu}};
|
||||
|
||||
static TBitem tb__select[]= {
|
||||
{ 0, "Border Select|B", 'b', NULL},
|
||||
{ 0, "(De)select All|A", 'a', NULL},
|
||||
@ -2019,7 +2028,7 @@ void toolbox_n(void)
|
||||
case OB_MBALL:
|
||||
menu1= addmenu_meta;
|
||||
menu2= tb_edit;
|
||||
menu3= tb__select;
|
||||
menu3= tb_mball_select;
|
||||
menu4= tb_transform_editmode2;
|
||||
menu5= tb_obdata; str5= "Meta";
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user