diff options
author | Joseph Eagar <joeedh@gmail.com> | 2009-10-23 03:22:05 +0400 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2009-10-23 03:22:05 +0400 |
commit | 8f788c64db587e74079d812dbcea40c2bd4b91ff (patch) | |
tree | c767e8318a9e7aded16be6cab2042f3ea11e7912 /source/blender/editors/object | |
parent | 36bb566d4e6e06e08d782d610d60d755cbda2396 (diff) |
merge with trunk/2.5 at r23876
[[Split portion of a mixed commit.]]
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/Makefile | 1 | ||||
-rw-r--r-- | source/blender/editors/object/SConscript | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_add.c | 352 | ||||
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 44 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 29 | ||||
-rw-r--r-- | source/blender/editors/object/object_group.c | 9 | ||||
-rw-r--r-- | source/blender/editors/object/object_hook.c | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 9 | ||||
-rw-r--r-- | source/blender/editors/object/object_lattice.c | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 33 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 70 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 32 | ||||
-rw-r--r-- | source/blender/editors/object/object_select.c | 13 | ||||
-rw-r--r-- | source/blender/editors/object/object_transform.c | 98 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 12 |
15 files changed, 477 insertions, 229 deletions
diff --git a/source/blender/editors/object/Makefile b/source/blender/editors/object/Makefile index 70ada46c80f..fd2af305d87 100644 --- a/source/blender/editors/object/Makefile +++ b/source/blender/editors/object/Makefile @@ -47,6 +47,7 @@ CPPFLAGS += -I../../makesdna CPPFLAGS += -I../../makesrna CPPFLAGS += -I../../python CPPFLAGS += -I../../imbuf +CPPFLAGS += -I../../ikplugin # own include diff --git a/source/blender/editors/object/SConscript b/source/blender/editors/object/SConscript index 0b7a4e41192..a6f034c9c33 100644 --- a/source/blender/editors/object/SConscript +++ b/source/blender/editors/object/SConscript @@ -6,7 +6,7 @@ sources = env.Glob('*.c') incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc' incs += ' #/intern/guardedalloc' -incs += ' ../../makesrna ../../python ../../bmesh' +incs += ' ../../makesrna ../../python ../../ikplugin ../../bmesh' defs = [] diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index ee9af61f516..25ecb41a523 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -26,17 +26,20 @@ */ #include <stdlib.h> +#include <string.h> #include "MEM_guardedalloc.h" #include "DNA_action_types.h" #include "DNA_curve_types.h" #include "DNA_group_types.h" +#include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" #include "DNA_object_fluidsim.h" #include "DNA_object_types.h" +#include "DNA_object_force.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_userdef_types.h" @@ -55,6 +58,7 @@ #include "BKE_depsgraph.h" #include "BKE_DerivedMesh.h" #include "BKE_displist.h" +#include "BKE_effect.h" #include "BKE_global.h" #include "BKE_group.h" #include "BKE_lattice.h" @@ -109,7 +113,7 @@ void ED_object_base_init_from_view(bContext *C, Base *base) VECCOPY(ob->loc, scene->cursor); } else { - if (v3d->localview) { + if (v3d->localvd) { base->lay= ob->lay= v3d->layact | v3d->lay; VECCOPY(ob->loc, v3d->cursor); } @@ -140,14 +144,14 @@ void add_object_draw(Scene *scene, View3D *v3d, int type) /* for toolbox or menu } /* for object add primitive operators */ -static Object *object_add_type(bContext *C, int type) +Object *ED_object_add_type(bContext *C, int type) { Scene *scene= CTX_data_scene(C); Object *ob; /* for as long scene has editmode... */ if (CTX_data_edit_object(C)) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */ + ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); /* freedata, and undo */ /* deselects all, sets scene->basact */ ob= add_object(scene, type); @@ -165,7 +169,7 @@ static Object *object_add_type(bContext *C, int type) /* for object add operator */ static int object_add_exec(bContext *C, wmOperator *op) { - object_add_type(C, RNA_int_get(op->ptr, "type")); + ED_object_add_type(C, RNA_enum_get(op->ptr, "type")); return OPERATOR_FINISHED; } @@ -189,94 +193,92 @@ void OBJECT_OT_add(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", object_type_items, 0, "Type", ""); } -/* ***************** add primitives *************** */ -/* ****** work both in and outside editmode ****** */ - -static EnumPropertyItem prop_mesh_types[] = { - {0, "PLANE", ICON_MESH_PLANE, "Plane", ""}, - {1, "CUBE", ICON_MESH_CUBE, "Cube", ""}, - {2, "CIRCLE", ICON_MESH_CIRCLE, "Circle", ""}, - {3, "UVSPHERE", ICON_MESH_UVSPHERE, "UVsphere", ""}, - {4, "ICOSPHERE", ICON_MESH_ICOSPHERE, "Icosphere", ""}, - {5, "CYLINDER", ICON_MESH_TUBE, "Cylinder", ""}, - {6, "CONE", ICON_MESH_CONE, "Cone", ""}, - {0, "", 0, NULL, NULL}, - {7, "GRID", ICON_MESH_GRID, "Grid", ""}, - {8, "MONKEY", ICON_MESH_MONKEY, "Monkey", ""}, - {0, NULL, 0, NULL, NULL} -}; +/********************* Add Effector Operator ********************/ +/* copy from rna_object_force.c*/ +static EnumPropertyItem field_type_items[] = { + {0, "NONE", 0, "None", ""}, + {PFIELD_FORCE, "FORCE", 0, "Force", ""}, + {PFIELD_WIND, "WIND", 0, "Wind", ""}, + {PFIELD_VORTEX, "VORTEX", 0, "Vortex", ""}, + {PFIELD_MAGNET, "MAGNET", 0, "Magnetic", ""}, + {PFIELD_HARMONIC, "HARMONIC", 0, "Harmonic", ""}, + {PFIELD_CHARGE, "CHARGE", 0, "Charge", ""}, + {PFIELD_LENNARDJ, "LENNARDJ", 0, "Lennard-Jones", ""}, + {PFIELD_TEXTURE, "TEXTURE", 0, "Texture", ""}, + {PFIELD_GUIDE, "GUIDE", 0, "Curve Guide", ""}, + {PFIELD_BOID, "BOID", 0, "Boid", ""}, + {PFIELD_TURBULENCE, "TURBULENCE", 0, "Turbulence", ""}, + {PFIELD_DRAG, "DRAG", 0, "Drag", ""}, + {0, NULL, 0, NULL, NULL}}; -static int object_add_mesh_exec(bContext *C, wmOperator *op) +void add_effector_draw(Scene *scene, View3D *v3d, int type) /* for toolbox or menus, only non-editmode stuff */ { - Object *obedit= CTX_data_edit_object(C); - int newob= 0; + /* keep here to get things compile, remove later */ +} + +/* for effector add primitive operators */ +static Object *effector_add_type(bContext *C, int type) +{ + Scene *scene= CTX_data_scene(C); + Object *ob; - if(obedit==NULL || obedit->type!=OB_MESH) { - object_add_type(C, OB_MESH); - ED_object_enter_editmode(C, EM_DO_UNDO); - newob = 1; + /* for as long scene has editmode... */ + if (CTX_data_edit_object(C)) + ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); /* freedata, and undo */ + + /* deselects all, sets scene->basact */ + if(type==PFIELD_GUIDE) { + ob = add_object(scene, OB_CURVE); + ((Curve*)ob->data)->flag |= CU_PATH|CU_3D; + ED_object_enter_editmode(C, 0); + BLI_addtail(curve_get_editcurve(ob), add_nurbs_primitive(C, CU_NURBS|CU_PRIM_PATH, 1)); + ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO); } - else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); + else + ob= add_object(scene, OB_EMPTY); - switch(RNA_enum_get(op->ptr, "type")) { - case 0: - WM_operator_name_call(C, "MESH_OT_primitive_plane_add", WM_OP_INVOKE_REGION_WIN, NULL); - break; - case 1: - WM_operator_name_call(C, "MESH_OT_primitive_cube_add", WM_OP_INVOKE_REGION_WIN, NULL); - break; - case 2: - WM_operator_name_call(C, "MESH_OT_primitive_circle_add", WM_OP_INVOKE_REGION_WIN, NULL); - break; - case 3: - WM_operator_name_call(C, "MESH_OT_primitive_uv_sphere_add", WM_OP_INVOKE_REGION_WIN, NULL); - break; - case 4: - WM_operator_name_call(C, "MESH_OT_primitive_ico_sphere_add", WM_OP_INVOKE_REGION_WIN, NULL); - break; - case 5: - WM_operator_name_call(C, "MESH_OT_primitive_cylinder_add", WM_OP_INVOKE_REGION_WIN, NULL); - break; - case 6: - WM_operator_name_call(C, "MESH_OT_primitive_cone_add", WM_OP_INVOKE_REGION_WIN, NULL); - break; - case 7: - WM_operator_name_call(C, "MESH_OT_primitive_grid_add", WM_OP_INVOKE_REGION_WIN, NULL); - break; - case 8: - WM_operator_name_call(C, "MESH_OT_primitive_monkey_add", WM_OP_INVOKE_REGION_WIN, NULL); - break; - } - /* userdef */ - if (newob && (U.flag & USER_ADD_EDITMODE)==0) { - ED_object_exit_editmode(C, EM_FREEDATA); - } - - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit); + ob->pd= object_add_collision_fields(type); + + /* editor level activate, notifiers */ + ED_base_object_activate(C, BASACT); + + /* more editor stuff */ + ED_object_base_init_from_view(C, BASACT); + + DAG_scene_sort(scene); + + return ob; +} + +/* for object add operator */ +static int effector_add_exec(bContext *C, wmOperator *op) +{ + effector_add_type(C, RNA_int_get(op->ptr, "type")); return OPERATOR_FINISHED; } - -void OBJECT_OT_mesh_add(wmOperatorType *ot) +void OBJECT_OT_effector_add(wmOperatorType *ot) { /* identifiers */ - ot->name= "Add Mesh"; - ot->description = "Add a mesh object to the scene."; - ot->idname= "OBJECT_OT_mesh_add"; + ot->name= "Add Effector"; + ot->description = "Add an empty object with a physics effector to the scene."; + ot->idname= "OBJECT_OT_effector_add"; /* api callbacks */ ot->invoke= WM_menu_invoke; - ot->exec= object_add_mesh_exec; + ot->exec= effector_add_exec; ot->poll= ED_operator_scene_editable; - /* flags: no register or undo, this operator calls operators */ - ot->flag= 0; //OPTYPE_REGISTER|OPTYPE_UNDO; + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_enum(ot->srna, "type", prop_mesh_types, 0, "Primitive", ""); + RNA_def_enum(ot->srna, "type", field_type_items, 0, "Type", ""); } +/* ***************** add primitives *************** */ + static EnumPropertyItem prop_curve_types[] = { {CU_BEZIER|CU_PRIM_CURVE, "BEZIER_CURVE", ICON_CURVE_BEZCURVE, "Bezier Curve", ""}, {CU_BEZIER|CU_PRIM_CIRCLE, "BEZIER_CIRCLE", ICON_CURVE_BEZCIRCLE, "Bezier Circle", ""}, @@ -294,7 +296,7 @@ static int object_add_curve_exec(bContext *C, wmOperator *op) int newob= 0; if(obedit==NULL || obedit->type!=OB_CURVE) { - object_add_type(C, OB_CURVE); + ED_object_add_type(C, OB_CURVE); ED_object_enter_editmode(C, 0); newob = 1; } @@ -307,7 +309,7 @@ static int object_add_curve_exec(bContext *C, wmOperator *op) /* userdef */ if (newob && (U.flag & USER_ADD_EDITMODE)==0) { - ED_object_exit_editmode(C, EM_FREEDATA); + ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO); } WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit); @@ -369,7 +371,7 @@ static int object_add_surface_exec(bContext *C, wmOperator *op) int newob= 0; if(obedit==NULL || obedit->type!=OB_SURF) { - object_add_type(C, OB_SURF); + ED_object_add_type(C, OB_SURF); ED_object_enter_editmode(C, 0); newob = 1; } @@ -382,7 +384,7 @@ static int object_add_surface_exec(bContext *C, wmOperator *op) /* userdef */ if (newob && (U.flag & USER_ADD_EDITMODE)==0) { - ED_object_exit_editmode(C, EM_FREEDATA); + ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO); } WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit); @@ -426,7 +428,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) int newob= 0; if(obedit==NULL || obedit->type!=OB_MBALL) { - object_add_type(C, OB_MBALL); + ED_object_add_type(C, OB_MBALL); ED_object_enter_editmode(C, 0); newob = 1; } @@ -439,7 +441,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) /* userdef */ if (newob && (U.flag & USER_ADD_EDITMODE)==0) { - ED_object_exit_editmode(C, EM_FREEDATA); + ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO); } WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit); @@ -467,7 +469,7 @@ static int object_metaball_add_invoke(bContext *C, wmOperator *op, wmEvent *even void OBJECT_OT_metaball_add(wmOperatorType *ot) { /* identifiers */ - ot->name= "Metaball"; + ot->name= "Add Metaball"; ot->description= "Add an metaball object to the scene."; ot->idname= "OBJECT_OT_metaball_add"; @@ -488,7 +490,7 @@ static int object_add_text_exec(bContext *C, wmOperator *op) if(obedit && obedit->type==OB_FONT) return OPERATOR_CANCELLED; - object_add_type(C, OB_FONT); + ED_object_add_type(C, OB_FONT); obedit= CTX_data_active_object(C); if(U.flag & USER_ADD_EDITMODE) @@ -522,7 +524,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) int newob= 0; if ((obedit==NULL) || (obedit->type != OB_ARMATURE)) { - object_add_type(C, OB_ARMATURE); + ED_object_add_type(C, OB_ARMATURE); ED_object_enter_editmode(C, 0); newob = 1; } @@ -536,7 +538,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) /* userdef */ if (newob && (U.flag & USER_ADD_EDITMODE)==0) { - ED_object_exit_editmode(C, EM_FREEDATA); + ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO); } WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit); @@ -559,45 +561,112 @@ void OBJECT_OT_armature_add(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int object_primitive_add_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int object_lamp_add_exec(bContext *C, wmOperator *op) { - uiPopupMenu *pup= uiPupMenuBegin(C, "Add Object", 0); - uiLayout *layout= uiPupMenuLayout(pup); - - uiItemMenuEnumO(layout, "Mesh", ICON_OUTLINER_OB_MESH, "OBJECT_OT_mesh_add", "type"); - uiItemMenuEnumO(layout, "Curve", ICON_OUTLINER_OB_CURVE, "OBJECT_OT_curve_add", "type"); - uiItemMenuEnumO(layout, "Surface", ICON_OUTLINER_OB_SURFACE, "OBJECT_OT_surface_add", "type"); - uiItemMenuEnumO(layout, NULL, ICON_OUTLINER_OB_META, "OBJECT_OT_metaball_add", "type"); - uiItemO(layout, "Text", ICON_OUTLINER_OB_FONT, "OBJECT_OT_text_add"); - uiItemS(layout); - uiItemO(layout, "Armature", ICON_OUTLINER_OB_ARMATURE, "OBJECT_OT_armature_add"); - uiItemEnumO(layout, NULL, ICON_OUTLINER_OB_LATTICE, "OBJECT_OT_add", "type", OB_LATTICE); - uiItemEnumO(layout, NULL, ICON_OUTLINER_OB_EMPTY, "OBJECT_OT_add", "type", OB_EMPTY); - uiItemS(layout); - uiItemEnumO(layout, NULL, ICON_OUTLINER_OB_CAMERA, "OBJECT_OT_add", "type", OB_CAMERA); - uiItemEnumO(layout, NULL, ICON_OUTLINER_OB_LAMP, "OBJECT_OT_add", "type", OB_LAMP); + Object *ob; + int type= RNA_enum_get(op->ptr, "type"); + + ob= ED_object_add_type(C, OB_LAMP); + if(ob && ob->data) + ((Lamp*)ob->data)->type= type; - uiPupMenuEnd(C, pup); + return OPERATOR_FINISHED; +} + +void OBJECT_OT_lamp_add(wmOperatorType *ot) +{ + static EnumPropertyItem lamp_type_items[] = { + {LA_LOCAL, "POINT", ICON_LAMP_POINT, "Point", "Omnidirectional point light source."}, + {LA_SUN, "SUN", ICON_LAMP_SUN, "Sun", "Constant direction parallel ray light source."}, + {LA_SPOT, "SPOT", ICON_LAMP_SPOT, "Spot", "Directional cone light source."}, + {LA_HEMI, "HEMI", ICON_LAMP_HEMI, "Hemi", "180 degree constant light source."}, + {LA_AREA, "AREA", ICON_LAMP_AREA, "Area", "Directional area light source."}, + {0, NULL, 0, NULL, NULL}}; + + /* identifiers */ + ot->name= "Add Lamp"; + ot->description = "Add a lamp object to the scene."; + ot->idname= "OBJECT_OT_lamp_add"; - /* this operator is only for a menu, not used further */ + /* api callbacks */ + ot->invoke= WM_menu_invoke; + ot->exec= object_lamp_add_exec; + ot->poll= ED_operator_scene_editable; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_enum(ot->srna, "type", lamp_type_items, 0, "Type", ""); +} + +/* add dupligroup */ +static EnumPropertyItem *add_dupligroup_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + EnumPropertyItem *item= NULL, item_tmp; + int totitem= 0; + int i= 0; + Group *group; + + memset(&item_tmp, 0, sizeof(item_tmp)); + + for(group= CTX_data_main(C)->group.first; group; group= group->id.next) { + item_tmp.identifier= item_tmp.name= group->id.name+2; + item_tmp.value= i++; + RNA_enum_item_add(&item, &totitem, &item_tmp); + } + + RNA_enum_item_end(&item, &totitem); + *free= 1; + + return item; +} + +static int group_instance_add_exec(bContext *C, wmOperator *op) +{ + /* XXX, using an enum for library lookups is a bit dodgy */ + Group *group= BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "type")); + + if(group) { + Object *ob= ED_object_add_type(C, OB_EMPTY); + rename_id(&ob->id, group->id.name+2); + ob->dup_group= group; + ob->transflag |= OB_DUPLIGROUP; + id_us_plus(&group->id); + + + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + + return OPERATOR_FINISHED; + } + return OPERATOR_CANCELLED; } /* only used as menu */ -void OBJECT_OT_primitive_add(wmOperatorType *ot) +void OBJECT_OT_group_instance_add(wmOperatorType *ot) { + PropertyRNA *prop; + static EnumPropertyItem prop_group_dummy_types[] = { + {0, NULL, 0, NULL, NULL} + }; + /* identifiers */ - ot->name= "Add Primitive"; - ot->description = "Add a primitive object."; - ot->idname= "OBJECT_OT_primitive_add"; - + ot->name= "Add Group Instance"; + ot->description = "Add a dupligroup instance."; + ot->idname= "OBJECT_OT_group_instance_add"; + /* api callbacks */ - ot->invoke= object_primitive_add_invoke; - + ot->exec= group_instance_add_exec; + ot->poll= ED_operator_scene_editable; - + /* flags */ ot->flag= 0; + + /* properties */ + prop= RNA_def_enum(ot->srna, "type", prop_group_dummy_types, 0, "Type", ""); + RNA_def_enum_funcs(prop, add_dupligroup_itemf); } /**************************** Delete Object *************************/ @@ -857,8 +926,8 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot) /**************************** Convert **************************/ static EnumPropertyItem convert_target_items[]= { - {OB_CURVE, "CURVE", 0, "Curve", ""}, - {OB_MESH, "MESH", 0, "Mesh", ""}, + {OB_CURVE, "CURVE", ICON_OUTLINER_OB_CURVE, "Curve from Mesh/Text", ""}, + {OB_MESH, "MESH", ICON_OUTLINER_OB_MESH, "Mesh from Curve/Meta/Surf/Mesh", ""}, {0, NULL, 0, NULL, NULL}}; static void curvetomesh(Scene *scene, Object *ob) @@ -910,6 +979,25 @@ static int convert_exec(bContext *C, wmOperator *op) if(ob->flag & OB_DONE) continue; + else if (ob->type==OB_MESH && target == OB_CURVE) { + ob->flag |= OB_DONE; + + ob1= copy_object(ob); + ob1->recalc |= OB_RECALC; + + basen= MEM_mallocN(sizeof(Base), "duplibase"); + *basen= *base; + BLI_addhead(&scene->base, basen); /* addhead: otherwise eternal loop */ + basen->object= ob1; + basen->flag |= SELECT; + base->flag &= ~SELECT; + ob->flag &= ~SELECT; + + mesh_to_curve(scene, ob1); + + if(ob1->type==OB_CURVE) + object_free_modifiers(ob1); /* after derivedmesh calls! */ + } else if(ob->type==OB_MESH && ob->modifiers.first) { /* converting a mesh with no modifiers causes a segfault */ ob->flag |= OB_DONE; basedel = base; @@ -935,7 +1023,7 @@ static int convert_exec(bContext *C, wmOperator *op) /* make new mesh data from the original copy */ dm= mesh_get_derived_final(scene, ob1, CD_MASK_MESH); /* dm= mesh_create_derived_no_deform(ob1, NULL); this was called original (instead of get_derived). man o man why! (ton) */ - + DM_to_mesh(dm, ob1->data); dm->release(dm); @@ -1059,48 +1147,14 @@ static int convert_exec(bContext *C, wmOperator *op) BASACT= basact; DAG_scene_sort(scene); - WM_event_add_notifier(C, NC_SCENE, scene); + WM_event_add_notifier(C, NC_SCENE|NC_OBJECT|ND_DRAW, scene); /* is NC_SCENE needed ? */ - return OPERATOR_FINISHED; -} -static int convert_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - Object *obact= CTX_data_active_object(C); - uiPopupMenu *pup; - uiLayout *layout; - char *title; - - if(obact->type==OB_FONT) { - pup= uiPupMenuBegin(C, "Convert Font to", 0); - layout= uiPupMenuLayout(pup); - - uiItemEnumO(layout, "Curve", 0, op->type->idname, "target", OB_CURVE); - } - else { - if(obact->type == OB_MBALL) - title= "Convert Metaball to"; - else if(obact->type == OB_CURVE) - title= "Convert Curve to"; - else if(obact->type == OB_SURF) - title= "Convert Nurbs Surface to"; - else if(obact->type == OB_MESH) - title= "Convert Modifiers to"; - else - return OPERATOR_CANCELLED; - - pup= uiPupMenuBegin(C, title, 0); - layout= uiPupMenuLayout(pup); - } - uiItemBooleanO(layout, "Mesh (keep original)", 0, op->type->idname, "keep_original", 1); - uiItemBooleanO(layout, "Mesh (delete original)", 0, op->type->idname, "keep_original", 0); - - uiPupMenuEnd(C, pup); - - return OPERATOR_CANCELLED; + return OPERATOR_FINISHED; } + void OBJECT_OT_convert(wmOperatorType *ot) { /* identifiers */ @@ -1109,7 +1163,7 @@ void OBJECT_OT_convert(wmOperatorType *ot) ot->idname= "OBJECT_OT_convert"; /* api callbacks */ - ot->invoke= convert_invoke; + ot->invoke= WM_menu_invoke; ot->exec= convert_exec; ot->poll= convert_poll; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 9b073ed5878..8c0da354938 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -56,6 +56,7 @@ #include "BKE_object.h" #include "BKE_report.h" #include "BKE_utildefines.h" +#include "BIK_api.h" #ifndef DISABLE_PYTHON #include "BPY_extern.h" @@ -334,6 +335,7 @@ static void test_constraints (Object *owner, const char substring[]) * optional... otherwise poletarget must exist too or else * the constraint is deemed invalid */ + /* default IK check ... */ if (exist_object(data->tar) == 0) { data->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; @@ -355,7 +357,8 @@ static void test_constraints (Object *owner, const char substring[]) } } } - + /* ... can be overwritten here */ + BIK_test_constraint(owner, curcon); /* targets have already been checked for this */ continue; } @@ -702,6 +705,25 @@ void ED_object_constraint_set_active(Object *ob, bConstraint *con) } } +void ED_object_constraint_update(Object *ob) +{ + + if(ob->pose) update_pose_constraint_flags(ob->pose); + + object_test_constraints(ob); + + if(ob->type==OB_ARMATURE) DAG_id_flush_update(&ob->id, OB_RECALC_DATA|OB_RECALC_OB); + else DAG_id_flush_update(&ob->id, OB_RECALC_OB); +} + +void ED_object_constraint_dependency_update(Scene *scene, Object *ob) +{ + ED_object_constraint_update(ob); + + if(ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels + DAG_scene_sort(scene); +} + static int constraint_poll(bContext *C) { PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint); @@ -717,6 +739,10 @@ static int constraint_delete_exec (bContext *C, wmOperator *op) /* remove constraint itself */ lb= get_active_constraints(ob); + if (BLI_findindex(lb, con) == -1) + /* abnormal situation which happens on bone constraint when the armature is not in pose mode */ + return OPERATOR_CANCELLED; + free_constraint_data(con); BLI_freelinkN(lb, con); @@ -823,17 +849,22 @@ void CONSTRAINT_OT_move_up (wmOperatorType *ot) static int pose_constraints_clear_exec(bContext *C, wmOperator *op) { Object *ob= CTX_data_active_object(C); + Scene *scene= CTX_data_scene(C); /* free constraints for all selected bones */ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans) { free_constraints(&pchan->constraints); + pchan->constflag &= ~(PCHAN_HAS_IK|PCHAN_HAS_CONST); } CTX_DATA_END; + /* force depsgraph to get recalculated since relationships removed */ + DAG_scene_sort(scene); /* sort order of objects */ + /* do updates */ - DAG_id_flush_update(&ob->id, OB_RECALC_OB); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE|ND_CONSTRAINT|NA_REMOVED, ob); + DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); return OPERATOR_FINISHED; } @@ -854,14 +885,18 @@ void POSE_OT_constraints_clear(wmOperatorType *ot) static int object_constraints_clear_exec(bContext *C, wmOperator *op) { Object *ob= CTX_data_active_object(C); + Scene *scene= CTX_data_scene(C); /* do freeing */ // TODO: we should free constraints for all selected objects instead (to be more consistent with bones) free_constraints(&ob->constraints); + /* force depsgraph to get recalculated since relationships removed */ + DAG_scene_sort(scene); /* sort order of objects */ + /* do updates */ DAG_id_flush_update(&ob->id, OB_RECALC_OB); - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, ob); + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); return OPERATOR_FINISHED; } @@ -910,7 +945,6 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o /* restricted target-type constraints -------------- */ /* NOTE: for these, we cannot try to add a target object if no valid ones are found, since that doesn't work */ /* curve-based constraints - set the only_curve and only_ob flags */ - case CONSTRAINT_TYPE_TRACKTO: case CONSTRAINT_TYPE_CLAMPTO: case CONSTRAINT_TYPE_FOLLOWPATH: only_curve= 1; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index dfda294561b..08689e9b62b 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -281,6 +281,8 @@ void OBJECT_OT_restrictview_set(wmOperatorType *ot) void ED_object_exit_editmode(bContext *C, int flag) { + /* Note! only in exceptional cases should 'EM_DO_UNDO' NOT be in the flag */ + Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); int freedata = flag & EM_FREEDATA; @@ -334,7 +336,7 @@ void ED_object_exit_editmode(bContext *C, int flag) if(freedata) free_editMball(obedit); } - /* freedata only 0 now on file saves */ + /* freedata only 0 now on file saves and render */ if(freedata) { /* for example; displist make is different in editmode */ scene->obedit= NULL; // XXX for context @@ -344,15 +346,16 @@ void ED_object_exit_editmode(bContext *C, int flag) /* also flush ob recalc, doesn't take much overhead, but used for particles */ DAG_id_flush_update(&obedit->id, OB_RECALC_OB|OB_RECALC_DATA); - ED_undo_push(C, "Editmode"); + if(flag & EM_DO_UNDO) + ED_undo_push(C, "Editmode"); if(flag & EM_WAITCURSOR) waitcursor(0); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, scene); - } - obedit->mode &= ~OB_MODE_EDIT; - ED_object_toggle_modes(C, obedit->restore_mode); + obedit->mode &= ~OB_MODE_EDIT; + ED_object_toggle_modes(C, obedit->restore_mode); + } } @@ -472,7 +475,7 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op) if(!CTX_data_edit_object(C)) ED_object_enter_editmode(C, EM_WAITCURSOR); else - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); + ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); return OPERATOR_FINISHED; } @@ -512,7 +515,7 @@ static int posemode_exec(bContext *C, wmOperator *op) if(base->object->type==OB_ARMATURE) { if(base->object==CTX_data_edit_object(C)) { - ED_object_exit_editmode(C, EM_FREEDATA); + ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO); ED_armature_enter_posemode(C, base); } else if(base->object->mode & OB_MODE_POSE) @@ -549,7 +552,7 @@ void check_editmode(int type) if (obedit==NULL || obedit->type==type) return; -// XXX ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */ +// XXX ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); /* freedata, and undo */ } #if 0 @@ -839,6 +842,7 @@ void special_editmenu(Scene *scene, View3D *v3d) BooleanModifierData *bmd = NULL; bmd = (BooleanModifierData *)modifier_new(eModifierType_Boolean); BLI_addtail(&ob->modifiers, bmd); + modifier_unique_name(&ob->modifiers, (ModifierData*)bmd); bmd->object = base_select->object; bmd->modifier.mode |= eModifierMode_Realtime; switch(nr){ @@ -969,9 +973,10 @@ static void object_flip_subdivison_particles(Scene *scene, Object *ob, int *set, } else if(depth == 0 && *set != 0) { SubsurfModifierData *smd = (SubsurfModifierData*) modifier_new(eModifierType_Subsurf); - + BLI_addtail(&ob->modifiers, smd); - + modifier_unique_name(&ob->modifiers, (ModifierData*)smd); + if (level!=-1) { smd->levels = level; } @@ -1188,6 +1193,7 @@ static void copymenu_modifiers(Scene *scene, View3D *v3d, Object *ob) nmd = modifier_new(md->type); modifier_copyData(md, nmd); BLI_addtail(&base->object->modifiers, nmd); + modifier_unique_name(&base->object->modifiers, nmd); } copy_object_particlesystems(base->object, ob); @@ -1211,6 +1217,7 @@ static void copymenu_modifiers(Scene *scene, View3D *v3d, Object *ob) mdn = modifier_new(event); BLI_addtail(&base->object->modifiers, mdn); + modifier_unique_name(&base->object->modifiers, mdn); modifier_copyData(md, mdn); } @@ -1242,7 +1249,7 @@ static void copymenu_modifiers(Scene *scene, View3D *v3d, Object *ob) static void copy_texture_space(Object *to, Object *ob) { float *poin1= NULL, *poin2= NULL; - int texflag= 0; + short texflag= 0; if(ob->type==OB_MESH) { texflag= ((Mesh *)ob->data)->texflag; diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index c83f3022c7c..198838d6f05 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -275,18 +275,14 @@ static EnumPropertyItem group_items[]= { static EnumPropertyItem *group_itemf(bContext *C, PointerRNA *ptr, int *free) { + Main *bmain= CTX_data_main(C); + Group *group; 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); @@ -298,7 +294,6 @@ static EnumPropertyItem *group_itemf(bContext *C, PointerRNA *ptr, int *free) } RNA_enum_item_end(&item, &totitem); - *free= 1; return item; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index ab7bcbc989d..4643b875872 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -480,6 +480,7 @@ void add_hook(Scene *scene, View3D *v3d, int mode) hmd = (HookModifierData*) modifier_new(eModifierType_Hook); BLI_insertlinkbefore(&obedit->modifiers, md, hmd); sprintf(hmd->modifier.name, "Hook-%s", ob->id.name+2); + modifier_unique_name(&obedit->modifiers, (ModifierData*)hmd); } else if (hmd->indexar) MEM_freeN(hmd->indexar); /* reassign, hook was set */ diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 315b6632051..dc7ae1490fd 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -83,13 +83,14 @@ void OBJECT_OT_select_name(struct wmOperatorType *ot); /* object_add.c */ void OBJECT_OT_add(struct wmOperatorType *ot); -void OBJECT_OT_mesh_add(struct wmOperatorType *ot); void OBJECT_OT_curve_add(struct wmOperatorType *ot); void OBJECT_OT_surface_add(struct wmOperatorType *ot); void OBJECT_OT_metaball_add(struct wmOperatorType *ot); void OBJECT_OT_text_add(struct wmOperatorType *ot); void OBJECT_OT_armature_add(struct wmOperatorType *ot); -void OBJECT_OT_primitive_add(struct wmOperatorType *ot); /* only used as menu */ +void OBJECT_OT_lamp_add(struct wmOperatorType *ot); +void OBJECT_OT_effector_add(struct wmOperatorType *ot); +void OBJECT_OT_group_instance_add(struct wmOperatorType *ot); void OBJECT_OT_duplicates_make_real(struct wmOperatorType *ot); void OBJECT_OT_duplicate(struct wmOperatorType *ot); @@ -174,5 +175,9 @@ void OBJECT_OT_game_property_remove(struct wmOperatorType *ot); void OBJECT_OT_shape_key_add(struct wmOperatorType *ot); void OBJECT_OT_shape_key_remove(struct wmOperatorType *ot); +/* object_group.c */ +void OBJECT_OT_group_add(struct wmOperatorType *ot); +void OBJECT_OT_group_remove(struct wmOperatorType *ot); + #endif /* ED_OBJECT_INTERN_H */ diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index bd8171e8593..b49c1eb5902 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -292,6 +292,7 @@ static BPoint *findnearestLattvert(ViewContext *vc, short mval[2], int sel) data.mval[0]= mval[0]; data.mval[1]= mval[1]; + ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); lattice_foreachScreenVert(vc, findnearestLattvert__doClosest, &data); return data.bp; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index cc8cc420bf7..f58e8cfeb9d 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -76,7 +76,7 @@ int ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, int type) { - ModifierData *md; + ModifierData *md=NULL, *new_md=NULL; ModifierTypeInfo *mti = modifierType_getInfo(type); if(mti->flags&eModifierTypeFlag_Single) { @@ -87,19 +87,28 @@ int ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, int ty } if(type == eModifierType_ParticleSystem) { + /* don't need to worry about the new modifier's name, since that is set to the number + * of particle systems which shouldn't have too many duplicates + */ object_add_particle_system(scene, ob); } else { + /* get new modifier data to add */ + new_md= modifier_new(type); + if(mti->flags&eModifierTypeFlag_RequiresOriginalData) { md = ob->modifiers.first; - + while(md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) md = md->next; - - BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(type)); + + BLI_insertlinkbefore(&ob->modifiers, md, new_md); } else - BLI_addtail(&ob->modifiers, modifier_new(type)); + BLI_addtail(&ob->modifiers, new_md); + + /* make sure modifier data has unique name */ + modifier_unique_name(&ob->modifiers, new_md); /* special cases */ if(type == eModifierType_Softbody) { @@ -110,8 +119,8 @@ int ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, int ty } else if(type == eModifierType_Collision) { if(!ob->pd) - ob->pd= object_add_collision_fields(); - + ob->pd= object_add_collision_fields(0); + ob->pd->deflect= 1; DAG_scene_sort(scene); } @@ -159,8 +168,8 @@ int ED_object_modifier_remove(ReportList *reports, Scene *scene, Object *ob, Mod DAG_scene_sort(scene); } else if(md->type == eModifierType_Surface) { - if(ob->pd) - ob->pd->flag &= ~PFIELD_SURFACE; + if(ob->pd && ob->pd->shape == PFIELD_SHAPE_SURFACE) + ob->pd->shape = PFIELD_SHAPE_PLANE; DAG_scene_sort(scene); } @@ -400,6 +409,7 @@ int ED_object_modifier_copy(ReportList *reports, Object *ob, ModifierData *md) nmd = modifier_new(md->type); modifier_copyData(md, nmd); BLI_insertlink(&ob->modifiers, md, nmd); + modifier_unique_name(&ob->modifiers, nmd); return 1; } @@ -430,12 +440,12 @@ static int modifier_add_exec(bContext *C, wmOperator *op) static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *ptr, int *free) { + Object *ob= CTX_data_active_object(C); EnumPropertyItem *item= NULL, *md_item; ModifierTypeInfo *mti; - Object *ob; int totitem= 0, a; - if(!C || !(ob= CTX_data_active_object(C))) /* needed for docs */ + if(!ob) return modifier_type_items; for(a=0; modifier_type_items[a].identifier; a++) { @@ -456,7 +466,6 @@ static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *ptr, int *f } RNA_enum_item_end(&item, &totitem); - *free= 1; return item; diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index dce09d47b2c..5c53e041f6e 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -63,8 +63,6 @@ void ED_operatortypes_object(void) { - wmOperatorType *ot; - WM_operatortype_append(OBJECT_OT_location_clear); WM_operatortype_append(OBJECT_OT_rotation_clear); WM_operatortype_append(OBJECT_OT_scale_clear); @@ -110,14 +108,14 @@ void ED_operatortypes_object(void) WM_operatortype_append(GROUP_OT_objects_remove_active); WM_operatortype_append(OBJECT_OT_delete); - WM_operatortype_append(OBJECT_OT_mesh_add); WM_operatortype_append(OBJECT_OT_curve_add); WM_operatortype_append(OBJECT_OT_text_add); WM_operatortype_append(OBJECT_OT_surface_add); WM_operatortype_append(OBJECT_OT_armature_add); + WM_operatortype_append(OBJECT_OT_lamp_add); WM_operatortype_append(OBJECT_OT_add); - WM_operatortype_append(OBJECT_OT_primitive_add); - WM_operatortype_append(OBJECT_OT_mesh_add); + WM_operatortype_append(OBJECT_OT_effector_add); + WM_operatortype_append(OBJECT_OT_group_instance_add); WM_operatortype_append(OBJECT_OT_metaball_add); WM_operatortype_append(OBJECT_OT_duplicates_make_real); WM_operatortype_append(OBJECT_OT_duplicate); @@ -175,8 +173,15 @@ void ED_operatortypes_object(void) WM_operatortype_append(LATTICE_OT_select_all_toggle); WM_operatortype_append(LATTICE_OT_make_regular); + + WM_operatortype_append(OBJECT_OT_group_add); + WM_operatortype_append(OBJECT_OT_group_remove); +} + +void ED_operatormacros_object(void) +{ + wmOperatorType *ot; - /* macros */ ot= WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); if(ot) { WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); @@ -184,10 +189,18 @@ void ED_operatortypes_object(void) } } -void ED_keymap_object(wmWindowManager *wm) +static int object_mode_poll(bContext *C) { - ListBase *keymap= WM_keymap_listbase(wm, "Object Non-modal", 0, 0); - wmKeymapItem *kmi; + Object *ob= CTX_data_active_object(C); + return (!ob || ob->mode == OB_MODE_OBJECT); +} + +void ED_keymap_object(wmKeyConfig *keyconf) +{ + wmKeyMap *keymap; + wmKeyMapItem *kmi; + + keymap= WM_keymap_find(keyconf, "Object Non-modal", 0, 0); /* Note: this keymap works disregarding mode */ WM_keymap_add_item(keymap, "OBJECT_OT_editmode_toggle", TABKEY, KM_PRESS, 0, 0); @@ -203,7 +216,8 @@ void ED_keymap_object(wmWindowManager *wm) WM_keymap_add_item(keymap, "OBJECT_OT_center_set", CKEY, KM_PRESS, KM_ALT|KM_SHIFT|KM_CTRL, 0); /* Note: this keymap gets disabled in non-objectmode, */ - keymap= WM_keymap_listbase(wm, "Object Mode", 0, 0); + keymap= WM_keymap_find(keyconf, "Object Mode", 0, 0); + keymap->poll= object_mode_poll; 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); @@ -227,13 +241,21 @@ void ED_keymap_object(wmWindowManager *wm) WM_keymap_add_item(keymap, "OBJECT_OT_restrictview_clear", HKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_restrictview_set", HKEY, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_restrictview_set", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1); + + WM_keymap_add_item(keymap, "OBJECT_OT_move_to_layer", MKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OBJECT_OT_delete", DELKEY, KM_PRESS, 0, 0); - WM_keymap_verify_item(keymap, "OBJECT_OT_primitive_add", AKEY, KM_PRESS, KM_SHIFT, 0); + kmi= WM_keymap_add_item(keymap, "WM_OT_call_menu", AKEY, KM_PRESS, KM_SHIFT, 0); + RNA_string_set(kmi->ptr, "name", "INFO_MT_add"); + + kmi= WM_keymap_add_item(keymap, "WM_OT_call_menu", AKEY, KM_PRESS, KM_CTRL, 0); + RNA_string_set(kmi->ptr, "name", "VIEW3D_MT_object_apply"); + WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_duplicate", DKEY, KM_PRESS, KM_ALT, 0)->ptr, "linked", 1); WM_keymap_add_item(keymap, "OBJECT_OT_join", JKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "OBJECT_OT_convert", CKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_proxy_make", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); // XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith @@ -246,8 +268,32 @@ void ED_keymap_object(wmWindowManager *wm) WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0); /* Lattice */ - keymap= WM_keymap_listbase(wm, "Lattice", 0, 0); + keymap= WM_keymap_find(keyconf, "Lattice", 0, 0); + keymap->poll= ED_operator_editlattice; WM_keymap_add_item(keymap, "LATTICE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); } +void ED_object_generic_keymap(struct wmKeyConfig *keyconf, struct wmKeyMap *keymap, int do_pet) +{ + wmKeyMapItem *km; + + /* used by mesh, curve & lattice only */ + if(do_pet) { + /* context ops */ + km = WM_keymap_add_item(keymap, "WM_OT_context_cycle_enum", OKEY, KM_PRESS, KM_SHIFT, 0); + RNA_string_set(km->ptr, "path", "scene.tool_settings.proportional_editing_falloff"); + + km = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, 0, 0); + RNA_string_set(km->ptr, "path", "scene.tool_settings.proportional_editing"); + RNA_string_set(km->ptr, "value_1", "DISABLED"); + RNA_string_set(km->ptr, "value_2", "ENABLED"); + + km = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, KM_ALT, 0); + RNA_string_set(km->ptr, "path", "scene.tool_settings.proportional_editing"); + RNA_string_set(km->ptr, "value_1", "DISABLED"); + RNA_string_set(km->ptr, "value_2", "CONNECTED"); + } + +} + diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 12cb2b95e06..0c97b945037 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -566,8 +566,9 @@ static int parent_set_exec(bContext *C, wmOperator *op) } else cu->flag |= CU_FOLLOW; - /* fall back on regular parenting now */ - partype= PAR_OBJECT; + /* fall back on regular parenting now (for follow only) */ + if(partype == PAR_FOLLOW) + partype= PAR_OBJECT; } } else if(partype==PAR_BONE) { @@ -593,7 +594,9 @@ static int parent_set_exec(bContext *C, wmOperator *op) /* apply transformation of previous parenting */ ED_object_apply_obmat(ob); - ob->parent= par; + /* set the parent (except for follow-path constraint option) */ + if(partype != PAR_PATH_CONST) + ob->parent= par; /* handle types */ if (pchan) @@ -602,7 +605,7 @@ static int parent_set_exec(bContext *C, wmOperator *op) ob->parsubstr[0]= 0; /* constraint */ - if(partype==PAR_PATH_CONST) { + if(partype == PAR_PATH_CONST) { bConstraint *con; bFollowPathConstraint *data; float cmat[4][4], vec[3]; @@ -615,11 +618,12 @@ static int parent_set_exec(bContext *C, wmOperator *op) add_constraint_to_object(con, ob); - get_constraint_target_matrix(con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra - give_timeoffset(ob)); + get_constraint_target_matrix(scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra - give_timeoffset(ob)); VecSubf(vec, ob->obmat[3], cmat[3]); ob->loc[0] = vec[0]; ob->loc[1] = vec[1]; + ob->loc[2] = vec[2]; } else if(pararm && ob->type==OB_MESH && par->type == OB_ARMATURE) { if(partype == PAR_ARMATURE_NAME) @@ -645,8 +649,12 @@ static int parent_set_exec(bContext *C, wmOperator *op) ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA; + if(partype == PAR_PATH_CONST) + ; /* don't do anything here, since this is not technically "parenting" */ if( ELEM(partype, PAR_CURVE, PAR_LATTICE) || pararm ) ob->partype= PARSKEL; /* note, dna define, not operator property */ + else if (partype == PAR_BONE) + ob->partype= PARBONE; /* note, dna define, not operator property */ else ob->partype= PAROBJECT; /* note, dna define, not operator property */ } @@ -970,8 +978,14 @@ static unsigned int move_to_layer_init(bContext *C, wmOperator *op) static int move_to_layer_invoke(bContext *C, wmOperator *op, wmEvent *event) { - move_to_layer_init(C, op); - return WM_operator_props_popup(C, op, event); + View3D *v3d= CTX_wm_view3d(C); + if(v3d && v3d->localvd) { + return WM_operator_confirm_message(C, op, "Move from localview"); + } + else { + move_to_layer_init(C, op); + return WM_operator_props_popup(C, op, event); + } } static int move_to_layer_exec(bContext *C, wmOperator *op) @@ -986,7 +1000,7 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) if(lay==0) return OPERATOR_CANCELLED; - if(v3d && v3d->localview) { + if(v3d && v3d->localvd) { /* now we can move out of localview. */ // XXX if (!okee("Move from localview")) return; CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { @@ -1015,7 +1029,7 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) /* warning, active object may be hidden now */ - WM_event_add_notifier(C, NC_SCENE, scene); + WM_event_add_notifier(C, NC_SCENE|NC_OBJECT|ND_DRAW, scene); /* is NC_SCENE needed ? */ DAG_scene_sort(scene); return OPERATOR_FINISHED; diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 432aaf2d2cb..90d1a9df93e 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -30,6 +30,8 @@ #include <stdlib.h> #include <string.h> +#include "MEM_guardedalloc.h" + #include "DNA_group_types.h" #include "DNA_material_types.h" #include "DNA_modifier_types.h" @@ -80,7 +82,7 @@ void ED_base_object_select(Base *base, short mode) if (base) { if (mode==BA_SELECT) { if (!(base->object->restrictflag & OB_RESTRICT_SELECT)) - if (mode==BA_SELECT) base->flag |= SELECT; + base->flag |= SELECT; } else if (mode==BA_DESELECT) { base->flag &= ~SELECT; @@ -103,13 +105,6 @@ void ED_base_object_activate(bContext *C, Base *base) /* XXX old signals, remember to handle notifiers now! */ // select_actionchannel_by_name(base->object->action, "Object", 1); - /* disable temporal locks */ - for(tbase=FIRSTBASE; tbase; tbase= tbase->next) { - if(base!=tbase && (tbase->object->shapeflag & OB_SHAPE_TEMPLOCK)) { - tbase->object->shapeflag &= ~OB_SHAPE_TEMPLOCK; - DAG_id_flush_update(&tbase->object->id, OB_RECALC_DATA); - } - } WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); } else @@ -169,7 +164,7 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot) /*********************** Selection by Links *********************/ static EnumPropertyItem prop_select_linked_types[] = { - {1, "IPO", 0, "Object IPO", ""}, // XXX depreceated animation system stuff... + //{1, "IPO", 0, "Object IPO", ""}, // XXX depreceated animation system stuff... {2, "OBDATA", 0, "Ob Data", ""}, {3, "MATERIAL", 0, "Material", ""}, {4, "TEXTURE", 0, "Texture", ""}, diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 2b207f2f27c..898d541d09d 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -27,6 +27,7 @@ #include <stdlib.h> +#include "DNA_action_types.h" #include "DNA_armature_types.h" #include "DNA_curve_types.h" #include "DNA_key_types.h" @@ -115,13 +116,96 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { if(!(ob->mode & OB_MODE_WEIGHT_PAINT)) { - /* eulers can only get cleared if they are not protected */ - if((ob->protectflag & OB_LOCK_ROTX)==0) - ob->rot[0]= ob->drot[0]= 0.0f; - if((ob->protectflag & OB_LOCK_ROTY)==0) - ob->rot[1]= ob->drot[1]= 0.0f; - if((ob->protectflag & OB_LOCK_ROTZ)==0) - ob->rot[2]= ob->drot[2]= 0.0f; + if (ob->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ|OB_LOCK_ROTW)) { + if (ob->protectflag & OB_LOCK_ROT4D) { + /* perform clamping on a component by component basis */ + if (ob->rotmode == ROT_MODE_AXISANGLE) { + if ((ob->protectflag & OB_LOCK_ROTW) == 0) + ob->rotAngle= 0.0f; + if ((ob->protectflag & OB_LOCK_ROTX) == 0) + ob->rotAxis[0]= 0.0f; + if ((ob->protectflag & OB_LOCK_ROTY) == 0) + ob->rotAxis[1]= 0.0f; + if ((ob->protectflag & OB_LOCK_ROTZ) == 0) + ob->rotAxis[2]= 0.0f; + + /* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */ + if (IS_EQ(ob->rotAxis[0], ob->rotAxis[1]) && IS_EQ(ob->rotAxis[1], ob->rotAxis[2])) + ob->rotAxis[1] = 1.0f; + } + else if (ob->rotmode == ROT_MODE_QUAT) { + if ((ob->protectflag & OB_LOCK_ROTW) == 0) + ob->quat[0]= 1.0f; + if ((ob->protectflag & OB_LOCK_ROTX) == 0) + ob->quat[1]= 0.0f; + if ((ob->protectflag & OB_LOCK_ROTY) == 0) + ob->quat[2]= 0.0f; + if ((ob->protectflag & OB_LOCK_ROTZ) == 0) + ob->quat[3]= 0.0f; + } + else { + /* the flag may have been set for the other modes, so just ignore the extra flag... */ + if ((ob->protectflag & OB_LOCK_ROTX) == 0) + ob->rot[0]= 0.0f; + if ((ob->protectflag & OB_LOCK_ROTY) == 0) + ob->rot[1]= 0.0f; + if ((ob->protectflag & OB_LOCK_ROTZ) == 0) + ob->rot[2]= 0.0f; + } + } + else { + /* perform clamping using euler form (3-components) */ + float eul[3], oldeul[3], quat1[4]; + + if (ob->rotmode == ROT_MODE_QUAT) { + QUATCOPY(quat1, ob->quat); + QuatToEul(ob->quat, oldeul); + } + else if (ob->rotmode == ROT_MODE_AXISANGLE) { + AxisAngleToEulO(ob->rotAxis, ob->rotAngle, oldeul, EULER_ORDER_DEFAULT); + } + else { + VECCOPY(oldeul, ob->rot); + } + + eul[0]= eul[1]= eul[2]= 0.0f; + + if (ob->protectflag & OB_LOCK_ROTX) + eul[0]= oldeul[0]; + if (ob->protectflag & OB_LOCK_ROTY) + eul[1]= oldeul[1]; + if (ob->protectflag & OB_LOCK_ROTZ) + eul[2]= oldeul[2]; + + if (ob->rotmode == ROT_MODE_QUAT) { + EulToQuat(eul, ob->quat); + /* quaternions flip w sign to accumulate rotations correctly */ + if ((quat1[0]<0.0f && ob->quat[0]>0.0f) || (quat1[0]>0.0f && ob->quat[0]<0.0f)) { + QuatMulf(ob->quat, -1.0f); + } + } + else if (ob->rotmode == ROT_MODE_AXISANGLE) { + EulOToAxisAngle(eul, EULER_ORDER_DEFAULT, ob->rotAxis, &ob->rotAngle); + } + else { + VECCOPY(ob->rot, eul); + } + } + } + else { + if (ob->rotmode == ROT_MODE_QUAT) { + ob->quat[1]=ob->quat[2]=ob->quat[3]= 0.0f; + ob->quat[0]= 1.0f; + } + else if (ob->rotmode == ROT_MODE_AXISANGLE) { + /* by default, make rotation of 0 radians around y-axis (roll) */ + ob->rotAxis[0]=ob->rotAxis[2]=ob->rotAngle= 0.0f; + ob->rotAxis[1]= 1.0f; + } + else { + ob->rot[0]= ob->rot[1]= ob->rot[2]= 0.0f; + } + } } ob->recalc |= OB_RECALC_OB; } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index e8b683810c6..94a5ad6fa9f 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -407,20 +407,23 @@ static float get_vert_def_nr(Object *ob, int def_nr, int vertnum) eve= BMIter_AtIndex(me->edit_btmesh->bm, BM_VERTS_OF_MESH, NULL, vertnum); if(!eve) return 0.0f; dvert= CustomData_bmesh_get(&me->edit_btmesh->bm->vdata, eve->head.data, CD_MDEFORMVERT); + vertnum= 0; } else - dvert = me->dvert + vertnum; + dvert = me->dvert; } else if(ob->type==OB_LATTICE) { Lattice *lt= vgroup_edit_lattice(ob); if(lt->dvert) - dvert = lt->dvert + vertnum; + dvert = lt->dvert; } if(dvert==NULL) return 0.0f; + dvert += vertnum; + for(i=dvert->totweight-1 ; i>=0 ; i--) if(dvert->dw[i].def_nr == def_nr) return dvert->dw[i].weight; @@ -1228,13 +1231,13 @@ static int set_active_group_exec(bContext *C, wmOperator *op) static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *ptr, int *free) { - Object *ob; + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; EnumPropertyItem tmp = {0, "", 0, "", ""}; EnumPropertyItem *item= NULL; bDeformGroup *def; int a, totitem= 0; - if(!C || !(ob = CTX_data_pointer_get_type(C, "object", &RNA_Object).data)) /* needed for docs */ + if(!ob) return vgroup_items; for(a=0, def=ob->defbase.first; def; def=def->next, a++) { @@ -1245,7 +1248,6 @@ static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *ptr, int *free) } RNA_enum_item_end(&item, &totitem); - *free= 1; return item; |