add a button for object color access, previously could only be accessed
[plumiferos.git] / source / blender / src / buttons_object.c
blob3e097ba98d5414c06aa62a293c84345f1141f6fe
1 /**
2 * $Id: buttons_object.c 10730 2007-05-17 17:15:22Z blendix $
4 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
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.
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.
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.
23 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24 * All rights reserved.
26 * The Original Code is: all of this file.
28 * Contributor(s): none yet.
30 * ***** END GPL/BL DUAL LICENSE BLOCK *****
33 #include <time.h>
34 #include <math.h>
35 #include <stdlib.h>
36 #include <string.h>
38 #ifdef HAVE_CONFIG_H
39 #include <config.h>
40 #endif
42 #include "MEM_guardedalloc.h"
44 #include "DNA_ID.h"
45 #include "DNA_screen_types.h"
46 #include "DNA_space_types.h"
47 #include "DNA_scene_types.h"
49 #include "BKE_action.h"
50 #include "BKE_global.h"
51 #include "BKE_main.h"
52 #include "BKE_library.h"
53 #include "BKE_softbody.h"
54 #include "BKE_utildefines.h"
56 #include "BLI_blenlib.h"
57 #include "BLI_arithb.h"
59 #include "BSE_filesel.h"
60 #include "BSE_headerbuttons.h"
62 #include "BIF_butspace.h"
63 #include "BIF_editaction.h"
64 #include "BIF_gl.h"
65 #include "BIF_glutil.h"
66 #include "BIF_graphics.h"
67 #include "BIF_interface.h"
68 #include "BIF_keyval.h"
69 #include "BIF_mainqueue.h"
70 #include "BIF_mywindow.h"
71 #include "BIF_poseobject.h"
72 #include "BIF_resources.h"
73 #include "BIF_screen.h"
74 #include "BIF_space.h"
75 #include "BIF_toolbox.h"
77 #include "BDR_drawobject.h"
78 #include "BDR_editcurve.h"
80 #include "mydevice.h"
81 #include "blendef.h"
83 /* -----includes for this file specific----- */
86 #include "DNA_action_types.h"
87 #include "DNA_armature_types.h"
88 #include "DNA_camera_types.h"
89 #include "DNA_constraint_types.h"
90 #include "DNA_curve_types.h"
91 #include "DNA_effect_types.h"
92 #include "DNA_group_types.h"
93 #include "DNA_image_types.h"
94 #include "DNA_key_types.h"
95 #include "DNA_lamp_types.h"
96 #include "DNA_lattice_types.h"
97 #include "DNA_material_types.h"
98 #include "DNA_meta_types.h"
99 #include "DNA_mesh_types.h"
100 #include "DNA_modifier_types.h"
101 #include "DNA_object_types.h"
102 #include "DNA_object_force.h"
103 #include "DNA_object_fluidsim.h"
104 #include "DNA_radio_types.h"
105 #include "DNA_screen_types.h"
106 #include "DNA_sound_types.h"
107 #include "DNA_texture_types.h"
108 #include "DNA_userdef_types.h"
109 #include "DNA_vfont_types.h"
110 #include "DNA_view3d_types.h"
111 #include "DNA_world_types.h"
112 #include "DNA_text_types.h"
114 #include "BKE_anim.h"
115 #include "BKE_armature.h"
116 #include "BKE_constraint.h"
117 #include "BKE_curve.h"
118 #include "BKE_deform.h"
119 #include "BKE_depsgraph.h"
120 #include "BKE_displist.h"
121 #include "BKE_effect.h"
122 #include "BKE_font.h"
123 #include "BKE_group.h"
124 #include "BKE_image.h"
125 #include "BKE_ipo.h"
126 #include "BKE_lattice.h"
127 #include "BKE_material.h"
128 #include "BKE_mball.h"
129 #include "BKE_mesh.h"
130 #include "BKE_modifier.h"
131 #include "BKE_object.h"
132 #include "BKE_sound.h"
133 #include "BKE_texture.h"
134 #include "BKE_utildefines.h"
135 #include "BKE_DerivedMesh.h"
137 #include "LBM_fluidsim.h"
138 #include "elbeem.h"
140 #include "BIF_editconstraint.h"
141 #include "BIF_editdeform.h"
143 #include "BSE_editipo.h"
144 #include "BSE_edit.h"
146 #include "BDR_editobject.h"
147 #include "BPY_extern.h"
149 #include "butspace.h" // own module
151 static float prspeed=0.0;
152 float prlen=0.0;
155 /* ********************* CONSTRAINT ***************************** */
157 static void constraint_active_func(void *ob_v, void *con_v)
159 Object *ob= ob_v;
160 bConstraint *con;
161 ListBase *lb;
163 /* lets be nice and escape if its active already */
164 if(con_v) {
165 con= con_v;
166 if(con->flag & CONSTRAINT_ACTIVE) return;
169 lb= get_active_constraints(ob);
171 for(con= lb->first; con; con= con->next) {
172 if(con==con_v) con->flag |= CONSTRAINT_ACTIVE;
173 else con->flag &= ~CONSTRAINT_ACTIVE;
176 /* make sure ipowin and buttons shows it */
177 if(ob->ipowin==ID_CO) {
178 allqueue(REDRAWIPO, ID_CO);
179 allspace(REMAKEIPO, 0);
180 allqueue(REDRAWNLA, 0);
182 allqueue(REDRAWBUTSOBJECT, 0);
185 static void add_constraint_to_active(Object *ob, bConstraint *con)
187 ListBase *list;
189 list = get_active_constraints(ob);
190 if (list) {
191 unique_constraint_name(con, list);
192 BLI_addtail(list, con);
194 con->flag |= CONSTRAINT_ACTIVE;
195 for(con= con->prev; con; con= con->prev)
196 con->flag &= ~CONSTRAINT_ACTIVE;
200 /* returns base ID for Ipo, sets actname to channel if appropriate */
201 /* should not make action... */
202 void get_constraint_ipo_context(void *ob_v, char *actname)
204 Object *ob= ob_v;
206 /* todo; check object if it has ob-level action ipo */
208 if (ob->flag & OB_POSEMODE) {
209 bPoseChannel *pchan;
211 pchan = get_active_posechannel(ob);
212 if (pchan) {
213 BLI_strncpy(actname, pchan->name, 32);
216 else if(ob->ipoflag & OB_ACTION_OB)
217 strcpy(actname, "Object");
220 /* initialize UI to show Ipo window and make sure channels etc exist */
221 static void enable_constraint_ipo_func (void *ob_v, void *con_v)
223 Object *ob= ob_v;
224 bConstraint *con = con_v;
225 char actname[32]="";
227 /* verifies if active constraint is set and shown in UI */
228 constraint_active_func(ob_v, con_v);
230 /* the context */
231 get_constraint_ipo_context(ob, actname);
233 /* adds ipo & channels & curve if needed */
234 verify_ipo((ID *)ob, ID_CO, actname, con->name);
236 /* make sure ipowin shows it */
237 ob->ipowin= ID_CO;
238 allqueue(REDRAWIPO, ID_CO);
239 allspace(REMAKEIPO, 0);
240 allqueue(REDRAWNLA, 0);
244 static void add_influence_key_to_constraint_func (void *ob_v, void *con_v)
246 Object *ob= ob_v;
247 bConstraint *con = con_v;
248 IpoCurve *icu;
249 char actname[32]="";
251 /* verifies if active constraint is set and shown in UI */
252 constraint_active_func(ob_v, con_v);
254 /* the context */
255 get_constraint_ipo_context(ob, actname);
257 /* adds ipo & channels & curve if needed */
258 icu= verify_ipocurve((ID *)ob, ID_CO, actname, con->name, CO_ENFORCE);
260 if (!icu) {
261 error("Cannot get a curve from this IPO, may be dealing with linked data");
262 return;
265 if(ob->action)
266 insert_vert_ipo(icu, get_action_frame(ob, (float)CFRA), con->enforce);
267 else
268 insert_vert_ipo(icu, CFRA, con->enforce);
270 /* make sure ipowin shows it */
271 ob->ipowin= ID_CO;
272 allqueue(REDRAWIPO, ID_CO);
273 allspace(REMAKEIPO, 0);
274 allqueue(REDRAWNLA, 0);
276 BIF_undo_push("Insert Influence Key");
279 void del_constr_func (void *ob_v, void *con_v)
281 bConstraint *con= con_v;
282 bConstraintChannel *chan;
283 ListBase *lb;
285 /* remove ipo channel */
286 lb= get_active_constraint_channels(ob_v, 0);
287 if(lb) {
288 chan = get_constraint_channel(lb, con->name);
289 if(chan) {
290 if(chan->ipo) chan->ipo->id.us--;
291 BLI_freelinkN(lb, chan);
294 /* remove constraint itself */
295 lb= get_active_constraints(ob_v);
296 free_constraint_data (con);
297 BLI_freelinkN(lb, con);
299 constraint_active_func(ob_v, NULL);
302 static void del_constraint_func (void *ob_v, void *con_v)
304 del_constr_func (ob_v, con_v);
305 BIF_undo_push("Delete constraint");
306 allqueue(REDRAWBUTSOBJECT, 0);
307 allqueue(REDRAWIPO, 0);
310 static void verify_constraint_name_func (void *con_v, void *name_v)
312 Object *ob= OBACT;
313 bConstraint *con= con_v;
314 char oldname[32];
316 if (!con)
317 return;
319 /* put on the stack */
320 BLI_strncpy(oldname, (char *)name_v, 32);
322 rename_constraint(ob, con, oldname);
324 constraint_active_func(ob, con);
325 allqueue(REDRAWACTION, 0);
328 void get_constraint_typestring (char *str, void *con_v)
330 bConstraint *con= con_v;
332 switch (con->type){
333 case CONSTRAINT_TYPE_PYTHON:
334 strcpy(str, "Script");
335 return;
336 case CONSTRAINT_TYPE_CHILDOF:
337 strcpy (str, "Child Of");
338 return;
339 case CONSTRAINT_TYPE_NULL:
340 strcpy (str, "Null");
341 return;
342 case CONSTRAINT_TYPE_TRACKTO:
343 strcpy (str, "Track To");
344 return;
345 case CONSTRAINT_TYPE_MINMAX:
346 strcpy (str, "Floor");
347 return;
348 case CONSTRAINT_TYPE_KINEMATIC:
349 strcpy (str, "IK Solver");
350 return;
351 case CONSTRAINT_TYPE_ROTLIKE:
352 strcpy (str, "Copy Rotation");
353 return;
354 case CONSTRAINT_TYPE_LOCLIKE:
355 strcpy (str, "Copy Location");
356 return;
357 case CONSTRAINT_TYPE_SIZELIKE:
358 strcpy (str, "Copy Scale");
359 return;
360 case CONSTRAINT_TYPE_ACTION:
361 strcpy (str, "Action");
362 return;
363 case CONSTRAINT_TYPE_LOCKTRACK:
364 strcpy (str, "Locked Track");
365 return;
366 case CONSTRAINT_TYPE_FOLLOWPATH:
367 strcpy (str, "Follow Path");
368 return;
369 case CONSTRAINT_TYPE_STRETCHTO:
370 strcpy (str, "Stretch To");
371 return;
372 case CONSTRAINT_TYPE_LOCLIMIT:
373 strcpy (str, "Limit Location");
374 return;
375 case CONSTRAINT_TYPE_ROTLIMIT:
376 strcpy (str, "Limit Rotation");
377 return;
378 case CONSTRAINT_TYPE_SIZELIMIT:
379 strcpy (str, "Limit Scale");
380 return;
381 case CONSTRAINT_TYPE_RIGIDBODYJOINT:
382 strcpy (str, "Rigid Body");
383 return;
384 case CONSTRAINT_TYPE_CLAMPTO:
385 strcpy (str, "Clamp To");
386 return;
387 default:
388 strcpy (str, "Unknown");
389 return;
393 static int get_constraint_col(bConstraint *con)
395 switch (con->type) {
396 case CONSTRAINT_TYPE_NULL:
397 return TH_BUT_NEUTRAL;
398 case CONSTRAINT_TYPE_KINEMATIC:
399 return TH_BUT_SETTING2;
400 case CONSTRAINT_TYPE_TRACKTO:
401 return TH_BUT_SETTING;
402 case CONSTRAINT_TYPE_ROTLIKE:
403 return TH_BUT_SETTING1;
404 case CONSTRAINT_TYPE_LOCLIKE:
405 return TH_BUT_POPUP;
406 case CONSTRAINT_TYPE_MINMAX:
407 return TH_BUT_POPUP;
408 case CONSTRAINT_TYPE_SIZELIKE:
409 return TH_BUT_POPUP;
410 case CONSTRAINT_TYPE_ACTION:
411 return TH_BUT_ACTION;
412 case CONSTRAINT_TYPE_LOCKTRACK:
413 return TH_BUT_SETTING;
414 case CONSTRAINT_TYPE_FOLLOWPATH:
415 return TH_BUT_SETTING2;
416 case CONSTRAINT_TYPE_STRETCHTO:
417 return TH_BUT_SETTING;
418 case CONSTRAINT_TYPE_LOCLIMIT:
419 return TH_BUT_POPUP;
420 case CONSTRAINT_TYPE_ROTLIMIT:
421 return TH_BUT_POPUP;
422 case CONSTRAINT_TYPE_SIZELIMIT:
423 return TH_BUT_POPUP;
424 case CONSTRAINT_TYPE_RIGIDBODYJOINT:
425 return TH_BUT_SETTING;
426 default:
427 return TH_REDALERT;
431 void const_moveUp(void *ob_v, void *con_v)
433 bConstraint *con, *constr= con_v;
434 ListBase *conlist;
436 if(constr->prev) {
437 conlist = get_active_constraints(ob_v);
438 for(con= conlist->first; con; con= con->next) {
439 if(con==constr) {
440 BLI_remlink(conlist, con);
441 BLI_insertlink(conlist, con->prev->prev, con);
442 break;
448 static void constraint_moveUp(void *ob_v, void *con_v)
450 const_moveUp(ob_v, con_v);
451 BIF_undo_push("Move constraint");
454 void const_moveDown(void *ob_v, void *con_v)
456 bConstraint *con, *constr= con_v;
457 ListBase *conlist;
459 if(constr->next) {
460 conlist = get_active_constraints(ob_v);
461 for(con= conlist->first; con; con= con->next) {
462 if(con==constr) {
463 BLI_remlink(conlist, con);
464 BLI_insertlink(conlist, con->next, con);
465 break;
471 static void constraint_moveDown(void *ob_v, void *con_v)
473 const_moveDown(ob_v, con_v);
474 BIF_undo_push("Move constraint");
477 /* autocomplete callback for buttons */
478 void autocomplete_bone(char *str, void *arg_v)
480 Object *ob= (Object *)arg_v;
482 if(ob==NULL || ob->pose==NULL) return;
484 /* search if str matches the beginning of name */
485 if(str[0]) {
486 AutoComplete *autocpl= autocomplete_begin(str, 32);
487 bPoseChannel *pchan;
489 for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next)
490 autocomplete_do_name(autocpl, pchan->name);
492 autocomplete_end(autocpl, str);
496 /* autocomplete callback for buttons */
497 void autocomplete_vgroup(char *str, void *arg_v)
499 Object *ob= (Object *)arg_v;
501 if(ob==NULL) return;
503 /* search if str matches the beginning of a name */
504 if(str[0]) {
505 AutoComplete *autocpl= autocomplete_begin(str, 32);
506 bDeformGroup *dg;
508 for(dg= ob->defbase.first; dg; dg= dg->next)
509 if(dg->name!=str)
510 autocomplete_do_name(autocpl, dg->name);
512 autocomplete_end(autocpl, str);
516 /* draw panel showing settings for a constraint */
517 static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, short *xco, short *yco)
519 Object *ob= OBACT, *target;
520 uiBut *but;
521 char typestr[64], *subtarget;
522 short height, width = 265, is_armature_target;
523 int curCol, rb_col;
525 target= get_constraint_target(con, &subtarget);
526 is_armature_target= (target && target->type==OB_ARMATURE);
528 /* unless button has own callback, it adds this callback to button */
529 uiBlockSetFunc(block, constraint_active_func, ob, con);
531 get_constraint_typestring (typestr, con);
533 curCol = get_constraint_col(con);
535 /* Draw constraint header */
536 uiBlockSetEmboss(block, UI_EMBOSSN);
538 /* rounded header */
539 rb_col= (con->flag & CONSTRAINT_ACTIVE)?40:20;
540 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-1, width+40, 22, NULL, 5.0, 0.0,
541 (con->flag & CONSTRAINT_EXPAND)?3:15 , rb_col-20, "");
543 /* open/close */
544 uiDefIconButBitS(block, ICONTOG, CONSTRAINT_EXPAND, B_CONSTRAINT_TEST, ICON_DISCLOSURE_TRI_RIGHT, *xco-10, *yco, 20, 20, &con->flag, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Constraint");
546 /* up/down */
547 uiBlockBeginAlign(block);
548 uiBlockSetEmboss(block, UI_EMBOSS);
549 but = uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, VICON_MOVE_UP, *xco+width-50, *yco, 16, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Move constraint up in constraint stack");
550 uiButSetFunc(but, constraint_moveUp, ob, con);
552 but = uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, VICON_MOVE_DOWN, *xco+width-50+18, *yco, 16, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Move constraint down in constraint stack");
553 uiButSetFunc(but, constraint_moveDown, ob, con);
554 uiBlockEndAlign(block);
556 if (con->flag & CONSTRAINT_EXPAND) {
558 if (con->flag & CONSTRAINT_DISABLE) {
559 BIF_ThemeColor(TH_REDALERT);
560 uiBlockSetCol(block, TH_REDALERT);
562 else {
563 BIF_ThemeColor(curCol);
566 /*if (type==TARGET_BONE)
567 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");
568 else
569 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");
571 uiBlockSetEmboss(block, UI_EMBOSS);
573 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+10, *yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
575 but = uiDefBut(block, TEX, B_CONSTRAINT_TEST, "", *xco+120, *yco, 85, 18, con->name, 0.0, 29.0, 0.0, 0.0, "Constraint name");
576 uiButSetFunc(but, verify_constraint_name_func, con, NULL);
578 else {
579 uiBlockSetEmboss(block, UI_EMBOSSN);
581 if (con->flag & CONSTRAINT_DISABLE) {
582 uiBlockSetCol(block, TH_REDALERT);
583 BIF_ThemeColor(TH_REDALERT);
585 else {
586 BIF_ThemeColor(curCol);
589 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+10, *yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
591 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, con->name, *xco+120, *yco-1, 135, 19, NULL, 0.0, 0.0, 0.0, 0.0, "");
594 uiBlockSetCol(block, TH_AUTO);
596 uiBlockSetEmboss(block, UI_EMBOSSN);
598 but = uiDefIconBut(block, BUT, B_CONSTRAINT_CHANGETARGET, ICON_X, *xco+262, *yco, 19, 19, list, 0.0, 0.0, 0.0, 0.0, "Delete constraint");
599 uiButSetFunc(but, del_constraint_func, ob, con);
601 uiBlockSetEmboss(block, UI_EMBOSS);
604 /* Draw constraint data*/
605 if (!(con->flag & CONSTRAINT_EXPAND)) {
606 (*yco)-=21;
608 else {
609 switch (con->type){
610 case CONSTRAINT_TYPE_PYTHON:
612 bPythonConstraint *data = con->data;
613 uiBut *but2;
614 static int pyconindex=0;
615 char *menustr;
617 height = 90;
618 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40, height-1, NULL, 5.0, 0.0, 12, rb_col, "");
620 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Script:", *xco+60, *yco-24, 55, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
622 /* do the scripts menu */
623 menustr = buildmenu_pyconstraints(data->text, &pyconindex);
624 but2 = uiDefButI(block, MENU, B_CONSTRAINT_TEST, menustr,
625 *xco+120, *yco-24, 150, 20, &pyconindex,
626 0.0, 1.0, 0, 0, "Set the Script Constraint to use");
627 uiButSetFunc(but2, validate_pyconstraint_cb, data, &pyconindex);
628 MEM_freeN(menustr);
630 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+60, *yco-48, 55, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
631 if (data->flag & PYCON_USETARGETS) {
632 /* Draw target parameters */
633 uiBlockBeginAlign(block);
634 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-48, 150, 18, &data->tar, "Target Object");
636 if (is_armature_target) {
637 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-66,150,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
638 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
640 else {
641 strcpy (data->subtarget, "");
644 uiBlockEndAlign(block);
646 else {
647 /* Draw indication that no target needed */
648 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Not Applicable", *xco+120, *yco-48, 150, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
651 /* settings */
652 uiBlockBeginAlign(block);
653 but=uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Options", *xco, *yco-88, (width/2),18, NULL, 0, 24, 0, 0, "Change some of the constraint's settings.");
654 uiButSetFunc(but, BPY_pyconstraint_settings, data, NULL);
656 uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Refresh", *xco+((width/2)+10), *yco-88, (width/2),18, NULL, 0, 24, 0, 0, "Force constraint to refresh it's settings");
657 uiBlockEndAlign(block);
659 break;
660 case CONSTRAINT_TYPE_ACTION:
662 bActionConstraint *data = con->data;
664 height = 88;
665 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
667 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
669 /* Draw target parameters */
670 uiBlockBeginAlign(block);
671 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
673 if (is_armature_target){
674 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
675 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
677 else {
678 strcpy (data->subtarget, "");
681 uiBlockEndAlign(block);
683 /* Draw action button */
684 uiBlockBeginAlign(block);
685 uiDefButS(block, TOG, B_CONSTRAINT_TEST, "Local", *xco+((width/2)-117), *yco-46, 78, 18, &data->local, 0, 0, 0, 0, "Use true local rotation difference");
686 uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, B_CONSTRAINT_TEST, "AC:", *xco+((width/2)-117), *yco-64, 78, 18, &data->act, "Action containing the keyed motion for this bone");
687 uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Key on%t|X Rot%x0|Y Rot%x1|Z Rot%x2", *xco+((width/2)-117), *yco-84, 78, 18, &data->type, 0, 24, 0, 0, "Specify which transformation channel from the target is used to key the action");
689 uiBlockBeginAlign(block);
690 uiDefButI(block, NUM, B_CONSTRAINT_TEST, "Start:", *xco+((width/2)-36), *yco-64, 78, 18, &data->start, 1, MAXFRAME, 0.0, 0.0, "Starting frame of the keyed motion");
691 uiDefButI(block, NUM, B_CONSTRAINT_TEST, "End:", *xco+((width/2)-36), *yco-84, 78, 18, &data->end, 1, MAXFRAME, 0.0, 0.0, "Ending frame of the keyed motion");
693 uiBlockBeginAlign(block);
694 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Min:", *xco+((width/2)+45), *yco-64, 78, 18, &data->min, -180, 180, 0, 0, "Minimum value for target channel range");
695 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Max:", *xco+((width/2)+45), *yco-84, 78, 18, &data->max, -180, 180, 0, 0, "Maximum value for target channel range");
696 uiBlockEndAlign(block);
698 break;
699 case CONSTRAINT_TYPE_LOCLIKE:
701 bLocateLikeConstraint *data = con->data;
703 height = 91;
704 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
706 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
708 /* Draw target parameters */
709 uiBlockBeginAlign(block);
710 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
712 if (is_armature_target) {
713 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
714 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
716 else {
717 strcpy (data->subtarget, "");
720 uiBlockEndAlign(block);
722 /* Draw XYZ toggles */
723 uiBlockBeginAlign(block);
724 but=uiDefButBitI(block, TOG, LOCLIKE_X, B_CONSTRAINT_TEST, "X", *xco+((width/2)-48), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy X component");
725 but=uiDefButBitI(block, TOG, LOCLIKE_X_INVERT, B_CONSTRAINT_TEST, "-", *xco+((width/2)-16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Invert X component");
726 but=uiDefButBitI(block, TOG, LOCLIKE_Y, B_CONSTRAINT_TEST, "Y", *xco+((width/2)+16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Y component");
727 but=uiDefButBitI(block, TOG, LOCLIKE_Y_INVERT, B_CONSTRAINT_TEST, "-", *xco+((width/2)+48), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Invert Y component");
728 but=uiDefButBitI(block, TOG, LOCLIKE_Z, B_CONSTRAINT_TEST, "Z", *xco+((width/2)+96), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Z component");
729 but=uiDefButBitI(block, TOG, LOCLIKE_Z_INVERT, B_CONSTRAINT_TEST, "-", *xco+((width/2)+128), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Invert Z component");
730 uiBlockEndAlign(block);
732 /* Draw options */
733 uiDefButBitI(block, TOG, LOCLIKE_OFFSET, B_CONSTRAINT_TEST, "Offset", *xco+(width/3), *yco-89, (width/3), 18, &data->flag, 0, 24, 0, 0, "Add original location onto copied location");
734 if (is_armature_target) {
735 uiDefButBitS(block, TOG, CONSTRAINT_LOCAL, B_CONSTRAINT_TEST, "Local", *xco, *yco-89, (width/3), 18, &con->flag, 0, 24, 0, 0, "Work on a Pose's local transform");
736 uiDefButBitI(block, TOG, LOCLIKE_TIP, B_CONSTRAINT_TEST, "Target Bone Tip", *xco+(width/3*2), *yco-89, (width/3), 18, &data->flag, 0, 24, 0, 0, "Copy Location of Target Bone's Tip");
739 break;
740 case CONSTRAINT_TYPE_ROTLIKE:
742 bRotateLikeConstraint *data = con->data;
744 height = 91;
745 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
747 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
749 /* Draw target parameters */
750 uiBlockBeginAlign(block);
751 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
753 if (is_armature_target) {
754 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
755 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
757 else {
758 strcpy (data->subtarget, "");
761 uiBlockEndAlign(block);
763 /* Draw XYZ toggles */
764 uiBlockBeginAlign(block);
765 if (is_armature_target)
766 uiDefButBitS(block, TOG, CONSTRAINT_LOCAL, B_CONSTRAINT_TEST, "Local", *xco+((width/2)-98), *yco-64, 50, 18, &con->flag, 0, 24, 0, 0, "Work on a Pose's local transform");
767 but=uiDefButBitI(block, TOG, ROTLIKE_X, B_CONSTRAINT_TEST, "X", *xco+((width/2)-48), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy X component");
768 but=uiDefButBitI(block, TOG, ROTLIKE_X_INVERT, B_CONSTRAINT_TEST, "-", *xco+((width/2)-16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Invert X component");
769 but=uiDefButBitI(block, TOG, ROTLIKE_Y, B_CONSTRAINT_TEST, "Y", *xco+((width/2)+16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Y component");
770 but=uiDefButBitI(block, TOG, ROTLIKE_Y_INVERT, B_CONSTRAINT_TEST, "-", *xco+((width/2)+48), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Invert Y component");
771 but=uiDefButBitI(block, TOG, ROTLIKE_Z, B_CONSTRAINT_TEST, "Z", *xco+((width/2)+96), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Z component");
772 but=uiDefButBitI(block, TOG, ROTLIKE_Z_INVERT, B_CONSTRAINT_TEST, "-", *xco+((width/2)+128), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Invert Z component");
773 uiBlockEndAlign(block);
775 break;
776 case CONSTRAINT_TYPE_SIZELIKE:
778 bSizeLikeConstraint *data = con->data;
779 height = 91;
781 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
783 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
785 /* Draw target parameters */
786 uiBlockBeginAlign(block);
787 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
789 if (is_armature_target) {
790 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
791 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
793 else {
794 strcpy (data->subtarget, "");
797 uiBlockEndAlign(block);
799 /* Draw XYZ toggles */
800 uiBlockBeginAlign(block);
801 if (is_armature_target)
802 uiDefButBitS(block, TOG, CONSTRAINT_LOCAL, B_CONSTRAINT_TEST, "Local", *xco+((width/2)-98), *yco-64, 50, 18, &con->flag, 0, 24, 0, 0, "Work on a Pose's local transform");
803 but=uiDefButBitI(block, TOG, SIZELIKE_X, B_CONSTRAINT_TEST, "X", *xco+((width/2)-48), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy X component");
804 but=uiDefButBitI(block, TOG, SIZELIKE_Y, B_CONSTRAINT_TEST, "Y", *xco+((width/2)-16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Y component");
805 but=uiDefButBitI(block, TOG, SIZELIKE_Z, B_CONSTRAINT_TEST, "Z", *xco+((width/2)+16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Z component");
806 uiBlockEndAlign(block);
808 break;
809 case CONSTRAINT_TYPE_KINEMATIC:
811 bKinematicConstraint *data = con->data;
813 height = 111;
814 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
816 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
818 /* Draw target parameters */
819 uiDefButBitS(block, TOG, CONSTRAINT_IK_ROT, B_CONSTRAINT_TEST, "Rot", *xco, *yco-24,60,19, &data->flag, 0, 0, 0, 0, "Chain follows rotation of target");
821 uiBlockBeginAlign(block);
822 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 19, &data->tar, "Target Object");
824 if (is_armature_target) {
825 but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,19, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
826 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
828 else {
829 strcpy (data->subtarget, "");
832 uiBlockBeginAlign(block);
833 uiDefButBitS(block, TOG, CONSTRAINT_IK_TIP, B_CONSTRAINT_TEST, "Use Tip", *xco, *yco-64, 137, 19, &data->flag, 0, 0, 0, 0, "Include Bone's tip als last element in Chain");
834 uiDefButI(block, NUM, B_CONSTRAINT_TEST, "ChainLen:", *xco, *yco-84,137,19, &data->rootbone, 0, 255, 0, 0, "If not zero, the amount of bones in this chain");
836 uiBlockBeginAlign(block);
837 uiDefButF(block, NUMSLI, B_CONSTRAINT_TEST, "PosW ", *xco+147, *yco-64, 137, 19, &data->weight, 0.01, 1.0, 2, 2, "For Tree-IK: weight of position control for this target");
838 uiDefButF(block, NUMSLI, B_CONSTRAINT_TEST, "RotW ", *xco+147, *yco-84, 137, 19, &data->orientweight, 0.01, 1.0, 2, 2, "For Tree-IK: Weight of orientation control for this target");
840 uiBlockBeginAlign(block);
841 uiDefButS(block, NUM, B_CONSTRAINT_TEST, "Iterations:", *xco, *yco-109, 137, 19, &data->iterations, 1, 10000, 0, 0, "Maximum number of solving iterations");
842 uiBlockBeginAlign(block);
843 uiDefButBitS(block, TOG, CONSTRAINT_IK_STRETCH, B_CONSTRAINT_TEST, "Stretch", *xco+147, *yco-109,137,19, &data->flag, 0, 0, 0, 0, "Enable IK stretching");
846 break;
847 case CONSTRAINT_TYPE_TRACKTO:
849 bTrackToConstraint *data = con->data;
851 height = 66;
852 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
854 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
856 /* Draw target parameters */
857 uiBlockBeginAlign(block);
858 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
860 if (is_armature_target) {
861 but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
862 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
864 else {
865 strcpy (data->subtarget, "");
868 uiBlockEndAlign(block);
870 uiBlockBeginAlign(block);
871 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Align:", *xco+5, *yco-42, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
873 uiDefButBitI(block, TOG, 1, B_CONSTRAINT_TEST, "TargetZ", *xco+60, *yco-42, 50, 18, &data->flags, 0, 1, 0, 0, "Target Z axis, not world Z axis, will constrain up direction");
874 uiBlockEndAlign(block);
876 uiBlockBeginAlign(block);
877 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "To:", *xco+12, *yco-64, 25, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
879 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X", *xco+39, *yco-64,17,18, &data->reserved1, 12.0, 0.0, 0, 0, "X axis points to the target object");
880 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y", *xco+56, *yco-64,17,18, &data->reserved1, 12.0, 1.0, 0, 0, "Y axis points to the target object");
881 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z", *xco+73, *yco-64,17,18, &data->reserved1, 12.0, 2.0, 0, 0, "Z axis points to the target object");
882 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-X", *xco+90, *yco-64,24,18, &data->reserved1, 12.0, 3.0, 0, 0, "-X axis points to the target object");
883 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Y", *xco+114, *yco-64,24,18, &data->reserved1, 12.0, 4.0, 0, 0, "-Y axis points to the target object");
884 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Z", *xco+138, *yco-64,24,18, &data->reserved1, 12.0, 5.0, 0, 0, "-Z axis points to the target object");
885 uiBlockEndAlign(block);
887 uiBlockBeginAlign(block);
888 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Up:", *xco+174, *yco-64, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
890 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X", *xco+204, *yco-64,17,18, &data->reserved2, 13.0, 0.0, 0, 0, "X axis points upward");
891 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y", *xco+221, *yco-64,17,18, &data->reserved2, 13.0, 1.0, 0, 0, "Y axis points upward");
892 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z", *xco+238, *yco-64,17,18, &data->reserved2, 13.0, 2.0, 0, 0, "Z axis points upward");
893 uiBlockEndAlign(block);
895 break;
896 case CONSTRAINT_TYPE_MINMAX:
898 bMinMaxConstraint *data = con->data;
900 height = 66;
901 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
903 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
905 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Offset:", *xco, *yco-44, 100, 18, &data->offset, -100, 100, 100.0, 0.0, "Offset from the position of the object center");
907 /* Draw target parameters */
908 uiBlockBeginAlign(block);
909 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
911 if (is_armature_target) {
912 but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
913 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
915 else {
916 strcpy (data->subtarget, "");
919 uiBlockEndAlign(block);
921 but=uiDefButI(block, TOG|BIT|0, B_CONSTRAINT_TEST, "Sticky", *xco, *yco-24, 44, 18, &data->flag, 0, 24, 0, 0, "Immobilize object while constrained");
922 but=uiDefButI(block, TOG|BIT|2, B_CONSTRAINT_TEST, "Use Rot", *xco+44, *yco-24, 64, 18, &data->flag, 0, 24, 0, 0, "Use target object rotation");
924 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Max/Min:", *xco-8, *yco-64, 54, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
926 uiBlockBeginAlign(block);
927 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X", *xco+51, *yco-64,17,18, &data->minmaxflag, 12.0, 0.0, 0, 0, "Will not pass below X of target");
928 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y", *xco+67, *yco-64,17,18, &data->minmaxflag, 12.0, 1.0, 0, 0, "Will not pass below Y of target");
929 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z", *xco+85, *yco-64,17,18, &data->minmaxflag, 12.0, 2.0, 0, 0, "Will not pass below Z of target");
930 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-X", *xco+102, *yco-64,24,18, &data->minmaxflag, 12.0, 3.0, 0, 0, "Will not pass above X of target");
931 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Y", *xco+126, *yco-64,24,18, &data->minmaxflag, 12.0, 4.0, 0, 0, "Will not pass above Y of target");
932 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Z", *xco+150, *yco-64,24,18, &data->minmaxflag, 12.0, 5.0, 0, 0, "Will not pass above Z of target");
933 uiBlockEndAlign(block);
935 break;
936 case CONSTRAINT_TYPE_LOCKTRACK:
938 bLockTrackConstraint *data = con->data;
939 height = 66;
940 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
942 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
944 /* Draw target parameters */
945 uiBlockBeginAlign(block);
946 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
948 if (is_armature_target) {
949 but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
950 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
952 else {
953 strcpy (data->subtarget, "");
956 uiBlockEndAlign(block);
958 uiBlockBeginAlign(block);
959 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "To:", *xco+12, *yco-64, 25, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
961 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X", *xco+39, *yco-64,17,18, &data->trackflag, 12.0, 0.0, 0, 0, "X axis points to the target object");
962 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y", *xco+56, *yco-64,17,18, &data->trackflag, 12.0, 1.0, 0, 0, "Y axis points to the target object");
963 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z", *xco+73, *yco-64,17,18, &data->trackflag, 12.0, 2.0, 0, 0, "Z axis points to the target object");
964 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-X", *xco+90, *yco-64,24,18, &data->trackflag, 12.0, 3.0, 0, 0, "-X axis points to the target object");
965 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Y", *xco+114, *yco-64,24,18, &data->trackflag, 12.0, 4.0, 0, 0, "-Y axis points to the target object");
966 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Z", *xco+138, *yco-64,24,18, &data->trackflag, 12.0, 5.0, 0, 0, "-Z axis points to the target object");
967 uiBlockEndAlign(block);
969 uiBlockBeginAlign(block);
970 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Lock:", *xco+166, *yco-64, 38, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
972 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X", *xco+204, *yco-64,17,18, &data->lockflag, 13.0, 0.0, 0, 0, "X axis is locked");
973 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y", *xco+221, *yco-64,17,18, &data->lockflag, 13.0, 1.0, 0, 0, "Y axis is locked");
974 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z", *xco+238, *yco-64,17,18, &data->lockflag, 13.0, 2.0, 0, 0, "Z axis is locked");
975 uiBlockEndAlign(block);
977 break;
978 case CONSTRAINT_TYPE_FOLLOWPATH:
980 bFollowPathConstraint *data = con->data;
982 height = 66;
983 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
985 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
987 /* Draw target parameters */
988 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
990 /* Draw Curve Follow toggle */
991 but=uiDefButBitI(block, TOG, 1, B_CONSTRAINT_TEST, "CurveFollow", *xco+39, *yco-44, 100, 18, &data->followflag, 0, 24, 0, 0, "Object will follow the heading and banking of the curve");
993 /* Draw Offset number button */
994 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Offset:", *xco+155, *yco-44, 100, 18, &data->offset, -MAXFRAMEF, MAXFRAMEF, 100.0, 0.0, "Offset from the position corresponding to the time frame");
996 uiBlockBeginAlign(block);
997 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Fw:", *xco+12, *yco-64, 27, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
999 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X", *xco+39, *yco-64,17,18, &data->trackflag, 12.0, 0.0, 0, 0, "The axis that points forward along the path");
1000 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y", *xco+56, *yco-64,17,18, &data->trackflag, 12.0, 1.0, 0, 0, "The axis that points forward along the path");
1001 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z", *xco+73, *yco-64,17,18, &data->trackflag, 12.0, 2.0, 0, 0, "The axis that points forward along the path");
1002 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-X", *xco+90, *yco-64,24,18, &data->trackflag, 12.0, 3.0, 0, 0, "The axis that points forward along the path");
1003 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Y", *xco+114, *yco-64,24,18, &data->trackflag, 12.0, 4.0, 0, 0, "The axis that points forward along the path");
1004 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"-Z", *xco+138, *yco-64,24,18, &data->trackflag, 12.0, 5.0, 0, 0, "The axis that points forward along the path");
1005 uiBlockEndAlign(block);
1007 uiBlockBeginAlign(block);
1008 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Up:", *xco+174, *yco-64, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1010 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X", *xco+204, *yco-64,17,18, &data->upflag, 13.0, 0.0, 0, 0, "The axis that points upward");
1011 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Y", *xco+221, *yco-64,17,18, &data->upflag, 13.0, 1.0, 0, 0, "The axis that points upward");
1012 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z", *xco+238, *yco-64,17,18, &data->upflag, 13.0, 2.0, 0, 0, "The axis that points upward");
1013 uiBlockEndAlign(block);
1015 break;
1016 case CONSTRAINT_TYPE_STRETCHTO:
1018 bStretchToConstraint *data = con->data;
1020 height = 105;
1021 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1023 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1025 /* Draw target parameters */
1026 uiBlockBeginAlign(block);
1027 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
1029 if (is_armature_target) {
1030 but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
1031 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1033 else {
1034 strcpy (data->subtarget, "");
1037 uiBlockEndAlign(block);
1040 uiBlockBeginAlign(block);
1041 uiDefButF(block,BUTM,B_CONSTRAINT_TEST,"R",*xco, *yco-60,20,18,&(data->orglength),0.0,0,0,0,"Recalculate RLength");
1042 uiDefButF(block,NUM,B_CONSTRAINT_TEST,"Rest Length:",*xco+18, *yco-60,237,18,&(data->orglength),0.0,100,0.5,0.5,"Length at Rest Position");
1043 uiBlockEndAlign(block);
1045 uiDefButF(block,NUM,B_CONSTRAINT_TEST,"Volume Variation:",*xco+18, *yco-82,237,18,&(data->bulge),0.0,100,0.5,0.5,"Factor between volume variation and stretching");
1047 uiBlockBeginAlign(block);
1048 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Vol:",*xco+14, *yco-104,30,18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1049 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"XZ", *xco+44, *yco-104,30,18, &data->volmode, 12.0, 0.0, 0, 0, "Keep Volume: Scaling X & Z");
1050 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X", *xco+74, *yco-104,20,18, &data->volmode, 12.0, 1.0, 0, 0, "Keep Volume: Scaling X");
1051 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z", *xco+94, *yco-104,20,18, &data->volmode, 12.0, 2.0, 0, 0, "Keep Volume: Scaling Z");
1052 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"NONE", *xco+114, *yco-104,50,18, &data->volmode, 12.0, 3.0, 0, 0, "Ignore Volume");
1053 uiBlockEndAlign(block);
1056 uiBlockBeginAlign(block);
1057 uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"Plane:",*xco+175, *yco-104,40,18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1058 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X", *xco+215, *yco-104,20,18, &data->plane, 12.0, 0.0, 0, 0, "Keep X axis");
1059 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z", *xco+235, *yco-104,20,18, &data->plane, 12.0, 2.0, 0, 0, "Keep Z axis");
1060 uiBlockEndAlign(block);
1062 break;
1063 case CONSTRAINT_TYPE_LOCLIMIT:
1065 bLocLimitConstraint *data = con->data;
1067 int togButWidth = 50;
1068 int textButWidth = ((width/2)-togButWidth);
1070 height = 106;
1071 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1073 /* Draw Pairs of LimitToggle+LimitValue */
1074 uiBlockBeginAlign(block);
1075 uiDefButBitS(block, TOG, LIMIT_XMIN, B_CONSTRAINT_TEST, "minX", *xco, *yco-28, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x value");
1076 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-28, (textButWidth-5), 18, &(data->xmin), -1000, 1000, 0.1,0.5,"Lowest x value to allow");
1077 uiBlockEndAlign(block);
1079 uiBlockBeginAlign(block);
1080 uiDefButBitS(block, TOG, LIMIT_XMAX, B_CONSTRAINT_TEST, "maxX", *xco+(width-(textButWidth-5)-togButWidth), *yco-28, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum x value");
1081 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-28, (textButWidth-5), 18, &(data->xmax), -1000, 1000, 0.1,0.5,"Highest x value to allow");
1082 uiBlockEndAlign(block);
1084 uiBlockBeginAlign(block);
1085 uiDefButBitS(block, TOG, LIMIT_YMIN, B_CONSTRAINT_TEST, "minY", *xco, *yco-50, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y value");
1086 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-50, (textButWidth-5), 18, &(data->ymin), -1000, 1000, 0.1,0.5,"Lowest y value to allow");
1087 uiBlockEndAlign(block);
1089 uiBlockBeginAlign(block);
1090 uiDefButBitS(block, TOG, LIMIT_YMAX, B_CONSTRAINT_TEST, "maxY", *xco+(width-(textButWidth-5)-togButWidth), *yco-50, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum y value");
1091 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-50, (textButWidth-5), 18, &(data->ymax), -1000, 1000, 0.1,0.5,"Highest y value to allow");
1092 uiBlockEndAlign(block);
1094 uiBlockBeginAlign(block);
1095 uiDefButBitS(block, TOG, LIMIT_ZMIN, B_CONSTRAINT_TEST, "minZ", *xco, *yco-72, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z value");
1096 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-72, (textButWidth-5), 18, &(data->zmin), -1000, 1000, 0.1,0.5,"Lowest z value to allow");
1097 uiBlockEndAlign(block);
1099 uiBlockBeginAlign(block);
1100 uiDefButBitS(block, TOG, LIMIT_ZMAX, B_CONSTRAINT_TEST, "maxZ", *xco+(width-(textButWidth-5)-togButWidth), *yco-72, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum z value");
1101 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-72, (textButWidth-5), 18, &(data->zmax), -1000, 1000, 0.1,0.5,"Highest z value to allow");
1102 uiBlockEndAlign(block);
1104 uiBlockBeginAlign(block);
1105 uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"Co-ordinate Space:",*xco, *yco-100,150,18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1107 if (ob->type == OB_ARMATURE && (ob->flag & OB_POSEMODE))
1108 uiDefButBitS(block, TOG, CONSTRAINT_LOCAL, B_CONSTRAINT_TEST, "Local", *xco+160, *yco-100, 60, 18, &con->flag, 0, 24, 0, 0, "Limit locations relative to the bone's rest-position");
1109 else if (ob->parent != NULL)
1110 uiDefButBitS(block, TOG, LIMIT_NOPARENT, B_CONSTRAINT_TEST, "Local", *xco+160, *yco-100, 60, 18, &data->flag2, 0, 24, 0, 0, "Limit locations relative to parent, not origin/world");
1111 else
1112 uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"World",*xco+160, *yco-100,60,18, NULL, 0.0, 0.0, 0.0, 0.0, "Limit locations relative to origin/world");
1114 uiBlockEndAlign(block);
1116 break;
1117 case CONSTRAINT_TYPE_ROTLIMIT:
1119 bRotLimitConstraint *data = con->data;
1120 int normButWidth = (width/3);
1122 if (ob->type == OB_ARMATURE && (ob->flag & OB_POSEMODE))
1123 height = 106;
1124 else
1125 height = 78;
1127 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1129 /* Draw Pairs of LimitToggle+LimitValue */
1130 uiBlockBeginAlign(block);
1131 uiDefButBitS(block, TOG, LIMIT_XROT, B_CONSTRAINT_TEST, "LimitX", *xco, *yco-28, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Limit rotation on x-axis");
1132 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min:", *xco+normButWidth, *yco-28, normButWidth, 18, &(data->xmin), -360, 360, 0.1,0.5,"Lowest x value to allow");
1133 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max:", *xco+(normButWidth * 2), *yco-28, normButWidth, 18, &(data->xmax), -360, 360, 0.1,0.5,"Highest x value to allow");
1134 uiBlockEndAlign(block);
1136 uiBlockBeginAlign(block);
1137 uiDefButBitS(block, TOG, LIMIT_YROT, B_CONSTRAINT_TEST, "LimitY", *xco, *yco-50, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Limit rotation on y-axis");
1138 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min:", *xco+normButWidth, *yco-50, normButWidth, 18, &(data->ymin), -360, 360, 0.1,0.5,"Lowest y value to allow");
1139 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max:", *xco+(normButWidth * 2), *yco-50, normButWidth, 18, &(data->ymax), -360, 360, 0.1,0.5,"Highest y value to allow");
1140 uiBlockEndAlign(block);
1142 uiBlockBeginAlign(block);
1143 uiDefButBitS(block, TOG, LIMIT_ZROT, B_CONSTRAINT_TEST, "LimitZ", *xco, *yco-72, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Limit rotation on z-axis");
1144 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min:", *xco+normButWidth, *yco-72, normButWidth, 18, &(data->zmin), -360, 360, 0.1,0.5,"Lowest z value to allow");
1145 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max:", *xco+(normButWidth * 2), *yco-72, normButWidth, 18, &(data->zmax), -360, 360, 0.1,0.5,"Highest z value to allow");
1146 uiBlockEndAlign(block);
1148 if (ob->type == OB_ARMATURE && (ob->flag & OB_POSEMODE)) {
1149 uiBlockBeginAlign(block);
1150 uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"Co-ordinate Space:",*xco, *yco-100,150,18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1151 uiDefButBitS(block, TOG, CONSTRAINT_LOCAL, B_CONSTRAINT_TEST, "Local", *xco+160, *yco-100, 60, 18, &con->flag, 0, 24, 0, 0, "Work on a Pose's local transform");
1152 uiBlockEndAlign(block);
1155 break;
1156 case CONSTRAINT_TYPE_SIZELIMIT:
1158 bSizeLimitConstraint *data = con->data;
1160 int togButWidth = 50;
1161 int textButWidth = ((width/2)-togButWidth);
1163 if (ob->type == OB_ARMATURE && (ob->flag & OB_POSEMODE))
1164 height = 106;
1165 else
1166 height = 78;
1168 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1170 /* Draw Pairs of LimitToggle+LimitValue */
1171 uiBlockBeginAlign(block);
1172 uiDefButBitS(block, TOG, LIMIT_XMIN, B_CONSTRAINT_TEST, "minX", *xco, *yco-28, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x value");
1173 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-28, (textButWidth-5), 18, &(data->xmin), 0.0001, 1000, 0.1,0.5,"Lowest x value to allow");
1174 uiBlockEndAlign(block);
1176 uiBlockBeginAlign(block);
1177 uiDefButBitS(block, TOG, LIMIT_XMAX, B_CONSTRAINT_TEST, "maxX", *xco+(width-(textButWidth-5)-togButWidth), *yco-28, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum x value");
1178 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-28, (textButWidth-5), 18, &(data->xmax), 0.0001, 1000, 0.1,0.5,"Highest x value to allow");
1179 uiBlockEndAlign(block);
1182 uiBlockBeginAlign(block);
1183 uiDefButBitS(block, TOG, LIMIT_YMIN, B_CONSTRAINT_TEST, "minY", *xco, *yco-50, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y value");
1184 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-50, (textButWidth-5), 18, &(data->ymin), 0.0001, 1000, 0.1,0.5,"Lowest y value to allow");
1185 uiBlockEndAlign(block);
1187 uiBlockBeginAlign(block);
1188 uiDefButBitS(block, TOG, LIMIT_YMAX, B_CONSTRAINT_TEST, "maxY", *xco+(width-(textButWidth-5)-togButWidth), *yco-50, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum y value");
1189 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-50, (textButWidth-5), 18, &(data->ymax), 0.0001, 1000, 0.1,0.5,"Highest y value to allow");
1190 uiBlockEndAlign(block);
1193 uiBlockBeginAlign(block);
1194 uiDefButBitS(block, TOG, LIMIT_ZMIN, B_CONSTRAINT_TEST, "minZ", *xco, *yco-72, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z value");
1195 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-72, (textButWidth-5), 18, &(data->zmin), 0.0001, 1000, 0.1,0.5,"Lowest z value to allow");
1196 uiBlockEndAlign(block);
1198 uiBlockBeginAlign(block);
1199 uiDefButBitS(block, TOG, LIMIT_ZMAX, B_CONSTRAINT_TEST, "maxZ", *xco+(width-(textButWidth-5)-togButWidth), *yco-72, 50, 18, &data->flag, 0, 24, 0, 0, "Use maximum z value");
1200 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-72, (textButWidth-5), 18, &(data->zmax), 0.0001, 1000, 0.1,0.5,"Highest z value to allow");
1201 uiBlockEndAlign(block);
1203 if (ob->type == OB_ARMATURE && (ob->flag & OB_POSEMODE)) {
1204 uiBlockBeginAlign(block);
1205 uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"Co-ordinate Space:",*xco, *yco-100,150,18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1206 uiDefButBitS(block, TOG, CONSTRAINT_LOCAL, B_CONSTRAINT_TEST, "Local", *xco+160, *yco-100, 60, 18, &con->flag, 0, 24, 0, 0, "Work on a Pose's local transform");
1207 uiBlockEndAlign(block);
1210 break;
1211 case CONSTRAINT_TYPE_RIGIDBODYJOINT:
1213 bRigidBodyJointConstraint *data = con->data;
1214 float extremeLin = 999.f;
1215 float extremeAngX = 180.f;
1216 float extremeAngY = 45.f;
1217 float extremeAngZ = 45.f;
1218 int togButWidth = 70;
1219 int offsetY = 150;
1220 int textButWidth = ((width/2)-togButWidth);
1222 uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Generic (experimental)%x12",//|Extra Force%x6",
1223 *xco, *yco-25, 150, 18, &data->type, 0, 0, 0, 0, "Choose the joint type");
1224 height = 140;
1225 if (data->type==CONSTRAINT_RB_GENERIC6DOF)
1226 height = 270;
1228 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1230 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "toObject:", *xco, *yco-50, 130, 18, &data->tar, "Child Object");
1231 uiDefButBitS(block, TOG, CONSTRAINT_DRAW_PIVOT, B_CONSTRAINT_TEST, "ShowPivot", *xco+135, *yco-50, 130, 18, &data->flag, 0, 24, 0, 0, "Show pivot position and rotation");
1233 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot X:", *xco, *yco-75, 130, 18, &data->pivX, -1000, 1000, 100, 0.0, "Offset pivot on X");
1234 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Y:", *xco, *yco-100, 130, 18, &data->pivY, -1000, 1000, 100, 0.0, "Offset pivot on Y");
1235 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Z:", *xco, *yco-125, 130, 18, &data->pivZ, -1000, 1000, 100, 0.0, "Offset pivot on z");
1237 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax X:", *xco+135, *yco-75, 130, 18, &data->axX, -360, 360, 1500, 0.0, "Rotate pivot on X Axis (in degrees)");
1238 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax Y:", *xco+135, *yco-100, 130, 18, &data->axY, -360, 360, 1500, 0.0, "Rotate pivot on Y Axis (in degrees)");
1239 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax Z:", *xco+135, *yco-125, 130, 18, &data->axZ, -360, 360, 1500, 0.0, "Rotate pivot on Z Axis (in degrees)");
1241 if (data->type==CONSTRAINT_RB_GENERIC6DOF){
1242 /* Draw Pairs of LimitToggle+LimitValue */
1243 uiBlockBeginAlign(block);
1244 uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "LinMinX", *xco, *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit");
1245 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-offsetY, (textButWidth-5), 18, &(data->minLimit[0]), -extremeLin, extremeLin, 0.1,0.5,"min x limit");
1247 uiBlockBeginAlign(block);
1248 uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "LinMaxX", *xco+(width-(textButWidth-5)-togButWidth), *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum x limit");
1249 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-offsetY, (textButWidth), 18, &(data->maxLimit[0]), -extremeLin, extremeLin, 0.1,0.5,"max x limit");
1251 offsetY += 20;
1252 uiBlockBeginAlign(block);
1253 uiDefButBitS(block, TOG, 2, B_CONSTRAINT_TEST, "LinMinY", *xco, *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y limit");
1254 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-offsetY, (textButWidth-5), 18, &(data->minLimit[1]), -extremeLin, extremeLin, 0.1,0.5,"min y limit");
1256 uiBlockBeginAlign(block);
1257 uiDefButBitS(block, TOG, 2, B_CONSTRAINT_TEST, "LinMaxY", *xco+(width-(textButWidth-5)-togButWidth), *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum y limit");
1258 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-offsetY, (textButWidth), 18, &(data->maxLimit[1]), -extremeLin, extremeLin, 0.1,0.5,"max y limit");
1260 offsetY += 20;
1261 uiBlockBeginAlign(block);
1262 uiDefButBitS(block, TOG, 4, B_CONSTRAINT_TEST, "LinMinZ", *xco, *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z limit");
1263 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-offsetY, (textButWidth-5), 18, &(data->minLimit[2]), -extremeLin, extremeLin, 0.1,0.5,"min z limit");
1265 uiBlockBeginAlign(block);
1266 uiDefButBitS(block, TOG, 4, B_CONSTRAINT_TEST, "LinMaxZ", *xco+(width-(textButWidth-5)-togButWidth), *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum z limit");
1267 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-offsetY, (textButWidth), 18, &(data->maxLimit[2]), -extremeLin, extremeLin, 0.1,0.5,"max z limit");
1268 offsetY += 20;
1270 /* Draw Pairs of LimitToggle+LimitValue */
1271 uiBlockBeginAlign(block);
1272 uiDefButBitS(block, TOG, 8, B_CONSTRAINT_TEST, "AngMinX", *xco, *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit");
1273 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-offsetY, (textButWidth-5), 18, &(data->minLimit[3]), -extremeAngX, extremeAngX, 0.1,0.5,"min x limit");
1274 uiBlockBeginAlign(block);
1275 uiDefButBitS(block, TOG, 8, B_CONSTRAINT_TEST, "AngMaxX", *xco+(width-(textButWidth-5)-togButWidth), *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum x limit");
1276 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-offsetY, (textButWidth), 18, &(data->maxLimit[3]), -extremeAngX, extremeAngX, 0.1,0.5,"max x limit");
1278 offsetY += 20;
1279 uiBlockBeginAlign(block);
1280 uiDefButBitS(block, TOG, 16, B_CONSTRAINT_TEST, "AngMinY", *xco, *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y limit");
1281 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-offsetY, (textButWidth-5), 18, &(data->minLimit[4]), -extremeAngY, extremeAngY, 0.1,0.5,"min y limit");
1283 uiBlockBeginAlign(block);
1284 uiDefButBitS(block, TOG, 16, B_CONSTRAINT_TEST, "AngMaxY", *xco+(width-(textButWidth-5)-togButWidth), *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum y limit");
1285 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-offsetY, (textButWidth), 18, &(data->maxLimit[4]), -extremeAngY, extremeAngY, 0.1,0.5,"max y limit");
1287 offsetY += 20;
1288 uiBlockBeginAlign(block);
1289 uiDefButBitS(block, TOG, 32, B_CONSTRAINT_TEST, "AngMinZ", *xco, *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z limit");
1290 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+togButWidth, *yco-offsetY, (textButWidth-5), 18, &(data->minLimit[5]), -extremeAngZ, extremeAngZ, 0.1,0.5,"min z limit");
1292 uiBlockBeginAlign(block);
1293 uiDefButBitS(block, TOG, 32, B_CONSTRAINT_TEST, "AngMaxZ", *xco+(width-(textButWidth-5)-togButWidth), *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use maximum z limit");
1294 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-offsetY, (textButWidth), 18, &(data->maxLimit[5]), -extremeAngZ, extremeAngZ, 0.1,0.5,"max z limit");
1295 uiBlockEndAlign(block);
1298 break;
1299 case CONSTRAINT_TYPE_CLAMPTO:
1301 bClampToConstraint *data = con->data;
1303 height = 66;
1304 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1306 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1308 /* Draw target parameters */
1309 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
1311 /* Draw XYZ toggles */
1312 uiBlockBeginAlign(block);
1313 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Main Axis:", *xco, *yco-64, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1314 uiDefButI(block, ROW, B_CONSTRAINT_TEST, "Auto", *xco+100, *yco-64, 50, 18, &data->flag, 12.0, CLAMPTO_AUTO, 0, 0, "Automatically determine main-axis of movement");
1315 uiDefButI(block, ROW, B_CONSTRAINT_TEST, "X", *xco+150, *yco-64, 32, 18, &data->flag, 12.0, CLAMPTO_X, 0, 0, "Main axis of movement is x-axis");
1316 uiDefButI(block, ROW, B_CONSTRAINT_TEST, "Y", *xco+182, *yco-64, 32, 18, &data->flag, 12.0, CLAMPTO_Y, 0, 0, "Main axis of movement is y-axis");
1317 uiDefButI(block, ROW, B_CONSTRAINT_TEST, "Z", *xco+214, *yco-64, 32, 18, &data->flag, 12.0, CLAMPTO_Z, 0, 0, "Main axis of movement is z-axis");
1318 uiBlockEndAlign(block);
1320 break;
1321 case CONSTRAINT_TYPE_NULL:
1323 height = 17;
1324 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1327 break;
1328 default:
1329 height = 0;
1330 break;
1333 (*yco)-=(24+height);
1336 if (con->type!=CONSTRAINT_TYPE_RIGIDBODYJOINT) {
1337 uiBlockBeginAlign(block);
1338 uiDefButF(block, NUMSLI, B_CONSTRAINT_INF, "Influence ", *xco, *yco, 197, 20, &(con->enforce), 0.0, 1.0, 0.0, 0.0, "Amount of influence this constraint will have on the final solution");
1339 if (con->type != CONSTRAINT_TYPE_NULL) {
1340 but = uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Show", *xco+200, *yco, 45, 20, 0, 0.0, 1.0, 0.0, 0.0, "Show constraint's ipo in the Ipo window, adds a channel if not there");
1341 /* If this is on an object or bone, add ipo channel the constraint */
1342 uiButSetFunc (but, enable_constraint_ipo_func, ob, con);
1343 but = uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Key", *xco+245, *yco, 40, 20, 0, 0.0, 1.0, 0.0, 0.0, "Add an influence keyframe to the constraint");
1344 /* Add a keyframe to the influence IPO */
1345 uiButSetFunc (but, add_influence_key_to_constraint_func, ob, con);
1347 uiBlockEndAlign(block);
1348 (*yco)-=24;
1350 else {
1351 (*yco)-=3;
1355 static uiBlock *add_constraintmenu(void *arg_unused)
1357 Object *ob= OBACT;
1358 uiBlock *block;
1359 ListBase *conlist;
1360 short yco= 0;
1362 conlist = get_active_constraints(ob);
1364 block= uiNewBlock(&curarea->uiblocks, "add_constraintmenu", UI_EMBOSSP, UI_HELV, curarea->win);
1366 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_LOCLIKE,"Copy Location", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1367 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_ROTLIKE,"Copy Rotation", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1368 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_SIZELIKE,"Copy Scale", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1370 uiDefBut(block, SEPR, 0, "", 0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1372 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_LOCLIMIT,"Limit Location", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1373 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_ROTLIMIT,"Limit Rotation", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1374 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_SIZELIMIT,"Limit Scale", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1376 uiDefBut(block, SEPR, 0, "", 0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1378 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_TRACKTO,"Track To", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1379 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_MINMAX,"Floor", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1380 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_LOCKTRACK,"Locked Track", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1381 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_FOLLOWPATH,"Follow Path", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1382 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_CLAMPTO,"Clamp To", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1384 uiDefBut(block, SEPR, 0, "", 0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1386 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_STRETCHTO,"Stretch To", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1388 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_RIGIDBODYJOINT,"Rigid Body Joint", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");//rcruiz
1390 if (ob->flag & OB_POSEMODE) {
1391 uiDefBut(block, SEPR, 0, "", 0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1393 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_KINEMATIC,"IK Solver", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1394 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_ACTION,"Action", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1397 uiDefBut(block, SEPR, 0, "", 0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1399 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_PYTHON, "Script", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1401 uiDefBut(block, SEPR, 0, "", 0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1403 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_NULL,"Null", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1406 uiTextBoundsBlock(block, 50);
1407 uiBlockSetDirection(block, UI_DOWN);
1409 return block;
1412 void do_constraintbuts(unsigned short event)
1414 Object *ob= OBACT;
1416 switch(event) {
1417 case B_CONSTRAINT_TEST:
1418 break; // no handling
1419 case B_CONSTRAINT_INF:
1420 /* influence; do not execute actions for 1 dag_flush */
1421 if(ob->pose)
1422 ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK);
1424 case B_CONSTRAINT_CHANGETARGET:
1425 if(ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels
1426 DAG_scene_sort(G.scene);
1427 break;
1429 case B_CONSTRAINT_ADD_PYTHON:
1431 bConstraint *con;
1433 con = add_new_constraint(CONSTRAINT_TYPE_PYTHON);
1434 add_constraint_to_active(ob, con);
1436 BIF_undo_push("Add constraint");
1438 break;
1439 case B_CONSTRAINT_ADD_NULL:
1441 bConstraint *con;
1443 con = add_new_constraint(CONSTRAINT_TYPE_NULL);
1444 add_constraint_to_active(ob, con);
1446 BIF_undo_push("Add constraint");
1448 break;
1449 case B_CONSTRAINT_ADD_KINEMATIC:
1451 bConstraint *con;
1453 con = add_new_constraint(CONSTRAINT_TYPE_KINEMATIC);
1454 add_constraint_to_active(ob, con);
1456 BIF_undo_push("Add constraint");
1458 break;
1459 case B_CONSTRAINT_ADD_TRACKTO:
1461 bConstraint *con;
1463 con = add_new_constraint(CONSTRAINT_TYPE_TRACKTO);
1464 add_constraint_to_active(ob, con);
1466 BIF_undo_push("Add constraint");
1468 break;
1469 case B_CONSTRAINT_ADD_MINMAX:
1471 bConstraint *con;
1473 con = add_new_constraint(CONSTRAINT_TYPE_MINMAX);
1474 add_constraint_to_active(ob, con);
1476 BIF_undo_push("Add constraint");
1478 break;
1479 case B_CONSTRAINT_ADD_ROTLIKE:
1481 bConstraint *con;
1483 con = add_new_constraint(CONSTRAINT_TYPE_ROTLIKE);
1484 add_constraint_to_active(ob, con);
1486 BIF_undo_push("Add constraint");
1488 break;
1489 case B_CONSTRAINT_ADD_LOCLIKE:
1491 bConstraint *con;
1493 con = add_new_constraint(CONSTRAINT_TYPE_LOCLIKE);
1494 add_constraint_to_active(ob, con);
1496 BIF_undo_push("Add constraint");
1498 break;
1499 case B_CONSTRAINT_ADD_SIZELIKE:
1501 bConstraint *con;
1503 con = add_new_constraint(CONSTRAINT_TYPE_SIZELIKE);
1504 add_constraint_to_active(ob, con);
1506 BIF_undo_push("Add constraint");
1508 break;
1509 case B_CONSTRAINT_ADD_ACTION:
1511 bConstraint *con;
1513 con = add_new_constraint(CONSTRAINT_TYPE_ACTION);
1514 add_constraint_to_active(ob, con);
1516 BIF_undo_push("Add constraint");
1518 break;
1519 case B_CONSTRAINT_ADD_LOCKTRACK:
1521 bConstraint *con;
1523 con = add_new_constraint(CONSTRAINT_TYPE_LOCKTRACK);
1524 add_constraint_to_active(ob, con);
1526 BIF_undo_push("Add constraint");
1528 break;
1529 case B_CONSTRAINT_ADD_FOLLOWPATH:
1531 bConstraint *con;
1533 con = add_new_constraint(CONSTRAINT_TYPE_FOLLOWPATH);
1534 add_constraint_to_active(ob, con);
1537 break;
1538 case B_CONSTRAINT_ADD_STRETCHTO:
1540 bConstraint *con;
1541 con = add_new_constraint(CONSTRAINT_TYPE_STRETCHTO);
1542 add_constraint_to_active(ob, con);
1544 BIF_undo_push("Add constraint");
1546 break;
1547 case B_CONSTRAINT_ADD_LOCLIMIT:
1549 bConstraint *con;
1551 con = add_new_constraint(CONSTRAINT_TYPE_LOCLIMIT);
1552 add_constraint_to_active(ob, con);
1554 BIF_undo_push("Add constraint");
1556 break;
1557 case B_CONSTRAINT_ADD_ROTLIMIT:
1559 bConstraint *con;
1561 con = add_new_constraint(CONSTRAINT_TYPE_ROTLIMIT);
1562 add_constraint_to_active(ob, con);
1564 BIF_undo_push("Add constraint");
1566 break;
1567 case B_CONSTRAINT_ADD_SIZELIMIT:
1569 bConstraint *con;
1571 con = add_new_constraint(CONSTRAINT_TYPE_SIZELIMIT);
1572 add_constraint_to_active(ob, con);
1574 BIF_undo_push("Add constraint");
1576 break;
1577 case B_CONSTRAINT_ADD_RIGIDBODYJOINT:
1579 bConstraint *con;
1580 con = add_new_constraint(CONSTRAINT_TYPE_RIGIDBODYJOINT);
1581 add_constraint_to_active(ob, con);
1583 BIF_undo_push("Add constraint");
1585 break;
1586 case B_CONSTRAINT_ADD_CLAMPTO:
1588 bConstraint *con;
1589 con = add_new_constraint(CONSTRAINT_TYPE_CLAMPTO);
1590 add_constraint_to_active(ob, con);
1592 BIF_undo_push("Add constraint");
1594 break;
1596 default:
1597 break;
1600 object_test_constraints(ob);
1602 if(ob->pose) update_pose_constraint_flags(ob->pose);
1604 if(ob->type==OB_ARMATURE) DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA|OB_RECALC_OB);
1605 else DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
1607 allqueue (REDRAWVIEW3D, 0);
1608 allqueue (REDRAWBUTSOBJECT, 0);
1611 void softbody_bake(Object *ob)
1613 Base *base;
1614 SoftBody *sb;
1615 ScrArea *sa;
1616 float frameleno= G.scene->r.framelen;
1617 int cfrao= CFRA, sfra=100000, efra=0, didbreak =0;
1620 G.scene->r.framelen= 1.0; // baking has to be in uncorrected time
1621 sbSetInterruptCallBack(blender_test_break); // make softbody module ESC aware
1622 G.afbreek=0; // init global break system
1624 if(ob) {
1625 sb= ob->soft;
1626 sfra= MIN2(sfra, sb->sfra);
1627 efra= MAX2(efra, sb->efra);
1628 sbObjectToSoftbody(ob); // put softbody in restposition, free bake
1629 ob->softflag |= OB_SB_BAKEDO;
1631 else {
1632 for(base=G.scene->base.first; base; base= base->next) {
1633 if(TESTBASELIB(base)) {
1634 if(base->object->soft) {
1635 sb= base->object->soft;
1636 sfra= MIN2(sfra, sb->sfra);
1637 efra= MAX2(efra, sb->efra);
1638 sbObjectToSoftbody(base->object); // put softbody in restposition, free bake
1639 base->object->softflag |= OB_SB_BAKEDO;
1645 CFRA= sfra;
1646 update_for_newframe_muted(); // put everything on this frame
1648 curarea->win_swap= 0; // clean swapbuffers
1650 for(; CFRA <= efra; CFRA++) {
1651 set_timecursor(CFRA);
1653 update_for_newframe_muted();
1655 for(sa= G.curscreen->areabase.first; sa; sa= sa->next) {
1656 if(sa->spacetype == SPACE_VIEW3D) {
1657 scrarea_do_windraw(sa);
1660 screen_swapbuffers();
1661 //blender_test_break() has a granularity of 10 ms, who cares .. baking the unit cube is kinda boring
1662 if (blender_test_break()){
1663 didbreak = 1;
1664 break;
1668 if((didbreak)&&(G.qual!=LR_SHIFTKEY)) {
1669 if(ob)
1670 sbObjectToSoftbody(ob); // free bake
1671 else {
1672 for(base=G.scene->base.first; base; base= base->next) {
1673 if(TESTBASELIB(base)) {
1674 if(base->object->soft) {
1675 sbObjectToSoftbody(base->object); // free bake
1682 /* restore */
1683 waitcursor(0);
1684 sbSetInterruptCallBack(NULL); // softbody module won't ESC
1685 G.afbreek=0; // reset global break system
1687 if(ob)
1688 ob->softflag &= ~OB_SB_BAKEDO;
1689 else {
1690 for(base=G.scene->base.first; base; base= base->next)
1691 if(TESTBASELIB(base))
1692 if(base->object->soft)
1693 base->object->softflag &= ~OB_SB_BAKEDO;
1696 CFRA= cfrao;
1697 G.scene->r.framelen= frameleno;
1698 update_for_newframe_muted();
1699 allqueue(REDRAWVIEW3D, 0);
1700 allqueue(REDRAWBUTSOBJECT, 0);
1703 // store processed path & file prefix for fluidsim bake directory
1704 void fluidsimFilesel(char *selection)
1706 Object *ob = OBACT;
1707 char srcDir[FILE_MAXDIR+FILE_MAXFILE], srcFile[FILE_MAXFILE];
1708 char prefix[FILE_MAXFILE];
1709 char *srch, *srchSub, *srchExt, *lastFound;
1710 int isElbeemSurf = 0;
1712 // make prefix
1713 strcpy(srcDir, selection);
1714 BLI_splitdirstring(srcDir, srcFile);
1715 strcpy(prefix, srcFile);
1716 // check if this is a previously generated surface mesh file
1717 srch = strstr(prefix, "fluidsurface_");
1718 // TODO search from back...
1719 if(srch) {
1720 srchSub = strstr(prefix,"_preview_");
1721 if(!srchSub) srchSub = strstr(prefix,"_final_");
1722 srchExt = strstr(prefix,".gz.bobj");
1723 if(!srchExt) srchExt = strstr(prefix,".bobj");
1724 if(srchSub && srchExt) {
1725 *srch = '\0';
1726 isElbeemSurf = 1;
1729 if(!isElbeemSurf) {
1730 // try to remove suffix
1731 lastFound = NULL;
1732 srch = strchr(prefix, '.'); // search last . from extension
1733 while(srch) {
1734 lastFound = srch;
1735 if(srch) {
1736 srch++;
1737 srch = strchr(srch, '.');
1740 if(lastFound) {
1741 *lastFound = '\0';
1745 if(ob->fluidsimSettings) {
1746 strcpy(ob->fluidsimSettings->surfdataPath, srcDir);
1747 //not necessary? strcat(ob->fluidsimSettings->surfdataPath, "/");
1748 strcat(ob->fluidsimSettings->surfdataPath, prefix);
1750 // redraw view & buttons...
1751 allqueue(REDRAWBUTSOBJECT, 0);
1752 allqueue(REDRAWVIEW3D, 0);
1753 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1757 void do_object_panels(unsigned short event)
1759 Object *ob;
1760 Effect *eff;
1762 ob= OBACT;
1763 if(ob==NULL)
1764 return;
1766 switch(event) {
1767 case B_TRACKBUTS:
1768 DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
1769 allqueue(REDRAWVIEW3D, 0);
1770 break;
1771 case B_RECALCPATH:
1772 DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
1773 allqueue(REDRAWVIEW3D, 0);
1774 break;
1775 case B_DUPLI_FRAME:
1776 ob->transflag &= ~(OB_DUPLIVERTS|OB_DUPLIFACES|OB_DUPLIGROUP);
1777 allqueue(REDRAWVIEW3D, 0);
1778 allqueue(REDRAWBUTSOBJECT, 0);
1779 break;
1780 case B_DUPLI_VERTS:
1781 ob->transflag &= ~(OB_DUPLIFRAMES|OB_DUPLIFACES|OB_DUPLIGROUP);
1782 DAG_scene_sort(G.scene);
1783 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1784 allqueue(REDRAWVIEW3D, 0);
1785 allqueue(REDRAWBUTSOBJECT, 0);
1786 break;
1787 case B_DUPLI_FACES:
1788 ob->transflag &= ~(OB_DUPLIVERTS|OB_DUPLIFRAMES|OB_DUPLIGROUP);
1789 allqueue(REDRAWVIEW3D, 0);
1790 allqueue(REDRAWBUTSOBJECT, 0);
1791 break;
1792 case B_DUPLI_GROUP:
1793 ob->transflag &= ~(OB_DUPLIVERTS|OB_DUPLIFRAMES|OB_DUPLIFACES);
1794 allqueue(REDRAWVIEW3D, 0);
1795 allqueue(REDRAWBUTSOBJECT, 0);
1796 break;
1798 case B_PRINTSPEED:
1800 float vec[3];
1801 CFRA++;
1802 do_ob_ipo(ob);
1803 where_is_object(ob);
1804 VECCOPY(vec, ob->obmat[3]);
1805 CFRA--;
1806 do_ob_ipo(ob);
1807 where_is_object(ob);
1808 VecSubf(vec, vec, ob->obmat[3]);
1809 prspeed= Normalize(vec);
1810 scrarea_queue_winredraw(curarea);
1812 break;
1813 case B_PRINTLEN:
1814 if(ob->type==OB_CURVE) {
1815 Curve *cu=ob->data;
1817 if(cu->path) prlen= cu->path->totdist; else prlen= -1.0;
1818 scrarea_queue_winredraw(curarea);
1820 break;
1821 case B_RELKEY:
1822 allspace(REMAKEIPO, 0);
1823 allqueue(REDRAWBUTSOBJECT, 0);
1824 allqueue(REDRAWBUTSEDIT, 0);
1825 allqueue(REDRAWIPO, 0);
1826 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1827 break;
1828 case B_CURVECHECK:
1829 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1830 allqueue(REDRAWVIEW3D, 0);
1831 break;
1833 case B_SOFTBODY_CHANGE:
1834 ob->softflag |= OB_SB_REDO;
1835 allqueue(REDRAWBUTSOBJECT, 0);
1836 allqueue(REDRAWVIEW3D, 0);
1837 break;
1838 case B_SOFTBODY_DEL_VG:
1839 if(ob->soft) {
1840 ob->soft->vertgroup= 0;
1841 ob->softflag |= OB_SB_REDO;
1842 allqueue(REDRAWBUTSOBJECT, 0);
1843 allqueue(REDRAWVIEW3D, 0);
1845 break;
1846 case B_SOFTBODY_BAKE:
1847 if(ob->soft) softbody_bake(ob);
1848 break;
1849 case B_SOFTBODY_BAKE_FREE:
1850 if(ob->soft) sbObjectToSoftbody(ob);
1851 allqueue(REDRAWBUTSOBJECT, 0);
1852 allqueue(REDRAWVIEW3D, 0);
1853 break;
1854 case B_FLUIDSIM_BAKE:
1855 /* write config files (currently no simulation) */
1856 fluidsimBake(ob);
1857 break;
1858 case B_FLUIDSIM_MAKEPART:
1860 PartEff *paf= NULL;
1861 /* prepare fluidsim particle display */
1862 // simplified delete effect, create new - recalc some particles...
1863 if(ob==NULL || ob->type!=OB_MESH) break;
1864 ob->fluidsimSettings->type = 0;
1865 // reset type, and init particle system once normally
1866 paf= give_parteff(ob);
1867 if( (BLI_countlist(&ob->effect)<MAX_EFFECT) &&
1868 (!paf)) {
1869 // create new entry
1870 copy_act_effect(ob); DAG_scene_sort(G.scene); }
1871 paf = give_parteff(ob);
1872 if(paf) {
1873 paf->totpart = 1000; paf->sta = paf->end = 1.0; // generate some particles...
1874 build_particle_system(ob);
1875 ob->fluidsimSettings->type = OB_FLUIDSIM_PARTICLE;
1878 allqueue(REDRAWVIEW3D, 0);
1879 allqueue(REDRAWBUTSOBJECT, 0);
1880 break;
1881 case B_FLUIDSIM_SELDIR:
1883 ScrArea *sa = closest_bigger_area();
1884 /* choose dir for surface files */
1885 areawinset(sa->win);
1886 activate_fileselect(FILE_SPECIAL, "Select Directory", ob->fluidsimSettings->surfdataPath, fluidsimFilesel);
1888 break;
1889 case B_FLUIDSIM_FORCEREDRAW:
1890 /* force redraw */
1891 allqueue(REDRAWBUTSOBJECT, 0);
1892 allqueue(REDRAWVIEW3D, 0);
1893 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
1894 break;
1895 case B_GROUP_RELINK:
1896 group_relink_nla_objects(ob);
1897 allqueue(REDRAWVIEW3D, 0);
1898 break;
1900 case B_OBJECT_IPOFLAG:
1901 if(ob->ipo) ob->ipo->showkey= (ob->ipoflag & OB_DRAWKEY)?1:0;
1902 allqueue(REDRAWVIEW3D, 0);
1903 break;
1905 default:
1906 if(event>=B_SELEFFECT && event<B_SELEFFECT+MAX_EFFECT) {
1907 int a=B_SELEFFECT;
1909 eff= ob->effect.first;
1910 while(eff) {
1911 if(event==a) eff->flag |= SELECT;
1912 else eff->flag &= ~SELECT;
1914 a++;
1915 eff= eff->next;
1917 allqueue(REDRAWBUTSOBJECT, 0);
1923 static void do_add_groupmenu(void *arg, int event)
1925 Object *ob= OBACT;
1927 if(ob) {
1929 if(event== -1) {
1930 Group *group= add_group( "Group" );
1931 add_to_group(group, ob);
1933 else
1934 add_to_group(BLI_findlink(&G.main->group, event), ob);
1936 ob->flag |= OB_FROMGROUP;
1937 BASACT->flag |= OB_FROMGROUP;
1938 allqueue(REDRAWBUTSOBJECT, 0);
1939 allqueue(REDRAWVIEW3D, 0);
1943 static uiBlock *add_groupmenu(void *arg_unused)
1945 uiBlock *block;
1946 Group *group;
1947 short xco=0, yco= 0, index=0;
1948 char str[32];
1950 block= uiNewBlock(&curarea->uiblocks, "add_constraintmenu", UI_EMBOSSP, UI_HELV, curarea->win);
1951 uiBlockSetButmFunc(block, do_add_groupmenu, NULL);
1953 uiDefBut(block, BUTM, B_NOP, "ADD NEW", 0, 20, 160, 19, NULL, 0.0, 0.0, 1, -1, "");
1954 for(group= G.main->group.first; group; group= group->id.next, index++) {
1955 if(group->id.lib) strcpy(str, "L ");
1956 else strcpy(str, " ");
1957 strcat(str, group->id.name+2);
1958 uiDefBut(block, BUTM, B_NOP, str, xco*160, -20*yco, 160, 19, NULL, 0.0, 0.0, 1, index, "");
1960 yco++;
1961 if(yco>24) {
1962 yco= 0;
1963 xco++;
1967 uiTextBoundsBlock(block, 50);
1968 uiBlockSetDirection(block, UI_DOWN);
1970 return block;
1973 static void group_ob_rem(void *gr_v, void *ob_v)
1975 Object *ob= OBACT;
1977 rem_from_group(gr_v, ob);
1978 if(find_group(ob)==NULL) {
1979 ob->flag &= ~OB_FROMGROUP;
1980 BASACT->flag &= ~OB_FROMGROUP;
1982 allqueue(REDRAWBUTSOBJECT, 0);
1983 allqueue(REDRAWVIEW3D, 0);
1987 static void group_local(void *gr_v, void *unused)
1989 Group *group= gr_v;
1991 group->id.lib= NULL;
1993 allqueue(REDRAWBUTSOBJECT, 0);
1994 allqueue(REDRAWVIEW3D, 0);
1998 static void object_panel_object(Object *ob)
2000 uiBlock *block;
2001 uiBut *but;
2002 Group *group;
2003 int a, xco, yco=0;
2004 short dx= 33, dy= 30;
2006 block= uiNewBlock(&curarea->uiblocks, "object_panel_object", UI_EMBOSS, UI_HELV, curarea->win);
2007 if(uiNewPanel(curarea, block, "Object and Links", "Object", 0, 0, 318, 204)==0) return;
2009 uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
2011 /* object name */
2012 uiBlockSetCol(block, TH_BUT_SETTING2);
2013 xco= std_libbuttons(block, 10, 180, 0, NULL, 0, ID_OB, 0, &ob->id, NULL, &(G.buts->menunr), B_OBALONE, B_OBLOCAL, 0, 0, B_KEEPDATA);
2014 uiBlockSetCol(block, TH_AUTO);
2016 /* parent */
2017 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_OBJECTPANELPARENT, "Par:", xco+5, 180, 305-xco, 20, &ob->parent, "Parent Object");
2019 /* TODO, check for ob->id.lib */
2020 but = uiDefButS(block, NUM, B_NOP, "PassIndex:", xco+5, 150, 305-xco, 20, &ob->index, 0.0, 1000.0, 0, 0, "Index # for the IndexOB render pass.");
2022 uiDefBlockBut(block, add_groupmenu, NULL, "Add to Group", 10,150,150,20, "Add Object to a new Group");
2024 /* all groups */
2025 for(group= G.main->group.first; group; group= group->id.next) {
2026 if(object_in_group(ob, group)) {
2027 xco= 160;
2029 uiBlockBeginAlign(block);
2030 but = uiDefBut(block, TEX, B_IDNAME, "GR:", 10, 120-yco, 150, 20, group->id.name+2, 0.0, 21.0, 0, 0, "Displays Group name. Click to change.");
2031 uiButSetFunc(but, test_idbutton_cb, group->id.name, NULL);
2033 if(group->id.lib) {
2034 but= uiDefIconBut(block, BUT, B_NOP, ICON_PARLIB, 160, 120-yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Make Group local");
2035 uiButSetFunc(but, group_local, group, NULL);
2036 xco= 180;
2038 but = uiDefIconBut(block, BUT, B_NOP, VICON_X, xco, 120-yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Remove Group membership");
2039 uiButSetFunc(but, group_ob_rem, group, ob);
2041 yco+= 20;
2042 xco= 10;
2044 /* layers */
2045 uiBlockBeginAlign(block);
2046 for(a=0; a<5; a++)
2047 uiDefButBitI(block, TOG, 1<<a, REDRAWVIEW3D, "", (short)(xco+a*(dx/2)), 120-yco, (short)(dx/2), (short)(dy/2), (int *)&(group->layer), 0, 0, 0, 0, "");
2048 for(a=0; a<5; a++)
2049 uiDefButBitI(block, TOG, 1<<(a+10), REDRAWVIEW3D, "", (short)(xco+a*(dx/2)), 105-yco, (short)(dx/2), (short)(dy/2), (int *)&(group->layer), 0, 0, 0, 0, "");
2051 xco+= 7;
2052 uiBlockBeginAlign(block);
2053 for(a=5; a<10; a++)
2054 uiDefButBitI(block, TOG, 1<<a, REDRAWVIEW3D, "", (short)(xco+a*(dx/2)), 120-yco, (short)(dx/2), (short)(dy/2), (int *)&(group->layer), 0, 0, 0, 0, "");
2055 for(a=5; a<10; a++)
2056 uiDefButBitI(block, TOG, 1<<(a+10), REDRAWVIEW3D, "", (short)(xco+a*(dx/2)), 105-yco, (short)(dx/2), (short)(dy/2), (int *)&(group->layer), 0, 0, 0, 0, "");
2058 uiBlockEndAlign(block);
2060 yco+= 40;
2064 if(120-yco < -10)
2065 uiNewPanelHeight(block, 204 - (120-yco));
2068 static void object_panel_anim(Object *ob)
2070 uiBlock *block;
2071 char str[32];
2073 block= uiNewBlock(&curarea->uiblocks, "object_panel_anim", UI_EMBOSS, UI_HELV, curarea->win);
2074 if(uiNewPanel(curarea, block, "Anim settings", "Object", 320, 0, 318, 204)==0) return;
2076 uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
2078 uiBlockBeginAlign(block);
2079 uiDefButS(block, ROW,B_TRACKBUTS,"TrackX", 24,180,59,19, &ob->trackflag, 12.0, 0.0, 0, 0, "Specify the axis that points to another object");
2080 uiDefButS(block, ROW,B_TRACKBUTS,"Y", 85,180,19,19, &ob->trackflag, 12.0, 1.0, 0, 0, "Specify the axis that points to another object");
2081 uiDefButS(block, ROW,B_TRACKBUTS,"Z", 104,180,19,19, &ob->trackflag, 12.0, 2.0, 0, 0, "Specify the axis that points to another object");
2082 uiDefButS(block, ROW,B_TRACKBUTS,"-X", 124,180,24,19, &ob->trackflag, 12.0, 3.0, 0, 0, "Specify the axis that points to another object");
2083 uiDefButS(block, ROW,B_TRACKBUTS,"-Y", 150,180,24,19, &ob->trackflag, 12.0, 4.0, 0, 0, "Specify the axis that points to another object");
2084 uiDefButS(block, ROW,B_TRACKBUTS,"-Z", 178,180,24,19, &ob->trackflag, 12.0, 5.0, 0, 0, "Specify the axis that points to another object");
2085 uiBlockBeginAlign(block);
2086 uiDefButS(block, ROW,REDRAWVIEW3D,"UpX", 226,180,45,19, &ob->upflag, 13.0, 0.0, 0, 0, "Specify the axis that points up");
2087 uiDefButS(block, ROW,REDRAWVIEW3D,"Y", 274,180,20,19, &ob->upflag, 13.0, 1.0, 0, 0, "Specify the axis that points up");
2088 uiDefButS(block, ROW,REDRAWVIEW3D,"Z", 298,180,19,19, &ob->upflag, 13.0, 2.0, 0, 0, "Specify the axis that points up");
2090 uiBlockBeginAlign(block);
2091 uiDefButBitS(block, TOG, OB_DRAWKEY, B_OBJECT_IPOFLAG, "Draw Key", 24,155,71,19, &ob->ipoflag, 0, 0, 0, 0, "Draw object as key position");
2092 uiDefButBitS(block, TOG, OB_DRAWKEYSEL, REDRAWVIEW3D, "Draw Key Sel", 97,155,81,19, &ob->ipoflag, 0, 0, 0, 0, "Limit the drawing of object keys");
2093 uiDefButBitS(block, TOG, OB_POWERTRACK, REDRAWVIEW3D, "Powertrack", 180,155,78,19, &ob->transflag, 0, 0, 0, 0, "Switch objects rotation off");
2094 uiDefButBitS(block, TOG, PARSLOW, 0, "SlowPar", 260,155,56,19, &ob->partype, 0, 0, 0, 0, "Create a delay in the parent relationship");
2095 uiBlockBeginAlign(block);
2097 uiDefButBitS(block, TOG, OB_DUPLIFRAMES, B_DUPLI_FRAME, "DupliFrames", 24,130,95,20, &ob->transflag, 0, 0, 0, 0, "Make copy of object for every frame");
2098 uiDefButBitS(block, TOG, OB_DUPLIVERTS, B_DUPLI_VERTS, "DupliVerts", 119,130,95,20, &ob->transflag, 0, 0, 0, 0, "Duplicate child objects on all vertices");
2099 uiDefButBitS(block, TOG, OB_DUPLIFACES, B_DUPLI_FACES, "DupliFaces", 214,130,102,20, &ob->transflag, 0, 0, 0, 0, "Duplicate child objects on all faces");
2100 uiDefButBitS(block, TOG, OB_DUPLIGROUP, B_DUPLI_GROUP, "DupliGroup", 24,110,150,20, &ob->transflag, 0, 0, 0, 0, "Enable group instancing");
2101 if(ob->transflag & OB_DUPLIFRAMES)
2102 uiDefButBitS(block, TOG, OB_DUPLINOSPEED, REDRAWVIEW3D, "No Speed", 174,110,142,20, &ob->transflag, 0, 0, 0, 0, "Set dupliframes to still, regardless of frame");
2103 else if(ob->transflag & OB_DUPLIVERTS)
2104 uiDefButBitS(block, TOG, OB_DUPLIROT, REDRAWVIEW3D, "Rot", 174,110,142,20, &ob->transflag, 0, 0, 0, 0, "Rotate dupli according to vertex normal");
2105 else if(ob->transflag & OB_DUPLIFACES)
2106 uiDefButBitS(block, TOG, OB_DUPLIFACES_SCALE, REDRAWVIEW3D, "Scale", 174,110,142,20, &ob->transflag, 0, 0, 0, 0, "Scale dupli based on face size");
2107 else
2108 uiDefIDPoinBut(block, test_grouppoin_but, ID_GR, B_GROUP_RELINK, "GR:", 174,110,142,20, &ob->dup_group, "Instance an existing group");
2110 uiBlockBeginAlign(block);
2111 /* DupSta and DupEnd are both shorts, so the maxframe is greater then their range
2112 just limit the buttons to the max short */
2113 uiDefButI(block, NUM, REDRAWVIEW3D, "DupSta:", 24,85,141,19, &ob->dupsta, 1.0, 32767, 0, 0, "Specify startframe for Dupliframes");
2114 uiDefButI(block, NUM, REDRAWVIEW3D, "DupOn:", 170,85,146,19, &ob->dupon, 1.0, 1500.0, 0, 0, "Specify the number of frames to use between DupOff frames");
2115 uiDefButI(block, NUM, REDRAWVIEW3D, "DupEnd", 24,65,140,19, &ob->dupend, 1.0, 32767, 0, 0, "Specify endframe for Dupliframes");
2116 uiDefButI(block, NUM, REDRAWVIEW3D, "DupOff", 171,65,145,19, &ob->dupoff, 0.0, 1500.0, 0, 0, "Specify recurring frames to exclude from the Dupliframes");
2117 uiBlockBeginAlign(block);
2118 uiDefButBitS(block, TOG, OB_OFFS_OB, REDRAWALL, "Offs Ob", 24,35,56,20, &ob->ipoflag, 0, 0, 0, 0, "Not functional at the moment!");
2119 uiDefButBitS(block, TOG, OB_OFFS_PARENT, REDRAWALL, "Offs Par", 82,35,56,20 , &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the parent");
2120 uiDefButBitS(block, TOG, OB_OFFS_PARTICLE, REDRAWALL, "Offs Particle", 140,35,103,20, &ob->ipoflag, 0, 0, 0, 0, "Let the timeoffset work on the particle effect");
2122 uiBlockBeginAlign(block);
2123 uiDefButF(block, NUM, REDRAWALL, "TimeOffset:", 24,10,115,20, &ob->sf, -MAXFRAMEF, MAXFRAMEF, 100, 0, "Specify an offset in frames");
2124 uiDefBut(block, BUT, B_AUTOTIMEOFS, "Automatic Time", 139,10,104,20, 0, 0, 0, 0, 0, "Generate automatic timeoffset values for all selected frames");
2125 uiDefBut(block, BUT, B_PRINTSPEED, "PrSpeed", 248,10,67,20, 0, 0, 0, 0, 0, "Print objectspeed");
2126 uiBlockEndAlign(block);
2128 sprintf(str, "%.4f", prspeed);
2129 uiDefBut(block, LABEL, 0, str, 247,35,63,31, NULL, 1.0, 0, 0, 0, "");
2133 static void object_panel_draw(Object *ob)
2135 uiBlock *block;
2136 int xco, a, dx, dy;
2138 block= uiNewBlock(&curarea->uiblocks, "object_panel_draw", UI_EMBOSS, UI_HELV, curarea->win);
2139 if(uiNewPanel(curarea, block, "Draw", "Object", 640, 0, 318, 204)==0) return;
2141 uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
2143 /* LAYERS */
2144 xco= 80;
2145 dx= 35;
2146 dy= 30;
2148 uiDefBut(block, LABEL, 0, "Layers", 10,170,100,20, NULL, 0, 0, 0, 0, "");
2150 uiBlockBeginAlign(block);
2151 for(a=0; a<5; a++)
2152 uiDefButBitI(block, TOG, 1<<a, B_OBLAY+a, "", (short)(xco+a*(dx/2)), 180, (short)(dx/2), (short)(dy/2), (int *)&(BASACT->lay), 0, 0, 0, 0, "");
2153 for(a=0; a<5; a++)
2154 uiDefButBitI(block, TOG, 1<<(a+10), B_OBLAY+a+10, "", (short)(xco+a*(dx/2)), 165, (short)(dx/2), (short)(dy/2), (int *)&(BASACT->lay), 0, 0, 0, 0, "");
2156 xco+= 7;
2157 uiBlockBeginAlign(block);
2158 for(a=5; a<10; a++)
2159 uiDefButBitI(block, TOG, 1<<a, B_OBLAY+a, "", (short)(xco+a*(dx/2)), 180, (short)(dx/2), (short)(dy/2), (int *)&(BASACT->lay), 0, 0, 0, 0, "");
2160 for(a=5; a<10; a++)
2161 uiDefButBitI(block, TOG, 1<<(a+10), B_OBLAY+a+10, "", (short)(xco+a*(dx/2)), 165, (short)(dx/2), (short)(dy/2), (int *)&(BASACT->lay), 0, 0, 0, 0, "");
2163 uiBlockEndAlign(block);
2165 /* Object Color */
2166 uiDefButF(block, COL, REDRAWVIEW3D, "", 270, 165,30, 30, ob->col, 0, 0, 0, 0, "Object color, used when faces have the ObCol mode enabled");
2168 uiDefBut(block, LABEL, 0, "Drawtype", 10,120,100,20, NULL, 0, 0, 0, 0, "");
2170 uiBlockBeginAlign(block);
2171 uiDefButC(block, ROW, REDRAWVIEW3D, "Shaded", 10,100,100, 20, &ob->dt, 0, OB_SHADED, 0, 0, "Draw active object shaded or textured");
2172 uiDefButC(block, ROW, REDRAWVIEW3D, "Solid", 10,80,100, 20, &ob->dt, 0, OB_SOLID, 0, 0, "Draw active object in solid");
2173 uiDefButC(block, ROW, REDRAWVIEW3D, "Wire", 10,60, 100, 20, &ob->dt, 0, OB_WIRE, 0, 0, "Draw active object in wireframe");
2174 uiDefButC(block, ROW, REDRAWVIEW3D, "Bounds", 10,40, 100, 20, &ob->dt, 0, OB_BOUNDBOX, 0, 0, "Only draw object with bounding box");
2175 uiBlockEndAlign(block);
2177 uiDefBut(block, LABEL, 0, "Draw Extra", 120,120,90,20, NULL, 0, 0, 0, 0, "");
2179 uiBlockBeginAlign(block);
2180 uiDefButBitC(block, TOG, OB_BOUNDBOX, REDRAWVIEW3D, "Bounds", 120, 100, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's bounds");
2181 uiDefButBitC(block, TOG, OB_DRAWNAME, REDRAWVIEW3D, "Name", 210, 100, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's name");
2183 uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Polyheder%x4",
2184 120, 80, 90, 20, &ob->boundtype, 0, 0, 0, 0, "Selects the boundary display type");
2185 uiDefButBitC(block, TOG, OB_AXIS, REDRAWVIEW3D, "Axis", 210, 80, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's center and axis");
2187 uiDefButBitC(block, TOG, OB_TEXSPACE, REDRAWVIEW3D, "TexSpace", 120, 60, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's texture space");
2188 uiDefButBitC(block, TOG, OB_DRAWWIRE, REDRAWVIEW3D, "Wire", 210, 60, 90, 20, &ob->dtx, 0, 0, 0, 0, "Adds the active object's wireframe over solid drawing");
2190 uiDefButBitC(block, TOG, OB_DRAWTRANSP, REDRAWVIEW3D, "Transp", 120, 40, 90, 20, &ob->dtx, 0, 0, 0, 0, "Enables transparent materials for the active object (Mesh only)");
2191 uiDefButBitC(block, TOG, OB_DRAWXRAY, REDRAWVIEW3D, "X-ray", 210, 40, 90, 20, &ob->dtx, 0, 0, 0, 0, "Makes the active object draw in front of others");
2195 void object_panel_constraint(char *context)
2197 uiBlock *block;
2198 Object *ob= OBACT;
2199 ListBase *conlist;
2200 bConstraint *curcon;
2201 short xco, yco;
2202 char str[64];
2204 block= uiNewBlock(&curarea->uiblocks, "object_panel_constraint", UI_EMBOSS, UI_HELV, curarea->win);
2205 if(uiNewPanel(curarea, block, "Constraints", context, 960, 0, 318, 204)==0) return;
2207 uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
2209 /* this is a variable height panel, newpanel doesnt force new size on existing panels */
2210 /* so first we make it default height */
2211 uiNewPanelHeight(block, 204);
2213 if(G.obedit==OBACT) return; // ??
2215 conlist = get_active_constraints(OBACT);
2217 if (conlist) {
2219 uiDefBlockBut(block, add_constraintmenu, NULL, "Add Constraint", 0, 190, 130, 20, "Add a new constraint");
2221 /* print active object or bone */
2222 str[0]= 0;
2223 if (ob->flag & OB_POSEMODE){
2224 bPoseChannel *pchan= get_active_posechannel(ob);
2225 if(pchan) sprintf(str, "To Bone: %s", pchan->name);
2227 else {
2228 sprintf(str, "To Object: %s", ob->id.name+2);
2230 uiDefBut(block, LABEL, 1, str, 150, 190, 150, 20, NULL, 0.0, 0.0, 0, 0, "Displays Active Object or Bone name");
2232 /* Go through the list of constraints and draw them */
2233 xco = 10;
2234 yco = 160;
2236 for (curcon = conlist->first; curcon; curcon=curcon->next) {
2237 /* hrms, the temporal constraint should not draw! */
2238 if(curcon->type==CONSTRAINT_TYPE_KINEMATIC) {
2239 bKinematicConstraint *data= curcon->data;
2240 if(data->flag & CONSTRAINT_IK_TEMP)
2241 continue;
2243 /* Draw default constraint header */
2244 draw_constraint(block, conlist, curcon, &xco, &yco);
2247 if(yco < 0) uiNewPanelHeight(block, 204-yco);
2252 void do_effects_panels(unsigned short event)
2254 Object *ob;
2255 Base *base;
2256 Effect *eff, *effn;
2257 PartEff *paf;
2259 ob= OBACT;
2261 switch(event) {
2263 case B_AUTOTIMEOFS:
2264 auto_timeoffs();
2265 break;
2266 case B_FRAMEMAP:
2267 G.scene->r.framelen= G.scene->r.framapto;
2268 G.scene->r.framelen/= G.scene->r.images;
2269 allqueue(REDRAWALL, 0);
2270 break;
2271 case B_NEWEFFECT:
2272 if(ob) {
2273 if(ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) {
2274 // NT particles and fluid meshes currently dont work together -> switch off beforehand
2275 if(ob->fluidsimSettings->type == OB_FLUIDSIM_DOMAIN) {
2276 pupmenu("Fluidsim Particle Error%t|Please disable the fluidsim domain before activating particles.%x0");
2277 break;
2278 //ob->fluidsimFlag = 0; ob->fluidsimSettings->type = 0; allqueue(REDRAWVIEW3D, 0);
2281 if (BLI_countlist(&ob->effect)==MAX_EFFECT)
2282 error("Unable to add: effect limit reached");
2283 else
2284 copy_act_effect(ob);
2286 DAG_scene_sort(G.scene);
2287 BIF_undo_push("New effect");
2288 allqueue(REDRAWBUTSOBJECT, 0);
2289 break;
2290 case B_DELEFFECT:
2291 if(ob==NULL || ob->type!=OB_MESH) break;
2292 eff= ob->effect.first;
2293 while(eff) {
2294 effn= eff->next;
2295 if(eff->flag & SELECT) {
2296 BLI_remlink(&ob->effect, eff);
2297 free_effect(eff);
2298 break;
2300 eff= effn;
2302 BIF_undo_push("Delete effect");
2303 allqueue(REDRAWVIEW3D, 0);
2304 allqueue(REDRAWBUTSOBJECT, 0);
2305 break;
2306 case B_NEXTEFFECT:
2307 if(ob==0 || ob->type!=OB_MESH) break;
2308 eff= ob->effect.first;
2309 while(eff) {
2310 if(eff->flag & SELECT) {
2311 if(eff->next) {
2312 eff->flag &= ~SELECT;
2313 eff->next->flag |= SELECT;
2315 break;
2317 eff= eff->next;
2319 allqueue(REDRAWBUTSOBJECT, 0);
2320 break;
2321 case B_PREVEFFECT:
2322 if(ob==0 || ob->type!=OB_MESH) break;
2323 eff= ob->effect.first;
2324 while(eff) {
2325 if(eff->flag & SELECT) {
2326 if(eff->prev) {
2327 eff->flag &= ~SELECT;
2328 eff->prev->flag |= SELECT;
2330 break;
2332 eff= eff->next;
2334 allqueue(REDRAWBUTSOBJECT, 0);
2335 break;
2336 case B_EFFECT_DEP:
2337 DAG_scene_sort(G.scene);
2338 /* no break, pass on */
2339 case B_CALCEFFECT:
2340 if(ob==NULL || ob->type!=OB_MESH) break;
2341 eff= ob->effect.first;
2342 while(eff) {
2343 if(eff->flag & SELECT) {
2344 if(eff->type==EFF_PARTICLE) build_particle_system(ob);
2346 eff= eff->next;
2348 allqueue(REDRAWVIEW3D, 0);
2349 allqueue(REDRAWBUTSOBJECT, 0);
2350 break;
2351 case B_PAF_SET_VG:
2353 paf= give_parteff(ob);
2354 if(paf) {
2355 bDeformGroup *dg= get_named_vertexgroup(ob, paf->vgroupname);
2356 if(dg)
2357 paf->vertgroup= get_defgroup_num(ob, dg)+1;
2358 else
2359 paf->vertgroup= 0;
2361 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
2362 allqueue(REDRAWVIEW3D, 0);
2364 break;
2365 case B_PAF_SET_VG1:
2367 paf= give_parteff(ob);
2368 if(paf) {
2369 bDeformGroup *dg= get_named_vertexgroup(ob, paf->vgroupname_v);
2370 if(dg)
2371 paf->vertgroup_v= get_defgroup_num(ob, dg)+1;
2372 else
2373 paf->vertgroup_v= 0;
2375 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
2376 allqueue(REDRAWVIEW3D, 0);
2378 break;
2379 case B_FIELD_DEP:
2380 /* do this before scene sort, that one checks for CU_PATH */
2381 if(ob->type==OB_CURVE && ob->pd->forcefield==PFIELD_GUIDE) {
2382 Curve *cu= ob->data;
2384 cu->flag |= (CU_PATH|CU_3D);
2385 do_curvebuts(B_CU3D); /* all curves too */
2387 DAG_scene_sort(G.scene);
2389 if(ob->type==OB_CURVE && ob->pd->forcefield==PFIELD_GUIDE)
2390 DAG_object_flush_update(G.scene, ob, OB_RECALC);
2391 else
2392 DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
2394 allqueue(REDRAWVIEW3D, 0);
2395 allqueue(REDRAWBUTSOBJECT, 0);
2396 break;
2397 case B_FIELD_CHANGE:
2398 DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
2399 allqueue(REDRAWVIEW3D, 0);
2400 break;
2401 case B_RECALCAL:
2402 if (G.vd==NULL)
2403 break;
2405 base= FIRSTBASE;
2406 while(base) {
2407 if(base->lay & G.vd->lay) {
2408 ob= base->object;
2409 eff= ob->effect.first;
2410 while(eff) {
2411 if(eff->flag & SELECT) {
2412 if(eff->type==EFF_PARTICLE) build_particle_system(ob);
2414 eff= eff->next;
2417 base= base->next;
2419 allqueue(REDRAWVIEW3D, 0);
2420 break;
2421 default:
2422 if(event>=B_SELEFFECT && event<B_SELEFFECT+MAX_EFFECT) {
2423 ob= OBACT;
2424 if(ob) {
2425 int a=B_SELEFFECT;
2427 eff= ob->effect.first;
2428 while(eff) {
2429 if(event==a) eff->flag |= SELECT;
2430 else eff->flag &= ~SELECT;
2432 a++;
2433 eff= eff->next;
2435 allqueue(REDRAWBUTSOBJECT, 0);
2442 /* Panel for particle interaction settings */
2443 static void object_panel_fields(Object *ob)
2445 uiBlock *block;
2447 block= uiNewBlock(&curarea->uiblocks, "object_panel_fields", UI_EMBOSS, UI_HELV, curarea->win);
2448 if(uiNewPanel(curarea, block, "Fields and Deflection", "Physics", 0, 0, 318, 204)==0) return;
2450 uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
2452 /* should become button, option? */
2453 if(ob->pd==NULL) {
2454 ob->pd= MEM_callocN(sizeof(PartDeflect), "PartDeflect");
2455 /* and if needed, init here */
2456 ob->pd->pdef_sbdamp = 0.1f;
2457 ob->pd->pdef_sbift = 0.2f;
2458 ob->pd->pdef_sboft = 0.02f;
2461 if(ob->pd) {
2462 PartDeflect *pd= ob->pd;
2463 char *menustr= MEM_mallocN(256, "temp string");
2464 char *tipstr="Choose field type";
2466 uiDefBut(block, LABEL, 0, "Fields", 10,180,140,20, NULL, 0.0, 0, 0, 0, "");
2468 /* setup menu button */
2469 sprintf(menustr, "Field Type%%t|None %%x0|Spherical %%x%d|Wind %%x%d|Vortex %%x%d|Curve Guide %%x%d",
2470 PFIELD_FORCE, PFIELD_WIND, PFIELD_VORTEX, PFIELD_GUIDE);
2472 if(pd->forcefield==PFIELD_FORCE) tipstr= "Object center attracts or repels particles";
2473 else if(pd->forcefield==PFIELD_WIND) tipstr= "Constant force applied in direction of Object Z axis";
2474 else if(pd->forcefield==PFIELD_VORTEX) tipstr= "Particles swirl around Z-axis of the Object";
2475 else if(pd->forcefield==PFIELD_GUIDE) tipstr= "Use a Curve Path to guide particles";
2477 uiDefButS(block, MENU, B_FIELD_DEP, menustr, 10,160,140,20, &pd->forcefield, 0.0, 0.0, 0, 0, tipstr);
2478 MEM_freeN(menustr);
2480 if(pd->forcefield) {
2481 uiBlockBeginAlign(block);
2482 if(pd->forcefield == PFIELD_GUIDE) {
2483 uiDefButF(block, NUM, B_FIELD_CHANGE, "MinDist: ", 10,120,140,20, &pd->f_strength, 0.0, 1000.0, 10, 0, "The distance from which particles are affected fully.");
2484 uiDefButF(block, NUM, B_FIELD_CHANGE, "Fall-off: ", 10,100,140,20, &pd->f_power, 0.0, 10.0, 10, 0, "Falloff factor, between mindist and maxdist");
2486 else {
2487 uiDefButF(block, NUM, B_FIELD_CHANGE, "Strength: ", 10,110,140,20, &pd->f_strength, -1000, 1000, 10, 0, "Strength of force field");
2488 uiDefButF(block, NUM, B_FIELD_CHANGE, "Fall-off: ", 10,90,140,20, &pd->f_power, 0, 10, 10, 0, "Falloff power (real gravitational fallof = 2)");
2491 uiBlockBeginAlign(block);
2492 uiDefButBitS(block, TOG, PFIELD_USEMAX, B_FIELD_CHANGE, "Use MaxDist", 10,60,140,20, &pd->flag, 0.0, 0, 0, 0, "Use a maximum distance for the field to work");
2493 uiDefButF(block, NUM, B_FIELD_CHANGE, "MaxDist: ", 10,40,140,20, &pd->maxdist, 0, 1000.0, 10, 0, "Maximum distance for the field to work");
2494 uiBlockEndAlign(block);
2496 if(pd->forcefield == PFIELD_GUIDE)
2497 uiDefButBitS(block, TOG, PFIELD_GUIDE_PATH_ADD, B_FIELD_CHANGE, "Additive", 10,10,140,20, &pd->flag, 0.0, 0, 0, 0, "Based on distance/falloff it adds a portion of the entire path");
2501 uiDefBut(block, LABEL, 0, "Deflection", 160,180,140,20, NULL, 0.0, 0, 0, 0, "");
2503 /* only meshes collide now */
2504 if(ob->type==OB_MESH) {
2505 uiDefButBitS(block, TOG, 1, B_REDR, "Deflection",160,160,150,20, &pd->deflect, 0, 0, 0, 0, "Deflects particles based on collision");
2506 if(pd->deflect) {
2507 uiDefBut(block, LABEL, 0, "Particles", 160,140,150,20, NULL, 0.0, 0, 0, 0, "");
2509 uiBlockBeginAlign(block);
2510 uiDefButF(block, NUM, B_DIFF, "Damping: ", 160,120,150,20, &pd->pdef_damp, 0.0, 1.0, 10, 0, "Amount of damping during particle collision");
2511 uiDefButF(block, NUM, B_DIFF, "Rnd Damping: ", 160,100,150,20, &pd->pdef_rdamp, 0.0, 1.0, 10, 0, "Random variation of damping");
2512 uiDefButF(block, NUM, B_DIFF, "Permeability: ", 160,80,150,20, &pd->pdef_perm, 0.0, 1.0, 10, 0, "Chance that the particle will pass through the mesh");
2513 uiBlockEndAlign(block);
2515 uiDefBut(block, LABEL, 0, "Soft Body", 160,60,150,20, NULL, 0.0, 0, 0, 0, "");
2517 uiBlockBeginAlign(block);
2518 uiDefButF(block, NUM, B_FIELD_CHANGE, "Damping:", 160,40,150,20, &pd->pdef_sbdamp, 0.0, 1.0, 10, 0, "Amount of damping during soft body collision");
2519 uiDefButF(block, NUM, B_FIELD_CHANGE, "Inner:", 160,20,150,20, &pd->pdef_sbift, 0.001, 1.0, 10, 0, "Inner face thickness");
2520 uiDefButF(block, NUM, B_FIELD_CHANGE, "Outer:", 160, 0,150,20, &pd->pdef_sboft, 0.001, 1.0, 10, 0, "Outer face thickness");
2527 /* Panel for softbodies */
2528 static void object_softbodies__enable(void *ob_v, void *arg2)
2530 Object *ob = ob_v;
2531 ModifierData *md = modifiers_findByType(ob, eModifierType_Softbody);
2533 if (modifiers_isSoftbodyEnabled(ob)) {
2534 if (md) {
2535 md->mode &= ~(eModifierMode_Render|eModifierMode_Realtime);
2537 } else {
2538 if (!md) {
2539 md = modifier_new(eModifierType_Softbody);
2540 BLI_addhead(&ob->modifiers, md);
2543 md->mode |= eModifierMode_Render|eModifierMode_Realtime;
2545 if (!ob->soft) {
2546 ob->soft= sbNew();
2547 ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
2551 allqueue(REDRAWBUTSEDIT, 0);
2554 static int _can_softbodies_at_all(Object *ob)
2556 // list of Yes
2557 if ((ob->type==OB_MESH)
2558 || (ob->type==OB_CURVE)
2559 || (ob->type==OB_LATTICE)
2560 || (ob->type==OB_SURF)
2561 ) return 1;
2562 // else deny
2563 return 0;
2565 static void object_softbodies_II(Object *ob)
2567 uiBlock *block;
2568 static int val;
2569 if(!_can_softbodies_at_all(ob)) return;
2570 /*bah that is ugly! creating missing data members in UI code*/
2571 if(ob->pd == NULL){
2572 ob->pd= MEM_callocN(sizeof(PartDeflect), "PartDeflect");
2573 ob->pd->pdef_sbdamp = 0.1f;
2574 ob->pd->pdef_sbift = 0.2f;
2575 ob->pd->pdef_sboft = 0.02f;
2577 block= uiNewBlock(&curarea->uiblocks, "object_softbodies_II", UI_EMBOSS, UI_HELV, curarea->win);
2578 uiNewPanelTabbed("Soft Body", "Physics");
2579 if(uiNewPanel(curarea, block, "Soft Body Collision", "Physics", 651, 0, 318, 204)==0) return;
2581 uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
2583 val = modifiers_isSoftbodyEnabled(ob);
2584 if(!val) {
2585 uiDefBut(block, LABEL, 0, "",10,10,1,2, NULL, 0.0, 0, 0, 0, ""); /* tell UI we go to 10,10*/
2586 uiBlockBeginAlign(block);
2587 uiDefBut(block, LABEL, 0, "Object is not a softbody",10,190,300,20, NULL, 0.0, 0, 0, 0, "");
2588 uiDefBut(block, LABEL, 0, "However it can deflect a softbody",10,170,300,20, NULL, 0.0, 0, 0, 0, "");
2589 /* OTHER OBJECTS COLLISION STUFF */
2590 if (ob->type==OB_MESH){
2591 uiBlockBeginAlign(block);
2592 uiDefButBitS(block, TOG, 1, B_REDR, "Deflection",10,50,150,20, &ob->pd->deflect, 0, 0, 0, 0, "Makes this object visible to softbody objects");
2593 if(ob->pd->deflect) {
2594 uiDefButF(block, NUM, B_FIELD_CHANGE, "Damping:", 160,50,150,20, &ob->pd->pdef_sbdamp, 0.0, 1.0, 10, 0, "Amount of damping during soft body collision");
2595 uiDefButBitS(block, TOG,OB_SB_COLLFINAL , B_DIFF, "Ev.M.Stack",10,30,150,20, &ob->softflag, 0, 0, 0, 0, "Pick collision object from modifier stack");
2596 uiDefButF(block, NUM, B_FIELD_CHANGE, "Inner:", 160,30,150,20, &ob->pd->pdef_sbift, 0.001, 1.0, 10, 0, "Inner face thickness");
2597 uiDefButF(block, NUM, B_FIELD_CHANGE, "Outer:", 160,10,150,20, &ob->pd->pdef_sboft, 0.001, 1.0, 10, 0, "Outer face thickness");
2600 uiBlockEndAlign(block);
2602 else{
2603 SoftBody *sb= ob->soft;
2604 /* SELF COLLISION STUFF */
2605 if ((ob->type==OB_MESH)||(ob->type==OB_CURVE) ) {
2606 uiBlockBeginAlign(block);
2607 if (ob->softflag & OB_SB_EDGES){
2608 uiDefButBitS(block, TOG, OB_SB_SELF, B_SOFTBODY_CHANGE, "Self Collision", 10,170,150,20, &ob->softflag, 0, 0, 0, 0, "enable naive vertex ball self collision");
2609 if(ob->softflag & OB_SB_SELF){
2610 uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Ball Size:", 160,170,150,20, &sb->colball, -10.0, 10.0, 10, 0, "Absolute ball size or factor if not manual adjusted");
2611 uiDefButS(block, ROW, B_DIFF, "Man",10,150,60,20, &sb->sbc_mode, 4.0,SBC_MODE_MANUAL, 0, 0, "Manual adjust");
2612 uiDefButS(block, ROW, B_DIFF, "Av",70,150,60,20, &sb->sbc_mode, 4.0,SBC_MODE_AVG, 0, 0, "Average Spring lenght * Ball Size");
2613 uiDefButS(block, ROW, B_DIFF, "Min",130,150,60,20, &sb->sbc_mode, 4.0,SBC_MODE_MIN, 0, 0, "Minimal Spring lenght * Ball Size");
2614 uiDefButS(block, ROW, B_DIFF, "Max",190,150,60,20, &sb->sbc_mode, 4.0,SBC_MODE_MAX, 0, 0, "Maximal Spring lenght * Ball Size");
2615 uiDefButS(block, ROW, B_DIFF, "AvMiMa",250,150,60,20, &sb->sbc_mode, 4.0,SBC_MODE_AVGMINMAX, 0, 0, "(Min+Max)/2 * Ball Size");
2616 uiDefButF(block, NUM, B_DIFF, "B Stiff:", 10,130,150,20, &sb->ballstiff, 0.001, 100.0, 10, 0, "Ball inflating presure");
2617 uiDefButF(block, NUM, B_DIFF, "B Damp:", 160,130,150,20, &sb->balldamp, 0.001, 1.0, 10, 0, "Blending to inelastic collision");
2620 else{
2621 uiDefBut(block, LABEL, 0, "<Self Collision> not available because there",10,170,300,20, NULL, 0.0, 0, 0, 0, "");
2622 uiDefBut(block, LABEL, 0, "are no edges, enable <Use Edges>",10,150,300,20, NULL, 0.0, 0, 0, 0, "");
2625 uiBlockEndAlign(block);
2626 /*SOLVER SETTINGS*/
2627 uiDefButF(block, NUM, B_DIFF, "Error Lim:", 10,100,130,20, &sb->rklimit , 0.001, 10.0, 10, 0, "The Runge-Kutta ODE solver error limit, low value gives more precision, high values speed");
2628 uiDefButBitS(block, TOG, SBSO_OLDERR, B_DIFF,"O", 140,100,20,20, &sb->solverflags, 0, 0, 0, 0, "Old Error Calculation");
2629 uiDefButS(block, NUM, B_DIFF, "Fuzzy:", 160,100,130,20, &sb->fuzzyness, 1.00, 100.0, 10, 0, "Fuzzyness while on collision, high values make collsion handling faster but less stable");
2630 uiDefButBitS(block, TOG, SBSO_MONITOR, B_DIFF,"M", 290,100,20,20, &sb->solverflags, 0, 0, 0, 0, "Turn on SB diagnose console prints");
2631 uiDefButS(block, NUM, B_DIFF, "MinS:", 10,80,100,20, &sb->minloops, 0.00, 30000.0, 10, 0, "Minimal # solver steps/frame ");
2632 uiDefButS(block, NUM, B_DIFF, "MaxS:", 110,80,100,20, &sb->maxloops, 0.00, 30000.0, 10, 0, "Maximal # solver steps/frame ");
2633 uiDefButS(block, NUM, B_DIFF, "Choke:", 210,80,100,20, &sb->choke, 0.00, 100.0, 10, 0, "'Viscosity' inside collision target ");
2635 /* OTHER OBJECTS COLLISION STUFF */
2636 if (ob->type==OB_MESH){
2637 uiDefButBitS(block, TOG, 1, B_REDR, "Deflection",10,50,150,20, &ob->pd->deflect, 0, 0, 0, 0, "Makes this object visible to other softbody objects");
2638 if(ob->pd->deflect) {
2639 uiDefButF(block, NUM, B_DIFF, "Damping:", 160,50,150,20, &ob->pd->pdef_sbdamp, 0.0, 1.0, 10, 0, "Amount of damping during soft body collision");
2640 uiDefButBitS(block, TOG,OB_SB_COLLFINAL , B_DIFF, "Ev.M.Stack",10,30,150,20, &ob->softflag, 0, 0, 0, 0, "Pick collision object from modifier stack");
2641 uiDefButF(block, NUM, B_DIFF, "Inner:", 160,30,150,20, &ob->pd->pdef_sbift, 0.001, 1.0, 10, 0, "Inner face thickness");
2642 uiDefButF(block, NUM, B_DIFF, "Outer:", 160,10,150,20, &ob->pd->pdef_sboft, 0.001, 1.0, 10, 0, "Outer face thickness");
2645 uiDefBut(block, LABEL, 0, "",10,10,1,2, NULL, 0.0, 0, 0, 0, ""); /* tell UI we go to 10,10*/
2647 uiBlockEndAlign(block);
2650 static void object_softbodies(Object *ob)
2652 uiBlock *block;
2653 static int val;
2654 uiBut *but;
2655 if(!_can_softbodies_at_all(ob)) return;
2656 block= uiNewBlock(&curarea->uiblocks, "object_softbodies", UI_EMBOSS, UI_HELV, curarea->win);
2657 if(uiNewPanel(curarea, block, "Soft Body", "Physics", 640, 0, 318, 204)==0) return;
2658 uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
2660 val = modifiers_isSoftbodyEnabled(ob);
2661 but = uiDefButI(block, TOG, REDRAWBUTSOBJECT, "Soft Body", 10,200,130,20, &val, 0, 0, 0, 0, "Sets object to become soft body");
2662 uiButSetFunc(but, object_softbodies__enable, ob, NULL);
2663 uiDefBut(block, LABEL, 0, "",10,10,300,0, NULL, 0.0, 0, 0, 0, ""); /* tell UI we go to 10,10*/
2665 if(modifiers_isSoftbodyEnabled(ob)){
2666 SoftBody *sb= ob->soft;
2667 int defCount;
2668 char *menustr;
2670 if(sb==NULL) {
2671 sb= ob->soft= sbNew();
2672 ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
2675 uiDefButBitS(block, TOG, OB_SB_BAKESET, REDRAWBUTSOBJECT, "Bake settings", 180,200,130,20, &ob->softflag, 0, 0, 0, 0, "To convert simulation into baked (cached) result");
2677 if(sb->keys) uiSetButLock(1, "Soft Body is baked, free it first");
2679 if(ob->softflag & OB_SB_BAKESET) {
2680 uiBlockBeginAlign(block);
2681 uiDefButI(block, NUM, B_DIFF, "Start:", 10, 170,100,20, &sb->sfra, 1.0, 10000.0, 10, 0, "Start frame for baking");
2682 uiDefButI(block, NUM, B_DIFF, "End:", 110, 170,100,20, &sb->efra, 1.0, 10000.0, 10, 0, "End frame for baking");
2683 uiDefButI(block, NUM, B_DIFF, "Interval:", 210, 170,100,20, &sb->interval, 1.0, 10.0, 10, 0, "Interval in frames between baked keys");
2684 uiBlockEndAlign(block);
2686 uiDefButS(block, TOG, B_DIFF, "Local", 10, 145,100,20, &sb->local, 0.0, 0.0, 0, 0, "Use local coordinates for baking");
2689 uiClearButLock();
2690 uiBlockBeginAlign(block);
2692 if(sb->keys) {
2693 char str[128];
2694 uiDefIconTextBut(block, BUT, B_SOFTBODY_BAKE_FREE, ICON_X, "FREE BAKE", 10, 120,300,20, NULL, 0.0, 0.0, 0, 0, "Free baked result");
2695 sprintf(str, "Stored %d vertices %d keys %.3f MB", sb->totpoint, sb->totkey, ((float)16*sb->totpoint*sb->totkey)/(1024.0*1024.0));
2696 uiDefBut(block, LABEL, 0, str, 10, 100,300,20, NULL, 0.0, 0.0, 00, 0, "");
2698 else
2699 uiDefBut(block, BUT, B_SOFTBODY_BAKE, "BAKE", 10, 120,300,20, NULL, 0.0, 0.0, 10, 0, "Start baking. Press ESC to exit without baking");
2702 else {
2703 /* GENERAL STUFF */
2704 static char str[128];
2705 if (sb->totpoint){
2706 sprintf(str, "Vertex Mass; Object mass %f [k]",sb->nodemass*sb->totpoint/1000.0f);
2708 else{
2709 sprintf(str, "Vertex Mass");
2711 uiBlockBeginAlign(block);
2712 uiDefButF(block, NUM, B_DIFF, "Friction:", 10, 170,150,20, &sb->mediafrict, 0.0, 50.0, 10, 0, "General media friction for point movements");
2713 uiDefButF(block, NUM, B_DIFF, "Mass:", 160, 170,150,20, &sb->nodemass , 0.001, 50000.0, 10, 0, str);
2714 uiDefButF(block, NUM, B_DIFF, "Grav:", 10,150,150,20, &sb->grav , 0.0, 10.0, 10, 0, "Apply gravitation to point movement");
2715 uiDefButF(block, NUM, B_DIFF, "Speed:", 160,150,150,20, &sb->physics_speed , 0.01, 100.0, 10, 0, "Tweak timing for physics to control frequency and speed");
2716 uiBlockEndAlign(block);
2718 /* GOAL STUFF */
2719 uiBlockBeginAlign(block);
2720 uiDefButBitS(block, TOG, OB_SB_GOAL, B_SOFTBODY_CHANGE, "Use Goal", 10,120,130,20, &ob->softflag, 0, 0, 0, 0, "Define forces for vertices to stick to animated position");
2721 if (ob->softflag & OB_SB_GOAL){
2722 if(ob->type==OB_MESH) {
2723 menustr= get_vertexgroup_menustr(ob);
2724 defCount=BLI_countlist(&ob->defbase);
2725 if(defCount==0) sb->vertgroup= 0;
2726 uiDefButS(block, MENU, B_SOFTBODY_CHANGE, menustr, 140,120,20,20, &sb->vertgroup, 0, defCount, 0, 0, "Browses available vertex groups");
2727 MEM_freeN (menustr);
2729 if(sb->vertgroup) {
2730 bDeformGroup *defGroup = BLI_findlink(&ob->defbase, sb->vertgroup-1);
2731 if(defGroup)
2732 uiDefBut(block, BUT, B_DIFF, defGroup->name, 160,120,130,20, NULL, 0.0, 0.0, 0, 0, "Name of current vertex group");
2733 else
2734 uiDefBut(block, BUT, B_DIFF, "(no group)", 160,120,130,20, NULL, 0.0, 0.0, 0, 0, "Vertex Group doesn't exist anymore");
2735 uiDefIconBut(block, BUT, B_SOFTBODY_DEL_VG, ICON_X, 290,120,20,20, 0, 0, 0, 0, 0, "Disable use of vertex group");
2737 else
2738 uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Goal:", 160,120,150,20, &sb->defgoal, 0.0, 1.0, 10, 0, "Default Goal (vertex target position) value, when no Vertex Group used");
2740 else {
2741 uiDefButS(block, TOG, B_SOFTBODY_CHANGE, "W", 140,120,20,20, &sb->vertgroup, 0, 1, 0, 0, "Use control point weight values");
2742 uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Goal:", 160,120,150,20, &sb->defgoal, 0.0, 1.0, 10, 0, "Default Goal (vertex target position) value, when no Vertex Group used");
2745 uiDefButF(block, NUM, B_DIFF, "G Stiff:", 10,100,150,20, &sb->goalspring, 0.0, 0.999, 10, 0, "Goal (vertex target position) spring stiffness");
2746 uiDefButF(block, NUM, B_DIFF, "G Damp:", 160,100,150,20, &sb->goalfrict , 0.0, 50.0, 10, 0, "Goal (vertex target position) friction");
2747 uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "G Min:", 10,80,150,20, &sb->mingoal, 0.0, 1.0, 10, 0, "Goal minimum, vertex group weights are scaled to match this range");
2748 uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "G Max:", 160,80,150,20, &sb->maxgoal, 0.0, 1.0, 10, 0, "Goal maximum, vertex group weights are scaled to match this range");
2750 uiBlockEndAlign(block);
2752 /* EDGE SPRING STUFF */
2753 if(ob->type!=OB_SURF) {
2754 uiBlockBeginAlign(block);
2755 uiDefButBitS(block, TOG, OB_SB_EDGES, B_SOFTBODY_CHANGE, "Use Edges", 10,50,90,20, &ob->softflag, 0, 0, 0, 0, "Use Edges as springs");
2756 if (ob->softflag & OB_SB_EDGES){
2757 uiDefButBitS(block, TOG, OB_SB_QUADS, B_SOFTBODY_CHANGE, "Stiff Quads", 110,50,90,20, &ob->softflag, 0, 0, 0, 0, "Adds diagonal springs on 4-gons");
2758 uiDefButBitS(block, TOG, OB_SB_EDGECOLL, B_DIFF, "CEdge", 220,50,45,20, &ob->softflag, 0, 0, 0, 0, "Edge collide too");
2759 uiDefButBitS(block, TOG, OB_SB_FACECOLL, B_DIFF, "CFace", 265,50,45,20, &ob->softflag, 0, 0, 0, 0, "Faces collide too SLOOOOOW warning ");
2760 uiDefButF(block, NUM, B_DIFF, "E Stiff:", 10,30,150,20, &sb->inspring, 0.0, 0.999, 10, 0, "Edge spring stiffness");
2761 uiDefButF(block, NUM, B_DIFF, "E Damp:", 160,30,150,20, &sb->infrict, 0.0, 50.0, 10, 0, "Edge spring friction");
2762 uiDefButS(block, NUM, B_DIFF, "Aero:", 10,10,150,20, &sb->aeroedge, 0.00, 30000.0, 10, 0, "Make edges 'sail'");
2763 if(ob->type==OB_MESH) {
2764 uiDefButF(block, NUM, B_SOFTBODY_CHANGE, "Rigidity:", 160,10,150,20, &sb->secondspring, 0.0, 10.0, 10, 0, "Strenght of Springs over 2 Edges");
2766 else sb->secondspring = 0;
2767 uiDefBut(block, LABEL, 0, "",10,10,1,0, NULL, 0.0, 0, 0, 0, ""); /* tell UI we go to 10,10*/
2769 uiBlockEndAlign(block);
2773 uiBlockEndAlign(block);
2776 static void object_panel_particles_motion(Object *ob)
2778 uiBlock *block;
2779 uiBut *but;
2780 PartEff *paf= give_parteff(ob);
2782 if (paf==NULL) return;
2784 block= uiNewBlock(&curarea->uiblocks, "object_panel_particles_motion", UI_EMBOSS, UI_HELV, curarea->win);
2785 uiNewPanelTabbed("Particles ", "Physics");
2786 if(uiNewPanel(curarea, block, "Particle Motion", "Physics", 320, 0, 318, 204)==0) return;
2788 uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
2790 /* top row */
2791 uiBlockBeginAlign(block);
2792 uiDefButI(block, NUM, B_CALCEFFECT, "Keys:", 0,180,75,20, &paf->totkey, 1.0, 100.0, 0, 0, "Specify the number of key positions");
2793 uiDefButBitS(block, TOG, PAF_BSPLINE, B_CALCEFFECT, "Bspline", 75,180,75,20, &paf->flag, 0, 0, 0, 0, "Use B spline formula for particle interpolation");
2794 uiDefButI(block, NUM, B_CALCEFFECT, "Seed:", 150,180,75,20, &paf->seed, 0.0, 255.0, 0, 0, "Set an offset in the random table");
2795 uiDefButF(block, NUM, B_CALCEFFECT, "RLife:", 225,180,85,20, &paf->randlife, 0.0, 2.0, 10, 1, "Give the particlelife a random variation");
2796 uiBlockEndAlign(block);
2798 /* left collumn */
2799 uiDefBut(block, LABEL, 0, "Velocity:", 0,160,150,20, NULL, 0.0, 0, 0, 0, "");
2800 uiBlockBeginAlign(block);
2801 uiBlockSetCol(block, TH_BUT_SETTING2);
2802 uiDefButF(block, NUM, B_CALCEFFECT, "Normal:", 0,140,150,18, &paf->normfac, -2.0, 2.0, 1, 3, "Let the mesh give the particle a starting speed");
2803 uiDefButF(block, NUM, B_CALCEFFECT, "Object:", 0,122,150,18, &paf->obfac, -1.0, 1.0, 1, 3, "Let the object give the particle a starting speed");
2804 uiDefButF(block, NUM, B_CALCEFFECT, "Random:", 0,104,150,18, &paf->randfac, 0.0, 2.0, 1, 3, "Give the starting speed a random variation");
2805 uiDefButF(block, NUM, B_CALCEFFECT, "Texture:", 0,86,150,18, &paf->texfac, 0.0, 2.0, 1, 3, "Let the texture give the particle a starting speed");
2806 uiDefButF(block, NUM, B_CALCEFFECT, "Damping:", 0,68,150,18, &paf->damp, 0.0, 1.0, 1, 3, "Specify the damping factor");
2807 uiBlockSetCol(block, TH_AUTO);
2808 but=uiDefBut(block, TEX, B_PAF_SET_VG1, "VGroup:", 0,50,150,18, paf->vgroupname_v, 0, 31, 0, 0, "Name of vertex group to use for speed control");
2809 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)OBACT);
2810 uiBlockEndAlign(block);
2812 uiDefBut(block, LABEL, 0, "Texture Emission", 0,30,150,20, NULL, 0.0, 0, 0, 0, "");
2813 uiBlockBeginAlign(block);
2814 uiDefButBitS(block, TOG3, PAF_TEXTIME, B_CALCEFFECT, "TexEmit", 0,10,75,20, &(paf->flag2), 0, 0, 0, 0, "Use a texture to define emission of particles");
2815 uiDefButS(block, NUM, B_CALCEFFECT, "Tex:", 75,10,75,20, &paf->timetex, 1.0, 10.0, 0, 0, "Specify texture used for the texture emission");
2817 /* right collumn */
2818 uiDefIDPoinBut(block, test_grouppoin_but, ID_GR, B_CALCEFFECT, "GR:", 160, 155, 150, 20, &paf->group, "Limit Force Fields to this Group");
2820 uiBlockBeginAlign(block);
2821 uiDefBut(block, LABEL, 0, "Force:", 160,130,75,20, NULL, 0.0, 0, 0, 0, "");
2822 uiDefButF(block, NUM, B_CALCEFFECT, "X:", 235,130,75,20, paf->force, -1.0, 1.0, 1, 2, "Specify the X axis of a continues force");
2823 uiDefButF(block, NUM, B_CALCEFFECT, "Y:", 160,110,75,20, paf->force+1,-1.0, 1.0, 1, 2, "Specify the Y axis of a continues force");
2824 uiDefButF(block, NUM, B_CALCEFFECT, "Z:", 235,110,75,20, paf->force+2, -1.0, 1.0, 1, 2, "Specify the Z axis of a continues force");
2826 uiBlockBeginAlign(block);
2827 uiDefButS(block, NUM, B_CALCEFFECT, "Tex:", 160,80,75,20, &paf->speedtex, 1.0, 10.0, 0, 2, "Specify the texture used for force");
2828 uiDefButF(block, NUM, B_CALCEFFECT, "X:", 235,80,75,20, paf->defvec, -1.0, 1.0, 1, 2, "Specify the X axis of a force, determined by the texture");
2829 uiDefButF(block, NUM, B_CALCEFFECT, "Y:", 160,60,75,20, paf->defvec+1,-1.0, 1.0, 1, 2, "Specify the Y axis of a force, determined by the texture");
2830 uiDefButF(block, NUM, B_CALCEFFECT, "Z:", 235,60,75,20, paf->defvec+2, -1.0, 1.0, 1, 2, "Specify the Z axis of a force, determined by the texture");
2832 uiBlockBeginAlign(block);
2833 uiDefButS(block, ROW, B_CALCEFFECT, "Int", 160,30,50,20, &paf->texmap, 14.0, 0.0, 0, 0, "Use texture intensity as a factor for texture force");
2834 uiDefButS(block, ROW, B_CALCEFFECT, "RGB", 210,30,50,20, &paf->texmap, 14.0, 1.0, 0, 0, "Use RGB values as a factor for particle speed vector");
2835 uiDefButS(block, ROW, B_CALCEFFECT, "Grad", 260,30,50,20, &paf->texmap, 14.0, 2.0, 0, 0, "Use texture gradient as a factor for particle speed vector");
2837 uiDefButF(block, NUM, B_CALCEFFECT, "Nabla:", 160,10,150,20, &paf->nabla, 0.0001f, 1.0, 1, 0, "Specify the dimension of the area for gradient calculation");
2842 static void object_panel_particles(Object *ob)
2844 uiBlock *block;
2845 uiBut *but;
2846 PartEff *paf= give_parteff(ob);
2848 /* the panelname "Particles " has a space to exclude previous saved panel "Particles" */
2849 block= uiNewBlock(&curarea->uiblocks, "object_panel_particles", UI_EMBOSS, UI_HELV, curarea->win);
2850 if(uiNewPanel(curarea, block, "Particles ", "Physics", 320, 0, 318, 204)==0) return;
2852 uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
2854 if (ob->type == OB_MESH) {
2855 uiBlockBeginAlign(block);
2856 if(paf==NULL)
2857 uiDefBut(block, BUT, B_NEWEFFECT, "NEW", 0,180,75,20, 0, 0, 0, 0, 0, "Create a new Particle effect");
2858 else
2859 uiDefBut(block, BUT, B_DELEFFECT, "Delete", 0,180,75,20, 0, 0, 0, 0, 0, "Delete the effect");
2861 else uiDefBut(block, LABEL, 0, "Only Mesh Objects can generate particles", 10,180,300,20, NULL, 0.0, 0, 0, 0, "");
2864 if(paf==NULL) return;
2866 uiDefBut(block, BUT, B_RECALCAL, "RecalcAll", 75,180,75,20, 0, 0, 0, 0, 0, "Update all particle systems");
2867 uiBlockEndAlign(block);
2869 uiDefBut(block, LABEL, 0, "Emit:", 0,150,75,20, NULL, 0.0, 0, 0, 0, "");
2870 uiBlockBeginAlign(block);
2871 uiDefButI(block, NUM, B_CALCEFFECT, "Amount:", 0,130,150,20, &paf->totpart, 1.0, 1000000.0, 0, 0, "The total number of particles");
2872 if(paf->flag & PAF_STATIC) {
2873 uiDefButS(block, NUM, REDRAWVIEW3D, "Step:", 0,110,150,20, &paf->staticstep, 1.0, 100.0, 10, 0, "For static duplicators, the Step value skips particles");
2875 else {
2876 uiDefButF(block, NUM, B_CALCEFFECT, "Sta:", 0,110,75,20, &paf->sta, -250.0, MAXFRAMEF, 100, 1, "Frame # to start emitting particles");
2877 uiDefButF(block, NUM, B_CALCEFFECT, "End:", 75,110,75,20, &paf->end, 1.0, MAXFRAMEF, 100, 1, "Frame # to stop emitting particles");
2879 uiDefButF(block, NUM, B_CALCEFFECT, "Life:", 0,90,75,20, &paf->lifetime, 1.0, MAXFRAMEF, 100, 1, "Specify the life span of the particles");
2880 uiDefButS(block, NUM, B_CALCEFFECT, "Disp:", 75,90,75,20, &paf->disp, 0.0, 100.0, 10, 0, "Percentage of particles to calculate for 3d view");
2881 uiBlockEndAlign(block);
2883 uiDefBut(block, LABEL, 0, "From:", 0,70,75,20, NULL, 0.0, 0, 0, 0, "");
2884 uiBlockBeginAlign(block);
2885 uiDefButBitS(block, TOGN, PAF_OFACE, B_CALCEFFECT, "Verts", 0,50,75,20, &paf->flag, 0, 0, 0, 0, "Emit particles from vertices");
2886 uiDefButBitS(block, TOG, PAF_FACE, B_CALCEFFECT, "Faces", 75,50,75,20, &paf->flag, 0, 0, 0, 0, "Emit particles from faces");
2887 if(paf->flag & PAF_FACE) {
2888 uiDefButBitS(block, TOG, PAF_TRAND, B_CALCEFFECT, "Rand", 0,30,50,20, &paf->flag, 0, 0, 0, 0, "Use true random distribution from faces");
2889 uiDefButBitS(block, TOG, PAF_EDISTR, B_CALCEFFECT, "Even", 50,30,50,20, &paf->flag, 0, 0, 0, 0, "Use even distribution from faces based on face areas");
2890 uiDefButS(block, NUM, B_CALCEFFECT, "P/F:", 100,30,50,20, &paf->userjit, 0.0, 200.0, 1, 0, "Jitter table distribution: maximum particles per face (0=uses default)");
2892 else uiBlockEndAlign(block); /* vgroup button no align */
2894 but=uiDefBut(block, TEX, B_PAF_SET_VG, "VGroup:", 0,10,150,20, paf->vgroupname, 0, 31, 0, 0, "Name of vertex group to use");
2895 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)OBACT);
2896 uiBlockEndAlign(block);
2898 /* right collumn */
2899 uiBlockBeginAlign(block);
2900 uiDefButBitS(block, TOG, PAF_STATIC, B_EFFECT_DEP, "Static", 160,180,75,20, &paf->flag, 0, 0, 0, 0, "Make static particles (deform only works with SubSurf)");
2901 if(paf->flag & PAF_STATIC) {
2902 uiDefButBitS(block, TOG, PAF_ANIMATED, B_DIFF, "Animated", 235,180,75,20, &paf->flag, 0, 0, 0, 0, "Static particles are recalculated each rendered frame");
2904 uiBlockEndAlign(block);
2906 uiDefBut(block, LABEL, 0, "Display:", 160,150,75,20, NULL, 0.0, 0, 0, 0, "");
2907 uiBlockBeginAlign(block);
2908 uiDefButS(block, NUM, B_CALCEFFECT, "Material:", 160,130,150,20, &paf->omat, 1.0, 16.0, 0, 0, "Specify material used for the particles");
2909 uiDefButS(block, TOG|BIT|7, B_REDR, "Mesh", 160,110,50,20, &paf->flag, 0, 0, 0, 0, "Render emitter Mesh also");
2910 uiDefButBitS(block, TOG, PAF_UNBORN, B_DIFF, "Unborn",210,110,50,20, &paf->flag, 0, 0, 0, 0, "Make particles appear before they are emitted");
2911 uiDefButBitS(block, TOG, PAF_DIED, B_DIFF, "Died", 260,110,50,20, &paf->flag, 0, 0, 0, 0, "Make particles appear after they have died");
2912 uiDefButS(block, TOG, REDRAWVIEW3D, "Vect", 160,90,75,20, &paf->stype, 0, 0, 0, 0, "Give the particles a direction and rotation");
2913 if(paf->flag & PAF_STATIC)
2914 uiDefButF(block, NUM, B_CALCEFFECT, "Max:", 235,90,75,20, &paf->maxlen, 0.0, 100.0, 10, 1, "The maximum length of a particle strand (zero is no limit)");
2915 else
2916 uiDefButF(block, NUM, B_CALCEFFECT, "Size:", 235,90,75,20, &paf->vectsize, 0.0, 1.0, 10, 1, "The amount the Vect option influences halo size");
2917 uiBlockEndAlign(block);
2919 uiDefBut(block, LABEL, 0, "Children:", 160,70,75,20, NULL, 0.0, 0, 0, 0, "");
2920 uiBlockBeginAlign(block);
2921 uiDefButS(block, NUM, B_REDR, "Generation:", 160,50,150,20, &paf->curmult, 0.0, 3.0, 0, 0, "Current generation of particles");
2922 uiDefButS(block, NUM, B_CALCEFFECT, "Num:", 160,30,75,20, paf->child+paf->curmult, 1.0, 600.0, 100, 0, "Specify the number of generations of particles that can multiply itself");
2923 uiDefButF(block, NUM, B_CALCEFFECT, "Prob:", 235,30,75,20, paf->mult+paf->curmult, 0.0, 1.0, 10, 1, "Probability \"dying\" particle spawns a new one.");
2924 uiDefButF(block, NUM, B_CALCEFFECT, "Life:", 160,10,75,20, paf->life+paf->curmult, 1.0, 600.0, 100, 1, "Specify the lifespan of the next generation particles");
2925 uiDefButS(block, NUM, B_CALCEFFECT, "Mat:", 235,10,75,20, paf->mat+paf->curmult, 1.0, 8.0, 0, 0, "Specify the material used for the particles");
2926 uiBlockEndAlign(block);
2930 /* NT - Panel for fluidsim settings */
2931 static void object_panel_fluidsim(Object *ob)
2933 #ifndef DISABLE_ELBEEM
2934 uiBlock *block;
2935 int yline = 160;
2936 const int lineHeight = 20;
2937 const int separateHeight = 3;
2938 const int objHeight = 20;
2939 char *msg = NULL;
2941 block= uiNewBlock(&curarea->uiblocks, "object_fluidsim", UI_EMBOSS, UI_HELV, curarea->win);
2942 if(uiNewPanel(curarea, block, "Fluid Simulation", "Physics", 1060, 0, 318, 204)==0) return;
2944 uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
2946 if(ob->type==OB_MESH) {
2947 if(((Mesh *)ob->data)->totvert == 0) {
2948 msg = "Mesh has no vertices.";
2949 goto errMessage;
2951 uiDefButBitS(block, TOG, OB_FLUIDSIM_ENABLE, REDRAWBUTSOBJECT, "Enable", 0,yline, 75,objHeight,
2952 &ob->fluidsimFlag, 0, 0, 0, 0, "Sets object to participate in fluid simulation");
2954 if(ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) {
2955 FluidsimSettings *fss= ob->fluidsimSettings;
2957 if(fss==NULL) {
2958 fss = ob->fluidsimSettings = fluidsimSettingsNew(ob);
2961 uiBlockBeginAlign(block);
2962 uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Domain", 90, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_DOMAIN, 20.0, 1.0, "Bounding box of this object represents the computational domain of the fluid simulation.");
2963 uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Fluid", 160, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_FLUID, 20.0, 2.0, "Object represents a volume of fluid in the simulation.");
2964 uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Obstacle", 230, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_OBSTACLE,20.0, 3.0, "Object is a fixed obstacle.");
2965 yline -= lineHeight;
2967 uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Inflow", 90, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_INFLOW, 20.0, 4.0, "Object adds fluid to the simulation.");
2968 uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Outflow", 160, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_OUTFLOW, 20.0, 5.0, "Object removes fluid from the simulation.");
2969 uiDefButS(block, ROW, B_FLUIDSIM_MAKEPART ,"Particle", 230, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_PARTICLE,20.0, 3.0, "Object is made a particle system to display particles generated by a fluidsim domain object.");
2970 uiBlockEndAlign(block);
2971 yline -= lineHeight;
2972 yline -= 2*separateHeight;
2974 /* display specific settings for each type */
2975 if(fss->type == OB_FLUIDSIM_DOMAIN) {
2976 const int maxRes = 512;
2977 char memString[32];
2979 // use mesh bounding box and object scaling
2980 // TODO fix redraw issue
2981 elbeemEstimateMemreq(fss->resolutionxyz,
2982 ob->fluidsimSettings->bbSize[0],ob->fluidsimSettings->bbSize[1],ob->fluidsimSettings->bbSize[2], fss->maxRefine, memString);
2984 uiBlockBeginAlign(block);
2985 uiDefButS(block, ROW, REDRAWBUTSOBJECT, "Std", 0,yline, 25,objHeight, &fss->show_advancedoptions, 16.0, 0, 20.0, 0, "Show standard domain options.");
2986 uiDefButS(block, ROW, REDRAWBUTSOBJECT, "Adv", 25,yline, 25,objHeight, &fss->show_advancedoptions, 16.0, 1, 20.0, 1, "Show advanced domain options.");
2987 uiDefButS(block, ROW, REDRAWBUTSOBJECT, "Bnd", 50,yline, 25,objHeight, &fss->show_advancedoptions, 16.0, 2, 20.0, 2, "Show domain boundary options.");
2988 uiBlockEndAlign(block);
2990 uiDefBut(block, BUT, B_FLUIDSIM_BAKE, "BAKE",90, yline,210,objHeight, NULL, 0.0, 0.0, 10, 0, "Perform simulation and output and surface&preview meshes for each frame.");
2991 yline -= lineHeight;
2992 yline -= 2*separateHeight;
2994 if(fss->show_advancedoptions == 0) {
2995 uiDefBut(block, LABEL, 0, "Req. BAKE Memory:", 0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "");
2996 uiDefBut(block, LABEL, 0, memString, 200,yline,100,objHeight, NULL, 0.0, 0, 0, 0, "");
2997 yline -= lineHeight;
2999 uiBlockBeginAlign(block);
3000 uiDefButS(block, NUM, REDRAWBUTSOBJECT, "Resolution:", 0, yline,150,objHeight, &fss->resolutionxyz, 1, maxRes, 10, 0, "Domain resolution in X, Y and Z direction");
3001 uiDefButS(block, NUM, B_DIFF, "Preview-Res.:", 150, yline,150,objHeight, &fss->previewresxyz, 1, 100, 10, 0, "Resolution of the preview meshes to generate, also in X, Y and Z direction");
3002 uiBlockEndAlign(block);
3003 yline -= lineHeight;
3004 yline -= 1*separateHeight;
3006 uiBlockBeginAlign(block);
3007 uiDefButF(block, NUM, B_DIFF, "Start time:", 0, yline,150,objHeight, &fss->animStart, 0.0, 100.0, 10, 0, "Simulation time of the first blender frame.");
3008 uiDefButF(block, NUM, B_DIFF, "End time:", 150, yline,150,objHeight, &fss->animEnd , 0.0, 100.0, 10, 0, "Simulation time of the last blender frame.");
3009 uiBlockEndAlign(block);
3010 yline -= lineHeight;
3011 yline -= 2*separateHeight;
3013 if((fss->guiDisplayMode<1) || (fss->guiDisplayMode>3)){ fss->guiDisplayMode=2; } // can be changed by particle setting
3014 uiDefBut(block, LABEL, 0, "Disp.-Qual.:", 0,yline, 90,objHeight, NULL, 0.0, 0, 0, 0, "");
3015 uiBlockBeginAlign(block);
3016 uiDefButS(block, MENU, B_FLUIDSIM_FORCEREDRAW, "GuiDisplayMode%t|Geometry %x1|Preview %x2|Final %x3",
3017 90,yline,105,objHeight, &fss->guiDisplayMode, 0, 0, 0, 0, "How to display the fluid mesh in the Blender GUI.");
3018 uiDefButS(block, MENU, B_DIFF, "RenderDisplayMode%t|Geometry %x1|Preview %x2|Final %x3",
3019 195,yline,105,objHeight, &fss->renderDisplayMode, 0, 0, 0, 0, "How to display the fluid mesh for rendering.");
3020 uiBlockEndAlign(block);
3021 yline -= lineHeight;
3022 yline -= 1*separateHeight;
3024 uiBlockBeginAlign(block);
3025 uiDefIconBut(block, BUT, B_FLUIDSIM_SELDIR, ICON_FILESEL, 0, yline, 20, objHeight, 0, 0, 0, 0, 0, "Select Directory (and/or filename prefix) to store baked fluid simulation files in");
3026 uiDefBut(block, TEX, B_FLUIDSIM_FORCEREDRAW,"", 20, yline, 280, objHeight, fss->surfdataPath, 0.0,79.0, 0, 0, "Enter Directory (and/or filename prefix) to store baked fluid simulation files in");
3027 uiBlockEndAlign(block);
3028 // FIXME what is the 79.0 above?
3029 } else if(fss->show_advancedoptions == 1) {
3030 // advanced options
3031 uiDefBut(block, LABEL, 0, "Gravity:", 0, yline, 90,objHeight, NULL, 0.0, 0, 0, 0, "");
3032 uiBlockBeginAlign(block);
3033 uiDefButF(block, NUM, B_DIFF, "X:", 90, yline, 70,objHeight, &fss->gravx, -1000.1, 1000.1, 10, 0, "Gravity in X direction");
3034 uiDefButF(block, NUM, B_DIFF, "Y:", 160, yline, 70,objHeight, &fss->gravy, -1000.1, 1000.1, 10, 0, "Gravity in Y direction");
3035 uiDefButF(block, NUM, B_DIFF, "Z:", 230, yline, 70,objHeight, &fss->gravz, -1000.1, 1000.1, 10, 0, "Gravity in Z direction");
3036 uiBlockEndAlign(block);
3037 yline -= lineHeight;
3038 yline -= 1*separateHeight;
3040 /* viscosity */
3041 if (fss->viscosityMode==1) /*manual*/
3042 uiBlockBeginAlign(block);
3043 uiDefButS(block, MENU, REDRAWVIEW3D, "Viscosity%t|Manual %x1|Water %x2|Oil %x3|Honey %x4",
3044 0,yline, 90,objHeight, &fss->viscosityMode, 0, 0, 0, 0, "Set viscosity of the fluid to a preset value, or use manual input.");
3045 if(fss->viscosityMode==1) {
3046 uiDefButF(block, NUM, B_DIFF, "Value:", 90, yline, 105,objHeight, &fss->viscosityValue, 0.0, 10.0, 10, 0, "Viscosity setting: value that is multiplied by 10 to the power of (exponent*-1).");
3047 uiDefButS(block, NUM, B_DIFF, "Neg-Exp.:", 195, yline, 105,objHeight, &fss->viscosityExponent, 0, 10, 10, 0, "Negative exponent for the viscosity value (to simplify entering small values e.g. 5*10^-6.");
3048 uiBlockEndAlign(block);
3049 } else {
3050 // display preset values
3051 uiDefBut(block, LABEL, 0, fluidsimViscosityPresetString[fss->viscosityMode], 90,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
3053 yline -= lineHeight;
3054 yline -= 1*separateHeight;
3056 uiDefBut(block, LABEL, 0, "Realworld-size:", 0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "");
3057 uiDefButF(block, NUM, B_DIFF, "", 150, yline,150,objHeight, &fss->realsize, 0.001, 10.0, 10, 0, "Size of the simulation domain in meters.");
3058 yline -= lineHeight;
3059 yline -= 2*separateHeight;
3061 uiDefBut(block, LABEL, 0, "Gridlevels:", 0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "");
3062 uiDefButI(block, NUM, B_DIFF, "", 150, yline,150,objHeight, &fss->maxRefine, -1, 4, 10, 0, "Number of coarsened Grids to use (set to -1 for automatic selection).");
3063 yline -= lineHeight;
3065 uiDefBut(block, LABEL, 0, "Compressibility:", 0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "");
3066 uiDefButF(block, NUM, B_DIFF, "", 150, yline,150,objHeight, &fss->gstar, 0.001, 0.10, 10,0, "Allowed compressibility due to gravitational force for standing fluid (directly affects simulation step size).");
3067 yline -= lineHeight;
3069 } else if(fss->show_advancedoptions == 2) {
3070 // copied from obstacle...
3071 //yline -= lineHeight + 5;
3072 //uiDefBut(block, LABEL, 0, "Domain boundary type settings:", 0,yline,300,objHeight, NULL, 0.0, 0, 0, 0, "");
3073 //yline -= lineHeight;
3075 uiBlockBeginAlign(block); // domain
3076 uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Noslip", 0, yline,100,objHeight, &fss->typeFlags, 15.0, OB_FSBND_NOSLIP, 20.0, 1.0, "Obstacle causes zero normal and tangential velocity (=sticky). Default for all. Only option for moving objects.");
3077 uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Part", 100, yline,100,objHeight, &fss->typeFlags, 15.0, OB_FSBND_PARTSLIP, 20.0, 2.0, "Mix between no-slip and free-slip. Non moving objects only!");
3078 uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Free", 200, yline,100,objHeight, &fss->typeFlags, 15.0, OB_FSBND_FREESLIP, 20.0, 3.0, "Obstacle only causes zero normal velocity (=not sticky). Non moving objects only!");
3079 uiBlockEndAlign(block);
3080 yline -= lineHeight;
3082 if(fss->typeFlags&OB_FSBND_PARTSLIP) {
3083 uiDefBut(block, LABEL, 0, "PartSlipValue:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
3084 uiDefButF(block, NUM, B_DIFF, "", 200, yline,100,objHeight, &fss->partSlipValue, 0.0, 1.0, 10,0, ".");
3085 yline -= lineHeight;
3086 } else {
3087 //uiDefBut(block, LABEL, 0, "-", 200,yline,100,objHeight, NULL, 0.0, 0, 0, 0, "");
3089 // copied from obstacle...
3091 uiDefBut(block, LABEL, 0, "Tracer Particles:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
3092 uiDefButI(block, NUM, B_DIFF, "", 200, yline,100,objHeight, &fss->generateTracers, 0.0, 10000.0, 10,0, "Number of tracer particles to generate.");
3093 yline -= lineHeight;
3094 uiDefBut(block, LABEL, 0, "Generate Particles:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
3095 uiDefButF(block, NUM, B_DIFF, "", 200, yline,100,objHeight, &fss->generateParticles, 0.0, 10.0, 10,0, "Amount of particles to generate (0=off, 1=normal, >1=more).");
3096 yline -= lineHeight;
3097 uiDefBut(block, LABEL, 0, "Surface Subdiv:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
3098 uiDefButI(block, NUM, B_DIFF, "", 200, yline,100,objHeight, &fss->surfaceSubdivs, 0.0, 5.0, 10,0, "Number of isosurface subdivisions. This is necessary for the inclusion of particles into the surface generation. Warning - can lead to longer computation times!");
3099 yline -= lineHeight;
3101 uiDefBut(block, LABEL, 0, "Surface Smoothing:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
3102 uiDefButF(block, NUM, B_DIFF, "", 200, yline,100,objHeight, &fss->surfaceSmoothing, 0.0, 5.0, 10,0, "Amount of surface smoothing (0=off, 1=normal, >1=stronger smoothing).");
3103 yline -= lineHeight;
3105 // use new variable...
3106 uiDefBut(block, LABEL, 0, "Generate&Use SpeedVecs:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
3107 uiDefButBitC(block, TOG, 1, REDRAWBUTSOBJECT, "Disable", 200, yline,100,objHeight, &fss->domainNovecgen, 0, 0, 0, 0, "Default is to generate and use fluidsim vertex speed vectors, this option switches calculation off during bake, and disables loading.");
3108 yline -= lineHeight;
3109 } // domain 3
3111 else if(
3112 (fss->type == OB_FLUIDSIM_FLUID)
3113 || (fss->type == OB_FLUIDSIM_INFLOW)
3115 uiBlockBeginAlign(block); // fluid
3116 uiDefButC(block, ROW, REDRAWBUTSOBJECT ,"Init Volume", 0, yline,100,objHeight, &fss->volumeInitType, 15.0, 1, 20.0, 1.0, "Type of volume init: use only inner region of mesh.");
3117 uiDefButC(block, ROW, REDRAWBUTSOBJECT ,"Init Shell", 100, yline,100,objHeight, &fss->volumeInitType, 15.0, 2, 20.0, 2.0, "Type of volume init: use only the hollow shell defined by the faces of the mesh.");
3118 uiDefButC(block, ROW, REDRAWBUTSOBJECT ,"Init Both", 200, yline,100,objHeight, &fss->volumeInitType, 15.0, 3, 20.0, 3.0, "Type of volume init: use both the inner volume and the outer shell.");
3119 uiBlockEndAlign(block);
3120 yline -= lineHeight;
3122 yline -= lineHeight + 5; // fluid + inflow
3123 if(fss->type == OB_FLUIDSIM_FLUID) uiDefBut(block, LABEL, 0, "Initial velocity:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
3124 if(fss->type == OB_FLUIDSIM_INFLOW) uiDefBut(block, LABEL, 0, "Inflow velocity:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
3125 yline -= lineHeight;
3126 uiBlockBeginAlign(block);
3127 uiDefButF(block, NUM, B_DIFF, "X:", 0, yline, 100,objHeight, &fss->iniVelx, -1000.1, 1000.1, 10, 0, "Fluid velocity in X direction");
3128 uiDefButF(block, NUM, B_DIFF, "Y:", 100, yline, 100,objHeight, &fss->iniVely, -1000.1, 1000.1, 10, 0, "Fluid velocity in Y direction");
3129 uiDefButF(block, NUM, B_DIFF, "Z:", 200, yline, 100,objHeight, &fss->iniVelz, -1000.1, 1000.1, 10, 0, "Fluid velocity in Z direction");
3130 uiBlockEndAlign(block);
3131 yline -= lineHeight;
3133 if(fss->type == OB_FLUIDSIM_INFLOW) { // inflow
3134 uiDefBut(block, LABEL, 0, "Local Inflow Coords", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
3135 uiDefButBitS(block, TOG, OB_FSINFLOW_LOCALCOORD, REDRAWBUTSOBJECT, "Enable", 200, yline,100,objHeight, &fss->typeFlags, 0, 0, 0, 0, "Use local coordinates for inflow (e.g. for rotating objects).");
3136 yline -= lineHeight;
3137 } else {
3140 // domainNovecgen "misused" here
3141 uiDefBut(block, LABEL, 0, "Animated Mesh:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
3142 uiDefButBitC(block, TOG, 1, REDRAWBUTSOBJECT, "Export", 200, yline,100,objHeight, &fss->domainNovecgen, 0, 0, 0, 0, "Export this mesh as an animated one. Slower, only use if really necessary (e.g. armatures or parented objects), animated pos/rot/scale IPOs do not require it.");
3143 yline -= lineHeight;
3145 } // fluid inflow
3146 else if( (fss->type == OB_FLUIDSIM_OUTFLOW) ) {
3147 yline -= lineHeight + 5;
3149 uiBlockBeginAlign(block); // outflow
3150 uiDefButC(block, ROW, REDRAWBUTSOBJECT ,"Init Volume", 0, yline,100,objHeight, &fss->volumeInitType, 15.0, 1, 20.0, 1.0, "Type of volume init: use only inner region of mesh.");
3151 uiDefButC(block, ROW, REDRAWBUTSOBJECT ,"Init Shell", 100, yline,100,objHeight, &fss->volumeInitType, 15.0, 2, 20.0, 2.0, "Type of volume init: use only the hollow shell defined by the faces of the mesh.");
3152 uiDefButC(block, ROW, REDRAWBUTSOBJECT ,"Init Both", 200, yline,100,objHeight, &fss->volumeInitType, 15.0, 3, 20.0, 3.0, "Type of volume init: use both the inner volume and the outer shell.");
3153 uiBlockEndAlign(block);
3154 yline -= lineHeight;
3156 // domainNovecgen "misused" here
3157 uiDefBut(block, LABEL, 0, "Animated Mesh:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
3158 uiDefButBitC(block, TOG, 1, REDRAWBUTSOBJECT, "Export", 200, yline,100,objHeight, &fss->domainNovecgen, 0, 0, 0, 0, "Export this mesh as an animated one. Slower, only use if really necessary (e.g. armatures or parented objects), animated pos/rot/scale IPOs do not require it.");
3159 yline -= lineHeight;
3161 //uiDefBut(block, LABEL, 0, "No additional settings as of now...", 0,yline,300,objHeight, NULL, 0.0, 0, 0, 0, "");
3163 else if( (fss->type == OB_FLUIDSIM_OBSTACLE) ) {
3164 yline -= lineHeight + 5; // obstacle
3166 uiBlockBeginAlign(block); // obstacle
3167 uiDefButC(block, ROW, REDRAWBUTSOBJECT ,"Init Volume", 0, yline,100,objHeight, &fss->volumeInitType, 15.0, 1, 20.0, 1.0, "Type of volume init: use only inner region of mesh.");
3168 uiDefButC(block, ROW, REDRAWBUTSOBJECT ,"Init Shell", 100, yline,100,objHeight, &fss->volumeInitType, 15.0, 2, 20.0, 2.0, "Type of volume init: use only the hollow shell defined by the faces of the mesh.");
3169 uiDefButC(block, ROW, REDRAWBUTSOBJECT ,"Init Both", 200, yline,100,objHeight, &fss->volumeInitType, 15.0, 3, 20.0, 3.0, "Type of volume init: use both the inner volume and the outer shell.");
3170 uiBlockEndAlign(block);
3171 yline -= lineHeight;
3173 uiBlockBeginAlign(block); // obstacle
3174 uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Noslip", 0, yline,100,objHeight, &fss->typeFlags, 15.0, OB_FSBND_NOSLIP, 20.0, 1.0, "Obstacle causes zero normal and tangential velocity (=sticky). Default for all. Only option for moving objects.");
3175 uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Part", 100, yline,100,objHeight, &fss->typeFlags, 15.0, OB_FSBND_PARTSLIP, 20.0, 2.0, "Mix between no-slip and free-slip. Non moving objects only!");
3176 uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Free", 200, yline,100,objHeight, &fss->typeFlags, 15.0, OB_FSBND_FREESLIP, 20.0, 3.0, "Obstacle only causes zero normal velocity (=not sticky). Non moving objects only!");
3177 uiBlockEndAlign(block);
3178 yline -= lineHeight;
3180 // domainNovecgen "misused" here
3181 uiDefBut(block, LABEL, 0, "Animated Mesh:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
3182 uiDefButBitC(block, TOG, 1, REDRAWBUTSOBJECT, "Export", 200, yline,100,objHeight, &fss->domainNovecgen, 0, 0, 0, 0, "Export this mesh as an animated one. Slower, only use if really necessary (e.g. armatures or parented objects), animated loc/rot/scale IPOs do not require it.");
3183 yline -= lineHeight;
3185 uiDefBut(block, LABEL, 0, "PartSlip Amount:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
3186 if(fss->typeFlags&OB_FSBND_PARTSLIP) {
3187 uiDefButF(block, NUM, B_DIFF, "", 200, yline,100,objHeight, &fss->partSlipValue, 0.0, 1.0, 10,0, "Amount of mixing between no- and free-slip, 0=stickier, 1=same as free slip.");
3188 } else { uiDefBut(block, LABEL, 0, "-", 200,yline,100,objHeight, NULL, 0.0, 0, 0, 0, ""); }
3189 yline -= lineHeight;
3191 // generateParticles "misused" here
3192 uiDefBut(block, LABEL, 0, "Impact Factor:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
3193 uiDefButF(block, NUM, B_DIFF, "", 200, yline,100,objHeight, &fss->surfaceSmoothing, -2.0, 10.0, 10,0, "This is an unphysical value for moving objects - it controls the impact an obstacle has on the fluid, =0 behaves a bit like outflow (deleting fluid), =1 is default, while >1 results in high forces. Can be used to tweak total mass.");
3194 yline -= lineHeight;
3196 yline -= lineHeight; // obstacle
3198 else if(fss->type == OB_FLUIDSIM_PARTICLE) {
3200 //fss->type == 0; // off, broken...
3201 if(1) {
3202 // limited selection, old fixed: fss->typeFlags = (1<<5)|(1<<1);
3203 # define PARTBUT_WIDTH (300/3)
3204 uiDefButBitS(block, TOG, (1<<2) , REDRAWBUTSOBJECT, "Drops", 0*PARTBUT_WIDTH, yline, PARTBUT_WIDTH,objHeight, &fss->typeFlags, 0, 0, 0, 0, "Show drop particles.");
3205 uiDefButBitS(block, TOG, (1<<4) , REDRAWBUTSOBJECT, "Floats", 1*PARTBUT_WIDTH, yline, PARTBUT_WIDTH,objHeight, &fss->typeFlags, 0, 0, 0, 0, "Show floating foam particles.");
3206 uiDefButBitS(block, TOG, (1<<5) , REDRAWBUTSOBJECT, "Tracer", 2*PARTBUT_WIDTH, yline, PARTBUT_WIDTH,objHeight, &fss->typeFlags, 0, 0, 0, 0, "Show tracer particles.");
3207 yline -= lineHeight;
3208 # undef PARTBUT_WIDTH
3211 uiDefBut(block, LABEL, 0, "Size Influence:", 0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "");
3212 uiDefButF(block, NUM, B_DIFF, "", 150, yline,150,objHeight, &fss->particleInfSize, 0.0, 2.0, 10,0, "Amount of particle size scaling: 0=off (all same size), 1=full (range 0.2-2.0), >1=stronger.");
3213 yline -= lineHeight;
3214 uiDefBut(block, LABEL, 0, "Alpha Influence:", 0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "");
3215 uiDefButF(block, NUM, B_DIFF, "", 150, yline,150,objHeight, &fss->particleInfAlpha, 0.0, 2.0, 10,0, "Amount of particle alpha change, inverse of size influence: 0=off (all same alpha), 1=full (large particles get lower alphas, smaller ones higher values).");
3216 yline -= lineHeight;
3218 yline -= 1*separateHeight;
3220 // FSPARTICLE also select input files
3221 uiBlockBeginAlign(block);
3222 uiDefIconBut(block, BUT, B_FLUIDSIM_SELDIR, ICON_FILESEL, 0, yline, 20, objHeight, 0, 0, 0, 0, 0, "Select fluid simulation bake directory/prefix to load particles from, same as for domain object.");
3223 uiDefBut(block, TEX, B_FLUIDSIM_FORCEREDRAW,"", 20, yline, 280, objHeight, fss->surfdataPath, 0.0,79.0, 0, 0, "Enter fluid simulation bake directory/prefix to load particles from, same as for domain object.");
3224 uiBlockEndAlign(block);
3225 yline -= lineHeight;
3226 } // disabled for now...
3229 else {
3230 yline -= lineHeight + 5;
3231 /* not yet set */
3232 uiDefBut(block, LABEL, 0, "Select object type for simulation", 0,yline,300,objHeight, NULL, 0.0, 0, 0, 0, "");
3233 yline -= lineHeight;
3235 return;
3237 } else {
3238 msg = "Object not enabled for fluid simulation...";
3240 } else {
3241 msg = "Only Mesh Objects can participate.";
3243 errMessage:
3244 yline -= lineHeight + 5;
3245 uiDefBut(block, LABEL, 0, msg, 0,yline,300,objHeight, NULL, 0.0, 0, 0, 0, "");
3246 yline -= lineHeight;
3248 #endif // DISABLE_ELBEEM
3251 void object_panels()
3253 Object *ob;
3255 /* check context here */
3256 ob= OBACT;
3257 if(ob) {
3258 object_panel_object(ob);
3259 object_panel_anim(ob);
3260 object_panel_draw(ob);
3261 object_panel_constraint("Object");
3263 uiClearButLock();
3267 void physics_panels()
3269 Object *ob;
3271 /* check context here */
3272 ob= OBACT;
3273 if(ob) {
3274 object_panel_fields(ob);
3275 object_panel_particles(ob);
3276 object_panel_particles_motion(ob);
3277 object_softbodies(ob);
3278 object_softbodies_II(ob);
3279 object_panel_fluidsim(ob);