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
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 *****
42 #include "MEM_guardedalloc.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"
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"
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"
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"
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"
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;
155 /* ********************* CONSTRAINT ***************************** */
157 static void constraint_active_func(void *ob_v, void *con_v)
163 /* lets be nice and escape if its active already */
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)
189 list = get_active_constraints(ob);
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)
206 /* todo; check object if it has ob-level action ipo */
208 if (ob->flag & OB_POSEMODE) {
211 pchan = get_active_posechannel(ob);
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)
224 bConstraint *con = con_v;
227 /* verifies if active constraint is set and shown in UI */
228 constraint_active_func(ob_v, con_v);
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 */
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)
247 bConstraint *con = con_v;
251 /* verifies if active constraint is set and shown in UI */
252 constraint_active_func(ob_v, con_v);
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);
261 error("Cannot get a curve from this IPO, may be dealing with linked data");
266 insert_vert_icu(icu, get_action_frame(ob, (float)CFRA), con->enforce, 0);
268 insert_vert_icu(icu, CFRA, con->enforce, 0);
270 /* make sure ipowin shows it */
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;
285 /* remove ipo channel */
286 lb= get_active_constraint_channels(ob_v, 0);
288 chan = get_constraint_channel(lb, con->name);
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)
313 bConstraint *con= con_v;
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;
333 case CONSTRAINT_TYPE_PYTHON:
334 strcpy(str, "Script");
336 case CONSTRAINT_TYPE_CHILDOF:
337 strcpy(str, "Child Of");
339 case CONSTRAINT_TYPE_NULL:
342 case CONSTRAINT_TYPE_TRACKTO:
343 strcpy(str, "Track To");
345 case CONSTRAINT_TYPE_MINMAX:
346 strcpy(str, "Floor");
348 case CONSTRAINT_TYPE_KINEMATIC:
349 strcpy(str, "IK Solver");
351 case CONSTRAINT_TYPE_ROTLIKE:
352 strcpy(str, "Copy Rotation");
354 case CONSTRAINT_TYPE_LOCLIKE:
355 strcpy(str, "Copy Location");
357 case CONSTRAINT_TYPE_SIZELIKE:
358 strcpy(str, "Copy Scale");
360 case CONSTRAINT_TYPE_ACTION:
361 strcpy(str, "Action");
363 case CONSTRAINT_TYPE_LOCKTRACK:
364 strcpy(str, "Locked Track");
366 case CONSTRAINT_TYPE_FOLLOWPATH:
367 strcpy(str, "Follow Path");
369 case CONSTRAINT_TYPE_STRETCHTO:
370 strcpy(str, "Stretch To");
372 case CONSTRAINT_TYPE_LOCLIMIT:
373 strcpy(str, "Limit Location");
375 case CONSTRAINT_TYPE_ROTLIMIT:
376 strcpy(str, "Limit Rotation");
378 case CONSTRAINT_TYPE_SIZELIMIT:
379 strcpy(str, "Limit Scale");
381 case CONSTRAINT_TYPE_RIGIDBODYJOINT:
382 strcpy(str, "Rigid Body");
384 case CONSTRAINT_TYPE_CLAMPTO:
385 strcpy(str, "Clamp To");
387 case CONSTRAINT_TYPE_TRANSFORM:
388 strcpy(str, "Transformation");
391 strcpy (str, "Unknown");
396 void const_moveUp(void *ob_v, void *con_v)
398 bConstraint *con, *constr= con_v;
402 conlist = get_active_constraints(ob_v);
403 for(con= conlist->first; con; con= con->next) {
405 BLI_remlink(conlist, con);
406 BLI_insertlink(conlist, con->prev->prev, con);
413 static void constraint_moveUp(void *ob_v, void *con_v)
415 const_moveUp(ob_v, con_v);
416 BIF_undo_push("Move constraint");
419 void const_moveDown(void *ob_v, void *con_v)
421 bConstraint *con, *constr= con_v;
425 conlist = get_active_constraints(ob_v);
426 for(con= conlist->first; con; con= con->next) {
428 BLI_remlink(conlist, con);
429 BLI_insertlink(conlist, con->next, con);
436 static void constraint_moveDown(void *ob_v, void *con_v)
438 const_moveDown(ob_v, con_v);
439 BIF_undo_push("Move constraint");
442 /* autocomplete callback for buttons */
443 void autocomplete_bone(char *str, void *arg_v)
445 Object *ob= (Object *)arg_v;
447 if(ob==NULL || ob->pose==NULL) return;
449 /* search if str matches the beginning of name */
451 AutoComplete *autocpl= autocomplete_begin(str, 32);
454 for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next)
455 autocomplete_do_name(autocpl, pchan->name);
457 autocomplete_end(autocpl, str);
461 /* autocomplete callback for buttons */
462 void autocomplete_vgroup(char *str, void *arg_v)
464 Object *ob= (Object *)arg_v;
468 /* search if str matches the beginning of a name */
470 AutoComplete *autocpl= autocomplete_begin(str, 32);
473 for(dg= ob->defbase.first; dg; dg= dg->next)
475 autocomplete_do_name(autocpl, dg->name);
477 autocomplete_end(autocpl, str);
481 /* Helper function for draw constraint - draws constraint space stuff
482 * This function should not be called if no menus are required
483 * owner/target: -1 = don't draw menu; 0= not posemode, 1 = posemode
485 static void draw_constraint_spaceselect (uiBlock *block, bConstraint *con, short xco, short yco, short owner, short target)
490 /* calculate sizes and placement of menus */
497 else if (target == -1) {
505 ownx = tarx + bwidth;
509 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "CSpace:", xco, yco, 80,18, NULL, 0.0, 0.0, 0.0, 0.0, "");
511 uiBlockBeginAlign(block);
515 uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Pose Space %x3|Local with Parent %x4|Local Space %x1",
516 tarx, yco, bwidth, 18, &con->tarspace, 0, 0, 0, 0, "Choose space that target is evaluated in");
518 else if (target == 0) {
519 uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Local (Without Parent) Space %x1",
520 tarx, yco, bwidth, 18, &con->tarspace, 0, 0, 0, 0, "Choose space that target is evaluated in");
525 uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Owner Space %t|World Space %x0|Pose Space %x3|Local with Parent %x4|Local Space %x1",
526 ownx, yco, bwidth, 18, &con->ownspace, 0, 0, 0, 0, "Choose space that owner is evaluated in");
528 else if (owner == 0) {
529 uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Owner Space %t|World Space %x0|Local (Without Parent) Space %x1",
530 ownx, yco, bwidth, 18, &con->ownspace, 0, 0, 0, 0, "Choose space that owner is evaluated in");
533 uiBlockEndAlign(block);
536 /* draw panel showing settings for a constraint */
537 static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, short *xco, short *yco)
539 Object *ob= OBACT, *target;
541 char typestr[64], *subtarget;
542 short height, width = 265;
543 short is_armature_target, is_geom_target, is_armature_owner;
546 target= get_constraint_target(con, &subtarget);
547 is_armature_target= (target && target->type==OB_ARMATURE);
548 is_armature_owner= ((ob->type == OB_ARMATURE) && (ob->flag & OB_POSEMODE));
549 is_geom_target= (target && (ELEM(target->type, OB_MESH, OB_LATTICE)) );
551 /* unless button has own callback, it adds this callback to button */
552 uiBlockSetFunc(block, constraint_active_func, ob, con);
554 get_constraint_typestring(typestr, con);
556 /* Draw constraint header */
557 uiBlockSetEmboss(block, UI_EMBOSSN);
560 rb_col= (con->flag & CONSTRAINT_ACTIVE)?40:20;
561 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-1, width+40, 22, NULL, 5.0, 0.0,
562 (con->flag & CONSTRAINT_EXPAND)?3:15 , rb_col-20, "");
565 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");
568 uiBlockBeginAlign(block);
569 uiBlockSetEmboss(block, UI_EMBOSS);
570 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");
571 uiButSetFunc(but, constraint_moveUp, ob, con);
573 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");
574 uiButSetFunc(but, constraint_moveDown, ob, con);
575 uiBlockEndAlign(block);
577 if (con->flag & CONSTRAINT_EXPAND) {
578 if (con->flag & CONSTRAINT_DISABLE)
579 uiBlockSetCol(block, TH_REDALERT);
581 uiBlockSetEmboss(block, UI_EMBOSS);
583 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+10, *yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
585 but = uiDefBut(block, TEX, B_CONSTRAINT_TEST, "", *xco+120, *yco, 85, 18, con->name, 0.0, 29.0, 0.0, 0.0, "Constraint name");
586 uiButSetFunc(but, verify_constraint_name_func, con, NULL);
589 uiBlockSetEmboss(block, UI_EMBOSSN);
591 if (con->flag & CONSTRAINT_DISABLE)
592 uiBlockSetCol(block, TH_REDALERT);
594 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+10, *yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
596 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, con->name, *xco+120, *yco-1, 135, 19, NULL, 0.0, 0.0, 0.0, 0.0, "");
599 uiBlockSetCol(block, TH_AUTO);
601 uiBlockSetEmboss(block, UI_EMBOSSN);
603 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");
604 uiButSetFunc(but, del_constraint_func, ob, con);
606 uiBlockSetEmboss(block, UI_EMBOSS);
609 /* Draw constraint data */
610 if ((con->flag & CONSTRAINT_EXPAND) == 0) {
615 case CONSTRAINT_TYPE_PYTHON:
617 bPythonConstraint *data = con->data;
619 static int pyconindex=0;
623 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40, height-1, NULL, 5.0, 0.0, 12, rb_col, "");
625 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Script:", *xco+60, *yco-24, 55, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
627 /* do the scripts menu */
628 menustr = buildmenu_pyconstraints(data->text, &pyconindex);
629 but2 = uiDefButI(block, MENU, B_CONSTRAINT_TEST, menustr,
630 *xco+120, *yco-24, 150, 20, &pyconindex,
631 0.0, 1.0, 0, 0, "Set the Script Constraint to use");
632 uiButSetFunc(but2, validate_pyconstraint_cb, data, &pyconindex);
635 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+60, *yco-48, 55, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
636 if (data->flag & PYCON_USETARGETS) {
637 /* Draw target parameters */
638 uiBlockBeginAlign(block);
639 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-48, 150, 18, &data->tar, "Target Object");
641 if (is_armature_target) {
642 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-66,150,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
643 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
645 else if (is_geom_target) {
646 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-66,150,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
647 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
650 strcpy (data->subtarget, "");
653 uiBlockEndAlign(block);
656 /* Draw indication that no target needed */
657 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Not Applicable", *xco+120, *yco-48, 150, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
661 uiBlockBeginAlign(block);
662 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.");
663 uiButSetFunc(but, BPY_pyconstraint_settings, data, NULL);
665 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");
666 uiBlockEndAlign(block);
668 /* constraint space settings */
669 if ((data->flag & PYCON_USETARGETS)==0) is_armature_target = -1;
670 draw_constraint_spaceselect(block, con, *xco, *yco-109, is_armature_owner, is_armature_target);
673 case CONSTRAINT_TYPE_ACTION:
675 bActionConstraint *data = con->data;
676 float minval, maxval;
679 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
681 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
683 /* Draw target parameters */
684 uiBlockBeginAlign(block);
685 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
687 if (is_armature_target) {
688 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
689 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
692 strcpy (data->subtarget, "");
695 uiBlockEndAlign(block);
697 /* Draw action/type buttons */
698 uiBlockBeginAlign(block);
699 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");
700 uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Key on%t|Loc X%x20|Loc Y%x21|Loc Z%x22|Rot X%x0|Rot Y%x1|Rot Z%x2|Size X%x10|Size Y%x11|Size Z%x12", *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");
702 /* Draw start/end frame buttons */
703 uiBlockBeginAlign(block);
704 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");
705 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");
707 /* Draw minimum/maximum transform range buttons */
708 uiBlockBeginAlign(block);
709 if (data->type < 10) { /* rotation */
713 else if (data->type < 20) { /* scaling */
717 else { /* location */
721 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Min:", *xco+((width/2)+45), *yco-64, 78, 18, &data->min, minval, maxval, 0, 0, "Minimum value for target channel range");
722 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Max:", *xco+((width/2)+45), *yco-84, 78, 18, &data->max, minval, maxval, 0, 0, "Maximum value for target channel range");
723 uiBlockEndAlign(block);
725 /* constraint space settings */
726 draw_constraint_spaceselect(block, con, *xco, *yco-104, -1, is_armature_target);
729 case CONSTRAINT_TYPE_CHILDOF:
731 bChildOfConstraint *data = con->data;
732 short normButWidth = (width/3);
735 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
737 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Parent:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
739 /* Draw target parameters */
740 uiBlockBeginAlign(block);
741 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object to use as Parent");
743 if (is_armature_target) {
744 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone to use as Parent");
745 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
747 else if (is_geom_target) {
748 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
749 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
752 strcpy (data->subtarget, "");
755 uiBlockEndAlign(block);
757 /* Draw triples of channel toggles */
758 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Use Channel(s):", *xco+65, *yco-64, 150, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
759 uiBlockBeginAlign(block);
760 uiDefButBitI(block, TOG, CHILDOF_LOCX, B_CONSTRAINT_TEST, "Loc X", *xco, *yco-84, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects x-location");
761 uiDefButBitI(block, TOG, CHILDOF_LOCY, B_CONSTRAINT_TEST, "Loc Y", *xco+normButWidth, *yco-84, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects y-location");
762 uiDefButBitI(block, TOG, CHILDOF_LOCZ, B_CONSTRAINT_TEST, "Loc Z", *xco+(normButWidth * 2), *yco-84, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects z-location");
763 uiBlockEndAlign(block);
765 uiBlockBeginAlign(block);
766 uiDefButBitI(block, TOG, CHILDOF_ROTX, B_CONSTRAINT_TEST, "Rot X", *xco, *yco-105, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects x-rotation");
767 uiDefButBitI(block, TOG, CHILDOF_ROTY, B_CONSTRAINT_TEST, "Rot Y", *xco+normButWidth, *yco-105, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects y-rotation");
768 uiDefButBitI(block, TOG, CHILDOF_ROTZ, B_CONSTRAINT_TEST, "Rot Z", *xco+(normButWidth * 2), *yco-105, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects z-rotation");
769 uiBlockEndAlign(block);
771 uiBlockBeginAlign(block);
772 uiDefButBitI(block, TOG, CHILDOF_SIZEX, B_CONSTRAINT_TEST, "Scale X", *xco, *yco-126, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects x-scaling");
773 uiDefButBitI(block, TOG, CHILDOF_SIZEY, B_CONSTRAINT_TEST, "Scale Y", *xco+normButWidth, *yco-126, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects y-scaling");
774 uiDefButBitI(block, TOG, CHILDOF_SIZEZ, B_CONSTRAINT_TEST, "Scale Z", *xco+(normButWidth * 2), *yco-126, normButWidth, 18, &data->flag, 0, 24, 0, 0, "Parent affects z-scaling");
775 uiBlockEndAlign(block);
778 /* Inverse options */
779 uiBlockBeginAlign(block);
780 but=uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Set Offset", *xco, *yco-151, (width/2),18, NULL, 0, 24, 0, 0, "Calculate current Parent-Inverse Matrix (i.e. restore offset from parent)");
781 uiButSetFunc(but, childof_const_setinv, data, NULL);
783 but=uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Clear Offset", *xco+((width/2)+10), *yco-151, (width/2),18, NULL, 0, 24, 0, 0, "Clear Parent-Inverse Matrix (i.e. clear offset from parent)");
784 uiButSetFunc(but, childof_const_clearinv, data, NULL);
785 uiBlockEndAlign(block);
788 case CONSTRAINT_TYPE_LOCLIKE:
790 bLocateLikeConstraint *data = con->data;
793 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
795 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
797 /* Draw target parameters */
798 uiBlockBeginAlign(block);
799 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
801 if (is_armature_target) {
802 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
803 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
805 else if (is_geom_target) {
806 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
807 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
810 strcpy (data->subtarget, "");
813 uiBlockEndAlign(block);
815 /* Draw XYZ toggles */
816 uiBlockBeginAlign(block);
817 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");
818 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");
819 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");
820 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");
821 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");
822 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");
823 uiBlockEndAlign(block);
826 uiDefButBitI(block, TOG, LOCLIKE_OFFSET, B_CONSTRAINT_TEST, "Offset", *xco, *yco-89, (width/2), 18, &data->flag, 0, 24, 0, 0, "Add original location onto copied location");
827 if (is_armature_target) {
828 uiDefButBitI(block, TOG, LOCLIKE_TIP, B_CONSTRAINT_TEST, "Target Bone Tail", *xco+(width/2), *yco-89, (width/2), 18, &data->flag, 0, 24, 0, 0, "Copy Location of Target Bone's Tail");
831 /* constraint space settings */
832 draw_constraint_spaceselect(block, con, *xco, *yco-109, is_armature_owner, is_armature_target);
835 case CONSTRAINT_TYPE_ROTLIKE:
837 bRotateLikeConstraint *data = con->data;
840 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
842 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
844 /* Draw target parameters */
845 uiBlockBeginAlign(block);
846 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
848 if (is_armature_target) {
849 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
850 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
852 else if (is_geom_target) {
853 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
854 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
857 strcpy (data->subtarget, "");
860 uiBlockEndAlign(block);
862 /* Draw XYZ toggles */
863 uiBlockBeginAlign(block);
864 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");
865 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");
866 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");
867 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");
868 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");
869 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");
870 uiBlockEndAlign(block);
872 /* constraint space settings */
873 draw_constraint_spaceselect(block, con, *xco, *yco-94, is_armature_owner, is_armature_target);
876 case CONSTRAINT_TYPE_SIZELIKE:
878 bSizeLikeConstraint *data = con->data;
882 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
884 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
886 /* Draw target parameters */
887 uiBlockBeginAlign(block);
888 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
890 if (is_armature_target) {
891 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
892 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
894 else if (is_geom_target) {
895 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
896 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
899 strcpy (data->subtarget, "");
902 uiBlockEndAlign(block);
904 /* Draw XYZ toggles */
905 uiBlockBeginAlign(block);
906 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");
907 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");
908 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");
909 uiBlockEndAlign(block);
911 /* constraint space settings */
912 draw_constraint_spaceselect(block, con, *xco, *yco-94, is_armature_owner, is_armature_target);
915 case CONSTRAINT_TYPE_KINEMATIC:
917 bKinematicConstraint *data = con->data;
920 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
922 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
924 /* Draw target parameters */
925 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");
927 uiBlockBeginAlign(block);
928 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 19, &data->tar, "Target Object");
930 if (is_armature_target) {
931 but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,19, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
932 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
934 else if (is_geom_target) {
935 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
936 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
939 strcpy (data->subtarget, "");
942 uiBlockBeginAlign(block);
943 uiDefButBitS(block, TOG, CONSTRAINT_IK_TIP, B_CONSTRAINT_TEST, "Use Tail", *xco, *yco-64, 137, 19, &data->flag, 0, 0, 0, 0, "Include Bone's tail as last element in Chain");
944 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");
946 uiBlockBeginAlign(block);
947 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");
948 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");
950 uiBlockBeginAlign(block);
951 uiDefButS(block, NUM, B_CONSTRAINT_TEST, "Iterations:", *xco, *yco-109, 137, 19, &data->iterations, 1, 10000, 0, 0, "Maximum number of solving iterations");
952 uiBlockBeginAlign(block);
953 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");
957 case CONSTRAINT_TYPE_TRACKTO:
959 bTrackToConstraint *data = con->data;
962 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
964 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
966 /* Draw target parameters */
967 uiBlockBeginAlign(block);
968 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
970 if (is_armature_target) {
971 but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
972 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
974 else if (is_geom_target) {
975 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
976 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
979 strcpy (data->subtarget, "");
982 uiBlockEndAlign(block);
984 uiBlockBeginAlign(block);
985 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Align:", *xco+5, *yco-42, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
987 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");
988 uiBlockEndAlign(block);
990 uiBlockBeginAlign(block);
991 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "To:", *xco+12, *yco-64, 25, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
993 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");
994 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");
995 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");
996 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");
997 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");
998 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");
999 uiBlockEndAlign(block);
1001 uiBlockBeginAlign(block);
1002 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Up:", *xco+174, *yco-64, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1004 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");
1005 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");
1006 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");
1007 uiBlockEndAlign(block);
1009 /* constraint space settings */
1010 draw_constraint_spaceselect(block, con, *xco, *yco-94, is_armature_owner, is_armature_target);
1013 case CONSTRAINT_TYPE_MINMAX:
1015 bMinMaxConstraint *data = con->data;
1018 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1020 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1022 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");
1024 /* Draw target parameters */
1025 uiBlockBeginAlign(block);
1026 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
1028 if (is_armature_target) {
1029 but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
1030 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1032 else if (is_geom_target) {
1033 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
1034 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
1037 strcpy (data->subtarget, "");
1040 uiBlockEndAlign(block);
1042 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");
1043 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");
1045 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Max/Min:", *xco-8, *yco-64, 54, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1047 uiBlockBeginAlign(block);
1048 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");
1049 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");
1050 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");
1051 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");
1052 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");
1053 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");
1054 uiBlockEndAlign(block);
1057 case CONSTRAINT_TYPE_LOCKTRACK:
1059 bLockTrackConstraint *data = con->data;
1061 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1063 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1065 /* Draw target parameters */
1066 uiBlockBeginAlign(block);
1067 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
1069 if (is_armature_target) {
1070 but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
1071 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1073 else if (is_geom_target) {
1074 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
1075 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
1078 strcpy (data->subtarget, "");
1081 uiBlockEndAlign(block);
1083 uiBlockBeginAlign(block);
1084 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "To:", *xco+12, *yco-64, 25, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1086 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");
1087 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");
1088 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");
1089 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");
1090 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");
1091 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");
1092 uiBlockEndAlign(block);
1094 uiBlockBeginAlign(block);
1095 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Lock:", *xco+166, *yco-64, 38, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1097 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");
1098 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");
1099 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");
1100 uiBlockEndAlign(block);
1103 case CONSTRAINT_TYPE_FOLLOWPATH:
1105 bFollowPathConstraint *data = con->data;
1108 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1110 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1112 /* Draw target parameters */
1113 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
1115 /* Draw Curve Follow toggle */
1116 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");
1118 /* Draw Offset number button */
1119 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");
1121 uiBlockBeginAlign(block);
1122 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Fw:", *xco+12, *yco-64, 27, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1124 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");
1125 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");
1126 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");
1127 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");
1128 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");
1129 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");
1130 uiBlockEndAlign(block);
1132 uiBlockBeginAlign(block);
1133 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Up:", *xco+174, *yco-64, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1135 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");
1136 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");
1137 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");
1138 uiBlockEndAlign(block);
1141 case CONSTRAINT_TYPE_STRETCHTO:
1143 bStretchToConstraint *data = con->data;
1146 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1148 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1150 /* Draw target parameters */
1151 uiBlockBeginAlign(block);
1152 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
1154 if (is_armature_target) {
1155 but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
1156 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1158 else if (is_geom_target) {
1159 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
1160 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
1163 strcpy (data->subtarget, "");
1166 uiBlockEndAlign(block);
1169 uiBlockBeginAlign(block);
1170 uiDefButF(block,BUTM,B_CONSTRAINT_TEST,"R",*xco, *yco-60,20,18,&(data->orglength),0.0,0,0,0,"Recalculate RLength");
1171 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");
1172 uiBlockEndAlign(block);
1174 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");
1176 uiBlockBeginAlign(block);
1177 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Vol:",*xco+14, *yco-104,30,18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1178 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");
1179 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");
1180 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");
1181 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"NONE", *xco+114, *yco-104,50,18, &data->volmode, 12.0, 3.0, 0, 0, "Ignore Volume");
1182 uiBlockEndAlign(block);
1185 uiBlockBeginAlign(block);
1186 uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"Plane:",*xco+175, *yco-104,40,18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1187 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X", *xco+215, *yco-104,20,18, &data->plane, 12.0, 0.0, 0, 0, "Keep X axis");
1188 uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z", *xco+235, *yco-104,20,18, &data->plane, 12.0, 2.0, 0, 0, "Keep Z axis");
1189 uiBlockEndAlign(block);
1192 case CONSTRAINT_TYPE_LOCLIMIT:
1194 bLocLimitConstraint *data = con->data;
1196 int togButWidth = 50;
1197 int textButWidth = ((width/2)-togButWidth);
1200 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1202 /* Draw Pairs of LimitToggle+LimitValue */
1203 uiBlockBeginAlign(block);
1204 uiDefButBitS(block, TOG, LIMIT_XMIN, B_CONSTRAINT_TEST, "minX", *xco, *yco-28, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x value");
1205 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");
1206 uiBlockEndAlign(block);
1208 uiBlockBeginAlign(block);
1209 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");
1210 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");
1211 uiBlockEndAlign(block);
1213 uiBlockBeginAlign(block);
1214 uiDefButBitS(block, TOG, LIMIT_YMIN, B_CONSTRAINT_TEST, "minY", *xco, *yco-50, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y value");
1215 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");
1216 uiBlockEndAlign(block);
1218 uiBlockBeginAlign(block);
1219 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");
1220 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");
1221 uiBlockEndAlign(block);
1223 uiBlockBeginAlign(block);
1224 uiDefButBitS(block, TOG, LIMIT_ZMIN, B_CONSTRAINT_TEST, "minZ", *xco, *yco-72, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z value");
1225 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");
1226 uiBlockEndAlign(block);
1228 uiBlockBeginAlign(block);
1229 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");
1230 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");
1231 uiBlockEndAlign(block);
1233 /* constraint space settings */
1234 draw_constraint_spaceselect(block, con, *xco, *yco-100, is_armature_owner, -1);
1237 case CONSTRAINT_TYPE_ROTLIMIT:
1239 bRotLimitConstraint *data = con->data;
1240 int normButWidth = (width/3);
1244 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1246 /* Draw Pairs of LimitToggle+LimitValue */
1247 uiBlockBeginAlign(block);
1248 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");
1249 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");
1250 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");
1251 uiBlockEndAlign(block);
1253 uiBlockBeginAlign(block);
1254 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");
1255 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");
1256 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");
1257 uiBlockEndAlign(block);
1259 uiBlockBeginAlign(block);
1260 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");
1261 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");
1262 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");
1263 uiBlockEndAlign(block);
1265 /* constraint space settings */
1266 draw_constraint_spaceselect(block, con, *xco, *yco-100, is_armature_owner, -1);
1269 case CONSTRAINT_TYPE_SIZELIMIT:
1271 bSizeLimitConstraint *data = con->data;
1273 int togButWidth = 50;
1274 int textButWidth = ((width/2)-togButWidth);
1278 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1280 /* Draw Pairs of LimitToggle+LimitValue */
1281 uiBlockBeginAlign(block);
1282 uiDefButBitS(block, TOG, LIMIT_XMIN, B_CONSTRAINT_TEST, "minX", *xco, *yco-28, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x value");
1283 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");
1284 uiBlockEndAlign(block);
1286 uiBlockBeginAlign(block);
1287 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");
1288 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");
1289 uiBlockEndAlign(block);
1292 uiBlockBeginAlign(block);
1293 uiDefButBitS(block, TOG, LIMIT_YMIN, B_CONSTRAINT_TEST, "minY", *xco, *yco-50, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y value");
1294 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");
1295 uiBlockEndAlign(block);
1297 uiBlockBeginAlign(block);
1298 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");
1299 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");
1300 uiBlockEndAlign(block);
1303 uiBlockBeginAlign(block);
1304 uiDefButBitS(block, TOG, LIMIT_ZMIN, B_CONSTRAINT_TEST, "minZ", *xco, *yco-72, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z value");
1305 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");
1306 uiBlockEndAlign(block);
1308 uiBlockBeginAlign(block);
1309 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");
1310 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");
1311 uiBlockEndAlign(block);
1313 /* constraint space settings */
1314 draw_constraint_spaceselect(block, con, *xco, *yco-100, is_armature_owner, -1);
1317 case CONSTRAINT_TYPE_RIGIDBODYJOINT:
1319 bRigidBodyJointConstraint *data = con->data;
1320 float extremeLin = 999.f;
1321 float extremeAngX = 180.f;
1322 float extremeAngY = 45.f;
1323 float extremeAngZ = 45.f;
1324 int togButWidth = 70;
1326 int textButWidth = ((width/2)-togButWidth);
1328 uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Cone Twist%x4|Generic (experimental)%x12",//|Extra Force%x6",
1329 *xco, *yco-25, 150, 18, &data->type, 0, 0, 0, 0, "Choose the joint type");
1331 if (data->type==CONSTRAINT_RB_GENERIC6DOF)
1333 if (data->type==CONSTRAINT_RB_CONETWIST)
1336 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1338 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "toObject:", *xco, *yco-50, 130, 18, &data->tar, "Child Object");
1339 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");
1341 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot X:", *xco, *yco-75, 130, 18, &data->pivX, -1000, 1000, 100, 0.0, "Offset pivot on X");
1342 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Y:", *xco, *yco-100, 130, 18, &data->pivY, -1000, 1000, 100, 0.0, "Offset pivot on Y");
1343 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Z:", *xco, *yco-125, 130, 18, &data->pivZ, -1000, 1000, 100, 0.0, "Offset pivot on z");
1345 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)");
1346 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)");
1347 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)");
1349 if (data->type==CONSTRAINT_RB_GENERIC6DOF) {
1350 /* Draw Pairs of LimitToggle+LimitValue */
1351 uiBlockBeginAlign(block);
1352 uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "LinMinX", *xco, *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit");
1353 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");
1355 uiBlockBeginAlign(block);
1356 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");
1357 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");
1360 uiBlockBeginAlign(block);
1361 uiDefButBitS(block, TOG, 2, B_CONSTRAINT_TEST, "LinMinY", *xco, *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y limit");
1362 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");
1364 uiBlockBeginAlign(block);
1365 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");
1366 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");
1369 uiBlockBeginAlign(block);
1370 uiDefButBitS(block, TOG, 4, B_CONSTRAINT_TEST, "LinMinZ", *xco, *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z limit");
1371 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");
1373 uiBlockBeginAlign(block);
1374 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");
1375 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");
1378 if ((data->type==CONSTRAINT_RB_GENERIC6DOF) || (data->type==CONSTRAINT_RB_CONETWIST)) {
1379 /* Draw Pairs of LimitToggle+LimitValue */
1380 uiBlockBeginAlign(block);
1381 uiDefButBitS(block, TOG, 8, B_CONSTRAINT_TEST, "AngMinX", *xco, *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit");
1382 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");
1383 uiBlockBeginAlign(block);
1384 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");
1385 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");
1388 uiBlockBeginAlign(block);
1389 uiDefButBitS(block, TOG, 16, B_CONSTRAINT_TEST, "AngMinY", *xco, *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y limit");
1390 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");
1392 uiBlockBeginAlign(block);
1393 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");
1394 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");
1397 uiBlockBeginAlign(block);
1398 uiDefButBitS(block, TOG, 32, B_CONSTRAINT_TEST, "AngMinZ", *xco, *yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z limit");
1399 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");
1401 uiBlockBeginAlign(block);
1402 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");
1403 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");
1404 uiBlockEndAlign(block);
1408 case CONSTRAINT_TYPE_CLAMPTO:
1410 bClampToConstraint *data = con->data;
1413 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1415 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1417 /* Draw target parameters */
1418 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
1420 /* Draw XYZ toggles */
1421 uiBlockBeginAlign(block);
1422 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Main Axis:", *xco, *yco-64, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1423 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");
1424 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");
1425 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");
1426 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");
1427 uiBlockEndAlign(block);
1429 /* Extra Options Controlling Behaviour */
1430 uiBlockBeginAlign(block);
1431 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Options:", *xco, *yco-86, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1432 uiDefButBitI(block, TOG, CLAMPTO_CYCLIC, B_CONSTRAINT_TEST, "Cyclic", *xco+((width/2)), *yco-86,60,19, &data->flag2, 0, 0, 0, 0, "Treat curve as cyclic curve (no clamping to curve bounding box)");
1433 uiBlockEndAlign(block);
1436 case CONSTRAINT_TYPE_TRANSFORM:
1438 bTransformConstraint *data = con->data;
1439 float fmin, fmax, tmin, tmax;
1442 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1444 /* Draw target parameters */
1445 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1447 /* Draw target parameters */
1448 uiBlockBeginAlign(block);
1449 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object to use as Parent");
1451 if (is_armature_target) {
1452 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone to use as Parent");
1453 uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
1455 else if (is_geom_target) {
1456 but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-66,150,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
1457 uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
1460 strcpy(data->subtarget, "");
1463 uiBlockEndAlign(block);
1465 /* Extrapolate Ranges? */
1466 uiDefButBitC(block, TOG, 1, B_CONSTRAINT_TEST, "Extrapolate", *xco, *yco-42,80,19, &data->expo, 0, 0, 0, 0, "Extrapolate ranges");
1468 /* Draw options for source motion */
1469 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Source:", *xco-10, *yco-62, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1471 /* draw Loc/Rot/Size toggles */
1472 uiBlockBeginAlign(block);
1473 uiDefButS(block, ROW, B_CONSTRAINT_TEST, "Loc", *xco-5, *yco-82, 45, 18, &data->from, 12.0, 0, 0, 0, "Use Location transform channels from Target");
1474 uiDefButS(block, ROW, B_CONSTRAINT_TEST, "Rot", *xco+40, *yco-82, 45, 18, &data->from, 12.0, 1, 0, 0, "Use Rotation transform channels from Target");
1475 uiDefButS(block, ROW, B_CONSTRAINT_TEST, "Scale", *xco+85, *yco-82, 45, 18, &data->from, 12.0, 2, 0, 0, "Use Scale transform channels from Target");
1476 uiBlockEndAlign(block);
1478 /* Draw Pairs of Axis: Min/Max Value*/
1479 if (data->from == 2) {
1483 else if (data->from == 1) {
1492 uiBlockBeginAlign(block);
1493 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "X:", *xco-10, *yco-107, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1494 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min", *xco+20, *yco-107, 55, 18, &data->from_min[0], fmin, fmax, 0, 0, "Bottom of range of x-axis source motion for source->target mapping");
1495 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max", *xco+75, *yco-107, 55, 18, &data->from_max[0], fmin, fmax, 0, 0, "Top of range of x-axis source motion for source->target mapping");
1496 uiBlockEndAlign(block);
1498 uiBlockBeginAlign(block);
1499 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Y:", *xco-10, *yco-127, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1500 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min", *xco+20, *yco-127, 55, 18, &data->from_min[1], fmin, fmax, 0, 0, "Bottom of range of y-axis source motion for source->target mapping");
1501 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max", *xco+75, *yco-127, 55, 18, &data->from_max[1], fmin, fmax, 0, 0, "Top of range of y-axis source motion for source->target mapping");
1502 uiBlockEndAlign(block);
1504 uiBlockBeginAlign(block);
1505 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Z:", *xco-10, *yco-147, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1506 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min", *xco+20, *yco-147, 55, 18, &data->from_min[2], fmin, fmax, 0, 0, "Bottom of range of z-axis source motion for source->target mapping");
1507 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max", *xco+75, *yco-147, 55, 18, &data->from_max[2], fmin, fmax, 0, 0, "Top of range of z-axis source motion for source->target mapping");
1508 uiBlockEndAlign(block);
1511 /* Draw options for target motion */
1512 uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Destination:", *xco+150, *yco-62, 150, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
1514 /* draw Loc/Rot/Size toggles */
1515 uiBlockBeginAlign(block);
1516 uiDefButS(block, ROW, B_CONSTRAINT_TEST, "Loc", *xco+150, *yco-82, 45, 18, &data->to, 12.0, 0, 0, 0, "Use as Location transform");
1517 uiDefButS(block, ROW, B_CONSTRAINT_TEST, "Rot", *xco+195, *yco-82, 45, 18, &data->to, 12.0, 1, 0, 0, "Use as Rotation transform");
1518 uiDefButS(block, ROW, B_CONSTRAINT_TEST, "Scale", *xco+245, *yco-82, 45, 18, &data->to, 12.0, 2, 0, 0, "Use as Scale transform");
1519 uiBlockEndAlign(block);
1521 /* Draw Pairs of Source-Axis: Min/Max Value*/
1522 if (data->to == 2) {
1526 else if (data->to == 1) {
1535 uiBlockBeginAlign(block);
1536 uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Axis Mapping%t|X->X%x0|Y->X%x1|Z->X%x2", *xco+150, *yco-107, 40, 18, &data->map[0], 0, 24, 0, 0, "Specify which source axis the x-axis destination uses");
1537 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min", *xco+175, *yco-107, 50, 18, &data->to_min[0], tmin, tmax, 0, 0, "Bottom of range of x-axis destination motion for source->target mapping");
1538 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max", *xco+240, *yco-107, 50, 18, &data->to_max[0], tmin, tmax, 0, 0, "Top of range of x-axis destination motion for source->target mapping");
1539 uiBlockEndAlign(block);
1541 uiBlockBeginAlign(block);
1542 uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Axis Mapping%t|X->Y%x0|Y->Y%x1|Z->Y%x2", *xco+150, *yco-127, 40, 18, &data->map[1], 0, 24, 0, 0, "Specify which source axis the y-axis destination uses");
1543 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min", *xco+175, *yco-127, 50, 18, &data->to_min[1], tmin, tmax, 0, 0, "Bottom of range of y-axis destination motion for source->target mapping");
1544 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max", *xco+240, *yco-127, 50, 18, &data->to_max[1], tmin, tmax, 0, 0, "Top of range of y-axis destination motion for source->target mapping");
1545 uiBlockEndAlign(block);
1547 uiBlockBeginAlign(block);
1548 uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Axis Mapping%t|X->Z%x0|Y->Z%x1|Z->Z%x2", *xco+150, *yco-147, 40, 18, &data->map[2], 0, 24, 0, 0, "Specify which source axis the z-axis destination uses");
1549 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "min", *xco+175, *yco-147, 50, 18, &data->to_min[2], tmin, tmax, 0, 0, "Bottom of range of z-axis destination motion for source->target mapping");
1550 uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max", *xco+240, *yco-147, 50, 18, &data->to_max[2], tmin, tmax, 0, 0, "Top of range of z-axis destination motion for source->target mapping");
1551 uiBlockEndAlign(block);
1553 /* constraint space settings */
1554 draw_constraint_spaceselect(block, con, *xco, *yco-170, is_armature_owner, is_armature_target);
1557 case CONSTRAINT_TYPE_NULL:
1560 uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
1568 (*yco)-=(24+height);
1571 if ((con->type != CONSTRAINT_TYPE_NULL) && (con->type!=CONSTRAINT_TYPE_RIGIDBODYJOINT)) {
1572 uiBlockBeginAlign(block);
1573 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");
1574 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");
1575 /* If this is on an object or bone, add ipo channel the constraint */
1576 uiButSetFunc (but, enable_constraint_ipo_func, ob, con);
1577 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");
1578 /* Add a keyframe to the influence IPO */
1579 uiButSetFunc (but, add_influence_key_to_constraint_func, ob, con);
1580 uiBlockEndAlign(block);
1588 static uiBlock *add_constraintmenu(void *arg_unused)
1595 conlist = get_active_constraints(ob);
1597 block= uiNewBlock(&curarea->uiblocks, "add_constraintmenu", UI_EMBOSSP, UI_HELV, curarea->win);
1599 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_CHILDOF, "Child Of", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1600 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_TRANSFORM, "Transformation", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1602 uiDefBut(block, SEPR, 0, "", 0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1604 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_LOCLIKE, "Copy Location", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1605 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_ROTLIKE, "Copy Rotation", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1606 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_SIZELIKE, "Copy Scale", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1608 uiDefBut(block, SEPR, 0, "", 0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1610 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_LOCLIMIT, "Limit Location", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1611 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_ROTLIMIT, "Limit Rotation", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1612 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_SIZELIMIT, "Limit Scale", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1614 uiDefBut(block, SEPR, 0, "", 0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1616 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_TRACKTO, "Track To", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1617 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_MINMAX, "Floor", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1618 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_LOCKTRACK, "Locked Track", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1619 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_FOLLOWPATH, "Follow Path", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1621 uiDefBut(block, SEPR, 0, "", 0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1623 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_CLAMPTO, "Clamp To", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1624 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_STRETCHTO, "Stretch To", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1626 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_RIGIDBODYJOINT, "Rigid Body Joint", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");//rcruiz
1628 if (ob->flag & OB_POSEMODE) {
1629 uiDefBut(block, SEPR, 0, "", 0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1631 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_KINEMATIC, "IK Solver", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1632 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_ACTION, "Action", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1635 uiDefBut(block, SEPR, 0, "", 0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1637 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_PYTHON, "Script", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1639 uiDefBut(block, SEPR, 0, "", 0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, "");
1641 uiDefBut(block, BUTM, B_CONSTRAINT_ADD_NULL, "Null", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, "");
1644 uiTextBoundsBlock(block, 50);
1645 uiBlockSetDirection(block, UI_DOWN);
1650 void do_constraintbuts(unsigned short event)
1656 case B_CONSTRAINT_TEST:
1657 break; // no handling
1658 case B_CONSTRAINT_INF:
1659 /* influence; do not execute actions for 1 dag_flush */
1661 ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK);
1663 case B_CONSTRAINT_CHANGETARGET:
1664 if (ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels
1665 DAG_scene_sort(G.scene);
1668 case B_CONSTRAINT_ADD_NULL:
1670 con = add_new_constraint(CONSTRAINT_TYPE_NULL);
1671 add_constraint_to_active(ob, con);
1673 BIF_undo_push("Add constraint");
1676 case B_CONSTRAINT_ADD_PYTHON:
1678 con = add_new_constraint(CONSTRAINT_TYPE_PYTHON);
1679 add_constraint_to_active(ob, con);
1681 BIF_undo_push("Add constraint");
1684 case B_CONSTRAINT_ADD_KINEMATIC:
1686 con = add_new_constraint(CONSTRAINT_TYPE_KINEMATIC);
1687 add_constraint_to_active(ob, con);
1689 BIF_undo_push("Add constraint");
1692 case B_CONSTRAINT_ADD_CHILDOF:
1694 con= add_new_constraint(CONSTRAINT_TYPE_CHILDOF);
1695 add_constraint_to_active(ob, con);
1697 /* if this constraint is being added to a posechannel, make sure
1698 * the constraint gets evaluated in pose-space
1700 if (ob->flag & OB_POSEMODE) {
1701 con->ownspace = CONSTRAINT_SPACE_POSE;
1702 con->flag |= CONSTRAINT_SPACEONCE;
1705 BIF_undo_push("Add constraint");
1708 case B_CONSTRAINT_ADD_TRACKTO:
1710 con = add_new_constraint(CONSTRAINT_TYPE_TRACKTO);
1711 add_constraint_to_active(ob, con);
1713 BIF_undo_push("Add constraint");
1716 case B_CONSTRAINT_ADD_MINMAX:
1718 con = add_new_constraint(CONSTRAINT_TYPE_MINMAX);
1719 add_constraint_to_active(ob, con);
1721 BIF_undo_push("Add constraint");
1724 case B_CONSTRAINT_ADD_ROTLIKE:
1726 con = add_new_constraint(CONSTRAINT_TYPE_ROTLIKE);
1727 add_constraint_to_active(ob, con);
1729 BIF_undo_push("Add constraint");
1732 case B_CONSTRAINT_ADD_LOCLIKE:
1734 con = add_new_constraint(CONSTRAINT_TYPE_LOCLIKE);
1735 add_constraint_to_active(ob, con);
1737 BIF_undo_push("Add constraint");
1740 case B_CONSTRAINT_ADD_SIZELIKE:
1742 con = add_new_constraint(CONSTRAINT_TYPE_SIZELIKE);
1743 add_constraint_to_active(ob, con);
1745 BIF_undo_push("Add constraint");
1748 case B_CONSTRAINT_ADD_ACTION:
1750 con = add_new_constraint(CONSTRAINT_TYPE_ACTION);
1751 add_constraint_to_active(ob, con);
1753 BIF_undo_push("Add constraint");
1756 case B_CONSTRAINT_ADD_LOCKTRACK:
1758 con = add_new_constraint(CONSTRAINT_TYPE_LOCKTRACK);
1759 add_constraint_to_active(ob, con);
1761 BIF_undo_push("Add constraint");
1764 case B_CONSTRAINT_ADD_FOLLOWPATH:
1766 con = add_new_constraint(CONSTRAINT_TYPE_FOLLOWPATH);
1767 add_constraint_to_active(ob, con);
1769 BIF_undo_push("Add constraint");
1772 case B_CONSTRAINT_ADD_STRETCHTO:
1774 con = add_new_constraint(CONSTRAINT_TYPE_STRETCHTO);
1775 add_constraint_to_active(ob, con);
1777 BIF_undo_push("Add constraint");
1780 case B_CONSTRAINT_ADD_LOCLIMIT:
1782 con = add_new_constraint(CONSTRAINT_TYPE_LOCLIMIT);
1783 add_constraint_to_active(ob, con);
1785 BIF_undo_push("Add constraint");
1788 case B_CONSTRAINT_ADD_ROTLIMIT:
1790 con = add_new_constraint(CONSTRAINT_TYPE_ROTLIMIT);
1791 add_constraint_to_active(ob, con);
1793 BIF_undo_push("Add constraint");
1796 case B_CONSTRAINT_ADD_SIZELIMIT:
1798 con = add_new_constraint(CONSTRAINT_TYPE_SIZELIMIT);
1799 add_constraint_to_active(ob, con);
1801 BIF_undo_push("Add constraint");
1804 case B_CONSTRAINT_ADD_RIGIDBODYJOINT:
1806 bRigidBodyJointConstraint *data;
1809 con = add_new_constraint(CONSTRAINT_TYPE_RIGIDBODYJOINT);
1810 add_constraint_to_active(ob, con);
1812 /* set selected first object as target - moved from new_constraint_data */
1813 data = (bRigidBodyJointConstraint*)con->data;
1814 base_iter = G.scene->base.first;
1815 while ( base_iter && !data->tar ) {
1816 if( ( ( base_iter->flag & SELECT ) &&
1817 // ( base_iter->lay & G.vd->lay ) ) &&
1818 ( base_iter != G.scene->basact ) ))
1820 data->tar=base_iter->object;
1823 base_iter = base_iter->next;
1826 BIF_undo_push("Add constraint");
1829 case B_CONSTRAINT_ADD_CLAMPTO:
1831 con = add_new_constraint(CONSTRAINT_TYPE_CLAMPTO);
1832 add_constraint_to_active(ob, con);
1834 BIF_undo_push("Add constraint");
1837 case B_CONSTRAINT_ADD_TRANSFORM:
1839 con = add_new_constraint(CONSTRAINT_TYPE_TRANSFORM);
1840 add_constraint_to_active(ob, con);
1842 BIF_undo_push("Add constraint");
1850 object_test_constraints(ob);
1852 if(ob->pose) update_pose_constraint_flags(ob->pose);
1854 if(ob->type==OB_ARMATURE) DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA|OB_RECALC_OB);
1855 else DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
1857 allqueue (REDRAWVIEW3D, 0);
1858 allqueue (REDRAWBUTSOBJECT, 0);
1861 void softbody_bake(Object *ob)
1866 float frameleno= G.scene->r.framelen;
1867 int cfrao= CFRA, sfra=100000, efra=0, didbreak =0;
1870 G.scene->r.framelen= 1.0; // baking has to be in uncorrected time
1871 sbSetInterruptCallBack(blender_test_break); // make softbody module ESC aware
1872 G.afbreek=0; // init global break system
1876 sfra= MIN2(sfra, sb->sfra);
1877 efra= MAX2(efra, sb->efra);
1878 sbObjectToSoftbody(ob); // put softbody in restposition, free bake
1879 ob->softflag |= OB_SB_BAKEDO;
1882 for(base=G.scene->base.first; base; base= base->next) {
1883 if(TESTBASELIB(base)) {
1884 if(base->object->soft) {
1885 sb= base->object->soft;
1886 sfra= MIN2(sfra, sb->sfra);
1887 efra= MAX2(efra, sb->efra);
1888 sbObjectToSoftbody(base->object); // put softbody in restposition, free bake
1889 base->object->softflag |= OB_SB_BAKEDO;
1896 update_for_newframe_muted(); // put everything on this frame
1898 curarea->win_swap= 0; // clean swapbuffers
1900 for(; CFRA <= efra; CFRA++) {
1901 set_timecursor(CFRA);
1903 update_for_newframe_muted();
1905 for(sa= G.curscreen->areabase.first; sa; sa= sa->next) {
1906 if(sa->spacetype == SPACE_VIEW3D) {
1907 scrarea_do_windraw(sa);
1910 screen_swapbuffers();
1911 //blender_test_break() has a granularity of 10 ms, who cares .. baking the unit cube is kinda boring
1912 if (blender_test_break()){
1918 if((didbreak)&&(G.qual!=LR_SHIFTKEY)) {
1920 sbObjectToSoftbody(ob); // free bake
1922 for(base=G.scene->base.first; base; base= base->next) {
1923 if(TESTBASELIB(base)) {
1924 if(base->object->soft) {
1925 sbObjectToSoftbody(base->object); // free bake
1934 sbSetInterruptCallBack(NULL); // softbody module won't ESC
1935 G.afbreek=0; // reset global break system
1938 ob->softflag &= ~OB_SB_BAKEDO;
1940 for(base=G.scene->base.first; base; base= base->next)
1941 if(TESTBASELIB(base))
1942 if(base->object->soft)
1943 base->object->softflag &= ~OB_SB_BAKEDO;
1947 G.scene->r.framelen= frameleno;
1948 update_for_newframe_muted();
1949 allqueue(REDRAWVIEW3D, 0);
1950 allqueue(REDRAWBUTSOBJECT, 0);
1953 // store processed path & file prefix for fluidsim bake directory
1954 void fluidsimFilesel(char *selection)
1957 char srcDir[FILE_MAXDIR+FILE_MAXFILE], srcFile[FILE_MAXFILE];
1958 char prefix[FILE_MAXFILE];
1959 char *srch, *srchSub, *srchExt, *lastFound;
1960 int isElbeemSurf = 0;
1963 strcpy(srcDir, selection);
1964 BLI_splitdirstring(srcDir, srcFile);
1965 strcpy(prefix, srcFile);
1966 // check if this is a previously generated surface mesh file
1967 srch = strstr(prefix, "fluidsurface_");
1968 // TODO search from back...
1970 srchSub = strstr(prefix,"_preview_");
1971 if(!srchSub) srchSub = strstr(prefix,"_final_");
1972 srchExt = strstr(prefix,".gz.bobj");
1973 if(!srchExt) srchExt = strstr(prefix,".bobj");
1974 if(srchSub && srchExt) {
1980 // try to remove suffix
1982 srch = strchr(prefix, '.'); // search last . from extension
1987 srch = strchr(srch, '.');
1995 if(ob->fluidsimSettings) {
1996 strcpy(ob->fluidsimSettings->surfdataPath, srcDir);
1997 //not necessary? strcat(ob->fluidsimSettings->surfdataPath, "/");
1998 strcat(ob->fluidsimSettings->surfdataPath, prefix);
2000 // redraw view & buttons...
2001 allqueue(REDRAWBUTSOBJECT, 0);
2002 allqueue(REDRAWVIEW3D, 0);
2003 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
2007 void do_object_panels(unsigned short event)
2018 DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
2019 allqueue(REDRAWVIEW3D, 0);
2022 DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
2023 allqueue(REDRAWVIEW3D, 0);
2026 ob->transflag &= ~(OB_DUPLIVERTS|OB_DUPLIFACES|OB_DUPLIGROUP);
2027 allqueue(REDRAWVIEW3D, 0);
2028 allqueue(REDRAWBUTSOBJECT, 0);
2031 ob->transflag &= ~(OB_DUPLIFRAMES|OB_DUPLIFACES|OB_DUPLIGROUP);
2032 DAG_scene_sort(G.scene);
2033 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
2034 allqueue(REDRAWVIEW3D, 0);
2035 allqueue(REDRAWBUTSOBJECT, 0);
2038 ob->transflag &= ~(OB_DUPLIVERTS|OB_DUPLIFRAMES|OB_DUPLIGROUP);
2039 allqueue(REDRAWVIEW3D, 0);
2040 allqueue(REDRAWBUTSOBJECT, 0);
2043 ob->transflag &= ~(OB_DUPLIVERTS|OB_DUPLIFRAMES|OB_DUPLIFACES);
2044 allqueue(REDRAWVIEW3D, 0);
2045 allqueue(REDRAWBUTSOBJECT, 0);
2053 where_is_object(ob);
2054 VECCOPY(vec, ob->obmat[3]);
2057 where_is_object(ob);
2058 VecSubf(vec, vec, ob->obmat[3]);
2059 prspeed= Normalize(vec);
2060 scrarea_queue_winredraw(curarea);
2064 if(ob->type==OB_CURVE) {
2067 if(cu->path) prlen= cu->path->totdist; else prlen= -1.0;
2068 scrarea_queue_winredraw(curarea);
2072 allspace(REMAKEIPO, 0);
2073 allqueue(REDRAWBUTSOBJECT, 0);
2074 allqueue(REDRAWBUTSEDIT, 0);
2075 allqueue(REDRAWIPO, 0);
2076 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
2079 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
2080 allqueue(REDRAWVIEW3D, 0);
2083 case B_SOFTBODY_CHANGE:
2084 ob->softflag |= OB_SB_REDO;
2085 allqueue(REDRAWBUTSOBJECT, 0);
2086 allqueue(REDRAWVIEW3D, 0);
2088 case B_SOFTBODY_DEL_VG:
2090 ob->soft->vertgroup= 0;
2091 ob->softflag |= OB_SB_REDO;
2092 allqueue(REDRAWBUTSOBJECT, 0);
2093 allqueue(REDRAWVIEW3D, 0);
2096 case B_SOFTBODY_BAKE:
2097 if(ob->soft) softbody_bake(ob);
2099 case B_SOFTBODY_BAKE_FREE:
2100 if(ob->soft) sbObjectToSoftbody(ob);
2101 allqueue(REDRAWBUTSOBJECT, 0);
2102 allqueue(REDRAWVIEW3D, 0);
2104 case B_FLUIDSIM_BAKE:
2105 /* write config files (currently no simulation) */
2108 case B_FLUIDSIM_MAKEPART:
2111 /* prepare fluidsim particle display */
2112 // simplified delete effect, create new - recalc some particles...
2113 if(ob==NULL || ob->type!=OB_MESH) break;
2114 ob->fluidsimSettings->type = 0;
2115 // reset type, and init particle system once normally
2116 paf= give_parteff(ob);
2117 if( (BLI_countlist(&ob->effect)<MAX_EFFECT) &&
2120 copy_act_effect(ob); DAG_scene_sort(G.scene); }
2121 paf = give_parteff(ob);
2123 paf->totpart = 1000; paf->sta = paf->end = 1.0; // generate some particles...
2124 build_particle_system(ob);
2125 ob->fluidsimSettings->type = OB_FLUIDSIM_PARTICLE;
2128 allqueue(REDRAWVIEW3D, 0);
2129 allqueue(REDRAWBUTSOBJECT, 0);
2131 case B_FLUIDSIM_SELDIR:
2133 ScrArea *sa = closest_bigger_area();
2134 /* choose dir for surface files */
2135 areawinset(sa->win);
2136 activate_fileselect(FILE_SPECIAL, "Select Directory", ob->fluidsimSettings->surfdataPath, fluidsimFilesel);
2139 case B_FLUIDSIM_FORCEREDRAW:
2141 allqueue(REDRAWBUTSOBJECT, 0);
2142 allqueue(REDRAWVIEW3D, 0);
2143 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
2145 case B_GROUP_RELINK:
2146 group_relink_nla_objects(ob);
2147 allqueue(REDRAWVIEW3D, 0);
2150 case B_OBJECT_IPOFLAG:
2151 if(ob->ipo) ob->ipo->showkey= (ob->ipoflag & OB_DRAWKEY)?1:0;
2152 allqueue(REDRAWVIEW3D, 0);
2156 if(event>=B_SELEFFECT && event<B_SELEFFECT+MAX_EFFECT) {
2159 eff= ob->effect.first;
2161 if(event==a) eff->flag |= SELECT;
2162 else eff->flag &= ~SELECT;
2167 allqueue(REDRAWBUTSOBJECT, 0);
2173 static void do_add_groupmenu(void *arg, int event)
2180 Group *group= add_group( "Group" );
2181 add_to_group(group, ob);
2184 add_to_group(BLI_findlink(&G.main->group, event), ob);
2186 ob->flag |= OB_FROMGROUP;
2187 BASACT->flag |= OB_FROMGROUP;
2188 allqueue(REDRAWBUTSOBJECT, 0);
2189 allqueue(REDRAWVIEW3D, 0);
2193 static uiBlock *add_groupmenu(void *arg_unused)
2200 block= uiNewBlock(&curarea->uiblocks, "add_constraintmenu", UI_EMBOSSP, UI_HELV, curarea->win);
2201 uiBlockSetButmFunc(block, do_add_groupmenu, NULL);
2203 uiDefBut(block, BUTM, B_NOP, "ADD NEW", 0, 20, 160, 19, NULL, 0.0, 0.0, 1, -1, "");
2204 for(group= G.main->group.first; group; group= group->id.next, yco++) {
2205 if(group->id.lib) strcpy(str, "L ");
2206 else strcpy(str, " ");
2207 strcat(str, group->id.name+2);
2208 uiDefBut(block, BUTM, B_NOP, str, 0, -20*yco, 160, 19, NULL, 0.0, 0.0, 1, yco, "");
2211 uiTextBoundsBlock(block, 50);
2212 uiBlockSetDirection(block, UI_DOWN);
2217 static void group_ob_rem(void *gr_v, void *ob_v)
2221 rem_from_group(gr_v, ob);
2222 if(find_group(ob)==NULL) {
2223 ob->flag &= ~OB_FROMGROUP;
2224 BASACT->flag &= ~OB_FROMGROUP;
2226 allqueue(REDRAWBUTSOBJECT, 0);
2227 allqueue(REDRAWVIEW3D, 0);
2231 static void group_local(void *gr_v, void *unused)
2235 group->id.lib= NULL;
2237 allqueue(REDRAWBUTSOBJECT, 0);
2238 allqueue(REDRAWVIEW3D, 0);
2242 static void object_panel_object(Object *ob)
2248 short dx= 33, dy= 30;
2250 block= uiNewBlock(&curarea->uiblocks, "object_panel_object", UI_EMBOSS, UI_HELV, curarea->win);
2251 if(uiNewPanel(curarea, block, "Object and Links", "Object", 0, 0, 318, 204)==0) return;
2253 uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
2256 uiBlockSetCol(block, TH_BUT_SETTING2);
2257 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);
2258 uiBlockSetCol(block, TH_AUTO);
2261 uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_OBJECTPANELPARENT, "Par:", xco+5, 180, 305-xco, 20, &ob->parent, "Parent Object");
2263 /* TODO, check for ob->id.lib */
2264 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.");
2266 uiDefBlockBut(block, add_groupmenu, NULL, "Add to Group", 10,150,150,20, "Add Object to a new Group");
2269 for(group= G.main->group.first; group; group= group->id.next) {
2270 if(object_in_group(ob, group)) {
2273 uiBlockBeginAlign(block);
2274 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.");
2275 uiButSetFunc(but, test_idbutton_cb, group->id.name, NULL);
2278 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");
2279 uiButSetFunc(but, group_local, group, NULL);
2282 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");
2283 uiButSetFunc(but, group_ob_rem, group, ob);
2289 uiBlockBeginAlign(block);
2291 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, "");
2293 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, "");
2296 uiBlockBeginAlign(block);
2298 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, "");
2300 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, "");
2302 uiBlockEndAlign(block);
2309 uiNewPanelHeight(block, 204 - (120-yco));
2312 static void object_panel_anim(Object *ob)
2317 block= uiNewBlock(&curarea->uiblocks, "object_panel_anim", UI_EMBOSS, UI_HELV, curarea->win);
2318 if(uiNewPanel(curarea, block, "Anim settings", "Object", 320, 0, 318, 204)==0) return;
2320 uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
2322 uiBlockBeginAlign(block);
2323 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");
2324 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");
2325 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");
2326 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");
2327 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");
2328 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");
2329 uiBlockBeginAlign(block);
2330 uiDefButS(block, ROW,REDRAWVIEW3D,"UpX", 226,180,45,19, &ob->upflag, 13.0, 0.0, 0, 0, "Specify the axis that points up");
2331 uiDefButS(block, ROW,REDRAWVIEW3D,"Y", 274,180,20,19, &ob->upflag, 13.0, 1.0, 0, 0, "Specify the axis that points up");
2332 uiDefButS(block, ROW,REDRAWVIEW3D,"Z", 298,180,19,19, &ob->upflag, 13.0, 2.0, 0, 0, "Specify the axis that points up");
2334 uiBlockBeginAlign(block);
2335 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");
2336 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");
2337 uiDefButBitS(block, TOG, OB_POWERTRACK, REDRAWVIEW3D, "Powertrack", 180,155,78,19, &ob->transflag, 0, 0, 0, 0, "Switch objects rotation off");
2338 uiDefButBitS(block, TOG, PARSLOW, 0, "SlowPar", 260,155,56,19, &ob->partype, 0, 0, 0, 0, "Create a delay in the parent relationship");
2339 uiBlockBeginAlign(block);
2341 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");
2342 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");
2343 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");
2344 uiDefButBitS(block, TOG, OB_DUPLIGROUP, B_DUPLI_GROUP, "DupliGroup", 24,110,150,20, &ob->transflag, 0, 0, 0, 0, "Enable group instancing");
2345 if(ob->transflag & OB_DUPLIFRAMES)
2346 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");
2347 else if(ob->transflag & OB_DUPLIVERTS)
2348 uiDefButBitS(block, TOG, OB_DUPLIROT, REDRAWVIEW3D, "Rot", 174,110,142,20, &ob->transflag, 0, 0, 0, 0, "Rotate dupli according to vertex normal");
2349 else if(ob->transflag & OB_DUPLIFACES)
2350 uiDefButBitS(block, TOG, OB_DUPLIFACES_SCALE, REDRAWVIEW3D, "Scale", 174,110,142,20, &ob->transflag, 0, 0, 0, 0, "Scale dupli based on face size");
2352 uiDefIDPoinBut(block, test_grouppoin_but, ID_GR, B_GROUP_RELINK, "GR:", 174,110,142,20, &ob->dup_group, "Instance an existing group");
2354 uiBlockBeginAlign(block);
2355 /* DupSta and DupEnd are both shorts, so the maxframe is greater then their range
2356 just limit the buttons to the max short */
2357 uiDefButI(block, NUM, REDRAWVIEW3D, "DupSta:", 24,85,141,19, &ob->dupsta, 1.0, 32767, 0, 0, "Specify startframe for Dupliframes");
2358 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");
2359 uiDefButI(block, NUM, REDRAWVIEW3D, "DupEnd", 24,65,140,19, &ob->dupend, 1.0, 32767, 0, 0, "Specify endframe for Dupliframes");
2360 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");
2361 uiBlockBeginAlign(block);
2362 uiDefButBitS(block, TOG, OB_OFFS_OB, REDRAWALL, "Offs Ob", 24,35,56,20, &ob->ipoflag, 0, 0, 0, 0, "Not functional at the moment!");
2363 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");
2364 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");
2366 uiBlockBeginAlign(block);
2367 uiDefButF(block, NUM, REDRAWALL, "TimeOffset:", 24,10,115,20, &ob->sf, -MAXFRAMEF, MAXFRAMEF, 100, 0, "Specify an offset in frames");
2368 uiDefBut(block, BUT, B_AUTOTIMEOFS, "Automatic Time", 139,10,104,20, 0, 0, 0, 0, 0, "Generate automatic timeoffset values for all selected frames");
2369 uiDefBut(block, BUT, B_PRINTSPEED, "PrSpeed", 248,10,67,20, 0, 0, 0, 0, 0, "Print objectspeed");
2370 uiBlockEndAlign(block);
2372 sprintf(str, "%.4f", prspeed);
2373 uiDefBut(block, LABEL, 0, str, 247,35,63,31, NULL, 1.0, 0, 0, 0, "");
2377 static void object_panel_draw(Object *ob)
2382 block= uiNewBlock(&curarea->uiblocks, "object_panel_draw", UI_EMBOSS, UI_HELV, curarea->win);
2383 if(uiNewPanel(curarea, block, "Draw", "Object", 640, 0, 318, 204)==0) return;
2385 uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
2392 uiDefBut(block, LABEL, 0, "Layers", 10,170,100,20, NULL, 0, 0, 0, 0, "");
2394 uiBlockBeginAlign(block);
2396 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, "");
2398 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, "");
2401 uiBlockBeginAlign(block);
2403 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, "");
2405 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, "");
2407 uiBlockEndAlign(block);
2409 uiDefBut(block, LABEL, 0, "Drawtype", 10,120,100,20, NULL, 0, 0, 0, 0, "");
2411 uiBlockBeginAlign(block);
2412 uiDefButC(block, ROW, REDRAWVIEW3D, "Shaded", 10,100,100, 20, &ob->dt, 0, OB_SHADED, 0, 0, "Draw active object shaded or textured");
2413 uiDefButC(block, ROW, REDRAWVIEW3D, "Solid", 10,80,100, 20, &ob->dt, 0, OB_SOLID, 0, 0, "Draw active object in solid");
2414 uiDefButC(block, ROW, REDRAWVIEW3D, "Wire", 10,60, 100, 20, &ob->dt, 0, OB_WIRE, 0, 0, "Draw active object in wireframe");
2415 uiDefButC(block, ROW, REDRAWVIEW3D, "Bounds", 10,40, 100, 20, &ob->dt, 0, OB_BOUNDBOX, 0, 0, "Only draw object with bounding box");
2416 uiBlockEndAlign(block);
2418 uiDefBut(block, LABEL, 0, "Draw Extra", 120,120,90,20, NULL, 0, 0, 0, 0, "");
2420 uiBlockBeginAlign(block);
2421 uiDefButBitC(block, TOG, OB_BOUNDBOX, REDRAWVIEW3D, "Bounds", 120, 100, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's bounds");
2422 uiDefButBitC(block, TOG, OB_DRAWNAME, REDRAWVIEW3D, "Name", 210, 100, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's name");
2424 uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Polyheder%x4",
2425 120, 80, 90, 20, &ob->boundtype, 0, 0, 0, 0, "Selects the boundary display type");
2426 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");
2428 uiDefButBitC(block, TOG, OB_TEXSPACE, REDRAWVIEW3D, "TexSpace", 120, 60, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's texture space");
2429 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");
2431 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)");
2432 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");
2435 void object_panel_constraint(char *context)
2440 bConstraint *curcon;
2444 block= uiNewBlock(&curarea->uiblocks, "object_panel_constraint", UI_EMBOSS, UI_HELV, curarea->win);
2445 if(uiNewPanel(curarea, block, "Constraints", context, 960, 0, 318, 204)==0) return;
2447 uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
2449 /* this is a variable height panel, newpanel doesnt force new size on existing panels */
2450 /* so first we make it default height */
2451 uiNewPanelHeight(block, 204);
2453 /* do not allow this panel to draw in editmode - why?*/
2454 if(G.obedit==OBACT) return; // ??
2456 conlist = get_active_constraints(OBACT);
2459 uiDefBlockBut(block, add_constraintmenu, NULL, "Add Constraint", 0, 190, 130, 20, "Add a new constraint");
2461 /* print active object or bone */
2463 if (ob->flag & OB_POSEMODE) {
2464 bPoseChannel *pchan= get_active_posechannel(ob);
2465 if(pchan) sprintf(str, "To Bone: %s", pchan->name);
2468 sprintf(str, "To Object: %s", ob->id.name+2);
2470 uiDefBut(block, LABEL, 1, str, 150, 190, 150, 20, NULL, 0.0, 0.0, 0, 0, "Displays Active Object or Bone name");
2472 /* Go through the list of constraints and draw them */
2476 for (curcon = conlist->first; curcon; curcon=curcon->next) {
2477 /* hrms, the temporal constraint should not draw! */
2478 if(curcon->type==CONSTRAINT_TYPE_KINEMATIC) {
2479 bKinematicConstraint *data= curcon->data;
2480 if(data->flag & CONSTRAINT_IK_TEMP)
2483 /* Draw default constraint header */
2484 draw_constraint(block, conlist, curcon, &xco, &yco);
2487 if(yco < 0) uiNewPanelHeight(block, 204-yco);
2492 void do_effects_panels(unsigned short event)
2507 G.scene->r.framelen= G.scene->r.framapto;
2508 G.scene->r.framelen/= G.scene->r.images;
2509 allqueue(REDRAWALL, 0);
2513 if(ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) {
2514 // NT particles and fluid meshes currently dont work together -> switch off beforehand
2515 if(ob->fluidsimSettings->type == OB_FLUIDSIM_DOMAIN) {
2516 pupmenu("Fluidsim Particle Error%t|Please disable the fluidsim domain before activating particles.%x0");
2518 //ob->fluidsimFlag = 0; ob->fluidsimSettings->type = 0; allqueue(REDRAWVIEW3D, 0);
2521 if (BLI_countlist(&ob->effect)==MAX_EFFECT)
2522 error("Unable to add: effect limit reached");
2524 copy_act_effect(ob);
2526 DAG_scene_sort(G.scene);
2527 BIF_undo_push("New effect");
2528 allqueue(REDRAWBUTSOBJECT, 0);
2531 if(ob==NULL || ob->type!=OB_MESH) break;
2532 eff= ob->effect.first;
2535 if(eff->flag & SELECT) {
2536 BLI_remlink(&ob->effect, eff);
2542 BIF_undo_push("Delete effect");
2543 allqueue(REDRAWVIEW3D, 0);
2544 allqueue(REDRAWBUTSOBJECT, 0);
2547 if(ob==0 || ob->type!=OB_MESH) break;
2548 eff= ob->effect.first;
2550 if(eff->flag & SELECT) {
2552 eff->flag &= ~SELECT;
2553 eff->next->flag |= SELECT;
2559 allqueue(REDRAWBUTSOBJECT, 0);
2562 if(ob==0 || ob->type!=OB_MESH) break;
2563 eff= ob->effect.first;
2565 if(eff->flag & SELECT) {
2567 eff->flag &= ~SELECT;
2568 eff->prev->flag |= SELECT;
2574 allqueue(REDRAWBUTSOBJECT, 0);
2577 DAG_scene_sort(G.scene);
2578 /* no break, pass on */
2580 if(ob==NULL || ob->type!=OB_MESH) break;
2581 eff= ob->effect.first;
2583 if(eff->flag & SELECT) {
2584 if(eff->type==EFF_PARTICLE) build_particle_system(ob);
2588 allqueue(REDRAWVIEW3D, 0);
2589 allqueue(REDRAWBUTSOBJECT, 0);
2593 paf= give_parteff(ob);
2595 bDeformGroup *dg= get_named_vertexgroup(ob, paf->vgroupname);
2597 paf->vertgroup= get_defgroup_num(ob, dg)+1;
2601 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
2602 allqueue(REDRAWVIEW3D, 0);
2607 paf= give_parteff(ob);
2609 bDeformGroup *dg= get_named_vertexgroup(ob, paf->vgroupname_v);
2611 paf->vertgroup_v= get_defgroup_num(ob, dg)+1;
2613 paf->vertgroup_v= 0;
2615 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
2616 allqueue(REDRAWVIEW3D, 0);
2620 /* do this before scene sort, that one checks for CU_PATH */
2621 if(ob->type==OB_CURVE && ob->pd->forcefield==PFIELD_GUIDE) {
2622 Curve *cu= ob->data;
2624 cu->flag |= (CU_PATH|CU_3D);
2625 do_curvebuts(B_CU3D); /* all curves too */
2627 DAG_scene_sort(G.scene);
2629 if(ob->type==OB_CURVE && ob->pd->forcefield==PFIELD_GUIDE)
2630 DAG_object_flush_update(G.scene, ob, OB_RECALC);
2632 DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
2634 allqueue(REDRAWVIEW3D, 0);
2635 allqueue(REDRAWBUTSOBJECT, 0);
2637 case B_FIELD_CHANGE:
2638 DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
2639 allqueue(REDRAWVIEW3D, 0);
2647 if(base->lay & G.vd->lay) {
2649 eff= ob->effect.first;
2651 if(eff->flag & SELECT) {
2652 if(eff->type==EFF_PARTICLE) build_particle_system(ob);
2659 allqueue(REDRAWVIEW3D, 0);
2662 if(event>=B_SELEFFECT && event<B_SELEFFECT+MAX_EFFECT) {
2667 eff= ob->effect.first;
2669 if(event==a) eff->flag |= SELECT;
2670 else eff->flag &= ~SELECT;
2675 allqueue(REDRAWBUTSOBJECT, 0);
2682 /* Panel for particle interaction settings */
2683 static void object_panel_fields(Object *ob)
2687 block= uiNewBlock(&curarea->uiblocks, "object_panel_fields", UI_EMBOSS, UI_HELV, curarea->win);
2688 if(uiNewPanel(curarea, block, "Fields and Deflection", "Physics", 0, 0, 318, 204)==0) return;
2690 uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
2692 /* should become button, option? */
2694 ob->pd= MEM_callocN(sizeof(PartDeflect), "PartDeflect");