Move the settings in the Mesh Tools panel to the new toolsettings struct in Scene. These settings are now saved per scene.

This commit is contained in:
Johnny Matthews 2005-08-24 20:37:25 +00:00
parent a978c122ee
commit a51896b591
10 changed files with 105 additions and 49 deletions

View File

@ -143,6 +143,11 @@ void free_scene(Scene *sce)
BLI_freelistN(&sce->markers);
if(sce->toolsettings){
MEM_freeN(sce->toolsettings);
sce->toolsettings = NULL;
}
if (sce->theDag) {
free_forest(sce->theDag);
MEM_freeN(sce->theDag);
@ -193,6 +198,18 @@ Scene *add_scene(char *name)
sce->r.stereomode = 1; // no stereo
sce->toolsettings = MEM_mallocN(sizeof(struct ToolSettings),"Tool Settings Struct");
sce->toolsettings->cornertype=0;
sce->toolsettings->degr = 90;
sce->toolsettings->step = 9;
sce->toolsettings->turn = 1;
sce->toolsettings->extr_offs = 1;
sce->toolsettings->doublimit = 0.001;
sce->toolsettings->segments = 32;
sce->toolsettings->rings = 32;
sce->toolsettings->vertices = 32;
sce->toolsettings->editbutflag = 1;
strcpy(sce->r.backbuf, "//backbuf");
strcpy(sce->r.pic, U.renderdir);
strcpy(sce->r.ftype, "//ftype");

View File

@ -2561,7 +2561,9 @@ static void direct_link_scene(FileData *fd, Scene *sce)
sce->basact= newdataadr(fd, sce->basact);
sce->radio= newdataadr(fd, sce->radio);
sce->toolsettings= newdataadr(fd, sce->toolsettings);
if(sce->ed) {
ed= sce->ed= newdataadr(fd, sce->ed);
@ -4849,6 +4851,24 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
Object *ob;
bArmature *arm;
Mesh *me;
Scene *sce= main->scene.first;
while(sce){
if(sce->toolsettings == NULL){
sce->toolsettings = MEM_mallocN(sizeof(struct ToolSettings),"Tool Settings Struct");
sce->toolsettings->cornertype=0;
sce->toolsettings->degr = 90;
sce->toolsettings->step = 9;
sce->toolsettings->turn = 1;
sce->toolsettings->extr_offs = 1;
sce->toolsettings->doublimit = 0.001;
sce->toolsettings->segments = 32;
sce->toolsettings->rings = 32;
sce->toolsettings->vertices = 32;
sce->toolsettings->editbutflag =1;
}
sce= sce->id.next;
}
for (lt=main->latt.first; lt; lt=lt->id.next) {
if (lt->fu==0.0 && lt->fv==0.0 && lt->fw==0.0) {

View File

@ -1086,7 +1086,8 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
}
writestruct(wd, DATA, "Radio", 1, sce->radio);
writestruct(wd, DATA, "ToolSettings", 1, sce->toolsettings);
ed= sce->ed;
if(ed) {
writestruct(wd, DATA, "Editing", 1, ed);

View File

@ -254,6 +254,31 @@ typedef struct TimeMarker {
unsigned int flag;
} TimeMarker;
typedef struct ToolSettings {
// Subdivide Settings
short cornertype;
short editbutflag;
// Extrude Tools
short degr;
short step;
short turn;
short pad1;
float extr_offs;
float doublimit;
// Primitive Settings
// UV Sphere
short segments;
short rings;
// Cylinder - Tube - Circle
short vertices;
char pad2,pad3;
} ToolSettings;
typedef struct Scene {
ID id;
struct Object *camera;
@ -282,6 +307,8 @@ typedef struct Scene {
struct GameFraming framing;
struct ToolSettings *toolsettings;
/* migrate or replace? depends on some internal things... */
/* no, is on the right place (ton) */
struct RenderData r;

View File

@ -151,12 +151,8 @@
#include "butspace.h" // own module
static short degr= 90, step= 9, turn= 1;
static float extr_offs= 1.0;
static float editbutweight=1.0;
short editbutflag= 1;
short cornertype = 0;
float doublimit= 0.001, editbutvweight=1;
float editbutvweight=1;
float uv_calc_radius= 1.0, uv_calc_cubesize= 1.0;
short uv_calc_mapdir= 1, uv_calc_mapalign= 1, facesel_draw_edges= 0;
@ -2447,10 +2443,10 @@ void do_meshbuts(unsigned short event)
switch(event) {
case B_SPIN:
if( select_area(SPACE_VIEW3D)) spin_mesh(step, degr, 0, 0);
if( select_area(SPACE_VIEW3D)) spin_mesh(G.scene->toolsettings->step, G.scene->toolsettings->degr, 0, 0);
break;
case B_SPINDUP:
if( select_area(SPACE_VIEW3D)) spin_mesh(step, degr, 0, 1);
if( select_area(SPACE_VIEW3D)) spin_mesh(G.scene->toolsettings->step, G.scene->toolsettings->degr, 0, 1);
break;
case B_EXTR:
G.f |= G_DISABLE_OK;
@ -2458,10 +2454,10 @@ void do_meshbuts(unsigned short event)
G.f -= G_DISABLE_OK;
break;
case B_SCREW:
if( select_area(SPACE_VIEW3D)) screw_mesh(step, turn);
if( select_area(SPACE_VIEW3D)) screw_mesh(G.scene->toolsettings->step, G.scene->toolsettings->turn);
break;
case B_EXTREP:
if( select_area(SPACE_VIEW3D)) extrude_repeat_mesh(step, extr_offs);
if( select_area(SPACE_VIEW3D)) extrude_repeat_mesh(G.scene->toolsettings->step, G.scene->toolsettings->extr_offs);
break;
case B_SPLIT:
G.f |= G_DISABLE_OK;
@ -2469,13 +2465,13 @@ void do_meshbuts(unsigned short event)
G.f -= G_DISABLE_OK;
break;
case B_REMDOUB:
notice("Removed: %d", removedoublesflag(1, doublimit));
notice("Removed: %d", removedoublesflag(1, G.scene->toolsettings->doublimit));
allqueue(REDRAWVIEW3D, 0);
BIF_undo_push("Rem Doubles");
break;
case B_SUBDIV:
waitcursor(1);
esubdivideflag(1, 0.0, editbutflag & B_BEAUTY,1,0);
esubdivideflag(1, 0.0, G.scene->toolsettings->editbutflag & B_BEAUTY,1,0);
countall();
waitcursor(0);
allqueue(REDRAWVIEW3D, 0);
@ -2486,7 +2482,7 @@ void do_meshbuts(unsigned short event)
if(button(&randfac, 1, 100, "Rand fac:")==0) return;
waitcursor(1);
fac= -( (float)randfac )/100;
esubdivideflag(1, fac, editbutflag & B_BEAUTY,1,0);
esubdivideflag(1, fac, G.scene->toolsettings->editbutflag & B_BEAUTY,1,0);
countall();
waitcursor(0);
allqueue(REDRAWVIEW3D, 0);
@ -2529,13 +2525,13 @@ static void editing_panel_mesh_tools(Object *ob, Mesh *me)
if(uiNewPanel(curarea, block, "Mesh Tools", "Editing", 640, 0, 318, 204)==0) return;
uiBlockBeginAlign(block);
uiDefButBitS(block, TOG, B_BEAUTY, 0, "Beauty", 10,195,40,19, &editbutflag, 0, 0, 0, 0, "Causes 'Subdivide' to split faces in halves instead of quarters using Long Edges Unless short is selected");
uiDefButBitS(block, TOG, B_BEAUTY_SHORT, 0, "Short", 50,195,40,19, &editbutflag, 0, 0, 0, 0, "Causes 'Subdivide' to split faces in halves instead of quarters using Short Edges");
uiDefButBitS(block, TOG, B_BEAUTY, 0, "Beauty", 10,195,40,19, &G.scene->toolsettings->editbutflag, 0, 0, 0, 0, "Causes 'Subdivide' to split faces in halves instead of quarters using Long Edges Unless short is selected");
uiDefButBitS(block, TOG, B_BEAUTY_SHORT, 0, "Short", 50,195,40,19, &G.scene->toolsettings->editbutflag, 0, 0, 0, 0, "Causes 'Subdivide' to split faces in halves instead of quarters using Short Edges");
uiDefBut(block, BUT,B_SUBDIV,"Subdivide", 90,195,80,19, 0, 0, 0, 0, 0, "Splits selected faces into halves or quarters");
uiDefButS(block, MENU, B_DIFF, "Corner Cut Type %t|Path %x0|Innervert %x1|Fan %x2",
170, 195, 85, 19, &cornertype, 0, 0, 0, 0, "Choose Quad Corner Cut Type");
170, 195, 85, 19, &G.scene->toolsettings->cornertype , 0, 0, 0, 0, "Choose Quad Corner Cut Type");
uiDefBut(block, BUT,B_VERTEXNOISE,"Noise", 10,175,60,19, 0, 0, 0, 0, 0, "Use vertex coordinate as texture coordinate");
uiDefBut(block, BUT,B_HASH,"Hash", 70,175,60,19, 0, 0, 0, 0, 0, "Randomizes selected vertice sequence data");
@ -2549,7 +2545,7 @@ static void editing_panel_mesh_tools(Object *ob, Mesh *me)
uiDefBut(block, BUT,B_FLIPNORM,"Flip Normals", 10,135,80,19, 0, 0, 0, 0, 0, "Toggles the direction of the selected face's normals");
uiDefBut(block, BUT,B_REMDOUB,"Rem Doubles", 90,135,80,19, 0, 0, 0, 0, 0, "Removes duplicates from selected vertices");
uiDefButF(block, NUM, B_DIFF, "Limit:", 170,135,85,19, &doublimit, 0.0001, 1.0, 10, 0, "Specifies the max distance 'Rem Doubles' will consider vertices as 'doubled'");
uiDefButF(block, NUM, B_DIFF, "Limit:", 170,135,85,19, &G.scene->toolsettings->doublimit, 0.0001, 1.0, 10, 0, "Specifies the max distance 'Rem Doubles' will consider vertices as 'doubled'");
uiBlockEndAlign(block);
uiDefBut(block, BUT,B_EXTR,"Extrude", 10,105,245,24, 0, 0, 0, 0, 0, "Converts selected edges to faces and selects the new vertices");
@ -2559,15 +2555,15 @@ static void editing_panel_mesh_tools(Object *ob, Mesh *me)
uiDefBut(block, BUT,B_SPIN, "Spin", 90,75,80,24, 0, 0, 0, 0, 0, "Extrudes the selected vertices in a circle around the cursor in the indicated viewport");
uiDefBut(block, BUT,B_SPINDUP,"Spin Dup", 170,75,85,24, 0, 0, 0, 0, 0, "Creates copies of the selected vertices in a circle around the cursor in the indicated viewport");
uiDefButS(block, NUM, B_DIFF, "Degr:", 10,55,80,19, &degr,10.0,360.0, 0, 0, "Specifies the number of degrees 'Spin' revolves");
uiDefButS(block, NUM, B_DIFF, "Steps:", 90,55,80,19, &step,1.0,180.0, 0, 0, "Specifies the total number of 'Spin' slices");
uiDefButS(block, NUM, B_DIFF, "Turns:", 170,55,85,19, &turn,1.0,360.0, 0, 0, "Specifies the number of revolutions the screw turns");
uiDefButBitS(block, TOG, B_KEEPORIG, B_DIFF, "Keep Original",10,35,160,19, &editbutflag, 0, 0, 0, 0, "Keeps a copy of the original vertices and faces after executing tools");
uiDefButBitS(block, TOG, B_CLOCKWISE, B_DIFF, "Clockwise", 170,35,85,19, &editbutflag, 0, 0, 0, 0, "Specifies the direction for 'Screw' and 'Spin'");
uiDefButS(block, NUM, B_DIFF, "Degr:", 10,55,80,19, &G.scene->toolsettings->degr,10.0,360.0, 0, 0, "Specifies the number of degrees 'Spin' revolves");
uiDefButS(block, NUM, B_DIFF, "Steps:", 90,55,80,19, &G.scene->toolsettings->step,1.0,180.0, 0, 0, "Specifies the total number of 'Spin' slices");
uiDefButS(block, NUM, B_DIFF, "Turns:", 170,55,85,19, &G.scene->toolsettings->turn,1.0,360.0, 0, 0, "Specifies the number of revolutions the screw turns");
uiDefButBitS(block, TOG, B_KEEPORIG, B_DIFF, "Keep Original",10,35,160,19, &G.scene->toolsettings->editbutflag, 0, 0, 0, 0, "Keeps a copy of the original vertices and faces after executing tools");
uiDefButBitS(block, TOG, B_CLOCKWISE, B_DIFF, "Clockwise", 170,35,85,19, &G.scene->toolsettings->editbutflag, 0, 0, 0, 0, "Specifies the direction for 'Screw' and 'Spin'");
uiBlockBeginAlign(block);
uiDefBut(block, BUT,B_EXTREP, "Extrude Dup", 10,10,120,19, 0, 0, 0, 0, 0, "Creates copies of the selected vertices in a straight line away from the current viewport");
uiDefButF(block, NUM, B_DIFF, "Offset:", 130,10,125,19, &extr_offs, 0.01, 100.0, 100, 0, "Sets the distance between each copy for 'Extrude Dup'");
uiDefButF(block, NUM, B_DIFF, "Offset:", 130,10,125,19, &G.scene->toolsettings->extr_offs, 0.01, 100.0, 100, 0, "Sets the distance between each copy for 'Extrude Dup'");
uiBlockEndAlign(block);
}

View File

@ -1506,7 +1506,6 @@ void snapmenu()
void mergemenu(void)
{
extern float doublimit;
short event;
event = pupmenu("Merge %t|At Center%x1|At Cursor%x2");
@ -1518,7 +1517,7 @@ void mergemenu(void)
else
snap_sel_to_curs(); /*Merge at Cursor*/
notice("Removed %d Vertices", removedoublesflag(1, doublimit));
notice("Removed %d Vertices", removedoublesflag(1, G.scene->toolsettings->doublimit));
allqueue(REDRAWVIEW3D, 0);
countall();
BIF_undo_push("Merge"); /* push the mesh down the undo pipe */

View File

@ -695,7 +695,6 @@ void extrude_repeat_mesh(int steps, float offs)
void spin_mesh(int steps,int degr,float *dvec, int mode)
{
extern short editbutflag;
EditMesh *em = G.editMesh;
EditVert *eve,*nextve;
float nor[3]= {0.0, 0.0, 0.0};
@ -719,7 +718,7 @@ void spin_mesh(int steps,int degr,float *dvec, int mode)
phi= (float)(degr*M_PI/360.0);
phi/= steps;
if(editbutflag & B_CLOCKWISE) phi= -phi;
if(G.scene->toolsettings->editbutflag & B_CLOCKWISE) phi= -phi;
if(dvec) {
n[0]=n[1]= 0.0;
@ -741,7 +740,7 @@ void spin_mesh(int steps,int degr,float *dvec, int mode)
Mat3MulMat3(tmat,cmat,bmat);
Mat3MulMat3(bmat,imat,tmat);
if(mode==0) if(editbutflag & B_KEEPORIG) adduplicateflag(1);
if(mode==0) if(G.scene->toolsettings->editbutflag & B_KEEPORIG) adduplicateflag(1);
ok= 1;
for(a=0;a<steps;a++) {
@ -2288,7 +2287,6 @@ void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype)
struct GHash *gh;
int i,j,edgecount,facetype,hold;
float length[4];
extern short cornertype;
//Set faces f1 to 0 cause we need it later
@ -2427,7 +2425,7 @@ void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype)
(ef->e2->f & flag && ef->e4->f & flag)){
fill_quad_double_op(ef, gh, numcuts);
}else{
switch(cornertype){
switch(G.scene->toolsettings->cornertype){
case 0: fill_quad_double_adj_path(ef, gh, numcuts); break;
case 1: fill_quad_double_adj_inner(ef, gh, numcuts); break;
case 2: fill_quad_double_adj_fan(ef, gh, numcuts); break;
@ -5350,7 +5348,6 @@ void subdivideflag(int flag, float rad, int beauty)
/* subdivide all with (vertflag & flag) */
/* if rad>0.0 it's a 'sphere' subdivide */
/* if rad<0.0 it's a fractal subdivide */
extern float doublimit;
EditVert *eve;
EditEdge *eed, *e1, *e2, *e3, *e4, *nexted;
EditFace *efa, efapin;
@ -5384,7 +5381,7 @@ void subdivideflag(int flag, float rad, int beauty)
/* area */
len1= AreaQ3Dfl(efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co);
if(len1 <= doublimit) {
if(len1 <= G.scene->toolsettings->doublimit) {
efa->e1->f2 = 0;
efa->e2->f2 = 0;
efa->e3->f2 = 0;
@ -5407,7 +5404,7 @@ void subdivideflag(int flag, float rad, int beauty)
else {
/* area */
len1= AreaT3Dfl(efa->v1->co, efa->v2->co, efa->v3->co);
if(len1 <= doublimit) {
if(len1 <= G.scene->toolsettings->doublimit) {
efa->e1->f2 = 0;
efa->e2->f2 = 0;
efa->e3->f2 = 0;

View File

@ -1882,8 +1882,6 @@ void split_font()
void special_editmenu(void)
{
Object *ob= OBACT;
extern short editbutflag;
extern float doublimit;
float fac;
int nr,ret;
short randfac,numcuts;
@ -2028,7 +2026,7 @@ void special_editmenu(void)
case 1:
numcuts = 1;
waitcursor(1);
esubdivideflag(1, 0.0, editbutflag,numcuts,0);
esubdivideflag(1, 0.0, G.scene->toolsettings->editbutflag,numcuts,0);
BIF_undo_push("ESubdivide Single");
break;
@ -2036,7 +2034,7 @@ void special_editmenu(void)
numcuts = 2;
if(button(&numcuts, 1, 128, "Number of Cuts:")==0) return;
waitcursor(1);
esubdivideflag(1, 0.0, editbutflag,numcuts,0);
esubdivideflag(1, 0.0, G.scene->toolsettings->editbutflag,numcuts,0);
BIF_undo_push("ESubdivide");
break;
case 3:
@ -2046,7 +2044,7 @@ void special_editmenu(void)
randfac= 10;
if(button(&randfac, 1, 100, "Rand fac:")==0) return;
fac= -( (float)randfac )/100;
esubdivideflag(1, fac, editbutflag,numcuts,0);
esubdivideflag(1, fac, G.scene->toolsettings->editbutflag,numcuts,0);
BIF_undo_push("Subdivide Fractal");
break;
@ -2054,7 +2052,7 @@ void special_editmenu(void)
mergemenu();
break;
case 5:
notice("Removed %d Vertices", removedoublesflag(1, doublimit));
notice("Removed %d Vertices", removedoublesflag(1, G.scene->toolsettings->doublimit));
BIF_undo_push("Remove Doubles");
break;
case 6:
@ -2080,12 +2078,12 @@ void special_editmenu(void)
numcuts = 2;
if(button(&numcuts, 1, 128, "Number of Cuts:")==0) return;
waitcursor(1);
esubdivideflag(1, 0.0, editbutflag | B_SMOOTH,numcuts,0);
esubdivideflag(1, 0.0, G.scene->toolsettings->editbutflag | B_SMOOTH,numcuts,0);
BIF_undo_push("Subdivide Smooth");
break;
case 13:
waitcursor(1);
subdivideflag(1, 0.0, editbutflag | B_SMOOTH);
subdivideflag(1, 0.0, G.scene->toolsettings->editbutflag | B_SMOOTH);
BIF_undo_push("Subdivide Smooth");
break;
}

View File

@ -309,6 +309,8 @@ Scene *copy_scene(Scene *sce, int level)
scen->ed= NULL;
scen->radio= NULL;
scen->theDag= NULL;
scen->toolsettings= MEM_dupallocN(sce->toolsettings);
obase= sce->base.first;
base= scen->base.first;
@ -324,6 +326,7 @@ Scene *copy_scene(Scene *sce, int level)
/* level 1 */
G.scene= scen;
single_object_users(0);
/* camera */
@ -340,12 +343,12 @@ Scene *copy_scene(Scene *sce, int level)
single_tex_users_expand();
scen->radio= MEM_dupallocN(sce->radio);
}
clear_id_newpoins();
BPY_copy_scriptlink(&sce->scriptlink);
// make a private copy of the avicodecdata
if (sce->r.avicodecdata) {

View File

@ -2045,7 +2045,6 @@ static uiBlock *view3d_edit_propfalloffmenu(void *arg_unused)
void do_view3d_edit_mesh_verticesmenu(void *arg, int event)
{
extern float doublimit;
switch(event) {
@ -2053,7 +2052,7 @@ void do_view3d_edit_mesh_verticesmenu(void *arg, int event)
make_parent();
break;
case 1: /* remove doubles */
notice("Removed: %d", removedoublesflag(1, doublimit));
notice("Removed: %d", removedoublesflag(1, G.scene->toolsettings->doublimit));
break;
case 2: /* smooth */
vertexsmooth();
@ -2103,25 +2102,24 @@ static uiBlock *view3d_edit_mesh_verticesmenu(void *arg_unused)
void do_view3d_edit_mesh_edgesmenu(void *arg, int event)
{
extern short editbutflag;
float fac;
short randfac;
switch(event) {
case 0: /* subdivide smooth */
esubdivideflag(1, 0.0, editbutflag | B_SMOOTH,1,0);
esubdivideflag(1, 0.0, G.scene->toolsettings->editbutflag | B_SMOOTH,1,0);
BIF_undo_push("Subdivide Smooth");
break;
case 1: /*subdivide fractal */
randfac= 10;
if(button(&randfac, 1, 100, "Rand fac:")==0) return;
fac= -( (float)randfac )/100;
esubdivideflag(1, fac, editbutflag,1,0);
esubdivideflag(1, fac, G.scene->toolsettings->editbutflag,1,0);
BIF_undo_push("Subdivide Fractal");
break;
case 2: /* subdivide */
esubdivideflag(1, 0.0, editbutflag,1,0);
esubdivideflag(1, 0.0, G.scene->toolsettings->editbutflag,1,0);
BIF_undo_push("Subdivide");
break;
case 3: /* knife subdivide */