svn merge -r 13357:13382 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / source / blender / src / buttons_object.c
index a064e266d6d8c15aa2394f5e9ee80f9f91983ab5..0b30f0b3cbaa846acf8600ad6126faa12a21d3a6 100644 (file)
@@ -604,13 +604,27 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
                uiBlockBeginAlign(block);
                        uiBlockSetEmboss(block, UI_EMBOSS);
                        
-                       if (prev_proxylock == 0) {
+                       if ((prev_proxylock) || (con->prev==NULL)) {
+                               /* don't draw 'button' behind arrow if disabled (and button doesn't do anything anyways) */
+                               uiBlockSetEmboss(block, UI_EMBOSSN);
+                               uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, VICON_MOVE_UP, *xco+width-50, *yco, 16, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Move constraint up in constraint stack");
+                               uiBlockSetEmboss(block, UI_EMBOSS);
+                       }
+                       else {
                                but = uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, VICON_MOVE_UP, *xco+width-50, *yco, 16, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Move constraint up in constraint stack");
                                uiButSetFunc(but, constraint_moveUp, ob, con);
                        }
                        
-                       but = uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, VICON_MOVE_DOWN, *xco+width-50+18, *yco, 16, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Move constraint down in constraint stack");
-                       uiButSetFunc(but, constraint_moveDown, ob, con);
+                       if (con->next) {
+                               but = uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, VICON_MOVE_DOWN, *xco+width-50+18, *yco, 16, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Move constraint down in constraint stack");
+                               uiButSetFunc(but, constraint_moveDown, ob, con);
+                       }
+                       else {
+                               /* don't draw 'button' behind arrow if no next constraint (it doesn't do anything anyways) */
+                               uiBlockSetEmboss(block, UI_EMBOSSN);
+                               uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, VICON_MOVE_DOWN, *xco+width-50+18, *yco, 16, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Move constraint down in constraint stack");
+                               uiBlockSetEmboss(block, UI_EMBOSS);
+                       }
                uiBlockEndAlign(block);
                
                
@@ -3472,7 +3486,7 @@ static char sbsolvers[] = "SIF  semi implicit euler with fixed step size (worth
 static char sbsolvers[] = "SOFT  step size controlled midpoint(1rst choice for real softbodies)%x0";
 #endif
 
-static void object_softbodies_II(Object *ob)
+static void object_softbodies_collision(Object *ob)
 {
        SoftBody *sb=ob->soft;
        uiBlock *block;
@@ -3487,9 +3501,9 @@ static void object_softbodies_II(Object *ob)
                ob->pd->pdef_sbift  = 0.2f;
                ob->pd->pdef_sboft  = 0.02f;
        }
-       block= uiNewBlock(&curarea->uiblocks, "object_softbodies_II", UI_EMBOSS, UI_HELV, curarea->win);
-       uiNewPanelTabbed("Soft Body", "Physics");
-       if(uiNewPanel(curarea, block, "Soft Body Col&Solv", "Physics", 651, 0, 318, 204)==0) return;
+       block= uiNewBlock(&curarea->uiblocks, "object_softbodies_collision", UI_EMBOSS, UI_HELV, curarea->win);
+       // uiNewPanelTabbed("Soft Body", "Physics"); /*don't really want it tabbed first */
+       if(uiNewPanel(curarea, block, "Soft Body Collision", "Physics", 651, 0, 318, 204)==0) return;
 
        uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
 
@@ -3562,9 +3576,10 @@ static void object_softbodies_II(Object *ob)
                        uiBlockEndAlign(block);
                        /*SOLVER SETTINGS*/
                        uiBlockBeginAlign(block);
+                       /* done in another panel now*/
+                       /*
                        uiDefButS(block, MENU, B_SOFTBODY_CHANGE, sbsolvers,10,100,50,20, &sb->solver_ID, 14.0, 0.0, 0, 0, "Select Solver");
-                       /*some have adapive step size - some not*/
-                       sb->solver_ID = 0; /* ugly hack to prepare peach freeze */
+                       sb->solver_ID = 0; 
                        switch (sb->solver_ID) {
                        case 0:
                        case 1:
@@ -3593,6 +3608,7 @@ static void object_softbodies_II(Object *ob)
                                uiDefButS(block, NUM, B_DIFF, "Steps:", 10,80,100,20, &sb->minloops,  1.00,  30000.0, 10, 0, "Solver steps/frame ");
                                uiDefButS(block, NUM, B_DIFF, "Choke:", 210,80,100,20, &sb->choke, 0.00,  100.0, 10, 0, "'Viscosity' inside collision target ");
                        }
+                       */
 
 
                }
