- added option to switch off compiling elbeem to scons files (set USE_FLUIDSIM=true)
[blender-staging.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_screen_types.h"
45 #include "DNA_space_types.h"
46 #include "DNA_scene_types.h"
47
48 #include "BKE_action.h"
49 #include "BKE_global.h"
50 #include "BKE_main.h"
51 #include "BKE_library.h"
52 #include "BKE_softbody.h"
53 #include "BKE_utildefines.h"
54
55 #include "BLI_blenlib.h"
56 #include "BLI_arithb.h"
57
58 #include "BSE_filesel.h"
59 #include "BSE_headerbuttons.h"
60
61 #include "BIF_butspace.h"
62 #include "BDR_editcurve.h"
63 #include "BIF_gl.h"
64 #include "BIF_glutil.h"
65 #include "BIF_graphics.h"
66 #include "BIF_interface.h"
67 #include "BIF_keyval.h"
68 #include "BIF_mainqueue.h"
69 #include "BIF_mywindow.h"
70 #include "BIF_poseobject.h"
71 #include "BIF_resources.h"
72 #include "BIF_screen.h"
73 #include "BIF_space.h"
74 #include "BIF_toolbox.h"
75
76 #include "BDR_drawobject.h"
77
78 #include "mydevice.h"
79 #include "blendef.h"
80
81 /* -----includes for this file specific----- */
82
83
84 #include "DNA_action_types.h"
85 #include "DNA_armature_types.h"
86 #include "DNA_camera_types.h"
87 #include "DNA_constraint_types.h"
88 #include "DNA_curve_types.h"
89 #include "DNA_effect_types.h"
90 #include "DNA_group_types.h"
91 #include "DNA_image_types.h"
92 #include "DNA_key_types.h"
93 #include "DNA_lamp_types.h"
94 #include "DNA_lattice_types.h"
95 #include "DNA_material_types.h"
96 #include "DNA_meta_types.h"
97 #include "DNA_mesh_types.h"
98 #include "DNA_modifier_types.h"
99 #include "DNA_object_types.h"
100 #include "DNA_object_force.h"
101 #include "DNA_object_fluidsim.h"
102 #include "DNA_radio_types.h"
103 #include "DNA_screen_types.h"
104 #include "DNA_sound_types.h"
105 #include "DNA_texture_types.h"
106 #include "DNA_userdef_types.h"
107 #include "DNA_vfont_types.h"
108 #include "DNA_view3d_types.h"
109 #include "DNA_world_types.h"
110
111 #include "BKE_anim.h"
112 #include "BKE_armature.h"
113 #include "BKE_constraint.h"
114 #include "BKE_curve.h"
115 #include "BKE_depsgraph.h"
116 #include "BKE_displist.h"
117 #include "BKE_effect.h"
118 #include "BKE_font.h"
119 #include "BKE_image.h"
120 #include "BKE_ipo.h"
121 #include "BKE_lattice.h"
122 #include "BKE_material.h"
123 #include "BKE_mball.h"
124 #include "BKE_mesh.h"
125 #include "BKE_modifier.h"
126 #include "BKE_object.h"
127 #include "BKE_sound.h"
128 #include "BKE_texture.h"
129 #include "BKE_utildefines.h"
130 #include "BKE_DerivedMesh.h"
131 #include "LBM_fluidsim.h"
132
133 #include "BIF_editconstraint.h"
134 #include "BSE_editipo.h"
135 #include "BDR_editobject.h"
136
137 #include "butspace.h" // own module
138
139 static float prspeed=0.0;
140 float prlen=0.0;
141
142
143 /* ********************* CONSTRAINT ***************************** */
144
145 static void constraint_active_func(void *ob_v, void *con_v)
146 {
147         Object *ob= ob_v;
148         bConstraint *con;
149         ListBase *lb;
150         
151         /* lets be nice and escape if its active already */
152         if(con_v) {
153                 con= con_v;
154                 if(con->flag & CONSTRAINT_ACTIVE) return;
155         }
156         
157         lb= get_active_constraints(ob);
158         
159         for(con= lb->first; con; con= con->next) {
160                 if(con==con_v) con->flag |= CONSTRAINT_ACTIVE;
161                 else con->flag &= ~CONSTRAINT_ACTIVE;
162         }
163
164         /* make sure ipowin and buttons shows it */
165         if(ob->ipowin==IPO_CO) {
166                 allqueue(REDRAWIPO, IPO_CO);
167                 allspace(REMAKEIPO, 0);
168                 allqueue(REDRAWNLA, 0);
169         }
170         allqueue(REDRAWBUTSOBJECT, 0);
171 }
172
173 static void add_constraint_to_active(Object *ob, bConstraint *con)
174 {
175         ListBase *list;
176         
177         list = get_active_constraints(ob);
178         if (list) {
179                 unique_constraint_name(con, list);
180                 BLI_addtail(list, con);
181                 
182                 con->flag |= CONSTRAINT_ACTIVE;
183                 for(con= con->prev; con; con= con->prev)
184                         con->flag &= ~CONSTRAINT_ACTIVE;
185         }
186 }
187
188 static void enable_constraint_ipo_func (void *ob_v, void *con_v)
189 {
190         Object *ob= ob_v;
191         bConstraint *con = con_v;
192         bConstraintChannel *chan;
193         ListBase *conbase;
194
195         constraint_active_func(ob_v, con_v);
196                 
197         conbase = get_active_constraint_channels(ob, 1);        // 1 == create
198
199         if (!conbase)
200                 return;
201
202         /* See if this list already has an appropriate channel */
203         chan = find_constraint_channel(conbase, con->name);
204
205         if (!chan){
206                 /* Add a new constraint channel */
207                 chan = MEM_callocN(sizeof(bConstraintChannel), "constraintChannel");
208                 strcpy(chan->name, con->name);
209                 BLI_addtail(conbase, chan);
210         }
211
212         /* Ensure there is an ipo to display */
213         if (!chan->ipo){
214                 chan->ipo = add_ipo(con->name, IPO_CO);
215         }
216
217         /* make sure ipowin shows it */
218         ob->ipowin= IPO_CO;
219         allqueue(REDRAWIPO, IPO_CO);
220         allspace(REMAKEIPO, 0);
221         allqueue(REDRAWNLA, 0);
222 }
223
224
225 static void add_influence_key_to_constraint_func (void *ob_v, void *con_v)
226 {
227         Object *ob= ob_v;
228         bConstraint *con = con_v;
229         bConstraintChannel *chan;
230         ListBase *conbase;
231         IpoCurve *icu;
232         
233         constraint_active_func(ob_v, con_v);
234         conbase = get_active_constraint_channels(ob, 1);        // 1=make
235         
236         if (!conbase)
237                 return;
238         
239         /* See if this list already has an appropriate channel */
240         chan = find_constraint_channel(conbase, con->name);
241         
242         if (!chan){
243                 /* Add a new constraint channel */
244                 chan = MEM_callocN(sizeof(bConstraintChannel), "constraintChannel");
245                 strcpy(chan->name, con->name);
246                 BLI_addtail(conbase, chan);
247         }
248         
249         /* Ensure there is an ipo to display */
250         if (!chan->ipo){
251                 chan->ipo = add_ipo(con->name, IPO_CO);
252         }
253         
254         /* now insert an ipo key */
255         icu= get_ipocurve(NULL, IPO_CO, CO_ENFORCE, chan->ipo);
256         insert_vert_ipo(icu, CFRA, con->enforce);
257         
258         /* make sure ipowin shows it */
259         ob->ipowin= IPO_CO;
260         allqueue(REDRAWIPO, IPO_CO);
261         allspace(REMAKEIPO, 0);
262         allqueue(REDRAWNLA, 0);
263         
264         BIF_undo_push("Insert Influence Key");
265 }
266
267
268 static void del_constraint_func (void *ob_v, void *con_v)
269 {
270         bConstraint *con= con_v;
271         bConstraintChannel *chan;
272         ListBase *lb;
273         
274         /* remove ipo channel */
275         lb= get_active_constraint_channels(ob_v, 0);
276         if(lb) {
277                 chan = find_constraint_channel(lb, con->name);
278                 if(chan) {
279                         if(chan->ipo) chan->ipo->id.us--;
280                         BLI_freelinkN(lb, chan);
281                 }
282         }
283         /* remove constraint itself */
284         lb= get_active_constraints(ob_v);
285         free_constraint_data (con);
286         BLI_freelinkN(lb, con);
287         
288         constraint_active_func(ob_v, NULL);
289
290         BIF_undo_push("Delete constraint");
291         allqueue(REDRAWBUTSOBJECT, 0);
292         allqueue(REDRAWIPO, 0); 
293
294 }
295
296 static void verify_constraint_name_func (void *ob_v, void *con_v)
297 {
298         ListBase *conlist;
299         bConstraint *con= con_v;
300         
301         if (!con)
302                 return;
303         
304         conlist = get_active_constraints(ob_v);
305         unique_constraint_name (con, conlist);
306         constraint_active_func(ob_v, con);
307
308 }
309
310 static void get_constraint_typestring (char *str, bConstraint *con)
311 {
312         switch (con->type){
313         case CONSTRAINT_TYPE_CHILDOF:
314                 strcpy (str, "Child Of");
315                 return;
316         case CONSTRAINT_TYPE_NULL:
317                 strcpy (str, "Null");
318                 return;
319         case CONSTRAINT_TYPE_TRACKTO:
320                 strcpy (str, "Track To");
321                 return;
322         case CONSTRAINT_TYPE_MINMAX:
323                 strcpy (str, "Floor");
324                 return;
325         case CONSTRAINT_TYPE_KINEMATIC:
326                 strcpy (str, "IK Solver");
327                 return;
328         case CONSTRAINT_TYPE_ROTLIKE:
329                 strcpy (str, "Copy Rotation");
330                 return;
331         case CONSTRAINT_TYPE_LOCLIKE:
332                 strcpy (str, "Copy Location");
333                 return;
334         case CONSTRAINT_TYPE_ACTION:
335                 strcpy (str, "Action");
336                 return;
337         case CONSTRAINT_TYPE_LOCKTRACK:
338                 strcpy (str, "Locked Track");
339                 return;
340         case CONSTRAINT_TYPE_FOLLOWPATH:
341                 strcpy (str, "Follow Path");
342                 return;
343         case CONSTRAINT_TYPE_STRETCHTO:
344                 strcpy (str, "Stretch To");
345                 return;
346         default:
347                 strcpy (str, "Unknown");
348                 return;
349         }
350 }
351
352 static int get_constraint_col(bConstraint *con)
353 {
354         switch (con->type) {
355         case CONSTRAINT_TYPE_NULL:
356                 return TH_BUT_NEUTRAL;
357         case CONSTRAINT_TYPE_KINEMATIC:
358                 return TH_BUT_SETTING2;
359         case CONSTRAINT_TYPE_TRACKTO:
360                 return TH_BUT_SETTING;
361         case CONSTRAINT_TYPE_ROTLIKE:
362                 return TH_BUT_SETTING1;
363         case CONSTRAINT_TYPE_LOCLIKE:
364                 return TH_BUT_POPUP;
365         case CONSTRAINT_TYPE_MINMAX:
366                 return TH_BUT_POPUP;
367         case CONSTRAINT_TYPE_ACTION:
368                 return TH_BUT_ACTION;
369         case CONSTRAINT_TYPE_LOCKTRACK:
370                 return TH_BUT_SETTING;
371         case CONSTRAINT_TYPE_FOLLOWPATH:
372                 return TH_BUT_SETTING2;
373         case CONSTRAINT_TYPE_STRETCHTO:
374                 return TH_BUT_SETTING;
375         default:
376                 return TH_REDALERT;
377         }
378 }
379
380 static void constraint_moveUp(void *ob_v, void *con_v)
381 {
382         bConstraint *con, *constr= con_v;
383         ListBase *conlist;
384         
385         if(constr->prev) {
386                 conlist = get_active_constraints(ob_v);
387                 for(con= conlist->first; con; con= con->next) {
388                         if(con==constr) {
389                                 BLI_remlink(conlist, con);
390                                 BLI_insertlink(conlist, con->prev->prev, con);
391                                 break;
392                         }
393                 }
394         }
395         BIF_undo_push("Move constraint");
396 }
397
398 static void constraint_moveDown(void *ob_v, void *con_v)
399 {
400         bConstraint *con, *constr= con_v;
401         ListBase *conlist;
402         
403         if(constr->next) {
404                 conlist = get_active_constraints(ob_v);
405                 for(con= conlist->first; con; con= con->next) {
406                         if(con==constr) {
407                                 BLI_remlink(conlist, con);
408                                 BLI_insertlink(conlist, con->next, con);
409                                 break;
410                         }
411                 }
412         }
413         BIF_undo_push("Move constraint");
414 }
415
416
417 static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, short *xco, short *yco)
418 {
419         Object *ob= OBACT;
420         uiBut *but;
421         char typestr[64];
422         short height, width = 265;
423         int curCol, rb_col;
424
425         /* unless button has own callback, it adds this callback to button */
426         uiBlockSetFunc(block, constraint_active_func, ob, con);
427         
428         get_constraint_typestring (typestr, con);
429
430         curCol = get_constraint_col(con);
431
432         /* Draw constraint header */
433         uiBlockSetEmboss(block, UI_EMBOSSN);
434         
435         /* rounded header */
436         rb_col= (con->flag & CONSTRAINT_ACTIVE)?40:20;
437         uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-1, width+40, 22, NULL, 5.0, 0.0, 
438                          (con->flag & CONSTRAINT_EXPAND)?3:15 , rb_col-20, ""); 
439         
440         /* open/close */
441         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");
442         
443         /* up down */
444         uiBlockSetEmboss(block, UI_EMBOSS);
445         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");
446         uiButSetFunc(but, constraint_moveUp, ob, con);
447         
448         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");
449         uiButSetFunc(but, constraint_moveDown, ob, con);
450         
451         if (con->flag & CONSTRAINT_EXPAND) {
452                 
453                 if (con->flag & CONSTRAINT_DISABLE) {
454                         BIF_ThemeColor(TH_REDALERT);
455                         uiBlockSetCol(block, TH_REDALERT);
456                 }
457                 else
458                         BIF_ThemeColor(curCol);
459
460                 /*if (type==TARGET_BONE)
461                         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"); 
462                 else
463                         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"); 
464                 */
465                 uiBlockSetEmboss(block, UI_EMBOSS);
466                 
467                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+10, *yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
468                 
469                 but = uiDefBut(block, TEX, B_CONSTRAINT_TEST, "", *xco+120, *yco, 85, 18, con->name, 0.0, 29.0, 0.0, 0.0, "Constraint name"); 
470                 uiButSetFunc(but, verify_constraint_name_func, ob, con);
471         }       
472         else{
473                 uiBlockSetEmboss(block, UI_EMBOSSN);
474
475                 if (con->flag & CONSTRAINT_DISABLE) {
476                         uiBlockSetCol(block, TH_REDALERT);
477                         BIF_ThemeColor(TH_REDALERT);
478                 }
479                 else
480                         BIF_ThemeColor(curCol);
481                 
482                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+10, *yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
483                 
484                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, con->name, *xco+120, *yco-1, 135, 19, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
485         }
486
487         uiBlockSetCol(block, TH_AUTO);  
488         
489         uiBlockSetEmboss(block, UI_EMBOSSN);
490         
491         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");
492         uiButSetFunc(but, del_constraint_func, ob, con);
493
494         uiBlockSetEmboss(block, UI_EMBOSS);
495
496
497         /* Draw constraint data*/
498         if (!(con->flag & CONSTRAINT_EXPAND)) {
499                 (*yco)-=21;
500         }
501         else {
502                 switch (con->type){
503                 case CONSTRAINT_TYPE_ACTION:
504                         {
505                                 bActionConstraint *data = con->data;
506                                 bArmature *arm;
507
508                                 height = 88;
509                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
510                                 
511                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
512
513                                 /* Draw target parameters */
514                                 uiBlockBeginAlign(block);
515                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
516
517                                 arm = get_armature(data->tar);
518                                 if (arm){
519                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
520                                 }
521                                 else
522                                         strcpy (data->subtarget, "");
523                                 uiBlockEndAlign(block);
524
525                                 /* Draw action button */
526                                 uiBlockBeginAlign(block);
527                                 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");
528                                 uiDefIDPoinBut(block, test_actionpoin_but, B_CONSTRAINT_TEST, "AC:",    *xco+((width/2)-117), *yco-64, 78, 18, &data->act, "Action containing the keyed motion for this bone"); 
529                                 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");
530
531                                 uiBlockBeginAlign(block);
532                                 uiDefButS(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"); 
533                                 uiDefButS(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"); 
534                                 
535                                 uiBlockBeginAlign(block);
536                                 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");
537                                 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");
538                                 uiBlockEndAlign(block);
539                         }
540                         break;
541                 case CONSTRAINT_TYPE_LOCLIKE:
542                         {
543                                 bLocateLikeConstraint *data = con->data;
544                                 bArmature *arm;
545                                 
546                                 height = 66;
547                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
548
549                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
550
551                                 /* Draw target parameters */
552                                 uiBlockBeginAlign(block);
553                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
554
555                                 arm = get_armature(data->tar);
556                                 if (arm){
557                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
558                                 }
559                                 else
560                                         strcpy (data->subtarget, "");
561                                 uiBlockEndAlign(block);
562                                 
563                                 /* Draw XYZ toggles */
564                                 uiBlockBeginAlign(block);
565                                 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");
566                                 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");
567                                 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");
568                                 uiBlockEndAlign(block);
569                         }
570                         break;
571                 case CONSTRAINT_TYPE_ROTLIKE:
572                         {
573                                 bRotateLikeConstraint *data = con->data;
574                                 bArmature *arm;
575                                 
576                                 height = 46;
577                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
578                                 
579                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
580
581                                 /* Draw target parameters */
582                                 uiBlockBeginAlign(block);
583                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
584
585                                 arm = get_armature(data->tar);
586                                 if (arm){
587                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
588                                 }
589                                 else
590                                         strcpy (data->subtarget, "");
591                                 uiBlockEndAlign(block);
592                         }
593                         break;
594                 case CONSTRAINT_TYPE_KINEMATIC:
595                         {
596                                 bKinematicConstraint *data = con->data;
597                                 bArmature *arm;
598                                 
599                                 height = 108;
600                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
601                                 
602                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
603
604                                 /* Draw target parameters */
605                                 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");
606                                 
607                                 uiBlockBeginAlign(block);
608                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 19, &data->tar, "Target Object"); 
609
610                                 arm = get_armature(data->tar);
611                                 if (arm)
612                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,19, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
613                                 else
614                                         strcpy (data->subtarget, "");
615         
616                                 uiBlockBeginAlign(block);
617                                 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");
618                                 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");
619                                 
620                                 uiBlockBeginAlign(block);
621                                 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");
622                                 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");
623                                 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"); 
624                                 uiDefButS(block, NUM, B_CONSTRAINT_TEST, "Iterations:", *xco+142, *yco-106, 143, 19, &data->iterations, 1, 10000, 0, 0, "Maximum number of solving iterations"); 
625                                 
626                         }
627                         break;
628                 case CONSTRAINT_TYPE_TRACKTO:
629                         {
630                                 bTrackToConstraint *data = con->data;
631                                 bArmature *arm;
632
633                                 height = 66;
634                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
635                                 
636                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
637
638                                 /* Draw target parameters */
639                                 uiBlockBeginAlign(block);
640                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
641
642                                 arm = get_armature(data->tar);
643                                 if (arm){
644                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
645                                 }
646                                 else
647                                         strcpy (data->subtarget, "");
648                                 uiBlockEndAlign(block);
649
650                                 uiBlockBeginAlign(block);
651                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "To:", *xco+12, *yco-64, 25, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
652                                 
653                                 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");
654                                 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");
655                                 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");
656                                 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");
657                                 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");
658                                 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");
659                                 uiBlockEndAlign(block);
660                                 
661                                 uiBlockBeginAlign(block);
662                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Up:", *xco+174, *yco-64, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
663                                 
664                                 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");
665                                 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");
666                                 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");
667                                 uiBlockEndAlign(block);
668                         }
669                         break;
670                 case CONSTRAINT_TYPE_MINMAX:
671                         {
672                                 bMinMaxConstraint *data = con->data;
673                                 bArmature *arm;
674
675                                 height = 66;
676                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
677                                 
678                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
679
680                                 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"); 
681
682                                 /* Draw target parameters */
683                                 uiBlockBeginAlign(block);
684                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
685
686                                 arm = get_armature(data->tar);
687                                 if (arm){
688                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
689                                 }
690                                 else
691                                         strcpy (data->subtarget, "");
692                                 uiBlockEndAlign(block);
693
694                                 but=uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "Sticky", *xco, *yco-24, 54, 18, &data->sticky, 0, 24, 0, 0, "Immobilize object while constrained");
695                                 
696                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Max/Min:", *xco-8, *yco-64, 54, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
697
698                                 uiBlockBeginAlign(block);                       
699                                 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");
700                                 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");
701                                 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");
702                                 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");
703                                 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");
704                                 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");
705                                 uiBlockEndAlign(block);
706                         }
707                         break;
708                 case CONSTRAINT_TYPE_LOCKTRACK:
709                         {
710                                 bLockTrackConstraint *data = con->data;
711                                 bArmature *arm;
712                                 height = 66;
713                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
714
715                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
716
717                                 /* Draw target parameters */
718                                 uiBlockBeginAlign(block);
719                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
720
721                                 arm = get_armature(data->tar);
722                                 if (arm){
723                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
724                                 }
725                                 else
726                                         strcpy (data->subtarget, "");
727                                 uiBlockEndAlign(block);
728                                 
729                                 uiBlockBeginAlign(block);
730                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "To:", *xco+12, *yco-64, 25, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
731                                 
732                                 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");
733                                 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");
734                                 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");
735                                 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");
736                                 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");
737                                 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");
738                                 uiBlockEndAlign(block);
739                                 
740                                 uiBlockBeginAlign(block);
741                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Lock:", *xco+166, *yco-64, 38, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
742                                 
743                                 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");
744                                 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");
745                                 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");
746                                 uiBlockEndAlign(block);
747                         }
748                         break;
749                 case CONSTRAINT_TYPE_FOLLOWPATH:
750                         {
751                                 bFollowPathConstraint *data = con->data;
752
753                                 height = 66;
754                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
755                                 
756                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
757
758                                 /* Draw target parameters */
759                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
760                                 
761                                 /* Draw Curve Follow toggle */
762                                 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");
763
764                                 /* Draw Offset number button */
765                                 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"); 
766
767                                 uiBlockBeginAlign(block);
768                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Fw:", *xco+12, *yco-64, 27, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
769                                 
770                                 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");
771                                 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");
772                                 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");
773                                 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");
774                                 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");
775                                 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");
776                                 uiBlockEndAlign(block);
777                                 
778                                 uiBlockBeginAlign(block);
779                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Up:", *xco+174, *yco-64, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
780                                 
781                                 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");
782                                 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");
783                                 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");
784                                 uiBlockEndAlign(block);
785                         }
786                         break;
787                 case CONSTRAINT_TYPE_STRETCHTO:
788                         {
789                                 bStretchToConstraint *data = con->data;
790                                 bArmature *arm;
791                                 
792                                 height = 105;
793                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
794                                 
795                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
796
797
798                                 /* Draw target parameters */
799                                 uiBlockBeginAlign(block);
800                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
801
802                                 arm = get_armature(data->tar);
803                                 if (arm){
804                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
805                                 }
806                                 else
807                                         strcpy (data->subtarget, "");
808                                 uiBlockEndAlign(block);
809
810                                 
811                                 uiBlockBeginAlign(block);
812                                 uiDefButF(block,BUTM,B_CONSTRAINT_TEST,"R",*xco, *yco-60,20,18,&(data->orglength),0.0,0,0,0,"Recalculate RLenght");
813                                 uiDefButF(block,NUM,B_CONSTRAINT_TEST,"Rest Length:",*xco+18, *yco-60,237,18,&(data->orglength),0.0,100,0.5,0.5,"Lenght at Rest Position");
814                                 uiBlockEndAlign(block);
815
816                                 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");
817
818                                 uiBlockBeginAlign(block);
819                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Vol:",*xco+14, *yco-104,30,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
820                                 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");
821                                 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");
822                                 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");
823                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"NONE", *xco+114, *yco-104,50,18, &data->volmode, 12.0, 3.0, 0, 0, "Ignore Volume");
824                                 uiBlockEndAlign(block);
825
826                                 
827                                 uiBlockBeginAlign(block);
828                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"Plane:",*xco+175, *yco-104,40,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
829                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X",       *xco+215, *yco-104,20,18, &data->plane, 12.0, 0.0, 0, 0, "Keep X axis");
830                                 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z",       *xco+235, *yco-104,20,18, &data->plane, 12.0, 2.0, 0, 0, "Keep Z axis");
831                                 uiBlockEndAlign(block);
832                                 }
833                         break;
834                 case CONSTRAINT_TYPE_NULL:
835                         {
836                                 height = 17;
837                                 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
838                                 
839                         }
840                         break;
841                 default:
842                         height = 0;
843                         break;
844                 }
845
846                 (*yco)-=(24+height);
847         }
848
849         if (con->type!=CONSTRAINT_TYPE_NULL) {
850                 uiBlockBeginAlign(block);
851                 uiDefButF(block, NUMSLI, B_CONSTRAINT_TEST, "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");
852                 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");
853                 /* If this is on an object or bone, add ipo channel the constraint */
854                 uiButSetFunc (but, enable_constraint_ipo_func, ob, con);
855                 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");
856                 /* Add a keyframe to the influence IPO */
857                 uiButSetFunc (but, add_influence_key_to_constraint_func, ob, con);
858                 uiBlockEndAlign(block);
859                 (*yco)-=24;
860         } else {
861                 (*yco)-=3;
862         }
863         
864 }
865
866 static uiBlock *add_constraintmenu(void *arg_unused)
867 {
868         Object *ob= OBACT;
869         uiBlock *block;
870         ListBase *conlist;
871         short yco= 0;
872         
873         conlist = get_active_constraints(ob);
874         
875         block= uiNewBlock(&curarea->uiblocks, "add_constraintmenu", UI_EMBOSSP, UI_HELV, curarea->win);
876
877         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_LOCLIKE,"Copy Location",         0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
878         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_ROTLIKE,"Copy Rotation",         0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
879         
880         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
881         
882         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_TRACKTO,"Track To",              0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
883         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_MINMAX,"Floor",          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
884         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_LOCKTRACK,"Locked Track",                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
885         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_FOLLOWPATH,"Follow Path",                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
886         
887         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
888         
889         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_STRETCHTO,"Stretch To",          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
890
891         if (ob->flag & OB_POSEMODE) {
892                 uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
893                 
894                 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_KINEMATIC,"IK Solver",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
895                 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_ACTION,"Action",         0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
896                 
897         }
898         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
899
900         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_NULL,"Null",             0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
901         
902         uiTextBoundsBlock(block, 50);
903         uiBlockSetDirection(block, UI_DOWN);
904                 
905         return block;
906 }
907
908 void do_constraintbuts(unsigned short event)
909 {
910         Object *ob= OBACT;
911         
912         switch(event) {
913         case B_CONSTRAINT_TEST:
914                 break;  // no handling
915                 
916         case B_CONSTRAINT_CHANGETARGET:
917                 if(ob->pose) ob->pose->flag |= POSE_RECALC;     // checks & sorts pose channels
918                 DAG_scene_sort(G.scene);
919                 break;
920                 
921         case B_CONSTRAINT_ADD_NULL:
922                 {
923                         bConstraint *con;
924                         
925                         con = add_new_constraint(CONSTRAINT_TYPE_NULL);
926                         add_constraint_to_active(ob, con);
927
928                         BIF_undo_push("Add constraint");
929                 }
930                 break;
931         case B_CONSTRAINT_ADD_KINEMATIC:
932                 {
933                         bConstraint *con;
934                         
935                         con = add_new_constraint(CONSTRAINT_TYPE_KINEMATIC);
936                         add_constraint_to_active(ob, con);
937
938                         BIF_undo_push("Add constraint");
939                 }
940                 break;
941         case B_CONSTRAINT_ADD_TRACKTO:
942                 {
943                         bConstraint *con;
944
945                         con = add_new_constraint(CONSTRAINT_TYPE_TRACKTO);
946                         add_constraint_to_active(ob, con);
947
948                         BIF_undo_push("Add constraint");
949                 }
950                 break;
951         case B_CONSTRAINT_ADD_MINMAX:
952                 {
953                         bConstraint *con;
954
955                         con = add_new_constraint(CONSTRAINT_TYPE_MINMAX);
956                         add_constraint_to_active(ob, con);
957
958                         BIF_undo_push("Add constraint");
959                 }
960                 break;
961         case B_CONSTRAINT_ADD_ROTLIKE:
962                 {
963                         bConstraint *con;
964
965                         con = add_new_constraint(CONSTRAINT_TYPE_ROTLIKE);
966                         add_constraint_to_active(ob, con);
967
968                         BIF_undo_push("Add constraint");
969                 }
970                 break;
971         case B_CONSTRAINT_ADD_LOCLIKE:
972                 {
973                         bConstraint *con;
974
975                         con = add_new_constraint(CONSTRAINT_TYPE_LOCLIKE);
976                         add_constraint_to_active(ob, con);
977
978                         BIF_undo_push("Add constraint");
979                 }
980                 break;
981         case B_CONSTRAINT_ADD_ACTION:
982                 {
983                         bConstraint *con;
984
985                         con = add_new_constraint(CONSTRAINT_TYPE_ACTION);
986                         add_constraint_to_active(ob, con);
987
988                         BIF_undo_push("Add constraint");
989                 }
990                 break;
991         case B_CONSTRAINT_ADD_LOCKTRACK:
992                 {
993                         bConstraint *con;
994
995                         con = add_new_constraint(CONSTRAINT_TYPE_LOCKTRACK);
996                         add_constraint_to_active(ob, con);
997
998                         BIF_undo_push("Add constraint");
999                 }
1000                 break;
1001         case B_CONSTRAINT_ADD_FOLLOWPATH:
1002                 {
1003                         bConstraint *con;
1004
1005                         con = add_new_constraint(CONSTRAINT_TYPE_FOLLOWPATH);
1006                         add_constraint_to_active(ob, con);
1007
1008                 }
1009                 break;
1010         case B_CONSTRAINT_ADD_STRETCHTO:
1011                 {
1012                         bConstraint *con;
1013                         con = add_new_constraint(CONSTRAINT_TYPE_STRETCHTO);
1014                         add_constraint_to_active(ob, con);
1015                                 
1016                         BIF_undo_push("Add constraint");
1017                 }
1018                 break;
1019
1020         default:
1021                 break;
1022         }
1023
1024         object_test_constraints(ob);
1025         
1026         if(ob->pose) update_pose_constraint_flags(ob->pose);
1027         
1028         if(ob->type==OB_ARMATURE) DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1029         else DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
1030         
1031         allqueue (REDRAWVIEW3D, 0);
1032         allqueue (REDRAWBUTSOBJECT, 0);
1033 }
1034
1035 void object_panel_constraint(char *context)
1036 {
1037         uiBlock *block;
1038         Object *ob= OBACT;
1039         ListBase *conlist;
1040         bConstraint *curcon;
1041         short xco, yco;
1042         char str[64];
1043         
1044         block= uiNewBlock(&curarea->uiblocks, "object_panel_constraint", UI_EMBOSS, UI_HELV, curarea->win);
1045         if(uiNewPanel(curarea, block, "Constraints", context, 640, 0, 318, 204)==0) return;
1046
1047         /* this is a variable height panel, newpanel doesnt force new size on existing panels */
1048         /* so first we make it default height */
1049         uiNewPanelHeight(block, 204);
1050
1051         if(G.obedit==OBACT) return;     // ??
1052         
1053         conlist = get_active_constraints(OBACT);
1054         
1055         if (conlist) {
1056                  
1057                 uiDefBlockBut(block, add_constraintmenu, NULL, "Add Constraint", 0, 190, 130, 20, "Add a new constraint");
1058                 
1059                 /* print active object or bone */
1060                 str[0]= 0;
1061                 if (ob->flag & OB_POSEMODE){
1062                         bPoseChannel *pchan= get_active_posechannel(ob);
1063                         if(pchan) sprintf(str, "To Bone: %s", pchan->name);
1064                 }
1065                 else {
1066                         sprintf(str, "To Object: %s", ob->id.name+2);
1067                 }
1068                 uiDefBut(block, LABEL, 1, str,  150, 190, 150, 20, NULL, 0.0, 0.0, 0, 0, "Displays Active Object or Bone name");
1069                 
1070                 /* Go through the list of constraints and draw them */
1071                 xco = 10;
1072                 yco = 160;
1073                 
1074                 for (curcon = conlist->first; curcon; curcon=curcon->next) {
1075                         /* Draw default constraint header */                    
1076                         draw_constraint(block, conlist, curcon, &xco, &yco);    
1077                 }
1078                 
1079                 if(yco < 0) uiNewPanelHeight(block, 204-yco);
1080                 
1081         }
1082 }
1083
1084 static void object_panel_draw(Object *ob)
1085 {
1086         uiBlock *block;
1087         int xco, a, dx, dy;
1088         
1089         block= uiNewBlock(&curarea->uiblocks, "object_panel_draw", UI_EMBOSS, UI_HELV, curarea->win);
1090         if(uiNewPanel(curarea, block, "Draw", "Object", 320, 0, 318, 204)==0) return;
1091
1092         /* LAYERS */
1093         xco= 120;
1094         dx= 35;
1095         dy= 30;
1096
1097         uiDefBut(block, LABEL, 0, "Layers",                             10,170,100,20, NULL, 0, 0, 0, 0, "");
1098         
1099         uiBlockBeginAlign(block);
1100         for(a=0; a<5; a++)
1101                 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, "");
1102         for(a=0; a<5; a++)
1103                 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, "");
1104                 
1105         xco+= 7;
1106         uiBlockBeginAlign(block);
1107         for(a=5; a<10; a++)
1108                 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, "");
1109         for(a=5; a<10; a++)
1110                 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, "");
1111
1112         uiBlockEndAlign(block);
1113
1114         uiDefBut(block, LABEL, 0, "Drawtype",                                           10,120,100,20, NULL, 0, 0, 0, 0, "");
1115         
1116         uiBlockBeginAlign(block);
1117         uiDefButC(block, ROW, REDRAWVIEW3D, "Shaded",   10,100,100, 20, &ob->dt, 0, OB_SHADED, 0, 0, "Draw active object shaded or textured");
1118         uiDefButC(block, ROW, REDRAWVIEW3D, "Solid",    10,80,100, 20, &ob->dt, 0, OB_SOLID, 0, 0, "Draw active object in solid");
1119         uiDefButC(block, ROW, REDRAWVIEW3D, "Wire",             10,60, 100, 20, &ob->dt, 0, OB_WIRE, 0, 0, "Draw active object in wireframe");
1120         uiDefButC(block, ROW, REDRAWVIEW3D, "Bounds",   10,40, 100, 20, &ob->dt, 0, OB_BOUNDBOX, 0, 0, "Only draw object with bounding box");
1121         uiBlockEndAlign(block);
1122         
1123         uiDefBut(block, LABEL, 0, "Draw Extra",                                                 120,120,90,20, NULL, 0, 0, 0, 0, "");
1124         
1125         uiBlockBeginAlign(block);
1126         uiDefButBitC(block, TOG, OB_BOUNDBOX, REDRAWVIEW3D, "Bounds",                           120, 100, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's bounds");
1127         uiDefButBitC(block, TOG, OB_DRAWNAME, REDRAWVIEW3D, "Name",             210, 100, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's name");
1128         
1129         uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Polyheder%x4",
1130                                                                                                                                         120, 80, 90, 20, &ob->boundtype, 0, 0, 0, 0, "Selects the boundary display type");
1131         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");
1132         
1133         uiDefButBitC(block, TOG, OB_TEXSPACE, REDRAWVIEW3D, "TexSpace", 120, 60, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's texture space");
1134         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");
1135         
1136         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)");
1137         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");
1138
1139 }
1140
1141 static void softbody_bake(Object *ob)
1142 {
1143         SoftBody *sb= ob->soft;
1144         ScrArea *sa;
1145         float frameleno= G.scene->r.framelen;
1146         int cfrao= CFRA;
1147         unsigned short event=0;
1148         short val;
1149         
1150         G.scene->r.framelen= 1.0;               // baking has to be in uncorrected time
1151         CFRA= sb->sfra;
1152         update_for_newframe_muted();    // put everything on this frame
1153         sbObjectToSoftbody(ob); // put softbody in restposition
1154         ob->softflag |= OB_SB_BAKEDO;
1155         
1156         curarea->win_swap= 0;           // clean swapbuffers
1157         
1158         for(; CFRA <= sb->efra; CFRA++) {
1159                 set_timecursor(CFRA);
1160                 
1161                 update_for_newframe_muted();
1162                 
1163                 for(sa= G.curscreen->areabase.first; sa; sa= sa->next) {
1164                         if(sa->spacetype == SPACE_VIEW3D) {
1165                                 scrarea_do_windraw(sa);
1166                         }
1167                 }
1168                 screen_swapbuffers();
1169                 
1170                 while(qtest()) {
1171                         
1172                         event= extern_qread(&val);
1173                         if(event==ESCKEY) break;
1174                 }
1175                 if(event==ESCKEY) break;
1176         }
1177         
1178         if(event==ESCKEY) sbObjectToSoftbody(ob);       // clears all
1179         
1180         /* restore */
1181         waitcursor(0);
1182         ob->softflag &= ~OB_SB_BAKEDO;
1183         CFRA= cfrao;
1184         G.scene->r.framelen= frameleno;
1185         update_for_newframe_muted();
1186         allqueue(REDRAWVIEW3D, 0);
1187         allqueue(REDRAWBUTSOBJECT, 0);
1188 }
1189
1190
1191 // NT store processed path & file prefix for fluidsim bake directory
1192 void fluidsimFilesel(char *selection)
1193 {
1194         Object *ob = OBACT;
1195         char srcDir[FILE_MAXDIR], srcFile[FILE_MAXFILE];
1196         char prefix[FILE_MAXFILE];
1197         char *srch, *srchSub, *srchExt, *lastFound;
1198         int isElbeemSurf = 0;
1199
1200         strcpy(srcDir, selection);
1201         BLI_splitdirstring(srcDir, srcFile);
1202
1203         // make prefix
1204         strcpy(prefix, srcFile);
1205         // check if this is a previously generated surface mesh file
1206         srch = strstr(prefix, "_surface_");
1207         if(srch) {
1208                 srchSub = strstr(prefix,"_preview_");
1209                 if(!srchSub) srchSub = strstr(prefix,"_final_");
1210                 srchExt = strstr(prefix,".gz.bobj");
1211                 if(!srchExt) srchExt = strstr(prefix,".bobj");
1212                 if(srchSub && srchExt) {
1213                         *srch = '\0';
1214                         isElbeemSurf = 1;
1215                 }
1216         }
1217         if(!isElbeemSurf) {
1218                 // try to remove suffix
1219                 lastFound = NULL;
1220                 srch = strchr(prefix, '.'); // search last . from extension
1221                 while(srch) {
1222                         lastFound = srch;
1223                         if(srch) {
1224                                 srch++;
1225                                 srch = strchr(srch, '.');
1226                         }
1227                 }
1228                 if(lastFound) {
1229                         *lastFound = '\0';
1230                 } 
1231         }
1232
1233         // TODO check srcDir for file path from sce?
1234         strcpy(ob->fluidsimSettings->surfdataDir, srcDir);
1235         strcpy(ob->fluidsimSettings->surfdataPrefix, prefix);
1236         //fprintf(stderr,"fluidsimFilesel: Using surfdata path '%s', prefix '%s' \n", ob->fluidsimSettings->surfdataDir,ob->fluidsimSettings->surfdataPrefix); // DEBUG
1237 }
1238
1239 void do_object_panels(unsigned short event)
1240 {
1241         Object *ob;
1242         Effect *eff;
1243         
1244         ob= OBACT;
1245
1246         switch(event) {
1247         case B_TRACKBUTS:
1248                 ob= OBACT;
1249                 DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
1250                 allqueue(REDRAWVIEW3D, 0);
1251                 break;
1252         case B_RECALCPATH:
1253                 DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
1254                 allqueue(REDRAWVIEW3D, 0);
1255                 break;
1256         case B_PRINTSPEED:
1257                 ob= OBACT;
1258                 if(ob) {
1259                         float vec[3];
1260                         CFRA++;
1261                         do_ob_ipo(ob);
1262                         where_is_object(ob);
1263                         VECCOPY(vec, ob->obmat[3]);
1264                         CFRA--;
1265                         do_ob_ipo(ob);
1266                         where_is_object(ob);
1267                         VecSubf(vec, vec, ob->obmat[3]);
1268                         prspeed= Normalise(vec);
1269                         scrarea_queue_winredraw(curarea);
1270                 }
1271                 break;
1272         case B_PRINTLEN:
1273                 ob= OBACT;
1274                 if(ob && ob->type==OB_CURVE) {
1275                         Curve *cu=ob->data;
1276                         
1277                         if(cu->path) prlen= cu->path->totdist; else prlen= -1.0;
1278                         scrarea_queue_winredraw(curarea);
1279                 } 
1280                 break;
1281         case B_RELKEY:
1282                 allspace(REMAKEIPO, 0);
1283                 allqueue(REDRAWBUTSOBJECT, 0);
1284                 allqueue(REDRAWIPO, 0);
1285                 DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
1286                 break;
1287         case B_CURVECHECK:
1288                 DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
1289                 allqueue(REDRAWVIEW3D, 0);
1290                 break;
1291         
1292         case B_SOFTBODY_CHANGE:
1293                 ob= OBACT;
1294                 if(ob) {
1295                         ob->softflag |= OB_SB_REDO;
1296                         allqueue(REDRAWBUTSOBJECT, 0);
1297                         allqueue(REDRAWVIEW3D, 0);
1298                 }
1299                 break;
1300         case B_SOFTBODY_DEL_VG:
1301                 ob= OBACT;
1302                 if(ob && ob->soft) {
1303                         ob->soft->vertgroup= 0;
1304                         ob->softflag |= OB_SB_REDO;
1305                         allqueue(REDRAWBUTSOBJECT, 0);
1306                         allqueue(REDRAWVIEW3D, 0);
1307                 }
1308                 break;
1309         case B_SOFTBODY_BAKE:
1310                 ob= OBACT;
1311                 if(ob && ob->soft) softbody_bake(ob);
1312                 break;
1313         case B_SOFTBODY_BAKE_FREE:
1314                 ob= OBACT;
1315                 if(ob && ob->soft) sbObjectToSoftbody(ob);
1316                 allqueue(REDRAWBUTSOBJECT, 0);
1317                 allqueue(REDRAWVIEW3D, 0);
1318                 break;
1319
1320         case B_FLUIDSIM_BAKE:
1321                 ob= OBACT;
1322                 /* write config files (currently no simulation) */
1323                 fluidsimBake(ob);
1324                 break;
1325         case B_FLUIDSIM_SELDIR: {
1326                         char str[FILE_MAXDIR+FILE_MAXFILE];
1327                         ScrArea *sa = closest_bigger_area();
1328                         strcpy(str,"//");
1329                         ob= OBACT;
1330                         /* chosse dir for surface files */
1331                         areawinset(sa->win);
1332                         activate_fileselect(FILE_SPECIAL, "Select Directory", str, fluidsimFilesel);
1333                         allqueue(REDRAWBUTSOBJECT, 0);
1334                         allqueue(REDRAWVIEW3D, 0);
1335                 }
1336                 break;
1337                 
1338         default:
1339                 if(event>=B_SELEFFECT && event<B_SELEFFECT+MAX_EFFECT) {
1340                         ob= OBACT;
1341                         if(ob) {
1342                                 int a=B_SELEFFECT;
1343                                 
1344                                 eff= ob->effect.first;
1345                                 while(eff) {
1346                                         if(event==a) eff->flag |= SELECT;
1347                                         else eff->flag &= ~SELECT;
1348                                         
1349                                         a++;
1350                                         eff= eff->next;
1351                                 }
1352                                 allqueue(REDRAWBUTSOBJECT, 0);
1353                         }
1354                 }
1355         }
1356
1357 }
1358
1359 static void object_panel_anim(Object *ob)
1360 {
1361         uiBlock *block;
1362         char str[32];
1363         
1364         block= uiNewBlock(&curarea->uiblocks, "object_panel_anim", UI_EMBOSS, UI_HELV, curarea->win);
1365         if(uiNewPanel(curarea, block, "Anim settings", "Object", 0, 0, 318, 204)==0) return;
1366         
1367         uiBlockBeginAlign(block);
1368         uiDefButC(block, ROW,B_TRACKBUTS,"TrackX",      24,190,59,19, &ob->trackflag, 12.0, 0.0, 0, 0, "Specify the axis that points to another object");
1369         uiDefButC(block, ROW,B_TRACKBUTS,"Y",           85,190,19,19, &ob->trackflag, 12.0, 1.0, 0, 0, "Specify the axis that points to another object");
1370         uiDefButC(block, ROW,B_TRACKBUTS,"Z",           104,190,19,19, &ob->trackflag, 12.0, 2.0, 0, 0, "Specify the axis that points to another object");
1371         uiDefButC(block, ROW,B_TRACKBUTS,"-X",          124,190,24,19, &ob->trackflag, 12.0, 3.0, 0, 0, "Specify the axis that points to another object");
1372         uiDefButC(block, ROW,B_TRACKBUTS,"-Y",          150,190,24,19, &ob->trackflag, 12.0, 4.0, 0, 0, "Specify the axis that points to another object");
1373         uiDefButC(block, ROW,B_TRACKBUTS,"-Z",          178,190,24,19, &ob->trackflag, 12.0, 5.0, 0, 0, "Specify the axis that points to another object");
1374         uiBlockBeginAlign(block);
1375         uiDefButC(block, ROW,REDRAWVIEW3D,"UpX",        226,190,45,19, &ob->upflag, 13.0, 0.0, 0, 0, "Specify the axis that points up");
1376         uiDefButC(block, ROW,REDRAWVIEW3D,"Y",          274,190,20,19, &ob->upflag, 13.0, 1.0, 0, 0, "Specify the axis that points up");
1377         uiDefButC(block, ROW,REDRAWVIEW3D,"Z",          298,190,19,19, &ob->upflag, 13.0, 2.0, 0, 0, "Specify the axis that points up");
1378         uiBlockBeginAlign(block);
1379         uiDefButBitC(block, TOG, OB_DRAWKEY, REDRAWVIEW3D, "Draw Key",          24,160,71,19, &ob->ipoflag, 0, 0, 0, 0, "Draw object as key position");
1380         uiDefButBitC(block, TOG, OB_DRAWKEYSEL, REDRAWVIEW3D, "Draw Key Sel",   97,160,81,19, &ob->ipoflag, 0, 0, 0, 0, "Limit the drawing of object keys");
1381         uiDefButBitC(block, TOG, OB_POWERTRACK, REDRAWVIEW3D, "Powertrack",             180,160,78,19, &ob->transflag, 0, 0, 0, 0, "Switch objects rotation off");
1382         uiDefButBitS(block, TOG, PARSLOW, 0, "SlowPar",                                 260,160,56,19, &ob->partype, 0, 0, 0, 0, "Create a delay in the parent relationship");
1383         uiBlockBeginAlign(block);
1384         uiDefButBitC(block, TOG, OB_DUPLIFRAMES, REDRAWVIEW3D, "DupliFrames",   24,128,89,19, &ob->transflag, 0, 0, 0, 0, "Make copy of object for every frame");
1385         uiDefButBitC(block, TOG, OB_DUPLIVERTS, REDRAWVIEW3D, "DupliVerts",             114,128,82,19, &ob->transflag, 0, 0, 0, 0, "Duplicate child objects on all vertices");
1386         uiDefButBitC(block, TOG, OB_DUPLIROT, REDRAWVIEW3D, "Rot",              200,128,31,19, &ob->transflag, 0, 0, 0, 0, "Rotate dupli according to facenormal");
1387         uiDefButBitC(block, TOG, OB_DUPLINOSPEED, REDRAWVIEW3D, "No Speed",     234,128,82,19, &ob->transflag, 0, 0, 0, 0, "Set dupliframes to still, regardless of frame");
1388         uiBlockBeginAlign(block);
1389         uiDefButS(block, NUM, REDRAWVIEW3D, "DupSta:",          24,105,141,19, &ob->dupsta, 1.0, (MAXFRAMEF - 1.0f), 0, 0, "Specify startframe for Dupliframes");
1390         uiDefButS(block, NUM, REDRAWVIEW3D, "DupOn:",           170,105,146,19, &ob->dupon, 1.0, 1500.0, 0, 0, "");
1391         uiDefButS(block, NUM, REDRAWVIEW3D, "DupEnd",           24,82,140,19, &ob->dupend, 1.0, MAXFRAMEF, 0, 0, "Specify endframe for Dupliframes");
1392         uiDefButS(block, NUM, REDRAWVIEW3D, "DupOff",           171,82,145,19, &ob->dupoff, 0.0, 1500.0, 0, 0, "");
1393         uiBlockBeginAlign(block);
1394         uiDefButBitC(block, TOG, OB_OFFS_OB, REDRAWALL, "Offs Ob",                      24,51,56,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on its own objectipo");
1395         uiDefButBitC(block, TOG, OB_OFFS_PARENT, REDRAWALL, "Offs Par",                 82,51,56,20 , &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the parent");
1396         uiDefButBitC(block, TOG, OB_OFFS_PARTICLE, REDRAWALL, "Offs Particle",          140,51,103,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the particle effect");
1397         
1398         uiBlockBeginAlign(block);
1399         uiDefButF(block, NUM, REDRAWALL, "TimeOffset:",                 24,17,115,30, &ob->sf, -MAXFRAMEF, MAXFRAMEF, 100, 0, "Specify an offset in frames");
1400         uiDefBut(block, BUT, B_AUTOTIMEOFS, "Automatic Time",   139,17,104,31, 0, 0, 0, 0, 0, "Generate automatic timeoffset values for all selected frames");
1401         uiDefBut(block, BUT, B_PRINTSPEED,      "PrSpeed",                      248,17,67,31, 0, 0, 0, 0, 0, "Print objectspeed");
1402         uiBlockEndAlign(block);
1403         
1404         sprintf(str, "%.4f", prspeed);
1405         uiDefBut(block, LABEL, 0, str,                                                  247,40,63,31, NULL, 1.0, 0, 0, 0, "");
1406         
1407 }
1408
1409 void do_effects_panels(unsigned short event)
1410 {
1411         Object *ob;
1412         Base *base;
1413         Effect *eff, *effn;
1414         int type;
1415         
1416         ob= OBACT;
1417
1418         switch(event) {
1419
1420     case B_AUTOTIMEOFS:
1421                 auto_timeoffs();
1422                 break;
1423         case B_FRAMEMAP:
1424                 G.scene->r.framelen= G.scene->r.framapto;
1425                 G.scene->r.framelen/= G.scene->r.images;
1426                 allqueue(REDRAWALL, 0);
1427                 break;
1428         case B_NEWEFFECT:
1429                 if(ob) {
1430                         if (BLI_countlist(&ob->effect)==MAX_EFFECT)
1431                                 error("Unable to add: effect limit reached");
1432                         else
1433                                 copy_act_effect(ob);
1434                 }
1435                 BIF_undo_push("New effect");
1436                 allqueue(REDRAWBUTSOBJECT, 0);
1437                 break;
1438         case B_DELEFFECT:
1439                 if(ob==0 || ob->type!=OB_MESH) break;
1440                 eff= ob->effect.first;
1441                 while(eff) {
1442                         effn= eff->next;
1443                         if(eff->flag & SELECT) {
1444                                 BLI_remlink(&ob->effect, eff);
1445                                 free_effect(eff);
1446                                 break;
1447                         }
1448                         eff= effn;
1449                 }
1450                 BIF_undo_push("Delete effect");
1451                 allqueue(REDRAWVIEW3D, 0);
1452                 allqueue(REDRAWBUTSOBJECT, 0);
1453                 break;
1454         case B_NEXTEFFECT:
1455                 if(ob==0 || ob->type!=OB_MESH) break;
1456                 eff= ob->effect.first;
1457                 while(eff) {
1458                         if(eff->flag & SELECT) {
1459                                 if(eff->next) {
1460                                         eff->flag &= ~SELECT;
1461                                         eff->next->flag |= SELECT;
1462                                 }
1463                                 break;
1464                         }
1465                         eff= eff->next;
1466                 }
1467                 allqueue(REDRAWBUTSOBJECT, 0);
1468                 break;
1469         case B_PREVEFFECT:
1470                 if(ob==0 || ob->type!=OB_MESH) break;
1471                 eff= ob->effect.first;
1472                 while(eff) {
1473                         if(eff->flag & SELECT) {
1474                                 if(eff->prev) {
1475                                         eff->flag &= ~SELECT;
1476                                         eff->prev->flag |= SELECT;
1477                                 }
1478                                 break;
1479                         }
1480                         eff= eff->next;
1481                 }
1482                 allqueue(REDRAWBUTSOBJECT, 0);
1483                 break;
1484         case B_CHANGEEFFECT:
1485                 if(ob==0 || ob->type!=OB_MESH) break;
1486                 eff= ob->effect.first;
1487                 while(eff) {
1488                         if(eff->flag & SELECT) {
1489                                 if(eff->type!=eff->buttype) {
1490                                         BLI_remlink(&ob->effect, eff);
1491                                         type= eff->buttype;
1492                                         free_effect(eff);
1493                                         eff= add_effect(type);
1494                                         BLI_addtail(&ob->effect, eff);
1495                                 }
1496                                 break;
1497                         }
1498                         eff= eff->next;
1499                 }
1500                 allqueue(REDRAWVIEW3D, 0);
1501                 allqueue(REDRAWBUTSOBJECT, 0);
1502                 break;
1503         case B_CALCEFFECT:
1504                 if(ob==0 || ob->type!=OB_MESH) break;
1505                 eff= ob->effect.first;
1506                 while(eff) {
1507                         if(eff->flag & SELECT) {
1508                                 if(eff->type==EFF_PARTICLE) build_particle_system(ob);
1509                         }
1510                         eff= eff->next;
1511                 }
1512                 allqueue(REDRAWVIEW3D, 0);
1513                 allqueue(REDRAWBUTSOBJECT, 0);
1514                 break;
1515         case B_RECALCAL:
1516                 base= FIRSTBASE;
1517                 while(base) {
1518                         if(base->lay & G.vd->lay) {
1519                                 ob= base->object;
1520                                 eff= ob->effect.first;
1521                                 while(eff) {
1522                                         if(eff->flag & SELECT) {
1523                                                 if(eff->type==EFF_PARTICLE) build_particle_system(ob);
1524                                         }
1525                                         eff= eff->next;
1526                                 }
1527                         }
1528                         base= base->next;
1529                 }
1530                 allqueue(REDRAWVIEW3D, 0);
1531                 break;
1532
1533         default:
1534                 if(event>=B_SELEFFECT && event<B_SELEFFECT+MAX_EFFECT) {
1535                         ob= OBACT;
1536                         if(ob) {
1537                                 int a=B_SELEFFECT;
1538                                 
1539                                 eff= ob->effect.first;
1540                                 while(eff) {
1541                                         if(event==a) eff->flag |= SELECT;
1542                                         else eff->flag &= ~SELECT;
1543                                         
1544                                         a++;
1545                                         eff= eff->next;
1546                                 }
1547                                 allqueue(REDRAWBUTSOBJECT, 0);
1548                         }
1549                 }
1550         }
1551
1552 }
1553
1554 /* Panel for particle interaction settings */
1555 static void object_panel_fields(Object *ob)
1556 {
1557         uiBlock *block;
1558
1559         block= uiNewBlock(&curarea->uiblocks, "object_panel_fields", UI_EMBOSS, UI_HELV, curarea->win);
1560         if(uiNewPanel(curarea, block, "Fields and Defection", "Physics", 420, 0, 318, 204)==0) return;
1561
1562         /* should become button, option? */
1563         if(ob->pd==NULL) {
1564                 ob->pd= MEM_callocN(sizeof(PartDeflect), "PartDeflect");
1565                 /* and if needed, init here */
1566                 ob->pd->pdef_sbdamp = 0.1;
1567                 ob->pd->pdef_sbift  = 0.2;
1568                 ob->pd->pdef_sboft  = 0.02;
1569         }
1570         
1571         if(ob->pd) {
1572                 PartDeflect *pd= ob->pd;
1573                 
1574                 uiDefBut(block, LABEL, 0, "Fields",             10,180,140,20, NULL, 0.0, 0, 0, 0, "");
1575                 
1576                 uiBlockBeginAlign(block);
1577                 uiDefButS(block, ROW, REDRAWVIEW3D, "None",                     10,160,50,20, &pd->forcefield, 1.0, 0, 0, 0, "No force");
1578                 uiDefButS(block, ROW, REDRAWVIEW3D, "Force field",      60,160,90,20, &pd->forcefield, 1.0, PFIELD_FORCE, 0, 0, "Object center attracts or repels particles");
1579                 uiDefButS(block, ROW, REDRAWVIEW3D, "Wind",                     10,140,50,20, &pd->forcefield, 1.0, PFIELD_WIND, 0, 0, "Constant force applied in direction of Object Z axis");
1580                 uiDefButS(block, ROW, REDRAWVIEW3D, "Vortex field",     60,140,90,20, &pd->forcefield, 1.0, PFIELD_VORTEX, 0, 0, "Particles swirl around Z-axis of the object");
1581
1582                 uiBlockBeginAlign(block);
1583                 uiDefButF(block, NUM, REDRAWVIEW3D, "Strength: ",       10,110,140,20, &pd->f_strength, -1000, 1000, 1000, 0, "Strength of force field");
1584                 uiDefButF(block, NUM, REDRAWVIEW3D, "Fall-off: ",       10,90,140,20, &pd->f_power, 0, 10, 100, 0, "Falloff power (real gravitational fallof = 2)");
1585                 
1586                 uiBlockBeginAlign(block);
1587                 uiDefButBitS(block, TOG, PFIELD_USEMAX, REDRAWVIEW3D, "Use MaxDist",    10,60,140,20, &pd->flag, 0.0, 0, 0, 0, "Use a maximum distance for the field to work");
1588                 uiDefButF(block, NUM, REDRAWVIEW3D, "MaxDist: ",        10,40,140,20, &pd->maxdist, 0, 1000.0, 100, 0, "Maximum distance for the field to work");
1589                 uiBlockEndAlign(block);
1590
1591 //              if(modifiers_isSoftbodyEnabled(ob)) {
1592                 if(0) {
1593                         uiDefBut(block, LABEL, 0, "Object is Soft Body,",               160,160,150,20, NULL, 0.0, 0, 0, 0, "");
1594                         uiDefBut(block, LABEL, 0, "no Deflection possible",             160,140,150,20, NULL, 0.0, 0, 0, 0, "");
1595                         pd->deflect= 0;
1596                 }
1597                 else {
1598                         uiDefBut(block, LABEL, 0, "Deflection", 160,180,140,20, NULL, 0.0, 0, 0, 0, "");
1599                         
1600                         /* only meshes collide now */
1601                         if(ob->type==OB_MESH) {
1602                                 uiDefButBitS(block, TOG, 1, B_REDR, "Deflection",160,160,150,20, &pd->deflect, 0, 0, 0, 0, "Deflects particles based on collision");
1603                                 uiDefBut(block, LABEL, 0, "Particles",                  160,140,150,20, NULL, 0.0, 0, 0, 0, "");
1604                                 
1605                                 uiBlockBeginAlign(block);
1606                                 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");
1607                                 uiDefButF(block, NUM, B_DIFF, "Rnd Damping: ",  160,100,150,20, &pd->pdef_rdamp, 0.0, 1.0, 10, 0, "Random variation of damping");
1608                                 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");
1609                                 uiBlockEndAlign(block);
1610                                 
1611                                 uiDefBut(block, LABEL, 0, "Soft Body",                  160,60,150,20, NULL, 0.0, 0, 0, 0, "");
1612
1613                                 uiBlockBeginAlign(block);
1614                                 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");
1615                                 uiDefButF(block, NUM, B_DIFF, "Inner:", 160,20,150,20, &pd->pdef_sbift, 0.001, 1.0, 10, 0, "Inner face thickness");
1616                                 uiDefButF(block, NUM, B_DIFF, "Outer:", 160, 0,150,20, &pd->pdef_sboft, 0.001, 1.0, 10, 0, "Outer face thickness");
1617                                 uiBlockBeginAlign(block);
1618 /* seems to be working fine .. so we do use modifier stack by default .. code here rests for debugging
1619                             uiDefButBitS(block, TOG, PDEFLE_DEFORM , 0,"UMS or CRASH",  0,0,150,20, &pd->flag, 0, 0, 0, 0, "Let collision object move with armatures/lattices WARNING logical circles will CRASH");
1620 */
1621                         }               
1622                 }       
1623         }
1624 }
1625
1626
1627 /* Panel for softbodies */
1628 static void object_softbodies__enable(void *ob_v, void *arg2)
1629 {
1630         Object *ob = ob_v;
1631         ModifierData *md = modifiers_findByType(ob, eModifierType_Softbody);
1632
1633         if (modifiers_isSoftbodyEnabled(ob)) {
1634                 if (md) {
1635                         md->mode &= ~(eModifierMode_Render|eModifierMode_Realtime);
1636                 }
1637         } else {
1638                 if (!md) {
1639                         md = modifier_new(eModifierType_Softbody);
1640                         BLI_addhead(&ob->modifiers, md);
1641                 }
1642
1643                 md->mode |= eModifierMode_Render|eModifierMode_Realtime;
1644
1645                 if (!ob->soft) {
1646                         ob->soft= sbNew();
1647                         ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
1648                 }
1649         }
1650
1651         allqueue(REDRAWBUTSEDIT, 0);
1652 }
1653
1654 static void object_softbodies(Object *ob)
1655 {
1656         uiBlock *block;
1657         
1658         block= uiNewBlock(&curarea->uiblocks, "object_softbodies", UI_EMBOSS, UI_HELV, curarea->win);
1659         if(uiNewPanel(curarea, block, "Soft Body", "Physics", 740, 0, 318, 204)==0) return;
1660
1661         /* do not allow to combine with force fields */
1662         /* if(ob->pd && ob->pd->deflect) { */
1663         /* no reason for that any more BM */
1664         if(0) {
1665                 uiDefBut(block, LABEL, 0, "Object has Deflection,",             10,160,300,20, NULL, 0.0, 0, 0, 0, "");
1666                 uiDefBut(block, LABEL, 0, "no Soft Body possible",              10,140,300,20, NULL, 0.0, 0, 0, 0, "");
1667         } else {
1668                 static int val;
1669                 uiBut *but;
1670
1671                 val = modifiers_isSoftbodyEnabled(ob);
1672                 but = uiDefButI(block, TOG, REDRAWBUTSOBJECT, "Enable Soft Body",       10,200,150,20, &val, 0, 0, 0, 0, "Sets object to become soft body");
1673                 uiButSetFunc(but, object_softbodies__enable, ob, NULL);
1674                 uiDefBut(block, LABEL, 0, "",   160, 200,150,20, NULL, 0.0, 0.0, 0, 0, "");     // alignment reason
1675         }
1676         
1677         if(modifiers_isSoftbodyEnabled(ob)) {
1678                 SoftBody *sb= ob->soft;
1679                 int defCount;
1680                 char *menustr;
1681                 
1682                 if(sb==NULL) {
1683                         sb= ob->soft= sbNew();
1684                         ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
1685                 }
1686                 
1687                 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");
1688                 
1689                 if(sb->keys) uiSetButLock(1, "Soft Body is baked, free it first");
1690                 
1691                 if(ob->softflag & OB_SB_BAKESET) {
1692                         uiBlockBeginAlign(block);
1693                         uiDefButS(block, NUM, B_DIFF, "Start:",                 10, 170,100,20, &sb->sfra, 1.0, 10000.0, 10, 0, "Start frame for baking");
1694                         uiDefButS(block, NUM, B_DIFF, "End:",                   110, 170,100,20, &sb->efra, 1.0, 10000.0, 10, 0, "End frame for baking");
1695                         uiDefButS(block, NUM, B_DIFF, "Interval:",              210, 170,100,20, &sb->interval, 1.0, 10.0, 10, 0, "Interval in frames between baked keys");
1696                         
1697                         uiClearButLock();
1698                         
1699                         uiBlockBeginAlign(block);
1700                         if(sb->keys) {
1701                                 char str[128];
1702                                 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");
1703                                 sprintf(str, "Stored %d vertices %d keys %.3f MB", sb->totpoint, sb->totkey, ((float)16*sb->totpoint*sb->totkey)/(1024.0*1024.0));
1704                                 uiDefBut(block, LABEL, 0, str, 10, 100,300,20, NULL, 0.0, 0.0, 00, 0, "");
1705                         }
1706                         else                            
1707                                 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");
1708                 }
1709                 else {
1710                         /* GENERAL STUFF */
1711                         uiBlockBeginAlign(block);
1712                         uiDefButF(block, NUM, B_DIFF, "Friction:",              10, 170,150,20, &sb->mediafrict, 0.0, 10.0, 10, 0, "General media friction for point movements");
1713                         uiDefButF(block, NUM, B_DIFF, "Mass:",                  160, 170,150,20, &sb->nodemass , 0.001, 50.0, 10, 0, "Point Mass, the heavier the slower");
1714                         uiDefButF(block, NUM, B_DIFF, "Grav:",                  10,150,150,20, &sb->grav , 0.0, 10.0, 10, 0, "Apply gravitation to point movement");
1715                         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");
1716                         uiDefButF(block, NUM, B_DIFF, "Error Limit:",   10,130,150,20, &sb->rklimit , 0.01, 1.0, 10, 0, "The Runge-Kutta ODE solver error limit, low value gives more precision");
1717                         uiBlockEndAlign(block);
1718                         
1719                         /* GOAL STUFF */
1720                         uiBlockBeginAlign(block);
1721                         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");
1722                         
1723                         menustr= get_vertexgroup_menustr(ob);
1724                         defCount=BLI_countlist(&ob->defbase);
1725                         if(defCount==0) sb->vertgroup= 0;
1726                         uiDefButS(block, MENU, B_SOFTBODY_CHANGE, menustr,              140,100,20,20, &sb->vertgroup, 0, defCount, 0, 0, "Browses available vertex groups");
1727                         
1728                         if(sb->vertgroup) {
1729                                 bDeformGroup *defGroup = BLI_findlink(&ob->defbase, sb->vertgroup-1);
1730                                 if(defGroup)
1731                                         uiDefBut(block, BUT, B_DIFF, defGroup->name,    160,100,130,20, NULL, 0.0, 0.0, 0, 0, "Name of current vertex group");
1732                                 else
1733                                         uiDefBut(block, BUT, B_DIFF, "(no group)",      160,100,130,20, NULL, 0.0, 0.0, 0, 0, "Vertex Group doesn't exist anymore");
1734                                 uiDefIconBut(block, BUT, B_SOFTBODY_DEL_VG, ICON_X, 290,100,20,20, 0, 0, 0, 0, 0, "Disable use of vertex group");
1735                         }
1736                         else {
1737                                 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");
1738                         }
1739                         MEM_freeN (menustr);
1740
1741                         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");
1742                         uiDefButF(block, NUM, B_DIFF, "G Damp:",        160,80,150,20, &sb->goalfrict  , 0.0, 10.0, 10, 0, "Goal (vertex target position) friction");
1743                         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");
1744                         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");
1745                         uiBlockEndAlign(block);
1746                         
1747                         /* EDGE SPRING STUFF */
1748                         uiBlockBeginAlign(block);
1749                         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");
1750                         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");
1751                         uiDefButF(block, NUM, B_DIFF, "E Stiff:",       10,10,150,20, &sb->inspring, 0.0,  0.999, 10, 0, "Edge spring stiffness");
1752                         uiDefButF(block, NUM, B_DIFF, "E Damp:",        160,10,150,20, &sb->infrict, 0.0,  10.0, 10, 0, "Edge spring friction");
1753                         uiBlockEndAlign(block);
1754                 }
1755         }
1756         uiBlockEndAlign(block);
1757
1758 }
1759
1760 static void object_panel_particles(Object *ob)
1761 {
1762         Effect *eff;
1763         uiBlock *block;
1764         int a;
1765         short x, y;
1766         
1767         block= uiNewBlock(&curarea->uiblocks, "object_panel_particles", UI_EMBOSS, UI_HELV, curarea->win);
1768         if(uiNewPanel(curarea, block, "Particles", "Physics", 0, 0, 418, 204)==0) return;
1769
1770         /* EFFECTS */
1771         
1772         if (ob->type == OB_MESH) {
1773                 uiBlockBeginAlign(block);
1774                 uiDefBut(block, BUT, B_NEWEFFECT, "NEW", 550,187,124,27, 0, 0, 0, 0, 0, "Create a new Particle effect");
1775                 uiDefBut(block, BUT, B_DELEFFECT, "Delete", 676,187,62,27, 0, 0, 0, 0, 0, "Delete the effect");
1776                 uiBlockEndAlign(block);
1777         }
1778
1779         /* select effs */
1780         eff= ob->effect.first;
1781         a= 0;
1782         while(eff) {
1783                 
1784                 x= 15 * a + 550;
1785                 y= 172; // - 12*( abs(a/10) ) ;
1786                 uiDefButBitS(block, TOG, SELECT, B_SELEFFECT+a, "", x, y, 15, 12, &eff->flag, 0, 0, 0, 0, "");
1787                 
1788                 a++;
1789                 if(a==MAX_EFFECT) break;
1790                 eff= eff->next;
1791         }
1792         
1793         eff= ob->effect.first;
1794         while(eff) {
1795                 if(eff->flag & SELECT) break;
1796                 eff= eff->next;
1797         }
1798         
1799         if(eff) {
1800                 if(eff->type==EFF_PARTICLE) {
1801                         PartEff *paf;
1802                         
1803                         paf= (PartEff *)eff;
1804                         
1805                         uiDefBut(block, BUT, B_RECALCAL, "RecalcAll", 741,187,67,27, 0, 0, 0, 0, 0, "Update the particle system");
1806                         uiBlockBeginAlign(block);
1807                         uiDefButBitS(block, TOG, PAF_STATIC, B_CALCEFFECT, "Static",    825,187,67,27, &paf->flag, 0, 0, 0, 0, "Make static particles (deform only works with SubSurf)");
1808                         if(paf->flag & PAF_STATIC) {
1809                                 uiDefButBitS(block, TOG, PAF_ANIMATED, B_DIFF, "Animated",895,187,107,27, &paf->flag, 0, 0, 0, 0, "Static particles are recalculated each rendered frame");
1810                         }                       
1811                         uiBlockBeginAlign(block);
1812                         uiDefButI(block, NUM, B_CALCEFFECT, "Tot:",                     550,146,91,20, &paf->totpart, 1.0, 100000.0, 0, 0, "Set the total number of particles");
1813                         if(paf->flag & PAF_STATIC) {
1814                                 uiDefButS(block, NUM, REDRAWVIEW3D, "Step:",    644,146,84+97,20, &paf->staticstep, 1.0, 100.0, 10, 0, "For static duplicators, the Step value skips particles");
1815                         }
1816                         else {
1817                                 uiDefButF(block, NUM, B_CALCEFFECT, "Sta:",             644,146,84,20, &paf->sta, -250.0, MAXFRAMEF, 100, 0, "Specify the startframe");
1818                                 uiDefButF(block, NUM, B_CALCEFFECT, "End:",             731,146,97,20, &paf->end, 1.0, MAXFRAMEF, 100, 0, "Specify the endframe");
1819                         }
1820                         uiDefButF(block, NUM, B_CALCEFFECT, "Life:",            831,146,88,20, &paf->lifetime, 1.0, MAXFRAMEF, 100, 0, "Specify the life span of the particles");
1821                         uiDefButI(block, NUM, B_CALCEFFECT, "Keys:",            922,146,80,20, &paf->totkey, 1.0, 100.0, 0, 0, "Specify the number of key positions");
1822                         
1823                         uiDefButS(block, NUM, B_REDR,           "CurMul:",              550,124,91,20, &paf->curmult, 0.0, 3.0, 0, 0, "Multiply the particles");
1824                         uiDefButS(block, NUM, B_CALCEFFECT, "Mat:",                     644,124,84,20, paf->mat+paf->curmult, 1.0, 8.0, 0, 0, "Specify the material used for the particles");
1825                         uiDefButF(block, NUM, B_CALCEFFECT, "Mult:",            730,124,98,20, paf->mult+paf->curmult, 0.0, 1.0, 10, 0, "Probability \"dying\" particle spawns a new one.");
1826                         uiDefButF(block, NUM, B_CALCEFFECT, "Life:",            831,124,89,20, paf->life+paf->curmult, 1.0, 600.0, 100, 0, "Specify the lifespan of the next generation particles");
1827                         uiDefButS(block, NUM, B_CALCEFFECT, "Child:",           922,124,80,20, paf->child+paf->curmult, 1.0, 600.0, 100, 0, "Specify the number of children of a particle that multiply itself");
1828                         
1829                         uiBlockBeginAlign(block);
1830                         uiDefButF(block, NUM, B_CALCEFFECT, "Randlife:",        550,96,96,20, &paf->randlife, 0.0, 2.0, 10, 0, "Give the particlelife a random variation");
1831                         uiDefButI(block, NUM, B_CALCEFFECT, "Seed:",            652,96,80,20, &paf->seed, 0.0, 255.0, 0, 0, "Set an offset in the random table");
1832
1833                         uiDefButBitS(block, TOG, PAF_FACE, B_CALCEFFECT, "Face",                735,96,46,20, &paf->flag, 0, 0, 0, 0, "Emit particles also from faces");
1834                         uiDefButBitS(block, TOG, PAF_BSPLINE, B_CALCEFFECT, "Bspline",  782,96,54,20, &paf->flag, 0, 0, 0, 0, "Use B spline formula for particle interpolation");
1835                         uiDefButS(block, TOG, REDRAWVIEW3D, "Vect",                             837,96,45,20, &paf->stype, 0, 0, 0, 0, "Give the particles a rotation direction");
1836                         uiDefButF(block, NUM, B_DIFF,                   "VectSize",             885,96,116,20, &paf->vectsize, 0.0, 1.0, 10, 0, "Set the speed for Vect");      
1837
1838                         uiBlockBeginAlign(block);
1839                         uiBlockSetCol(block, TH_BUT_SETTING2);
1840                         uiDefButF(block, NUM, B_CALCEFFECT, "Norm:",            550,67,96,20, &paf->normfac, -2.0, 2.0, 10, 0, "Let the mesh give the particle a starting speed");
1841                         uiDefButF(block, NUM, B_CALCEFFECT, "Ob:",              649,67,86,20, &paf->obfac, -1.0, 1.0, 10, 0, "Let the object give the particle a starting speed");
1842                         uiDefButF(block, NUM, B_CALCEFFECT, "Rand:",            738,67,86,20, &paf->randfac, 0.0, 2.0, 10, 0, "Give the startingspeed a random variation");
1843                         uiDefButF(block, NUM, B_CALCEFFECT, "Tex:",             826,67,85,20, &paf->texfac, 0.0, 2.0, 10, 0, "Let the texture give the particle a starting speed");
1844                         uiDefButF(block, NUM, B_CALCEFFECT, "Damp:",            913,67,89,20, &paf->damp, 0.0, 1.0, 10, 0, "Specify the damping factor");
1845                         uiBlockSetCol(block, TH_AUTO);
1846                         
1847                         uiBlockBeginAlign(block);
1848                         uiDefButF(block, NUM, B_CALCEFFECT, "X:",               550,31,72,20, paf->force, -1.0, 1.0, 1, 0, "Specify the X axis of a continues force");
1849                         uiDefButF(block, NUM, B_CALCEFFECT, "Y:",               624,31,78,20, paf->force+1,-1.0, 1.0, 1, 0, "Specify the Y axis of a continues force");
1850                         uiDefBut(block, LABEL, 0, "Force:",                             550,9,72,20, NULL, 1.0, 0, 0, 0, "");
1851                         uiDefButF(block, NUM, B_CALCEFFECT, "Z:",               623,9,79,20, paf->force+2, -1.0, 1.0, 1, 0, "Specify the Z axis of a continues force");
1852
1853                         uiBlockBeginAlign(block);
1854                         uiDefButF(block, NUM, B_CALCEFFECT, "X:",               722,31,74,20, paf->defvec, -1.0, 1.0, 1, 0, "Specify the X axis of a force, determined by the texture");
1855                         uiDefButF(block, NUM, B_CALCEFFECT, "Y:",               798,31,74,20, paf->defvec+1,-1.0, 1.0, 1, 0, "Specify the Y axis of a force, determined by the texture");
1856                         uiDefBut(block, LABEL, 0, "Texture:",                   722,9,74,20, NULL, 1.0, 0, 0, 0, "");
1857                         uiDefButF(block, NUM, B_CALCEFFECT, "Z:",               797,9,75,20, paf->defvec+2, -1.0, 1.0, 1, 0, "Specify the Z axis of a force, determined by the texture");
1858                         uiBlockEndAlign(block);
1859
1860                         uiDefButS(block, ROW, B_CALCEFFECT, "Int",              875,9,32,43, &paf->texmap, 14.0, 0.0, 0, 0, "Use texture intensity as a factor for texture force");
1861
1862                         uiBlockBeginAlign(block);
1863                         uiDefButS(block, ROW, B_CALCEFFECT, "RGB",              911,31,45,20, &paf->texmap, 14.0, 1.0, 0, 0, "Use RGB values as a factor for particle speed vector");
1864                         uiDefButS(block, ROW, B_CALCEFFECT, "Grad",             958,31,44,20, &paf->texmap, 14.0, 2.0, 0, 0, "Use texture gradient as a factor for particle speed vector");
1865                         uiDefButF(block, NUM, B_CALCEFFECT, "Nabla:",           911,9,91,20, &paf->nabla, 0.0001f, 1.0, 1, 0, "Specify the dimension of the area for gradient calculation");
1866
1867                 }
1868         }
1869 }
1870
1871 /* NT - Panel for fluidsim settings */
1872 static void object_panel_fluidsim(Object *ob)
1873 {
1874         uiBlock *block;
1875         int yline = 160;
1876         const int lineHeight = 20;
1877         const int separateHeight = 3;
1878         const int objHeight = 20;
1879         
1880         block= uiNewBlock(&curarea->uiblocks, "object_fluidsim", UI_EMBOSS, UI_HELV, curarea->win);
1881         if(uiNewPanel(curarea, block, "Fluid Simulation", "Physics", 1060, 0, 318, 204)==0) return;
1882
1883         uiDefButBitS(block, TOG, OB_FLUIDSIM_ENABLE, REDRAWBUTSOBJECT, "Enable",         0,yline, 75,objHeight, 
1884                         &ob->fluidsimFlag, 0, 0, 0, 0, "Sets object to participate in fluid simulation");
1885
1886         if(ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) {
1887                 FluidsimSettings *fss= ob->fluidsimSettings;
1888                 
1889                 if(fss==NULL) {
1890                         fss = ob->fluidsimSettings = fluidsimSettingsNew(ob);
1891                 }
1892
1893                 if(ob->type==OB_MESH) {
1894
1895                         uiBlockBeginAlign(block);
1896                         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.");
1897                         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.");
1898                         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.");
1899                         yline -= lineHeight;
1900
1901                         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.");
1902                         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.");
1903                         uiBlockEndAlign(block);
1904                         yline -= lineHeight;
1905                         yline -= 2*separateHeight;
1906
1907                         /* display specific settings for each type */
1908                         if(fss->type == OB_FLUIDSIM_DOMAIN) {
1909                                 const int maxRes = 200;
1910
1911                         /* domain "advanced" settings */
1912                         if(fss->type == OB_FLUIDSIM_DOMAIN) { }
1913                                 uiDefButBitS(block, TOG, 1, REDRAWBUTSOBJECT, "Advanced>>",      0,yline, 75,objHeight, &fss->show_advancedoptions, 0, 0, 0, 0, "Show advanced domain options.");
1914                                 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.");
1915                                 yline -= lineHeight;
1916                                 yline -= 2*separateHeight;
1917
1918                                 if(fss->show_advancedoptions == 0) {
1919                                         uiDefButS(block, NUM, B_DIFF, "Resolution:", 0, yline,150,objHeight, &fss->resolutionxyz, 1, maxRes, 10, 0, "Domain resolution in X,Y and Z direction");
1920                                         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");
1921                                         yline -= lineHeight;
1922                                         yline -= 1*separateHeight;
1923
1924                                         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.");
1925                                         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.");
1926                                         yline -= lineHeight;
1927                                         yline -= 2*separateHeight;
1928
1929                                         uiDefBut(block, LABEL,   0, "Disp.-Qual.:",              0,yline, 90,objHeight, NULL, 0.0, 0, 0, 0, "");
1930                                         uiDefButS(block, MENU, REDRAWVIEW3D, "GuiDisplayMode%t|Geometry %x1|Preview %x2|Final %x3",     
1931                                                          90,yline,105,objHeight, &fss->guiDisplayMode, 0, 0, 0, 0, "How to display the fluid mesh in the blender gui.");
1932                                         uiDefButS(block, MENU, REDRAWVIEW3D, "RenderDisplayMode%t|Geometry %x1|Preview %x2|Final %x3",  
1933                                                         195,yline,105,objHeight, &fss->renderDisplayMode, 0, 0, 0, 0, "How to display the fluid mesh for rendering.");
1934                                         yline -= lineHeight;
1935                                         yline -= 1*separateHeight;
1936
1937                                         uiDefIconBut(block, BUT, B_FLUIDSIM_SELDIR, ICON_FILESEL,          0, yline, 20, objHeight,      0, 0, 0, 0, 0,   "Select Directory (and/or filenames) to store baked fluid simulation files in");
1938                                         uiDefBut(block, TEX,   0,"",    20, yline, 200, objHeight,fss->surfdataDir, 0.0,79.0, 0, 0, "Enter Directory (and/or filenames) to store baked fluid simulation files in");
1939                                         uiDefBut(block, TEX,   0,"", 220, yline,  80, objHeight,fss->surfdataPrefix, 0.0,79.0, 0, 0, "Enter Filename-Prefix to store baked fluid simulation files with");
1940                                         // FIXME what is the 79.0 above?
1941                                 } else {
1942                                         // advanced options
1943                                         uiBlockBeginAlign(block);
1944                                         uiDefBut(block, LABEL, 0, "Gravity:",           0, yline,  90,objHeight, NULL, 0.0, 0, 0, 0, "");
1945                                         uiDefButF(block, NUM, B_DIFF, "X:",    90, yline,  70,objHeight, &fss->gravx, -1000.1, 1000.1, 10, 0, "Gravity in X direction");
1946                                         uiDefButF(block, NUM, B_DIFF, "Y:",   160, yline,  70,objHeight, &fss->gravy, -1000.1, 1000.1, 10, 0, "Gravity in Y direction");
1947                                         uiDefButF(block, NUM, B_DIFF, "Z:",   230, yline,  70,objHeight, &fss->gravz, -1000.1, 1000.1, 10, 0, "Gravity in Z direction");
1948                                         uiBlockEndAlign(block);
1949                                         //yline -= lineHeight; yline -= separateHeight;
1950                                         yline -= lineHeight;
1951                                         yline -= 1*separateHeight;
1952
1953                                         /* viscosity */
1954                                         uiBlockBeginAlign(block);
1955                                         uiDefButS(block, MENU, REDRAWVIEW3D, "Viscosity%t|Manual %x1|Water %x2|Oil %x3|Honey %x4",      
1956                                                         0,yline, 90,objHeight, &fss->viscosityMode, 0, 0, 0, 0, "Set viscosity of the fluid to a preset value, or use manual input.");
1957                                         if(fss->viscosityMode==1) {
1958                                                 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).");
1959                                                 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.");
1960                                         } else {
1961                                                 // display preset values
1962                                                 uiDefBut(block, LABEL,   0, fluidsimViscosityPresetString[fss->viscosityMode],  90,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
1963                                         }
1964                                         uiBlockEndAlign(block);
1965                                         yline -= lineHeight;
1966                                         yline -= 1*separateHeight;
1967
1968                                         uiDefBut(block, LABEL, 0, "Realworld-size:",            0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "");
1969                                         uiDefButF(block, NUM, B_DIFF, "", 150, yline,150,objHeight, &fss->realsize, 0.001, 1.0, 10, 0, "Size of the simulation domain in meters.");
1970                                         yline -= lineHeight;
1971                                         yline -= 2*separateHeight;
1972
1973                                         uiDefBut(block, LABEL, 0, "Gridlevels:",                0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "");
1974                                         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).");
1975                                         yline -= lineHeight;
1976
1977                                         uiDefBut(block, LABEL, 0, "Compressibility:",           0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "");
1978                                         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).");
1979                                         yline -= lineHeight;
1980
1981                                 }
1982                         }
1983                         else if(
1984                                         (fss->type == OB_FLUIDSIM_FLUID) 
1985                                         || (fss->type == OB_FLUIDSIM_INFLOW) 
1986                                         ) {
1987                                 yline -= lineHeight + 5;
1988                                 if(fss->type == OB_FLUIDSIM_FLUID)  uiDefBut(block, LABEL, 0, "Initial velocity:",              0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
1989                                 if(fss->type == OB_FLUIDSIM_INFLOW) uiDefBut(block, LABEL, 0, "Inflow velocity:",                 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
1990                                 yline -= lineHeight;
1991                                 uiBlockBeginAlign(block);
1992                                 uiDefButF(block, NUM, B_DIFF, "X:",   0, yline, 100,objHeight, &fss->iniVelx, -1000.1, 1000.1, 10, 0, "Fluid velocity in X direction");
1993                                 uiDefButF(block, NUM, B_DIFF, "Y:", 100, yline, 100,objHeight, &fss->iniVely, -1000.1, 1000.1, 10, 0, "Fluid velocity in Y direction");
1994                                 uiDefButF(block, NUM, B_DIFF, "Z:", 200, yline, 100,objHeight, &fss->iniVelz, -1000.1, 1000.1, 10, 0, "Fluid velocity in Z direction");
1995                                 uiBlockEndAlign(block);
1996                                 yline -= lineHeight;
1997                         }
1998                         else if(
1999                                         (fss->type == OB_FLUIDSIM_OBSTACLE) 
2000                                         || (fss->type == OB_FLUIDSIM_OUTFLOW) 
2001                                 )       {
2002                                 yline -= lineHeight + 5;
2003                                 uiDefBut(block, LABEL, 0, "No additional settings as of now...",                0,yline,300,objHeight, NULL, 0.0, 0, 0, 0, "");
2004                                 yline -= lineHeight;
2005                         }
2006                         else {
2007                                 yline -= lineHeight + 5;
2008                                 /* not yet set */
2009                                 uiDefBut(block, LABEL, 0, "Select object type for simulation",          0,yline,300,objHeight, NULL, 0.0, 0, 0, 0, "");
2010                                 yline -= lineHeight;
2011                         }
2012
2013                 } else {
2014                         yline -= lineHeight + 5;
2015                         uiDefBut(block, LABEL, 0, "Sorry - only meshes supported", 0,yline,300,objHeight, NULL, 0.0, 0, 0, 0, "");
2016                         yline -= lineHeight;
2017                 }
2018         } else {
2019                 yline -= lineHeight + 5;
2020                 uiDefBut(block, LABEL, 0, "Object not enabled for fluid simulation...", 0,yline,300,objHeight, NULL, 0.0, 0, 0, 0, "");
2021                 yline -= lineHeight;
2022         }
2023 }
2024
2025 void object_panels()
2026 {
2027         Object *ob;
2028
2029         /* check context here */
2030         ob= OBACT;
2031         if(ob) {
2032                 if(ob->id.lib) uiSetButLock(1, "Can't edit library data");
2033
2034                 object_panel_anim(ob);
2035                 object_panel_draw(ob);
2036                 object_panel_constraint("Object");
2037
2038                 uiClearButLock();
2039         }
2040 }
2041
2042 void physics_panels()
2043 {
2044         Object *ob;
2045         
2046         /* check context here */
2047         ob= OBACT;
2048         if(ob) {
2049                 if(ob->id.lib) uiSetButLock(1, "Can't edit library data");
2050                 object_panel_particles(ob);
2051                 object_panel_fields(ob);
2052                 object_softbodies(ob);
2053                 object_panel_fluidsim(ob);
2054         }
2055 }
2056