0fd762837b1e2d21c321c5b4f88e47b7fcbf378b
[blender.git] / source / blender / src / buttons_object.c
1 /**
2  * $Id: 
3  *
4  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. The Blender
10  * Foundation also sells licenses for use in proprietary software under
11  * the Blender License.  See http://www.blender.org/BL/ for information
12  * about this.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  *
23  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24  * All rights reserved.
25  *
26  * The Original Code is: all of this file.
27  *
28  * Contributor(s): none yet.
29  *
30  * ***** END GPL/BL DUAL LICENSE BLOCK *****
31  */
32
33 #include <time.h>
34 #include <math.h>
35 #include <stdlib.h>
36 #include <string.h>
37
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
41
42 #include "MEM_guardedalloc.h"
43 #include "DNA_screen_types.h"
44 #include "DNA_space_types.h"
45 #include "DNA_scene_types.h"
46
47 #include "BKE_global.h"
48 #include "BKE_main.h"
49 #include "BKE_library.h"
50 #include "BKE_softbody.h"
51
52 #include "BLI_blenlib.h"
53 #include "BLI_arithb.h"
54
55 #include "BSE_filesel.h"
56
57 #include "BIF_gl.h"
58 #include "BIF_graphics.h"
59 #include "BIF_keyval.h"
60 #include "BIF_mainqueue.h"
61 #include "BIF_resources.h"
62 #include "BIF_screen.h"
63 #include "BIF_mywindow.h"
64 #include "BIF_space.h"
65 #include "BIF_glutil.h"
66 #include "BIF_interface.h"
67 #include "BIF_toolbox.h"
68 #include "BDR_editcurve.h"
69 #include "BDR_drawobject.h"
70
71 //#include "BIF_editsca.h"
72
73 #include "BIF_butspace.h"
74
75 #include "mydevice.h"
76 #include "blendef.h"
77
78 /* -----includes for this file specific----- */
79
80
81 #include "DNA_action_types.h"
82 #include "DNA_armature_types.h"
83 #include "DNA_camera_types.h"
84 #include "DNA_constraint_types.h"
85 #include "DNA_curve_types.h"
86 #include "DNA_effect_types.h"
87 #include "DNA_group_types.h"
88 #include "DNA_ika_types.h"
89 #include "DNA_image_types.h"
90 #include "DNA_key_types.h"
91 #include "DNA_lamp_types.h"
92 #include "DNA_lattice_types.h"
93 #include "DNA_material_types.h"
94 #include "DNA_meta_types.h"
95 #include "DNA_mesh_types.h"
96 #include "DNA_object_types.h"
97 #include "DNA_radio_types.h"
98 #include "DNA_screen_types.h"
99 #include "DNA_sound_types.h"
100 #include "DNA_texture_types.h"
101 #include "DNA_userdef_types.h"
102 #include "DNA_vfont_types.h"
103 #include "DNA_view3d_types.h"
104 #include "DNA_world_types.h"
105
106 #include "BKE_anim.h"
107 #include "BKE_armature.h"
108 #include "BKE_constraint.h"
109 #include "BKE_curve.h"
110 #include "BKE_displist.h"
111 #include "BKE_effect.h"
112 #include "BKE_font.h"
113 #include "BKE_ika.h"
114 #include "BKE_image.h"
115 #include "BKE_ipo.h"
116 #include "BKE_lattice.h"
117 #include "BKE_material.h"
118 #include "BKE_mball.h"
119 #include "BKE_mesh.h"
120 #include "BKE_object.h"
121 #include "BKE_sound.h"
122 #include "BKE_texture.h"
123 #include "BKE_utildefines.h"
124
125 #include "BIF_editconstraint.h"
126 #include "BSE_editipo.h"
127 #include "BDR_editobject.h"
128
129 #include "butspace.h" // own module
130
131 static float prspeed=0.0;
132 float prlen=0.0;
133
134
135 /* ********************* function prototypes ******************** */
136 void object_panel_draw(Object *);
137 void object_panel_hooks(Object *);
138 void object_panel_effects(Object *);
139
140 /* ********************* CONSTRAINT ***************************** */
141
142 #if 0
143 static void add_influence_key_to_constraint_func (void *arg1v, void *unused)
144 {
145         bConstraint *con = arg1v;
146         add_influence_key_to_constraint(con);
147 }
148 #endif
149
150 static void activate_constraint_ipo_func (void *arg1v, void *unused)
151 {
152
153         bConstraint *con = arg1v;
154         bConstraintChannel *chan;
155         ListBase *conbase;
156
157         get_constraint_client(NULL, NULL, NULL);
158
159         conbase = get_constraint_client_channels(1);
160
161         if (!conbase)
162                 return;
163
164         /* See if this list already has an appropriate channel */
165         chan = find_constraint_channel(conbase, con->name);
166
167         if (!chan){
168                 /* Add a new constraint channel */
169                 chan = add_new_constraint_channel(con->name);
170                 BLI_addtail(conbase, chan);
171         }
172
173         /* Ensure there is an ipo to display */
174         if (!chan->ipo){
175                 chan->ipo = add_ipo(con->name, IPO_CO);
176         }
177
178         /* Make this the active channel */
179         OBACT->activecon = chan;
180
181         allqueue(REDRAWIPO, 0);
182         allqueue(REDRAWNLA, 0);
183 }
184
185 static void del_constraint_func (void *arg1v, void *arg2v)
186 {
187         bConstraint *con= arg1v;
188         Object *ob;
189
190         ListBase *lb= arg2v;
191         
192         ob=OBACT;
193         
194         if (ob->activecon && !strcmp(ob->activecon->name, con->name))
195                 ob->activecon = NULL;
196
197         free_constraint_data (con);
198
199         BLI_freelinkN(lb, con);
200
201         BIF_undo_push("Delete constraint");
202         allqueue(REDRAWBUTSOBJECT, 0);
203         allqueue(REDRAWIPO, 0); 
204
205 }
206
207 static void verify_constraint_name_func (void *data, void *data2_unused)
208 {
209         ListBase *conlist;
210         bConstraint *con;
211         char ownerstr[64];
212         short type;
213         
214         con = (bConstraint*) data;
215         if (!con)
216                 return;
217         
218         conlist = get_constraint_client(ownerstr, &type, NULL);
219         unique_constraint_name (con, conlist);
220 }
221
222 static void constraint_changed_func (void *data, void *data2_unused)
223 {
224         bConstraint *con = (bConstraint*) data;
225
226         if (con->type == con->otype)
227                 return;
228
229         free_constraint_data (con);
230         con->data = new_constraint_data(con->type);
231
232 }
233
234 static void move_constraint_func (void *datav, void *data2_unused)
235 {
236         bConstraint *constraint_to_move= datav;
237         int val;
238         ListBase *conlist;
239         char ownerstr[64];
240         short   type;
241         bConstraint *curCon, *con, *neighbour;
242         
243         val= pupmenu("Move up%x1|Move down %x2");
244         
245         con = constraint_to_move;
246
247         if(val>0) {
248                 conlist = get_constraint_client(ownerstr, &type, NULL);
249                 for (curCon = conlist->first; curCon; curCon = curCon->next){
250                         if (curCon == con){
251                                 /* Move up */
252                                 if (val == 1 && con->prev){
253                                         neighbour = con->prev;
254                                         BLI_remlink(conlist, neighbour);
255                                         BLI_insertlink(conlist, con, neighbour);
256                                 }
257                                 /* Move down */
258                                 else if (val == 2 && con->next){
259                                         neighbour = con->next;
260                                         BLI_remlink (conlist, con);
261                                         BLI_insertlink(conlist, neighbour, con);
262                                 }
263                                 break;
264                         }
265                 }
266         }
267 }
268
269 static void get_constraint_typestring (char *str, bConstraint *con)
270 {
271         switch (con->type){
272         case CONSTRAINT_TYPE_CHILDOF:
273                 strcpy (str, "Child Of");
274                 return;
275         case CONSTRAINT_TYPE_NULL:
276                 strcpy (str, "Null");
277                 return;
278         case CONSTRAINT_TYPE_TRACKTO:
279                 strcpy (str, "Track To");
280                 return;
281         case CONSTRAINT_TYPE_KINEMATIC:
282                 strcpy (str, "IK Solver");
283                 return;
284         case CONSTRAINT_TYPE_ROTLIKE:
285                 strcpy (str, "Copy Rotation");
286                 return;
287         case CONSTRAINT_TYPE_LOCLIKE:
288                 strcpy (str, "Copy Location");
289                 return;
290         case CONSTRAINT_TYPE_ACTION:
291                 strcpy (str, "Action");
292                 return;
293         case CONSTRAINT_TYPE_LOCKTRACK:
294                 strcpy (str, "Locked Track");
295                 return;
296         case CONSTRAINT_TYPE_FOLLOWPATH:
297                 strcpy (str, "Follow Path");
298                 return;
299         case CONSTRAINT_TYPE_STRETCHTO:
300                 strcpy (str, "Stretch To");
301                 return;
302         default:
303                 strcpy (str, "Unknown");
304                 return;
305         }
306 }
307
308 static int get_constraint_col(bConstraint *con)
309 {
310         switch (con->type) {
311         case CONSTRAINT_TYPE_NULL:
312                 return TH_BUT_NEUTRAL;
313         case CONSTRAINT_TYPE_KINEMATIC:
314                 return TH_BUT_SETTING2;
315         case CONSTRAINT_TYPE_TRACKTO:
316                 return TH_BUT_SETTING;
317         case CONSTRAINT_TYPE_ROTLIKE:
318                 return TH_BUT_SETTING1;
319         case CONSTRAINT_TYPE_LOCLIKE:
320                 return TH_BUT_POPUP;
321         case CONSTRAINT_TYPE_ACTION:
322                 return TH_BUT_ACTION;
323         case CONSTRAINT_TYPE_LOCKTRACK:
324                 return TH_BUT_SETTING;
325         case CONSTRAINT_TYPE_FOLLOWPATH:
326                 return TH_BUT_SETTING2;
327         case CONSTRAINT_TYPE_STRETCHTO:
328                 return TH_BUT_SETTING;
329         default:
330                 return TH_REDALERT;
331         }
332 }
333
334 static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, short *xco, short *yco, short type)
335 {
336         uiBut *but;
337         char typestr[64];
338         short height, width = 265;
339         int curCol;
340
341         get_constraint_typestring (typestr, con);
342
343         curCol = get_constraint_col(con);
344
345         /* Draw constraint header */
346         uiBlockSetEmboss(block, UI_EMBOSSN);
347         
348         uiDefIconButS(block, ICONTOG|BIT|CONSTRAINT_EXPAND_BIT, B_CONSTRAINT_REDRAW, ICON_DISCLOSURE_TRI_RIGHT, *xco-10, *yco, 20, 20, &con->flag, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Constraint");
349
350         if (con->flag & CONSTRAINT_EXPAND) {
351                 
352                 if (con->flag & CONSTRAINT_DISABLE) {
353                         BIF_ThemeColor(TH_REDALERT);
354                         uiBlockSetCol(block, TH_REDALERT);
355                 }
356                 else
357                         BIF_ThemeColor(curCol);
358
359                 /*if (type==TARGET_BONE)
360                         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"); 
361                 else
362                         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"); 
363                 */
364                 uiBlockSetEmboss(block, UI_EMBOSSX);
365                 
366                 /* rounded header */
367                 BIF_ThemeColorShade(curCol, -20);
368                 uiSetRoundBox(3);
369                 uiRoundBox((float)*xco+4, (float)*yco-18, (float)*xco+width+30, (float)*yco+6, 5.0);
370
371                 but = uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+10, *yco-1, 100, 19, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
372
373                 uiButSetFunc(but, constraint_changed_func, con, NULL);
374                 con->otype = con->type;
375                 
376                 but = uiDefBut(block, TEX, B_CONSTRAINT_REDRAW, "", *xco+120, *yco-1, 135, 19, con->name, 0.0, 29.0, 0.0, 0.0, "Constraint name"); 
377                 uiButSetFunc(but, verify_constraint_name_func, con, NULL);
378         }       
379         else{
380                 uiBlockSetEmboss(block, UI_EMBOSSN);
381
382                 if (con->flag & CONSTRAINT_DISABLE) {
383                         uiBlockSetCol(block, TH_REDALERT);
384                         BIF_ThemeColor(TH_REDALERT);
385                 }
386                 else
387                         BIF_ThemeColor(curCol);
388                         
389                 /* coloured rectangle to hold constraint controls */
390                 if (con->type!=CONSTRAINT_TYPE_NULL) glRects(*xco+3, *yco-36, *xco+width+30, *yco-15);
391         
392                 /* rounded header */
393                 BIF_ThemeColorShade(curCol, -20);
394                 uiSetRoundBox(3);
395                 uiRoundBox((float)*xco+4, (float)*yco-15, (float)*xco+width+30, (float)*yco+6, 5.0);
396                 
397                 but = uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+10, *yco-1, 100, 19, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
398                 uiButSetFunc(but, move_constraint_func, con, NULL);
399                 
400                 but = uiDefBut(block, LABEL, B_CONSTRAINT_TEST, con->name, *xco+120, *yco-1, 135, 19, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
401                 uiButSetFunc(but, move_constraint_func, con, NULL);
402         }
403
404         uiBlockSetCol(block, TH_AUTO);  
405         
406         uiBlockSetEmboss(block, UI_EMBOSSN);
407         
408         but = uiDefIconBut(block, BUT, B_CONSTRAINT_REDRAW, ICON_X, *xco+262, *yco, 19, 19, list, 0.0, 0.0, 0.0, 0.0, "Delete constraint");
409         uiButSetFunc(but, del_constraint_func, con, list);
410
411         uiBlockSetEmboss(block, UI_EMBOSSX);
412
413
414         /* Draw constraint data*/
415         if (!(con->flag & CONSTRAINT_EXPAND)) {
416                 (*yco)-=21;
417         }
418         else {
419                 switch (con->type){
420                 case CONSTRAINT_TYPE_ACTION:
421                         {
422                                 bActionConstraint *data = con->data;
423                                 bArmature *arm;
424
425                                 height = 86;
426                                 
427                                 BIF_ThemeColor(curCol);
428                                 glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
429
430                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
431
432                                 /* Draw target parameters */
433                                 uiBlockBeginAlign(block);
434                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
435
436                                 arm = get_armature(data->tar);
437                                 if (arm){
438                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
439                                 }
440                                 else
441                                         strcpy (data->subtarget, "");
442                                 uiBlockEndAlign(block);
443
444                                 /* Draw action button */
445                                 uiDefIDPoinBut(block, test_actionpoin_but, B_CONSTRAINT_CHANGETARGET, "AC:", *xco+((width/2)-117), *yco-64, 78, 18, &data->act, "Action containing the keyed motion for this bone"); 
446                                 uiDefButI(block, MENU, B_CONSTRAINT_REDRAW, "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");
447
448                                 uiBlockBeginAlign(block);
449                                 uiDefButS(block, NUM, B_CONSTRAINT_CHANGETARGET, "Start:", *xco+((width/2)-36), *yco-64, 78, 18, &data->start, 1, MAXFRAME, 0.0, 0.0, "Starting frame of the keyed motion"); 
450                                 uiDefButS(block, NUM, B_CONSTRAINT_CHANGETARGET, "End:", *xco+((width/2)-36), *yco-84, 78, 18, &data->end, 1, MAXFRAME, 0.0, 0.0, "Ending frame of the keyed motion"); 
451                                 uiBlockEndAlign(block);
452                                 
453                                 uiBlockBeginAlign(block);
454                                 uiDefButF(block, NUM, B_CONSTRAINT_REDRAW, "Min:", *xco+((width/2)+45), *yco-64, 78, 18, &data->min, -180, 180, 0, 0, "Minimum value for target channel range");
455                                 uiDefButF(block, NUM, B_CONSTRAINT_REDRAW, "Max:", *xco+((width/2)+45), *yco-84, 78, 18, &data->max, -180, 180, 0, 0, "Maximum value for target channel range");
456                                 uiBlockEndAlign(block);
457                         }
458                         break;
459                 case CONSTRAINT_TYPE_LOCLIKE:
460                         {
461                                 bLocateLikeConstraint *data = con->data;
462                                 bArmature *arm;
463                                 height = 66;
464                                 
465                                 BIF_ThemeColor(curCol);
466                                 glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
467
468                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
469
470                                 /* Draw target parameters */
471                                 uiBlockBeginAlign(block);
472                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
473
474                                 arm = get_armature(data->tar);
475                                 if (arm){
476                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
477                                 }
478                                 else
479                                         strcpy (data->subtarget, "");
480                                 uiBlockEndAlign(block);
481                                 
482                                 /* Draw XYZ toggles */
483                                 uiBlockBeginAlign(block);
484                                 but=uiDefButI(block, TOG|BIT|0, B_CONSTRAINT_TEST, "X", *xco+((width/2)-48), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy X component");
485                                 but=uiDefButI(block, TOG|BIT|1, B_CONSTRAINT_TEST, "Y", *xco+((width/2)-16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Y component");
486                                 but=uiDefButI(block, TOG|BIT|2, B_CONSTRAINT_TEST, "Z", *xco+((width/2)+16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Z component");
487                                 uiBlockEndAlign(block);
488                         }
489                         break;
490                 case CONSTRAINT_TYPE_ROTLIKE:
491                         {
492                                 bRotateLikeConstraint *data = con->data;
493                                 bArmature *arm;
494                                 height = 46;
495
496                                 BIF_ThemeColor(curCol);
497                                 glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
498                                 
499                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
500
501                                 /* Draw target parameters */
502                                 uiBlockBeginAlign(block);
503                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
504
505                                 arm = get_armature(data->tar);
506                                 if (arm){
507                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
508                                 }
509                                 else
510                                         strcpy (data->subtarget, "");
511                                 uiBlockEndAlign(block);
512                         }
513                         break;
514                 case CONSTRAINT_TYPE_KINEMATIC:
515                         {
516                                 bKinematicConstraint *data = con->data;
517                                 bArmature *arm;
518                                 
519                                 height = 66;
520                                 
521                                 BIF_ThemeColor(curCol);
522                                 glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
523                                 
524                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
525
526                                 /* Draw target parameters */
527                                 uiBlockBeginAlign(block);
528                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
529
530                                 arm = get_armature(data->tar);
531                                 if (arm){
532                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
533                                 }
534                                 else
535                                         strcpy (data->subtarget, "");
536                                 uiBlockEndAlign(block);
537         
538                                 uiDefButF(block, NUM, B_CONSTRAINT_REDRAW, "Tolerance:", *xco+((width/2)-117), *yco-64, 120, 18, &data->tolerance, 0.0001f, 1.0, 0.0, 0.0, "Maximum distance to target after solving"); 
539                                 uiDefButI(block, NUM, B_CONSTRAINT_REDRAW, "Iterations:", *xco+((width/2)+3), *yco-64, 120, 18, &data->iterations, 1, 10000, 0.0, 0.0, "Maximum number of solving iterations"); 
540                                 
541                         }
542                         break;
543                 case CONSTRAINT_TYPE_TRACKTO:
544                         {
545                                 bTrackToConstraint *data = con->data;
546                                 bArmature *arm;
547
548                                 height = 66;
549                                 
550                                 BIF_ThemeColor(curCol);
551                                 glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
552                                 
553                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
554
555                                 /* Draw target parameters */
556                                 uiBlockBeginAlign(block);
557                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
558
559                                 arm = get_armature(data->tar);
560                                 if (arm){
561                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
562                                 }
563                                 else
564                                         strcpy (data->subtarget, "");
565                                 uiBlockEndAlign(block);
566
567                                 uiBlockBeginAlign(block);
568                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "To:", *xco+12, *yco-64, 25, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
569                                 
570                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"X",   *xco+39, *yco-64,17,18, &data->reserved1, 12.0, 0.0, 0, 0, "The axis that points to the target object");
571                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"Y",   *xco+56, *yco-64,17,18, &data->reserved1, 12.0, 1.0, 0, 0, "The axis that points to the target object");
572                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"Z",   *xco+73, *yco-64,17,18, &data->reserved1, 12.0, 2.0, 0, 0, "The axis that points to the target object");
573                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"-X",  *xco+90, *yco-64,24,18, &data->reserved1, 12.0, 3.0, 0, 0, "The axis that points to the target object");
574                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"-Y",  *xco+114, *yco-64,24,18, &data->reserved1, 12.0, 4.0, 0, 0, "The axis that points to the target object");
575                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"-Z",  *xco+138, *yco-64,24,18, &data->reserved1, 12.0, 5.0, 0, 0, "The axis that points to the target object");
576                                 uiBlockEndAlign(block);
577                                 
578                                 uiBlockBeginAlign(block);
579                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Up:", *xco+174, *yco-64, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
580                                 
581                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"X",   *xco+204, *yco-64,17,18, &data->reserved2, 13.0, 0.0, 0, 0, "The axis that points upward");
582                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"Y",   *xco+221, *yco-64,17,18, &data->reserved2, 13.0, 1.0, 0, 0, "The axis that points upward");
583                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"Z",   *xco+238, *yco-64,17,18, &data->reserved2, 13.0, 2.0, 0, 0, "The axis that points upward");
584                                 uiBlockEndAlign(block);
585                         }
586                         break;
587                 case CONSTRAINT_TYPE_LOCKTRACK:
588                         {
589                                 bLockTrackConstraint *data = con->data;
590                                 bArmature *arm;
591                                 height = 66;
592                                 
593                                 BIF_ThemeColor(curCol);
594                                 glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
595
596                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
597
598                                 /* Draw target parameters */
599                                 uiBlockBeginAlign(block);
600                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
601
602                                 arm = get_armature(data->tar);
603                                 if (arm){
604                                         but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
605                                 }
606                                 else
607                                         strcpy (data->subtarget, "");
608                                 uiBlockEndAlign(block);
609                                 
610                                 uiBlockBeginAlign(block);
611                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "To:", *xco+12, *yco-64, 25, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
612                                 
613                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"X",   *xco+39, *yco-64,17,18, &data->trackflag, 12.0, 0.0, 0, 0, "The axis that points to the target object");
614                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"Y",   *xco+56, *yco-64,17,18, &data->trackflag, 12.0, 1.0, 0, 0, "The axis that points to the target object");
615                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"Z",   *xco+73, *yco-64,17,18, &data->trackflag, 12.0, 2.0, 0, 0, "The axis that points to the target object");
616                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"-X",  *xco+90, *yco-64,24,18, &data->trackflag, 12.0, 3.0, 0, 0, "The axis that points to the target object");
617                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"-Y",  *xco+114, *yco-64,24,18, &data->trackflag, 12.0, 4.0, 0, 0, "The axis that points to the target object");
618                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"-Z",  *xco+138, *yco-64,24,18, &data->trackflag, 12.0, 5.0, 0, 0, "The axis that points to the target object");
619                                 uiBlockEndAlign(block);
620                                 
621                                 uiBlockBeginAlign(block);
622                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Lock:", *xco+166, *yco-64, 38, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
623                                 
624                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"X",   *xco+204, *yco-64,17,18, &data->lockflag, 13.0, 0.0, 0, 0, "The axis that is locked");
625                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"Y",   *xco+221, *yco-64,17,18, &data->lockflag, 13.0, 1.0, 0, 0, "The axis that is locked");
626                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"Z",   *xco+238, *yco-64,17,18, &data->lockflag, 13.0, 2.0, 0, 0, "The axis that is locked");
627                                 uiBlockEndAlign(block);
628                         }
629                         break;
630                 case CONSTRAINT_TYPE_FOLLOWPATH:
631                         {
632                                 bFollowPathConstraint *data = con->data;
633
634                                 height = 66;
635                                 
636                                 BIF_ThemeColor(curCol);
637                                 glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
638                                 
639                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
640
641                                 /* Draw target parameters */
642                                 uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object"); 
643                                 
644                                 /* Draw Curve Follow toggle */
645                                 but=uiDefButI(block, TOG|BIT|0, 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");
646
647                                 /* Draw Offset number button */
648                                 uiDefButF(block, NUM, B_CONSTRAINT_REDRAW, "Offset:", *xco+155, *yco-44, 100, 18, &data->offset, -9000, 9000, 100.0, 0.0, "Offset from the position corresponding to the time frame"); 
649
650                                 uiBlockBeginAlign(block);
651                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Fw:", *xco+12, *yco-64, 27, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
652                                 
653                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"X",   *xco+39, *yco-64,17,18, &data->trackflag, 12.0, 0.0, 0, 0, "The axis that points forward along the path");
654                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"Y",   *xco+56, *yco-64,17,18, &data->trackflag, 12.0, 1.0, 0, 0, "The axis that points forward along the path");
655                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"Z",   *xco+73, *yco-64,17,18, &data->trackflag, 12.0, 2.0, 0, 0, "The axis that points forward along the path");
656                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"-X",  *xco+90, *yco-64,24,18, &data->trackflag, 12.0, 3.0, 0, 0, "The axis that points forward along the path");
657                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"-Y",  *xco+114, *yco-64,24,18, &data->trackflag, 12.0, 4.0, 0, 0, "The axis that points forward along the path");
658                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"-Z",  *xco+138, *yco-64,24,18, &data->trackflag, 12.0, 5.0, 0, 0, "The axis that points forward along the path");
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_REDRAW,"X",   *xco+204, *yco-64,17,18, &data->upflag, 13.0, 0.0, 0, 0, "The axis that points upward");
665                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"Y",   *xco+221, *yco-64,17,18, &data->upflag, 13.0, 1.0, 0, 0, "The axis that points upward");
666                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"Z",   *xco+238, *yco-64,17,18, &data->upflag, 13.0, 2.0, 0, 0, "The axis that points upward");
667                                 uiBlockEndAlign(block);
668                         }
669                         break;
670                 case CONSTRAINT_TYPE_STRETCHTO:
671                         {
672                                 bStretchToConstraint *data = con->data;
673                                 bArmature *arm;
674                                 height = 105;
675                                 BIF_ThemeColor(curCol);
676
677                                 glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
678                                 
679                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
680
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                                 
695                                 uiBlockBeginAlign(block);
696                                 uiDefButF(block,BUTM,B_CONSTRAINT_REDRAW,"R",*xco, *yco-60,20,18,&(data->orglength),0.0,0,0,0,"Recalculate RLenght");
697                                 uiDefButF(block,NUM,B_CONSTRAINT_REDRAW,"Rest Length:",*xco+18, *yco-60,237,18,&(data->orglength),0.0,100,0.5,0.5,"Lenght at Rest Position");
698                                 uiBlockEndAlign(block);
699
700                                 uiDefButF(block,NUM,B_CONSTRAINT_REDRAW,"Volume Variation:",*xco+18, *yco-82,237,18,&(data->bulge),0.0,100,0.5,0.5,"Factor between volume variation and stretching");
701
702                                 uiBlockBeginAlign(block);
703                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Vol:",*xco+14, *yco-104,30,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
704                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"XZ",   *xco+44, *yco-104,30,18, &data->volmode, 12.0, 0.0, 0, 0, "Keep Volume: Scaling X & Z");
705                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"X",    *xco+74, *yco-104,20,18, &data->volmode, 12.0, 1.0, 0, 0, "Keep Volume: Scaling X");
706                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"Z",    *xco+94, *yco-104,20,18, &data->volmode, 12.0, 2.0, 0, 0, "Keep Volume: Scaling Z");
707                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"NONE", *xco+114, *yco-104,50,18, &data->volmode, 12.0, 3.0, 0, 0, "Ignore Volume");
708                                 uiBlockEndAlign(block);
709
710                                 
711                                 uiBlockBeginAlign(block);
712                                 uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"Plane:",*xco+175, *yco-104,40,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
713                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"X",     *xco+215, *yco-104,20,18, &data->plane, 12.0, 0.0, 0, 0, "Keep X axis");
714                                 uiDefButI(block, ROW,B_CONSTRAINT_REDRAW,"Z",     *xco+235, *yco-104,20,18, &data->plane, 12.0, 2.0, 0, 0, "Keep Z axis");
715                                 uiBlockEndAlign(block);
716                                 }
717                         break;
718                 case CONSTRAINT_TYPE_NULL:
719                         {
720                                 height = 17;
721                                 
722                                 BIF_ThemeColor(curCol);
723                                 glRects(*xco+3, *yco-height-17, *xco+width+30, *yco-18);
724                                 
725                         }
726                         break;
727                 default:
728                         height = 0;
729                         break;
730                 }
731
732                 (*yco)-=(24+height);
733         }
734
735         if (con->type!=CONSTRAINT_TYPE_NULL) {
736                 uiDefButF(block, NUMSLI, B_CONSTRAINT_REDRAW, "Influence ", *xco+17, *yco, 197, 19, &(con->enforce), 0.0, 1.0, 0.0, 0.0, "Amount of influence this constraint will have on the final solution");
737                 but = uiDefBut(block, BUT, B_CONSTRAINT_REDRAW, "Edit", *xco+215, *yco, 41, 19, 0, 0.0, 1.0, 0.0, 0.0, "Show this constraint's ipo in the object's Ipo window");
738                 /* If this is on an object, add the constraint to the object */
739                 uiButSetFunc (but, activate_constraint_ipo_func, con, NULL);
740                 /* If this is on a bone, add the constraint to the action (if any) */
741                 //but = uiDefBut(block, BUT, B_CONSTRAINT_REDRAW, "Key", *xco+227, *yco, 41, 20, 0, 0.0, 1.0, 0.0, 0.0, "Add an influence keyframe to the constraint");
742                 /* Add a keyframe to the influence IPO */
743                 //uiButSetFunc (but, add_influence_key_to_constraint_func, con, NULL);
744                 (*yco)-=24;
745         } else {
746                 (*yco)-=3;
747         }
748         
749 }
750
751 static uiBlock *add_constraintmenu(void *arg_unused)
752 {
753         uiBlock *block;
754         
755         ListBase *conlist;
756         char ownerstr[64];
757         short type;
758         short yco= 0;
759         
760         conlist = get_constraint_client(ownerstr, &type, NULL);
761         
762         block= uiNewBlock(&curarea->uiblocks, "add_constraintmenu", UI_EMBOSSP, UI_HELV, curarea->win);
763
764         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_LOCLIKE,"Copy Location",         0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
765         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_ROTLIKE,"Copy Rotation",         0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
766         
767         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
768         
769         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_TRACKTO,"Track To",              0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
770         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_LOCKTRACK,"Locked Track",                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
771         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_FOLLOWPATH,"Follow Path",                0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
772         
773         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
774         
775         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_STRETCHTO,"Stretch To",          0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
776
777         if (type==TARGET_BONE) {
778         
779                 uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
780                 
781                 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_KINEMATIC,"IK Solver",           0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
782                 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_ACTION,"Action",         0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
783                 
784         }
785         uiDefBut(block, SEPR, 0, "",                                    0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
786
787         uiDefBut(block, BUTM, B_CONSTRAINT_ADD_NULL,"Null",             0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
788         
789         uiTextBoundsBlock(block, 50);
790         uiBlockSetDirection(block, UI_DOWN);
791                 
792         return block;
793 }
794
795 void do_constraintbuts(unsigned short event)
796 {
797         switch(event) {
798         case B_CONSTRAINT_CHANGENAME:
799                 break;
800         case B_CONSTRAINT_TEST:
801                 test_scene_constraints();
802                 allqueue (REDRAWVIEW3D, 0);
803                 allqueue (REDRAWBUTSOBJECT, 0);
804                 break;
805         case B_CONSTRAINT_REDRAW:
806                 test_scene_constraints();
807                 allqueue (REDRAWVIEW3D, 0);
808                 allqueue (REDRAWBUTSOBJECT, 0);
809                 break;
810         case B_CONSTRAINT_CHANGETARGET:
811                 test_scene_constraints();
812                 allqueue (REDRAWVIEW3D, 0);
813                 allqueue (REDRAWBUTSOBJECT, 0);
814                 break;
815         case B_CONSTRAINT_CHANGETYPE:
816                 test_scene_constraints();
817                 allqueue (REDRAWVIEW3D, 0);
818                 allqueue (REDRAWBUTSOBJECT, 0);
819                 break;
820         case B_CONSTRAINT_ADD_NULL:
821                 {
822                         bConstraint *con;
823                         
824                         con = add_new_constraint(CONSTRAINT_TYPE_NULL);
825                         add_constraint_to_client(con);
826
827                         test_scene_constraints();
828                         BIF_undo_push("Add constraint");
829                         allqueue (REDRAWVIEW3D, 0);
830                         allqueue (REDRAWBUTSOBJECT, 0);
831                 }
832                 break;
833         case B_CONSTRAINT_ADD_KINEMATIC:
834                 {
835                         bConstraint *con;
836                         
837                         con = add_new_constraint(CONSTRAINT_TYPE_KINEMATIC);
838                         add_constraint_to_client(con);
839
840                         test_scene_constraints();
841                         BIF_undo_push("Add constraint");
842                         allqueue (REDRAWVIEW3D, 0);
843                         allqueue (REDRAWBUTSOBJECT, 0);
844                 }
845                 break;
846         case B_CONSTRAINT_ADD_TRACKTO:
847                 {
848                         bConstraint *con;
849
850                         con = add_new_constraint(CONSTRAINT_TYPE_TRACKTO);
851                         add_constraint_to_client(con);
852
853                         test_scene_constraints();
854                         BIF_undo_push("Add constraint");
855                         allqueue (REDRAWVIEW3D, 0);
856                         allqueue (REDRAWBUTSOBJECT, 0);
857                 }
858                 break;
859         case B_CONSTRAINT_ADD_ROTLIKE:
860                 {
861                         bConstraint *con;
862
863                         con = add_new_constraint(CONSTRAINT_TYPE_ROTLIKE);
864                         add_constraint_to_client(con);
865
866                         test_scene_constraints();
867                         BIF_undo_push("Add constraint");
868                         allqueue (REDRAWVIEW3D, 0);
869                         allqueue (REDRAWBUTSOBJECT, 0);
870                 }
871                 break;
872         case B_CONSTRAINT_ADD_LOCLIKE:
873                 {
874                         bConstraint *con;
875
876                         con = add_new_constraint(CONSTRAINT_TYPE_LOCLIKE);
877                         add_constraint_to_client(con);
878
879                         test_scene_constraints();
880                         BIF_undo_push("Add constraint");
881                         allqueue (REDRAWVIEW3D, 0);
882                         allqueue (REDRAWBUTSOBJECT, 0);
883                 }
884                 break;
885         case B_CONSTRAINT_ADD_ACTION:
886                 {
887                         bConstraint *con;
888
889                         con = add_new_constraint(CONSTRAINT_TYPE_ACTION);
890                         add_constraint_to_client(con);
891
892                         test_scene_constraints();
893                         BIF_undo_push("Add constraint");
894                         allqueue (REDRAWVIEW3D, 0);
895                         allqueue (REDRAWBUTSOBJECT, 0);
896                 }
897                 break;
898         case B_CONSTRAINT_ADD_LOCKTRACK:
899                 {
900                         bConstraint *con;
901
902                         con = add_new_constraint(CONSTRAINT_TYPE_LOCKTRACK);
903                         add_constraint_to_client(con);
904
905                         test_scene_constraints();
906                         BIF_undo_push("Add constraint");
907                         allqueue (REDRAWVIEW3D, 0);
908                         allqueue (REDRAWBUTSOBJECT, 0);
909                 }
910                 break;
911         case B_CONSTRAINT_ADD_FOLLOWPATH:
912                 {
913                         bConstraint *con;
914
915                         con = add_new_constraint(CONSTRAINT_TYPE_FOLLOWPATH);
916                         add_constraint_to_client(con);
917
918                         test_scene_constraints();
919                         allqueue (REDRAWVIEW3D, 0);
920                         allqueue (REDRAWBUTSOBJECT, 0);
921                 }
922                 break;
923         case B_CONSTRAINT_ADD_STRETCHTO:
924         {
925                 bConstraint *con;
926                 con = add_new_constraint(CONSTRAINT_TYPE_STRETCHTO);
927                 add_constraint_to_client(con);
928                         
929                 test_scene_constraints();
930                 BIF_undo_push("Add constraint");
931                 allqueue(REDRAWVIEW3D,0);
932                 allqueue(REDRAWBUTSOBJECT,0);
933         }
934                 break;
935
936         case B_CONSTRAINT_DEL:
937                 test_scene_constraints();
938                 allqueue (REDRAWVIEW3D, 0);
939                 allqueue (REDRAWBUTSOBJECT, 0);
940                 break;
941         default:
942                 break;
943         }
944
945         clear_object_constraint_status(OBACT);
946         make_displists_by_armature (OBACT);
947 }
948
949 static void object_panel_constraint(void)
950 {
951         uiBlock *block;
952         ListBase *conlist;
953         bConstraint *curcon;
954         short xco, yco, type;
955         char ownerstr[64];
956         
957         block= uiNewBlock(&curarea->uiblocks, "object_panel_constraint", UI_EMBOSS, UI_HELV, curarea->win);
958         if(uiNewPanel(curarea, block, "Constraints", "Object", 640, 0, 318, 204)==0) return;
959
960         /* this is a variable height panel, newpanel doesnt force new size on existing panels */
961         /* so first we make it default height */
962         uiNewPanelHeight(block, 204);
963
964         conlist = get_constraint_client(ownerstr, &type, NULL);
965         
966         if (conlist) {
967                  
968                 uiDefBlockBut(block, add_constraintmenu, NULL, "Add Constraint", 0, 190, 130, 20, "Add a new constraint");
969                 
970                 /* print active object or bone */
971                 {
972                         short type;
973                         void *data=NULL;
974                         char str[64];
975                         
976                         str[0]= 0;
977                         get_constraint_client(NULL, &type, &data);
978                         if (data && type==TARGET_BONE){
979                                 sprintf(str, "To Bone: %s", ((Bone*)data)->name);
980                         }
981                         else if(OBACT) {
982                                 Object *ob= OBACT;
983                                 sprintf(str, "To Object: %s", ob->id.name+2);
984                         }
985                         uiDefBut(block, LABEL, 1, str,  150, 190, 150, 20, NULL, 0.0, 0.0, 0, 0, "Displays Active Object or Bone name");
986                 }
987                 
988                 /* Go through the list of constraints and draw them */
989                 xco = 10;
990                 yco = 160;
991                 // local panel coords
992                 uiPanelPush(block);
993                 
994                 for (curcon = conlist->first; curcon; curcon=curcon->next) {
995                         /* Draw default constraint header */                    
996                         draw_constraint(block, conlist, curcon, &xco, &yco, type);      
997                 }
998                 
999                 uiPanelPop(block);
1000                 
1001                 if(yco < 0) uiNewPanelHeight(block, 204-yco);
1002                 
1003         }
1004 }
1005
1006 void object_panel_draw(Object *ob)
1007 {
1008         uiBlock *block;
1009         int xco, a, dx, dy;
1010         
1011         block= uiNewBlock(&curarea->uiblocks, "object_panel_draw", UI_EMBOSS, UI_HELV, curarea->win);
1012         if(uiNewPanel(curarea, block, "Draw", "Object", 320, 0, 318, 204)==0) return;
1013
1014         /* LAYERS */
1015         xco= 151;
1016         dx= 32;
1017         dy= 30;
1018
1019         uiBlockBeginAlign(block);
1020         for(a=0; a<5; a++)
1021                 uiDefButI(block, TOG|BIT|(a), B_OBLAY+a, "",    (short)(xco+a*(dx/2)), 180, (short)(dx/2), (short)(dy/2), &(BASACT->lay), 0, 0, 0, 0, "");
1022         for(a=0; a<5; a++)
1023                 uiDefButI(block, TOG|BIT|(a+10), B_OBLAY+a+10, "",      (short)(xco+a*(dx/2)), 165, (short)(dx/2), (short)(dy/2), &(BASACT->lay), 0, 0, 0, 0, "");
1024                 
1025         xco+= 5;
1026         uiBlockBeginAlign(block);
1027         for(a=5; a<10; a++)
1028                 uiDefButI(block, TOG|BIT|(a), B_OBLAY+a, "",    (short)(xco+a*(dx/2)), 180, (short)(dx/2), (short)(dy/2), &(BASACT->lay), 0, 0, 0, 0, "");
1029         for(a=5; a<10; a++)
1030                 uiDefButI(block, TOG|BIT|(a+10), B_OBLAY+a+10, "",      (short)(xco+a*(dx/2)), 165, (short)(dx/2), (short)(dy/2), &(BASACT->lay), 0, 0, 0, 0, "");
1031
1032         uiBlockEndAlign(block);
1033
1034         uiDefBut(block, LABEL, 0, "Drawtype",                                           28,200,100,18, NULL, 0, 0, 0, 0, "");
1035         uiDefButC(block, MENU, REDRAWVIEW3D, "Drawtype%t|Bounds %x1|Wire %x2|Solid %x3|Shaded %x4",     
1036                                                                                                                                 28,180,100,18, &ob->dt, 0, 0, 0, 0, "Sets the drawing type of the active object");
1037         uiDefBut(block, LABEL, 0, "Draw Extra",                                         28,160,100,18, NULL, 0, 0, 0, 0, "");
1038         uiBlockBeginAlign(block);
1039         uiDefButC(block, TOG|BIT|0, REDRAWVIEW3D, "Bounds",             28, 140, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's bounds");
1040         uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Polyheder%x4",
1041                                                                                                                         28, 120, 100, 18, &ob->boundtype, 0, 0, 0, 0, "Selects the boundary display type");
1042         uiDefButBitC(block, TOG, OB_DRAWWIRE, REDRAWVIEW3D, "Wire",             28, 100, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's wireframe in shaded drawing modes");
1043         uiDefButBitC(block, TOG, OB_AXIS, REDRAWVIEW3D, "Axis",         28, 80, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's centre and axis");
1044         uiDefButBitC(block, TOG, OB_TEXSPACE, REDRAWVIEW3D, "TexSpace", 28, 60, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's texture space");
1045         uiDefButBitC(block, TOG, OB_DRAWNAME, REDRAWVIEW3D, "Name",             28, 40, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's name");
1046         
1047         
1048 }
1049
1050 void object_panel_hooks(Object *ob)
1051 {
1052         uiBlock *block;
1053         ObHook *hook;
1054         int tothook=0, nr, active;
1055         char *cp;
1056         
1057         block= uiNewBlock(&curarea->uiblocks, "object_panel_hooks", UI_EMBOSS, UI_HELV, curarea->win);
1058         uiNewPanelTabbed("Draw", "Object");
1059         if(uiNewPanel(curarea, block, "Hooks", "Object", 320, 0, 318, 204)==0) return;
1060
1061         if(ob->hooks.first==NULL) {
1062                 uiDefBut(block, LABEL, 0, "Add hooks in Editmode", 10,180,300,19, NULL, 0, 0, 0, 0, "");
1063                 return;
1064         }
1065         
1066         /* build menu */
1067         for(hook= ob->hooks.first; hook; hook= hook->next) tothook++;
1068         
1069         cp= MEM_callocN(32*tothook+32, "temp string");
1070         strcpy(cp, "Active Hook %t|");
1071
1072         for(hook= ob->hooks.first; hook; hook= hook->next) {
1073                 strcat(cp, hook->name);
1074                 strcat(cp, " |");
1075         }
1076         /* active is stored in first hook */
1077         hook= ob->hooks.first;
1078         if(hook->active<1 || hook->active > tothook) hook->active= 1;
1079         active= hook->active;
1080         
1081         uiBlockBeginAlign(block);
1082         uiDefButS(block, MENU, B_REDR, cp,                                      10,180,150,19, &hook->active, 0, 0, 0, 0, "Set active hook");
1083         MEM_freeN(cp);
1084
1085         for(nr=1, hook= ob->hooks.first; hook; hook= hook->next, nr++) {
1086                 if(nr==active) break;
1087         }
1088         if(hook==NULL) printf("error in object_panel_hooks\n");
1089         
1090         uiDefBut(block, TEX, B_REDR, "Name: ",                          160,180,150,19, hook->name, 0, 31, 0, 0, "Set name of hook");
1091
1092         uiBlockBeginAlign(block);
1093         uiDefButF(block, NUM, B_MAKEDISP, "Falloff: ",          160,140,150,19, &hook->falloff, 0.0, 100.0, 100, 0, "If not zero, the distance from hook where influence ends");
1094         uiDefButF(block, NUMSLI, B_MAKEDISP, "Force: ",         160,120,150,19, &hook->force, 0.0, 1.0, 100, 0, "Set relative force of hook");
1095         uiBlockEndAlign(block);
1096
1097         uiDefIDPoinBut(block, test_obpoin_but, B_CLR_HOOK, "Parent:",   10, 120, 150, 19, &hook->parent, "Parent Object for hook, also recalculates and clears offset"); 
1098
1099         uiBlockBeginAlign(block);
1100         uiDefBut(block, BUT, B_DEL_HOOK, "Delete",                              10,80,150,19, NULL, 0.0, 0.0, 0, 0, "Delete hook");
1101         uiDefBut(block, BUT, B_CLR_HOOK, "Clear offset",                160,80,150,19, NULL, 0.0, 0.0, 0, 0, "Recalculate and clear offset (transform) of hook");
1102 }
1103
1104
1105 void do_object_panels(unsigned short event)
1106 {
1107         Object *ob;
1108         ObHook *hook;
1109         Effect *eff;
1110         
1111         ob= OBACT;
1112
1113         switch(event) {
1114         case B_TRACKBUTS:
1115                 ob= OBACT;
1116                 if(ob && ob->parent && ob->parent->type==OB_CURVE) freedisplist(&ob->disp);
1117                 allqueue(REDRAWVIEW3D, 0);
1118                 break;
1119         case B_DEL_HOOK:
1120                 hook= ob->hooks.first;
1121                 if(hook) {
1122                         int active= hook->active, nr;
1123                         for(nr=1, hook=ob->hooks.first; hook; hook=hook->next, nr++) {
1124                                 if(active==nr) break;
1125                         }
1126                         if(hook) {
1127                                 BLI_remlink(&ob->hooks, hook);
1128                                 if(hook->indexar) MEM_freeN(hook->indexar);
1129                                 MEM_freeN(hook);
1130                         }
1131                         freedisplist(&ob->disp);
1132                         BIF_undo_push("Delete hook");
1133                         allqueue(REDRAWVIEW3D, 0);
1134                         allqueue(REDRAWBUTSOBJECT, 0);
1135                 }
1136                 break;
1137         case B_CLR_HOOK:
1138                 hook= ob->hooks.first;
1139                 if(hook) {
1140                         int active= hook->active, nr;
1141                         for(nr=1, hook=ob->hooks.first; hook; hook=hook->next, nr++) {
1142                                 if(active==nr) break;
1143                         }
1144                         if(hook && hook->parent) {
1145                                 Mat4Invert(hook->parent->imat, hook->parent->obmat);
1146                                 /* apparently this call goes from right to left... */
1147                                 Mat4MulSerie(hook->parentinv, hook->parent->imat, ob->obmat, NULL, 
1148                                                         NULL, NULL, NULL, NULL, NULL);
1149                                 BIF_undo_push("Clear hook");
1150                                 allqueue(REDRAWVIEW3D, 0);
1151                         }
1152                 }
1153                 break;
1154         case B_RECALCPATH:
1155                 calc_curvepath(OBACT);
1156                 allqueue(REDRAWVIEW3D, 0);
1157                 break;
1158         case B_PRINTSPEED:
1159                 ob= OBACT;
1160                 if(ob) {
1161                         float vec[3];
1162                         CFRA++;
1163                         do_ob_ipo(ob);
1164                         where_is_object(ob);
1165                         VECCOPY(vec, ob->obmat[3]);
1166                         CFRA--;
1167                         do_ob_ipo(ob);
1168                         where_is_object(ob);
1169                         VecSubf(vec, vec, ob->obmat[3]);
1170                         prspeed= Normalise(vec);
1171                         scrarea_queue_winredraw(curarea);
1172                 }
1173                 break;
1174         case B_PRINTLEN:
1175                 ob= OBACT;
1176                 if(ob && ob->type==OB_CURVE) {
1177                         Curve *cu=ob->data;
1178                         
1179                         if(cu->path) prlen= cu->path->totdist; else prlen= -1.0;
1180                         scrarea_queue_winredraw(curarea);
1181                 } 
1182                 break;
1183         case B_RELKEY:
1184                 allspace(REMAKEIPO, 0);
1185                 allqueue(REDRAWBUTSOBJECT, 0);
1186                 allqueue(REDRAWIPO, 0);
1187                 break;
1188         case B_CURVECHECK:
1189                 curve_changes_other_objects(OBACT);
1190                 allqueue(REDRAWVIEW3D, 0);
1191                 break;
1192         
1193         case B_SOFTBODY_CHANGE:
1194                 ob= OBACT;
1195                 if(ob) {
1196                         ob->softflag |= OB_SB_REDO;
1197                         allqueue(REDRAWBUTSOBJECT, 0);
1198                         allqueue(REDRAWVIEW3D, 0);
1199                 }
1200                 break;
1201         case B_SOFTBODY_DEL_VG:
1202                 ob= OBACT;
1203                 if(ob && ob->soft) {
1204                         ob->soft->vertgroup= 0;
1205                         ob->softflag |= OB_SB_REDO;
1206                         allqueue(REDRAWBUTSOBJECT, 0);
1207                         allqueue(REDRAWVIEW3D, 0);
1208                 }
1209                 break;
1210                 
1211         default:
1212                 if(event>=B_SELEFFECT && event<B_SELEFFECT+MAX_EFFECT) {
1213                         ob= OBACT;
1214                         if(ob) {
1215                                 int a=B_SELEFFECT;
1216                                 
1217                                 eff= ob->effect.first;
1218                                 while(eff) {
1219                                         if(event==a) eff->flag |= SELECT;
1220                                         else eff->flag &= ~SELECT;
1221                                         
1222                                         a++;
1223                                         eff= eff->next;
1224                                 }
1225                                 allqueue(REDRAWBUTSOBJECT, 0);
1226                         }
1227                 }
1228         }
1229
1230 }
1231
1232 static void object_panel_anim(Object *ob)
1233 {
1234         uiBlock *block;
1235         char str[32];
1236         
1237         block= uiNewBlock(&curarea->uiblocks, "object_panel_anim", UI_EMBOSS, UI_HELV, curarea->win);
1238         if(uiNewPanel(curarea, block, "Anim settings", "Object", 0, 0, 318, 204)==0) return;
1239         
1240         uiBlockBeginAlign(block);
1241         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");
1242         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");
1243         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");
1244         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");
1245         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");
1246         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");
1247         uiBlockBeginAlign(block);
1248         uiDefButC(block, ROW,REDRAWVIEW3D,"UpX",        226,190,45,19, &ob->upflag, 13.0, 0.0, 0, 0, "Specify the axis that points up");
1249         uiDefButC(block, ROW,REDRAWVIEW3D,"Y",          274,190,20,19, &ob->upflag, 13.0, 1.0, 0, 0, "Specify the axis that points up");
1250         uiDefButC(block, ROW,REDRAWVIEW3D,"Z",          298,190,19,19, &ob->upflag, 13.0, 2.0, 0, 0, "Specify the axis that points up");
1251         uiBlockBeginAlign(block);
1252         uiDefButC(block, TOG|BIT|0, REDRAWVIEW3D, "Draw Key",           24,160,71,19, &ob->ipoflag, 0, 0, 0, 0, "Draw object as key position");
1253         uiDefButC(block, TOG|BIT|1, REDRAWVIEW3D, "Draw Key Sel",       97,160,81,19, &ob->ipoflag, 0, 0, 0, 0, "Limit the drawing of object keys");
1254         uiDefButC(block, TOG|BIT|7, REDRAWVIEW3D, "Powertrack",         180,160,78,19, &ob->transflag, 0, 0, 0, 0, "Switch objects rotation off");
1255         uiDefButS(block, TOG|BIT|4, 0, "SlowPar",                                       260,160,56,19, &ob->partype, 0, 0, 0, 0, "Create a delay in the parent relationship");
1256         uiBlockBeginAlign(block);
1257         uiDefButC(block, TOG|BIT|3, REDRAWVIEW3D, "DupliFrames",        24,128,89,19, &ob->transflag, 0, 0, 0, 0, "Make copy of object for every frame");
1258         uiDefButC(block, TOG|BIT|4, REDRAWVIEW3D, "DupliVerts",         114,128,82,19, &ob->transflag, 0, 0, 0, 0, "Duplicate child objects on all vertices");
1259         uiDefButC(block, TOG|BIT|5, REDRAWVIEW3D, "Rot",                200,128,31,19, &ob->transflag, 0, 0, 0, 0, "Rotate dupli according to facenormal");
1260         uiDefButC(block, TOG|BIT|6, REDRAWVIEW3D, "No Speed",   234,128,82,19, &ob->transflag, 0, 0, 0, 0, "Set dupliframes to still, regardless of frame");
1261         uiBlockBeginAlign(block);
1262         uiDefButS(block, NUM, REDRAWVIEW3D, "DupSta:",          24,105,141,19, &ob->dupsta, 1.0, (MAXFRAMEF - 1.0f), 0, 0, "Specify startframe for Dupliframes");
1263         uiDefButS(block, NUM, REDRAWVIEW3D, "DupOn:",           170,105,146,19, &ob->dupon, 1.0, 1500.0, 0, 0, "");
1264         uiDefButS(block, NUM, REDRAWVIEW3D, "DupEnd",           24,82,140,19, &ob->dupend, 1.0, MAXFRAMEF, 0, 0, "Specify endframe for Dupliframes");
1265         uiDefButS(block, NUM, REDRAWVIEW3D, "DupOff",           171,82,145,19, &ob->dupoff, 0.0, 1500.0, 0, 0, "");
1266         uiBlockBeginAlign(block);
1267         uiDefButC(block, TOG|BIT|2, REDRAWALL, "Offs Ob",                       24,51,56,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on its own objectipo");
1268         uiDefButC(block, TOG|BIT|6, REDRAWALL, "Offs Par",                      82,51,56,20 , &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the parent");
1269         uiDefButC(block, TOG|BIT|7, REDRAWALL, "Offs Particle",         140,51,103,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the particle effect");
1270         
1271         uiBlockBeginAlign(block);
1272         uiDefButF(block, NUM, REDRAWALL, "TimeOffset:",                 24,17,115,30, &ob->sf, -9000.0, 9000.0, 100, 0, "Specify an offset in frames");
1273         uiDefBut(block, BUT, B_AUTOTIMEOFS, "Automatic Time",   139,17,104,31, 0, 0, 0, 0, 0, "Generate automatic timeoffset values for all selected frames");
1274         uiDefBut(block, BUT, B_PRINTSPEED,      "PrSpeed",                      248,17,67,31, 0, 0, 0, 0, 0, "Print objectspeed");
1275         uiBlockEndAlign(block);
1276         
1277         sprintf(str, "%.4f", prspeed);
1278         uiDefBut(block, LABEL, 0, str,                                                  247,40,63,31, NULL, 1.0, 0, 0, 0, "");
1279         
1280 }
1281
1282 void do_effects_panels(unsigned short event)
1283 {
1284         Object *ob;
1285         Base *base;
1286         Effect *eff, *effn;
1287         int type;
1288         
1289         ob= OBACT;
1290
1291         switch(event) {
1292
1293     case B_AUTOTIMEOFS:
1294                 auto_timeoffs();
1295                 break;
1296         case B_FRAMEMAP:
1297                 G.scene->r.framelen= G.scene->r.framapto;
1298                 G.scene->r.framelen/= G.scene->r.images;
1299                 break;
1300         case B_NEWEFFECT:
1301                 if(ob) {
1302                         if (BLI_countlist(&ob->effect)==MAX_EFFECT)
1303                                 error("Unable to add: effect limit reached");
1304                         else
1305                                 copy_act_effect(ob);
1306                 }
1307                 BIF_undo_push("New effect");
1308                 allqueue(REDRAWBUTSOBJECT, 0);
1309                 break;
1310         case B_DELEFFECT:
1311                 if(ob==0 || ob->type!=OB_MESH) break;
1312                 eff= ob->effect.first;
1313                 while(eff) {
1314                         effn= eff->next;
1315                         if(eff->flag & SELECT) {
1316                                 BLI_remlink(&ob->effect, eff);
1317                                 free_effect(eff);
1318                                 break;
1319                         }
1320                         eff= effn;
1321                 }
1322                 BIF_undo_push("Delete effect");
1323                 allqueue(REDRAWVIEW3D, 0);
1324                 allqueue(REDRAWBUTSOBJECT, 0);
1325                 break;
1326         case B_NEXTEFFECT:
1327                 if(ob==0 || ob->type!=OB_MESH) break;
1328                 eff= ob->effect.first;
1329                 while(eff) {
1330                         if(eff->flag & SELECT) {
1331                                 if(eff->next) {
1332                                         eff->flag &= ~SELECT;
1333                                         eff->next->flag |= SELECT;
1334                                 }
1335                                 break;
1336                         }
1337                         eff= eff->next;
1338                 }
1339                 allqueue(REDRAWBUTSOBJECT, 0);
1340                 break;
1341         case B_PREVEFFECT:
1342                 if(ob==0 || ob->type!=OB_MESH) break;
1343                 eff= ob->effect.first;
1344                 while(eff) {
1345                         if(eff->flag & SELECT) {
1346                                 if(eff->prev) {
1347                                         eff->flag &= ~SELECT;
1348                                         eff->prev->flag |= SELECT;
1349                                 }
1350                                 break;
1351                         }
1352                         eff= eff->next;
1353                 }
1354                 allqueue(REDRAWBUTSOBJECT, 0);
1355                 break;
1356         case B_CHANGEEFFECT:
1357                 if(ob==0 || ob->type!=OB_MESH) break;
1358                 eff= ob->effect.first;
1359                 while(eff) {
1360                         if(eff->flag & SELECT) {
1361                                 if(eff->type!=eff->buttype) {
1362                                         BLI_remlink(&ob->effect, eff);
1363                                         type= eff->buttype;
1364                                         free_effect(eff);
1365                                         eff= add_effect(type);
1366                                         BLI_addtail(&ob->effect, eff);
1367                                 }
1368                                 break;
1369                         }
1370                         eff= eff->next;
1371                 }
1372                 allqueue(REDRAWVIEW3D, 0);
1373                 allqueue(REDRAWBUTSOBJECT, 0);
1374                 break;
1375         case B_CALCEFFECT:
1376                 if(ob==0 || ob->type!=OB_MESH) break;
1377                 eff= ob->effect.first;
1378                 while(eff) {
1379                         if(eff->flag & SELECT) {
1380                                 if(eff->type==EFF_PARTICLE) build_particle_system(ob);
1381                                 else if(eff->type==EFF_WAVE) freedisplist(&ob->disp);
1382                         }
1383                         eff= eff->next;
1384                 }
1385                 allqueue(REDRAWVIEW3D, 0);
1386                 allqueue(REDRAWBUTSOBJECT, 0);
1387                 break;
1388         case B_RECALCAL:
1389                 base= FIRSTBASE;
1390                 while(base) {
1391                         if(base->lay & G.vd->lay) {
1392                                 ob= base->object;
1393                                 eff= ob->effect.first;
1394                                 while(eff) {
1395                                         if(eff->flag & SELECT) {
1396                                                 if(eff->type==EFF_PARTICLE) build_particle_system(ob);
1397                                         }
1398                                         eff= eff->next;
1399                                 }
1400                         }
1401                         base= base->next;
1402                 }
1403                 allqueue(REDRAWVIEW3D, 0);
1404                 break;
1405
1406         default:
1407                 if(event>=B_SELEFFECT && event<B_SELEFFECT+MAX_EFFECT) {
1408                         ob= OBACT;
1409                         if(ob) {
1410                                 int a=B_SELEFFECT;
1411                                 
1412                                 eff= ob->effect.first;
1413                                 while(eff) {
1414                                         if(event==a) eff->flag |= SELECT;
1415                                         else eff->flag &= ~SELECT;
1416                                         
1417                                         a++;
1418                                         eff= eff->next;
1419                                 }
1420                                 allqueue(REDRAWBUTSOBJECT, 0);
1421                         }
1422                 }
1423         }
1424
1425 }
1426
1427 /* Panel for particle interaction settings */
1428 static void object_panel_deflectors(Object *ob)
1429 {
1430         uiBlock *block;
1431
1432         block= uiNewBlock(&curarea->uiblocks, "object_panel_deflectors", UI_EMBOSS, UI_HELV, curarea->win);
1433         uiNewPanelTabbed("Constraints", "Object");
1434         if(uiNewPanel(curarea, block, "Particle Interaction", "Object", 640, 0, 318, 204)==0) return;
1435
1436         /* should become button, option? */
1437         if(ob->pd==NULL) {
1438                 ob->pd= MEM_callocN(sizeof(PartDeflect), "PartDeflect");
1439                 /* and if needed, init here */
1440         }
1441         
1442         if(ob->pd) {
1443                 PartDeflect *pd= ob->pd;
1444                 
1445                 uiBlockBeginAlign(block);
1446                 uiDefButS(block, ROW, REDRAWVIEW3D, "None",                     10,160,50,20, &pd->forcefield, 1.0, 0, 0, 0, "No force");
1447                 uiDefButS(block, ROW, REDRAWVIEW3D, "Wind",                     60,160,50,20, &pd->forcefield, 1.0, PFIELD_WIND, 0, 0, "Constant force applied in direction of Object Z axis");
1448                 uiDefButS(block, ROW, REDRAWVIEW3D, "Force field",      110,160,100,20, &pd->forcefield, 1.0, PFIELD_FORCE, 0, 0, "Object center attracts or repels particles");
1449                 uiDefButS(block, ROW, REDRAWVIEW3D, "Vortex field",     210,160,100,20, &pd->forcefield, 1.0, PFIELD_VORTEX, 0, 0, "Particles swirl around Z-axis of the object");
1450
1451                 uiBlockBeginAlign(block);
1452                 uiDefButF(block, NUM, REDRAWVIEW3D, "Strength: ",       10,130,150,20, &pd->f_strength, -1000, 1000, 1000, 0, "Strength of force field");
1453                 uiDefButF(block, NUM, REDRAWVIEW3D, "Fall-off: ",       160,130,150,20, &pd->f_power, 0, 10, 100, 0, "Falloff power (real gravitational fallof = 2)");
1454                 uiDefButBitS(block, TOG, PFIELD_USEMAX, REDRAWVIEW3D, "Use MaxDist",    10,110,150,20, &pd->flag, 0.0, 0, 0, 0, "Use a maximum distance for the field to work");
1455                 uiDefButF(block, NUM, REDRAWVIEW3D, "MaxDist: ",        160,110,150,20, &pd->maxdist, 0, 1000.0, 100, 0, "Maximum distance for the field to work");
1456
1457                 /* only meshes collide now */
1458                 if(ob->type==OB_MESH) {
1459                         uiBlockBeginAlign(block);
1460                         uiDefButS(block, TOG|BIT|0, B_DIFF, "Deflection",10,50,200,20, &pd->deflect, 0, 0, 0, 0, "Deflects particles based on collision");
1461                         uiDefButF(block, NUM, B_DIFF, "Damping: ",      10,30,200,20, &pd->pdef_damp, 0.0, 1.0, 10, 0, "Amount of damping during particle collision");
1462                         uiDefButF(block, NUM, B_DIFF, "Rnd Damping: ",  10,10,200,20, &pd->pdef_rdamp, 0.0, 1.0, 10, 0, "Random variation of damping");
1463                         uiDefButF(block, NUM, B_DIFF, "Permeability: ",         10,-10,200,20, &pd->pdef_perm, 0.0, 1.0, 10, 0, "Chance that the particle will pass through the mesh");
1464                 }
1465                 uiBlockEndAlign(block);
1466         }
1467 }
1468
1469 /* Panel for softbodies */
1470
1471 static void object_softbodies(Object *ob)
1472 {
1473         uiBlock *block;
1474         
1475         block= uiNewBlock(&curarea->uiblocks, "object_softbodies", UI_EMBOSS, UI_HELV, curarea->win);
1476         uiNewPanelTabbed("Constraints", "Object");
1477         if(uiNewPanel(curarea, block, "Softbody", "Object", 640, 0, 318, 204)==0) return;
1478
1479         uiDefButBitS(block, TOG, OB_SB_ENABLE, REDRAWBUTSOBJECT, "Enable Soft Body",    10,200,150,20, &ob->softflag, 0, 0, 0, 0, "Sets object to become soft body");
1480         uiDefBut(block, LABEL, 0, "",   160, 200,150,20, NULL, 0.0, 0.0, 0, 0, "");     // alignment reason
1481         
1482         if(ob->softflag & OB_SB_ENABLE) {
1483                 SoftBody *sb= ob->soft;
1484                 int defCount;
1485                 char *menustr;
1486                 
1487                 if(sb==NULL) {
1488                         sb= ob->soft= sbNew();
1489                         ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
1490                         // default add edges for softbody
1491                         if(ob->type==OB_MESH) {
1492                                 Mesh *me= ob->data;
1493                                 if(me->medge==NULL) make_edges(me);
1494                         }
1495                 }
1496                 
1497                 /* GENERAL STUFF */
1498                 uiBlockBeginAlign(block);
1499                 uiDefButF(block, NUM, B_DIFF, "Friction:",              10, 170,150,20, &sb->mediafrict, 0.0, 10.0, 10, 0, "General Friction for point movements");
1500                 uiDefButF(block, NUM, B_DIFF, "Mass:",                  160, 170,150,20, &sb->nodemass , 0.001, 50.0, 10, 0, "Point Mass, the heavier the slower");
1501                 uiDefButF(block, NUM, B_DIFF, "Grav:",                  10,150,150,20, &sb->grav , 0.0, 10.0, 10, 0, "Apply gravitation to point movement");
1502                 uiDefButF(block, NUM, B_DIFF, "RKL:",                   160,150,150,20, &sb->rklimit , 0.01, 1.0, 10, 0, "Runge-Kutta ODE solver error limit");
1503                 uiDefButBitS(block, TOG, OB_SB_POSTDEF, B_DIFF, "PostDef",      10,130,300,20, &ob->softflag, 0, 0, 0, 0, "Apply Soft AFTER Deform");
1504                 uiBlockEndAlign(block);
1505                 
1506                 /* GOAL STUFF */
1507                 uiBlockBeginAlign(block);
1508                 uiDefButBitS(block, TOG, OB_SB_GOAL, B_DIFF, "Use Goal",        10,100,130,20, &ob->softflag, 0, 0, 0, 0, "Define forces for vertices to stick to animated position");
1509                 
1510                 menustr= get_vertexgroup_menustr(ob);
1511                 defCount=BLI_countlist(&ob->defbase);
1512                 if(defCount==0) sb->vertgroup= 0;
1513                 uiDefButS(block, MENU, B_SOFTBODY_CHANGE, menustr,              140,100,20,20, &sb->vertgroup, 0, defCount, 0, 0, "Browses available vertex groups");
1514                 
1515                 if(sb->vertgroup) {
1516                         bDeformGroup *defGroup = BLI_findlink(&ob->defbase, sb->vertgroup-1);
1517                         if(defGroup)
1518                                 uiDefBut(block, BUT, B_DIFF, defGroup->name,    160,100,130,20, NULL, 0.0, 0.0, 0, 0, "Name of current vertex group");
1519                         else
1520                                 uiDefBut(block, BUT, B_DIFF, "(no group)",      160,100,130,20, NULL, 0.0, 0.0, 0, 0, "Vertex Group doesn't exist anymore");
1521                         uiDefIconBut(block, BUT, B_SOFTBODY_DEL_VG, ICON_X, 290,100,20,20, 0, 0, 0, 0, 0, "Disable use of vertex group");
1522                 }
1523                 else {
1524                         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");
1525                 }
1526                 MEM_freeN (menustr);
1527
1528                 uiDefButF(block, NUM, B_DIFF, "GSpring:",       10,80,150,20, &sb->goalspring, 0.0, 0.999, 10, 0, "Goal (vertex target position) Spring Constant");
1529                 uiDefButF(block, NUM, B_DIFF, "GFrict:",        160,80,150,20, &sb->goalfrict  , 0.0, 10.0, 10, 0, "Goal (vertex target position) Friction Constant");
1530                 uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "GMin:",               10,60,150,20, &sb->mingoal, 0.0, 1.0, 10, 0, "Min Goal bound");
1531                 uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "GMax:",               160,60,150,20, &sb->maxgoal, 0.0, 1.0, 10, 0, "Max Goal bound");
1532                 uiBlockEndAlign(block);
1533                 
1534                 /* EDGE SPRING STUFF */
1535                 uiBlockBeginAlign(block);
1536                 uiDefButBitS(block, TOG, OB_SB_EDGES, B_SOFTBODY_CHANGE, "Use Edges",           10,30,150,20, &ob->softflag, 0, 0, 0, 0, "Use Robust 2nd order solver");
1537                 uiDefButBitS(block, TOG, OB_SB_QUADS, B_SOFTBODY_CHANGE, "Stiff Quads",         160,30,150,20, &ob->softflag, 0, 0, 0, 0, "Sets object to have diagonal springs on 4-gons");
1538                 uiDefButF(block, NUM, B_DIFF, "ESpring:",       10,10,150,20, &sb->inspring, 0.0,  0.999, 10, 0, "Edge Spring Constant");
1539                 uiDefButF(block, NUM, B_DIFF, "EFrict:",        160,10,150,20, &sb->infrict, 0.0,  10.0, 10, 0, "Edge Friction Constant");
1540                 uiBlockEndAlign(block);
1541
1542         }
1543         uiBlockEndAlign(block);
1544
1545 }
1546
1547 void object_panel_effects(Object *ob)
1548 {
1549         Effect *eff;
1550         uiBlock *block;
1551         int a;
1552         short x, y;
1553         
1554         block= uiNewBlock(&curarea->uiblocks, "object_panel_effects", UI_EMBOSS, UI_HELV, curarea->win);
1555         uiNewPanelTabbed("Constraints", "Object");
1556         if(uiNewPanel(curarea, block, "Effects", "Object", 640, 0, 318, 204)==0) return;
1557
1558         /* EFFECTS */
1559         
1560         if (ob->type == OB_MESH) {
1561                 uiBlockBeginAlign(block);
1562                 uiDefBut(block, BUT, B_NEWEFFECT, "NEW Effect", 550,187,124,27, 0, 0, 0, 0, 0, "Create a new effect");
1563                 uiDefBut(block, BUT, B_DELEFFECT, "Delete", 676,187,62,27, 0, 0, 0, 0, 0, "Delete the effect");
1564                 uiBlockEndAlign(block);
1565         }
1566
1567         /* select effs */
1568         eff= ob->effect.first;
1569         a= 0;
1570         while(eff) {
1571                 
1572                 x= 15 * a + 550;
1573                 y= 172; // - 12*( abs(a/10) ) ;
1574                 uiDefButS(block, TOG|BIT|0, B_SELEFFECT+a, "", x, y, 15, 12, &eff->flag, 0, 0, 0, 0, "");
1575                 
1576                 a++;
1577                 if(a==MAX_EFFECT) break;
1578                 eff= eff->next;
1579         }
1580         
1581         eff= ob->effect.first;
1582         while(eff) {
1583                 if(eff->flag & SELECT) break;
1584                 eff= eff->next;
1585         }
1586         
1587         if(eff) {
1588                 uiDefButS(block, MENU, B_CHANGEEFFECT, "Build %x0|Particles %x1|Wave %x2", 895,187,107,27, &eff->buttype, 0, 0, 0, 0, "Set effect type");
1589                 
1590                 if(eff->type==EFF_BUILD) {
1591                         BuildEff *bld;
1592                         
1593                         bld= (BuildEff *)eff;
1594                         
1595                         uiDefButF(block, NUM, 0, "Len:",                        649,138,95,21, &bld->len, 1.0, 9000.0, 100, 0, "Specify the total time the build effect requires");
1596                         uiDefButF(block, NUM, 0, "Sfra:",                       746,138,94,22, &bld->sfra, 1.0, 9000.0, 100, 0, "Specify the startframe of the effect");
1597                 }
1598                 else if(eff->type==EFF_WAVE) {
1599                         WaveEff *wav;
1600                         
1601                         wav= (WaveEff *)eff;
1602                         uiBlockBeginAlign(block);
1603                         uiDefButS(block, TOG|BIT|1, B_CALCEFFECT, "X",          782,135,54,23, &wav->flag, 0, 0, 0, 0, "Enable X axis motion");
1604                         uiDefButS(block, TOG|BIT|2, B_CALCEFFECT, "Y",          840,135,47,23, &wav->flag, 0, 0, 0, 0, "Enable Y axis motion");
1605                         uiDefButS(block, TOG|BIT|3, B_CALCEFFECT, "Cycl",       890,135,111,23, &wav->flag, 0, 0, 0, 0, "Enable cyclic wave effect");
1606                         uiBlockBeginAlign(block);
1607                         uiDefButF(block, NUM, B_CALCEFFECT, "Sta x:",           550,135,113,24, &wav->startx, -100.0, 100.0, 100, 0, "Starting position for the X axis");
1608                         uiDefButF(block, NUM, B_CALCEFFECT, "Sta y:",           665,135,104,24, &wav->starty, -100.0, 100.0, 100, 0, "Starting position for the Y axis");
1609                         uiBlockBeginAlign(block);
1610                         uiDefButF(block, NUMSLI, B_CALCEFFECT, "Speed:",        550,100,216,20, &wav->speed, -2.0, 2.0, 0, 0, "Specify the wave speed");
1611                         uiDefButF(block, NUMSLI, B_CALCEFFECT, "Heigth:",       550,80,216,20, &wav->height, -2.0, 2.0, 0, 0, "Specify the amplitude of the wave");
1612                         uiDefButF(block, NUMSLI, B_CALCEFFECT, "Width:",        550,60,216,20, &wav->width, 0.0, 5.0, 0, 0, "Specify the width of the wave");
1613                         uiDefButF(block, NUMSLI, B_CALCEFFECT, "Narrow:",       550,40,216,20, &wav->narrow, 0.0, 10.0, 0, 0, "Specify how narrow the wave follows");
1614                         uiBlockBeginAlign(block);
1615                         uiDefButF(block, NUM, B_CALCEFFECT, "Time sta:",        780,100,219,20, &wav->timeoffs, -1000.0, 1000.0, 100, 0, "Specify startingframe of the wave");
1616
1617                         uiDefButF(block, NUM, B_CALCEFFECT, "Lifetime:",        780,80,219,20, &wav->lifetime,  -1000.0, 1000.0, 100, 0, "Specify the lifespan of the wave");
1618                         uiDefButF(block, NUM, B_CALCEFFECT, "Damptime:",        780,60,219,20, &wav->damp,  -1000.0, 1000.0, 100, 0, "Specify the dampingtime of the wave");
1619                         uiBlockEndAlign(block);
1620                 }
1621                 else if(eff->type==EFF_PARTICLE) {
1622                         PartEff *paf;
1623                         
1624                         paf= (PartEff *)eff;
1625                         
1626                         uiDefBut(block, BUT, B_RECALCAL, "RecalcAll", 741,187,67,27, 0, 0, 0, 0, 0, "Update the particle system");
1627                         uiBlockBeginAlign(block);
1628                         uiDefButS(block, TOG|BIT|2, B_CALCEFFECT, "Static",     825,187,67,27, &paf->flag, 0, 0, 0, 0, "Make static particles (deform only works with SubSurf)");
1629                         if(paf->flag & PAF_STATIC)
1630                                 uiDefButS(block, TOG|BIT|4, B_DIFF, "Animated",825,167,67,20, &paf->flag, 0, 0, 0, 0, "Static particles are recalculated each rendered frame");
1631                         
1632                         uiBlockBeginAlign(block);
1633                         uiDefButI(block, NUM, B_CALCEFFECT, "Tot:",                     550,146,91,20, &paf->totpart, 1.0, 100000.0, 0, 0, "Set the total number of particles");
1634                         if(paf->flag & PAF_STATIC) {
1635                                 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");
1636                         }
1637                         else {
1638                                 uiDefButF(block, NUM, B_CALCEFFECT, "Sta:",             644,146,84,20, &paf->sta, -250.0, 9000.0, 100, 0, "Specify the startframe");
1639                                 uiDefButF(block, NUM, B_CALCEFFECT, "End:",             731,146,97,20, &paf->end, 1.0, 9000.0, 100, 0, "Specify the endframe");
1640                         }
1641                         uiDefButF(block, NUM, B_CALCEFFECT, "Life:",            831,146,88,20, &paf->lifetime, 1.0, 9000.0, 100, 0, "Specify the life span of the particles");
1642                         uiDefButI(block, NUM, B_CALCEFFECT, "Keys:",            922,146,80,20, &paf->totkey, 1.0, 100.0, 0, 0, "Specify the number of key positions");
1643                         
1644                         uiDefButS(block, NUM, B_REDR,           "CurMul:",              550,124,91,20, &paf->curmult, 0.0, 3.0, 0, 0, "Multiply the particles");
1645                         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");
1646                         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.");
1647                         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");
1648                         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");
1649                         
1650                         uiBlockBeginAlign(block);
1651                         uiDefButF(block, NUM, B_CALCEFFECT, "Randlife:",        550,96,96,20, &paf->randlife, 0.0, 2.0, 10, 0, "Give the particlelife a random variation");
1652                         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");
1653
1654                         uiDefButS(block, TOG|BIT|3, B_CALCEFFECT, "Face",               735,96,46,20, &paf->flag, 0, 0, 0, 0, "Emit particles also from faces");
1655                         uiDefButS(block, TOG|BIT|1, B_CALCEFFECT, "Bspline",    782,96,54,20, &paf->flag, 0, 0, 0, 0, "Use B spline formula for particle interpolation");
1656                         uiDefButS(block, TOG, REDRAWVIEW3D, "Vect",                             837,96,45,20, &paf->stype, 0, 0, 0, 0, "Give the particles a rotation direction");
1657                         uiDefButF(block, NUM, B_DIFF,                   "VectSize",             885,96,116,20, &paf->vectsize, 0.0, 1.0, 10, 0, "Set the speed for Vect");      
1658
1659                         uiBlockBeginAlign(block);
1660                         uiBlockSetCol(block, TH_BUT_SETTING2);
1661                         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");
1662                         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");
1663                         uiDefButF(block, NUM, B_CALCEFFECT, "Rand:",            738,67,86,20, &paf->randfac, 0.0, 2.0, 10, 0, "Give the startingspeed a random variation");
1664                         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");
1665                         uiDefButF(block, NUM, B_CALCEFFECT, "Damp:",            913,67,89,20, &paf->damp, 0.0, 1.0, 10, 0, "Specify the damping factor");
1666                         uiBlockSetCol(block, TH_AUTO);
1667                         
1668                         uiBlockBeginAlign(block);
1669                         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");
1670                         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");
1671                         uiDefBut(block, LABEL, 0, "Force:",                             550,9,72,20, NULL, 1.0, 0, 0, 0, "");
1672                         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");
1673
1674                         uiBlockBeginAlign(block);
1675                         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");
1676                         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");
1677                         uiDefBut(block, LABEL, 0, "Texture:",                   722,9,74,20, NULL, 1.0, 0, 0, 0, "");
1678                         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");
1679                         uiBlockEndAlign(block);
1680
1681                         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");
1682
1683                         uiBlockBeginAlign(block);
1684                         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");
1685                         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");
1686                         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");
1687
1688                 }
1689         }
1690 }
1691
1692 void object_panels()
1693 {
1694         Object *ob;
1695
1696         /* check context here */
1697         ob= OBACT;
1698         if(ob) {
1699                 if(ob->id.lib) uiSetButLock(1, "Can't edit library data");
1700
1701                 object_panel_anim(ob);
1702                 object_panel_draw(ob);
1703                 object_panel_hooks(ob);
1704                 object_panel_constraint();
1705                 if(ob->type==OB_MESH) {
1706                         object_panel_effects(ob);
1707                 }
1708                 object_panel_deflectors(ob);
1709                 object_softbodies(ob);
1710
1711                 uiClearButLock();
1712         }
1713 }
1714