softbody review
[blender.git] / source / blender / src / buttons_object.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. The Blender
10  * Foundation also sells licenses for use in proprietary software under
11  * the Blender License.  See http://www.blender.org/BL/ for information
12  * about this.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  *
23  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24  * All rights reserved.
25  *
26  * The Original Code is: all of this file.
27  *
28  * Contributor(s): none yet.
29  *
30  * ***** END GPL/BL DUAL LICENSE BLOCK *****
31  */
32
33 #include <time.h>
34 #include <math.h>
35 #include <stdlib.h>
36 #include <string.h>
37
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #include "MEM_guardedalloc.h"
43
44 #include "DNA_ID.h"
45 #include "DNA_screen_types.h"
46 #include "DNA_space_types.h"
47 #include "DNA_scene_types.h"
48
49 #include "BKE_action.h"
50 #include "BKE_global.h"
51 #include "BKE_main.h"
52 #include "BKE_library.h"
53 #include "BKE_softbody.h"
54 #include "BKE_utildefines.h"
55
56 #include "BLI_blenlib.h"
57 #include "BLI_arithb.h"
58
59 #include "BSE_filesel.h"
60 #include "BSE_headerbuttons.h"
61
62 #include "BIF_butspace.h"
63 #include "BIF_editaction.h"
64 #include "BIF_gl.h"
65 #include "BIF_glutil.h"
66 #include "BIF_graphics.h"
67 #include "BIF_interface.h"
68 #include "BIF_keyval.h"
69 #include "BIF_mainqueue.h"
70 #include "BIF_mywindow.h"
71 #include "BIF_poseobject.h"
72 #include "BIF_resources.h"
73 #include "BIF_screen.h"
74 #include "BIF_space.h"
75 #include "BIF_toolbox.h"
76
77 #include "BDR_drawobject.h"
78 #include "BDR_editcurve.h"
79
80 #include "mydevice.h"
81 #include "blendef.h"
82
83 /* -----includes for this file specific----- */
84
85
86 #include "DNA_action_types.h"
87 #include "DNA_armature_types.h"
88 #include "DNA_camera_types.h"
89 #include "DNA_constraint_types.h"
90 #include "DNA_curve_types.h"
91 #include "DNA_effect_types.h"
92 #include "DNA_group_types.h"
93 #include "DNA_image_types.h"
94 #include "DNA_key_types.h"
95 #include "DNA_lamp_types.h"
96 #include "DNA_lattice_types.h"
97 #include "DNA_material_types.h"
98 #include "DNA_meta_types.h"
99 #include "DNA_mesh_types.h"
100 #include "DNA_modifier_types.h"
101 #include "DNA_object_types.h"
102 #include "DNA_object_force.h"
103 #include "DNA_object_fluidsim.h"
104 #include "DNA_radio_types.h"
105 #include "DNA_screen_types.h"
106 #include "DNA_sound_types.h"
107 #include "DNA_texture_types.h"
108 #include "DNA_userdef_types.h"
109 #include "DNA_vfont_types.h"
110 #include "DNA_view3d_types.h"
111 #include "DNA_world_types.h"
112
113 #include "BKE_anim.h"
114 #include "BKE_armature.h"
115 #include "BKE_constraint.h"
116 #include "BKE_curve.h"
117 #include "BKE_deform.h"
118 #include "BKE_depsgraph.h"
119 #include "BKE_displist.h"
120 #include "BKE_effect.h"
121 #include "BKE_font.h"
122 #include "BKE_group.h"
123 #include "BKE_image.h"
124 #include "BKE_ipo.h"
125 #include "BKE_lattice.h"
126 #include "BKE_material.h"
127 #include "BKE_mball.h"
128 #include "BKE_mesh.h"
129 #include "BKE_modifier.h"
130 #include "BKE_object.h"
131 #include "BKE_sound.h"
132 #include "BKE_texture.h"
133 #include "BKE_utildefines.h"
134 #include "BKE_DerivedMesh.h"
135
136 #include "LBM_fluidsim.h"
137 #include "elbeem.h"
138
139 #include "BIF_editconstraint.h"
140 #include "BIF_editdeform.h"
141
142 #include "BSE_editipo.h"
143 #include "BSE_edit.h"
144
145 #include "BDR_editobject.h"
146
147 #include "butspace.h" // own module
148
149 static float prspeed=0.0;
150 float prlen=0.0;
151
152
153 /* ********************* CONSTRAINT ***************************** */
154
155 static void constraint_active_func(void *ob_v, void *con_v)
156 {
157         Object *ob= ob_v;
158         bConstraint *con;
159         ListBase *lb;
160         
161         /* lets be nice and escape if its active already */
162         if(con_v) {
163                 con= con_v;
164                 if(con->flag & CONSTRAINT_ACTIVE) return;
165         }
166         
167         lb= get_active_constraints(ob);
168         
169         for(con= lb->first; con; con= con->next) {
170                 if(con==con_v) con->flag |= CONSTRAINT_ACTIVE;
171                 else con->flag &= ~CONSTRAINT_ACTIVE;
172         }
173
174         /* make sure ipowin and buttons shows it */
175         if(ob->ipowin==ID_CO) {
176                 allqueue(REDRAWIPO, ID_CO);
177                 allspace(REMAKEIPO, 0);
178                 allqueue(REDRAWNLA, 0);
179         }
180         allqueue(REDRAWBUTSOBJECT, 0);
181 }
182
183 static void add_constraint_to_active(Object *ob, bConstraint *con)
184 {
185         ListBase *list;
186         
187         list = get_active_constraints(ob);
188         if (list) {
189                 unique_constraint_name(con, list);
190                 BLI_addtail(list, con);
191                 
192                 con->flag |= CONSTRAINT_ACTIVE;
193                 for(con= con->prev; con; con= con->prev)
194                         con->flag &= ~CONSTRAINT_ACTIVE;
195         }
196 }
197
198 /* returns base ID for Ipo, sets actname to channel if appropriate */
199 /* should not make action... */
200 void get_constraint_ipo_context(void *ob_v, char *actname)
201 {
202         Object *ob= ob_v;
203         
204         /* todo; check object if it has ob-level action ipo */
205         
206         if (ob->flag & OB_POSEMODE) {
207                 bPoseChannel *pchan;
208                 
209                 pchan = get_active_posechannel(ob);
210                 if (pchan) {
211                         BLI_strncpy(actname, pchan->name, 32);
212                 }
213         }
214         else if(ob->ipoflag & OB_ACTION_OB)
215                 strcpy(actname, "Object");
216 }       
217
218 /* initialize UI to show Ipo window and make sure channels etc exist */
219 static void enable_constraint_ipo_func (void *ob_v, void *con_v)
220 {
221         Object *ob= ob_v;
222         bConstraint *con = con_v;
223         char actname[32]="";
224         
225         /* verifies if active constraint is set and shown in UI */
226         constraint_active_func(ob_v, con_v);
227         
228         /* the context */
229         get_constraint_ipo_context(ob, actname);
230         
231         /* adds ipo & channels & curve if needed */
232         verify_ipo((ID *)ob, ID_CO, actname, con->name);
233         
234         /* make sure ipowin shows it */
235         ob->ipowin= ID_CO;
236         allqueue(REDRAWIPO, ID_CO);
237         allspace(REMAKEIPO, 0);
238         allqueue(REDRAWNLA, 0);
239 }
240
241
242 static void add_influence_key_to_constraint_func (void *ob_v, void *con_v)
243 {
244         Object *ob= ob_v;
245         bConstraint *con = con_v;
246         IpoCurve *icu;
247         char actname[32]="";
248         
249         /* verifies if active constraint is set and shown in UI */
250         constraint_active_func(ob_v, con_v);
251         
252         /* the context */
253         get_constraint_ipo_context(ob, actname);
254
255         /* adds ipo & channels & curve if needed */
256         icu= verify_ipocurve((ID *)ob, ID_CO, actname, con->name, CO_ENFORCE);
257
258         if(ob->action)
259                 insert_vert_ipo(icu, get_action_frame(ob, (float)CFRA), con->enforce);
260         else
261                 insert_vert_ipo(icu, CFRA, con->enforce);
262         
263         /* make sure ipowin shows it */
264         ob->ipowin= ID_CO;
265         allqueue(REDRAWIPO, ID_CO);
266         allspace(REMAKEIPO, 0);
267         allqueue(REDRAWNLA, 0);
268         
269         BIF_undo_push("Insert Influence Key");
270 }
271
272 void del_constr_func (void *ob_v, void *con_v)
273 {
274         bConstraint *con= con_v;
275         bConstraintChannel *chan;
276         ListBase *lb;
277         
278         /* remove ipo channel */
279         lb= get_active_constraint_channels(ob_v, 0);
280         if(lb) {
281                 chan = get_constraint_channel(lb, con->name);
282                 if(chan) {
283                         if(chan->ipo) chan->ipo->id.us--;
284                         BLI_freelinkN(lb, chan);
285                 }
286         }
287         /* remove constraint itself */
288         lb= get_active_constraints(ob_v);
289         free_constraint_data (con);
290         BLI_freelinkN(lb, con);
291         
292         constraint_active_func(ob_v, NULL);
293 }
294
295 static void del_constraint_func (void *ob_v, void *con_v)
296 {
297         del_constr_func (ob_v, con_v);
298         BIF_undo_push("Delete constraint");
299         allqueue(REDRAWBUTSOBJECT, 0);
300         allqueue(REDRAWIPO, 0); 
301 }
302
303 static void verify_constraint_name_func (void *con_v, void *name_v)
304 {
305         Object *ob= OBACT;
306         bConstraint *con= con_v;
307         char oldname[32];       
308         
309         if (!con)
310                 return;
311         
312         /* put on the stack */
313         BLI_strncpy(oldname, (char *)name_v, 32);
314         
315         rename_constraint(ob, con, oldname);
316         
317         constraint_active_func(ob, con);
318         allqueue(REDRAWACTION, 0); 
319 }
320
321 void get_constraint_typestring (char *str, void *con_v)
322 {
323         bConstraint *con= con_v;
324
325         switch (con->type){
326         case CONSTRAINT_TYPE_CHILDOF:
327                 strcpy (str, "Child Of");
328                 return;
329         case CONSTRAINT_TYPE_NULL:
330                 strcpy (str, "Null");
331                 return;
332         case CONSTRAINT_TYPE_TRACKTO:
333                 strcpy (str, "Track To");
334                 return;
335         case CONSTRAINT_TYPE_MINMAX:
336                 strcpy (str, "Floor");
337                 return;
338         case CONSTRAINT_TYPE_KINEMATIC:
339                 strcpy (str, "IK Solver");
340                 return;
341         case CONSTRAINT_TYPE_ROTLIKE:
342                 strcpy (str, "Copy Rotation");
343                 return;
344         case CONSTRAINT_TYPE_LOCLIKE:
345                 strcpy (str, "Copy Location");
346                 return;
347         case CONSTRAINT_TYPE_SIZELIKE:
348                 strcpy (str, "Copy Scale");
349                 return;
350         case CONSTRAINT_TYPE_ACTION:
351                 strcpy (str, "Action");
352                 return;
353         case CONSTRAINT_TYPE_LOCKTRACK:
354                 strcpy (str, "Locked Track");
355                 return;
356         case CONSTRAINT_TYPE_FOLLOWPATH:
357                 strcpy (str, "Follow Path");
358                 return;
359         case CONSTRAINT_TYPE_STRETCHTO:
360                 strcpy (str, "Stretch To");
361                 return;
362         case CONSTRAINT_TYPE_LOCLIMIT:
363                 strcpy (str, "Limit Location");
364                 return;
365         case CONSTRAINT_TYPE_ROTLIMIT:
366                 strcpy (str, "Limit Rotation");
367                 return;
368         case CONSTRAINT_TYPE_SIZELIMIT:
369                 strcpy (str, "Limit Scale");
370                 return;
371         default:
372                 strcpy (str, "Unknown");
373                 return;
374         }
375 }
376
377 static int get_constraint_col(bConstraint *con)
378 {
379         switch (con->type) {
380         case CONSTRAINT_TYPE_NULL:
381                 return TH_BUT_NEUTRAL;
382         case CONSTRAINT_TYPE_KINEMATIC:
383                 return TH_BUT_SETTING2;
384         case CONSTRAINT_TYPE_TRACKTO:
385                 return TH_BUT_SETTING;
386         case CONSTRAINT_TYPE_ROTLIKE:
387                 return TH_BUT_SETTING1;
388         case CONSTRAINT_TYPE_LOCLIKE:
389                 return TH_BUT_POPUP;
390         case CONSTRAINT_TYPE_MINMAX:
391                 return TH_BUT_POPUP;
392         case CONSTRAINT_TYPE_SIZELIKE:
393                 return TH_BUT_POPUP;
394         case CONSTRAINT_TYPE_ACTION:
395                 return TH_BUT_ACTION;
396         case CONSTRAINT_TYPE_LOCKTRACK:
397                 return TH_BUT_SETTING;
398         case CONSTRAINT_TYPE_FOLLOWPATH:
399                 return TH_BUT_SETTING2;
400         case CONSTRAINT_TYPE_STRETCHTO:
401                 return TH_BUT_SETTING;
402         case CONSTRAINT_TYPE_LOCLIMIT:
403                 return TH_BUT_POPUP;
404         case CONSTRAINT_TYPE_ROTLIMIT:
405                 return TH_BUT_POPUP;
406         case CONSTRAINT_TYPE_SIZELIMIT:
407                 return TH_BUT_POPUP;
408         default:
409                 return TH_REDALERT;
410         }
411 }
412
413 void const_moveUp(void *ob_v, void *con_v)
414 {
415         bConstraint *con, *constr= con_v;
416         ListBase *conlist;
417         
418         if(constr->prev) {
419                 conlist = get_active_constraints(ob_v);
420                 for(con= conlist->first; con; con= con->next) {
421                         if(con==constr) {
422                                 BLI_remlink(conlist, con);
423                                 BLI_insertlink(conlist, con->prev->prev, con);
424                                 break;
425                         }
426                 }
427         }
428 }
429
430 static void constraint_moveUp(void *ob_v, void *con_v)
431 {
432         const_moveUp(ob_v, con_v);
433         BIF_undo_push("Move constraint");
434 }
435
436 void const_moveDown(void *ob_v, void *con_v)
437 {
438         bConstraint *con, *constr= con_v;
439         ListBase *conlist;
440         
441         if(constr->next) {
442                 conlist = get_active_constraints(ob_v);
443                 for(con= conlist->first; con; con= con->next) {
444                         if(con==constr) {
445                                 BLI_remlink(conlist, con);
446                                 BLI_insertlink(conlist, con->next, con);
447                                 break;
448                         }
449                 }
450         }
451 }
452
453 static void constraint_moveDown(void *ob_v, void *con_v)
454 {
455         const_moveDown(ob_v, con_v);
456         BIF_undo_push("Move constraint");
457 }
458
459 /* autocomplete callback for  buttons */
460 void autocomplete_bone(char *str, void *arg_v)
461 {
462         Object *ob= (Object *)arg_v;
463         char truncate[40]= {0};
464         
465         if(ob==NULL || ob->pose==NULL) return;
466         
467         /* search if str matches the beginning of name */
468         if(str[0]) {
469                 bPoseChannel *pchan;
470                 
471                 for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
472                         int a;
473                         
474                         for(a=0; a<31; a++) {
475                                 if(str[a]==0 || str[a]!=pchan->name[a])
476                                         break;
477                         }
478                         /* found a match */
479                         if(str[a]==0) {
480                                 /* first match */
481                                 if(truncate[0]==0)
482                                         BLI_strncpy(truncate, pchan->name, 32);
483                                 else {
484                                         /* remove from truncate what is not in bone->name */
485                                         for(a=0; a<31; a++) {
486                                                 if(truncate[a]!=pchan->name[a])
487                                                         truncate[a]= 0;
488                                         }
489                                 }
490                         }
491                 }
492                 if(truncate[0])
493                         BLI_strncpy(str, truncate, 32);
494         }
495 }
496
497 /* autocomplete callback for buttons */
498 void autocomplete_vgroup(char *str, void *arg_v)
499 {
500         Object *ob= (Object *)arg_v;
501         char truncate[40]= {0};
502         
503         if(ob==NULL) return;
504         
505         /* search if str matches the beginning of a name */
506         if(str[0]) {
507                 bDeformGroup *dg;
508                 
509                 for(dg= ob->defbase.first; dg; dg= dg->next) {
510                         int a;
511                         if(dg->name==str) continue;
512                         
513                         for(a=0; a<31; a++) {
514                                 if(str[a]==0 || str[a]!=dg->name[a])
515                                         break;
516                         }
517                         /* found a match */
518                         if(str[a]==0) {
519                                 /* first match */
520                                 if(truncate[0]==0)
521                                         BLI_strncpy(truncate, dg->name, 32);
522                                 else {
523                                         /* remove from truncate what is not in bone->name */
524                                         for(a=0; a<31; a++) {
525                                                 if(truncate[a]!=dg->name[a])
526                                                         truncate[a]= 0;
527                                         }
528                                 }
529                         }
530                 }
531                 if(truncate[0])
532                         BLI_strncpy(str, truncate, 32);
533         }
534 }
535
536 static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, short *xco, short *yco)
537 {
538         Object *ob= OBACT, *target;
539         uiBut *but;
540         char typestr[64], *subtarget;
541         short height, width = 265, is_armature_target;
542         int curCol, rb_col;
543
544         target= get_constraint_target(con, &subtarget);
545         is_armature_target= (target && target->type==OB_ARMATURE);
546         
547         /* unless button has own callback, it adds this callback to button */
548         uiBlockSetFunc(block, constraint_active_func, ob, con);
549         
550         get_constraint_typestring (typestr, con);
551
552         curCol = get_constraint_col(con);
553
554         /* Draw constraint header */
555         uiBlockSetEmboss(block, UI_EMBOSSN);
556         
557         /* rounded header */
558         rb_col= (con->flag & CONSTRAINT_ACTIVE)?40:20;
559         uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-1, width+40, 22, NULL, 5.0, 0.0, 
560                          (con->flag & CONSTRAINT_EXPAND)?3:15 , rb_col-20, ""); 
561         
562         /* open/close */
563         uiDefIconButBitS(block, ICONTOG, CONSTRAINT_EXPAND, B_CONSTRAINT_TEST, ICON_DISCLOSURE_TRI_RIGHT, *xco-10, *yco, 20, 20, &con->flag, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Constraint");
564         
565         /* up down */
566         uiBlockSetEmboss(block, UI_EMBOSS);
567         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 modifier up in stack");
568         uiButSetFunc(but, constraint_moveUp, ob, con);
569         
570         but = uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, VICON_MOVE_DOWN, *xco+width-50+20, *yco, 16, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier down in stack");
571         uiButSetFunc(but, constraint_moveDown, ob, con);
572         
573         if (con->flag & CONSTRAINT_EXPAND) {
574                 
575                 if (con->flag & CONSTRAINT_DISABLE) {
576                         BIF_ThemeColor(TH_REDALERT);
577                         uiBlockSetCol(block, TH_REDALERT);
578                 }
579                 else
580                         BIF_ThemeColor(curCol);
581
582                 /*if (type==TARGET_BONE)
583                         but = uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Bone Constraint%t|Track To%x2|IK Solver%x3|Copy Rotation%x8|Copy Location%x9|Action%x12|Null%x0", *xco+20, *yco, 100, 20, &con->type, 0.0, 0.0, 0.0, 0.0, "Constraint type"); 
584                 else
585                         but = uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Object Constraint%t|Track To%x2|Copy Rotation%x8|Copy Location%x9|Null%x0", *xco+20, *yco, 100, 20, &con->type, 0.0, 0.0, 0.0, 0.0, "Constraint type"); 
586                 */
587                 uiBlockSetEmboss(block, UI_EMBOSS);
588                 
589                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+10, *yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
590                 
591                 but = uiDefBut(block, TEX, B_CONSTRAINT_TEST, "", *xco+120, *yco, 85, 18, con->name, 0.0, 29.0, 0.0, 0.0, "Constraint name"); 
592                 uiButSetFunc(but, verify_constraint_name_func, con, NULL);
593         }       
594         else{
595                 uiBlockSetEmboss(block, UI_EMBOSSN);
596
597                 if (con->flag & CONSTRAINT_DISABLE) {
598                         uiBlockSetCol(block, TH_REDALERT);
599                         BIF_ThemeColor(TH_REDALERT);
600                 }
601                 else
602                         BIF_ThemeColor(curCol);
603                 
604                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+10, *yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
605                 
606                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, con->name, *xco+120, *yco-1, 135, 19, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
607         }
608
609         uiBlockSetCol(block, TH_AUTO);  
610         
611         uiBlockSetEmboss(block, UI_EMBOSSN);
612         
613         but = uiDefIconBut(block, BUT, B_CONSTRAINT_CHANGETARGET, ICON_X, *xco+262, *yco, 19, 19, list, 0.0, 0.0, 0.0, 0.0, "Delete constraint");
614         uiButSetFunc(but, del_constraint_func, ob, con);
615
616         uiBlockSetEmboss(block, UI_EMBOSS);
617
618
619         /* Draw constraint data*/
620         if (!(con->flag & CONSTRAINT_EXPAND)) {
621                 (*yco)-=21;
622         }
623         else {
624                 switch (con->type){
625                 case CONSTRAINT_TYPE_ACTION:
626                         {
627                                 bActionConstraint *data = con->data;
628
629                                 height = 88;
630                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
631                                 
632                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
633
634                                 /* Draw target parameters */
635                                 uiBlockBeginAlign(block);
636                                 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
637
638                                 if (is_armature_target){
639                                         but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
640                                         uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
641                                 }
642                                 else
643                                         strcpy (data->subtarget, "");
644                                 uiBlockEndAlign(block);
645
646                                 /* Draw action button */
647                                 uiBlockBeginAlign(block);
648                                 uiDefButS(block, TOG, B_CONSTRAINT_TEST, "Local",                                               *xco+((width/2)-117), *yco-46, 78, 18, &data->local, 0, 0, 0, 0, "Use true local rotation difference");
649                                 uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, B_CONSTRAINT_TEST, "AC:",     *xco+((width/2)-117), *yco-64, 78, 18, &data->act, "Action containing the keyed motion for this bone"); 
650                                 uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Key on%t|X Rot%x0|Y Rot%x1|Z Rot%x2", *xco+((width/2)-117), *yco-84, 78, 18, &data->type, 0, 24, 0, 0, "Specify which transformation channel from the target is used to key the action");
651
652                                 uiBlockBeginAlign(block);
653                                 uiDefButI(block, NUM, B_CONSTRAINT_TEST, "Start:", *xco+((width/2)-36), *yco-64, 78, 18, &data->start, 1, MAXFRAME, 0.0, 0.0, "Starting frame of the keyed motion"); 
654                                 uiDefButI(block, NUM, B_CONSTRAINT_TEST, "End:", *xco+((width/2)-36), *yco-84, 78, 18, &data->end, 1, MAXFRAME, 0.0, 0.0, "Ending frame of the keyed motion"); 
655                                 
656                                 uiBlockBeginAlign(block);
657                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Min:", *xco+((width/2)+45), *yco-64, 78, 18, &data->min, -180, 180, 0, 0, "Minimum value for target channel range");
658                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Max:", *xco+((width/2)+45), *yco-84, 78, 18, &data->max, -180, 180, 0, 0, "Maximum value for target channel range");
659                                 uiBlockEndAlign(block);
660                         }
661                         break;
662                 case CONSTRAINT_TYPE_LOCLIKE:
663                         {
664                                 bLocateLikeConstraint *data = con->data;
665                                 
666                                 height = 66;
667                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
668
669                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
670
671                                 /* Draw target parameters */
672                                 uiBlockBeginAlign(block);
673                                 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
674
675                                 if (is_armature_target) {
676                                         but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
677                                         uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
678                                 }
679                                 else
680                                         strcpy (data->subtarget, "");
681                                 uiBlockEndAlign(block);
682                                 
683                                 /* Draw XYZ toggles */
684                                 uiBlockBeginAlign(block);
685                                 if (is_armature_target)
686                                         uiDefButBitS(block, TOG, CONSTRAINT_LOCAL, B_CONSTRAINT_TEST, "Local", *xco+((width/2)-98), *yco-64, 50, 18, &con->flag, 0, 24, 0, 0, "Work on a Pose's local transform");
687                                 but=uiDefButBitI(block, TOG, LOCLIKE_X, B_CONSTRAINT_TEST, "X", *xco+((width/2)-48), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy X component");
688                                 but=uiDefButBitI(block, TOG, LOCLIKE_Y, B_CONSTRAINT_TEST, "Y", *xco+((width/2)-16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Y component");
689                                 but=uiDefButBitI(block, TOG, LOCLIKE_Z, B_CONSTRAINT_TEST, "Z", *xco+((width/2)+16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Z component");
690                                 uiBlockEndAlign(block);
691                         }
692                         break;
693                 case CONSTRAINT_TYPE_ROTLIKE:
694                         {
695                                 bRotateLikeConstraint *data = con->data;
696                                 
697                                 /* also old files stuff... version patch is too much code! */
698                                 if(data->flag==0) data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z;
699                                 
700                                 height = 66;
701                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
702                                 
703                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
704
705                                 /* Draw target parameters */
706                                 uiBlockBeginAlign(block);
707                                 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
708
709                                 if (is_armature_target) {
710                                         but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
711                                         uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
712                                 }
713                                 else
714                                         strcpy (data->subtarget, "");
715                                 uiBlockEndAlign(block);
716                                 
717                                 /* Draw XYZ toggles */
718                                 uiBlockBeginAlign(block);
719                                 if (is_armature_target)
720                                         uiDefButBitS(block, TOG, CONSTRAINT_LOCAL, B_CONSTRAINT_TEST, "Local", *xco+((width/2)-98), *yco-64, 50, 18, &con->flag, 0, 24, 0, 0, "Work on a Pose's local transform");
721                                 uiDefButBitI(block, TOG, ROTLIKE_X, B_CONSTRAINT_TEST, "X", *xco+((width/2)-48), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy X component");
722                                 uiDefButBitI(block, TOG, ROTLIKE_Y, B_CONSTRAINT_TEST, "Y", *xco+((width/2)-16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Y component");
723                                 uiDefButBitI(block, TOG, ROTLIKE_Z, B_CONSTRAINT_TEST, "Z", *xco+((width/2)+16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Z component");
724                                 uiBlockEndAlign(block);
725                         }
726                         break;
727                 case CONSTRAINT_TYPE_SIZELIKE:
728                         {
729                                 bSizeLikeConstraint *data = con->data;
730                                 height = 66;
731                         
732                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
733
734                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
735
736                                 /* Draw target parameters */
737                                 uiBlockBeginAlign(block);
738                                 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
739                                 
740                                 if (is_armature_target) {
741                                         but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
742                                         uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
743                                 }
744                                 else
745                                         strcpy (data->subtarget, "");
746                                 uiBlockEndAlign(block);
747
748                                 /* Draw XYZ toggles */
749                                 uiBlockBeginAlign(block);
750                                 but=uiDefButI(block, TOG|BIT|0, B_CONSTRAINT_TEST, "X", *xco+((width/2)-48), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy X component");
751                                 but=uiDefButI(block, TOG|BIT|1, B_CONSTRAINT_TEST, "Y", *xco+((width/2)-16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Y component");
752                                 but=uiDefButI(block, TOG|BIT|2, B_CONSTRAINT_TEST, "Z", *xco+((width/2)+16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Z component");
753                                 uiBlockEndAlign(block);
754                         }
755                         break;
756                 case CONSTRAINT_TYPE_KINEMATIC:
757                         {
758                                 bKinematicConstraint *data = con->data;
759                                 
760                                 height = 111;
761                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
762                                 
763                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
764
765                                 /* Draw target parameters */
766                                 uiDefButBitS(block, TOG, CONSTRAINT_IK_ROT, B_CONSTRAINT_TEST, "Rot", *xco, *yco-24,60,19, &data->flag, 0, 0, 0, 0, "Chain follows rotation of target");
767                                 
768                                 uiBlockBeginAlign(block);
769                                 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 19, &data->tar, "Target Object"); 
770
771                                 if (is_armature_target) {
772                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,19, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
773                                         uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
774                                 }
775                                 else
776                                         strcpy (data->subtarget, "");
777         
778                                 uiBlockBeginAlign(block);
779                                 uiDefButBitS(block, TOG, CONSTRAINT_IK_TIP, B_CONSTRAINT_TEST, "Use Tip", *xco, *yco-64, 137, 19, &data->flag, 0, 0, 0, 0, "Include Bone's tip als last element in Chain");
780                                 uiDefButI(block, NUM, B_CONSTRAINT_TEST, "ChainLen:", *xco, *yco-84,137,19, &data->rootbone, 0, 255, 0, 0, "If not zero, the amount of bones in this chain");
781                                 
782                                 uiBlockBeginAlign(block);
783                                 uiDefButF(block, NUMSLI, B_CONSTRAINT_TEST, "PosW ", *xco+147, *yco-64, 137, 19, &data->weight, 0.01, 1.0, 2, 2, "For Tree-IK: weight of position control for this target");
784                                 uiDefButF(block, NUMSLI, B_CONSTRAINT_TEST, "RotW ", *xco+147, *yco-84, 137, 19, &data->orientweight, 0.01, 1.0, 2, 2, "For Tree-IK: Weight of orientation control for this target");
785
786                                 uiBlockBeginAlign(block);
787                                 uiDefButS(block, NUM, B_CONSTRAINT_TEST, "Iterations:", *xco, *yco-109, 137, 19, &data->iterations, 1, 10000, 0, 0, "Maximum number of solving iterations"); 
788                                 uiBlockBeginAlign(block);
789                                 uiDefButBitS(block, TOG, CONSTRAINT_IK_STRETCH, B_CONSTRAINT_TEST, "Stretch", *xco+147, *yco-109,137,19, &data->flag, 0, 0, 0, 0, "Enable IK stretching");
790                                 
791                         }
792                         break;
793                 case CONSTRAINT_TYPE_TRACKTO:
794                         {
795                                 bTrackToConstraint *data = con->data;
796
797                                 height = 66;
798                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
799                                 
800                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
801
802                                 /* Draw target parameters */
803                                 uiBlockBeginAlign(block);
804                                 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
805
806                                 if (is_armature_target) {
807                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
808                                         uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
809                                 }
810                                 else
811                                         strcpy (data->subtarget, "");
812                                 uiBlockEndAlign(block);
813
814                                 uiBlockBeginAlign(block);
815                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "To:", *xco+12, *yco-64, 25, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
816                                 
817                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X",     *xco+39, *yco-64,17,18, &data->reserved1, 12.0, 0.0, 0, 0, "The axis that points to the target object");
818                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y",     *xco+56, *yco-64,17,18, &data->reserved1, 12.0, 1.0, 0, 0, "The axis that points to the target object");
819                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z",     *xco+73, *yco-64,17,18, &data->reserved1, 12.0, 2.0, 0, 0, "The axis that points to the target object");
820                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-X",    *xco+90, *yco-64,24,18, &data->reserved1, 12.0, 3.0, 0, 0, "The axis that points to the target object");
821                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Y",    *xco+114, *yco-64,24,18, &data->reserved1, 12.0, 4.0, 0, 0, "The axis that points to the target object");
822                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Z",    *xco+138, *yco-64,24,18, &data->reserved1, 12.0, 5.0, 0, 0, "The axis that points to the target object");
823                                 uiBlockEndAlign(block);
824                                 
825                                 uiBlockBeginAlign(block);
826                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Up:", *xco+174, *yco-64, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
827                                 
828                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X",     *xco+204, *yco-64,17,18, &data->reserved2, 13.0, 0.0, 0, 0, "The axis that points upward");
829                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y",     *xco+221, *yco-64,17,18, &data->reserved2, 13.0, 1.0, 0, 0, "The axis that points upward");
830                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z",     *xco+238, *yco-64,17,18, &data->reserved2, 13.0, 2.0, 0, 0, "The axis that points upward");
831                                 uiBlockEndAlign(block);
832                         }
833                         break;
834                 case CONSTRAINT_TYPE_MINMAX:
835                         {
836                                 bMinMaxConstraint *data = con->data;
837
838                                 height = 66;
839                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
840                                 
841                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
842
843                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Offset:", *xco, *yco-44, 100, 18, &data->offset, -100, 100, 100.0, 0.0, "Offset from the position of the object center"); 
844
845                                 /* Draw target parameters */
846                                 uiBlockBeginAlign(block);
847                                 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
848
849                                 if (is_armature_target) {
850                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
851                                         uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
852                                 }
853                                 else
854                                         strcpy (data->subtarget, "");
855                                 uiBlockEndAlign(block);
856
857                                 but=uiDefButI(block, TOG|BIT|0, B_CONSTRAINT_TEST, "Sticky", *xco, *yco-24, 44, 18, &data->flag, 0, 24, 0, 0, "Immobilize object while constrained");
858                                 but=uiDefButI(block, TOG|BIT|2, B_CONSTRAINT_TEST, "Use Rot", *xco+44, *yco-24, 64, 18, &data->flag, 0, 24, 0, 0, "Use target object rotation");
859                                 
860                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Max/Min:", *xco-8, *yco-64, 54, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
861
862                                 uiBlockBeginAlign(block);                       
863                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X",     *xco+51, *yco-64,17,18, &data->minmaxflag, 12.0, 0.0, 0, 0, "Will not pass below X of target");
864                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y",     *xco+67, *yco-64,17,18, &data->minmaxflag, 12.0, 1.0, 0, 0, "Will not pass below Y of target");
865                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z",     *xco+85, *yco-64,17,18, &data->minmaxflag, 12.0, 2.0, 0, 0, "Will not pass below Z of target");
866                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-X",    *xco+102, *yco-64,24,18, &data->minmaxflag, 12.0, 3.0, 0, 0, "Will not pass above X of target");
867                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Y",    *xco+126, *yco-64,24,18, &data->minmaxflag, 12.0, 4.0, 0, 0, "Will not pass above Y of target");
868                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Z",    *xco+150, *yco-64,24,18, &data->minmaxflag, 12.0, 5.0, 0, 0, "Will not pass above Z of target");
869                                 uiBlockEndAlign(block);
870                         }
871                         break;
872                 case CONSTRAINT_TYPE_LOCKTRACK:
873                         {
874                                 bLockTrackConstraint *data = con->data;
875                                 height = 66;
876                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
877
878                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
879
880                                 /* Draw target parameters */
881                                 uiBlockBeginAlign(block);
882                                 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
883
884                                 if (is_armature_target) {
885                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
886                                         uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
887                                 }
888                                 else
889                                         strcpy (data->subtarget, "");
890                                 uiBlockEndAlign(block);
891                                 
892                                 uiBlockBeginAlign(block);
893                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "To:", *xco+12, *yco-64, 25, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
894                                 
895                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X",     *xco+39, *yco-64,17,18, &data->trackflag, 12.0, 0.0, 0, 0, "The axis that points to the target object");
896                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y",     *xco+56, *yco-64,17,18, &data->trackflag, 12.0, 1.0, 0, 0, "The axis that points to the target object");
897                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z",     *xco+73, *yco-64,17,18, &data->trackflag, 12.0, 2.0, 0, 0, "The axis that points to the target object");
898                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-X",    *xco+90, *yco-64,24,18, &data->trackflag, 12.0, 3.0, 0, 0, "The axis that points to the target object");
899                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Y",    *xco+114, *yco-64,24,18, &data->trackflag, 12.0, 4.0, 0, 0, "The axis that points to the target object");
900                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Z",    *xco+138, *yco-64,24,18, &data->trackflag, 12.0, 5.0, 0, 0, "The axis that points to the target object");
901                                 uiBlockEndAlign(block);
902                                 
903                                 uiBlockBeginAlign(block);
904                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Lock:", *xco+166, *yco-64, 38, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
905                                 
906                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X",     *xco+204, *yco-64,17,18, &data->lockflag, 13.0, 0.0, 0, 0, "The axis that is locked");
907                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y",     *xco+221, *yco-64,17,18, &data->lockflag, 13.0, 1.0, 0, 0, "The axis that is locked");
908                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z",     *xco+238, *yco-64,17,18, &data->lockflag, 13.0, 2.0, 0, 0, "The axis that is locked");
909                                 uiBlockEndAlign(block);
910                         }
911                         break;
912                 case CONSTRAINT_TYPE_FOLLOWPATH:
913                         {
914                                 bFollowPathConstraint *data = con->data;
915
916                                 height = 66;
917                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
918                                 
919                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
920
921                                 /* Draw target parameters */
922                                 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
923                                 
924                                 /* Draw Curve Follow toggle */
925                                 but=uiDefButBitI(block, TOG, 1, B_CONSTRAINT_TEST, "CurveFollow", *xco+39, *yco-44, 100, 18, &data->followflag, 0, 24, 0, 0, "Object will follow the heading and banking of the curve");
926
927                                 /* Draw Offset number button */
928                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Offset:", *xco+155, *yco-44, 100, 18, &data->offset, -MAXFRAMEF, MAXFRAMEF, 100.0, 0.0, "Offset from the position corresponding to the time frame"); 
929
930                                 uiBlockBeginAlign(block);
931                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Fw:", *xco+12, *yco-64, 27, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
932                                 
933                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X",     *xco+39, *yco-64,17,18, &data->trackflag, 12.0, 0.0, 0, 0, "The axis that points forward along the path");
934                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y",     *xco+56, *yco-64,17,18, &data->trackflag, 12.0, 1.0, 0, 0, "The axis that points forward along the path");
935                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z",     *xco+73, *yco-64,17,18, &data->trackflag, 12.0, 2.0, 0, 0, "The axis that points forward along the path");
936                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-X",    *xco+90, *yco-64,24,18, &data->trackflag, 12.0, 3.0, 0, 0, "The axis that points forward along the path");
937                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Y",    *xco+114, *yco-64,24,18, &data->trackflag, 12.0, 4.0, 0, 0, "The axis that points forward along the path");
938                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Z",    *xco+138, *yco-64,24,18, &data->trackflag, 12.0, 5.0, 0, 0, "The axis that points forward along the path");
939                                 uiBlockEndAlign(block);
940                                 
941                                 uiBlockBeginAlign(block);
942                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Up:", *xco+174, *yco-64, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
943                                 
944                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X",     *xco+204, *yco-64,17,18, &data->upflag, 13.0, 0.0, 0, 0, "The axis that points upward");
945                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y",     *xco+221, *yco-64,17,18, &data->upflag, 13.0, 1.0, 0, 0, "The axis that points upward");
946                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z",     *xco+238, *yco-64,17,18, &data->upflag, 13.0, 2.0, 0, 0, "The axis that points upward");
947                                 uiBlockEndAlign(block);
948                         }
949                         break;
950                 case CONSTRAINT_TYPE_STRETCHTO:
951                         {
952                                 bStretchToConstraint *data = con->data;
953                                 
954                                 height = 105;
955                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
956                                 
957                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
958
959                                 /* Draw target parameters */
960                                 uiBlockBeginAlign(block);
961                                 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
962
963                                 if (is_armature_target) {
964                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
965                                         uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
966                                 }
967                                 else
968                                         strcpy (data->subtarget, "");
969                                 uiBlockEndAlign(block);
970
971                                 
972                                 uiBlockBeginAlign(block);
973                                 uiDefButF(block,BUTM,B_CONSTRAINT_TEST,"R",*xco, *yco-60,20,18,&(data->orglength),0.0,0,0,0,"Recalculate RLength");
974                                 uiDefButF(block,NUM,B_CONSTRAINT_TEST,"Rest Length:",*xco+18, *yco-60,237,18,&(data->orglength),0.0,100,0.5,0.5,"Length at Rest Position");
975                                 uiBlockEndAlign(block);
976
977                                 uiDefButF(block,NUM,B_CONSTRAINT_TEST,"Volume Variation:",*xco+18, *yco-82,237,18,&(data->bulge),0.0,100,0.5,0.5,"Factor between volume variation and stretching");
978
979                                 uiBlockBeginAlign(block);
980                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Vol:",*xco+14, *yco-104,30,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
981                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"XZ",     *xco+44, *yco-104,30,18, &data->volmode, 12.0, 0.0, 0, 0, "Keep Volume: Scaling X & Z");
982                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X",      *xco+74, *yco-104,20,18, &data->volmode, 12.0, 1.0, 0, 0, "Keep Volume: Scaling X");
983                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z",      *xco+94, *yco-104,20,18, &data->volmode, 12.0, 2.0, 0, 0, "Keep Volume: Scaling Z");
984                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"NONE", *xco+114, *yco-104,50,18, &data->volmode, 12.0, 3.0, 0, 0, "Ignore Volume");
985                                 uiBlockEndAlign(block);
986
987                                 
988                                 uiBlockBeginAlign(block);
989                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"Plane:",*xco+175, *yco-104,40,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
990                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X",       *xco+215, *yco-104,20,18, &data->plane, 12.0, 0.0, 0, 0, "Keep X axis");
991                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z",       *xco+235, *yco-104,20,18, &data->plane, 12.0, 2.0, 0, 0, "Keep Z axis");
992                                 uiBlockEndAlign(block);
993                                 }
994                         break;
995                 case CONSTRAINT_TYPE_LOCLIMIT:
996                         {
997                                 bLocLimitConstraint *data = con->data;
998                                 
999                                 int togButWidth = 50;
1000                                 int textButWidth = ((width/2)-togButWidth);
1001                                 
1002                                 height = 118; 
1003                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
1004                                 
1005                                 /* Draw Pairs of LimitToggle+LimitValue */
1006                                 uiBlockBeginAlign(block); 
1007                                 uiDefButBitS(block, TOG, LIMIT_XMIN, B_CONSTRAINT_TEST, "minX", *xco, *yco-28, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x value"); 
1008                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-28, (textButWidth-5), 18, &(data->xmin), -1000, 1000, 0.1,0.5,"Lowest x value to allow"); 
1009                                 uiBlockEndAlign(block); 
1010                                 
1011                                 uiBlockBeginAlign(block); 
1012                                 uiDefButBitS(block, TOG, LIMIT_XMAX, B_CONSTRAINT_TEST, "maxX", *xco+(width-(textButWidth-5)-togButWidth), *yco-28, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum x value"); 
1013                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-28, (textButWidth-5), 18, &(data->xmax), -1000, 1000, 0.1,0.5,"Highest x value to allow"); 
1014                                 uiBlockEndAlign(block); 
1015                                 
1016                                 uiBlockBeginAlign(block); 
1017                                 uiDefButBitS(block, TOG, LIMIT_YMIN, B_CONSTRAINT_TEST, "minY", *xco, *yco-50, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y value"); 
1018                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-50, (textButWidth-5), 18, &(data->ymin), -1000, 1000, 0.1,0.5,"Lowest y value to allow"); 
1019                                 uiBlockEndAlign(block);
1020                                 
1021                                 uiBlockBeginAlign(block); 
1022                                 uiDefButBitS(block, TOG, LIMIT_YMAX, B_CONSTRAINT_TEST, "maxY", *xco+(width-(textButWidth-5)-togButWidth), *yco-50, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum y value"); 
1023                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-50, (textButWidth-5), 18, &(data->ymax), -1000, 1000, 0.1,0.5,"Highest y value to allow"); 
1024                                 uiBlockEndAlign(block); 
1025                                 
1026                                 uiBlockBeginAlign(block); 
1027                                 uiDefButBitS(block, TOG, LIMIT_ZMIN, B_CONSTRAINT_TEST, "minZ", *xco, *yco-72, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z value"); 
1028                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-72, (textButWidth-5), 18, &(data->zmin), -1000, 1000, 0.1,0.5,"Lowest z value to allow"); 
1029                                 uiBlockEndAlign(block);
1030                                 
1031                                 uiBlockBeginAlign(block); 
1032                                 uiDefButBitS(block, TOG, LIMIT_ZMAX, B_CONSTRAINT_TEST, "maxZ", *xco+(width-(textButWidth-5)-togButWidth), *yco-72, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum z value"); 
1033                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-72, (textButWidth-5), 18, &(data->zmax), -1000, 1000, 0.1,0.5,"Highest z value to allow"); 
1034                                 uiBlockEndAlign(block);
1035                                 
1036                                 uiBlockBeginAlign(block);
1037                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"Co-ordinate Space:",*xco, *yco-100,150,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1038                                 
1039                                 if (ob->type == OB_ARMATURE && (ob->flag & OB_POSEMODE))
1040                                         uiDefButBitS(block, TOG, CONSTRAINT_LOCAL, B_CONSTRAINT_TEST, "Local", *xco+160, *yco-100, 60, 18, &con->flag, 0, 24, 0, 0, "Limit locations relative to the bone's rest-position");
1041                                 else if (ob->parent != NULL)
1042                                         uiDefButBitS(block, TOG, LIMIT_NOPARENT, B_CONSTRAINT_TEST, "Local", *xco+160, *yco-100, 60, 18, &data->flag2, 0, 24, 0, 0, "Limit locations relative to parent, not origin/world");
1043                                 else 
1044                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"World",*xco+160, *yco-100,60,18, NULL, 0.0, 0.0, 0.0, 0.0, "Limit locations relative to origin/world"); 
1045                                 
1046                                 uiBlockEndAlign(block);
1047                         }
1048                         break;
1049                 case CONSTRAINT_TYPE_ROTLIMIT:
1050                         {
1051                                 bRotLimitConstraint *data = con->data;
1052                                 
1053                                 int normButWidth = (width/3);
1054                                 
1055                                 height = 118; 
1056                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
1057                                 
1058                                 /* Draw Pairs of LimitToggle+LimitValue */
1059                                 uiBlockBeginAlign(block); 
1060                                 uiDefButBitS(block, TOG, LIMIT_XROT, B_CONSTRAINT_TEST, "LimitX", *xco, *yco-28, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Limit rotation on x-axis"); 
1061                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min:", *xco+normButWidth, *yco-28, normButWidth, 18, &(data->xmin), -360, 360, 0.1,0.5,"Lowest x value to allow"); 
1062                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max:", *xco+(normButWidth * 2), *yco-28, normButWidth, 18, &(data->xmax), -360, 360, 0.1,0.5,"Highest x value to allow"); 
1063                                 uiBlockEndAlign(block); 
1064                                 
1065                                 uiBlockBeginAlign(block); 
1066                                 uiDefButBitS(block, TOG, LIMIT_YROT, B_CONSTRAINT_TEST, "LimitY", *xco, *yco-50, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Limit rotation on y-axis"); 
1067                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min:", *xco+normButWidth, *yco-50, normButWidth, 18, &(data->ymin), -360, 360, 0.1,0.5,"Lowest y value to allow"); 
1068                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max:", *xco+(normButWidth * 2), *yco-50, normButWidth, 18, &(data->ymax), -360, 360, 0.1,0.5,"Highest y value to allow"); 
1069                                 uiBlockEndAlign(block); 
1070                                 
1071                                 uiBlockBeginAlign(block); 
1072                                 uiDefButBitS(block, TOG, LIMIT_ZROT, B_CONSTRAINT_TEST, "LimitZ", *xco, *yco-72, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Limit rotation on z-axis"); 
1073                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min:", *xco+normButWidth, *yco-72, normButWidth, 18, &(data->zmin), -360, 360, 0.1,0.5,"Lowest z value to allow"); 
1074                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max:", *xco+(normButWidth * 2), *yco-72, normButWidth, 18, &(data->zmax), -360, 360, 0.1,0.5,"Highest z value to allow"); 
1075                                 uiBlockEndAlign(block); 
1076                                 
1077                                 if (ob->type == OB_ARMATURE && (ob->flag & OB_POSEMODE)) {
1078                                         uiBlockBeginAlign(block);
1079                                         uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"Co-ordinate Space:",*xco, *yco-100,150,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
1080                                         uiDefButBitS(block, TOG, CONSTRAINT_LOCAL, B_CONSTRAINT_TEST, "Local", *xco+160, *yco-100, 60, 18, &con->flag, 0, 24, 0, 0, "Work on a Pose's local transform");
1081                                         uiBlockEndAlign(block);
1082                                 }
1083                         }
1084                         break;
1085                 case CONSTRAINT_TYPE_SIZELIMIT:
1086                         {
1087                                 bSizeLimitConstraint *data = con->data;
1088                                 
1089                                 int togButWidth = 50;
1090                                 int textButWidth = ((width/2)-togButWidth);
1091                                 
1092                                 height = 90; 
1093                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
1094                                 
1095                                 /* Draw Pairs of LimitToggle+LimitValue */
1096                                 uiBlockBeginAlign(block); 
1097                                 uiDefButBitS(block, TOG, LIMIT_XMIN, B_CONSTRAINT_TEST, "minX", *xco, *yco-28, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x value"); 
1098                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-28, (textButWidth-5), 18, &(data->xmin), 0.0001, 1000, 0.1,0.5,"Lowest x value to allow"); 
1099                                 uiBlockEndAlign(block); 
1100
1101                                 uiBlockBeginAlign(block); 
1102                                 uiDefButBitS(block, TOG, LIMIT_XMAX, B_CONSTRAINT_TEST, "maxX", *xco+(width-(textButWidth-5)-togButWidth), *yco-28, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum x value"); 
1103                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-28, (textButWidth-5), 18, &(data->xmax), 0.0001, 1000, 0.1,0.5,"Highest x value to allow"); 
1104                                 uiBlockEndAlign(block); 
1105
1106
1107                                 uiBlockBeginAlign(block); 
1108                                 uiDefButBitS(block, TOG, LIMIT_YMIN, B_CONSTRAINT_TEST, "minY", *xco, *yco-50, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y value"); 
1109                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-50, (textButWidth-5), 18, &(data->ymin), 0.0001, 1000, 0.1,0.5,"Lowest y value to allow"); 
1110                                 uiBlockEndAlign(block); 
1111
1112                                 uiBlockBeginAlign(block); 
1113                                 uiDefButBitS(block, TOG, LIMIT_YMAX, B_CONSTRAINT_TEST, "maxY", *xco+(width-(textButWidth-5)-togButWidth), *yco-50, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum y value"); 
1114                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-50, (textButWidth-5), 18, &(data->ymax), 0.0001, 1000, 0.1,0.5,"Highest y value to allow"); 
1115                                 uiBlockEndAlign(block); 
1116
1117
1118                                 uiBlockBeginAlign(block); 
1119                                 uiDefButBitS(block, TOG, LIMIT_ZMIN, B_CONSTRAINT_TEST, "minZ", *xco, *yco-72, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z value"); 
1120                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-72, (textButWidth-5), 18, &(data->zmin), 0.0001, 1000, 0.1,0.5,"Lowest z value to allow"); 
1121                                 uiBlockEndAlign(block); 
1122
1123                                 uiBlockBeginAlign(block); 
1124                                 uiDefButBitS(block, TOG, LIMIT_ZMAX, B_CONSTRAINT_TEST, "maxZ", *xco+(width-(textButWidth-5)-togButWidth), *yco-72, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum z value"); 
1125                                 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-72, (textButWidth-5), 18, &(data->zmax), 0.0001, 1000, 0.1,0.5,"Highest z value to allow"); 
1126                                 uiBlockEndAlign(block);
1127                         }
1128                         break;
1129                 case CONSTRAINT_TYPE_NULL:
1130                         {
1131                                 height = 17;
1132                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
1133                                 
1134                         }
1135                         break;
1136                 default:
1137                         height = 0;
1138                         break;
1139                 }
1140
1141                 (*yco)-=(24+height);
1142         }
1143
1144         if (con->type!=CONSTRAINT_TYPE_NULL) {
1145                 uiBlockBeginAlign(block);
1146                 uiDefButF(block, NUMSLI, B_CONSTRAINT_INF, "Influence ", *xco, *yco, 197, 20, &(con->enforce), 0.0, 1.0, 0.0, 0.0, "Amount of influence this constraint will have on the final solution");
1147                 but = uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Show", *xco+200, *yco, 45, 20, 0, 0.0, 1.0, 0.0, 0.0, "Show constraint's ipo in the Ipo window, adds a channel if not there");
1148                 /* If this is on an object or bone, add ipo channel the constraint */
1149                 uiButSetFunc (but, enable_constraint_ipo_func, ob, con);
1150                 but = uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Key", *xco+245, *yco, 40, 20, 0, 0.0, 1.0, 0.0, 0.0, "Add an influence keyframe to the constraint");
1151                 /* Add a keyframe to the influence IPO */
1152                 uiButSetFunc (but, add_influence_key_to_constraint_func, ob, con);
1153                 uiBlockEndAlign(block);
1154                 (*yco)-=24;
1155         } else {
1156                 (*yco)-=3;
1157         }
1158         
1159 }
1160
1161 static uiBlock *add_constraintmenu(void *arg_unused)
1162 {
1163         Object *ob= OBACT;
1164         uiBlock *block;
1165         ListBase *conlist;
1166         short yco= 0;
1167         
1168         conlist = get_active_constraints(ob);
1169         
1170         block= uiNewBlock(&curarea->uiblocks, "add_constraintmenu", UI_EMBOSSP, UI_HELV, curarea->win);
1171
1172         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_LOCLIKE,"Copy Location",         0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1173         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_ROTLIKE,"Copy Rotation",         0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1174         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_SIZELIKE,"Copy Scale",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1175         
1176         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1177         
1178         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_LOCLIMIT,"Limit Location",               0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1179         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_ROTLIMIT,"Limit Rotation",               0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1180         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_SIZELIMIT,"Limit Scale",                 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1181         
1182         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1183         
1184         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_TRACKTO,"Track To",              0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1185         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_MINMAX,"Floor",          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1186         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_LOCKTRACK,"Locked Track",                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1187         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_FOLLOWPATH,"Follow Path",                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1188         
1189         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1190         
1191         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_STRETCHTO,"Stretch To",          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1192
1193         if (ob->flag & OB_POSEMODE) {
1194                 uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1195                 
1196                 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_KINEMATIC,"IK Solver",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1197                 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_ACTION,"Action",         0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1198                 
1199         }
1200         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1201
1202         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_NULL,"Null",             0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1203         
1204         uiTextBoundsBlock(block, 50);
1205         uiBlockSetDirection(block, UI_DOWN);
1206                 
1207         return block;
1208 }
1209
1210 void do_constraintbuts(unsigned short event)
1211 {
1212         Object *ob= OBACT;
1213         
1214         switch(event) {
1215         case B_CONSTRAINT_TEST:
1216                 break;  // no handling
1217         case B_CONSTRAINT_INF:
1218                 /* influence; do not execute actions for 1 dag_flush */
1219                 if(ob->pose)
1220                         ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK);
1221
1222         case B_CONSTRAINT_CHANGETARGET:
1223                 if(ob->pose) ob->pose->flag |= POSE_RECALC;     // checks & sorts pose channels
1224                 DAG_scene_sort(G.scene);
1225                 break;
1226                 
1227         case B_CONSTRAINT_ADD_NULL:
1228                 {
1229                         bConstraint *con;
1230                         
1231                         con = add_new_constraint(CONSTRAINT_TYPE_NULL);
1232                         add_constraint_to_active(ob, con);
1233
1234                         BIF_undo_push("Add constraint");
1235                 }
1236                 break;
1237         case B_CONSTRAINT_ADD_KINEMATIC:
1238                 {
1239                         bConstraint *con;
1240                         
1241                         con = add_new_constraint(CONSTRAINT_TYPE_KINEMATIC);
1242                         add_constraint_to_active(ob, con);
1243
1244                         BIF_undo_push("Add constraint");
1245                 }
1246                 break;
1247         case B_CONSTRAINT_ADD_TRACKTO:
1248                 {
1249                         bConstraint *con;
1250
1251                         con = add_new_constraint(CONSTRAINT_TYPE_TRACKTO);
1252                         add_constraint_to_active(ob, con);
1253
1254                         BIF_undo_push("Add constraint");
1255                 }
1256                 break;
1257         case B_CONSTRAINT_ADD_MINMAX:
1258                 {
1259                         bConstraint *con;
1260
1261                         con = add_new_constraint(CONSTRAINT_TYPE_MINMAX);
1262                         add_constraint_to_active(ob, con);
1263
1264                         BIF_undo_push("Add constraint");
1265                 }
1266                 break;
1267         case B_CONSTRAINT_ADD_ROTLIKE:
1268                 {
1269                         bConstraint *con;
1270
1271                         con = add_new_constraint(CONSTRAINT_TYPE_ROTLIKE);
1272                         add_constraint_to_active(ob, con);
1273
1274                         BIF_undo_push("Add constraint");
1275                 }
1276                 break;
1277         case B_CONSTRAINT_ADD_LOCLIKE:
1278                 {
1279                         bConstraint *con;
1280
1281                         con = add_new_constraint(CONSTRAINT_TYPE_LOCLIKE);
1282                         add_constraint_to_active(ob, con);
1283
1284                         BIF_undo_push("Add constraint");
1285                 }
1286                 break;
1287         case B_CONSTRAINT_ADD_SIZELIKE:
1288                 {
1289                         bConstraint *con;
1290  
1291                         con = add_new_constraint(CONSTRAINT_TYPE_SIZELIKE);
1292                         add_constraint_to_active(ob, con);
1293   
1294                         BIF_undo_push("Add constraint");
1295                 }
1296                 break;
1297         case B_CONSTRAINT_ADD_ACTION:
1298                 {
1299                         bConstraint *con;
1300
1301                         con = add_new_constraint(CONSTRAINT_TYPE_ACTION);
1302                         add_constraint_to_active(ob, con);
1303
1304                         BIF_undo_push("Add constraint");
1305                 }
1306                 break;
1307         case B_CONSTRAINT_ADD_LOCKTRACK:
1308                 {
1309                         bConstraint *con;
1310
1311                         con = add_new_constraint(CONSTRAINT_TYPE_LOCKTRACK);
1312                         add_constraint_to_active(ob, con);
1313
1314                         BIF_undo_push("Add constraint");
1315                 }
1316                 break;
1317         case B_CONSTRAINT_ADD_FOLLOWPATH:
1318                 {
1319                         bConstraint *con;
1320
1321                         con = add_new_constraint(CONSTRAINT_TYPE_FOLLOWPATH);
1322                         add_constraint_to_active(ob, con);
1323
1324                 }
1325                 break;
1326         case B_CONSTRAINT_ADD_STRETCHTO:
1327                 {
1328                         bConstraint *con;
1329                         con = add_new_constraint(CONSTRAINT_TYPE_STRETCHTO);
1330                         add_constraint_to_active(ob, con);
1331                                 
1332                         BIF_undo_push("Add constraint");
1333                 }
1334                 break;
1335         case B_CONSTRAINT_ADD_LOCLIMIT:
1336                 {
1337                         bConstraint *con;
1338
1339                         con = add_new_constraint(CONSTRAINT_TYPE_LOCLIMIT);
1340                         add_constraint_to_active(ob, con);
1341
1342                         BIF_undo_push("Add constraint");
1343                 }
1344                 break;
1345         case B_CONSTRAINT_ADD_ROTLIMIT:
1346                 {
1347                         bConstraint *con;
1348
1349                         con = add_new_constraint(CONSTRAINT_TYPE_ROTLIMIT);
1350                         add_constraint_to_active(ob, con);
1351
1352                         BIF_undo_push("Add constraint");
1353                 }
1354                 break;
1355         case B_CONSTRAINT_ADD_SIZELIMIT:
1356                 {
1357                         bConstraint *con;
1358
1359                         con = add_new_constraint(CONSTRAINT_TYPE_SIZELIMIT);
1360                         add_constraint_to_active(ob, con);
1361
1362                         BIF_undo_push("Add constraint");
1363                 }
1364                 break;
1365
1366         default:
1367                 break;
1368         }
1369
1370         object_test_constraints(ob);
1371         
1372         if(ob->pose) update_pose_constraint_flags(ob->pose);
1373         
1374         if(ob->type==OB_ARMATURE) DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA|OB_RECALC_OB);
1375         else DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
1376         
1377         allqueue (REDRAWVIEW3D, 0);
1378         allqueue (REDRAWBUTSOBJECT, 0);
1379 }
1380
1381 void softbody_bake(Object *ob)
1382 {
1383         Base *base;
1384         SoftBody *sb;
1385         ScrArea *sa;
1386         float frameleno= G.scene->r.framelen;
1387         int cfrao= CFRA, sfra=100000, efra=0;
1388         unsigned short event=0;
1389         short val;
1390         
1391         G.scene->r.framelen= 1.0;               // baking has to be in uncorrected time
1392         
1393         if(ob) {
1394                 sb= ob->soft;
1395                 sfra= MIN2(sfra, sb->sfra);
1396                 efra= MAX2(efra, sb->efra);
1397                 sbObjectToSoftbody(ob); // put softbody in restposition, free bake
1398                 ob->softflag |= OB_SB_BAKEDO;
1399         }
1400         else {
1401                 for(base=G.scene->base.first; base; base= base->next) {
1402                         if(TESTBASE(base)) {
1403                                 if(base->object->soft) {
1404                                         sb= base->object->soft;
1405                                         sfra= MIN2(sfra, sb->sfra);
1406                                         efra= MAX2(efra, sb->efra);
1407                                         sbObjectToSoftbody(base->object);       // put softbody in restposition, free bake
1408                                         base->object->softflag |= OB_SB_BAKEDO;
1409                                 }
1410                         }
1411                 }
1412         }
1413         
1414         CFRA= sfra;
1415         update_for_newframe_muted();    // put everything on this frame
1416         
1417         curarea->win_swap= 0;           // clean swapbuffers
1418         
1419         for(; CFRA <= efra; CFRA++) {
1420                 set_timecursor(CFRA);
1421                 
1422                 update_for_newframe_muted();
1423                 
1424                 for(sa= G.curscreen->areabase.first; sa; sa= sa->next) {
1425                         if(sa->spacetype == SPACE_VIEW3D) {
1426                                 scrarea_do_windraw(sa);
1427                         }
1428                 }
1429                 screen_swapbuffers();
1430                 
1431                 while(qtest()) {
1432                         
1433                         event= extern_qread(&val);
1434                         if(event==ESCKEY) break;
1435                 }
1436                 if(event==ESCKEY) break;
1437         }
1438         
1439         if(event==ESCKEY) {
1440                 if(ob) 
1441                         sbObjectToSoftbody(ob); // free bake
1442                 else {
1443                         for(base=G.scene->base.first; base; base= base->next) {
1444                                 if(TESTBASE(base)) {
1445                                         if(base->object->soft) {
1446                                                 sbObjectToSoftbody(base->object);       // free bake
1447                                         }
1448                                 }
1449                         }
1450                 }
1451         }
1452         
1453         /* restore */
1454         waitcursor(0);
1455         
1456         if(ob) 
1457                 ob->softflag &= ~OB_SB_BAKEDO;
1458         else {
1459                 for(base=G.scene->base.first; base; base= base->next)
1460                         if(TESTBASE(base))
1461                                 if(base->object->soft)
1462                                         base->object->softflag &= ~OB_SB_BAKEDO;
1463         }
1464         
1465         CFRA= cfrao;
1466         G.scene->r.framelen= frameleno;
1467         update_for_newframe_muted();
1468         allqueue(REDRAWVIEW3D, 0);
1469         allqueue(REDRAWBUTSOBJECT, 0);
1470 }
1471
1472 // store processed path & file prefix for fluidsim bake directory
1473 void fluidsimFilesel(char *selection)
1474 {
1475         Object *ob = OBACT;
1476         char srcDir[FILE_MAXDIR+FILE_MAXFILE], srcFile[FILE_MAXFILE];
1477         char prefix[FILE_MAXFILE];
1478         char *srch, *srchSub, *srchExt, *lastFound;
1479         int isElbeemSurf = 0;
1480
1481         // make prefix
1482         strcpy(srcDir, selection);
1483         BLI_splitdirstring(srcDir, srcFile);
1484         strcpy(prefix, srcFile);
1485         // check if this is a previously generated surface mesh file
1486         srch = strstr(prefix, "fluidsurface_");
1487         // TODO search from back...
1488         if(srch) {
1489                 srchSub = strstr(prefix,"_preview_");
1490                 if(!srchSub) srchSub = strstr(prefix,"_final_");
1491                 srchExt = strstr(prefix,".gz.bobj");
1492                 if(!srchExt) srchExt = strstr(prefix,".bobj");
1493                 if(srchSub && srchExt) {
1494                         *srch = '\0';
1495                         isElbeemSurf = 1;
1496                 }
1497         }
1498         if(!isElbeemSurf) {
1499                 // try to remove suffix
1500                 lastFound = NULL;
1501                 srch = strchr(prefix, '.'); // search last . from extension
1502                 while(srch) {
1503                         lastFound = srch;
1504                         if(srch) {
1505                                 srch++;
1506                                 srch = strchr(srch, '.');
1507                         }
1508                 }
1509                 if(lastFound) {
1510                         *lastFound = '\0';
1511                 } 
1512         }
1513
1514         if(ob->fluidsimSettings) {
1515                 strcpy(ob->fluidsimSettings->surfdataPath, srcDir);
1516                 //not necessary? strcat(ob->fluidsimSettings->surfdataPath, "/");
1517                 strcat(ob->fluidsimSettings->surfdataPath, prefix);
1518
1519                 // redraw view & buttons...
1520                 allqueue(REDRAWBUTSOBJECT, 0);
1521                 allqueue(REDRAWVIEW3D, 0);
1522                 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1523         }
1524 }
1525
1526 void do_object_panels(unsigned short event)
1527 {
1528         Object *ob;
1529         Effect *eff;
1530         
1531         ob= OBACT;
1532
1533         switch(event) {
1534         case B_TRACKBUTS:
1535                 ob= OBACT;
1536                 DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
1537                 allqueue(REDRAWVIEW3D, 0);
1538                 break;
1539         case B_RECALCPATH:
1540                 DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
1541                 allqueue(REDRAWVIEW3D, 0);
1542                 break;
1543         case B_PRINTSPEED:
1544                 ob= OBACT;
1545                 if(ob) {
1546                         float vec[3];
1547                         CFRA++;
1548                         do_ob_ipo(ob);
1549                         where_is_object(ob);
1550                         VECCOPY(vec, ob->obmat[3]);
1551                         CFRA--;
1552                         do_ob_ipo(ob);
1553                         where_is_object(ob);
1554                         VecSubf(vec, vec, ob->obmat[3]);
1555                         prspeed= Normalise(vec);
1556                         scrarea_queue_winredraw(curarea);
1557                 }
1558                 break;
1559         case B_PRINTLEN:
1560                 ob= OBACT;
1561                 if(ob && ob->type==OB_CURVE) {
1562                         Curve *cu=ob->data;
1563                         
1564                         if(cu->path) prlen= cu->path->totdist; else prlen= -1.0;
1565                         scrarea_queue_winredraw(curarea);
1566                 } 
1567                 break;
1568         case B_RELKEY:
1569                 allspace(REMAKEIPO, 0);
1570                 allqueue(REDRAWBUTSOBJECT, 0);
1571                 allqueue(REDRAWBUTSEDIT, 0);
1572                 allqueue(REDRAWIPO, 0);
1573                 DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
1574                 break;
1575         case B_CURVECHECK:
1576                 DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
1577                 allqueue(REDRAWVIEW3D, 0);
1578                 break;
1579         
1580         case B_SOFTBODY_CHANGE:
1581                 ob= OBACT;
1582                 if(ob) {
1583                         ob->softflag |= OB_SB_REDO;
1584                         allqueue(REDRAWBUTSOBJECT, 0);
1585                         allqueue(REDRAWVIEW3D, 0);
1586                 }
1587                 break;
1588         case B_SOFTBODY_DEL_VG:
1589                 ob= OBACT;
1590                 if(ob && ob->soft) {
1591                         ob->soft->vertgroup= 0;
1592                         ob->softflag |= OB_SB_REDO;
1593                         allqueue(REDRAWBUTSOBJECT, 0);
1594                         allqueue(REDRAWVIEW3D, 0);
1595                 }
1596                 break;
1597         case B_SOFTBODY_BAKE:
1598                 ob= OBACT;
1599                 if(ob && ob->soft) softbody_bake(ob);
1600                 break;
1601         case B_SOFTBODY_BAKE_FREE:
1602                 ob= OBACT;
1603                 if(ob && ob->soft) sbObjectToSoftbody(ob);
1604                 allqueue(REDRAWBUTSOBJECT, 0);
1605                 allqueue(REDRAWVIEW3D, 0);
1606                 break;
1607         case B_FLUIDSIM_BAKE:
1608                 ob= OBACT;
1609                 /* write config files (currently no simulation) */
1610                 fluidsimBake(ob);
1611                 break;
1612         case B_FLUIDSIM_MAKEPART:
1613                 ob= OBACT;
1614                 if(1) {
1615                         PartEff *paf= NULL;
1616                         /* prepare fluidsim particle display */
1617                         // simplified delete effect, create new - recalc some particles...
1618                         if(ob==NULL || ob->type!=OB_MESH) break;
1619                         ob->fluidsimSettings->type = 0;
1620                         // reset type, and init particle system once normally
1621                         paf= give_parteff(ob); 
1622                         if( (BLI_countlist(&ob->effect)<MAX_EFFECT) && 
1623                             (!paf)) { 
1624                                 // create new entry
1625                                 copy_act_effect(ob); DAG_scene_sort(G.scene); }
1626                         paf = give_parteff(ob);
1627                         if(paf) {
1628                                 paf->totpart = 1000; paf->sta = paf->end = 1.0; // generate some particles...
1629                                 build_particle_system(ob);
1630                                 ob->fluidsimSettings->type = OB_FLUIDSIM_PARTICLE;
1631                         }
1632                 }
1633                 allqueue(REDRAWVIEW3D, 0);
1634                 allqueue(REDRAWBUTSOBJECT, 0);
1635                 break;
1636         case B_FLUIDSIM_SELDIR: {
1637                         ScrArea *sa = closest_bigger_area();
1638                         ob= OBACT;
1639                         /* choose dir for surface files */
1640                         areawinset(sa->win);
1641                         activate_fileselect(FILE_SPECIAL, "Select Directory", ob->fluidsimSettings->surfdataPath, fluidsimFilesel);
1642                 }
1643                 break;
1644         case B_FLUIDSIM_FORCEREDRAW:
1645                 /* force redraw */
1646                 allqueue(REDRAWBUTSOBJECT, 0);
1647                 allqueue(REDRAWVIEW3D, 0);
1648                 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1649                 break;
1650         case B_GROUP_RELINK:
1651                 group_relink_nla_objects(OBACT);
1652                 allqueue(REDRAWVIEW3D, 0);
1653                 break;
1654                 
1655         default:
1656                 if(event>=B_SELEFFECT && event<B_SELEFFECT+MAX_EFFECT) {
1657                         ob= OBACT;
1658                         if(ob) {
1659                                 int a=B_SELEFFECT;
1660                                 
1661                                 eff= ob->effect.first;
1662                                 while(eff) {
1663                                         if(event==a) eff->flag |= SELECT;
1664                                         else eff->flag &= ~SELECT;
1665                                         
1666                                         a++;
1667                                         eff= eff->next;
1668                                 }
1669                                 allqueue(REDRAWBUTSOBJECT, 0);
1670                         }
1671                 }
1672         }
1673
1674 }
1675
1676 static void do_add_groupmenu(void *arg, int event)
1677 {
1678         Object *ob= OBACT;
1679         
1680         if(ob) {
1681                 
1682                 if(event== -1) {
1683                         Group *group= add_group();
1684                         add_to_group(group, ob);
1685                 }
1686                 else
1687                         add_to_group(BLI_findlink(&G.main->group, event), ob);
1688                         
1689                 ob->flag |= OB_FROMGROUP;
1690                 BASACT->flag |= OB_FROMGROUP;
1691                 allqueue(REDRAWBUTSOBJECT, 0);
1692                 allqueue(REDRAWVIEW3D, 0);
1693         }               
1694 }
1695
1696 static uiBlock *add_groupmenu(void *arg_unused)
1697 {
1698         uiBlock *block;
1699         Group *group;
1700         short yco= 0;
1701         char str[32];
1702         
1703         block= uiNewBlock(&curarea->uiblocks, "add_constraintmenu", UI_EMBOSSP, UI_HELV, curarea->win);
1704         uiBlockSetButmFunc(block, do_add_groupmenu, NULL);
1705
1706         uiDefBut(block, BUTM, B_NOP, "ADD NEW",         0, 20, 160, 19, NULL, 0.0, 0.0, 1, -1, "");
1707         for(group= G.main->group.first; group; group= group->id.next, yco++) {
1708                 if(group->id.lib) strcpy(str, "L  ");
1709                 else strcpy(str, "   ");
1710                 strcat(str, group->id.name+2);
1711                 uiDefBut(block, BUTM, B_NOP, str,       0, -20*yco, 160, 19, NULL, 0.0, 0.0, 1, yco, "");
1712         }
1713         
1714         uiTextBoundsBlock(block, 50);
1715         uiBlockSetDirection(block, UI_DOWN);    
1716         
1717         return block;
1718 }
1719
1720 static void group_ob_rem(void *gr_v, void *ob_v)
1721 {
1722         Object *ob= OBACT;
1723         
1724         rem_from_group(gr_v, ob);
1725         if(find_group(ob)==NULL) {
1726                 ob->flag &= ~OB_FROMGROUP;
1727                 BASACT->flag &= ~OB_FROMGROUP;
1728         }
1729         allqueue(REDRAWBUTSOBJECT, 0);
1730         allqueue(REDRAWVIEW3D, 0);
1731
1732 }
1733
1734 static void group_local(void *gr_v, void *unused)
1735 {
1736         Group *group= gr_v;
1737         
1738         group->id.lib= NULL;
1739         
1740         allqueue(REDRAWBUTSOBJECT, 0);
1741         allqueue(REDRAWVIEW3D, 0);
1742         
1743 }
1744
1745 static void object_panel_object(Object *ob)
1746 {
1747         uiBlock *block;
1748         uiBut *but;
1749         Group *group;
1750         int a=0, xco;
1751         
1752         block= uiNewBlock(&curarea->uiblocks, "object_panel_object", UI_EMBOSS, UI_HELV, curarea->win);
1753         if(uiNewPanel(curarea, block, "Object and Links", "Object", 0, 0, 318, 204)==0) return;
1754         
1755         if(ob->id.lib) uiSetButLock(1, "Can't edit library data");
1756         
1757         /* object name */
1758         uiBlockSetCol(block, TH_BUT_SETTING2);
1759         xco= std_libbuttons(block, 10, 180, 0, NULL, 0, ID_OB, 0, &ob->id, NULL, &(G.buts->menunr), B_OBALONE, B_OBLOCAL, 0, 0, B_KEEPDATA);
1760         uiBlockSetCol(block, TH_AUTO);
1761         
1762         /* parent */
1763         uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_OBJECTPANELPARENT, "Par:", xco+5, 180, 305-xco, 20, &ob->parent, "Parent Object"); 
1764
1765         uiDefBlockBut(block, add_groupmenu, NULL, "Add to Group", 10,150,150,20, "Add Object to a new Group");
1766
1767         /* all groups */
1768         uiBlockBeginAlign(block);
1769         for(group= G.main->group.first; group; group= group->id.next) {
1770                 if(object_in_group(ob, group)) {
1771                         xco= 160;
1772                         
1773                         but = uiDefBut(block, TEX, B_IDNAME, "GR:",     10, 120-a, 150, 20, group->id.name+2, 0.0, 19.0, 0, 0, "Displays Group name. Click to change.");
1774                         uiButSetFunc(but, test_idbutton_cb, group->id.name, NULL);
1775                         
1776                         if(group->id.lib) {
1777                                 but= uiDefIconBut(block, BUT, B_NOP, ICON_PARLIB, 160, 120-a, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Make Group local");
1778                                 uiButSetFunc(but, group_local, group, NULL);
1779                                 xco= 180;
1780                         }
1781                         but = uiDefIconBut(block, BUT, B_NOP, VICON_X, xco, 120-a, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Remove Group membership");
1782                         uiButSetFunc(but, group_ob_rem, group, ob);
1783                         
1784                         a+= 20;
1785                 }
1786         }
1787 }
1788
1789 static void object_panel_anim(Object *ob)
1790 {
1791         uiBlock *block;
1792         char str[32];
1793         
1794         block= uiNewBlock(&curarea->uiblocks, "object_panel_anim", UI_EMBOSS, UI_HELV, curarea->win);
1795         if(uiNewPanel(curarea, block, "Anim settings", "Object", 320, 0, 318, 204)==0) return;
1796         
1797         if(ob->id.lib) uiSetButLock(1, "Can't edit library data");
1798         
1799         uiBlockBeginAlign(block);
1800         uiDefButS(block, ROW,B_TRACKBUTS,"TrackX",      24,180,59,19, &ob->trackflag, 12.0, 0.0, 0, 0, "Specify the axis that points to another object");
1801         uiDefButS(block, ROW,B_TRACKBUTS,"Y",           85,180,19,19, &ob->trackflag, 12.0, 1.0, 0, 0, "Specify the axis that points to another object");
1802         uiDefButS(block, ROW,B_TRACKBUTS,"Z",           104,180,19,19, &ob->trackflag, 12.0, 2.0, 0, 0, "Specify the axis that points to another object");
1803         uiDefButS(block, ROW,B_TRACKBUTS,"-X",          124,180,24,19, &ob->trackflag, 12.0, 3.0, 0, 0, "Specify the axis that points to another object");
1804         uiDefButS(block, ROW,B_TRACKBUTS,"-Y",          150,180,24,19, &ob->trackflag, 12.0, 4.0, 0, 0, "Specify the axis that points to another object");
1805         uiDefButS(block, ROW,B_TRACKBUTS,"-Z",          178,180,24,19, &ob->trackflag, 12.0, 5.0, 0, 0, "Specify the axis that points to another object");
1806         uiBlockBeginAlign(block);
1807         uiDefButS(block, ROW,REDRAWVIEW3D,"UpX",        226,180,45,19, &ob->upflag, 13.0, 0.0, 0, 0, "Specify the axis that points up");
1808         uiDefButS(block, ROW,REDRAWVIEW3D,"Y",          274,180,20,19, &ob->upflag, 13.0, 1.0, 0, 0, "Specify the axis that points up");
1809         uiDefButS(block, ROW,REDRAWVIEW3D,"Z",          298,180,19,19, &ob->upflag, 13.0, 2.0, 0, 0, "Specify the axis that points up");
1810         
1811         uiBlockBeginAlign(block);
1812         uiDefButBitS(block, TOG, OB_DRAWKEY, REDRAWVIEW3D, "Draw Key",          24,155,71,19, &ob->ipoflag, 0, 0, 0, 0, "Draw object as key position");
1813         uiDefButBitS(block, TOG, OB_DRAWKEYSEL, REDRAWVIEW3D, "Draw Key Sel",   97,155,81,19, &ob->ipoflag, 0, 0, 0, 0, "Limit the drawing of object keys");
1814         uiDefButBitS(block, TOG, OB_POWERTRACK, REDRAWVIEW3D, "Powertrack",             180,155,78,19, &ob->transflag, 0, 0, 0, 0, "Switch objects rotation off");
1815         uiDefButBitS(block, TOG, PARSLOW, 0, "SlowPar",                                 260,155,56,19, &ob->partype, 0, 0, 0, 0, "Create a delay in the parent relationship");
1816         uiBlockBeginAlign(block);
1817         
1818         uiDefButBitS(block, TOG, OB_DUPLIFRAMES, REDRAWVIEW3D, "DupliFrames",   24,130,89,20, &ob->transflag, 0, 0, 0, 0, "Make copy of object for every frame");
1819         uiDefButBitS(block, TOG, OB_DUPLIVERTS, REDRAWVIEW3D, "DupliVerts",             114,130,82,20, &ob->transflag, 0, 0, 0, 0, "Duplicate child objects on all vertices");
1820         uiDefButBitS(block, TOG, OB_DUPLIROT, REDRAWVIEW3D, "Rot",                              200,130,31,20, &ob->transflag, 0, 0, 0, 0, "Rotate dupli according to vertnormal");
1821         uiDefButBitS(block, TOG, OB_DUPLINOSPEED, REDRAWVIEW3D, "No Speed",             234,130,82,20, &ob->transflag, 0, 0, 0, 0, "Set dupliframes to still, regardless of frame");
1822         
1823         uiDefButBitS(block, TOG, OB_DUPLIGROUP, REDRAWVIEW3D, "DupliGroup",             24,110,150,20, &ob->transflag, 0, 0, 0, 0, "Enable group instancing");
1824         uiDefIDPoinBut(block, test_grouppoin_but, ID_GR, B_GROUP_RELINK, "GR:", 174,110,142,20, &ob->dup_group, "Instance an existing group");
1825
1826         uiBlockBeginAlign(block);
1827         /* DupSta and DupEnd are both shorts, so the maxframe is greater then their range
1828         just limit the buttons to the max short */
1829         uiDefButI(block, NUM, REDRAWVIEW3D, "DupSta:",          24,85,141,19, &ob->dupsta, 1.0, 32767, 0, 0, "Specify startframe for Dupliframes");
1830         uiDefButI(block, NUM, REDRAWVIEW3D, "DupOn:",           170,85,146,19, &ob->dupon, 1.0, 1500.0, 0, 0, "Specify the number of frames to use between DupOff frames");
1831         uiDefButI(block, NUM, REDRAWVIEW3D, "DupEnd",           24,65,140,19, &ob->dupend, 1.0, 32767, 0, 0, "Specify endframe for Dupliframes");
1832         uiDefButI(block, NUM, REDRAWVIEW3D, "DupOff",           171,65,145,19, &ob->dupoff, 0.0, 1500.0, 0, 0, "Specify recurring frames to exclude from the Dupliframes");
1833         uiBlockBeginAlign(block);
1834         uiDefButBitS(block, TOG, OB_OFFS_OB, REDRAWALL, "Offs Ob",                      24,35,56,20, &ob->ipoflag, 0, 0, 0, 0, "Not functional at the moment!");
1835         uiDefButBitS(block, TOG, OB_OFFS_PARENT, REDRAWALL, "Offs Par",                 82,35,56,20 , &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the parent");
1836         uiDefButBitS(block, TOG, OB_OFFS_PARTICLE, REDRAWALL, "Offs Particle",          140,35,103,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the particle effect");
1837         
1838         uiBlockBeginAlign(block);
1839         uiDefButF(block, NUM, REDRAWALL, "TimeOffset:",                 24,10,115,20, &ob->sf, -MAXFRAMEF, MAXFRAMEF, 100, 0, "Specify an offset in frames");
1840         uiDefBut(block, BUT, B_AUTOTIMEOFS, "Automatic Time",   139,10,104,20, 0, 0, 0, 0, 0, "Generate automatic timeoffset values for all selected frames");
1841         uiDefBut(block, BUT, B_PRINTSPEED,      "PrSpeed",                      248,10,67,20, 0, 0, 0, 0, 0, "Print objectspeed");
1842         uiBlockEndAlign(block);
1843         
1844         sprintf(str, "%.4f", prspeed);
1845         uiDefBut(block, LABEL, 0, str,                                                  247,35,63,31, NULL, 1.0, 0, 0, 0, "");
1846         
1847 }
1848
1849 static void object_panel_draw(Object *ob)
1850 {
1851         uiBlock *block;
1852         int xco, a, dx, dy;
1853         
1854         block= uiNewBlock(&curarea->uiblocks, "object_panel_draw", UI_EMBOSS, UI_HELV, curarea->win);
1855         if(uiNewPanel(curarea, block, "Draw", "Object", 640, 0, 318, 204)==0) return;
1856         
1857         if(ob->id.lib) uiSetButLock(1, "Can't edit library data");
1858         
1859         /* LAYERS */
1860         xco= 120;
1861         dx= 35;
1862         dy= 30;
1863         
1864         uiDefBut(block, LABEL, 0, "Layers",                             10,170,100,20, NULL, 0, 0, 0, 0, "");
1865         
1866         uiBlockBeginAlign(block);
1867         for(a=0; a<5; a++)
1868                 uiDefButBitI(block, TOG, 1<<a, B_OBLAY+a, "",   (short)(xco+a*(dx/2)), 180, (short)(dx/2), (short)(dy/2), &(BASACT->lay), 0, 0, 0, 0, "");
1869         for(a=0; a<5; a++)
1870                 uiDefButBitI(block, TOG, 1<<(a+10), B_OBLAY+a+10, "",   (short)(xco+a*(dx/2)), 165, (short)(dx/2), (short)(dy/2), &(BASACT->lay), 0, 0, 0, 0, "");
1871         
1872         xco+= 7;
1873         uiBlockBeginAlign(block);
1874         for(a=5; a<10; a++)
1875                 uiDefButBitI(block, TOG, 1<<a, B_OBLAY+a, "",   (short)(xco+a*(dx/2)), 180, (short)(dx/2), (short)(dy/2), &(BASACT->lay), 0, 0, 0, 0, "");
1876         for(a=5; a<10; a++)
1877                 uiDefButBitI(block, TOG, 1<<(a+10), B_OBLAY+a+10, "",   (short)(xco+a*(dx/2)), 165, (short)(dx/2), (short)(dy/2), &(BASACT->lay), 0, 0, 0, 0, "");
1878         
1879         uiBlockEndAlign(block);
1880         
1881         uiDefBut(block, LABEL, 0, "Drawtype",                                           10,120,100,20, NULL, 0, 0, 0, 0, "");
1882         
1883         uiBlockBeginAlign(block);
1884         uiDefButC(block, ROW, REDRAWVIEW3D, "Shaded",   10,100,100, 20, &ob->dt, 0, OB_SHADED, 0, 0, "Draw active object shaded or textured");
1885         uiDefButC(block, ROW, REDRAWVIEW3D, "Solid",    10,80,100, 20, &ob->dt, 0, OB_SOLID, 0, 0, "Draw active object in solid");
1886         uiDefButC(block, ROW, REDRAWVIEW3D, "Wire",             10,60, 100, 20, &ob->dt, 0, OB_WIRE, 0, 0, "Draw active object in wireframe");
1887         uiDefButC(block, ROW, REDRAWVIEW3D, "Bounds",   10,40, 100, 20, &ob->dt, 0, OB_BOUNDBOX, 0, 0, "Only draw object with bounding box");
1888         uiBlockEndAlign(block);
1889         
1890         uiDefBut(block, LABEL, 0, "Draw Extra",                                                 120,120,90,20, NULL, 0, 0, 0, 0, "");
1891         
1892         uiBlockBeginAlign(block);
1893         uiDefButBitC(block, TOG, OB_BOUNDBOX, REDRAWVIEW3D, "Bounds",                           120, 100, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's bounds");
1894         uiDefButBitC(block, TOG, OB_DRAWNAME, REDRAWVIEW3D, "Name",             210, 100, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's name");
1895         
1896         uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Polyheder%x4",
1897                           120, 80, 90, 20, &ob->boundtype, 0, 0, 0, 0, "Selects the boundary display type");
1898         uiDefButBitC(block, TOG, OB_AXIS, REDRAWVIEW3D, "Axis",                 210, 80, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's centre and axis");
1899         
1900         uiDefButBitC(block, TOG, OB_TEXSPACE, REDRAWVIEW3D, "TexSpace", 120, 60, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's texture space");
1901         uiDefButBitC(block, TOG, OB_DRAWWIRE, REDRAWVIEW3D, "Wire",             210, 60, 90, 20, &ob->dtx, 0, 0, 0, 0, "Adds the active object's wireframe over solid drawing");
1902         
1903         uiDefButBitC(block, TOG, OB_DRAWTRANSP, REDRAWVIEW3D, "Transp", 120, 40, 90, 20, &ob->dtx, 0, 0, 0, 0, "Enables transparent materials for the active object (Mesh only)");
1904         uiDefButBitC(block, TOG, OB_DRAWXRAY, REDRAWVIEW3D, "X-ray",    210, 40, 90, 20, &ob->dtx, 0, 0, 0, 0, "Makes the active object draw in front of others");
1905         
1906 }
1907
1908 void object_panel_constraint(char *context)
1909 {
1910         uiBlock *block;
1911         Object *ob= OBACT;
1912         ListBase *conlist;
1913         bConstraint *curcon;
1914         short xco, yco;
1915         char str[64];
1916         
1917         block= uiNewBlock(&curarea->uiblocks, "object_panel_constraint", UI_EMBOSS, UI_HELV, curarea->win);
1918         if(uiNewPanel(curarea, block, "Constraints", context, 960, 0, 318, 204)==0) return;
1919         
1920         if(ob->id.lib) uiSetButLock(1, "Can't edit library data");
1921         
1922         /* this is a variable height panel, newpanel doesnt force new size on existing panels */
1923         /* so first we make it default height */
1924         uiNewPanelHeight(block, 204);
1925         
1926         if(G.obedit==OBACT) return;     // ??
1927         
1928         conlist = get_active_constraints(OBACT);
1929         
1930         if (conlist) {
1931                 
1932                 uiDefBlockBut(block, add_constraintmenu, NULL, "Add Constraint", 0, 190, 130, 20, "Add a new constraint");
1933                 
1934                 /* print active object or bone */
1935                 str[0]= 0;
1936                 if (ob->flag & OB_POSEMODE){
1937                         bPoseChannel *pchan= get_active_posechannel(ob);
1938                         if(pchan) sprintf(str, "To Bone: %s", pchan->name);
1939                 }
1940                 else {
1941                         sprintf(str, "To Object: %s", ob->id.name+2);
1942                 }
1943                 uiDefBut(block, LABEL, 1, str,  150, 190, 150, 20, NULL, 0.0, 0.0, 0, 0, "Displays Active Object or Bone name");
1944                 
1945                 /* Go through the list of constraints and draw them */
1946                 xco = 10;
1947                 yco = 160;
1948                 
1949                 for (curcon = conlist->first; curcon; curcon=curcon->next) {
1950                         /* hrms, the temporal constraint should not draw! */
1951                         if(curcon->type==CONSTRAINT_TYPE_KINEMATIC) {
1952                                 bKinematicConstraint *data= curcon->data;
1953                                 if(data->flag & CONSTRAINT_IK_TEMP)
1954                                         continue;
1955                         }
1956                         /* Draw default constraint header */
1957                         draw_constraint(block, conlist, curcon, &xco, &yco);    
1958                 }
1959                 
1960                 if(yco < 0) uiNewPanelHeight(block, 204-yco);
1961                 
1962         }
1963 }
1964
1965 void do_effects_panels(unsigned short event)
1966 {
1967         Object *ob;
1968         Base *base;
1969         Effect *eff, *effn;
1970         PartEff *paf;
1971         
1972         ob= OBACT;
1973
1974         switch(event) {
1975
1976     case B_AUTOTIMEOFS:
1977                 auto_timeoffs();
1978                 break;
1979         case B_FRAMEMAP:
1980                 G.scene->r.framelen= G.scene->r.framapto;
1981                 G.scene->r.framelen/= G.scene->r.images;
1982                 allqueue(REDRAWALL, 0);
1983                 break;
1984         case B_NEWEFFECT:
1985                 if(ob) {
1986                         if(ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) { 
1987                                 // NT particles and fluid meshes currently dont work together -> switch off beforehand
1988                                 if(ob->fluidsimSettings->type == OB_FLUIDSIM_DOMAIN) {
1989                                         pupmenu("Fluidsim Particle Error%t|Please disable the fluidsim domain before activating particles.%x0");
1990                                         break;
1991                                         //ob->fluidsimFlag = 0; ob->fluidsimSettings->type = 0; allqueue(REDRAWVIEW3D, 0); 
1992                                 }
1993                         }
1994                         if (BLI_countlist(&ob->effect)==MAX_EFFECT)
1995                                 error("Unable to add: effect limit reached");
1996                         else
1997                                 copy_act_effect(ob);
1998                 }
1999                 DAG_scene_sort(G.scene);
2000                 BIF_undo_push("New effect");
2001                 allqueue(REDRAWBUTSOBJECT, 0);
2002                 break;
2003         case B_DELEFFECT:
2004                 if(ob==NULL || ob->type!=OB_MESH) break;
2005                 eff= ob->effect.first;
2006                 while(eff) {
2007                         effn= eff->next;
2008                         if(eff->flag & SELECT) {
2009                                 BLI_remlink(&ob->effect, eff);
2010                                 free_effect(eff);
2011                                 break;
2012                         }
2013                         eff= effn;
2014                 }
2015                 BIF_undo_push("Delete effect");
2016                 allqueue(REDRAWVIEW3D, 0);
2017                 allqueue(REDRAWBUTSOBJECT, 0);
2018                 break;
2019         case B_NEXTEFFECT:
2020                 if(ob==0 || ob->type!=OB_MESH) break;
2021                 eff= ob->effect.first;
2022                 while(eff) {
2023                         if(eff->flag & SELECT) {
2024                                 if(eff->next) {
2025                                         eff->flag &= ~SELECT;
2026                                         eff->next->flag |= SELECT;
2027                                 }
2028                                 break;
2029                         }
2030                         eff= eff->next;
2031                 }
2032                 allqueue(REDRAWBUTSOBJECT, 0);
2033                 break;
2034         case B_PREVEFFECT:
2035                 if(ob==0 || ob->type!=OB_MESH) break;
2036                 eff= ob->effect.first;
2037                 while(eff) {
2038                         if(eff->flag & SELECT) {
2039                                 if(eff->prev) {
2040                                         eff->flag &= ~SELECT;
2041                                         eff->prev->flag |= SELECT;
2042                                 }
2043                                 break;
2044                         }
2045                         eff= eff->next;
2046                 }
2047                 allqueue(REDRAWBUTSOBJECT, 0);
2048                 break;
2049         case B_EFFECT_DEP:
2050                 DAG_scene_sort(G.scene);
2051                 /* no break, pass on */
2052         case B_CALCEFFECT:
2053                 if(ob==NULL || ob->type!=OB_MESH) break;
2054                 eff= ob->effect.first;
2055                 while(eff) {
2056                         if(eff->flag & SELECT) {
2057                                 if(eff->type==EFF_PARTICLE) build_particle_system(ob);
2058                         }
2059                         eff= eff->next;
2060                 }
2061                 allqueue(REDRAWVIEW3D, 0);
2062                 allqueue(REDRAWBUTSOBJECT, 0);
2063                 break;
2064         case B_PAF_SET_VG:
2065                 
2066                 paf= give_parteff(ob);
2067                 if(paf) {
2068                         bDeformGroup *dg= get_named_vertexgroup(ob, paf->vgroupname);
2069                         if(dg)
2070                                 paf->vertgroup= get_defgroup_num(ob, dg)+1;
2071                         else
2072                                 paf->vertgroup= 0;
2073                         
2074                         DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
2075                         allqueue(REDRAWVIEW3D, 0);
2076                 }
2077                 break;
2078         case B_PAF_SET_VG1:
2079                 
2080                 paf= give_parteff(ob);
2081                 if(paf) {
2082                         bDeformGroup *dg= get_named_vertexgroup(ob, paf->vgroupname_v);
2083                         if(dg)
2084                                 paf->vertgroup_v= get_defgroup_num(ob, dg)+1;
2085                         else
2086                                 paf->vertgroup_v= 0;
2087                         
2088                         DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
2089                         allqueue(REDRAWVIEW3D, 0);
2090                 }
2091                 break;
2092         case B_FIELD_DEP:
2093                 /* do this before scene sort, that one checks for CU_PATH */
2094                 if(ob->type==OB_CURVE && ob->pd->forcefield==PFIELD_GUIDE) {
2095                         Curve *cu= ob->data;
2096                         
2097                         cu->flag |= (CU_PATH|CU_3D);
2098                         do_curvebuts(B_CU3D);   /* all curves too */
2099                 }
2100                 DAG_scene_sort(G.scene);
2101
2102                 if(ob->type==OB_CURVE && ob->pd->forcefield==PFIELD_GUIDE)
2103                         DAG_object_flush_update(G.scene, ob, OB_RECALC);
2104                 else
2105                         DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
2106
2107                 allqueue(REDRAWVIEW3D, 0);
2108                 allqueue(REDRAWBUTSOBJECT, 0);
2109                 break;
2110         case B_FIELD_CHANGE:
2111                 DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
2112                 allqueue(REDRAWVIEW3D, 0);
2113                 break;
2114         case B_RECALCAL:
2115                 if (G.vd==NULL)
2116                         break;
2117                 
2118                 base= FIRSTBASE;
2119                 while(base) {
2120                         if(base->lay & G.vd->lay) {
2121                                 ob= base->object;
2122                                 eff= ob->effect.first;
2123                                 while(eff) {
2124                                         if(eff->flag & SELECT) {
2125                                                 if(eff->type==EFF_PARTICLE) build_particle_system(ob);
2126                                         }
2127                                         eff= eff->next;
2128                                 }
2129                         }
2130                         base= base->next;
2131                 }
2132                 allqueue(REDRAWVIEW3D, 0);
2133                 break;
2134         default:
2135                 if(event>=B_SELEFFECT && event<B_SELEFFECT+MAX_EFFECT) {
2136                         ob= OBACT;
2137                         if(ob) {
2138                                 int a=B_SELEFFECT;
2139                                 
2140                                 eff= ob->effect.first;
2141                                 while(eff) {
2142                                         if(event==a) eff->flag |= SELECT;
2143                                         else eff->flag &= ~SELECT;
2144                                         
2145                                         a++;
2146                                         eff= eff->next;
2147                                 }
2148                                 allqueue(REDRAWBUTSOBJECT, 0);
2149                         }
2150                 }
2151         }
2152
2153 }
2154
2155 /* Panel for particle interaction settings */
2156 static void object_panel_fields(Object *ob)
2157 {
2158         uiBlock *block;
2159
2160         block= uiNewBlock(&curarea->uiblocks, "object_panel_fields", UI_EMBOSS, UI_HELV, curarea->win);
2161         if(uiNewPanel(curarea, block, "Fields and Deflection", "Physics", 0, 0, 318, 204)==0) return;
2162
2163         if(ob->id.lib) uiSetButLock(1, "Can't edit library data");
2164         
2165         /* should become button, option? */
2166         if(ob->pd==NULL) {
2167                 ob->pd= MEM_callocN(sizeof(PartDeflect), "PartDeflect");
2168                 /* and if needed, init here */
2169                 ob->pd->pdef_sbdamp = 0.1f;
2170                 ob->pd->pdef_sbift  = 0.2f;
2171                 ob->pd->pdef_sboft  = 0.02f;
2172         }
2173         
2174         if(ob->pd) {
2175                 PartDeflect *pd= ob->pd;
2176                 char *menustr= MEM_mallocN(256, "temp string");
2177                 char *tipstr="Choose field type";
2178                 
2179                 uiDefBut(block, LABEL, 0, "Fields",             10,180,140,20, NULL, 0.0, 0, 0, 0, "");
2180                 
2181                 /* setup menu button */
2182                 sprintf(menustr, "Field Type%%t|None %%x0|Spherical %%x%d|Wind %%x%d|Vortex %%x%d|Curve Guide %%x%d", 
2183                                 PFIELD_FORCE, PFIELD_WIND, PFIELD_VORTEX, PFIELD_GUIDE);
2184                 
2185                 if(pd->forcefield==PFIELD_FORCE) tipstr= "Object center attracts or repels particles";
2186                 else if(pd->forcefield==PFIELD_WIND) tipstr= "Constant force applied in direction of Object Z axis";
2187                 else if(pd->forcefield==PFIELD_VORTEX) tipstr= "Particles swirl around Z-axis of the Object";
2188                 else if(pd->forcefield==PFIELD_GUIDE) tipstr= "Use a Curve Path to guide particles";
2189                 
2190                 uiDefButS(block, MENU, B_FIELD_DEP, menustr,                    10,160,140,20, &pd->forcefield, 0.0, 0.0, 0, 0, tipstr);
2191                 MEM_freeN(menustr);
2192                 
2193                 if(pd->forcefield) {
2194                         uiBlockBeginAlign(block);
2195                         if(pd->forcefield == PFIELD_GUIDE) {
2196                                 uiDefButF(block, NUM, B_FIELD_CHANGE, "MinDist: ",      10,120,140,20, &pd->f_strength, 0.0, 1000.0, 10, 0, "The distance from which particles are affected fully.");
2197                                 uiDefButF(block, NUM, B_FIELD_CHANGE, "Fall-off: ",     10,100,140,20, &pd->f_power, 0.0, 10.0, 10, 0, "Falloff factor, between mindist and maxdist");
2198                         }
2199                         else {  
2200                                 uiDefButF(block, NUM, B_FIELD_CHANGE, "Strength: ",     10,110,140,20, &pd->f_strength, -1000, 1000, 10, 0, "Strength of force field");
2201                                 uiDefButF(block, NUM, B_FIELD_CHANGE, "Fall-off: ",     10,90,140,20, &pd->f_power, 0, 10, 10, 0, "Falloff power (real gravitational fallof = 2)");
2202                         }
2203                         
2204                         uiBlockBeginAlign(block);
2205                         uiDefButBitS(block, TOG, PFIELD_USEMAX, B_FIELD_CHANGE, "Use MaxDist",  10,60,140,20, &pd->flag, 0.0, 0, 0, 0, "Use a maximum distance for the field to work");
2206                         uiDefButF(block, NUM, B_FIELD_CHANGE, "MaxDist: ",      10,40,140,20, &pd->maxdist, 0, 1000.0, 10, 0, "Maximum distance for the field to work");
2207                         uiBlockEndAlign(block);
2208                         
2209                         if(pd->forcefield == PFIELD_GUIDE)
2210                                 uiDefButBitS(block, TOG, PFIELD_GUIDE_PATH_ADD, B_FIELD_CHANGE, "Additive",     10,10,140,20, &pd->flag, 0.0, 0, 0, 0, "Based on distance/falloff it adds a portion of the entire path");
2211                         
2212                 }
2213                 
2214                 uiDefBut(block, LABEL, 0, "Deflection", 160,180,140,20, NULL, 0.0, 0, 0, 0, "");
2215                         
2216                 /* only meshes collide now */
2217                 if(ob->type==OB_MESH) {
2218                         uiDefButBitS(block, TOG, 1, B_REDR, "Deflection",160,160,150,20, &pd->deflect, 0, 0, 0, 0, "Deflects particles based on collision");
2219                         if(pd->deflect) {
2220                                 uiDefBut(block, LABEL, 0, "Particles",                  160,140,150,20, NULL, 0.0, 0, 0, 0, "");
2221                                 
2222                                 uiBlockBeginAlign(block);
2223                                 uiDefButF(block, NUM, B_DIFF, "Damping: ",              160,120,150,20, &pd->pdef_damp, 0.0, 1.0, 10, 0, "Amount of damping during particle collision");
2224                                 uiDefButF(block, NUM, B_DIFF, "Rnd Damping: ",  160,100,150,20, &pd->pdef_rdamp, 0.0, 1.0, 10, 0, "Random variation of damping");
2225                                 uiDefButF(block, NUM, B_DIFF, "Permeability: ", 160,80,150,20, &pd->pdef_perm, 0.0, 1.0, 10, 0, "Chance that the particle will pass through the mesh");
2226                                 uiBlockEndAlign(block);
2227                                 
2228                                 uiDefBut(block, LABEL, 0, "Soft Body",                  160,60,150,20, NULL, 0.0, 0, 0, 0, "");
2229
2230                                 uiBlockBeginAlign(block);
2231                                 uiDefButF(block, NUM, B_DIFF, "Damping:",       160,40,150,20, &pd->pdef_sbdamp, 0.0, 1.0, 10, 0, "Amount of damping during soft body collision");
2232                                 uiDefButF(block, NUM, B_DIFF, "Inner:", 160,20,150,20, &pd->pdef_sbift, 0.001, 1.0, 10, 0, "Inner face thickness");
2233                                 uiDefButF(block, NUM, B_DIFF, "Outer:", 160, 0,150,20, &pd->pdef_sboft, 0.001, 1.0, 10, 0, "Outer face thickness");
2234                         }
2235                 }               
2236         }
2237 }
2238
2239
2240 /* Panel for softbodies */
2241 static void object_softbodies__enable(void *ob_v, void *arg2)
2242 {
2243         Object *ob = ob_v;
2244         ModifierData *md = modifiers_findByType(ob, eModifierType_Softbody);
2245
2246         if (modifiers_isSoftbodyEnabled(ob)) {
2247                 if (md) {
2248                         md->mode &= ~(eModifierMode_Render|eModifierMode_Realtime);
2249                 }
2250         } else {
2251                 if (!md) {
2252                         md = modifier_new(eModifierType_Softbody);
2253                         BLI_addhead(&ob->modifiers, md);
2254                 }
2255
2256                 md->mode |= eModifierMode_Render|eModifierMode_Realtime;
2257
2258                 if (!ob->soft) {
2259                         ob->soft= sbNew();
2260                         ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
2261                 }
2262         }
2263
2264         allqueue(REDRAWBUTSEDIT, 0);
2265 }
2266
2267 static void object_softbodies_II(Object *ob)
2268 {
2269         uiBlock *block;
2270         static int val;
2271         //uiBut *but;
2272         block= uiNewBlock(&curarea->uiblocks, "object_softbodies_II", UI_EMBOSS, UI_HELV, curarea->win);
2273         if(uiNewPanel(curarea, block, "Soft Body II", "Physics", 651, 0, 318, 204)==0) return;
2274
2275         if(ob->id.lib) uiSetButLock(1, "Can't edit library data");
2276
2277         val = modifiers_isSoftbodyEnabled(ob);
2278         if(!val) {
2279                 uiDefBut(block, LABEL, 0, "",10,10,1,2, NULL, 0.0, 0, 0, 0, ""); /* tell UI we go to 10,10*/
2280                 uiBlockBeginAlign(block);
2281                 uiDefBut(block, LABEL, 0, "Object is not a softbody",10,190,300,20, NULL, 0.0, 0, 0, 0, ""); 
2282                 uiDefBut(block, LABEL, 0, "However it can deflect a softbody",10,170,300,20, NULL, 0.0, 0, 0, 0, ""); 
2283                 /* OTHER OBJECTS COLLISION STUFF */
2284                 if (ob->type==OB_MESH){
2285                         uiBlockBeginAlign(block);
2286                         uiDefButBitS(block, TOG, 1, B_REDR, "Deflection",10,50,150,20, &ob->pd->deflect, 0, 0, 0, 0, "Makes this object visible to softbody objects");
2287                         if(ob->pd->deflect) {
2288                                 uiDefButF(block, NUM, B_DIFF, "Damping:",       160,50,150,20, &ob->pd->pdef_sbdamp, 0.0, 1.0, 10, 0, "Amount of damping during soft body collision");
2289                             uiDefButBitS(block, TOG,OB_SB_COLLFINAL , B_DIFF, "Ev.M.Stack",10,30,150,20, &ob->softflag, 0, 0, 0, 0, "Pick collision object from modifier stack");
2290                                 uiDefButF(block, NUM, B_DIFF, "Inner:", 160,30,150,20, &ob->pd->pdef_sbift, 0.001, 1.0, 10, 0, "Inner face thickness");
2291                                 uiDefButF(block, NUM, B_DIFF, "Outer:", 160,10,150,20, &ob->pd->pdef_sboft, 0.001, 1.0, 10, 0, "Outer face thickness");
2292                         }
2293                 }
2294                 uiBlockEndAlign(block);
2295         }
2296         else{
2297                 SoftBody *sb= ob->soft;
2298                 /* SELF COLLISION STUFF */
2299                 if ((ob->type==OB_MESH)||(ob->type==OB_CURVE) ) {
2300                         uiBlockBeginAlign(block);
2301                         if (ob->softflag & OB_SB_EDGES){
2302                                 uiDefButBitS(block, TOG, OB_SB_SELF, B_SOFTBODY_CHANGE, "Self Collision",               10,170,150,20, &ob->softflag, 0, 0, 0, 0, "enable naive vertex ball self collision");
2303                                 if(ob->softflag & OB_SB_SELF){
2304                                         uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Ball Size:", 160,170,150,20, &sb->colball, -10.0,  10.0, 10, 0, "Absolute ball size or factor if not manual adjusted");
2305                                         uiDefButS(block, ROW, B_DIFF, "Man",10,150,60,20, &sb->sbc_mode, 4.0,(float)0, 0, 0, "Manual adjust");
2306                                         uiDefButS(block, ROW, B_DIFF, "Av",70,150,60,20, &sb->sbc_mode, 4.0,(float)1, 0, 0, "Average Spring lenght * Ball Size");
2307                                         uiDefButS(block, ROW, B_DIFF, "Min",130,150,60,20, &sb->sbc_mode, 4.0,(float)2, 0, 0, "Minimal Spring lenght * Ball Size");
2308                                         uiDefButS(block, ROW, B_DIFF, "Max",190,150,60,20, &sb->sbc_mode, 4.0,(float)3, 0, 0, "Maximal Spring lenght * Ball Size");
2309                                         uiDefButS(block, ROW, B_DIFF, "AvMiMa",250,150,60,20, &sb->sbc_mode, 4.0,(float)4, 0, 0, "(Min+Max)/2 * Ball Size");
2310                                         uiDefButF(block, NUM, B_DIFF, "B Stiff:", 10,130,150,20, &sb->ballstiff, 0.001,  100.0, 10, 0, "Ball inflating presure");
2311                                         uiDefButF(block, NUM, B_DIFF, "B Damp:", 160,130,150,20, &sb->balldamp,  0.001,  1.0, 10, 0, "Blending to inelastic collision");
2312                                 }
2313                         }
2314                         else{
2315                                 uiDefBut(block, LABEL, 0, "<Self Collision> not available because there",10,170,300,20, NULL, 0.0, 0, 0, 0, ""); 
2316                                 uiDefBut(block, LABEL, 0, "are no edges, enable <Use Edges>",10,150,300,20, NULL, 0.0, 0, 0, 0, ""); 
2317                         }
2318
2319                         uiBlockEndAlign(block);
2320                         /*SOLVER SETTINGS*/
2321                         uiDefButF(block, NUM, B_DIFF, "Error Limit:",   10,100,150,20, &sb->rklimit , 0.01, 10.0, 10, 0, "The Runge-Kutta ODE solver error limit, low value gives more precision, high values speed");
2322                         uiDefButS(block, NUM, B_DIFF, "Fuzzy:", 160,100,130,20, &sb->fuzzyness,  1.00,  100.0, 10, 0, "Fuzzyness while on collision, high values make collsion handling faster but less stable");
2323                         uiDefButS(block, TOG, SBSO_MONITOR, "M", 290,100,20,20, &sb->solverflags,  0,  0.0, 10, 0, "Turn on SB diagnose console prints (Maaammmaa!)");
2324                         uiDefButS(block, NUM, B_DIFF, "MinS:", 10,80,100,20, &sb->minloops,  0.00,  30000.0, 10, 0, "Minimal # solver steps/frame ");
2325                         uiDefButS(block, NUM, B_DIFF, "MaxS:", 110,80,100,20, &sb->maxloops,  0.00,  30000.0, 10, 0, "Maximal # solver steps/frame ");
2326                         uiDefButS(block, NUM, B_DIFF, "Choke:", 210,80,100,20, &sb->choke, 0.00,  100.0, 10, 0, "'Viscosity' inside collision target ");
2327                 }
2328                 /* OTHER OBJECTS COLLISION STUFF */
2329                 if (ob->type==OB_MESH){
2330                         uiDefButBitS(block, TOG, 1, B_REDR, "Deflection",10,50,150,20, &ob->pd->deflect, 0, 0, 0, 0, "Makes this object visible to other softbody objects");
2331                         if(ob->pd->deflect) {
2332                                 uiDefButF(block, NUM, B_DIFF, "Damping:",       160,50,150,20, &ob->pd->pdef_sbdamp, 0.0, 1.0, 10, 0, "Amount of damping during soft body collision");
2333                             uiDefButBitS(block, TOG,OB_SB_COLLFINAL , B_DIFF, "Ev.M.Stack",10,30,150,20, &ob->softflag, 0, 0, 0, 0, "Pick collision object from modifier stack");
2334                                 uiDefButF(block, NUM, B_DIFF, "Inner:", 160,30,150,20, &ob->pd->pdef_sbift, 0.001, 1.0, 10, 0, "Inner face thickness");
2335                                 uiDefButF(block, NUM, B_DIFF, "Outer:", 160,10,150,20, &ob->pd->pdef_sboft, 0.001, 1.0, 10, 0, "Outer face thickness");
2336                         }
2337                 }
2338                 uiDefBut(block, LABEL, 0, "",10,10,1,2, NULL, 0.0, 0, 0, 0, ""); /* tell UI we go to 10,10*/
2339         }
2340                 uiBlockEndAlign(block);
2341 }
2342
2343 static void object_softbodies(Object *ob)
2344 {
2345         uiBlock *block;
2346         static int val;
2347         uiBut *but;
2348         block= uiNewBlock(&curarea->uiblocks, "object_softbodies", UI_EMBOSS, UI_HELV, curarea->win);
2349         if(uiNewPanel(curarea, block, "Soft Body", "Physics", 640, 0, 318, 204)==0) return;
2350
2351         if(ob->id.lib) uiSetButLock(1, "Can't edit library data");
2352
2353         val = modifiers_isSoftbodyEnabled(ob);
2354         but = uiDefButI(block, TOG, REDRAWBUTSOBJECT, "Soft Body",      10,200,130,20, &val, 0, 0, 0, 0, "Sets object to become soft body");
2355         uiButSetFunc(but, object_softbodies__enable, ob, NULL);
2356         uiDefBut(block, LABEL, 0, "",10,10,300,0, NULL, 0.0, 0, 0, 0, ""); /* tell UI we go to 10,10*/
2357
2358         if(modifiers_isSoftbodyEnabled(ob)){
2359                 SoftBody *sb= ob->soft;
2360                 int defCount;
2361                 char *menustr;
2362
2363                 if(sb==NULL) {
2364                         sb= ob->soft= sbNew();
2365                         ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
2366                 }
2367
2368                 uiDefButBitS(block, TOG, OB_SB_BAKESET, REDRAWBUTSOBJECT, "Bake settings",      180,200,130,20, &ob->softflag, 0, 0, 0, 0, "To convert simulation into baked (cached) result");
2369
2370                 if(sb->keys) uiSetButLock(1, "Soft Body is baked, free it first");
2371
2372                 if(ob->softflag & OB_SB_BAKESET) {
2373                         uiBlockBeginAlign(block);
2374                         uiDefButI(block, NUM, B_DIFF, "Start:",                 10, 170,100,20, &sb->sfra, 1.0, 10000.0, 10, 0, "Start frame for baking");
2375                         uiDefButI(block, NUM, B_DIFF, "End:",                   110, 170,100,20, &sb->efra, 1.0, 10000.0, 10, 0, "End frame for baking");
2376                         uiDefButI(block, NUM, B_DIFF, "Interval:",              210, 170,100,20, &sb->interval, 1.0, 10.0, 10, 0, "Interval in frames between baked keys");
2377                         uiBlockEndAlign(block);
2378
2379                         uiDefButS(block, TOG, B_DIFF, "Local",                  10, 145,100,20, &sb->local, 0.0, 0.0, 0, 0, "Use local coordinates for baking");
2380
2381
2382                         uiClearButLock();
2383                         uiBlockBeginAlign(block);
2384
2385                         if(sb->keys) {
2386                                 char str[128];
2387                                 uiDefIconTextBut(block, BUT, B_SOFTBODY_BAKE_FREE, ICON_X, "FREE BAKE", 10, 120,300,20, NULL, 0.0, 0.0, 0, 0, "Free baked result");
2388                                 sprintf(str, "Stored %d vertices %d keys %.3f MB", sb->totpoint, sb->totkey, ((float)16*sb->totpoint*sb->totkey)/(1024.0*1024.0));
2389                                 uiDefBut(block, LABEL, 0, str, 10, 100,300,20, NULL, 0.0, 0.0, 00, 0, "");
2390                         }
2391                         else                            
2392                                 uiDefBut(block, BUT, B_SOFTBODY_BAKE, "BAKE",   10, 120,300,20, NULL, 0.0, 0.0, 10, 0, "Start baking. Press ESC to exit without baking");
2393
2394                 }
2395                 else {
2396                         /* GENERAL STUFF */
2397                         uiBlockBeginAlign(block);
2398                         uiDefButF(block, NUM, B_DIFF, "Friction:", 10, 170,150,20, &sb->mediafrict, 0.0, 50.0, 10, 0, "General media friction for point movements");
2399                         uiDefButF(block, NUM, B_DIFF, "Mass:",     160, 170,150,20, &sb->nodemass , 0.001, 50.0, 10, 0, "Point Mass, the heavier the slower");
2400                         uiDefButF(block, NUM, B_DIFF, "Grav:",     10,150,150,20, &sb->grav , 0.0, 10.0, 10, 0, "Apply gravitation to point movement");
2401                         uiDefButF(block, NUM, B_DIFF, "Speed:",    160,150,150,20, &sb->physics_speed , 0.01, 100.0, 10, 0, "Tweak timing for physics to control frequency and speed");
2402                         uiBlockEndAlign(block);
2403
2404                         /* GOAL STUFF */
2405                         uiBlockBeginAlign(block);
2406                         uiDefButBitS(block, TOG, OB_SB_GOAL, B_SOFTBODY_CHANGE, "Use Goal",     10,120,130,20, &ob->softflag, 0, 0, 0, 0, "Define forces for vertices to stick to animated position");
2407                         if (ob->softflag & OB_SB_GOAL){
2408                                 if(ob->type==OB_MESH) {
2409                                         menustr= get_vertexgroup_menustr(ob);
2410                                         defCount=BLI_countlist(&ob->defbase);
2411                                         if(defCount==0) sb->vertgroup= 0;
2412                                         uiDefButS(block, MENU, B_SOFTBODY_CHANGE, menustr,      140,120,20,20, &sb->vertgroup, 0, defCount, 0, 0, "Browses available vertex groups");
2413                                         MEM_freeN (menustr);
2414
2415                                         if(sb->vertgroup) {
2416                                                 bDeformGroup *defGroup = BLI_findlink(&ob->defbase, sb->vertgroup-1);
2417                                                 if(defGroup)
2418                                                         uiDefBut(block, BUT, B_DIFF, defGroup->name,    160,120,130,20, NULL, 0.0, 0.0, 0, 0, "Name of current vertex group");
2419                                                 else
2420                                                         uiDefBut(block, BUT, B_DIFF, "(no group)",      160,120,130,20, NULL, 0.0, 0.0, 0, 0, "Vertex Group doesn't exist anymore");
2421                                                 uiDefIconBut(block, BUT, B_SOFTBODY_DEL_VG, ICON_X, 290,120,20,20, 0, 0, 0, 0, 0, "Disable use of vertex group");
2422                                         }
2423                                         else
2424                                                 uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Goal:",       160,120,150,20, &sb->defgoal, 0.0, 1.0, 10, 0, "Default Goal (vertex target position) value, when no Vertex Group used");
2425                                 }
2426                                 else {
2427                                         uiDefButS(block, TOG, B_SOFTBODY_CHANGE, "W",                   140,120,20,20, &sb->vertgroup, 0, 1, 0, 0, "Use control point weight values");
2428                                         uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Goal:",       160,120,150,20, &sb->defgoal, 0.0, 1.0, 10, 0, "Default Goal (vertex target position) value, when no Vertex Group used");
2429                                 }
2430
2431                                 uiDefButF(block, NUM, B_DIFF, "G Stiff:",       10,100,150,20, &sb->goalspring, 0.0, 0.999, 10, 0, "Goal (vertex target position) spring stiffness");
2432                                 uiDefButF(block, NUM, B_DIFF, "G Damp:",        160,100,150,20, &sb->goalfrict  , 0.0, 50.0, 10, 0, "Goal (vertex target position) friction");
2433                                 uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "G Min:",              10,80,150,20, &sb->mingoal, 0.0, 1.0, 10, 0, "Goal minimum, vertex group weights are scaled to match this range");
2434                                 uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "G Max:",              160,80,150,20, &sb->maxgoal, 0.0, 1.0, 10, 0, "Goal maximum, vertex group weights are scaled to match this range");
2435                         }
2436                         uiBlockEndAlign(block);
2437
2438                         /* EDGE SPRING STUFF */
2439                         if(ob->type!=OB_SURF) {
2440                                 uiBlockBeginAlign(block);
2441                                 uiDefButBitS(block, TOG, OB_SB_EDGES, B_SOFTBODY_CHANGE, "Use Edges",           10,50,90,20, &ob->softflag, 0, 0, 0, 0, "Use Edges as springs");
2442                         if (ob->softflag & OB_SB_EDGES){
2443                                 uiDefButBitS(block, TOG, OB_SB_QUADS, B_SOFTBODY_CHANGE, "Stiff Quads",         110,50,90,20, &ob->softflag, 0, 0, 0, 0, "Adds diagonal springs on 4-gons");
2444                                 uiDefButBitS(block, TOG, OB_SB_EDGECOLL, B_DIFF, "CEdge",               220,50,45,20, &ob->softflag, 0, 0, 0, 0, "Edge collide too"); 
2445                                 uiDefButBitS(block, TOG, OB_SB_FACECOLL, B_DIFF, "CFace",               265,50,45,20, &ob->softflag, 0, 0, 0, 0, "Faces collide too SLOOOOOW warning "); 
2446                                 uiDefButF(block, NUM, B_DIFF, "E Stiff:",       10,30,150,20, &sb->inspring, 0.0,  0.999, 10, 0, "Edge spring stiffness");
2447                                 uiDefButF(block, NUM, B_DIFF, "E Damp:",        160,30,150,20, &sb->infrict, 0.0,  50.0, 10, 0, "Edge spring friction");
2448                                 uiDefButS(block, NUM, B_DIFF, "Aero:",     10,10,150,20, &sb->aeroedge,  0.00,  30000.0, 10, 0, "Make edges 'sail'");
2449                                 if(ob->type==OB_MESH) {
2450                                         uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Rigidity:", 160,10,150,20, &sb->secondspring, 0.0,  10.0, 10, 0, "Strenght of Springs over 2 Edges");
2451                                 }
2452                                 else sb->secondspring = 0;
2453                                 uiDefBut(block, LABEL, 0, "",10,10,1,0, NULL, 0.0, 0, 0, 0, ""); /* tell UI we go to 10,10*/
2454                         }
2455                                 uiBlockEndAlign(block);
2456                         }
2457                 }
2458         }
2459         uiBlockEndAlign(block);
2460 }
2461
2462 static void object_panel_particles_motion(Object *ob)
2463 {
2464         uiBlock *block;
2465         uiBut *but;
2466         PartEff *paf= give_parteff(ob);
2467
2468         if (paf==NULL) return;
2469                 
2470         block= uiNewBlock(&curarea->uiblocks, "object_panel_particles_motion", UI_EMBOSS, UI_HELV, curarea->win);
2471         uiNewPanelTabbed("Particles ", "Physics");
2472         if(uiNewPanel(curarea, block, "Particle Motion", "Physics", 320, 0, 318, 204)==0) return;
2473         
2474         if(ob->id.lib) uiSetButLock(1, "Can't edit library data");
2475         
2476         /* top row */
2477         uiBlockBeginAlign(block);
2478         uiDefButI(block, NUM, B_CALCEFFECT, "Keys:",    0,180,75,20, &paf->totkey, 1.0, 100.0, 0, 0, "Specify the number of key positions");
2479         uiDefButBitS(block, TOG, PAF_BSPLINE, B_CALCEFFECT, "Bspline",  75,180,75,20, &paf->flag, 0, 0, 0, 0, "Use B spline formula for particle interpolation");
2480         uiDefButI(block, NUM, B_CALCEFFECT, "Seed:",    150,180,75,20, &paf->seed, 0.0, 255.0, 0, 0, "Set an offset in the random table");
2481         uiDefButF(block, NUM, B_CALCEFFECT, "RLife:",   225,180,85,20, &paf->randlife, 0.0, 2.0, 10, 1, "Give the particlelife a random variation");
2482         uiBlockEndAlign(block);
2483         
2484         /* left collumn */
2485         uiDefBut(block, LABEL, 0, "Velocity:",                  0,160,150,20, NULL, 0.0, 0, 0, 0, "");
2486         uiBlockBeginAlign(block);
2487         uiBlockSetCol(block, TH_BUT_SETTING2);
2488         uiDefButF(block, NUM, B_CALCEFFECT, "Normal:",          0,140,150,18, &paf->normfac, -2.0, 2.0, 1, 3, "Let the mesh give the particle a starting speed");
2489         uiDefButF(block, NUM, B_CALCEFFECT, "Object:",          0,122,150,18, &paf->obfac, -1.0, 1.0, 1, 3, "Let the object give the particle a starting speed");
2490         uiDefButF(block, NUM, B_CALCEFFECT, "Random:",          0,104,150,18, &paf->randfac, 0.0, 2.0, 1, 3, "Give the startingspeed a random variation");
2491         uiDefButF(block, NUM, B_CALCEFFECT, "Texture:",         0,86,150,18, &paf->texfac, 0.0, 2.0, 1, 3, "Let the texture give the particle a starting speed");
2492         uiDefButF(block, NUM, B_CALCEFFECT, "Damping:",         0,68,150,18, &paf->damp, 0.0, 1.0, 1, 3, "Specify the damping factor");
2493         uiBlockSetCol(block, TH_AUTO);
2494         but=uiDefBut(block, TEX, B_PAF_SET_VG1, "VGroup:",      0,50,150,18, paf->vgroupname_v, 0, 31, 0, 0, "Name of vertex group to use for speed control");
2495         uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)OBACT);
2496         uiBlockEndAlign(block);
2497         
2498         uiDefBut(block, LABEL, 0, "Texture Emission",                   0,30,150,20, NULL, 0.0, 0, 0, 0, "");
2499         uiBlockBeginAlign(block);
2500         uiDefButBitS(block, TOG3, PAF_TEXTIME, B_CALCEFFECT, "TexEmit",         0,10,75,20, &(paf->flag2), 0, 0, 0, 0, "Use a texture to define emission of particles");
2501         uiDefButS(block, NUM, B_CALCEFFECT, "Tex:",             75,10,75,20, &paf->timetex, 1.0, 10.0, 0, 0, "Specify texture used for the texture emission");
2502         
2503         /* right collumn */
2504         uiDefIDPoinBut(block, test_grouppoin_but, ID_GR, B_CALCEFFECT, "GR:", 160, 155, 150, 20, &paf->group, "Limit Force Fields to this Group"); 
2505
2506         uiBlockBeginAlign(block);
2507         uiDefBut(block, LABEL, 0, "Force:",                             160,130,75,20, NULL, 0.0, 0, 0, 0, "");
2508         uiDefButF(block, NUM, B_CALCEFFECT, "X:",               235,130,75,20, paf->force, -1.0, 1.0, 1, 2, "Specify the X axis of a continues force");
2509         uiDefButF(block, NUM, B_CALCEFFECT, "Y:",               160,110,75,20, paf->force+1,-1.0, 1.0, 1, 2, "Specify the Y axis of a continues force");
2510         uiDefButF(block, NUM, B_CALCEFFECT, "Z:",               235,110,75,20, paf->force+2, -1.0, 1.0, 1, 2, "Specify the Z axis of a continues force");
2511         
2512         uiBlockBeginAlign(block);
2513         uiDefButS(block, NUM, B_CALCEFFECT, "Tex:",             160,80,75,20, &paf->speedtex, 1.0, 10.0, 0, 2, "Specify the texture used for force");
2514         uiDefButF(block, NUM, B_CALCEFFECT, "X:",               235,80,75,20, paf->defvec, -1.0, 1.0, 1, 2, "Specify the X axis of a force, determined by the texture");
2515         uiDefButF(block, NUM, B_CALCEFFECT, "Y:",               160,60,75,20, paf->defvec+1,-1.0, 1.0, 1, 2, "Specify the Y axis of a force, determined by the texture");
2516         uiDefButF(block, NUM, B_CALCEFFECT, "Z:",               235,60,75,20, paf->defvec+2, -1.0, 1.0, 1, 2, "Specify the Z axis of a force, determined by the texture");
2517         
2518         uiBlockBeginAlign(block);
2519         uiDefButS(block, ROW, B_CALCEFFECT, "Int",              160,30,50,20, &paf->texmap, 14.0, 0.0, 0, 0, "Use texture intensity as a factor for texture force");
2520         uiDefButS(block, ROW, B_CALCEFFECT, "RGB",              210,30,50,20, &paf->texmap, 14.0, 1.0, 0, 0, "Use RGB values as a factor for particle speed vector");
2521         uiDefButS(block, ROW, B_CALCEFFECT, "Grad",             260,30,50,20, &paf->texmap, 14.0, 2.0, 0, 0, "Use texture gradient as a factor for particle speed vector");
2522         
2523         uiDefButF(block, NUM, B_CALCEFFECT, "Nabla:",   160,10,150,20, &paf->nabla, 0.0001f, 1.0, 1, 0, "Specify the dimension of the area for gradient calculation");
2524         
2525 }
2526
2527
2528 static void object_panel_particles(Object *ob)
2529 {
2530         uiBlock *block;
2531         uiBut *but;
2532         PartEff *paf= give_parteff(ob);
2533         
2534         /* the panelname "Particles " has a space to exclude previous saved panel "Particles" */
2535         block= uiNewBlock(&curarea->uiblocks, "object_panel_particles", UI_EMBOSS, UI_HELV, curarea->win);
2536         if(uiNewPanel(curarea, block, "Particles ", "Physics", 320, 0, 318, 204)==0) return;
2537
2538         if(ob->id.lib) uiSetButLock(1, "Can't edit library data");
2539         
2540         if (ob->type == OB_MESH) {
2541                 uiBlockBeginAlign(block);
2542                 if(paf==NULL)
2543                         uiDefBut(block, BUT, B_NEWEFFECT, "NEW",        0,180,75,20, 0, 0, 0, 0, 0, "Create a new Particle effect");
2544                 else
2545                         uiDefBut(block, BUT, B_DELEFFECT, "Delete", 0,180,75,20, 0, 0, 0, 0, 0, "Delete the effect");
2546         }
2547         else uiDefBut(block, LABEL, 0, "Only Mesh Objects can generate particles",                              10,180,300,20, NULL, 0.0, 0, 0, 0, "");
2548         
2549         
2550         if(paf==NULL) return;
2551         
2552         uiDefBut(block, BUT, B_RECALCAL, "RecalcAll",           75,180,75,20, 0, 0, 0, 0, 0, "Update all particle systems");
2553         uiBlockEndAlign(block);
2554         
2555         uiDefBut(block, LABEL, 0, "Emit:",                                      0,150,75,20, NULL, 0.0, 0, 0, 0, "");
2556         uiBlockBeginAlign(block);
2557         uiDefButI(block, NUM, B_CALCEFFECT, "Amount:",          0,130,150,20, &paf->totpart, 1.0, 100000.0, 0, 0, "The total number of particles");
2558         if(paf->flag & PAF_STATIC) {
2559                 uiDefButS(block, NUM, REDRAWVIEW3D, "Step:",    0,110,150,20, &paf->staticstep, 1.0, 100.0, 10, 0, "For static duplicators, the Step value skips particles");
2560         }
2561         else {
2562                 uiDefButF(block, NUM, B_CALCEFFECT, "Sta:",             0,110,75,20, &paf->sta, -250.0, MAXFRAMEF, 100, 1, "Frame # to start emitting particles");
2563                 uiDefButF(block, NUM, B_CALCEFFECT, "End:",             75,110,75,20, &paf->end, 1.0, MAXFRAMEF, 100, 1, "Frame # to stop emitting particles");
2564         }
2565         uiDefButF(block, NUM, B_CALCEFFECT, "Life:",            0,90,75,20, &paf->lifetime, 1.0, MAXFRAMEF, 100, 1, "Specify the life span of the particles");
2566         uiDefButS(block, NUM, B_CALCEFFECT, "Disp:",            75,90,75,20, &paf->disp, 0.0, 100.0, 10, 0, "Percentage of particles to calculate for 3d view");
2567         uiBlockEndAlign(block);
2568         
2569         uiDefBut(block, LABEL, 0, "From:",                                      0,70,75,20, NULL, 0.0, 0, 0, 0, "");
2570         uiBlockBeginAlign(block);
2571         uiDefButBitS(block, TOGN, PAF_OFACE, B_CALCEFFECT, "Verts",     0,50,75,20, &paf->flag, 0, 0, 0, 0, "Emit particles from vertices");
2572         uiDefButBitS(block, TOG, PAF_FACE, B_CALCEFFECT, "Faces",       75,50,75,20, &paf->flag, 0, 0, 0, 0, "Emit particles from faces");
2573         if(paf->flag & PAF_FACE) {
2574                 uiDefButBitS(block, TOG, PAF_TRAND, B_CALCEFFECT, "Rand",       0,30,50,20, &paf->flag, 0, 0, 0, 0, "Use true random distribution from faces");
2575                 uiDefButBitS(block, TOG, PAF_EDISTR, B_CALCEFFECT, "Even",      50,30,50,20, &paf->flag, 0, 0, 0, 0, "Use even distribution from faces based on face areas");
2576                 uiDefButS(block, NUM, B_CALCEFFECT, "P/F:",                                     100,30,50,20, &paf->userjit, 0.0, 200.0, 1, 0, "Jitter table distribution: maximum particles per face (0=uses default)");
2577         }
2578         else uiBlockEndAlign(block);    /* vgroup button no align */
2579         
2580         but=uiDefBut(block, TEX, B_PAF_SET_VG, "VGroup:",                                       0,10,150,20, paf->vgroupname, 0, 31, 0, 0, "Name of vertex group to use");
2581         uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)OBACT);
2582         uiBlockEndAlign(block);
2583         
2584         /* right collumn */
2585         uiBlockBeginAlign(block);
2586         uiDefButBitS(block, TOG, PAF_STATIC, B_EFFECT_DEP, "Static",    160,180,75,20, &paf->flag, 0, 0, 0, 0, "Make static particles (deform only works with SubSurf)");
2587         if(paf->flag & PAF_STATIC) {
2588                 uiDefButBitS(block, TOG, PAF_ANIMATED, B_DIFF, "Animated",      235,180,75,20, &paf->flag, 0, 0, 0, 0, "Static particles are recalculated each rendered frame");
2589         }
2590         uiBlockEndAlign(block);
2591
2592         uiDefBut(block, LABEL, 0, "Display:",                           160,150,75,20, NULL, 0.0, 0, 0, 0, "");
2593         uiBlockBeginAlign(block);
2594         uiDefButS(block, NUM, B_CALCEFFECT, "Material:",        160,130,150,20, &paf->omat, 1.0, 16.0, 0, 0, "Specify material used for the particles");
2595         uiDefButS(block, TOG|BIT|7, B_REDR, "Mesh",                     160,110,50,20, &paf->flag, 0, 0, 0, 0, "Render emitter Mesh also");
2596         uiDefButBitS(block, TOG, PAF_UNBORN, B_DIFF, "Unborn",210,110,50,20, &paf->flag, 0, 0, 0, 0, "Make particles appear before they are emitted");
2597         uiDefButBitS(block, TOG, PAF_DIED, B_DIFF, "Died",      260,110,50,20, &paf->flag, 0, 0, 0, 0, "Make particles appear after they have died");
2598         uiDefButS(block, TOG, REDRAWVIEW3D, "Vect",                     160,90,75,20, &paf->stype, 0, 0, 0, 0, "Give the particles a direction and rotation");
2599         uiDefButF(block, NUM, B_DIFF,           "Size:",                235,90,75,20, &paf->vectsize, 0.0, 1.0, 10, 1, "The amount the Vect option influences halo size");      
2600         uiBlockEndAlign(block);
2601
2602         uiDefBut(block, LABEL, 0, "Children:",                          160,70,75,20, NULL, 0.0, 0, 0, 0, "");
2603         uiBlockBeginAlign(block);
2604         uiDefButS(block, NUM, B_REDR,           "Generation:",  160,50,150,20, &paf->curmult, 0.0, 3.0, 0, 0, "Current generation of particles");
2605         uiDefButS(block, NUM, B_CALCEFFECT, "Num:",                     160,30,75,20, paf->child+paf->curmult, 1.0, 600.0, 100, 0, "Specify the number of generations of particles that can multiply itself");
2606         uiDefButF(block, NUM, B_CALCEFFECT, "Prob:",            235,30,75,20, paf->mult+paf->curmult, 0.0, 1.0, 10, 1, "Probability \"dying\" particle spawns a new one.");
2607         uiDefButF(block, NUM, B_CALCEFFECT, "Life:",            160,10,75,20, paf->life+paf->curmult, 1.0, 600.0, 100, 1, "Specify the lifespan of the next generation particles");
2608         uiDefButS(block, NUM, B_CALCEFFECT, "Mat:",                     235,10,75,20, paf->mat+paf->curmult, 1.0, 8.0, 0, 0, "Specify the material used for the particles");
2609         uiBlockEndAlign(block);
2610         
2611 }
2612
2613 /* NT - Panel for fluidsim settings */
2614 static void object_panel_fluidsim(Object *ob)
2615 {
2616 #ifndef DISABLE_ELBEEM
2617         uiBlock *block;
2618         int yline = 160;
2619         const int lineHeight = 20;
2620         const int separateHeight = 3;
2621         const int objHeight = 20;
2622         
2623         block= uiNewBlock(&curarea->uiblocks, "object_fluidsim", UI_EMBOSS, UI_HELV, curarea->win);
2624         uiNewPanelTabbed("Soft Body", "Physics");
2625         if(uiNewPanel(curarea, block, "Fluid Simulation", "Physics", 1060, 0, 318, 204)==0) return;
2626
2627         if(ob->id.lib) uiSetButLock(1, "Can't edit library data");
2628         
2629         if(ob->type==OB_MESH) {
2630                 uiDefButBitS(block, TOG, OB_FLUIDSIM_ENABLE, REDRAWBUTSOBJECT, "Enable",         0,yline, 75,objHeight, 
2631                                 &ob->fluidsimFlag, 0, 0, 0, 0, "Sets object to participate in fluid simulation");
2632
2633                 if(ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) {
2634                         FluidsimSettings *fss= ob->fluidsimSettings;
2635                         
2636                         if(fss==NULL) {
2637                                 fss = ob->fluidsimSettings = fluidsimSettingsNew(ob);
2638                         }
2639                         
2640                         uiBlockBeginAlign(block);
2641                         uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Domain",           90, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_DOMAIN,  20.0, 1.0, "Bounding box of this object represents the computational domain of the fluid simulation.");
2642                         uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Fluid",           160, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_FLUID,   20.0, 2.0, "Object represents a volume of fluid in the simulation.");
2643                         uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Obstacle",      230, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_OBSTACLE,20.0, 3.0, "Object is a fixed obstacle.");
2644                         yline -= lineHeight;
2645
2646                         uiDefButS(block, ROW, REDRAWBUTSOBJECT    ,"Inflow",        90, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_INFLOW,  20.0, 4.0, "Object adds fluid to the simulation.");
2647                         uiDefButS(block, ROW, REDRAWBUTSOBJECT    ,"Outflow",   160, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_OUTFLOW, 20.0, 5.0, "Object removes fluid from the simulation.");
2648                         uiDefButS(block, ROW, B_FLUIDSIM_MAKEPART ,"Particle",   230, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_PARTICLE,20.0, 3.0, "Object is made a particle system to display particles generated by a fluidsim domain object.");
2649                         uiBlockEndAlign(block);
2650                         yline -= lineHeight;
2651                         yline -= 2*separateHeight;
2652
2653                         /* display specific settings for each type */
2654                         if(fss->type == OB_FLUIDSIM_DOMAIN) {
2655                                 const int maxRes = 512;
2656                                 char memString[32];
2657
2658                                 // use mesh bounding box and object scaling
2659                                 // TODO fix redraw issue
2660                                 elbeemEstimateMemreq(fss->resolutionxyz, 
2661                                                 ob->fluidsimSettings->bbSize[0],ob->fluidsimSettings->bbSize[1],ob->fluidsimSettings->bbSize[2], fss->maxRefine, memString);
2662                                 
2663                                 uiBlockBeginAlign(block);
2664                                 uiDefButS(block, ROW, REDRAWBUTSOBJECT, "Std",   0,yline, 25,objHeight, &fss->show_advancedoptions, 16.0, 0, 20.0, 0, "Show standard domain options.");
2665                                 uiDefButS(block, ROW, REDRAWBUTSOBJECT, "Adv",  25,yline, 25,objHeight, &fss->show_advancedoptions, 16.0, 1, 20.0, 1, "Show advanced domain options.");
2666                                 uiDefButS(block, ROW, REDRAWBUTSOBJECT, "Bnd",  50,yline, 25,objHeight, &fss->show_advancedoptions, 16.0, 2, 20.0, 2, "Show domain boundary options.");
2667                                 uiBlockEndAlign(block);
2668                                 
2669                                 uiDefBut(block, BUT, B_FLUIDSIM_BAKE, "BAKE",90, yline,210,objHeight, NULL, 0.0, 0.0, 10, 0, "Perform simulation and output and surface&preview meshes for each frame.");
2670                                 yline -= lineHeight;
2671                                 yline -= 2*separateHeight;
2672
2673                                 if(fss->show_advancedoptions == 0) {
2674                                         uiDefBut(block, LABEL,   0, "Req. BAKE Memory:",  0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "");
2675                                         uiDefBut(block, LABEL,   0, memString,  200,yline,100,objHeight, NULL, 0.0, 0, 0, 0, "");
2676                                         yline -= lineHeight;
2677
2678                                         uiBlockBeginAlign(block);
2679                                         uiDefButS(block, NUM, REDRAWBUTSOBJECT, "Resolution:", 0, yline,150,objHeight, &fss->resolutionxyz, 1, maxRes, 10, 0, "Domain resolution in X,Y and Z direction");
2680                                         uiDefButS(block, NUM, B_DIFF,           "Preview-Res.:", 150, yline,150,objHeight, &fss->previewresxyz, 1, 100, 10, 0, "Resolution of the preview meshes to generate, also in X,Y and Z direction");
2681                                         uiBlockEndAlign(block);
2682                                         yline -= lineHeight;
2683                                         yline -= 1*separateHeight;
2684
2685                                         uiBlockBeginAlign(block);
2686                                         uiDefButF(block, NUM, B_DIFF, "Start time:",   0, yline,150,objHeight, &fss->animStart, 0.0, 100.0, 10, 0, "Simulation time of the first blender frame.");
2687                                         uiDefButF(block, NUM, B_DIFF, "End time:",   150, yline,150,objHeight, &fss->animEnd  , 0.0, 100.0, 10, 0, "Simulation time of the last blender frame.");
2688                                         uiBlockEndAlign(block);
2689                                         yline -= lineHeight;
2690                                         yline -= 2*separateHeight;
2691
2692                                         if((fss->guiDisplayMode<1) || (fss->guiDisplayMode>3)){ fss->guiDisplayMode=2; } // can be changed by particle setting
2693                                         uiDefBut(block, LABEL,   0, "Disp.-Qual.:",              0,yline, 90,objHeight, NULL, 0.0, 0, 0, 0, "");
2694                                         uiBlockBeginAlign(block);
2695                                         uiDefButS(block, MENU, B_FLUIDSIM_FORCEREDRAW, "GuiDisplayMode%t|Geometry %x1|Preview %x2|Final %x3",   
2696                                                          90,yline,105,objHeight, &fss->guiDisplayMode, 0, 0, 0, 0, "How to display the fluid mesh in the blender gui.");
2697                                         uiDefButS(block, MENU, B_DIFF, "RenderDisplayMode%t|Geometry %x1|Preview %x2|Final %x3",        
2698                                                         195,yline,105,objHeight, &fss->renderDisplayMode, 0, 0, 0, 0, "How to display the fluid mesh for rendering.");
2699                                         uiBlockEndAlign(block);
2700                                         yline -= lineHeight;
2701                                         yline -= 1*separateHeight;
2702
2703                                         uiBlockBeginAlign(block);
2704                                         uiDefIconBut(block, BUT, B_FLUIDSIM_SELDIR, ICON_FILESEL,  0, yline,  20, objHeight,                   0, 0, 0, 0, 0,  "Select Directory (and/or filename prefix) to store baked fluid simulation files in");
2705                                         uiDefBut(block, TEX,     B_FLUIDSIM_FORCEREDRAW,"",           20, yline, 280, objHeight, fss->surfdataPath, 0.0,79.0, 0, 0,  "Enter Directory (and/or filename prefix) to store baked fluid simulation files in");
2706                                         uiBlockEndAlign(block);
2707                                         // FIXME what is the 79.0 above?
2708                                 } else if(fss->show_advancedoptions == 1) {
2709                                         // advanced options
2710                                         uiDefBut(block, LABEL, 0, "Gravity:",           0, yline,  90,objHeight, NULL, 0.0, 0, 0, 0, "");
2711                                         uiBlockBeginAlign(block);
2712                                         uiDefButF(block, NUM, B_DIFF, "X:",    90, yline,  70,objHeight, &fss->gravx, -1000.1, 1000.1, 10, 0, "Gravity in X direction");
2713                                         uiDefButF(block, NUM, B_DIFF, "Y:",   160, yline,  70,objHeight, &fss->gravy, -1000.1, 1000.1, 10, 0, "Gravity in Y direction");
2714                                         uiDefButF(block, NUM, B_DIFF, "Z:",   230, yline,  70,objHeight, &fss->gravz, -1000.1, 1000.1, 10, 0, "Gravity in Z direction");
2715                                         uiBlockEndAlign(block);
2716                                         yline -= lineHeight;
2717                                         yline -= 1*separateHeight;
2718
2719                                         /* viscosity */
2720                                         if (fss->viscosityMode==1) /*manual*/
2721                                                 uiBlockBeginAlign(block);
2722                                         uiDefButS(block, MENU, REDRAWVIEW3D, "Viscosity%t|Manual %x1|Water %x2|Oil %x3|Honey %x4",      
2723                                                         0,yline, 90,objHeight, &fss->viscosityMode, 0, 0, 0, 0, "Set viscosity of the fluid to a preset value, or use manual input.");
2724                                         if(fss->viscosityMode==1) {
2725                                                 uiDefButF(block, NUM, B_DIFF, "Value:",     90, yline, 105,objHeight, &fss->viscosityValue,       0.0, 10.0, 10, 0, "Viscosity setting, value that is multiplied by 10 to the power of (exponent*-1).");
2726                                                 uiDefButS(block, NUM, B_DIFF, "Neg-Exp.:", 195, yline, 105,objHeight, &fss->viscosityExponent, 0,   10,  10, 0, "Negative exponent for the viscosity value (to simplify entering small values e.g. 5*10^-6.");
2727                                                 uiBlockEndAlign(block);
2728                                         } else {
2729                                                 // display preset values
2730                                                 uiDefBut(block, LABEL,   0, fluidsimViscosityPresetString[fss->viscosityMode],  90,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
2731                                         }
2732                                         yline -= lineHeight;
2733                                         yline -= 1*separateHeight;
2734
2735                                         uiDefBut(block, LABEL, 0, "Realworld-size:",            0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "");
2736                                         uiDefButF(block, NUM, B_DIFF, "", 150, yline,150,objHeight, &fss->realsize, 0.001, 10.0, 10, 0, "Size of the simulation domain in meters.");
2737                                         yline -= lineHeight;
2738                                         yline -= 2*separateHeight;
2739
2740                                         uiDefBut(block, LABEL, 0, "Gridlevels:",                0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "");
2741                                         uiDefButI(block, NUM, B_DIFF, "", 150, yline,150,objHeight, &fss->maxRefine, -1, 4, 10, 0, "Number of coarsened Grids to use (set to -1 for automatic selection).");
2742                                         yline -= lineHeight;
2743
2744                                         uiDefBut(block, LABEL, 0, "Compressibility:",           0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "");
2745                                         uiDefButF(block, NUM, B_DIFF, "", 150, yline,150,objHeight, &fss->gstar, 0.001, 0.10, 10,0, "Allowed compressibility due to gravitational force for standing fluid (directly affects simulation step size).");
2746                                         yline -= lineHeight;
2747
2748                                 } else if(fss->show_advancedoptions == 2) {
2749                                         // copied from obstacle...
2750                                         //yline -= lineHeight + 5;
2751                                         //uiDefBut(block, LABEL, 0, "Domain boundary type settings:",           0,yline,300,objHeight, NULL, 0.0, 0, 0, 0, "");
2752                                         //yline -= lineHeight;
2753
2754                                         uiBlockBeginAlign(block); // domain
2755                                         uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Noslip",    0, yline,100,objHeight, &fss->typeFlags, 15.0, OB_FSBND_NOSLIP,   20.0, 1.0, "Obstacle causes zero normal and tangential velocity (=sticky). Default for all. Only option for movi