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