From 1b1667018e3e960d21ec0c802290a5e49ffe2a90 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 27 May 2009 00:03:49 +0000 Subject: UI: * Added Constraints template and Add Constraint operator. * Added toggle=True/False parameter to uiItemR, to get a toggle button (actual button) rather than an "option" button (checkbox) * Added OPTION/OPTIONN button type, to distinguish with TOG/TOGN. RNA: * Make all modifier pointers editable, including correct updates. * Added notifiers and updates to constraints. * Fix a stack corruption, pointed out by Andrea, and potentially causing crashes. --- source/blender/blenkernel/BKE_library.h | 1 + source/blender/blenkernel/intern/library.c | 6 + source/blender/editors/include/ED_object.h | 17 +- source/blender/editors/include/UI_interface.h | 9 +- source/blender/editors/interface/interface.c | 13 +- source/blender/editors/interface/interface_api.c | 11 +- .../blender/editors/interface/interface_handlers.c | 6 +- .../blender/editors/interface/interface_layout.c | 19 +- .../editors/interface/interface_templates.c | 1652 +++++++++++++++++--- source/blender/editors/interface/interface_utils.c | 6 +- .../blender/editors/interface/interface_widgets.c | 6 +- source/blender/editors/object/editconstraint.c | 293 +++- source/blender/editors/object/object_intern.h | 3 + source/blender/editors/object/object_modifier.c | 2 + source/blender/editors/object/object_ops.c | 2 + source/blender/editors/space_image/image_header.c | 14 +- source/blender/editors/space_view3d/space_view3d.c | 1 + .../blender/editors/space_view3d/view3d_header.c | 24 +- source/blender/makesrna/RNA_enum_types.h | 1 + source/blender/makesrna/intern/rna_constraint.c | 346 +++- source/blender/makesrna/intern/rna_modifier.c | 217 ++- source/blender/makesrna/intern/rna_object.c | 4 +- source/blender/makesrna/intern/rna_pose.c | 1 - source/blender/makesrna/intern/rna_sound.c | 16 +- source/blender/makesrna/intern/rna_ui.c | 2 +- source/blender/windowmanager/WM_types.h | 1 + 26 files changed, 2187 insertions(+), 486 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index e598394cc60..ce182267b93 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -45,6 +45,7 @@ void *copy_libblock(void *rt); void id_lib_extern(struct ID *id); void id_us_plus(struct ID *id); +void id_us_min(struct ID *id); int check_for_dupid(struct ListBase *lb, struct ID *id, char *name); int new_id(struct ListBase *lb, struct ID *id, const char *name); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index d0e4c1a15bc..90ab4e05d44 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -142,6 +142,12 @@ void id_us_plus(ID *id) } } +void id_us_min(ID *id) +{ + if(id) + id->us--; +} + ListBase *wich_libbase(Main *mainlib, short type) { switch( type ) { diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index c6277f319bc..3d0de795778 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -35,6 +35,7 @@ struct bContext; struct Base; struct View3D; struct bConstraint; +struct bConstraintChannel; struct KeyBlock; struct Lattice; struct Mesh; @@ -71,8 +72,20 @@ void ED_object_base_init_from_view(struct bContext *C, struct Base *base); int object_data_is_libdata(struct Object *ob); /* constraints */ -struct bConstraint *add_new_constraint (short type); -void add_constraint_to_object (struct bConstraint *con, struct Object *ob); +struct bConstraint *add_new_constraint(short type); +void add_constraint_to_object(struct bConstraint *con, struct Object *ob); + +struct ListBase *get_active_constraints(struct Object *ob); +struct bConstraint *get_active_constraint(struct Object *ob); +struct bConstraintChannel *get_active_constraint_channel(struct Scene *scene, struct Object *ob); + +void object_test_constraints(struct Object *ob); + +void ED_object_constraint_rename(struct Object *ob, struct bConstraint *con, char *oldname); +void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con); +int ED_object_constraint_delete(struct ReportList *reports, struct Object *ob, struct bConstraint *con); +int ED_object_constraint_move_down(struct ReportList *reports, struct Object *ob, struct bConstraint *con); +int ED_object_constraint_move_up(struct ReportList *reports, struct Object *ob, struct bConstraint *con); /* editlattice.c */ void mouse_lattice(struct bContext *C, short mval[2], int extend); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 144009aaa71..b5ed2c59a26 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -188,6 +188,8 @@ typedef struct uiLayout uiLayout; #define FTPREVIEW (35<<9) #define NUMABS (36<<9) #define TOGBUT (37<<9) +#define OPTION (38<<9) +#define OPTIONN (39<<9) #define BUTTYPE (63<<9) /* Drawing @@ -559,7 +561,8 @@ uiBlock *uiLayoutFreeBlock(uiLayout *layout); void uiTemplateHeader(uiLayout *layout, struct bContext *C); void uiTemplateHeaderID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop); -uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr); +uiLayout *uiTemplateModifier(uiLayout *layout, struct PointerRNA *ptr); +uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr); /* items */ void uiItemO(uiLayout *layout, char *name, int icon, char *opname); @@ -571,8 +574,8 @@ void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *pr void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value); void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, struct IDProperty *properties, int context); -void uiItemR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int expand, int slider); -void uiItemFullR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int expand, int slider); +void uiItemR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int expand, int slider, int toggle); +void uiItemFullR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int expand, int slider, int toggle); void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value); void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 3ec91975a91..e86e79f7887 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -679,7 +679,7 @@ static void ui_is_but_sel(uiBut *but) value= ui_get_but_val(but); - if( but->type==TOGN || but->type==ICONTOGN) true= 0; + if(ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) true= 0; if( but->bit ) { lvalue= (int)value; @@ -700,10 +700,12 @@ static void ui_is_but_sel(uiBut *but) case TOG3: case BUT_TOGDUAL: case ICONTOG: + case OPTION: if(value!=but->hardmin) push= 1; break; case ICONTOGN: case TOGN: + case OPTIONN: if(value==0.0) push= 1; break; case ROW: @@ -1509,7 +1511,12 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) * custom collection too for bones, vertex groups, .. */ ui_rna_ID_collection(C, but, &ptr, &prop); - if(prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr)) { + if(str == NULL || str[0] == '\0') { + memset(&rptr, 0, sizeof(rptr)); + RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr); + return 11; + } + else if(prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr)) { RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr); return 1; } @@ -1987,7 +1994,7 @@ void uiBlockEndAlign(uiBlock *block) int ui_but_can_align(uiBut *but) { - return (but->type != LABEL); + return !ELEM3(but->type, LABEL, OPTION, OPTIONN); } static void ui_block_do_align_but(uiBlock *block, uiBut *first, int nr) diff --git a/source/blender/editors/interface/interface_api.c b/source/blender/editors/interface/interface_api.c index 0aa6d9895cb..1bb34a71d0a 100644 --- a/source/blender/editors/interface/interface_api.c +++ b/source/blender/editors/interface/interface_api.c @@ -89,7 +89,8 @@ void RNA_api_ui_layout(StructRNA *srna) parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in data."); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail."); - RNA_def_boolean(func, "slider", 0, "", "Use slider for numeric values."); + RNA_def_boolean(func, "slider", 0, "", "Use slider widget for numeric values."); + RNA_def_boolean(func, "toggle", 0, "", "Use toggle widget for boolean values."); func= RNA_def_function(srna, "items_enumR", "uiItemsEnumR"); parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property."); @@ -191,11 +192,15 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_string(func, "unlink", "", 0, "", "Operator identifier to unlink the ID block."); func= RNA_def_function(srna, "template_modifier", "uiTemplateModifier"); - parm= RNA_def_pointer(func, "context", "Context", "", "Current context."); - RNA_def_property_flag(parm, PROP_REQUIRED); parm= RNA_def_pointer(func, "data", "AnyType", "", "Modifier data."); RNA_def_property_flag(parm, PROP_REQUIRED); parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "template_constraint", "uiTemplateConstraint"); + parm= RNA_def_pointer(func, "data", "AnyType", "", "Constraint data."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); + RNA_def_function_return(func, parm); } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index ce01bc19856..ec2f960dd14 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -364,7 +364,7 @@ static void ui_apply_but_TOG(bContext *C, uiBlock *block, uiBut *but, uiHandleBu if(value==0.0) push= 1; else push= 0; - if(but->type==TOGN || but->type==ICONTOGN) push= !push; + if(ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) push= !push; ui_set_but_val(but, (double)push); if(but->type==ICONTOG || but->type==ICONTOGN) ui_check_but(but); } @@ -566,6 +566,8 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut case ICONTOGN: case TOGN: case BUT_TOGDUAL: + case OPTION: + case OPTIONN: ui_apply_but_TOG(C, block, but, data); break; case ROW: @@ -2672,6 +2674,8 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) case ICONTOGN: case TOGN: case BUT_TOGDUAL: + case OPTION: + case OPTIONN: retval= ui_do_but_TOG(C, but, data, event); break; #if 0 diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 3fa0a8849fe..1b633c0fd77 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -672,7 +672,7 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA *r_h= h; } -void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int expand, int slider) +void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int expand, int slider, int toggle) { uiBlock *block= layout->root->block; uiBut *but; @@ -734,10 +734,13 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper if(slider && but->type==NUM) but->type= NUMSLI; + + if(toggle && but->type==OPTION) + but->type= TOG; } } -void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *propname, int expand, int slider) +void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *propname, int expand, int slider, int toggle) { PropertyRNA *prop; @@ -752,7 +755,7 @@ void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *prop return; } - uiItemFullR(layout, name, icon, ptr, prop, RNA_NO_INDEX, 0, expand, slider); + uiItemFullR(layout, name, icon, ptr, prop, RNA_NO_INDEX, 0, expand, slider, toggle); } void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value) @@ -770,7 +773,7 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, return; } - uiItemFullR(layout, name, icon, ptr, prop, RNA_ENUM_VALUE, value, 0, 0); + uiItemFullR(layout, name, icon, ptr, prop, RNA_ENUM_VALUE, value, 0, 0, 0); } void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname) @@ -1595,7 +1598,7 @@ static void ui_item_align(uiLayout *litem, int nr) } } -static void ui_item_layout(uiItem *item, int align) +static void ui_item_layout(uiItem *item) { uiItem *subitem; @@ -1605,7 +1608,7 @@ static void ui_item_layout(uiItem *item, int align) if(litem->items.first == NULL) return; - if(litem->align && !align) + if(litem->align) ui_item_align(litem, ++litem->root->block->alignnr); switch(litem->item.type) { @@ -1635,14 +1638,14 @@ static void ui_item_layout(uiItem *item, int align) } for(subitem=litem->items.first; subitem; subitem=subitem->next) - ui_item_layout(subitem, litem->align || align); + ui_item_layout(subitem); } } static void ui_layout_items(const bContext *C, uiBlock *block, uiLayout *layout) { ui_item_estimate(&layout->item); - ui_item_layout(&layout->item, 0); + ui_item_layout(&layout->item); } static void ui_layout_end(const bContext *C, uiBlock *block, uiLayout *layout, int *x, int *y) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 1c38f5b281b..e926b431aab 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -341,163 +341,6 @@ static void modifiers_moveDown(bContext *C, void *ob_v, void *md_v) BKE_reports_clear(&reports); } -static void modifier_testLatticeObj(bContext *C, char *name, ID **idpp) -{ - Main *bmain= CTX_data_main(C); - ID *id; - - for (id= bmain->object.first; id; id= id->next) { - if( strcmp(name, id->name+2)==0 ) { - if (((Object *)id)->type != OB_LATTICE) { - uiPupMenuError(C, "Lattice deform object must be a lattice"); - break; - } - *idpp= id; - return; - } - } - *idpp= 0; -} - -static void modifier_testCurveObj(bContext *C, char *name, ID **idpp) -{ - Main *bmain= CTX_data_main(C); - ID *id; - - for (id= bmain->object.first; id; id= id->next) { - if( strcmp(name, id->name+2)==0 ) { - if (((Object *)id)->type != OB_CURVE) { - uiPupMenuError(C, "Curve deform object must be a curve"); - break; - } - *idpp= id; - return; - } - } - *idpp= 0; -} - -static void modifier_testMeshObj(bContext *C, char *name, ID **idpp) -{ - Main *bmain= CTX_data_main(C); - Object *obact= CTX_data_active_object(C); - ID *id; - - for (id= bmain->object.first; id; id= id->next) { - /* no boolean on its own object */ - if(id != (ID *)obact) { - if( strcmp(name, id->name+2)==0 ) { - if (((Object *)id)->type != OB_MESH) { - uiPupMenuError(C, "Boolean modifier object must be a mesh"); - break; - } - *idpp= id; - return; - } - } - } - *idpp= NULL; -} - -static void modifier_testArmatureObj(bContext *C, char *name, ID **idpp) -{ - Main *bmain= CTX_data_main(C); - ID *id; - - for (id= bmain->object.first; id; id= id->next) { - if( strcmp(name, id->name+2)==0 ) { - if (((Object *)id)->type != OB_ARMATURE) { - uiPupMenuError(C, "Armature deform object must be an armature"); - break; - } - *idpp= id; - return; - } - } - *idpp= 0; -} - -static void modifier_testTexture(bContext *C, char *name, ID **idpp) -{ - Main *bmain= CTX_data_main(C); - ID *id; - - for(id = bmain->tex.first; id; id = id->next) { - if(strcmp(name, id->name + 2) == 0) { - *idpp = id; - /* texture gets user, objects not: delete object = clear modifier */ - id_us_plus(id); - return; - } - } - *idpp = 0; -} - -#if 0 /* this is currently unused, but could be useful in the future */ -static void modifier_testMaterial(bContext *C, char *name, ID **idpp) -{ - Main *bmain= CTX_data_main(C); - ID *id; - - for(id = bmain->mat.first; id; id = id->next) { - if(strcmp(name, id->name + 2) == 0) { - *idpp = id; - return; - } - } - *idpp = 0; -} -#endif - -static void modifier_testImage(bContext *C, char *name, ID **idpp) -{ - Main *bmain= CTX_data_main(C); - ID *id; - - for(id = bmain->image.first; id; id = id->next) { - if(strcmp(name, id->name + 2) == 0) { - *idpp = id; - return; - } - } - *idpp = 0; -} - -/* autocomplete callback for ID buttons */ -void autocomplete_image(bContext *C, char *str, void *arg_v) -{ - Main *bmain= CTX_data_main(C); - - /* search if str matches the beginning of an ID struct */ - if(str[0]) { - AutoComplete *autocpl = autocomplete_begin(str, 22); - ID *id; - - for(id = bmain->image.first; id; id = id->next) - autocomplete_do_name(autocpl, id->name+2); - - autocomplete_end(autocpl, str); - } -} - -/* autocomplete callback for ID buttons */ -void autocomplete_meshob(bContext *C, char *str, void *arg_v) -{ - Main *bmain= CTX_data_main(C); - - /* search if str matches the beginning of an ID struct */ - if(str[0]) { - AutoComplete *autocpl = autocomplete_begin(str, 22); - ID *id; - - for(id = bmain->object.first; id; id = id->next) - if(((Object *)id)->type == OB_MESH) - autocomplete_do_name(autocpl, id->name+2); - - autocomplete_end(autocpl, str); - } -} - static void modifiers_convertParticles(bContext *C, void *obv, void *mdv) { Scene *scene= CTX_data_scene(C); @@ -557,6 +400,23 @@ static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v) } } +static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v) +{ + Object *ob = ob_v; + ModifierData *md = md_v; + ModifierData *nmd = modifier_new(md->type); + + modifier_copyData(md, nmd); + nmd->mode &= ~eModifierMode_Virtual; + + BLI_addhead(&ob->modifiers, nmd); + + ob->partype = PAROBJECT; + + ED_undo_push(C, "Modifier convert to real"); +} + +#if 0 static void modifiers_clearHookOffset(bContext *C, void *ob_v, void *md_v) { Object *ob = ob_v; @@ -627,103 +487,6 @@ static void modifiers_reassignHook(bContext *C, void *ob_v, void *md_v) }*/ } -static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v) -{ - Object *ob = ob_v; - ModifierData *md = md_v; - ModifierData *nmd = modifier_new(md->type); - - modifier_copyData(md, nmd); - nmd->mode &= ~eModifierMode_Virtual; - - BLI_addhead(&ob->modifiers, nmd); - - ob->partype = PAROBJECT; - - ED_undo_push(C, "Modifier convert to real"); -} - -static void build_uvlayer_menu_vars(CustomData *data, char **menu_string, - int *uvlayer_tmp, char *uvlayer_name) -{ - char strtmp[38]; - int totuv, i; - CustomDataLayer *layer - = &data->layers[CustomData_get_layer_index(data, CD_MTFACE)]; - - *uvlayer_tmp = -1; - - totuv = CustomData_number_of_layers(data, CD_MTFACE); - - *menu_string = MEM_callocN(sizeof(**menu_string) * (totuv * 38 + 10), - "menu_string"); - sprintf(*menu_string, "UV Layer%%t"); - for(i = 0; i < totuv; i++) { - /* assign first layer as uvlayer_name if uvlayer_name is null. */ - if(strcmp(layer->name, uvlayer_name) == 0) *uvlayer_tmp = i + 1; - sprintf(strtmp, "|%s%%x%d", layer->name, i + 1); - strcat(*menu_string, strtmp); - layer++; - } - - /* there is no uvlayer defined, or else it was deleted. Assign active - * layer, then recalc modifiers. - */ - if(*uvlayer_tmp == -1) { - if(CustomData_get_active_layer_index(data, CD_MTFACE) != -1) { - *uvlayer_tmp = 1; - layer = data->layers; - for(i = 0; i < CustomData_get_active_layer_index(data, CD_MTFACE); - i++, layer++) { - if(layer->type == CD_MTFACE) (*uvlayer_tmp)++; - } - strcpy(uvlayer_name, layer->name); - - /* update the modifiers */ - /* XXX do_modifier_panels(B_MODIFIER_RECALC);*/ - } else { - /* ok we have no uv layers, so make sure menu button knows that.*/ - *uvlayer_tmp = 0; - } - } -} - -void set_wave_uvlayer(bContext *C, void *arg1, void *arg2) -{ - WaveModifierData *wmd=arg1; - CustomDataLayer *layer = arg2; - - /*check we have UV layers*/ - if (wmd->uvlayer_tmp < 1) return; - layer = layer + (wmd->uvlayer_tmp-1); - - strcpy(wmd->uvlayer_name, layer->name); -} - -void set_displace_uvlayer(bContext *C, void *arg1, void *arg2) -{ - DisplaceModifierData *dmd=arg1; - CustomDataLayer *layer = arg2; - - /*check we have UV layers*/ - if (dmd->uvlayer_tmp < 1) return; - layer = layer + (dmd->uvlayer_tmp-1); - - strcpy(dmd->uvlayer_name, layer->name); -} - -void set_uvproject_uvlayer(bContext *C, void *arg1, void *arg2) -{ - UVProjectModifierData *umd=arg1; - CustomDataLayer *layer = arg2; - - /*check we have UV layers*/ - if (umd->uvlayer_tmp < 1) return; - layer = layer + (umd->uvlayer_tmp-1); - - strcpy(umd->uvlayer_name, layer->name); -} - static void modifiers_bindMeshDeform(bContext *C, void *ob_v, void *md_v) { Scene *scene= CTX_data_scene(C); @@ -784,6 +547,7 @@ void modifiers_explodeDelVg(bContext *C, void *arg1, void *arg2) ExplodeModifierData *emd=arg1; emd->vgroup = 0; } +#endif static int modifier_is_fluid_particles(ModifierData *md) { @@ -794,16 +558,14 @@ static int modifier_is_fluid_particles(ModifierData *md) return 0; } -static uiLayout *draw_modifier(bContext *C, uiLayout *layout, Object *ob, ModifierData *md, int index, int cageIndex, int lastCageIndex) +static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, int index, int cageIndex, int lastCageIndex) { - Object *obedit= CTX_data_edit_object(C); ModifierTypeInfo *mti = modifierType_getInfo(md->type); uiBut *but; uiBlock *block; uiLayout *column, *row, *result= NULL; int isVirtual = md->mode&eModifierMode_Virtual; int x = 0, y = 0; // XXX , color = md->error?TH_REDALERT:TH_BUT_NEUTRAL; - int editing = (obedit==ob); short width = 295, buttonWidth = width-120-10; char str[128]; @@ -950,7 +712,7 @@ static uiLayout *draw_modifier(bContext *C, uiLayout *layout, Object *ob, Modifi return result; } -uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) +uiLayout *uiTemplateModifier(uiLayout *layout, PointerRNA *ptr) { Object *ob; ModifierData *md, *vmd; @@ -980,7 +742,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) for(i=0; vmd; i++, vmd=vmd->next) { if(md == vmd) - return draw_modifier(C, layout, ob, md, i, cageIndex, lastCageIndex); + return draw_modifier(layout, ob, md, i, cageIndex, lastCageIndex); else if(vmd->mode&eModifierMode_Virtual) i--; } @@ -988,3 +750,1375 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) return NULL; } +/************************ Constraint Template *************************/ + +#include "DNA_action_types.h" +#include "DNA_constraint_types.h" + +#include "BKE_action.h" +#include "BKE_constraint.h" + +#define REDRAWIPO 1 +#define REDRAWNLA 2 +#define REDRAWBUTSOBJECT 3 +#define REDRAWACTION 4 +#define B_CONSTRAINT_TEST 5 +#define B_CONSTRAINT_CHANGETARGET 6 +#define B_CONSTRAINT_INF 7 +#define REMAKEIPO 8 +#define B_DIFF 9 + +void do_constraint_panels(bContext *C, void *arg, int event) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_active_object(C); + + switch(event) { + case B_CONSTRAINT_TEST: + // XXX allqueue(REDRAWVIEW3D, 0); + // XXX allqueue(REDRAWBUTSOBJECT, 0); + // XXX allqueue(REDRAWBUTSEDIT, 0); + break; // no handling + case B_CONSTRAINT_INF: + /* influence; do not execute actions for 1 dag_flush */ + if (ob->pose) + ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK); + break; + case B_CONSTRAINT_CHANGETARGET: + if (ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels + DAG_scene_sort(scene); + break; + default: + break; + } + + object_test_constraints(ob); + + if(ob->pose) update_pose_constraint_flags(ob->pose); + + if(ob->type==OB_ARMATURE) DAG_object_flush_update(scene, ob, OB_RECALC_DATA|OB_RECALC_OB); + else DAG_object_flush_update(scene, ob, OB_RECALC_OB); + + // XXX allqueue(REDRAWVIEW3D, 0); + // XXX allqueue(REDRAWBUTSOBJECT, 0); + // XXX allqueue(REDRAWBUTSEDIT, 0); +} + +static void constraint_active_func(bContext *C, void *ob_v, void *con_v) +{ + ED_object_constraint_set_active(ob_v, con_v); +} + +static void del_constraint_func (bContext *C, void *ob_v, void *con_v) +{ + if(ED_object_constraint_delete(NULL, ob_v, con_v)) + ED_undo_push(C, "Delete Constraint"); +} + +static void verify_constraint_name_func (bContext *C, void *con_v, void *name_v) +{ + Object *ob= CTX_data_active_object(C); + bConstraint *con= con_v; + char oldname[32]; + + if (!con) + return; + + /* put on the stack */ + BLI_strncpy(oldname, (char *)name_v, 32); + + ED_object_constraint_rename(ob, con, oldname); + ED_object_constraint_set_active(ob, con); + // XXX allqueue(REDRAWACTION, 0); +} + +static void constraint_moveUp(bContext *C, void *ob_v, void *con_v) +{ + if(ED_object_constraint_move_up(NULL, ob_v, con_v)) + ED_undo_push(C, "Move Constraint"); +} + +static void constraint_moveDown(bContext *C, void *ob_v, void *con_v) +{ + if(ED_object_constraint_move_down(NULL, ob_v, con_v)) + ED_undo_push(C, "Move Constraint"); +} + +/* some commonly used macros in the constraints drawing code */ +#define is_armature_target(target) (target && target->type==OB_ARMATURE) +#define is_armature_owner(ob) ((ob->type == OB_ARMATURE) && (ob->flag & OB_POSEMODE)) +#define is_geom_target(target) (target && (ELEM(target->type, OB_MESH, OB_LATTICE)) ) + +/* Helper function for draw constraint - draws constraint space stuff + * This function should not be called if no menus are required + * owner/target: -1 = don't draw menu; 0= not posemode, 1 = posemode + */ +static void draw_constraint_spaceselect (uiBlock *block, bConstraint *con, short xco, short yco, short owner, short target) +{ + short tarx, ownx; + short bwidth; + + /* calculate sizes and placement of menus */ + if (owner == -1) { + bwidth = 125; + tarx = 120; + ownx = 0; + } + else if (target == -1) { + bwidth = 125; + tarx = 0; + ownx = 120; + } + else { + bwidth = 100; + tarx = 95; + ownx = tarx + bwidth; + } + + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "CSpace:", xco, yco, 80,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + uiBlockBeginAlign(block); + + /* Target-Space */ + if (target == 1) { + uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Pose Space %x2|Local with Parent %x3|Local Space %x1", + tarx, yco, bwidth, 18, &con->tarspace, 0, 0, 0, 0, "Choose space that target is evaluated in"); + } + else if (target == 0) { + uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Local (Without Parent) Space %x1", + tarx, yco, bwidth, 18, &con->tarspace, 0, 0, 0, 0, "Choose space that target is evaluated in"); + } + + /* Owner-Space */ + if (owner == 1) { + uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Owner Space %t|World Space %x0|Pose Space %x2|Local with Parent %x3|Local Space %x1", + ownx, yco, bwidth, 18, &con->ownspace, 0, 0, 0, 0, "Choose space that owner is evaluated in"); + } + else if (owner == 0) { + uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Owner Space %t|World Space %x0|Local (Without Parent) Space %x1", + ownx, yco, bwidth, 18, &con->ownspace, 0, 0, 0, 0, "Choose space that owner is evaluated in"); + } + + uiBlockEndAlign(block); +} + +/* draw panel showing settings for a constraint */ +static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) +{ + bPoseChannel *pchan= get_active_posechannel(ob); + bConstraintTypeInfo *cti; + uiBlock *block; + uiLayout *result= NULL, *col, *box; + uiBut *but; + char typestr[32]; + short width = 265; + short proxy_protected, xco=0, yco=0; + int rb_col; + + /* get constraint typeinfo */ + cti= constraint_get_typeinfo(con); + if (cti == NULL) { + /* exception for 'Null' constraint - it doesn't have constraint typeinfo! */ + if (con->type == CONSTRAINT_TYPE_NULL) + strcpy(typestr, "Null"); + else + strcpy(typestr, "Unknown"); + } + else + strcpy(typestr, cti->name); + + /* determine whether constraint is proxy protected or not */ + if (proxylocked_constraints_owner(ob, pchan)) + proxy_protected= (con->flag & CONSTRAINT_PROXY_LOCAL)==0; + else + proxy_protected= 0; + + /* unless button has own callback, it adds this callback to button */ + block= uiLayoutBlock(layout); + uiBlockSetHandleFunc(block, do_constraint_panels, NULL); + uiBlockSetFunc(block, constraint_active_func, ob, con); + + col= uiLayoutColumn(layout, 1); + box= uiLayoutBox(col); + + block= uiLayoutFreeBlock(box); + + /* Draw constraint header */ + uiBlockSetEmboss(block, UI_EMBOSSN); + + /* rounded header */ + rb_col= (con->flag & CONSTRAINT_ACTIVE)?50:20; + + /* open/close */ + 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"); + + /* name */ + if ((con->flag & CONSTRAINT_EXPAND) && (proxy_protected==0)) { + /* XXX if (con->flag & CONSTRAINT_DISABLE) + uiBlockSetCol(block, TH_REDALERT);*/ + + uiBlockSetEmboss(block, UI_EMBOSS); + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, xco+10, yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + but = uiDefBut(block, TEX, B_CONSTRAINT_TEST, "", xco+120, yco, 85, 18, con->name, 0.0, 29.0, 0.0, 0.0, "Constraint name"); + uiButSetFunc(but, verify_constraint_name_func, con, NULL); + } + else { + uiBlockSetEmboss(block, UI_EMBOSSN); + + /* XXX if (con->flag & CONSTRAINT_DISABLE) + uiBlockSetCol(block, TH_REDALERT);*/ + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, xco+10, yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, con->name, xco+120, yco-1, 135, 19, NULL, 0.0, 0.0, 0.0, 0.0, ""); + } + + // XXX uiBlockSetCol(block, TH_AUTO); + + /* proxy-protected constraints cannot be edited, so hide up/down + close buttons */ + if (proxy_protected) { + uiBlockSetEmboss(block, UI_EMBOSSN); + + /* draw a ghost icon (for proxy) and also a lock beside it, to show that constraint is "proxy locked" */ + uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, ICON_GHOST, xco+244, yco, 19, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Proxy Protected"); + uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, ICON_LOCKED, xco+262, yco, 19, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Proxy Protected"); + + uiBlockSetEmboss(block, UI_EMBOSS); + } + else { + short prev_proxylock, show_upbut, show_downbut; + + /* Up/Down buttons: + * Proxy-constraints are not allowed to occur after local (non-proxy) constraints + * as that poses problems when restoring them, so disable the "up" button where + * it may cause this situation. + * + * Up/Down buttons should only be shown (or not greyed - todo) if they serve some purpose. + */ + if (proxylocked_constraints_owner(ob, pchan)) { + if (con->prev) { + prev_proxylock= (con->prev->flag & CONSTRAINT_PROXY_LOCAL) ? 0 : 1; + } + else + prev_proxylock= 0; + } + else + prev_proxylock= 0; + + show_upbut= ((prev_proxylock == 0) && (con->prev)); + show_downbut= (con->next) ? 1 : 0; + + if (show_upbut || show_downbut) { + uiBlockBeginAlign(block); + uiBlockSetEmboss(block, UI_EMBOSS); + + if (show_upbut) { + 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"); + uiButSetFunc(but, constraint_moveUp, ob, con); + } + + if (show_downbut) { + 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"); + uiButSetFunc(but, constraint_moveDown, ob, con); + } + uiBlockEndAlign(block); + } + + + /* Close 'button' - emboss calls here disable drawing of 'button' behind X */ + uiBlockSetEmboss(block, UI_EMBOSSN); + + but = uiDefIconBut(block, BUT, B_CONSTRAINT_CHANGETARGET, ICON_X, xco+262, yco, 19, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Delete constraint"); + uiButSetFunc(but, del_constraint_func, ob, con); + + uiBlockSetEmboss(block, UI_EMBOSS); + } + + /* Set but-locks for protected settings (magic numbers are used here!) */ + if (proxy_protected) + uiBlockSetButLock(block, 1, "Cannot edit Proxy-Protected Constraint"); + + /* Draw constraint data */ + if ((con->flag & CONSTRAINT_EXPAND) == 0) { + (yco) -= 21; + } + else { + box= uiLayoutBox(col); + block= uiLayoutFreeBlock(box); + + switch (con->type) { +#ifndef DISABLE_PYTHON + case CONSTRAINT_TYPE_PYTHON: + { + bPythonConstraint *data = con->data; + bConstraintTarget *ct; + // uiBut *but2; + int tarnum, theight; + // static int pyconindex=0; + // char *menustr; + + theight = (data->tarnum)? (data->tarnum * 38) : (38); + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Script:", xco+60, yco-24, 55, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* do the scripts menu */ + /* XXX menustr = buildmenu_pyconstraints(data->text, &pyconindex); + but2 = uiDefButI(block, MENU, B_CONSTRAINT_TEST, menustr, + xco+120, yco-24, 150, 20, &pyconindex, + 0, 0, 0, 0, "Set the Script Constraint to use"); + uiButSetFunc(but2, validate_pyconstraint_cb, data, &pyconindex); + MEM_freeN(menustr); */ + + /* draw target(s) */ + if (data->flag & PYCON_USETARGETS) { + /* Draw target parameters */ + for (ct=data->targets.first, tarnum=1; ct; ct=ct->next, tarnum++) { + char tarstr[32]; + short yoffset= ((tarnum-1) * 38); + + /* target label */ + sprintf(tarstr, "Target %d:", tarnum); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, tarstr, xco+45, yco-(48+yoffset), 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* target space-selector - per target */ + if (is_armature_target(ct->tar)) { + uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Pose Space %x3|Local with Parent %x4|Local Space %x1", + xco+10, yco-(66+yoffset), 100, 18, &ct->space, 0, 0, 0, 0, "Choose space that target is evaluated in"); + } + else { + uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Target Space %t|World Space %x0|Local (Without Parent) Space %x1", + xco+10, yco-(66+yoffset), 100, 18, &ct->space, 0, 0, 0, 0, "Choose space that target is evaluated in"); + } + + uiBlockBeginAlign(block); + /* target object */ + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-(48+yoffset), 150, 18, &ct->tar, "Target Object"); + + /* subtarget */ + if (is_armature_target(ct->tar)) { + but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-(66+yoffset),150,18, &ct->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)ct->tar); + } + else if (is_geom_target(ct->tar)) { + but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+120, yco-(66+yoffset),150,18, &ct->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points"); + uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)ct->tar); + } + else { + strcpy(ct->subtarget, ""); + } + uiBlockEndAlign(block); + } + } + else { + /* Draw indication that no target needed */ + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+60, yco-48, 55, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Not Applicable", xco+120, yco-48, 150, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + } + + /* settings */ + uiBlockBeginAlign(block); + but=uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Options", xco, yco-(52+theight), (width/2),18, NULL, 0, 24, 0, 0, "Change some of the constraint's settings."); + // XXX uiButSetFunc(but, BPY_pyconstraint_settings, data, NULL); + + but=uiDefBut(block, BUT, B_CONSTRAINT_TEST, "Refresh", xco+((width/2)+10), yco-(52+theight), (width/2),18, NULL, 0, 24, 0, 0, "Force constraint to refresh it's settings"); + uiBlockEndAlign(block); + + /* constraint space settings */ + draw_constraint_spaceselect(block, con, xco, yco-(73+theight), is_armature_owner(ob), -1); + } + break; +#endif /* DISABLE_PYTHON */ + case CONSTRAINT_TYPE_ACTION: + { + bActionConstraint *data = con->data; + float minval, maxval; + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* Draw target parameters */ + uiBlockBeginAlign(block); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); + + if (is_armature_target(data->tar)) { + but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); + } + else { + strcpy(data->subtarget, ""); + } + + uiBlockEndAlign(block); + + /* Draw action/type buttons */ + uiBlockBeginAlign(block); + 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"); + 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"); + uiBlockEndAlign(block); + + /* Draw start/end frame buttons */ + uiBlockBeginAlign(block); + 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"); + 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"); + uiBlockEndAlign(block); + + /* Draw minimum/maximum transform range buttons */ + uiBlockBeginAlign(block); + if (data->type < 10) { /* rotation */ + minval = -180.0f; + maxval = 180.0f; + } + else if (data->type < 20) { /* scaling */ + minval = 0.0001f; + maxval = 1000.0f; + } + else { /* location */ + minval = -1000.0f; + maxval = 1000.0f; + } + 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"); + 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"); + uiBlockEndAlign(block); + + /* constraint space settings */ + draw_constraint_spaceselect(block, con, xco, yco-104, -1, is_armature_target(data->tar)); + } + break; + case CONSTRAINT_TYPE_CHILDOF: + { + bChildOfConstraint *data = con->data; + short normButWidth = (width/3); + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Parent:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* Draw target parameters */ + uiBlockBeginAlign(block); + 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"); + + if (is_armature_target(data->tar)) { + 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"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); + } + else if (is_geom_target(data->tar)) { + 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"); + uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar); + } + else { + strcpy(data->subtarget, ""); + } + uiBlockEndAlign(block); + + /* Draw triples of channel toggles */ + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Use Channel(s):", xco+65, yco-64, 150, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + uiBlockBeginAlign(block); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + + /* Inverse options */ + uiBlockBeginAlign(block); + 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)"); + // XXX uiButSetFunc(but, childof_const_setinv, con, NULL); + + 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)"); + // XXX uiButSetFunc(but, childof_const_clearinv, con, NULL); + uiBlockEndAlign(block); + } + break; + case CONSTRAINT_TYPE_LOCLIKE: + { + bLocateLikeConstraint *data = con->data; + + result= uiLayoutColumn(box, 0); + + /* constraint space settings */ + block= uiLayoutFreeBlock(box); + draw_constraint_spaceselect(block, con, 0, 0, is_armature_owner(ob), is_armature_target(data->tar)); + } + break; + case CONSTRAINT_TYPE_ROTLIKE: + { + bRotateLikeConstraint *data = con->data; + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* Draw target parameters */ + uiBlockBeginAlign(block); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); + + if (is_armature_target(data->tar)) { + but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); + } + else if (is_geom_target(data->tar)) { + 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"); + uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar); + } + else { + strcpy(data->subtarget, ""); + } + uiBlockEndAlign(block); + + /* Draw XYZ toggles */ + uiBlockBeginAlign(block); + 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + /* draw offset toggle */ + uiDefButBitI(block, TOG, ROTLIKE_OFFSET, B_CONSTRAINT_TEST, "Offset", xco, yco-64, 80, 18, &data->flag, 0, 24, 0, 0, "Add original rotation onto copied rotation"); + + /* constraint space settings */ + draw_constraint_spaceselect(block, con, xco, yco-94, is_armature_owner(ob), is_armature_target(data->tar)); + } + break; + case CONSTRAINT_TYPE_SIZELIKE: + { + bSizeLikeConstraint *data = con->data; + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* Draw target parameters */ + uiBlockBeginAlign(block); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); + + if (is_armature_target(data->tar)) { + but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); + } + else if (is_geom_target(data->tar)) { + 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"); + uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar); + } + else { + strcpy(data->subtarget, ""); + } + uiBlockEndAlign(block); + + /* Draw XYZ toggles */ + uiBlockBeginAlign(block); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + /* draw offset toggle */ + uiDefButBitI(block, TOG, SIZELIKE_OFFSET, B_CONSTRAINT_TEST, "Offset", xco, yco-64, 80, 18, &data->flag, 0, 24, 0, 0, "Add original scaling onto copied scaling"); + + /* constraint space settings */ + draw_constraint_spaceselect(block, con, xco, yco-94, is_armature_owner(ob), is_armature_target(data->tar)); + } + break; + case CONSTRAINT_TYPE_KINEMATIC: + { + bKinematicConstraint *data = con->data; + + /* IK Target */ + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco, yco-24, 80, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* Draw target parameters */ + uiBlockBeginAlign(block); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco, yco-44, 137, 19, &data->tar, "Target Object"); + + if (is_armature_target(data->tar)) { + but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco, yco-62,137,19, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); + } + else if (is_geom_target(data->tar)) { + but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco, yco-62,137,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points"); + uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar); + } + else { + strcpy (data->subtarget, ""); + } + + uiBlockEndAlign(block); + + /* Settings */ + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, CONSTRAINT_IK_TIP, B_CONSTRAINT_TEST, "Use Tail", xco, yco-92, 137, 19, &data->flag, 0, 0, 0, 0, "Include Bone's tail also last element in Chain"); + uiDefButS(block, NUM, B_CONSTRAINT_TEST, "ChainLen:", xco, yco-112,137,19, &data->rootbone, 0, 255, 0, 0, "If not zero, the amount of bones in this chain"); + + uiBlockBeginAlign(block); + uiDefButF(block, NUMSLI, B_CONSTRAINT_TEST, "PosW ", xco+147, yco-92, 137, 19, &data->weight, 0.01, 1.0, 2, 2, "For Tree-IK: weight of position control for this target"); + uiDefButBitS(block, TOG, CONSTRAINT_IK_ROT, B_CONSTRAINT_TEST, "Rot", xco+147, yco-112, 40,19, &data->flag, 0, 0, 0, 0, "Chain follows rotation of target"); + uiDefButF(block, NUMSLI, B_CONSTRAINT_TEST, "W ", xco+187, yco-112, 97, 19, &data->orientweight, 0.01, 1.0, 2, 2, "For Tree-IK: Weight of orientation control for this target"); + + uiBlockBeginAlign(block); + + uiDefButBitS(block, TOG, CONSTRAINT_IK_STRETCH, B_CONSTRAINT_TEST, "Stretch", xco, yco-137,137,19, &data->flag, 0, 0, 0, 0, "Enable IK stretching"); + uiBlockBeginAlign(block); + uiDefButS(block, NUM, B_CONSTRAINT_TEST, "Iterations:", xco+147, yco-137, 137, 19, &data->iterations, 1, 10000, 0, 0, "Maximum number of solving iterations"); + uiBlockEndAlign(block); + + /* Pole Vector */ + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Pole Target:", xco+147, yco-24, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + uiBlockBeginAlign(block); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+147, yco-44, 137, 19, &data->poletar, "Pole Target Object"); + if (is_armature_target(data->poletar)) { + but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+147, yco-62,137,19, &data->polesubtarget, 0, 24, 0, 0, "Pole Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->poletar); + } + else if (is_geom_target(data->poletar)) { + but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+147, yco-62,137,18, &data->polesubtarget, 0, 24, 0, 0, "Name of Vertex Group defining pole 'target' points"); + uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->poletar); + } + else { + strcpy(data->polesubtarget, ""); + } + + if (data->poletar) { + uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pole Offset ", xco, yco-167, 137, 19, &data->poleangle, -180.0, 180.0, 0, 0, "Pole rotation offset"); + } + } + break; + case CONSTRAINT_TYPE_TRACKTO: + { + bTrackToConstraint *data = con->data; + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* Draw target parameters */ + uiBlockBeginAlign(block); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); + + if (is_armature_target(data->tar)) { + but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); + } + else if (is_geom_target(data->tar)) { + 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"); + uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar); + } + else { + strcpy(data->subtarget, ""); + } + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Align:", xco+5, yco-42, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "To:", xco+12, yco-64, 25, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Up:", xco+174, yco-64, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + if (is_armature_target(data->tar)) { + uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Head/Tail:", xco, yco-94, 241, 18, &con->headtail, 0.0, 1, 0.1, 0.1, "Target along length of bone: Head=0, Tail=1"); + + /* constraint space settings */ + draw_constraint_spaceselect(block, con, xco, yco-116, is_armature_owner(ob), is_armature_target(data->tar)); + } + else { + /* constraint space settings */ + draw_constraint_spaceselect(block, con, xco, yco-94, is_armature_owner(ob), is_armature_target(data->tar)); + } + } + break; + case CONSTRAINT_TYPE_MINMAX: + { + bMinMaxConstraint *data = con->data; + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + 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"); + + /* Draw target parameters */ + uiBlockBeginAlign(block); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); + + if (is_armature_target(data->tar)) { + but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); + } + else if (is_geom_target(data->tar)) { + 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"); + uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar); + } + else { + strcpy(data->subtarget, ""); + } + uiBlockEndAlign(block); + + uiDefButBitI(block, TOG, MINMAX_STICKY, B_CONSTRAINT_TEST, "Sticky", xco, yco-24, 44, 18, &data->flag, 0, 24, 0, 0, "Immobilize object while constrained"); + uiDefButBitI(block, TOG, MINMAX_USEROT, B_CONSTRAINT_TEST, "Use Rot", xco+44, yco-24, 64, 18, &data->flag, 0, 24, 0, 0, "Use target object rotation"); + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Max/Min:", xco-8, yco-64, 54, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + uiBlockBeginAlign(block); + 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + if (is_armature_target(data->tar)) { + uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Head/Tail:", xco, yco-86, 241, 18, &con->headtail, 0.0, 1, 0.1, 0.1, "Target along length of bone: Head=0, Tail=1"); + } + + } + break; + case CONSTRAINT_TYPE_LOCKTRACK: + { + bLockTrackConstraint *data = con->data; + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* Draw target parameters */ + uiBlockBeginAlign(block); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); + + if (is_armature_target(data->tar)) { + but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); + } + else if (is_geom_target(data->tar)) { + 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"); + uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar); + } + else { + strcpy(data->subtarget, ""); + } + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "To:", xco+12, yco-64, 25, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Lock:", xco+166, yco-64, 38, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + } + break; + case CONSTRAINT_TYPE_FOLLOWPATH: + { + bFollowPathConstraint *data = con->data; + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* Draw target parameters */ + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); + + /* Draw Curve Follow toggle */ + 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"); + + /* Draw Offset number button */ + 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"); + + uiBlockBeginAlign(block); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Fw:", xco+12, yco-64, 27, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Up:", xco+174, yco-64, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + } + break; + case CONSTRAINT_TYPE_STRETCHTO: + { + bStretchToConstraint *data = con->data; + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* Draw target parameters */ + uiBlockBeginAlign(block); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); + + if (is_armature_target(data->tar)) { + but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); + } + else if (is_geom_target(data->tar)) { + 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"); + uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar); + } + else { + strcpy(data->subtarget, ""); + } + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + if (is_armature_target(data->tar)) { + uiDefButF(block, BUTM, B_CONSTRAINT_TEST, "R", xco, yco-60, 20, 18, &data->orglength, 0.0, 0, 0, 0, "Recalculate RLength"); + uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Rest Length:", xco+18, yco-60,139,18, &data->orglength, 0.0, 100, 0.5, 0.5, "Length at Rest Position"); + uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Head/Tail:", xco+155, yco-60,98,18, &con->headtail, 0.0, 1, 0.1, 0.1, "Target along length of bone: Head=0, Tail=1"); + } + else { + uiDefButF(block, BUTM, B_CONSTRAINT_TEST, "R", xco, yco-60, 20, 18, &data->orglength, 0.0, 0, 0, 0, "Recalculate RLength"); + 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"); + } + uiBlockEndAlign(block); + + 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"); + + uiBlockBeginAlign(block); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Vol:",xco+14, yco-104,30,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + 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"); + 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"); + 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"); + uiDefButI(block, ROW,B_CONSTRAINT_TEST,"NONE", xco+114, yco-104,50,18, &data->volmode, 12.0, 3.0, 0, 0, "Ignore Volume"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"Plane:",xco+175, yco-104,40,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + uiDefButI(block, ROW,B_CONSTRAINT_TEST,"X", xco+215, yco-104,20,18, &data->plane, 12.0, 0.0, 0, 0, "Keep X axis"); + uiDefButI(block, ROW,B_CONSTRAINT_TEST,"Z", xco+235, yco-104,20,18, &data->plane, 12.0, 2.0, 0, 0, "Keep Z axis"); + uiBlockEndAlign(block); + } + break; + case CONSTRAINT_TYPE_LOCLIMIT: + { + bLocLimitConstraint *data = con->data; + + int togButWidth = 50; + int textButWidth = ((width/2)-togButWidth); + + /* Draw Pairs of LimitToggle+LimitValue */ + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, LIMIT_XMIN, B_CONSTRAINT_TEST, "minX", xco, yco-28, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x value"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, LIMIT_YMIN, B_CONSTRAINT_TEST, "minY", xco, yco-50, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y value"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, LIMIT_ZMIN, B_CONSTRAINT_TEST, "minZ", xco, yco-72, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z value"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + uiBlockEndAlign(block); + + /* special option(s) */ + uiDefButBitS(block, TOG, LIMIT_TRANSFORM, B_CONSTRAINT_TEST, "For Transform", xco+(width/4), yco-100, (width/2), 18, &data->flag2, 0, 24, 0, 0, "Transforms are affected by this constraint as well"); + + /* constraint space settings */ + draw_constraint_spaceselect(block, con, xco, yco-130, is_armature_owner(ob), -1); + } + break; + case CONSTRAINT_TYPE_ROTLIMIT: + { + bRotLimitConstraint *data = con->data; + int normButWidth = (width/3); + + /* Draw Pairs of LimitToggle+LimitValue */ + uiBlockBeginAlign(block); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + /* special option(s) */ + uiDefButBitS(block, TOG, LIMIT_TRANSFORM, B_CONSTRAINT_TEST, "For Transform", xco+(width/4), yco-100, (width/2), 18, &data->flag2, 0, 24, 0, 0, "Transforms are affected by this constraint as well"); + + /* constraint space settings */ + draw_constraint_spaceselect(block, con, xco, yco-130, is_armature_owner(ob), -1); + } + break; + case CONSTRAINT_TYPE_SIZELIMIT: + { + bSizeLimitConstraint *data = con->data; + + int togButWidth = 50; + int textButWidth = ((width/2)-togButWidth); + + /* Draw Pairs of LimitToggle+LimitValue */ + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, LIMIT_XMIN, B_CONSTRAINT_TEST, "minX", xco, yco-28, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x value"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + uiBlockEndAlign(block); + + + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, LIMIT_YMIN, B_CONSTRAINT_TEST, "minY", xco, yco-50, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y value"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + uiBlockEndAlign(block); + + + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, LIMIT_ZMIN, B_CONSTRAINT_TEST, "minZ", xco, yco-72, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z value"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + uiBlockEndAlign(block); + + /* special option(s) */ + uiDefButBitS(block, TOG, LIMIT_TRANSFORM, B_CONSTRAINT_TEST, "For Transform", xco+(width/4), yco-100, (width/2), 18, &data->flag2, 0, 24, 0, 0, "Transforms are affected by this constraint as well"); + + /* constraint space settings */ + draw_constraint_spaceselect(block, con, xco, yco-130, is_armature_owner(ob), -1); + } + break; + case CONSTRAINT_TYPE_DISTLIMIT: + { + bDistLimitConstraint *data = con->data; + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* Draw target parameters */ + uiBlockBeginAlign(block); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); + + if (is_armature_target(data->tar)) { + but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); + } + else if (is_geom_target(data->tar)) { + 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"); + uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar); + } + else { + strcpy(data->subtarget, ""); + } + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + if (is_armature_target(data->tar)) { + uiDefButF(block, BUTM, B_CONSTRAINT_TEST, "R", xco, yco-60, 20, 18, &data->dist, 0, 0, 0, 0, "Recalculate distance"); + uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Distance:", xco+18, yco-60,139,18, &data->dist, 0.0, 100, 0.5, 0.5, "Radius of limiting sphere"); + uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Head/Tail:", xco+155, yco-60,100,18, &con->headtail, 0.0, 1, 0.1, 0.1, "Target along length of bone: Head=0, Tail=1"); + } + else { + uiDefButF(block, BUTM, B_CONSTRAINT_TEST, "R", xco, yco-60, 20, 18, &data->dist, 0, 0, 0, 0, "Recalculate distance"); + uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Distance:", xco+18, yco-60, 237, 18, &data->dist, 0.0, 100, 0.5, 0.5, "Radius of limiting sphere"); + } + + /* disabled soft-distance controls... currently it doesn't work yet. It was intended to be used for soft-ik (see xsi-blog for details) */ +#if 0 + uiDefButBitS(block, TOG, LIMITDIST_USESOFT, B_CONSTRAINT_TEST, "Soft", xco, yco-82, 50, 18, &data->flag, 0, 24, 0, 0, "Enables soft-distance"); + if (data->flag & LIMITDIST_USESOFT) + uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Soft-Distance:", xco+50, yco-82, 187, 18, &data->soft, 0.0, 100, 0.5, 0.5, "Distance surrounding radius when transforms should get 'delayed'"); +#endif + uiBlockEndAlign(block); + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Clamp Region:",xco+((width/2)-110), yco-104,100,18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Limit Mode%t|Inside %x0|Outside %x1|Surface %x2", xco+(width/2), yco-104, 100, 18, &data->mode, 0, 24, 0, 0, "Distances in relation to sphere of influence to allow"); + } + break; + case CONSTRAINT_TYPE_RIGIDBODYJOINT: + { + bRigidBodyJointConstraint *data = con->data; + float extremeLin = 999.f; + float extremeAngX = 180.f; + float extremeAngY = 45.f; + float extremeAngZ = 45.f; + int togButWidth = 70; + int offsetY = 150; + int textButWidth = ((width/2)-togButWidth); + + uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Generic 6DOF%x12",//|Extra Force%x6", + //uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Cone Twist%x4|Generic 6DOF%x12",//|Extra Force%x6", + xco, yco-25, 150, 18, &data->type, 0, 0, 0, 0, "Choose the joint type"); + + uiDefButBitS(block, TOG, CONSTRAINT_DISABLE_LINKED_COLLISION, B_CONSTRAINT_TEST, "No Collision", xco+155, yco-25, 111, 18, &data->flag, 0, 24, 0, 0, "Disable Collision Between Linked Bodies"); + + + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "toObject:", xco, yco-50, 130, 18, &data->tar, "Child Object"); + 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"); + + uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot X:", xco, yco-75, 130, 18, &data->pivX, -1000, 1000, 100, 0.0, "Offset pivot on X"); + uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Y:", xco, yco-100, 130, 18, &data->pivY, -1000, 1000, 100, 0.0, "Offset pivot on Y"); + uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Z:", xco, yco-125, 130, 18, &data->pivZ, -1000, 1000, 100, 0.0, "Offset pivot on z"); + + 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)"); + 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)"); + 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)"); + + if (data->type==CONSTRAINT_RB_GENERIC6DOF) { + /* Draw Pairs of LimitToggle+LimitValue */ + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, 1, B_CONSTRAINT_TEST, "LinMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + uiBlockEndAlign(block); + + offsetY += 20; + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, 2, B_CONSTRAINT_TEST, "LinMinY", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y limit"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + uiBlockEndAlign(block); + + offsetY += 20; + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, 4, B_CONSTRAINT_TEST, "LinMinZ", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z limit"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + uiBlockEndAlign(block); + offsetY += 20; + } + if ((data->type==CONSTRAINT_RB_GENERIC6DOF) || (data->type==CONSTRAINT_RB_CONETWIST)) { + /* Draw Pairs of LimitToggle+LimitValue */ + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, 8, B_CONSTRAINT_TEST, "AngMinX", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum x limit"); + 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"); + uiBlockEndAlign(block); + uiBlockBeginAlign(block); + 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"); + 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"); + uiBlockEndAlign(block); + + offsetY += 20; + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, 16, B_CONSTRAINT_TEST, "AngMinY", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum y limit"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + uiBlockEndAlign(block); + + offsetY += 20; + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, 32, B_CONSTRAINT_TEST, "AngMinZ", xco, yco-offsetY, togButWidth, 18, &data->flag, 0, 24, 0, 0, "Use minimum z limit"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + uiBlockEndAlign(block); + } + + } + break; + case CONSTRAINT_TYPE_CLAMPTO: + { + bClampToConstraint *data = con->data; + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* Draw target parameters */ + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); + + /* Draw XYZ toggles */ + uiBlockBeginAlign(block); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Main Axis:", xco, yco-64, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + 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"); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + /* Extra Options Controlling Behaviour */ + //uiBlockBeginAlign(block); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Options:", xco, yco-88, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + uiDefButBitI(block, TOG, CLAMPTO_CYCLIC, B_CONSTRAINT_TEST, "Cyclic", xco+((width/2)), yco-88,60,19, &data->flag2, 0, 0, 0, 0, "Treat curve as cyclic curve (no clamping to curve bounding box)"); + //uiBlockEndAlign(block); + } + break; + case CONSTRAINT_TYPE_TRANSFORM: + { + bTransformConstraint *data = con->data; + float fmin, fmax, tmin, tmax; + + /* Draw target parameters */ + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* Draw target parameters */ + uiBlockBeginAlign(block); + 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"); + + if (is_armature_target(data->tar)) { + 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"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar); + } + else if (is_geom_target(data->tar)) { + 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"); + uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar); + } + else { + strcpy(data->subtarget, ""); + } + uiBlockEndAlign(block); + + /* Extrapolate Ranges? */ + uiDefButBitC(block, TOG, 1, B_CONSTRAINT_TEST, "Extrapolate", xco-10, yco-42,80,19, &data->expo, 0, 0, 0, 0, "Extrapolate ranges"); + + /* Draw options for source motion */ + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Source:", xco-10, yco-62, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* draw Loc/Rot/Size toggles */ + uiBlockBeginAlign(block); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + /* Draw Pairs of Axis: Min/Max Value*/ + if (data->from == 2) { + fmin= 0.0001; + fmax= 1000.0; + } + else if (data->from == 1) { + fmin= -360.0; + fmax= 360.0; + } + else { + fmin = -1000.0; + fmax= 1000.0; + } + + uiBlockBeginAlign(block); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "X:", xco-10, yco-107, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + 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"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Y:", xco-10, yco-127, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + 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"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Z:", xco-10, yco-147, 30, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + 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"); + 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"); + uiBlockEndAlign(block); + + + /* Draw options for target motion */ + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Destination:", xco+150, yco-62, 150, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + + /* draw Loc/Rot/Size toggles */ + uiBlockBeginAlign(block); + uiDefButS(block, ROW, B_CONSTRAINT_TEST, "Loc", xco+150, yco-82, 45, 18, &data->to, 12.0, 0, 0, 0, "Use as Location transform"); + uiDefButS(block, ROW, B_CONSTRAINT_TEST, "Rot", xco+195, yco-82, 45, 18, &data->to, 12.0, 1, 0, 0, "Use as Rotation transform"); + uiDefButS(block, ROW, B_CONSTRAINT_TEST, "Scale", xco+245, yco-82, 45, 18, &data->to, 12.0, 2, 0, 0, "Use as Scale transform"); + uiBlockEndAlign(block); + + /* Draw Pairs of Source-Axis: Min/Max Value*/ + if (data->to == 2) { + tmin= 0.0001; + tmax= 1000.0; + } + else if (data->to == 1) { + tmin= -360.0; + tmax= 360.0; + } + else { + tmin = -1000.0; + tmax= 1000.0; + } + + uiBlockBeginAlign(block); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + 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"); + 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"); + 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"); + uiBlockEndAlign(block); + + /* constraint space settings */ + draw_constraint_spaceselect(block, con, xco, yco-170, is_armature_owner(ob), is_armature_target(data->tar)); + } + break; + case CONSTRAINT_TYPE_NULL: + { + uiItemL(box, "", 0); + } + break; + + case CONSTRAINT_TYPE_SHRINKWRAP: + { + bShrinkwrapConstraint *data = con->data; + + /* Draw parameters */ + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + uiDefIDPoinBut(block, test_meshobpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->target, "Target Object"); + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Dist:", xco + 75, yco-42, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", xco+120, yco-42, 135, 18, &data->dist, -100.0f, 100.0f, 1.0f, 0.0f, "Distance to target"); + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Type:", xco + 70, yco-60, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + uiDefButS(block, MENU, B_MODIFIER_RECALC, "Shrinkwrap Type%t|Nearest Surface Point %x0|Projection %x1|Nearest Vertex %x2", xco+120, yco-60, 135, 18, &data->shrinkType, 0, 0, 0, 0, "Selects type of shrinkwrap algorithm for target position."); + + if(data->shrinkType == MOD_SHRINKWRAP_PROJECT) + { + /* Draw XYZ toggles */ + uiDefBut(block, LABEL,B_CONSTRAINT_TEST, "Axis:", xco+ 75, yco-78, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + uiDefButBitC(block, TOG, MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS, B_CONSTRAINT_TEST, "X",xco+120, yco-78, 45, 18, &data->projAxis, 0, 0, 0, 0, "Projection over X axis"); + uiDefButBitC(block, TOG, MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS, B_CONSTRAINT_TEST, "Y",xco+165, yco-78, 45, 18, &data->projAxis, 0, 0, 0, 0, "Projection over Y axis"); + uiDefButBitC(block, TOG, MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS, B_CONSTRAINT_TEST, "Z",xco+210, yco-78, 45, 18, &data->projAxis, 0, 0, 0, 0, "Projection over Z axis"); + } + } + break; + default: + result= box; + break; + } + } + + if (ELEM(con->type, CONSTRAINT_TYPE_NULL, CONSTRAINT_TYPE_RIGIDBODYJOINT)==0) { + box= uiLayoutBox(col); + block= uiLayoutFreeBlock(box); + uiBlockBeginAlign(block); + uiDefButF(block, NUMSLI, B_CONSTRAINT_INF, "Influence ", xco, yco, width, 20, &(con->enforce), 0.0, 1.0, 0.0, 0.0, "Amount of influence this constraint will have on the final solution"); + uiBlockEndAlign(block); + + // XXX Show/Key buttons, functionaly can be replaced with right click menu? + } + + /* clear any locks set up for proxies/lib-linking */ + uiBlockClearButLock(block); + + return result; +} + +uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) +{ + Object *ob; + bConstraint *con; + + /* verify we have valid data */ + if(!RNA_struct_is_a(ptr->type, &RNA_Constraint)) { + printf("uiTemplateConstraint: expected constraint on object.\n"); + return NULL; + } + + ob= ptr->id.data; + con= ptr->data; + + if(!ob || !(GS(ob->id.name) == ID_OB)) { + printf("uiTemplateConstraint: expected constraint on object.\n"); + return NULL; + } + + uiBlockSetButLock(uiLayoutBlock(layout), (ob && ob->id.lib), ERROR_LIBDATA_MESSAGE); + + /* hrms, the temporal constraint should not draw! */ + if(con->type==CONSTRAINT_TYPE_KINEMATIC) { + bKinematicConstraint *data= con->data; + if(data->flag & CONSTRAINT_IK_TEMP) + return NULL; + } + + return draw_constraint(layout, ob, con); +} + diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index ce44ad53378..465270694d5 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -268,7 +268,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind else if(icon) but= uiDefIconTextButR(block, ICONTOG, 0, icon, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); else - but= uiDefButR(block, TOG, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); + but= uiDefButR(block, OPTION, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); break; } case PROP_INT: @@ -338,7 +338,7 @@ void uiDefAutoButsRNA(const bContext *C, uiLayout *layout, PointerRNA *ptr) name= (char*)RNA_property_ui_name(prop); uiItemL(uiLayoutColumn(split, 0), name, 0); - uiItemFullR(uiLayoutColumn(split, 0), "", 0, ptr, prop, -1, 0, 0, 0); + uiItemFullR(uiLayoutColumn(split, 0), "", 0, ptr, prop, -1, 0, 0, 0, 0); } RNA_property_collection_end(&iter); @@ -366,7 +366,7 @@ void uiDefAutoButsRNA_single(const bContext *C, uiLayout *layout, PointerRNA *pt name= (char*)RNA_property_ui_name(prop); col= uiLayoutColumn(layout, 1); uiItemL(col, name, 0); - uiItemFullR(col, "", 0, ptr, prop, -1, 0, 0, 0); + uiItemFullR(col, "", 0, ptr, prop, -1, 0, 0, 0, 0); } RNA_property_collection_end(&iter); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 00bd3a57334..cab02a052be 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1811,11 +1811,13 @@ void ui_draw_but(ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) wt= widget_type(UI_WTYPE_NAME); break; case TOGBUT: - wt= widget_type(UI_WTYPE_TOGGLE); - break; case TOG: case TOGN: case TOG3: + wt= widget_type(UI_WTYPE_TOGGLE); + break; + case OPTION: + case OPTIONN: if (!(but->flag & UI_HAS_ICON)) { wt= widget_type(UI_WTYPE_OPTION); but->flag |= UI_TEXT_LEFT; diff --git a/source/blender/editors/object/editconstraint.c b/source/blender/editors/object/editconstraint.c index d0e487f98c7..b2cf3be6229 100644 --- a/source/blender/editors/object/editconstraint.c +++ b/source/blender/editors/object/editconstraint.c @@ -49,17 +49,27 @@ #include "BKE_action.h" #include "BKE_armature.h" #include "BKE_constraint.h" +#include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_global.h" #include "BKE_main.h" #include "BKE_object.h" +#include "BKE_report.h" #include "BKE_utildefines.h" #ifndef DISABLE_PYTHON #include "BPY_extern.h" #endif +#include "WM_api.h" +#include "WM_types.h" + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + #include "ED_object.h" +#include "ED_screen.h" #include "object_intern.h" @@ -589,55 +599,6 @@ void ob_clear_constraints (Scene *scene) BIF_undo_push("Clear Constraint(s)"); } -/* Rename the given constraint - * - con already has the new name - */ -void rename_constraint (Object *ob, bConstraint *con, char *oldname) -{ - bConstraint *tcon; - ListBase *conlist= NULL; - int from_object= 0; - char *channame=""; - - /* get context by searching for con (primitive...) */ - for (tcon= ob->constraints.first; tcon; tcon= tcon->next) { - if (tcon==con) - break; - } - - if (tcon) { - conlist= &ob->constraints; - channame= "Object"; - from_object= 1; - } - else if (ob->pose) { - bPoseChannel *pchan; - - for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) { - for (tcon= pchan->constraints.first; tcon; tcon= tcon->next) { - if (tcon==con) - break; - } - if (tcon) - break; - } - - if (tcon) { - conlist= &pchan->constraints; - channame= pchan->name; - } - } - - if (conlist==NULL) { - printf("rename constraint failed\n"); /* should not happen in UI */ - return; - } - - /* first make sure it's a unique name within context */ - unique_constraint_name (con, conlist); -} - - /* ------------- Constraint Sanity Testing ------------------- */ /* checks validity of object pointers, and NULLs, @@ -889,3 +850,237 @@ void childof_const_clearinv (void *conv, void *unused) /* simply clear the matrix */ Mat4One(data->invmat); } + +/***************************** BUTTONS ****************************/ + +/* Rename the given constraint, con already has the new name */ +void ED_object_constraint_rename(Object *ob, bConstraint *con, char *oldname) +{ + bConstraint *tcon; + ListBase *conlist= NULL; + int from_object= 0; + char *channame=""; + + /* get context by searching for con (primitive...) */ + for (tcon= ob->constraints.first; tcon; tcon= tcon->next) { + if (tcon==con) + break; + } + + if (tcon) { + conlist= &ob->constraints; + channame= "Object"; + from_object= 1; + } + else if (ob->pose) { + bPoseChannel *pchan; + + for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) { + for (tcon= pchan->constraints.first; tcon; tcon= tcon->next) { + if (tcon==con) + break; + } + if (tcon) + break; + } + + if (tcon) { + conlist= &pchan->constraints; + channame= pchan->name; + } + } + + if (conlist==NULL) { + printf("rename constraint failed\n"); /* should not happen in UI */ + return; + } + + /* first make sure it's a unique name within context */ + unique_constraint_name (con, conlist); +} + + + + +void ED_object_constraint_set_active(Object *ob, bConstraint *con) +{ + ListBase *lb; + bConstraint *origcon= con; + + /* lets be nice and escape if its active already */ + if(con && (con->flag & CONSTRAINT_ACTIVE)) + return ; + + lb= get_active_constraints(ob); + if(lb == NULL) + return; + + for(con= lb->first; con; con= con->next) { + if(con==origcon) con->flag |= CONSTRAINT_ACTIVE; + else con->flag &= ~CONSTRAINT_ACTIVE; + } + + /* make sure ipowin and buttons shows it */ + if(ob->ipowin==ID_CO) { + // XXX allqueue(REDRAWIPO, ID_CO); + // XXX allspace(REMAKEIPO, 0); + // XXX allqueue(REDRAWNLA, 0); + } + // XXX allqueue(REDRAWBUTSOBJECT, 0); +} + +int ED_object_constraint_delete(ReportList *reports, Object *ob, bConstraint *con) +{ + bConstraintChannel *chan; + ListBase *lb; + + /* remove ipo channel */ + lb= NULL; // XXX get_active_constraint_channels(ob, 0); + if(lb) { + chan = NULL; // XXX get_constraint_channel(lb, con->name); + if(chan) { + if(chan->ipo) chan->ipo->id.us--; + BLI_freelinkN(lb, chan); + } + } + + /* remove constraint itself */ + lb= get_active_constraints(ob); + free_constraint_data(con); + BLI_freelinkN(lb, con); + + ED_object_constraint_set_active(ob, NULL); + + return 1; +} + +int ED_object_constraint_move_down(ReportList *reports, Object *ob, bConstraint *constr) +{ + bConstraint *con; + ListBase *conlist; + + if(constr->next) { + conlist = get_active_constraints(ob); + for(con= conlist->first; con; con= con->next) { + if(con==constr) { + BLI_remlink(conlist, con); + BLI_insertlink(conlist, con->next, con); + return 1; + } + } + } + + return 0; +} + +int ED_object_constraint_move_up(ReportList *reports, Object *ob, bConstraint *constr) +{ + bConstraint *con; + ListBase *conlist; + + if(constr->prev) { + conlist = get_active_constraints(ob); + for(con= conlist->first; con; con= con->next) { + if(con==constr) { + BLI_remlink(conlist, con); + BLI_insertlink(conlist, con->prev->prev, con); + return 1; + } + } + } + + return 0; +} + +/***************************** OPERATORS ****************************/ + +/************************ add constraint operator *********************/ + +static int constraint_add_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + bConstraint *con; + ListBase *list= get_active_constraints(ob); + bPoseChannel *pchan= get_active_posechannel(ob); + int type= RNA_enum_get(op->ptr, "type"); + + con = add_new_constraint(type); + + if(list) { + unique_constraint_name(con, list); + BLI_addtail(list, con); + + if(proxylocked_constraints_owner(ob, pchan)) + con->flag |= CONSTRAINT_PROXY_LOCAL; + + con->flag |= CONSTRAINT_ACTIVE; + for(con= con->prev; con; con= con->prev) + con->flag &= ~CONSTRAINT_ACTIVE; + } + + switch(type) { + case CONSTRAINT_TYPE_CHILDOF: + { + /* if this constraint is being added to a posechannel, make sure + * the constraint gets evaluated in pose-space */ + if(ob->flag & OB_POSEMODE) { + con->ownspace = CONSTRAINT_SPACE_POSE; + con->flag |= CONSTRAINT_SPACEONCE; + } + } + break; + case CONSTRAINT_TYPE_RIGIDBODYJOINT: + { + bRigidBodyJointConstraint *data; + + /* set selected first object as target - moved from new_constraint_data */ + data = (bRigidBodyJointConstraint*)con->data; + + CTX_DATA_BEGIN(C, Object*, selob, selected_objects) { + if(selob != ob) { + data->tar= selob; + break; + } + } + CTX_DATA_END; + } + break; + default: + break; + } + + object_test_constraints(ob); + + if(ob->pose) + update_pose_constraint_flags(ob->pose); + + if(ob->type==OB_ARMATURE) + DAG_object_flush_update(scene, ob, OB_RECALC_DATA|OB_RECALC_OB); + else + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_constraint_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Constraint"; + ot->description = "Add a constraint to the active object."; + ot->idname= "OBJECT_OT_constraint_add"; + + /* api callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= constraint_add_exec; + + ot->poll= ED_operator_object_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); +} + diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 223f2190f4b..ce8bd7287f7 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -88,5 +88,8 @@ void GROUP_OT_objects_remove_active(struct wmOperatorType *ot); void OBJECT_OT_modifier_add(struct wmOperatorType *ot); void OBJECT_OT_multires_subdivide(struct wmOperatorType *ot); +/* editconstraint.c */ +void OBJECT_OT_constraint_add(struct wmOperatorType *ot); + #endif /* ED_OBJECT_INTERN_H */ diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 68b8c4a6a14..2bbc68ac039 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -368,6 +368,8 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", modifier_type_items, 0, "Type", ""); } +/****************** multires subdivide operator *********************/ + static int multires_subdivide_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index f2a020e69a6..9d8247522e1 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -101,6 +101,8 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_modifier_add); WM_operatortype_append(OBJECT_OT_multires_subdivide); + + WM_operatortype_append(OBJECT_OT_constraint_add); } void ED_keymap_object(wmWindowManager *wm) diff --git a/source/blender/editors/space_image/image_header.c b/source/blender/editors/space_image/image_header.c index 2accef990d3..9a61d3a7081 100644 --- a/source/blender/editors/space_image/image_header.c +++ b/source/blender/editors/space_image/image_header.c @@ -150,8 +150,8 @@ static void image_viewmenu(bContext *C, uiLayout *layout, void *arg_unused) uiItemS(layout); - uiItemR(layout, NULL, 0, &spaceptr, "update_automatically", 0, 0); - // XXX if(show_uvedit) uiItemR(layout, NULL, 0, &uvptr, "local_view", 0, 0); // "UV Local View", Numpad / + uiItemR(layout, NULL, 0, &spaceptr, "update_automatically", 0, 0, 0); + // XXX if(show_uvedit) uiItemR(layout, NULL, 0, &uvptr, "local_view", 0, 0, 0); // "UV Local View", Numpad / uiItemS(layout); @@ -234,7 +234,7 @@ static void image_imagemenu(bContext *C, uiLayout *layout, void *arg_unused) uiItemS(layout); - uiItemR(layout, NULL, 0, &spaceptr, "image_painting", 0, 0); + uiItemR(layout, NULL, 0, &spaceptr, "image_painting", 0, 0, 0); /* move to realtime properties panel */ RNA_id_pointer_create(&ima->id, &imaptr); @@ -338,12 +338,12 @@ static void image_uvsmenu(bContext *C, uiLayout *layout, void *arg_unused) RNA_id_pointer_create(&scene->id, &sceneptr); /* create menu */ - uiItemR(layout, NULL, 0, &uvptr, "snap_to_pixels", 0, 0); - uiItemR(layout, NULL, 0, &uvptr, "constrain_to_image_bounds", 0, 0); + uiItemR(layout, NULL, 0, &uvptr, "snap_to_pixels", 0, 0, 0); + uiItemR(layout, NULL, 0, &uvptr, "constrain_to_image_bounds", 0, 0, 0); uiItemS(layout); - uiItemR(layout, NULL, 0, &uvptr, "live_unwrap", 0, 0); + uiItemR(layout, NULL, 0, &uvptr, "live_unwrap", 0, 0, 0); uiItemO(layout, NULL, 0, "UV_OT_unwrap"); uiItemBooleanO(layout, "Unpin", 0, "UV_OT_pin", "clear", 1); uiItemO(layout, NULL, 0, "UV_OT_pin"); @@ -363,7 +363,7 @@ static void image_uvsmenu(bContext *C, uiLayout *layout, void *arg_unused) uiItemS(layout); - uiItemR(layout, NULL, 0, &sceneptr, "proportional_editing", 0, 0); + uiItemR(layout, NULL, 0, &sceneptr, "proportional_editing", 0, 0, 0); uiItemMenuEnumR(layout, NULL, 0, &sceneptr, "proportional_editing_falloff"); uiItemS(layout); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 3b3fd5109cf..70f90a1a9d9 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -393,6 +393,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) case ND_GEOM_DATA: case ND_DRAW: case ND_MODIFIER: + case ND_CONSTRAINT: case ND_KEYS: ED_region_tag_redraw(ar); break; diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 6f67d0076aa..5e553592f21 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -3359,7 +3359,7 @@ static void view3d_edit_curvemenu(bContext *C, uiLayout *layout, void *arg_unuse uiItemS(layout); - uiItemR(layout, NULL, 0, &sceneptr, "proportional_editing", 0, 0); // |O + uiItemR(layout, NULL, 0, &sceneptr, "proportional_editing", 0, 0, 0); // |O uiItemMenuEnumR(layout, NULL, 0, &sceneptr, "proportional_editing_falloff"); uiItemS(layout); @@ -4533,12 +4533,12 @@ static void view3d_sculpt_menu(bContext *C, uiLayout *layout, void *arg_unused) RNA_pointer_create(&sc->id, &RNA_Sculpt, s, &rna); - uiItemR(layout, NULL, 0, &rna, "symmetry_x", 0, 0); - uiItemR(layout, NULL, 0, &rna, "symmetry_y", 0, 0); - uiItemR(layout, NULL, 0, &rna, "symmetry_z", 0, 0); - uiItemR(layout, NULL, 0, &rna, "lock_x", 0, 0); - uiItemR(layout, NULL, 0, &rna, "lock_y", 0, 0); - uiItemR(layout, NULL, 0, &rna, "lock_z", 0, 0); + uiItemR(layout, NULL, 0, &rna, "symmetry_x", 0, 0, 0); + uiItemR(layout, NULL, 0, &rna, "symmetry_y", 0, 0, 0); + uiItemR(layout, NULL, 0, &rna, "symmetry_z", 0, 0, 0); + uiItemR(layout, NULL, 0, &rna, "lock_x", 0, 0, 0); + uiItemR(layout, NULL, 0, &rna, "lock_y", 0, 0, 0); + uiItemR(layout, NULL, 0, &rna, "lock_z", 0, 0, 0); /* Brush settings */ RNA_pointer_create(&sc->id, &RNA_Brush, s->brush, &rna); @@ -4551,12 +4551,12 @@ static void view3d_sculpt_menu(bContext *C, uiLayout *layout, void *arg_unused) uiItemS(layout); - uiItemR(layout, NULL, 0, &rna, "airbrush", 0, 0); - uiItemR(layout, NULL, 0, &rna, "rake", 0, 0); - uiItemR(layout, NULL, 0, &rna, "anchored", 0, 0); - uiItemR(layout, NULL, 0, &rna, "space", 0, 0); + uiItemR(layout, NULL, 0, &rna, "airbrush", 0, 0, 0); + uiItemR(layout, NULL, 0, &rna, "rake", 0, 0, 0); + uiItemR(layout, NULL, 0, &rna, "anchored", 0, 0, 0); + uiItemR(layout, NULL, 0, &rna, "space", 0, 0, 0); - uiItemR(layout, NULL, 0, &rna, "flip_direction", 0, 0); + uiItemR(layout, NULL, 0, &rna, "flip_direction", 0, 0, 0); } uiBlock *view3d_sculptmenu(bContext *C, ARegion *ar, void *arg_unused) diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 2262c73a9af..c679d9fc544 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -33,6 +33,7 @@ extern EnumPropertyItem prop_mode_items[]; extern EnumPropertyItem space_type_items[]; extern EnumPropertyItem region_type_items[]; extern EnumPropertyItem modifier_type_items[]; +extern EnumPropertyItem constraint_type_items[]; extern EnumPropertyItem beztriple_handle_type_items[]; extern EnumPropertyItem beztriple_interpolation_mode_items[]; diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 774f2f9c0ef..6f3e85e0103 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -27,12 +27,45 @@ #include "RNA_define.h" #include "RNA_types.h" +#include "DNA_action_types.h" #include "DNA_constraint_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "WM_types.h" + +EnumPropertyItem constraint_type_items[] ={ + {CONSTRAINT_TYPE_NULL, "NULL", "Null", ""}, + {CONSTRAINT_TYPE_CHILDOF, "CHILD_OF", "Child Of", ""}, + {CONSTRAINT_TYPE_TRACKTO, "TRACK_TO", "Track To", ""}, + {CONSTRAINT_TYPE_KINEMATIC, "IK", "IK", ""}, + {CONSTRAINT_TYPE_FOLLOWPATH, "FOLLOW_PATH", "Follow Path", ""}, + {CONSTRAINT_TYPE_ROTLIMIT, "LIMIT_ROTATION", "Limit Rotation", ""}, + {CONSTRAINT_TYPE_LOCLIMIT, "LIMIT_LOCATION", "Limit Location", ""}, + {CONSTRAINT_TYPE_SIZELIMIT, "LIMIT_SCALE", "Limit Scale", ""}, + {CONSTRAINT_TYPE_ROTLIKE, "COPY_ROTATION", "Copy Rotation", ""}, + {CONSTRAINT_TYPE_LOCLIKE, "COPY_LOCATION", "Copy Location", ""}, + {CONSTRAINT_TYPE_SIZELIKE, "COPY_SCALE", "Copy Scale", ""}, + {CONSTRAINT_TYPE_PYTHON, "SCRIPT", "Script", ""}, + {CONSTRAINT_TYPE_ACTION, "ACTION", "Action", ""}, + {CONSTRAINT_TYPE_LOCKTRACK, "LOCKED_TRACK", "Locked Track", ""}, + {CONSTRAINT_TYPE_DISTLIMIT, "LIMIT_DISTANCE", "Limit Distance", ""}, + {CONSTRAINT_TYPE_STRETCHTO, "STRETCH_TO", "Stretch To", ""}, + {CONSTRAINT_TYPE_MINMAX, "FLOOR", "Floor", ""}, + {CONSTRAINT_TYPE_RIGIDBODYJOINT, "RIGID_BODY_JOINT", "Rigid Body Joint", ""}, + {CONSTRAINT_TYPE_CLAMPTO, "CLAMP_TO", "Clamp To", ""}, + {CONSTRAINT_TYPE_TRANSFORM, "TRANSFORM", "Transformation", ""}, + {0, NULL, NULL, NULL}}; + + #ifdef RNA_RUNTIME +#include "BKE_action.h" +#include "BKE_context.h" +#include "BKE_depsgraph.h" + +#include "ED_object.h" + StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr) { bConstraint *con= (bConstraint*)ptr->data; @@ -47,21 +80,21 @@ StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr) case CONSTRAINT_TYPE_FOLLOWPATH: return &RNA_FollowPathConstraint; case CONSTRAINT_TYPE_ROTLIKE: - return &RNA_RotateLikeConstraint; + return &RNA_CopyRotationConstraint; case CONSTRAINT_TYPE_LOCLIKE: - return &RNA_LocateLikeConstraint; + return &RNA_CopyLocationConstraint; case CONSTRAINT_TYPE_SIZELIKE: - return &RNA_SizeLikeConstraint; + return &RNA_CopyScaleConstraint; case CONSTRAINT_TYPE_PYTHON: return &RNA_PythonConstraint; case CONSTRAINT_TYPE_ACTION: return &RNA_ActionConstraint; case CONSTRAINT_TYPE_LOCKTRACK: - return &RNA_LockTrackConstraint; + return &RNA_LockedTrackConstraint; case CONSTRAINT_TYPE_STRETCHTO: return &RNA_StretchToConstraint; case CONSTRAINT_TYPE_MINMAX: - return &RNA_MinMaxConstraint; + return &RNA_FloorConstraint; case CONSTRAINT_TYPE_RIGIDBODYJOINT: return &RNA_RigidBodyJointConstraint; case CONSTRAINT_TYPE_CLAMPTO: @@ -69,18 +102,66 @@ StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr) case CONSTRAINT_TYPE_TRANSFORM: return &RNA_TransformConstraint; case CONSTRAINT_TYPE_ROTLIMIT: - return &RNA_RotationLimitConstraint; + return &RNA_LimitRotationConstraint; case CONSTRAINT_TYPE_LOCLIMIT: - return &RNA_LocationLimitConstraint; + return &RNA_LimitLocationConstraint; case CONSTRAINT_TYPE_SIZELIMIT: - return &RNA_SizeLimitConstraint; + return &RNA_LimitScaleConstraint; case CONSTRAINT_TYPE_DISTLIMIT: - return &RNA_DistLimitConstraint; + return &RNA_LimitDistanceConstraint; default: return &RNA_UnknownType; } } +static char *rna_Constraint_path(PointerRNA *ptr) +{ + return BLI_sprintfN("constraints[%s]", ((bConstraint*)ptr->data)->name); // XXX not unique +} + +void rna_CopyLocationConstraint_target_set(PointerRNA *ptr, PointerRNA value) +{ + bLocateLikeConstraint *data= (bLocateLikeConstraint*)(((bConstraint*)ptr->data)->data); + + if(value.data != data->tar) { + data->tar= value.data; + data->subtarget[0]= '\0'; + } +} + +static void rna_Constraint_update(bContext *C, PointerRNA *ptr) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= ptr->id.data; + + if(ob->pose) update_pose_constraint_flags(ob->pose); + + object_test_constraints(ob); + + if(ob->type==OB_ARMATURE) DAG_object_flush_update(scene, ob, OB_RECALC_DATA|OB_RECALC_OB); + else DAG_object_flush_update(scene, ob, OB_RECALC_OB); +} + +static void rna_Constraint_dependency_update(bContext *C, PointerRNA *ptr) +{ + Object *ob= ptr->id.data; + + rna_Constraint_update(C, ptr); + + if(ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels + DAG_scene_sort(CTX_data_scene(C)); +} + +static void rna_Constraint_influence_update(bContext *C, PointerRNA *ptr) +{ + Object *ob= ptr->id.data; + + if(ob->pose) + ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK); + + rna_Constraint_update(C, ptr); +} + #else static void rna_def_constrainttarget(BlenderRNA *brna) @@ -94,12 +175,13 @@ static void rna_def_constrainttarget(BlenderRNA *brna) prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "subtarget"); RNA_def_property_ui_text(prop, "Sub-Target", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); // space, flag and type still to do } @@ -115,48 +197,58 @@ static void rna_def_constraint_childof(BlenderRNA *brna) prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "subtarget"); RNA_def_property_ui_text(prop, "Sub-Target", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "locationx", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_LOCX); RNA_def_property_ui_text(prop, "Location X", "Use X Location of Parent."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "locationy", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_LOCY); RNA_def_property_ui_text(prop, "Location Y", "Use Y Location of Parent."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "locationz", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_LOCZ); RNA_def_property_ui_text(prop, "Location Z", "Use Z Location of Parent."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "rotationx", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_ROTX); RNA_def_property_ui_text(prop, "Rotation X", "Use X Rotation of Parent."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "rotationy", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_ROTY); RNA_def_property_ui_text(prop, "Rotation Y", "Use Y Rotation of Parent."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "rotationz", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_ROTZ); RNA_def_property_ui_text(prop, "Rotation Z", "Use Z Rotation of Parent."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "sizex", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_SIZEX); RNA_def_property_ui_text(prop, "Size X", "Use X Scale of Parent."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "sizey", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_SIZEY); RNA_def_property_ui_text(prop, "Size Y", "Use Y Scale of Parent."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "sizez", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_SIZEZ); RNA_def_property_ui_text(prop, "Size Z", "Use Z Scale of Parent."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_python(BlenderRNA *brna) @@ -176,14 +268,16 @@ static void rna_def_constraint_python(BlenderRNA *brna) prop= RNA_def_property(srna, "number_of_targets", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "tarnum"); RNA_def_property_ui_text(prop, "Number of Targets", "Usually only 1-3 are needed."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Text"); RNA_def_property_ui_text(prop, "Script", "The text object that contains the Python script."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_targets", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PYCON_USETARGETS); RNA_def_property_ui_text(prop, "Use Targets", "Use the targets indicated in the constraint panel."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "script_error", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PYCON_SCRIPTERROR); @@ -202,30 +296,34 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna) prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "subtarget"); RNA_def_property_ui_text(prop, "Sub-Target", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 1, 10000); RNA_def_property_ui_text(prop, "Iterations", "Maximum number of solving iterations."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "pole_target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "poletar"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Pole Target", "Object for pole rotation."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "pole_subtarget", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "polesubtarget"); RNA_def_property_ui_text(prop, "Pole Sub-Target", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "pole_angle", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "poleangle"); RNA_def_property_range(prop, 0.0, 180.f); RNA_def_property_ui_text(prop, "Pole Angle", "Pole rotation offset."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01, 1.f); @@ -235,27 +333,33 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "orientweight"); RNA_def_property_range(prop, 0.01, 1.f); RNA_def_property_ui_text(prop, "Orientation Weight", "For Tree-IK: Weight of orientation control for this target."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "chain_length", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "rootbone"); RNA_def_property_range(prop, 0, 255); RNA_def_property_ui_text(prop, "Chain Length", "How many bones are included in the IK effect - 0 uses all bones."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "tail", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_IK_TIP); RNA_def_property_ui_text(prop, "Use Tail", "Include bone's tail as last element in chain."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "rotation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_IK_ROT); RNA_def_property_ui_text(prop, "Rotation", "Chain follows rotation of target."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "targetless", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_IK_AUTO); RNA_def_property_ui_text(prop, "Targetless", "Use targetless IK."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "stretch", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_IK_STRETCH); RNA_def_property_ui_text(prop, "Stretch", "Enable IK Stretching."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_track_to(BlenderRNA *brna) @@ -284,26 +388,30 @@ static void rna_def_constraint_track_to(BlenderRNA *brna) prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "subtarget"); RNA_def_property_ui_text(prop, "Sub-Target", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "track", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "reserved1"); RNA_def_property_enum_items(prop, track_items); RNA_def_property_ui_text(prop, "Track Axis", "Axis that points to the target object."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "up", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "reserved2"); RNA_def_property_enum_items(prop, up_items); RNA_def_property_ui_text(prop, "Up Axis", "Axis that points upward."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "target_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", TARGET_Z_UP); RNA_def_property_ui_text(prop, "Target Z", "Target's Z axis, not World Z axis, will constraint the Up direction."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_rotate_like(BlenderRNA *brna) @@ -311,46 +419,54 @@ static void rna_def_constraint_rotate_like(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - srna= RNA_def_struct(brna, "RotateLikeConstraint", "Constraint"); + srna= RNA_def_struct(brna, "CopyRotationConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Copy Rotation Constraint", "Copies the rotation of the target."); RNA_def_struct_sdna_from(srna, "bRotateLikeConstraint", "data"); prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "subtarget"); RNA_def_property_ui_text(prop, "Sub-Target", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "rotate_like_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_X); RNA_def_property_ui_text(prop, "Like X", "Copy the target's X rotation."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "rotate_like_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_Y); RNA_def_property_ui_text(prop, "Like Y", "Copy the target's Y rotation."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "rotate_like_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_Z); RNA_def_property_ui_text(prop, "Like Z", "Copy the target's Z rotation."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "invert_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_X); + RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_X_INVERT); RNA_def_property_ui_text(prop, "Invert X", "Invert the X rotation."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "invert_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_Y_INVERT); RNA_def_property_ui_text(prop, "Invert Y", "Invert the Y rotation."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "invert_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_Z_INVERT); RNA_def_property_ui_text(prop, "Invert Z", "Invert the Z rotation."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "offset", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_OFFSET); RNA_def_property_ui_text(prop, "Offset", "Add original rotation into copied rotation."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_locate_like(BlenderRNA *brna) @@ -358,46 +474,63 @@ static void rna_def_constraint_locate_like(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - srna= RNA_def_struct(brna, "LocateLikeConstraint", "Constraint"); + srna= RNA_def_struct(brna, "CopyLocationConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Copy Location Constraint", "Copies the location of the target."); RNA_def_struct_sdna_from(srna, "bLocateLikeConstraint", "data"); prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, NULL, "rna_CopyLocationConstraint_target_set"); RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "subtarget"); RNA_def_property_ui_text(prop, "Sub-Target", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "locate_like_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_X); RNA_def_property_ui_text(prop, "Like X", "Copy the target's X location."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "locate_like_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Y); RNA_def_property_ui_text(prop, "Like Y", "Copy the target's Y location."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "locate_like_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Z); RNA_def_property_ui_text(prop, "Like Z", "Copy the target's Z location."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "invert_x", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_X); + RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_X_INVERT); RNA_def_property_ui_text(prop, "Invert X", "Invert the X location."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "invert_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Y_INVERT); RNA_def_property_ui_text(prop, "Invert Y", "Invert the Y location."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "invert_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Z_INVERT); RNA_def_property_ui_text(prop, "Invert Z", "Invert the Z location."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "offset", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_OFFSET); RNA_def_property_ui_text(prop, "Offset", "Add original location into copied location."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + + RNA_def_struct_sdna(srna, "bConstraint"); + + prop= RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_PERCENTAGE); + RNA_def_property_float_sdna(prop, NULL, "headtail"); + RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_minmax(BlenderRNA *brna) @@ -414,35 +547,40 @@ static void rna_def_constraint_minmax(BlenderRNA *brna) {LOCLIKE_Z_INVERT, "FLOOR_NEGATIVE_Z", "Floor Negative Z", ""}, {0, NULL, NULL, NULL}}; - srna= RNA_def_struct(brna, "MinMaxConstraint", "Constraint"); + srna= RNA_def_struct(brna, "FloorConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Floor Constraint", "Uses the target object for location limitation."); RNA_def_struct_sdna_from(srna, "bMinMaxConstraint","data"); prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "subtarget"); RNA_def_property_ui_text(prop, "Sub-Target", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "floor_location", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "minmaxflag"); RNA_def_property_enum_items(prop, minmax_items); RNA_def_property_ui_text(prop, "Floor Location", "Location of target that object will not pass through."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "sticky", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MINMAX_STICKY); RNA_def_property_ui_text(prop, "Sticky", "Immobilize object while constrained."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_rotation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MINMAX_USEROT); RNA_def_property_ui_text(prop, "Use Rotation", "Use the target's rotation to determine floor."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Offset", "Offset of floor from object center."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_size_like(BlenderRNA *brna) @@ -450,34 +588,40 @@ static void rna_def_constraint_size_like(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - srna= RNA_def_struct(brna, "SizeLikeConstraint", "Constraint"); + srna= RNA_def_struct(brna, "CopyScaleConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Copy Scale Constraint", "Copies the scale of the target."); RNA_def_struct_sdna_from(srna, "bSizeLikeConstraint", "data"); prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "subtarget"); RNA_def_property_ui_text(prop, "Sub-Target", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "size_like_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_X); RNA_def_property_ui_text(prop, "Like X", "Copy the target's X scale."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "size_like_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_Y); RNA_def_property_ui_text(prop, "Like Y", "Copy the target's Y scale."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "size_like_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_Z); RNA_def_property_ui_text(prop, "Like Z", "Copy the target's Z scale."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "offset", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_OFFSET); RNA_def_property_ui_text(prop, "Offset", "Add original scale into copied scale."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_action(BlenderRNA *brna) @@ -503,12 +647,13 @@ static void rna_def_constraint_action(BlenderRNA *brna) prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "subtarget"); RNA_def_property_ui_text(prop, "Sub-Target", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "transform_channel", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); @@ -517,28 +662,31 @@ static void rna_def_constraint_action(BlenderRNA *brna) prop= RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "act"); - RNA_def_property_struct_type(prop, "Action"); RNA_def_property_ui_text(prop, "Action", ""); prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "start"); RNA_def_property_range(prop, MINFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "Start Frame", "First frame of the Action to use."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "end"); RNA_def_property_range(prop, MINFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "End Frame", "Last frame of the Action to use."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "maximum", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "max"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum", "Maximum value for target channel range."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "minimum", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "min"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum", "Minimum value for target channel range."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_locked_track(BlenderRNA *brna) @@ -561,28 +709,31 @@ static void rna_def_constraint_locked_track(BlenderRNA *brna) {TRACK_Z, "LOCK_Z", "Lock Z", ""}, {0, NULL, NULL, NULL}}; - srna= RNA_def_struct(brna, "LockTrackConstraint", "Constraint"); + srna= RNA_def_struct(brna, "LockedTrackConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Locked Track Constraint", "Points toward the target along the track axis, while locking the other axis."); RNA_def_struct_sdna_from(srna, "bLockTrackConstraint", "data"); prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "subtarget"); RNA_def_property_ui_text(prop, "Sub-Target", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "track", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "trackflag"); RNA_def_property_enum_items(prop, locktrack_items); RNA_def_property_ui_text(prop, "Track Axis", "Axis that points to the target object."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "locked", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "lockflag"); RNA_def_property_enum_items(prop, lock_items); RNA_def_property_ui_text(prop, "Locked Axis", "Axis that points upward."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_follow_path(BlenderRNA *brna) @@ -611,26 +762,30 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna) prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "offset", PROP_INT, PROP_NONE); RNA_def_property_range(prop, -300000.0, 300000.f); RNA_def_property_ui_text(prop, "Offset", "Offset from the position corresponding to the time frame."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "forward", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "trackflag"); RNA_def_property_enum_items(prop, forwardpath_items); RNA_def_property_ui_text(prop, "Forward Axis", "Axis that points forward along the path."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "up", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "upflag"); RNA_def_property_enum_items(prop, pathup_items); RNA_def_property_ui_text(prop, "Up Axis", "Axis that points upward."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "curve_follow", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "followflag", 1); RNA_def_property_ui_text(prop, "Follow Curve", "Object will follow the heading and banking of the curve."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_stretch_to(BlenderRNA *brna) @@ -656,27 +811,31 @@ static void rna_def_constraint_stretch_to(BlenderRNA *brna) prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "volume", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "volmode"); RNA_def_property_enum_items(prop, volume_items); RNA_def_property_ui_text(prop, "Maintain Volume", "Maintain the object's volume as it stretches."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "keep_axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "plane"); RNA_def_property_enum_items(prop, plane_items); RNA_def_property_ui_text(prop, "Keep Axis", "Axis to maintain during stretch."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "original_length", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "orglength"); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Original Length", "Length at rest position."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "bulge", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Volume Variation", "Factor between volume variation and stretching."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_rigid_body_joint(BlenderRNA *brna) @@ -697,47 +856,54 @@ static void rna_def_constraint_rigid_body_joint(BlenderRNA *brna) prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Target", "Target Object."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "child", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Child Object", "Child object."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "pivot_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); RNA_def_property_enum_items(prop, pivot_items); RNA_def_property_ui_text(prop, "Pivot Type", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "pivot_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pivX"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Pivot X", "Offset pivot on X."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "pivot_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pivY"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Pivot Y", "Offset pivot on Y."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "pivot_z", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pivZ"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Pivot Z", "Offset pivot on Z."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "axX"); RNA_def_property_range(prop, -360.0, 360.f); RNA_def_property_ui_text(prop, "Axis X", "Rotate pivot on X axis in degrees."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "axY"); RNA_def_property_range(prop, -360.0, 360.f); RNA_def_property_ui_text(prop, "Axis Y", "Rotate pivot on Y axis in degrees."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "axis_z", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "axZ"); RNA_def_property_range(prop, -360.0, 360.f); RNA_def_property_ui_text(prop, "Axis Z", "Rotate pivot on Z axis in degrees."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); /* XXX not sure how to wrap the two 6 element arrays for the generic joint */ //float minLimit[6]; @@ -746,10 +912,12 @@ static void rna_def_constraint_rigid_body_joint(BlenderRNA *brna) prop= RNA_def_property(srna, "disable_linked_collision", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_DISABLE_LINKED_COLLISION); RNA_def_property_ui_text(prop, "Disable Linked Collision", "Disable collision between linked bodies."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "draw_pivot", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_DRAW_PIVOT); RNA_def_property_ui_text(prop, "Draw Pivot", "Display the pivot point and rotation in 3D view."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_clamp_to(BlenderRNA *brna) @@ -770,17 +938,19 @@ static void rna_def_constraint_clamp_to(BlenderRNA *brna) prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "main_axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "flag"); RNA_def_property_enum_items(prop, clamp_items); RNA_def_property_ui_text(prop, "Main Axis", "Main axis of movement."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "cyclic", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag2", CLAMPTO_CYCLIC); RNA_def_property_ui_text(prop, "Cyclic", "Treat curve as cyclic curve (no clamping to curve bounding box."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_transform(BlenderRNA *brna) @@ -806,22 +976,25 @@ static void rna_def_constraint_transform(BlenderRNA *brna) prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "subtarget"); RNA_def_property_ui_text(prop, "Sub-Target", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "map_from", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "from"); RNA_def_property_enum_items(prop, transform_items); RNA_def_property_ui_text(prop, "Map From", "The transformation type to use from the target."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "map_to", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "to"); RNA_def_property_enum_items(prop, transform_items); RNA_def_property_ui_text(prop, "Map To", "The transformation type to affect of the constrained object."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); /* it would be cool to have a method for rna to directly address specific elements of arrays in dna */ @@ -829,80 +1002,96 @@ static void rna_def_constraint_transform(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, 0, "map"); RNA_def_property_enum_items(prop, axis_map_items); RNA_def_property_ui_text(prop, "Map To X From", "The source axis constrained object's X axis uses."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "map_to_y_from", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, 1, "map"); RNA_def_property_enum_items(prop, axis_map_items); RNA_def_property_ui_text(prop, "Map To Y From", "The source axis constrained object's Y axis uses."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "map_to_z_from", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, 2, "map"); RNA_def_property_enum_items(prop, axis_map_items); RNA_def_property_ui_text(prop, "Map To Z From", "The source axis constrained object's Z axis uses."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "extrapolate_motion", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "expo", CLAMPTO_CYCLIC); RNA_def_property_ui_text(prop, "Extrapolate Motion", "Extrapolate ranges."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "from_min_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, 0, "from_min"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Minimum X", "Bottom range of X axis source motion."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "from_min_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, 1, "from_min"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Minimum Y", "Bottom range of Y axis source motion."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "from_min_z", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, 2, "from_min"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Minimum Z", "Bottom range of Z axis source motion."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "from_max_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, 0, "from_max"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Maximum X", "Top range of X axis source motion."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "from_max_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, 1, "from_max"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Maximum Y", "Top range of Y axis source motion."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "from_max_z", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, 2, "from_max"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "From Maximum Z", "Top range of Z axis source motion."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "to_min_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, 0, "to_min"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Minimum X", "Bottom range of X axis destination motion."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "to_min_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, 1, "to_min"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Minimum Y", "Bottom range of Y axis destination motion."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "to_min_z", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, 2, "to_min"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Minimum Z", "Bottom range of Z axis destination motion."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "to_max_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, 0, "to_max"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Maximum X", "Top range of X axis destination motion."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "to_max_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, 1, "to_max"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Maximum Y", "Top range of Y axis destination motion."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "to_max_z", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, 2, "to_max"); RNA_def_property_range(prop, 0.0, 1000.f); RNA_def_property_ui_text(prop, "To Maximum Z", "Top range of Z axis destination motion."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); */ } @@ -911,67 +1100,80 @@ static void rna_def_constraint_location_limit(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - srna= RNA_def_struct(brna, "LocationLimitConstraint", "Constraint"); - RNA_def_struct_ui_text(srna, "Location Limit Constraint", "Limits the location of the constrained object."); + srna= RNA_def_struct(brna, "LimitLocationConstraint", "Constraint"); + RNA_def_struct_ui_text(srna, "Limit Location Constraint", "Limits the location of the constrained object."); RNA_def_struct_sdna_from(srna, "bLocLimitConstraint", "data"); prop= RNA_def_property(srna, "use_minimum_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_XMIN); RNA_def_property_ui_text(prop, "Minimum X", "Use the minimum X value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_minimum_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_YMIN); RNA_def_property_ui_text(prop, "Minimum Y", "Use the minimum Y value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_minimum_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_ZMIN); RNA_def_property_ui_text(prop, "Minimum Z", "Use the minimum Z value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_maximum_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_XMAX); RNA_def_property_ui_text(prop, "Maximum X", "Use the maximum X value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_maximum_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_YMAX); RNA_def_property_ui_text(prop, "Maximum Y", "Use the maximum Y value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_maximum_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_ZMAX); RNA_def_property_ui_text(prop, "Maximum Z", "Use the maximum Z value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "minimum_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "minimum_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ymin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "minimum_z", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "zmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Z", "Lowest Z value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "maximum_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "maximum_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ymax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "maximum_z", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "zmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "limit_transform", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag2", LIMIT_TRANSFORM); RNA_def_property_ui_text(prop, "For Transform", "Transforms are affected by this constraint as well."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_rotation_limit(BlenderRNA *brna) @@ -979,67 +1181,80 @@ static void rna_def_constraint_rotation_limit(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - srna= RNA_def_struct(brna, "RotationLimitConstraint", "Constraint"); - RNA_def_struct_ui_text(srna, "Rotation Limit Constraint", "Limits the rotation of the constrained object."); + srna= RNA_def_struct(brna, "LimitRotationConstraint", "Constraint"); + RNA_def_struct_ui_text(srna, "Limit Rotation Constraint", "Limits the rotation of the constrained object."); RNA_def_struct_sdna_from(srna, "bRotLimitConstraint", "data"); prop= RNA_def_property(srna, "use_minimum_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_XMIN); RNA_def_property_ui_text(prop, "Minimum X", "Use the minimum X value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_minimum_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_YMIN); RNA_def_property_ui_text(prop, "Minimum Y", "Use the minimum Y value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_minimum_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_ZMIN); RNA_def_property_ui_text(prop, "Minimum Z", "Use the minimum Z value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_maximum_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_XMAX); RNA_def_property_ui_text(prop, "Maximum X", "Use the maximum X value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_maximum_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_YMAX); RNA_def_property_ui_text(prop, "Maximum Y", "Use the maximum Y value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_maximum_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_ZMAX); RNA_def_property_ui_text(prop, "Maximum Z", "Use the maximum Z value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "minimum_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "minimum_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ymin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "minimum_z", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "zmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Z", "Lowest Z value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "maximum_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "maximum_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ymax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "maximum_z", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "zmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "limit_transform", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag2", LIMIT_TRANSFORM); RNA_def_property_ui_text(prop, "For Transform", "Transforms are affected by this constraint as well."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_size_limit(BlenderRNA *brna) @@ -1047,67 +1262,80 @@ static void rna_def_constraint_size_limit(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - srna= RNA_def_struct(brna, "SizeLimitConstraint", "Constraint"); - RNA_def_struct_ui_text(srna, "Size Limit Constraint", "Limits the scaling of the constrained object."); + srna= RNA_def_struct(brna, "LimitScaleConstraint", "Constraint"); + RNA_def_struct_ui_text(srna, "Limit Size Constraint", "Limits the scaling of the constrained object."); RNA_def_struct_sdna_from(srna, "bSizeLimitConstraint", "data"); prop= RNA_def_property(srna, "use_minimum_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_XMIN); RNA_def_property_ui_text(prop, "Minimum X", "Use the minimum X value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_minimum_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_YMIN); RNA_def_property_ui_text(prop, "Minimum Y", "Use the minimum Y value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_minimum_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_ZMIN); RNA_def_property_ui_text(prop, "Minimum Z", "Use the minimum Z value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_maximum_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_XMAX); RNA_def_property_ui_text(prop, "Maximum X", "Use the maximum X value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_maximum_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_YMAX); RNA_def_property_ui_text(prop, "Maximum Y", "Use the maximum Y value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "use_maximum_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_ZMAX); RNA_def_property_ui_text(prop, "Maximum Z", "Use the maximum Z value."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "minimum_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "minimum_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ymin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "minimum_z", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "zmin"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Minimum Z", "Lowest Z value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "maximum_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "maximum_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ymax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "maximum_z", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "zmax"); RNA_def_property_range(prop, -1000.0, 1000.f); RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "limit_transform", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag2", LIMIT_TRANSFORM); RNA_def_property_ui_text(prop, "For Transform", "Transforms are affected by this constraint as well."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } static void rna_def_constraint_distance_limit(BlenderRNA *brna) @@ -1121,28 +1349,31 @@ static void rna_def_constraint_distance_limit(BlenderRNA *brna) {LIMITDIST_ONSURFACE, "LIMITDIST_ONSURFACE", "On Surface", ""}, {0, NULL, NULL, NULL}}; - srna= RNA_def_struct(brna, "DistLimitConstraint", "Constraint"); - RNA_def_struct_ui_text(srna, "Distance Limit Constraint", "Limits the distance from target object."); + srna= RNA_def_struct(brna, "LimitDistanceConstraint", "Constraint"); + RNA_def_struct_ui_text(srna, "Limit Distance Constraint", "Limits the distance from target object."); RNA_def_struct_sdna_from(srna, "bDistLimitConstraint", "data"); prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "subtarget"); RNA_def_property_ui_text(prop, "Sub-Target", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "dist"); RNA_def_property_range(prop, 0.0, 100.f); RNA_def_property_ui_text(prop, "Distance", "Radius of limiting sphere."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop= RNA_def_property(srna, "limit_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mode"); RNA_def_property_enum_items(prop, distance_items); RNA_def_property_ui_text(prop, "Limit Mode", "Distances in relation to sphere of influence to allow."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); } /* base struct for constraints */ @@ -1151,33 +1382,11 @@ void RNA_def_constraint(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem type_items[] ={ - {CONSTRAINT_TYPE_NULL, "NULL", "Null", ""}, - {CONSTRAINT_TYPE_CHILDOF, "CHILDOF", "Child Of", ""}, - {CONSTRAINT_TYPE_TRACKTO, "TRACKTO", "Track To", ""}, - {CONSTRAINT_TYPE_KINEMATIC, "IK", "IK", ""}, - {CONSTRAINT_TYPE_FOLLOWPATH, "FOLLOWPATH", "Follow Path", ""}, - {CONSTRAINT_TYPE_ROTLIMIT, "LIMITROT", "Limit Rotation", ""}, - {CONSTRAINT_TYPE_LOCLIMIT, "LIMITLOC", "Limit Location", ""}, - {CONSTRAINT_TYPE_SIZELIMIT, "LIMITSCALE", "Limit Scale", ""}, - {CONSTRAINT_TYPE_ROTLIKE, "COPYROT", "Copy Rotation", ""}, - {CONSTRAINT_TYPE_LOCLIKE, "COPYLOC", "Copy Location", ""}, - {CONSTRAINT_TYPE_SIZELIKE, "COPYSCALE", "Copy Scale", ""}, - {CONSTRAINT_TYPE_PYTHON, "SCRIPT", "Script", ""}, - {CONSTRAINT_TYPE_ACTION, "ACTION", "Action", ""}, - {CONSTRAINT_TYPE_LOCKTRACK, "LOCKTRACK", "Locked Track", ""}, - {CONSTRAINT_TYPE_DISTLIMIT, "LIMITDIST", "Limit Distance", ""}, - {CONSTRAINT_TYPE_STRETCHTO, "STRETCHTO", "Stretch To", ""}, - {CONSTRAINT_TYPE_MINMAX, "FLOOR", "Floor", ""}, - {CONSTRAINT_TYPE_RIGIDBODYJOINT, "RIGIDBODYJOINT", "Rigid Body Joint", ""}, - {CONSTRAINT_TYPE_CLAMPTO, "CLAMPTO", "Clamp To", ""}, - {CONSTRAINT_TYPE_TRANSFORM, "TRANSFORM", "Transformation", ""}, - {0, NULL, NULL, NULL}}; - /* data */ srna= RNA_def_struct(brna, "Constraint", NULL ); RNA_def_struct_ui_text(srna, "Constraint", "Constraint modifying the transformation of objects and bones."); RNA_def_struct_refine_func(srna, "rna_ConstraintType_refine"); + RNA_def_struct_path_func(srna, "rna_Constraint_path"); RNA_def_struct_sdna(srna, "bConstraint"); /* strings */ @@ -1189,7 +1398,7 @@ void RNA_def_constraint(BlenderRNA *brna) prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, type_items); + RNA_def_property_enum_items(prop, constraint_type_items); RNA_def_property_ui_text(prop, "Type", ""); /* flags */ @@ -1218,6 +1427,7 @@ void RNA_def_constraint(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "enforce"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Influence", "Amount of influence constraint will have on the final solution."); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_influence_update"); /* pointers */ rna_def_constrainttarget(brna); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 7fc9f0a689e..35892cefc8a 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -77,6 +77,7 @@ EnumPropertyItem modifier_type_items[] ={ #include "BKE_context.h" #include "BKE_depsgraph.h" +#include "BKE_library.h" static void rna_UVProject_projectors_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { @@ -152,11 +153,22 @@ static StructRNA* rna_Modifier_refine(struct PointerRNA *ptr) } } +static char *rna_Modifier_path(PointerRNA *ptr) +{ + return BLI_sprintfN("modifiers[%s]", ((ModifierData*)ptr->data)->name); // XXX not unique +} + static void rna_Modifier_update(bContext *C, PointerRNA *ptr) { DAG_object_flush_update(CTX_data_scene(C), ptr->id.data, OB_RECALC_DATA); } +static void rna_Modifier_dependency_update(bContext *C, PointerRNA *ptr) +{ + rna_Modifier_update(C, ptr); + DAG_scene_sort(CTX_data_scene(C)); +} + static void rna_ExplodeModifier_vgroup_get(PointerRNA *ptr, char *value) { ExplodeModifierData *emd= (ExplodeModifierData*)ptr->data; @@ -273,6 +285,96 @@ static void rna_MultiresModifier_level_range(PointerRNA *ptr, int *min, int *max *max = mmd->totlvl; } +static void modifier_object_set(Object **ob_p, int type, PointerRNA value) +{ + Object *ob= value.data; + + if(!ob || ob->type == type) + *ob_p= ob; +} + +static void modifier_ID_set(ID **id_p, PointerRNA value) +{ + ID *id= value.data; + + if(*id_p) + id_us_min(*id_p); + if(id) + id_us_plus(id); + + *id_p = id; +} + +static void rna_LatticeModifier_object_set(PointerRNA *ptr, PointerRNA value) +{ + modifier_object_set(&((LatticeModifierData*)ptr->data)->object, OB_LATTICE, value); +} + +static void rna_BooleanModifier_object_set(PointerRNA *ptr, PointerRNA value) +{ + modifier_object_set(&((BooleanModifierData*)ptr->data)->object, OB_MESH, value); +} + +static void rna_CurveModifier_object_set(PointerRNA *ptr, PointerRNA value) +{ + modifier_object_set(&((CurveModifierData*)ptr->data)->object, OB_CURVE, value); +} + +static void rna_ArmatureModifier_object_set(PointerRNA *ptr, PointerRNA value) +{ + modifier_object_set(&((ArmatureModifierData*)ptr->data)->object, OB_ARMATURE, value); +} + +static void rna_MaskModifier_armature_set(PointerRNA *ptr, PointerRNA value) +{ + modifier_object_set(&((MaskModifierData*)ptr->data)->ob_arm, OB_ARMATURE, value); +} + +static void rna_ShrinkwrapModifier_auxiliary_target_set(PointerRNA *ptr, PointerRNA value) +{ + modifier_object_set(&((ShrinkwrapModifierData*)ptr->data)->auxTarget, OB_MESH, value); +} + +static void rna_ShrinkwrapModifier_target_set(PointerRNA *ptr, PointerRNA value) +{ + modifier_object_set(&((ShrinkwrapModifierData*)ptr->data)->target, OB_MESH, value); +} + +static void rna_MeshDeformModifier_object_set(PointerRNA *ptr, PointerRNA value) +{ + modifier_object_set(&((MeshDeformModifierData*)ptr->data)->object, OB_MESH, value); +} + +static void rna_ArrayModifier_end_cap_set(PointerRNA *ptr, PointerRNA value) +{ + modifier_object_set(&((ArrayModifierData*)ptr->data)->end_cap, OB_MESH, value); +} + +static void rna_ArrayModifier_start_cap_set(PointerRNA *ptr, PointerRNA value) +{ + modifier_object_set(&((ArrayModifierData*)ptr->data)->start_cap, OB_MESH, value); +} + +static void rna_ArrayModifier_curve_set(PointerRNA *ptr, PointerRNA value) +{ + modifier_object_set(&((ArrayModifierData*)ptr->data)->curve_ob, OB_CURVE, value); +} + +static void rna_WaveModifier_texture_set(PointerRNA *ptr, PointerRNA value) +{ + modifier_ID_set((ID**)&((WaveModifierData*)ptr->data)->texture, value); +} + +static void rna_DisplaceModifier_texture_set(PointerRNA *ptr, PointerRNA value) +{ + modifier_ID_set((ID**)&((DisplaceModifierData*)ptr->data)->texture, value); +} + +static void rna_UVProjectModifier_image_set(PointerRNA *ptr, PointerRNA value) +{ + modifier_ID_set((ID**)&((UVProjectModifierData*)ptr->data)->image, value); +} + #else static void rna_def_property_subdivision_common(StructRNA *srna, const char type[]) @@ -351,11 +453,11 @@ static void rna_def_modifier_lattice(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Lattice Modifier", "Lattice deformation modifier."); RNA_def_struct_sdna(srna, "LatticeModifierData"); - prop= RNA_def_property(srna, "lattice", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "object"); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_ui_text(prop, "Lattice", "Lattice object to deform with."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Object", "Lattice object to deform with."); + RNA_def_property_pointer_funcs(prop, NULL, "rna_LatticeModifier_object_set"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); @@ -382,11 +484,11 @@ static void rna_def_modifier_curve(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Curve Modifier", "Curve deformation modifier."); RNA_def_struct_sdna(srna, "CurveModifierData"); - prop= RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "object"); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_ui_text(prop, "Curve", "Curve object to deform with."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Object", "Curve object to deform with."); + RNA_def_property_pointer_funcs(prop, NULL, "rna_CurveModifier_object_set"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); @@ -483,9 +585,9 @@ static void rna_def_modifier_mirror(BlenderRNA *brna) prop= RNA_def_property(srna, "mirror_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "mirror_ob"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Mirror Object", "Object to use as mirror."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); } static void rna_def_modifier_decimate(BlenderRNA *brna) @@ -600,9 +702,9 @@ static void rna_def_modifier_wave(BlenderRNA *brna) prop= RNA_def_property(srna, "start_position_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "objectcenter"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Start Position Object", ""); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); @@ -611,8 +713,9 @@ static void rna_def_modifier_wave(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Texture"); RNA_def_property_ui_text(prop, "Texture", "Texture for modulating the wave."); + RNA_def_property_pointer_funcs(prop, NULL, "rna_WaveModifier_texture_set"); + RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "texture_coordinates", PROP_ENUM, PROP_NONE); @@ -629,9 +732,9 @@ static void rna_def_modifier_wave(BlenderRNA *brna) prop= RNA_def_property(srna, "texture_coordinates_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "map_object"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Texture Coordinates Object", ""); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "speed", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, FLT_MIN, FLT_MAX); @@ -669,10 +772,10 @@ static void rna_def_modifier_armature(BlenderRNA *brna) RNA_def_struct_sdna(srna, "ArmatureModifierData"); prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "object"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Object", "Armature object to deform with."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ArmatureModifier_object_set"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); @@ -732,9 +835,9 @@ static void rna_def_modifier_hook(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Object", "Parent Object for hook, also recalculates and clears offset"); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); @@ -768,9 +871,10 @@ static void rna_def_modifier_boolean(BlenderRNA *brna) RNA_def_struct_sdna(srna, "BooleanModifierData"); prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Object", "Mesh object to use for boolean operation."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_BooleanModifier_object_set"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_operation_items); @@ -813,9 +917,10 @@ static void rna_def_modifier_array(BlenderRNA *brna) prop= RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "curve_ob"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Curve", "Curve object to fit array length to."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_curve_set"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); /* Offset parameters */ prop= RNA_def_property(srna, "constant_offset", PROP_BOOLEAN, PROP_NONE); @@ -864,20 +969,22 @@ static void rna_def_modifier_array(BlenderRNA *brna) prop= RNA_def_property(srna, "offset_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "offset_ob"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Offset Object", ""); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); /* Caps */ prop= RNA_def_property(srna, "start_cap", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Start Cap", "Mesh object to use as a start cap."); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_start_cap_set"); + RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "end_cap", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "End Cap", "Mesh object to use as an end cap."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_end_cap_set"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); } static void rna_def_modifier_edgesplit(BlenderRNA *brna) @@ -937,8 +1044,9 @@ static void rna_def_modifier_displace(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Texture"); RNA_def_property_ui_text(prop, "Texture", ""); + RNA_def_property_pointer_funcs(prop, NULL, "rna_DisplaceModifier_texture_set"); + RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "midlevel", PROP_FLOAT, PROP_NONE); @@ -972,9 +1080,9 @@ static void rna_def_modifier_displace(BlenderRNA *brna) prop= RNA_def_property(srna, "texture_coordinate_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "map_object"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Texture Coordinate Object", ""); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); } static void rna_def_modifier_uvproject(BlenderRNA *brna) @@ -998,8 +1106,9 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Projectors", ""); prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Image"); RNA_def_property_ui_text(prop, "Image", ""); + RNA_def_property_pointer_funcs(prop, NULL, "rna_UVProjectModifier_image_set"); + RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "horizontal_aspect_ratio", PROP_FLOAT, PROP_NONE); @@ -1136,11 +1245,11 @@ static void rna_def_modifier_meshdeform(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "MeshDeform Modifier", "Mesh deformation modifier to deform with other meshes."); RNA_def_struct_sdna(srna, "MeshDeformModifierData"); - prop= RNA_def_property(srna, "mesh", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "object"); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_ui_text(prop, "Mesh", ""); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Object", "Mesh object to deform with."); + RNA_def_property_pointer_funcs(prop, NULL, "rna_MeshDeformModifier_object_set"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MDEF_INVERT_VGROUP); @@ -1186,9 +1295,9 @@ static void rna_def_modifier_particleinstance(BlenderRNA *brna) prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "ob"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Object", "Object that has the particle system."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "particle_system_number", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "psys"); @@ -1277,16 +1386,13 @@ static void rna_def_modifier_cloth(BlenderRNA *brna) prop= RNA_def_property(srna, "settings", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "sim_parms"); - RNA_def_property_struct_type(prop, "ClothSettings"); RNA_def_property_ui_text(prop, "Cloth Settings", ""); prop= RNA_def_property(srna, "collision_settings", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "coll_parms"); - RNA_def_property_struct_type(prop, "ClothCollisionSettings"); RNA_def_property_ui_text(prop, "Cloth Collision Settings", ""); prop= RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NEVER_NULL); - RNA_def_property_struct_type(prop, "PointCache"); RNA_def_property_ui_text(prop, "Point Cache", ""); } @@ -1373,15 +1479,17 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Target", "Mesh target to shrink to."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ShrinkwrapModifier_target_set"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "auxiliary_target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "auxTarget"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Auxiliary Target", "Additional mesh target to shrink to."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_ShrinkwrapModifier_auxiliary_target_set"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "vgroup_name"); @@ -1455,7 +1563,6 @@ static void rna_def_modifier_fluidsim(BlenderRNA *brna) prop= RNA_def_property(srna, "settings", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "fss"); - RNA_def_property_struct_type(prop, "FluidSettings"); RNA_def_property_ui_text(prop, "Settings", "Settings for how this object is used in the fluid simulation."); } @@ -1480,9 +1587,10 @@ static void rna_def_modifier_mask(BlenderRNA *brna) prop= RNA_def_property(srna, "armature", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "ob_arm"); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Armature", "Armature to use as source of bones to mask."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_MaskModifier_armature_set"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "vgroup"); @@ -1524,9 +1632,9 @@ static void rna_def_modifier_simpledeform(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "origin", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Origin", "Origin of modifier space coordinates."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "relative", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "originOpts", MOD_SIMPLEDEFORM_ORIGIN_LOCAL); @@ -1567,6 +1675,7 @@ void RNA_def_modifier(BlenderRNA *brna) srna= RNA_def_struct(brna, "Modifier", NULL); RNA_def_struct_ui_text(srna , "Modifier", "Modifier affecting the geometry data of an object."); RNA_def_struct_refine_func(srna, "rna_Modifier_refine"); + RNA_def_struct_path_func(srna, "rna_Modifier_path"); RNA_def_struct_sdna(srna, "ModifierData"); /* strings */ diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index cbc80e68b4a..47a243b9697 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -48,7 +48,7 @@ static void rna_Object_update(bContext *C, PointerRNA *ptr) DAG_object_flush_update(CTX_data_scene(C), ptr->id.data, OB_RECALC_OB); } -static void rna_Object_scene_update(bContext *C, PointerRNA *ptr) +static void rna_Object_dependency_update(bContext *C, PointerRNA *ptr) { DAG_object_flush_update(CTX_data_scene(C), ptr->id.data, OB_RECALC_OB); DAG_scene_sort(CTX_data_scene(C)); @@ -760,7 +760,7 @@ static StructRNA *rna_def_object(BlenderRNA *brna) RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag"); RNA_def_property_enum_items(prop, dupli_items); RNA_def_property_ui_text(prop, "Dupli Type", "If not None, object duplication method to use."); - RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_scene_update"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update"); prop= RNA_def_property(srna, "dupli_frames_no_speed", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLINOSPEED); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 5aad710c712..8edcc4c72f4 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -82,7 +82,6 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_struct_idproperties_func(srna, "rna_PoseChannel_idproperties"); prop= RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "constraints", NULL); RNA_def_property_struct_type(prop, "Constraint"); RNA_def_property_ui_text(prop, "Constraints", "Constraints that act on this PoseChannel."); diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c index 2aeb1b984fb..c6515385757 100644 --- a/source/blender/makesrna/intern/rna_sound.c +++ b/source/blender/makesrna/intern/rna_sound.c @@ -64,30 +64,30 @@ static void rna_def_sample(BlenderRNA *brna) prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_sample_type_items); - RNA_def_property_flag(prop, PROP_NOT_EDITABLE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Types", ""); prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_flag(prop, PROP_NOT_EDITABLE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Filename", "Full path filename of the sample"); prop= RNA_def_property(srna, "length", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "len"); RNA_def_property_ui_text(prop, "Length", "The length of sample in seconds"); - RNA_def_property_flag(prop, PROP_NOT_EDITABLE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop= RNA_def_property(srna, "rate", PROP_INT, PROP_UNSIGNED); RNA_def_property_ui_text(prop, "Rate", "Sample rate in kHz"); - RNA_def_property_flag(prop, PROP_NOT_EDITABLE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop= RNA_def_property(srna, "bits", PROP_INT, PROP_UNSIGNED); RNA_def_property_ui_text(prop, "Bits", "Bit-depth of sample"); - RNA_def_property_flag(prop, PROP_NOT_EDITABLE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop= RNA_def_property(srna, "channels", PROP_INT, PROP_UNSIGNED); RNA_def_property_ui_text(prop, "Channels", "Number of channels (mono=1; stereo=2)"); - RNA_def_property_flag(prop, PROP_NOT_EDITABLE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); } static void rna_def_soundlistener(BlenderRNA *brna) @@ -117,12 +117,12 @@ static void rna_def_soundlistener(BlenderRNA *brna) prop= RNA_def_property(srna, "num_sounds_blender", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "numsoundsblender"); RNA_def_property_ui_text(prop, "Total Sounds in Blender", "The total number of sounds currently linked and available."); - RNA_def_property_flag(prop, PROP_NOT_EDITABLE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop= RNA_def_property(srna, "num_sounds_gameengine", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "numsoundsgameengine"); RNA_def_property_ui_text(prop, "Total Sounds in Game Engine", "The total number of sounds in the Game Engine."); - RNA_def_property_flag(prop, PROP_NOT_EDITABLE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); } #endif diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index a3e48f629cb..252e8cee27a 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -151,7 +151,7 @@ static StructRNA *rna_Panel_register(const bContext *C, ReportList *reports, voi PanelType *pt, dummypt = {0}; Panel dummypanel= {0}; PointerRNA dummyptr; - int have_function[2]; + int have_function[3]; /* setup dummy panel & panel type to store static properties in */ dummypanel.type= &dummypt; diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index b96089a05f1..09b81d69ac0 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -196,6 +196,7 @@ typedef struct wmNotifier { #define ND_MODIFIER (23<<16) #define ND_KEYS (24<<16) #define ND_GEOM_DATA (25<<16) +#define ND_CONSTRAINT (26<<16) /* NC_MATERIAL Material */ #define ND_SHADING (30<<16) -- cgit v1.2.3