From 83acd4ac6b4c86631636098681fe7aeb4add1da3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 14 Jul 2009 20:27:28 +0000 Subject: 2.5: Objects * Added Relations panel with layers, pass_index, parent. * Groups panel now can do add to group/remove from group. * Parent, parent type, track are now editable. * Separate constraint add operator for object and bones. --- release/ui/buttons_object_constraint.py | 4 +- release/ui/buttons_objects.py | 48 +++++-- release/ui/buttons_scene.py | 10 +- source/blender/editors/include/ED_object.h | 1 + source/blender/editors/object/editconstraint.c | 46 ++++++- source/blender/editors/object/editgroup.c | 2 +- source/blender/editors/object/object_edit.c | 16 +++ source/blender/editors/object/object_intern.h | 1 + source/blender/editors/object/object_ops.c | 6 +- .../blender/editors/space_buttons/buttons_intern.h | 3 + source/blender/editors/space_buttons/buttons_ops.c | 133 ++++++++++++++++++ .../blender/editors/space_buttons/space_buttons.c | 3 + source/blender/makesrna/intern/rna_object.c | 149 ++++++++++++++++++--- source/blender/makesrna/intern/rna_scene.c | 2 +- 14 files changed, 375 insertions(+), 49 deletions(-) diff --git a/release/ui/buttons_object_constraint.py b/release/ui/buttons_object_constraint.py index 12aed082381..52fb572f27d 100644 --- a/release/ui/buttons_object_constraint.py +++ b/release/ui/buttons_object_constraint.py @@ -528,7 +528,7 @@ class OBJECT_PT_constraints(ConstraintButtonsPanel): class BONE_PT_constraints(ConstraintButtonsPanel): __idname__ = "BONE_PT_constraints" - __label__ = "Bone Constraints" + __label__ = "Constraints" __context__ = "bone" def poll(self, context): @@ -541,7 +541,7 @@ class BONE_PT_constraints(ConstraintButtonsPanel): layout = self.layout row = layout.row() - row.item_menu_enumO("OBJECT_OT_constraint_add", "type") + row.item_menu_enumO("POSE_OT_constraint_add", "type") row.itemL(); for con in pchan.constraints: diff --git a/release/ui/buttons_objects.py b/release/ui/buttons_objects.py index 59e19d05959..47c127adeae 100644 --- a/release/ui/buttons_objects.py +++ b/release/ui/buttons_objects.py @@ -31,6 +31,31 @@ class OBJECT_PT_transform(ObjectButtonsPanel): row.column().itemR(ob, "rotation") row.column().itemR(ob, "scale") +class OBJECT_PT_relations(ObjectButtonsPanel): + __idname__ = "OBJECT_PT_relations" + __label__ = "Relations" + + def draw(self, context): + layout = self.layout + ob = context.object + + split = layout.split() + col = split.column() + col.itemR(ob, "layers") + col.itemS() + col.itemR(ob, "pass_index") + + col = split.column() + col.itemL(text="Parent:") + col.itemR(ob, "parent", text="") + + sub = col.column() + sub.itemR(ob, "parent_type", text="Type") + parent = ob.parent + if parent and ob.parent_type == 'BONE' and parent.type == 'ARMATURE': + sub.item_pointerR(ob, "parent_bone", parent.data, "bones", text="") + sub.active = parent != None + class OBJECT_PT_groups(ObjectButtonsPanel): __idname__ = "OBJECT_PT_groups" __label__ = "Groups" @@ -39,24 +64,23 @@ class OBJECT_PT_groups(ObjectButtonsPanel): layout = self.layout ob = context.object - row = layout.row() - row.itemR(ob, "pass_index") - row.itemR(ob, "parent") - - # layout.left_right() - # layout.itemO("OBJECT_OT_add_group"); + split = layout.split() + split.item_menu_enumO("OBJECT_OT_group_add", "group", text="Add to Group") + split.itemL() for group in bpy.data.groups: if ob.name in group.objects: col = layout.column(align=True) + col.set_context_pointer("group", group) + row = col.box().row() row.itemR(group, "name", text="") - #row.itemO("OBJECT_OT_remove_group") + row.itemO("OBJECT_OT_group_remove", text="", icon="VICON_X") split = col.box().split() - split.column().itemR(group, "layer") - split.column().itemR(group, "dupli_offset") + split.column().itemR(group, "layer", text="Dupli") + split.column().itemR(group, "dupli_offset", text="") class OBJECT_PT_display(ObjectButtonsPanel): __idname__ = "OBJECT_PT_display" @@ -132,12 +156,16 @@ class OBJECT_PT_animation(ObjectButtonsPanel): sub = split.column() sub.itemL(text="Tracking:") + sub.itemR(ob, "track", text="") sub.itemR(ob, "track_axis", text="Axis") sub.itemR(ob, "up_axis", text="Up Axis") - sub.itemR(ob, "track_rotation", text="Rotation") + row = sub.row() + row.itemR(ob, "track_override_parent", text="Override Parent") + row.active = ob.parent != None bpy.types.register(OBJECT_PT_context_object) bpy.types.register(OBJECT_PT_transform) +bpy.types.register(OBJECT_PT_relations) bpy.types.register(OBJECT_PT_groups) bpy.types.register(OBJECT_PT_display) bpy.types.register(OBJECT_PT_duplication) diff --git a/release/ui/buttons_scene.py b/release/ui/buttons_scene.py index 38286c9b86f..55578c44cee 100644 --- a/release/ui/buttons_scene.py +++ b/release/ui/buttons_scene.py @@ -28,10 +28,6 @@ class RENDER_PT_layers(RenderButtonsPanel): scene = context.scene rd = scene.render_data - split = layout.split() - split.itemL(text="Scene:") - split.column().itemR(scene, "visible_layers", text="") - row = layout.row() row.template_list(rd, "layers", rd, "active_layer_index", rows=2) @@ -42,8 +38,10 @@ class RENDER_PT_layers(RenderButtonsPanel): rl = rd.layers[rd.active_layer_index] split = layout.split() - split.itemL(text="Layers:") - split.column().itemR(rl, "visible_layers", text="") + col = split.column() + col.itemR(scene, "visible_layers", text="Scene") + col = split.column() + col.itemR(rl, "visible_layers", text="Layer") layout.itemR(rl, "light_override", text="Light") layout.itemR(rl, "material_override", text="Material") diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index f7dcc7fd1a0..ab718aca81f 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -57,6 +57,7 @@ void ED_object_apply_obmat(struct Object *ob); /* single object duplicate, if dupflag==0, fully linked, else it uses U.dupflag */ struct Base *ED_object_add_duplicate(struct Scene *scene, struct Base *base, int usedupflag); +void ED_object_parent(struct Object *ob, struct Object *parent, int type, const char *substr); /* bitflags for enter/exit editmode */ #define EM_FREEDATA 1 diff --git a/source/blender/editors/object/editconstraint.c b/source/blender/editors/object/editconstraint.c index 7be4697d0c8..62bc5d13257 100644 --- a/source/blender/editors/object/editconstraint.c +++ b/source/blender/editors/object/editconstraint.c @@ -1008,12 +1008,11 @@ void CONSTRAINT_OT_move_up (wmOperatorType *ot) /************************ add constraint operator *********************/ -static int constraint_add_exec(bContext *C, wmOperator *op) +static int constraint_add_exec(bContext *C, wmOperator *op, ListBase *list) { Scene *scene= CTX_data_scene(C); Object *ob = CTX_data_active_object(C); bConstraint *con, *coniter; - ListBase *list= get_active_constraints(ob); bPoseChannel *pchan= get_active_posechannel(ob); int type= RNA_enum_get(op->ptr, "type"); @@ -1077,6 +1076,26 @@ static int constraint_add_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int object_constraint_add_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + + if(!ob) + return OPERATOR_CANCELLED; + + return constraint_add_exec(C, op, &ob->constraints); +} + +static int pose_constraint_add_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + + if(!ob) + return OPERATOR_CANCELLED;; + + return constraint_add_exec(C, op, get_active_constraints(ob)); +} + void OBJECT_OT_constraint_add(wmOperatorType *ot) { /* identifiers */ @@ -1086,13 +1105,32 @@ void OBJECT_OT_constraint_add(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_menu_invoke; - ot->exec= constraint_add_exec; - + ot->exec= object_constraint_add_exec; ot->poll= ED_operator_object_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + /* properties */ + RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); +} + +void POSE_OT_constraint_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Constraint"; + ot->description = "Add a constraint to the active bone."; + ot->idname= "POSE_OT_constraint_add"; + + /* api callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= pose_constraint_add_exec; + ot->poll= ED_operator_posemode; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); } diff --git a/source/blender/editors/object/editgroup.c b/source/blender/editors/object/editgroup.c index 5943b36a6b0..9a184892e71 100644 --- a/source/blender/editors/object/editgroup.c +++ b/source/blender/editors/object/editgroup.c @@ -200,7 +200,7 @@ void GROUP_OT_objects_remove(wmOperatorType *ot) { /* identifiers */ - ot->name= "Remove from group"; + ot->name= "Remove From Groups"; ot->description = "Remove selected objects from all groups."; ot->idname= "GROUP_OT_objects_remove"; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 0746fbaefb6..26a89999475 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -2786,6 +2786,22 @@ static int test_parent_loop(Object *par, Object *ob) return test_parent_loop(par->parent, ob); } +void ED_object_parent(Object *ob, Object *par, int type, const char *substr) +{ + if(!par || test_parent_loop(par, ob)) { + ob->parent= NULL; + ob->partype= PAROBJECT; + ob->parsubstr[0]= 0; + return; + } + + /* this could use some more checks */ + + ob->parent= par; + ob->partype &= ~PARTYPE; + ob->partype |= type; + BLI_strncpy(ob->parsubstr, substr, sizeof(ob->parsubstr)); +} static int parent_set_exec(bContext *C, wmOperator *op) { diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 23a4b5773ff..5610a75d4d3 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -102,6 +102,7 @@ void OBJECT_OT_modifier_mdef_bind(struct wmOperatorType *ot); /* editconstraint.c */ void OBJECT_OT_constraint_add(struct wmOperatorType *ot); +void POSE_OT_constraint_add(struct wmOperatorType *ot); void CONSTRAINT_OT_delete(struct wmOperatorType *ot); void CONSTRAINT_OT_move_up(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index acfe2416d77..b73030226ef 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -112,6 +112,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_modifier_mdef_bind); WM_operatortype_append(OBJECT_OT_constraint_add); + WM_operatortype_append(POSE_OT_constraint_add); WM_operatortype_append(CONSTRAINT_OT_delete); WM_operatortype_append(CONSTRAINT_OT_move_up); WM_operatortype_append(CONSTRAINT_OT_move_down); @@ -147,16 +148,13 @@ void ED_keymap_object(wmWindowManager *wm) WM_keymap_add_item(keymap, "OBJECT_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OBJECT_OT_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "OBJECT_OT_select_random", PADASTERKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "OBJECT_OT_select_by_type", PADASTERKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "OBJECT_OT_select_by_layer", PADASTERKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_track_set", TKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_verify_item(keymap, "OBJECT_OT_track_set", TKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_verify_item(keymap, "OBJECT_OT_track_clear", TKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_location_clear", GKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_rotation_clear", RKEY, KM_PRESS, KM_ALT, 0); diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index f09f35589b9..20db9fce8f2 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -61,6 +61,9 @@ void buttons_context_draw(const struct bContext *C, struct uiLayout *layout); void buttons_context_register(struct ARegionType *art); /* buttons_ops.c */ +void OBJECT_OT_group_add(struct wmOperatorType *ot); +void OBJECT_OT_group_remove(struct wmOperatorType *ot); + void OBJECT_OT_material_slot_add(struct wmOperatorType *ot); void OBJECT_OT_material_slot_remove(struct wmOperatorType *ot); void OBJECT_OT_material_slot_assign(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index fb1e9d1214d..7dececd2679 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -31,6 +31,7 @@ #include "MEM_guardedalloc.h" #include "DNA_curve_types.h" +#include "DNA_group_types.h" #include "DNA_object_types.h" #include "DNA_material_types.h" #include "DNA_node_types.h" @@ -40,6 +41,7 @@ #include "BKE_context.h" #include "BKE_depsgraph.h" +#include "BKE_group.h" #include "BKE_font.h" #include "BKE_library.h" #include "BKE_main.h" @@ -62,8 +64,139 @@ #include "ED_curve.h" #include "ED_mesh.h" +#include "RNA_access.h" +#include "RNA_define.h" + #include "buttons_intern.h" // own include + +/********************** group operators *********************/ + +static int group_add_exec(bContext *C, wmOperator *op) +{ + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + Base *base; + Group *group; + int value= RNA_enum_get(op->ptr, "group"); + + if(!ob) + return OPERATOR_CANCELLED; + + base= object_in_scene(ob, scene); + if(!base) + return OPERATOR_CANCELLED; + + if(value == -1) + group= add_group( "Group" ); + else + group= BLI_findlink(&bmain->group, value); + + if(group) { + add_to_group(group, ob); + ob->flag |= OB_FROMGROUP; + base->flag |= OB_FROMGROUP; + } + + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + + return OPERATOR_FINISHED; +} + +static EnumPropertyItem group_items[]= { + {-1, "ADD_NEW", 0, "Add New Group", ""}, + {0, NULL, 0, NULL, NULL}}; + +static EnumPropertyItem *group_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + EnumPropertyItem tmp = {0, "", 0, "", ""}; + EnumPropertyItem *item= NULL; + Main *bmain; + Group *group; + int a, totitem= 0; + + if(!C) /* needed for docs */ + return group_items; + + RNA_enum_items_add_value(&item, &totitem, group_items, -1); + + bmain= CTX_data_main(C); + if(bmain->group.first) + RNA_enum_item_add_separator(&item, &totitem); + + for(a=0, group=bmain->group.first; group; group=group->id.next, a++) { + tmp.value= a; + tmp.identifier= group->id.name+2; + tmp.name= group->id.name+2; + RNA_enum_item_add(&item, &totitem, &tmp); + } + + RNA_enum_item_end(&item, &totitem); + + *free= 1; + + return item; +} + +void OBJECT_OT_group_add(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name= "Add Group"; + ot->idname= "OBJECT_OT_group_add"; + + /* api callbacks */ + ot->exec= group_add_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + prop= RNA_def_enum(ot->srna, "group", group_items, -1, "Group", "Group to add object to."); + RNA_def_enum_funcs(prop, group_itemf); +} + +static int group_remove_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + Group *group= CTX_data_pointer_get_type(C, "group", &RNA_Group).data; + Base *base; + + if(!ob || !group) + return OPERATOR_CANCELLED; + + base= object_in_scene(ob, scene); + if(!base) + return OPERATOR_CANCELLED; + + rem_from_group(group, ob); + + if(find_group(ob, NULL) == NULL) { + ob->flag &= ~OB_FROMGROUP; + base->flag &= ~OB_FROMGROUP; + } + + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_group_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Remove Group"; + ot->idname= "OBJECT_OT_group_remove"; + + /* api callbacks */ + ot->exec= group_remove_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /********************** material slot operators *********************/ static int material_slot_add_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 17f55c9395e..65fbdeb4205 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -210,6 +210,9 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar) void buttons_operatortypes(void) { + WM_operatortype_append(OBJECT_OT_group_add); + WM_operatortype_append(OBJECT_OT_group_remove); + WM_operatortype_append(OBJECT_OT_material_slot_add); WM_operatortype_append(OBJECT_OT_material_slot_remove); WM_operatortype_append(OBJECT_OT_material_slot_assign); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 33e8c1fbd26..5ec25cfe4c2 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -41,6 +41,17 @@ #include "WM_types.h" +static EnumPropertyItem parent_type_items[] = { + {PAROBJECT, "OBJECT", 0, "Object", ""}, + {PARCURVE, "CURVE", 0, "Curve", ""}, + //{PARKEY, "KEY", 0, "Key", ""}, + {PARSKEL, "ARMATURE", 0, "Armature", ""}, + {PARSKEL, "LATTICE", 0, "Lattice", ""}, // PARSKEL reuse will give issues + {PARVERT1, "VERTEX", 0, "Vertex", ""}, + {PARVERT3, "VERTEX_3", 0, "3 Vertices", ""}, + {PARBONE, "BONE", 0, "Bone", ""}, + {0, NULL, 0, NULL, NULL}}; + #ifdef RNA_RUNTIME #include "DNA_key_types.h" @@ -54,6 +65,9 @@ #include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_particle.h" +#include "BKE_scene.h" + +#include "ED_object.h" void rna_Object_update(bContext *C, PointerRNA *ptr) { @@ -71,6 +85,27 @@ static void rna_Object_dependency_update(bContext *C, PointerRNA *ptr) DAG_scene_sort(CTX_data_scene(C)); } +static void rna_Object_layer_update(bContext *C, PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + Scene *scene= CTX_data_scene(C); + Base *base; + + base= object_in_scene(ob, scene); + if(!base) + return; + + /* try to avoid scene sort */ + if((ob->lay & scene->lay) && (base->lay & scene->lay)) + base->lay= ob->lay; + else if((ob->lay & scene->lay)==0 && (base->lay & scene->lay)==0) + base->lay= ob->lay; + else { + base->lay= ob->lay; + DAG_scene_sort(scene); + } +} + static int rna_Object_data_editable(PointerRNA *ptr) { Object *ob= (Object*)ptr->data; @@ -123,6 +158,67 @@ static StructRNA *rna_Object_data_typef(PointerRNA *ptr) } } +static void rna_Object_parent_set(PointerRNA *ptr, PointerRNA value) +{ + Object *ob= (Object*)ptr->data; + Object *par= (Object*)value.data; + + ED_object_parent(ob, par, ob->partype, ob->parsubstr); +} + +static void rna_Object_parent_type_set(PointerRNA *ptr, int value) +{ + Object *ob= (Object*)ptr->data; + + ED_object_parent(ob, ob->parent, value, ob->parsubstr); +} + +static void rna_Object_track_set(PointerRNA *ptr, PointerRNA value) +{ + Object *ob= (Object*)ptr->data; + + if(ob != value.data) + ob->track= value.data; +} + +static EnumPropertyItem *rna_Object_parent_type_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + Object *ob= (Object*)ptr->data; + Object *par= ob->parent; + EnumPropertyItem *item= NULL; + int totitem= 0; + + RNA_enum_items_add_value(&item, &totitem, parent_type_items, PAROBJECT); + + if(par) { + if(par->type == OB_CURVE) + RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARCURVE); + else if(par->type == OB_LATTICE) + RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARSKEL); + else if(par->type == OB_ARMATURE) { + RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARSKEL); + RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARBONE); + } + else if(par->type == OB_MESH) { + RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT1); + RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT3); + } + } + + RNA_enum_item_end(&item, &totitem); + + *free= 1; + + return item; +} + +static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value) +{ + Object *ob= (Object*)ptr->data; + + ED_object_parent(ob, ob->parent, ob->partype, value); +} + static int rna_VertexGroup_index_get(PointerRNA *ptr) { Object *ob= (Object*)ptr->id.data; @@ -769,17 +865,6 @@ static void rna_def_object(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem parent_type_items[] = { - {PAROBJECT, "OBJECT", 0, "Object", ""}, - {PARCURVE, "CURVE", 0, "Curve", ""}, - //{PARKEY, "KEY", 0, "Key", ""}, - {PARSKEL, "ARMATURE", 0, "Armature", ""}, - {PARSKEL, "LATTICE", 0, "Lattice", ""}, // PARSKEL reuse will give issues - {PARVERT1, "VERTEX", 0, "Vertex", ""}, - {PARVERT3, "VERTEX_3", 0, "3 Vertices", ""}, - {PARBONE, "BONE", 0, "Bone", ""}, - {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem object_type_items[] = { {OB_EMPTY, "EMPTY", 0, "Empty", ""}, {OB_MESH, "MESH", 0, "Mesh", ""}, @@ -856,56 +941,70 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Data", "Object data."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update_data"); + prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, object_type_items); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Type", "Type of Object."); + prop= RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); RNA_def_property_array(prop, 20); RNA_def_property_ui_text(prop, "Layers", "Layers the object is on."); RNA_def_property_boolean_funcs(prop, NULL, "rna_Object_layer_set"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_layer_update"); prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Selected", "Object selection state."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); /* parent and track */ prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_parent_set", NULL); + RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Parent", "Parent Object"); - - prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, object_type_items); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Type", "Type of Object."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update"); prop= RNA_def_property(srna, "parent_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "partype"); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "partype"); RNA_def_property_enum_items(prop, parent_type_items); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_enum_funcs(prop, NULL, "rna_Object_parent_type_set", "rna_Object_parent_type_itemf"); RNA_def_property_ui_text(prop, "Parent Type", "Type of parent relation."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update"); prop= RNA_def_property(srna, "parent_vertices", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "par1"); RNA_def_property_array(prop, 3); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Parent Vertices", "Indices of vertices in cases of a vertex parenting relation."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update"); prop= RNA_def_property(srna, "parent_bone", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "parsubstr"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Object_parent_bone_set"); RNA_def_property_ui_text(prop, "Parent Bone", "Name of parent bone in case of a bone parenting relation."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update"); prop= RNA_def_property(srna, "track", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_track_set", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Track", "Object being tracked to define the rotation (Old Track)."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update"); prop= RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "trackflag"); RNA_def_property_enum_items(prop, track_items); RNA_def_property_ui_text(prop, "Track Axis", "Tracking axis pointing to the another object."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update"); prop= RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "upflag"); RNA_def_property_enum_items(prop, up_items); RNA_def_property_ui_text(prop, "Up Axis", "Specify the axis that points up."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update"); /* proxy */ @@ -1043,6 +1142,7 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "col"); RNA_def_property_ui_text(prop, "Color", "Object color and alpha, used when faces have the ObColor mode enabled."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); /* physics */ @@ -1071,10 +1171,12 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_struct_type(prop, "ParticleSystem"); RNA_def_property_pointer_funcs(prop, "rna_Object_active_particle_system_get", NULL, NULL); RNA_def_property_ui_text(prop, "Active Particle System", "Active particle system being displayed"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); prop= RNA_def_property(srna, "active_particle_system_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_funcs(prop, "rna_Object_active_particle_system_index_get", "rna_Object_active_particle_system_index_set", "rna_Object_active_particle_system_index_range"); RNA_def_property_ui_text(prop, "Active Particle System Index", "Index of active particle system slot."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); /* restrict */ @@ -1086,10 +1188,12 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "restrict_select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT); RNA_def_property_ui_text(prop, "Restrict Select", "Restrict selection in the viewport."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); prop= RNA_def_property(srna, "restrict_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER); RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); /* anim */ @@ -1099,19 +1203,22 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_DRAWKEY); RNA_def_property_clear_flag(prop, PROP_EDITABLE); // update ipo flag indirect RNA_def_property_ui_text(prop, "Draw Keys", "Draw object as key positions."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update"); prop= RNA_def_property(srna, "draw_keys_selected", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "ipoflag", OB_DRAWKEYSEL); RNA_def_property_ui_text(prop, "Draw Keys Selected", "Limit the drawing of object keys to selected."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); - prop= RNA_def_property(srna, "track_rotation", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "track_override_parent", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_POWERTRACK); - RNA_def_property_ui_text(prop, "Track Rotation", "Switch object rotation of in tracking."); + RNA_def_property_ui_text(prop, "Track Override Parent", "Override rotation from parenting."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update"); prop= RNA_def_property(srna, "slow_parent", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "partype", PARSLOW); RNA_def_property_ui_text(prop, "Slow Parent", "Create a delay in the parent relationship."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_update"); prop= RNA_def_property(srna, "dupli_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag"); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index f52e130d527..920d8760358 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1105,7 +1105,7 @@ void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "use_compositing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_DOCOMP); - RNA_def_property_ui_text(prop, "Compositing", "Process the render result through the compositing pipeline, if a compositing nodes are enabled."); + RNA_def_property_ui_text(prop, "Compositing", "Process the render result through the compositing pipeline, if compositing nodes are enabled."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "use_sequencer", PROP_BOOLEAN, PROP_NONE); -- cgit v1.2.3