@@ -3610,6 +3626,103 @@ static void object_softbodies_II(Object *ob)
        }
        uiBlockEndAlign(block);
 }
+static void object_softbodies_solver(Object *ob)
+{
+       SoftBody *sb=ob->soft;
+       uiBlock *block;
+       static int val;
+       short *softflag=&ob->softflag, psys_cur=0, adaptive_mode=0;
+       int ob_has_hair=psys_ob_has_hair(ob);
+    if(!_can_softbodies_at_all(ob)) return;
+       block= uiNewBlock(&curarea->uiblocks, "object_softbodies_solver", UI_EMBOSS, UI_HELV, curarea->win);
+       if(uiNewPanel(curarea, block, "Soft Body Solver", "Physics", 651, 0, 318, 204)==0) return;
+
+       uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
+    /* doubt that is really needed here but for now */ 
+       if(ob_has_hair) {
+               if(PE_get_current_num(ob) >= 0) {
+                       ParticleSystem *psys = PE_get_current(ob);
+                       if(psys) {
+                               sb = psys->soft;
+                               softflag = &psys->softflag;
+                               psys_cur = 1;
+                       }
+               }
+       }
+
+       if(psys_cur) {
+               if(*softflag & OB_SB_ENABLE)
+                       val = 1;
+               else
+                       val = 0;
+       }
+       else
+               val = modifiers_isSoftbodyEnabled(ob);
+
+       if(!val) { 
+               uiDefBut(block, LABEL, 0, "",10,10,1,2, NULL, 0.0, 0, 0, 0, ""); /* tell UI we go to 10,10*/
+               if(psys_cur){
+                       uiDefBut(block, LABEL, 0, "Hair is not a softbody",10,190,300,20, NULL, 0.0, 0, 0, 0, ""); 
+               }
+               else {
+                       uiDefBut(block, LABEL, 0, "Object is not a softbody",10,190,300,20, NULL, 0.0, 0, 0, 0, ""); 
+               }
+       }
+       else{ 
+               if ((ob->type==OB_MESH)||(ob->type==OB_CURVE) ) {
+                       /*SOLVER SETTINGS*/
+                       uiBlockBeginAlign(block);
+                       uiDefBut(block, LABEL, 0, "Solver select",10,200,300,20, NULL, 0.0, 0, 0, 0, ""); 
+                       uiDefButS(block, MENU, B_SOFTBODY_CHANGE, sbsolvers,10,180,300,20, &sb->solver_ID, 14.0, 0.0, 0, 0, "Select Solver (choose 1 of 1 i was working on some other but failed *sigh* BM) ");
+                       uiBlockEndAlign(block);
+                       
+                       /*some have adapive step size - some not*/
+                       sb->solver_ID = 0; /* ugly hack to prepare peach freeze */
+                       switch (sb->solver_ID) {
+                       case 0:
+                       case 1:
+                               {adaptive_mode = 1; break;}
+                       case 3:
+                               {adaptive_mode = 0; break;}
+                       default: printf("SB_solver?\n"); // should never happen
+                       }
+                       if(adaptive_mode){
+                               uiBlockBeginAlign(block);
+                           uiDefBut(block, LABEL, 0, "Step size controls",10,160,300,20, NULL, 0.0, 0, 0, 0, "");
+                               uiDefButF(block, NUM, B_DIFF, "Error Lim:",     10,140,280,20, &sb->rklimit , 0.001, 10.0, 10, 0, "The Runge-Kutta ODE solver error limit, low value gives more precision, high values speed");
+                               uiDefButBitS(block, TOG, SBSO_OLDERR, B_DIFF,"V", 290,140,20,20, &sb->solverflags,  0,  0, 0, 0, "Use velocities for automagic step sizes");
+                               uiDefButS(block, NUM, B_DIFF, "MinS:", 10,120,150,20, &sb->minloops,  0.00,  30000.0, 10, 0, "Minimal # solver steps/frame ");
+                               uiDefButS(block, NUM, B_DIFF, "MaxS:", 160,120,150,20, &sb->maxloops,  0.00,  30000.0, 10, 0, "Maximal # solver steps/frame ");
+                               uiBlockEndAlign(block);
+
+                               uiBlockBeginAlign(block);
+                       uiDefBut(block, LABEL, 0, "Collision helpers",10,100,300,20, NULL, 0.0, 0, 0, 0, "");
+                               uiDefButS(block, NUM, B_DIFF, "Choke:", 10,80,150,20, &sb->choke, 0.00,  100.0, 10, 0, "'Viscosity' inside collision target ");
+                               uiDefButS(block, NUM, B_DIFF, "Fuzzy:", 160,80,150,20, &sb->fuzzyness,  1.00,  100.0, 10, 0, "Fuzzyness while on collision, high values make collsion handling faster but less stable");
+                               uiBlockEndAlign(block);
+                               
+                               uiBlockBeginAlign(block);
+                               uiDefBut(block, LABEL, 0, "Diagnosis stuff",10,60,300,20, NULL, 0.0, 0, 0, 0, "");
+                               uiDefButBitS(block, TOG, SBSO_MONITOR, B_DIFF,"Print Performance to Console", 10,40,300,20, &sb->solverflags,  0,  0, 0, 0, "Turn on SB diagnose console prints");                              
+                               uiBlockEndAlign(block);
+                       } 
+                       else{
+                               uiBlockEndAlign(block);
+                               uiBlockBeginAlign(block);
+                               uiDefButS(block, NUM, B_DIFF, "Fuzzy:", 210,100,90,20, &sb->fuzzyness,  1.00,  100.0, 10, 0, "Fuzzyness while on collision, high values make collsion handling faster but less stable");
+                               uiDefButBitS(block, TOG, SBSO_MONITOR, B_DIFF,"M", 290,100,20,20, &sb->solverflags,  0,  0, 0, 0, "Turn on SB diagnose console prints");
+                               uiBlockEndAlign(block);
+                               uiDefButS(block, NUM, B_DIFF, "Steps:", 10,80,100,20, &sb->minloops,  1.00,  30000.0, 10, 0, "Solver steps/frame ");
+                               uiDefButS(block, NUM, B_DIFF, "Choke:", 210,80,100,20, &sb->choke, 0.00,  100.0, 10, 0, "'Viscosity' inside collision target ");
+                       }
+
+       uiBlockEndAlign(block);
+
+               }
+               //uiDefBut(block, LABEL, 0, "",10,10,1,2, NULL, 0.0, 0, 0, 0, ""); /* tell UI we go to 10,10*/
+       }
+       uiBlockEndAlign(block);
+}
 
 static void sb_clear_cache(void *ob_v, void *actsoft_v)
 {
@@ -5149,7 +5262,8 @@ void physics_panels()
                        object_panel_deflection(ob);
                object_panel_fields(ob);
                object_softbodies(ob);
-               object_softbodies_II(ob);
+               object_softbodies_collision(ob);
+               object_softbodies_solver(ob);
                object_panel_cloth(ob);
                object_panel_cloth_II(ob);
                object_panel_fluidsim(ob);