diff options
author | Nick Samarin <nicks1987@bigmir.net> | 2011-02-16 20:07:18 +0300 |
---|---|---|
committer | Nick Samarin <nicks1987@bigmir.net> | 2011-02-16 20:07:18 +0300 |
commit | c5f6a01dd5998976addd2085470bb73a150579e5 (patch) | |
tree | 42b3345fb3ea2e7607a6d1eec379b8ce23b5ffbc /source/blender/editors/object | |
parent | 4cf62f1e7e2bb28b47f79e4bd7c1482ab742ebbd (diff) | |
parent | 9e9e028f059f29d493dc020dda965a9bea8ffd6b (diff) |
synched with trunk at revision 34793
Diffstat (limited to 'source/blender/editors/object')
19 files changed, 1090 insertions, 969 deletions
diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index b16b50f10ba..5efe5af0842 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -19,9 +19,7 @@ # # ***** END GPL LICENSE BLOCK ***** -FILE(GLOB SRC *.c *.cpp) - -SET(INC +set(INC ../include ../../blenkernel ../../blenlib @@ -37,12 +35,28 @@ SET(INC ../../../../extern/recastnavigation/Recast/Include ) -IF(NOT WITH_PYTHON) - ADD_DEFINITIONS(-DDISABLE_PYTHON) -ENDIF(NOT WITH_PYTHON) +set(SRC + object_add.c + object_bake.c + object_constraint.c + object_edit.c + object_group.c + object_hook.c + object_lattice.c + object_modifier.c + object_navmesh.cpp + object_ops.c + object_relations.c + object_select.c + object_shapekey.c + object_transform.c + object_vgroup.c + + object_intern.h +) -IF(WIN32) - LIST(APPEND INC ${PTHREADS_INC}) -ENDIF(WIN32) +if(WITH_PYTHON) + add_definitions(-DWITH_PYTHON) +endif() -BLENDERLIB(bf_editor_object "${SRC}" "${INC}") +blender_add_lib(bf_editor_object "${SRC}" "${INC}") diff --git a/source/blender/editors/object/Makefile b/source/blender/editors/object/Makefile deleted file mode 100644 index 4694653b115..00000000000 --- a/source/blender/editors/object/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -# -# $Id$ -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2007 Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): none yet. -# -# ***** END GPL LICENSE BLOCK ***** -# -# Makes module object directory and bounces make to subdirectories. - -LIBNAME = ed_object -DIR = $(OCGDIR)/blender/$(LIBNAME) - -include nan_compile.mk - -CFLAGS += $(LEVEL_1_C_WARNINGS) - -CPPFLAGS += -I$(OPENGL_HEADERS) - -CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include - -CPPFLAGS += -I../../windowmanager -CPPFLAGS += -I../../blenkernel -CPPFLAGS += -I../../blenloader -CPPFLAGS += -I../../blenlib -CPPFLAGS += -I../../makesdna -CPPFLAGS += -I../../makesrna -CPPFLAGS += -I../../python -CPPFLAGS += -I../../imbuf -CPPFLAGS += -I../../ikplugin -CPPFLAGS += -I../../gpu -CPPFLAGS += -I../../render/extern/include - -# own include - -CPPFLAGS += -I../include diff --git a/source/blender/editors/object/SConscript b/source/blender/editors/object/SConscript index d4e6cec6986..0b4d82ee5d3 100644 --- a/source/blender/editors/object/SConscript +++ b/source/blender/editors/object/SConscript @@ -18,7 +18,7 @@ if env['OURPLATFORM'] == 'linux2': if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): incs += ' ' + env['BF_PTHREADS_INC'] -if not env['WITH_BF_PYTHON']: - defs.append('DISABLE_PYTHON') +if env['WITH_BF_PYTHON']: + defs.append('WITH_PYTHON') env.BlenderLib ( 'bf_editors_object', sources, Split(incs), defs, libtype=['core'], priority=[35] ) diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 40b7df72f1c..08a31923cda 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -43,8 +43,10 @@ #include "BLI_math.h" #include "BLI_listbase.h" +#include "BLI_utildefines.h" #include "BKE_anim.h" +#include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_constraint.h" #include "BKE_context.h" @@ -104,15 +106,16 @@ void ED_object_location_from_view(bContext *C, float *loc) void ED_object_rotation_from_view(bContext *C, float *rot) { - RegionView3D *rv3d= ED_view3d_context_rv3d(C); - + RegionView3D *rv3d= CTX_wm_region_view3d(C); if(rv3d) { - rv3d->viewquat[0]= -rv3d->viewquat[0]; - quat_to_eul( rot, rv3d->viewquat); - rv3d->viewquat[0]= -rv3d->viewquat[0]; + float quat[4]; + copy_qt_qt(quat, rv3d->viewquat); + quat[0]= -quat[0]; + quat_to_eul(rot, quat); + } + else { + zero_v3(rot); } - else - rot[0] = rot[1] = rot[2] = 0.f; } void ED_object_base_init_transform(bContext *C, Base *base, float *loc, float *rot) @@ -161,11 +164,6 @@ float ED_object_new_primitive_matrix(bContext *C, Object *obedit, float *loc, fl /********************* Add Object Operator ********************/ -void add_object_draw(Scene *scene, View3D *v3d, int type) /* for toolbox or menus, only non-editmode stuff */ -{ - /* keep here to get things compile, remove later */ -} - void ED_object_add_generic_props(wmOperatorType *ot, int do_editmode) { PropertyRNA *prop; @@ -218,7 +216,7 @@ static void object_add_generic_invoke_options(bContext *C, wmOperator *op) } } -int ED_object_add_generic_invoke(bContext *C, wmOperator *op, wmEvent *event) +int ED_object_add_generic_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { object_add_generic_invoke_options(C, op); return op->type->exec(C, op); @@ -260,9 +258,11 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, floa view_align = FALSE; else if (RNA_property_is_set(op->ptr, "view_align")) view_align = RNA_boolean_get(op->ptr, "view_align"); - else + else { view_align = U.flag & USER_ADD_VIEWALIGNED; - + RNA_boolean_set(op->ptr, "view_align", view_align); + } + if (view_align) ED_object_rotation_from_view(C, rot); else @@ -280,6 +280,7 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, floa } /* for object add primitive operators */ +/* do not call undo push in this function (users of this function have to) */ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, int enter_editmode, unsigned int layer) { Main *bmain= CTX_data_main(C); @@ -336,7 +337,7 @@ void OBJECT_OT_add(wmOperatorType *ot) ot->invoke= ED_object_add_generic_invoke; ot->exec= object_add_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -363,11 +364,6 @@ static EnumPropertyItem field_type_items[] = { {PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", ""}, {0, NULL, 0, NULL, NULL}}; -void add_effector_draw(Scene *scene, View3D *v3d, int type) /* for toolbox or menus, only non-editmode stuff */ -{ - /* keep here to get things compile, remove later */ -} - /* for effector add primitive operators */ static Object *effector_add_type(bContext *C, wmOperator *op, int type) { @@ -408,6 +404,8 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type) ob->pd= object_add_collision_fields(type); + DAG_scene_sort(CTX_data_main(C), CTX_data_scene(C)); + return ob; } @@ -431,7 +429,7 @@ void OBJECT_OT_effector_add(wmOperatorType *ot) ot->invoke= WM_menu_invoke; ot->exec= effector_add_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -482,7 +480,7 @@ void OBJECT_OT_camera_add(wmOperatorType *ot) /* api callbacks */ ot->exec= object_camera_add_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -492,20 +490,10 @@ void OBJECT_OT_camera_add(wmOperatorType *ot) /* ***************** add primitives *************** */ - -static EnumPropertyItem prop_metaball_types[]= { - {MB_BALL, "MBALL_BALL", ICON_META_BALL, "Meta Ball", ""}, - {MB_TUBE, "MBALL_CAPSULE", ICON_META_CAPSULE, "Meta Capsule", ""}, - {MB_PLANE, "MBALL_PLANE", ICON_META_PLANE, "Meta Plane", ""}, - {MB_CUBE, "MBALL_CUBE", ICON_META_CUBE, "Meta Cube", ""}, - {MB_ELIPSOID, "MBALL_ELLIPSOID", ICON_META_ELLIPSOID, "Meta Ellipsoid", ""}, - {0, NULL, 0, NULL, NULL} -}; - static int object_metaball_add_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); - MetaElem *elem; + /*MetaElem *elem;*/ /*UNUSED*/ int newob= 0; int enter_editmode; unsigned int layer; @@ -521,11 +509,11 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) obedit= ED_object_add_type(C, OB_MBALL, loc, rot, TRUE, layer); newob = 1; } - else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); + else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); ED_object_new_primitive_matrix(C, obedit, loc, rot, mat); - elem= (MetaElem*)add_metaball_primitive(C, mat, RNA_enum_get(op->ptr, "type"), newob); + /* elem= (MetaElem *) */ add_metaball_primitive(C, mat, RNA_enum_get(op->ptr, "type"), newob); /* userdef */ if (newob && !enter_editmode) { @@ -537,7 +525,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int object_metaball_add_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int object_metaball_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { Object *obedit= CTX_data_edit_object(C); uiPopupMenu *pup; @@ -545,7 +533,7 @@ static int object_metaball_add_invoke(bContext *C, wmOperator *op, wmEvent *even object_add_generic_invoke_options(C, op); - pup= uiPupMenuBegin(C, op->type->name, 0); + pup= uiPupMenuBegin(C, op->type->name, ICON_NULL); layout= uiPupMenuLayout(pup); if(!obedit || obedit->type == OB_MBALL) uiItemsEnumO(layout, op->type->idname, "type"); @@ -571,7 +559,7 @@ void OBJECT_OT_metaball_add(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_enum(ot->srna, "type", prop_metaball_types, 0, "Primitive", ""); + RNA_def_enum(ot->srna, "type", metaelem_type_items, 0, "Primitive", ""); ED_object_add_generic_props(ot, TRUE); } @@ -606,7 +594,7 @@ void OBJECT_OT_text_add(wmOperatorType *ot) /* api callbacks */ ot->invoke= ED_object_add_generic_invoke; ot->exec= object_add_text_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -617,7 +605,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); View3D *v3d= CTX_wm_view3d(C); - RegionView3D *rv3d= NULL; + RegionView3D *rv3d= CTX_wm_region_view3d(C); int newob= 0; int enter_editmode; unsigned int layer; @@ -632,16 +620,13 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) ED_object_enter_editmode(C, 0); newob = 1; } - else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); + else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); if(obedit==NULL) { BKE_report(op->reports, RPT_ERROR, "Cannot create editmode armature."); return OPERATOR_CANCELLED; } - if(v3d) - rv3d= CTX_wm_region(C)->regiondata; - /* v3d and rv3d are allowed to be NULL */ add_primitive_bone(CTX_data_scene(C), v3d, rv3d); @@ -664,14 +649,14 @@ void OBJECT_OT_armature_add(wmOperatorType *ot) /* api callbacks */ ot->invoke= ED_object_add_generic_invoke; ot->exec= object_armature_add_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } -static char *get_lamp_defname(int type) +static const char *get_lamp_defname(int type) { switch (type) { case LA_LOCAL: return "Point"; @@ -697,9 +682,7 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; ob= ED_object_add_type(C, OB_LAMP, loc, rot, FALSE, layer); - if(ob && ob->data) - ((Lamp*)ob->data)->type= type; - + ((Lamp*)ob->data)->type= type; rename_id((ID *)ob, get_lamp_defname(type)); rename_id((ID *)ob->data, get_lamp_defname(type)); @@ -724,7 +707,7 @@ void OBJECT_OT_lamp_add(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_menu_invoke; ot->exec= object_lamp_add_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -781,7 +764,7 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot) ot->invoke= WM_enum_search_invoke; ot->exec= group_instance_add_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -805,7 +788,7 @@ void ED_base_object_free_and_unlink(Main *bmain, Scene *scene, Base *base) MEM_freeN(base); } -static int object_delete_exec(bContext *C, wmOperator *op) +static int object_delete_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); @@ -817,6 +800,10 @@ static int object_delete_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_bases) { if(base->object->type==OB_LAMP) islamp= 1; + + /* deselect object -- it could be used in other scenes */ + base->object->flag &= ~SELECT; + /* remove from current scene only */ ED_base_object_free_and_unlink(bmain, scene, base); } @@ -843,7 +830,7 @@ void OBJECT_OT_delete(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_operator_confirm; ot->exec= object_delete_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -851,7 +838,7 @@ void OBJECT_OT_delete(wmOperatorType *ot) /**************************** Copy Utilities ******************************/ -static void copy_object__forwardModifierLinks(void *userData, Object *ob, +static void copy_object__forwardModifierLinks(void *UNUSED(userData), Object *UNUSED(ob), ID **idpoin) { /* this is copied from ID_NEW; it might be better to have a macro */ @@ -991,7 +978,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base) ob->lay= base->lay; copy_m4_m4(ob->obmat, dob->mat); - object_apply_mat4(ob, ob->obmat); + object_apply_mat4(ob, ob->obmat, FALSE, FALSE); } copy_object_set_idnew(C, 0); @@ -1001,7 +988,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base) base->object->transflag &= ~OB_DUPLI; } -static int object_duplicates_make_real_exec(bContext *C, wmOperator *op) +static int object_duplicates_make_real_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); @@ -1010,6 +997,9 @@ static int object_duplicates_make_real_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { make_object_duplilist_real(C, scene, base); + + /* dependencies were changed */ + WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, base->object); } CTX_DATA_END; @@ -1032,7 +1022,7 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot) /* api callbacks */ ot->exec= object_duplicates_make_real_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1047,9 +1037,7 @@ static EnumPropertyItem convert_target_items[]= { static void curvetomesh(Scene *scene, Object *ob) { - Curve *cu= ob->data; - - if(cu->disp.first==0) + if(ob->disp.first==0) makeDispListCurveTypes(scene, ob, 0); /* force creation */ nurbs_to_mesh(ob); /* also does users */ @@ -1077,7 +1065,7 @@ static Base *duplibase_for_convert(Scene *scene, Base *base, Object *ob) } obn= copy_object(ob); - obn->recalc |= OB_RECALC_ALL; + obn->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; basen= MEM_mallocN(sizeof(Base), "duplibase"); *basen= *base; @@ -1102,8 +1090,8 @@ static int convert_exec(bContext *C, wmOperator *op) Nurb *nu; MetaBall *mb; Mesh *me; - int target= RNA_enum_get(op->ptr, "target"); - int keep_original= RNA_boolean_get(op->ptr, "keep_original"); + const short target= RNA_enum_get(op->ptr, "target"); + const short keep_original= RNA_boolean_get(op->ptr, "keep_original"); int a, mballConverted= 0; /* don't forget multiple users! */ @@ -1112,17 +1100,31 @@ static int convert_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; ob->flag &= ~OB_DONE; + + /* flag data thats not been edited (only needed for !keep_original) */ + if(ob->data) { + ((ID *)ob->data)->flag |= LIB_DOIT; + } } CTX_DATA_END; CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; - if(ob->flag & OB_DONE) { + if(ob->flag & OB_DONE || !IS_TAGGED(ob->data)) { if (ob->type != target) { base->flag &= ~SELECT; ob->flag &= ~SELECT; } + + /* obdata already modified */ + if(!IS_TAGGED(ob->data)) { + /* When 2 objects with linked data are selected, converting both + * would keep modifiers on all but the converted object [#26003] */ + if(ob->type == OB_MESH) { + object_free_modifiers(ob); /* after derivedmesh calls! */ + } + } } else if (ob->type==OB_MESH && target == OB_CURVE) { ob->flag |= OB_DONE; @@ -1161,7 +1163,7 @@ static int convert_exec(bContext *C, wmOperator *op) newob->data= copy_mesh(me); } else { newob = ob; - ob->recalc |= OB_RECALC_ALL; + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; } /* make new mesh data from the original copy */ @@ -1194,7 +1196,7 @@ static int convert_exec(bContext *C, wmOperator *op) cu= newob->data; - if (!cu->disp.first) + if (!newob->disp.first) makeDispListCurveTypes(scene, newob, 0); newob->type= OB_CURVE; @@ -1222,7 +1224,7 @@ static int convert_exec(bContext *C, wmOperator *op) for(ob1= bmain->object.first; ob1; ob1=ob1->id.next) { if(ob1->data==ob->data) { ob1->type= OB_CURVE; - ob1->recalc |= OB_RECALC_ALL; + ob1->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; } } } @@ -1231,8 +1233,12 @@ static int convert_exec(bContext *C, wmOperator *op) for(nu=cu->nurb.first; nu; nu=nu->next) nu->charidx= 0; - if(target == OB_MESH) + if(target == OB_MESH) { curvetomesh(scene, newob); + + /* meshes doesn't use displist */ + freedisplist(&newob->disp); + } } else if(ELEM(ob->type, OB_CURVE, OB_SURF)) { ob->flag |= OB_DONE; @@ -1249,19 +1255,17 @@ static int convert_exec(bContext *C, wmOperator *op) newob->data= copy_curve(ob->data); } else { newob= ob; + + /* meshes doesn't use displist */ + freedisplist(&newob->disp); } curvetomesh(scene, newob); } } - else if(ob->type==OB_MBALL) { + else if(ob->type==OB_MBALL && target == OB_MESH) { Object *baseob; - if (target != OB_MESH) { - ob->flag |= OB_DONE; - continue; - } - base->flag &= ~SELECT; ob->flag &= ~SELECT; @@ -1303,11 +1307,12 @@ static int convert_exec(bContext *C, wmOperator *op) mballConverted= 1; } - else - continue; } - else + else { continue; + } + + /* tag obdata if it was been changed */ /* If the original object is active then make this object active */ if(basen) { @@ -1319,8 +1324,9 @@ static int convert_exec(bContext *C, wmOperator *op) basen= NULL; } - if (!keep_original) { - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + if (!keep_original && (ob->flag & OB_DONE)) { + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + ((ID *)ob->data)->flag &= ~LIB_DOIT; /* flag not to convert this datablock again */ } /* delete original if needed */ @@ -1359,11 +1365,13 @@ static int convert_exec(bContext *C, wmOperator *op) ED_base_object_activate(C, basact); BASACT= basact; } else if (BASACT->object->flag & OB_DONE) { - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER|ND_DATA, BASACT->object); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, BASACT->object); + WM_event_add_notifier(C, NC_OBJECT|ND_DATA, BASACT->object); } DAG_scene_sort(bmain, scene); - WM_event_add_notifier(C, NC_SCENE|NC_OBJECT|ND_DRAW, scene); /* is NC_SCENE needed ? */ + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, scene); + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); return OPERATOR_FINISHED; } @@ -1413,7 +1421,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } else { obn= copy_object(ob); - obn->recalc |= OB_RECALC_ALL; + obn->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; basen= MEM_mallocN(sizeof(Base), "duplibase"); *basen= *base; @@ -1449,17 +1457,12 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } } } - if(dupflag & USER_DUP_ACT){ /* Not buttons in the UI to modify this, add later? */ - id= (ID *)obn->action; - if (id){ - ID_NEW_US(obn->action) - else{ - obn->action= copy_action(obn->action); - } - id->us--; - } - } #endif // XXX old animation system + + if(dupflag & USER_DUP_ACT) { + BKE_copy_animdata_id_action(&obn->id); + } + if(dupflag & USER_DUP_MAT) { for(a=0; a<obn->totcol; a++) { id= (ID *)obn->mat[a]; @@ -1467,6 +1470,10 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base ID_NEW_US(obn->mat[a]) else obn->mat[a]= copy_material(obn->mat[a]); id->us--; + + if(dupflag & USER_DUP_ACT) { + BKE_copy_animdata_id_action(&obn->mat[a]->id); + } } } } @@ -1477,6 +1484,11 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if(id) { ID_NEW_US(psys->part) else psys->part= psys_copy_settings(psys->part); + + if(dupflag & USER_DUP_ACT) { + BKE_copy_animdata_id_action(&psys->part->id); + } + id->us--; } } @@ -1544,7 +1556,10 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base case OB_LAMP: if(dupflag & USER_DUP_LAMP) { ID_NEW_US2(obn->data ) - else obn->data= copy_lamp(obn->data); + else { + obn->data= copy_lamp(obn->data); + didit= 1; + } id->us--; } break; @@ -1568,29 +1583,42 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base case OB_LATTICE: if(dupflag!=0) { ID_NEW_US2(obn->data ) - else obn->data= copy_lattice(obn->data); + else { + obn->data= copy_lattice(obn->data); + didit= 1; + } id->us--; } break; case OB_CAMERA: if(dupflag!=0) { ID_NEW_US2(obn->data ) - else obn->data= copy_camera(obn->data); + else { + obn->data= copy_camera(obn->data); + didit= 1; + } id->us--; } break; } - - if(dupflag & USER_DUP_MAT) { - matarar= give_matarar(obn); - if(didit && matarar) { - for(a=0; a<obn->totcol; a++) { - id= (ID *)(*matarar)[a]; - if(id) { - ID_NEW_US( (*matarar)[a] ) - else (*matarar)[a]= copy_material((*matarar)[a]); - - id->us--; + + /* check if obdata is copied */ + if(didit) { + if(dupflag & USER_DUP_ACT) { + BKE_copy_animdata_id_action((ID *)obn->data); + } + + if(dupflag & USER_DUP_MAT) { + matarar= give_matarar(obn); + if(matarar) { + for(a=0; a<obn->totcol; a++) { + id= (ID *)(*matarar)[a]; + if(id) { + ID_NEW_US( (*matarar)[a] ) + else (*matarar)[a]= copy_material((*matarar)[a]); + + id->us--; + } } } } @@ -1647,8 +1675,10 @@ static int duplicate_exec(bContext *C, wmOperator *op) /* new object becomes active */ if(BASACT==base) ED_base_object_activate(C, basen); - - ED_render_id_flush_update(bmain, basen->object->data); + + if(basen->object->data) { + DAG_id_tag_update(basen->object->data, 0); + } } CTX_DATA_END; @@ -1673,7 +1703,7 @@ void OBJECT_OT_duplicate(wmOperatorType *ot) /* api callbacks */ ot->exec= duplicate_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1686,20 +1716,6 @@ void OBJECT_OT_duplicate(wmOperatorType *ot) /* **************** add named object, for dragdrop ************* */ -/* contextual operator dupli */ - -static int add_named_poll(bContext *C) -{ - if(!ED_operator_scene_editable(C)) { - return 0; - } else { - Object *ob= CTX_data_active_object(C); - if(ob && ob->mode != OB_MODE_OBJECT) - return 0; - else - return 1; - } -} static int add_named_exec(bContext *C, wmOperator *op) { @@ -1758,7 +1774,7 @@ void OBJECT_OT_add_named(wmOperatorType *ot) /* api callbacks */ ot->exec= add_named_exec; - ot->poll= add_named_poll; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index f81e73faf73..0b3e116d266 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -42,6 +42,7 @@ #include "BLI_blenlib.h" #include "BLI_threads.h" +#include "BLI_utildefines.h" #include "BKE_blender.h" #include "BKE_context.h" @@ -69,7 +70,7 @@ /* ****************** render BAKING ********************** */ /* threaded break test */ -static int thread_break(void *unused) +static int thread_break(void *UNUSED(arg)) { return G.afbreek; } @@ -235,13 +236,13 @@ static void bake_freejob(void *bkv) BakeRender *bkr= bkv; finish_bake_internal(bkr); - if(bkr->tot==0) BKE_report(bkr->reports, RPT_ERROR, "No valid images found to bake to"); + if(bkr->tot==0) BKE_report(bkr->reports, RPT_ERROR, "No objects or images found to bake to"); MEM_freeN(bkr); G.rendering = 0; } /* catch esc */ -static int objects_bake_render_modal(bContext *C, wmOperator *op, wmEvent *event) +static int objects_bake_render_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { /* no running blender, remove handler and pass through */ if(0==WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) @@ -256,7 +257,7 @@ static int objects_bake_render_modal(bContext *C, wmOperator *op, wmEvent *event return OPERATOR_PASS_THROUGH; } -static int objects_bake_render_invoke(bContext *C, wmOperator *op, wmEvent *_event) +static int objects_bake_render_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(_event)) { Scene *scene= CTX_data_scene(C); @@ -307,9 +308,7 @@ static int bake_image_exec(bContext *C, wmOperator *op) } else { ListBase threads; - BakeRender bkr; - - memset(&bkr, 0, sizeof(bkr)); + BakeRender bkr= {0}; init_bake_internal(&bkr, C); bkr.reports= op->reports; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index f5d87df10a1..f3346bf200c 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -35,6 +35,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" #include "DNA_constraint_types.h" #include "DNA_curve_types.h" @@ -53,7 +54,7 @@ #include "BKE_report.h" #include "BIK_api.h" -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON #include "BPY_extern.h" #endif @@ -65,6 +66,7 @@ #include "RNA_enum_types.h" #include "ED_object.h" +#include "ED_armature.h" #include "ED_screen.h" #include "UI_interface.h" @@ -153,7 +155,7 @@ void validate_pyconstraint_cb (void *arg1, void *arg2) data->text = text; } -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON /* this returns a string for the list of usable pyconstraint script names */ char *buildmenu_pyconstraints (Text *con_text, int *pyconindex) { @@ -194,12 +196,15 @@ char *buildmenu_pyconstraints (Text *con_text, int *pyconindex) return str; } -#endif /* DISABLE_PYTHON */ +#endif /* WITH_PYTHON */ /* this callback gets called when the 'refresh' button of a pyconstraint gets pressed */ void update_pyconstraint_cb (void *arg1, void *arg2) { -#ifndef DISABLE_PYTHON +#ifndef WITH_PYTHON + (void)arg1; /* unused */ + (void)arg2; /* unused */ +#else Object *owner= (Object *)arg1; bConstraint *con= (bConstraint *)arg2; if (owner && con) @@ -208,7 +213,7 @@ void update_pyconstraint_cb (void *arg1, void *arg2) } /* helper function for add_constriant - sets the last target for the active constraint */ -static void set_constraint_nth_target (bConstraint *con, Object *target, char subtarget[], int index) +static void set_constraint_nth_target (bConstraint *con, Object *target, const char subtarget[], int index) { bConstraintTypeInfo *cti= constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; @@ -400,11 +405,26 @@ static void test_constraints (Object *owner, bPoseChannel *pchan) for (ct= targets.first; ct; ct= ct->next) { /* general validity checks (for those constraints that need this) */ if (exist_object(ct->tar) == 0) { + /* object doesn't exist, but constraint requires target */ ct->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } else if (ct->tar == owner) { - if (!get_named_bone(get_armature(owner), ct->subtarget)) { + if (type == CONSTRAINT_OBTYPE_BONE) { + if (!get_named_bone(get_armature(owner), ct->subtarget)) { + /* bone must exist in armature... */ + // TODO: clear subtarget? + curcon->flag |= CONSTRAINT_DISABLE; + } + else if (strcmp(pchan->name, ct->subtarget) == 0) { + /* cannot target self */ + ct->subtarget[0] = '\0'; + curcon->flag |= CONSTRAINT_DISABLE; + } + } + else { + /* cannot use self as target */ + ct->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } } @@ -464,11 +484,11 @@ static EnumPropertyItem constraint_owner_items[] = { static int edit_constraint_poll_generic(bContext *C, StructRNA *rna_type) { PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", rna_type); - Object *ob= (ptr.id.data)?ptr.id.data:ED_object_active_context(C); - + Object *ob= (ptr.id.data) ? ptr.id.data : ED_object_active_context(C); + if (!ob || ob->id.lib) return 0; - if (ptr.data && ((ID*)ptr.id.data)->lib) return 0; - + if (ptr.id.data && ((ID*)ptr.id.data)->lib) return 0; + return 1; } @@ -510,7 +530,7 @@ static int edit_constraint_invoke_properties(bContext *C, wmOperator *op) return 0; } -static bConstraint *edit_constraint_property_get(bContext *C, wmOperator *op, Object *ob, int type) +static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int type) { char constraint_name[32]; int owner = RNA_enum_get(op->ptr, "owner"); @@ -526,11 +546,20 @@ static bConstraint *edit_constraint_property_get(bContext *C, wmOperator *op, Ob bPoseChannel *pchan= get_active_posechannel(ob); if (pchan) list = &pchan->constraints; - else + else { + //if (G.f & G_DEBUG) + //printf("edit_constraint_property_get: No active bone for object '%s'\n", (ob)? ob->id.name+2 : "<None>"); return NULL; + } + } + else { + //if (G.f & G_DEBUG) + //printf("edit_constraint_property_get: defaulting to getting list in the standard way\n"); + list = get_active_constraints(ob); } con = constraints_findByName(list, constraint_name); + printf("constraint found = %p, %s\n", con, (con)?con->name:"<Not found>"); if (con && (type != 0) && (con->type != type)) con = NULL; @@ -546,7 +575,7 @@ static bConstraint *edit_constraint_property_get(bContext *C, wmOperator *op, Ob static int stretchto_reset_exec (bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_STRETCHTO); + bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_STRETCHTO); bStretchToConstraint *data= (con) ? (bStretchToConstraint *)con->data : NULL; /* despite 3 layers of checks, we may still not be able to find a constraint */ @@ -561,7 +590,7 @@ static int stretchto_reset_exec (bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int stretchto_reset_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int stretchto_reset_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_constraint_invoke_properties(C, op)) return stretchto_reset_exec(C, op); @@ -589,7 +618,7 @@ void CONSTRAINT_OT_stretchto_reset (wmOperatorType *ot) static int limitdistance_reset_exec (bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_DISTLIMIT); + bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_DISTLIMIT); bDistLimitConstraint *data= (con) ? (bDistLimitConstraint *)con->data : NULL; /* despite 3 layers of checks, we may still not be able to find a constraint */ @@ -604,7 +633,7 @@ static int limitdistance_reset_exec (bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int limitdistance_reset_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int limitdistance_reset_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_constraint_invoke_properties(C, op)) return limitdistance_reset_exec(C, op); @@ -635,13 +664,16 @@ static int childof_set_inverse_exec (bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Object *ob = ED_object_active_context(C); - bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_CHILDOF); + bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); bChildOfConstraint *data= (con) ? (bChildOfConstraint *)con->data : NULL; bPoseChannel *pchan= NULL; /* despite 3 layers of checks, we may still not be able to find a constraint */ - if (data == NULL) + if (data == NULL) { + printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob)? ob->id.name+2 : "<None>"); + BKE_report(op->reports, RPT_ERROR, "Couldn't find constraint data for Child-Of Set Inverse"); return OPERATOR_CANCELLED; + } /* try to find a pose channel */ // TODO: get from context instead? @@ -691,7 +723,7 @@ static int childof_set_inverse_exec (bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int childof_set_inverse_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int childof_set_inverse_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_constraint_invoke_properties(C, op)) return childof_set_inverse_exec(C, op); @@ -719,9 +751,14 @@ void CONSTRAINT_OT_childof_set_inverse (wmOperatorType *ot) static int childof_clear_inverse_exec (bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_CHILDOF); + bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); bChildOfConstraint *data= (con) ? (bChildOfConstraint *)con->data : NULL; + if(data==NULL) { + BKE_report(op->reports, RPT_ERROR, "Childof constraint not found."); + return OPERATOR_CANCELLED; + } + /* simply clear the matrix */ unit_m4(data->invmat); @@ -730,7 +767,7 @@ static int childof_clear_inverse_exec (bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int childof_clear_inverse_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int childof_clear_inverse_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_constraint_invoke_properties(C, op)) return childof_clear_inverse_exec(C, op); @@ -775,8 +812,8 @@ void ED_object_constraint_update(Object *ob) 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); + if(ob->type==OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA|OB_RECALC_OB); + else DAG_id_tag_update(&ob->id, OB_RECALC_OB); } void ED_object_constraint_dependency_update(Main *bmain, Scene *scene, Object *ob) @@ -793,7 +830,7 @@ static int constraint_poll(bContext *C) return (ptr.id.data && ptr.data); } -static int constraint_delete_exec (bContext *C, wmOperator *op) +static int constraint_delete_exec (bContext *C, wmOperator *UNUSED(op)) { PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint); Object *ob= ptr.id.data; @@ -836,7 +873,7 @@ void CONSTRAINT_OT_delete (wmOperatorType *ot) static int constraint_move_down_exec (bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - bConstraint *con = edit_constraint_property_get(C, op, ob, 0); + bConstraint *con = edit_constraint_property_get(op, ob, 0); if (con && con->next) { ListBase *conlist= get_constraint_lb(ob, con, NULL); @@ -854,7 +891,7 @@ static int constraint_move_down_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } -static int constraint_move_down_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int constraint_move_down_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_constraint_invoke_properties(C, op)) return constraint_move_down_exec(C, op); @@ -884,7 +921,7 @@ void CONSTRAINT_OT_move_down (wmOperatorType *ot) static int constraint_move_up_exec (bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - bConstraint *con = edit_constraint_property_get(C, op, ob, 0); + bConstraint *con = edit_constraint_property_get(op, ob, 0); if (con && con->prev) { ListBase *conlist= get_constraint_lb(ob, con, NULL); @@ -902,7 +939,7 @@ static int constraint_move_up_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } -static int constraint_move_up_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int constraint_move_up_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_constraint_invoke_properties(C, op)) return constraint_move_up_exec(C, op); @@ -931,11 +968,11 @@ void CONSTRAINT_OT_move_up (wmOperatorType *ot) /************************ remove constraint operators *********************/ -static int pose_constraints_clear_exec(bContext *C, wmOperator *op) +static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); /* free constraints for all selected bones */ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones) @@ -949,7 +986,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *op) DAG_scene_sort(bmain, scene); /* sort order of objects */ /* do updates */ - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); return OPERATOR_FINISHED; @@ -968,7 +1005,7 @@ void POSE_OT_constraints_clear(wmOperatorType *ot) } -static int object_constraints_clear_exec(bContext *C, wmOperator *op) +static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); @@ -977,7 +1014,7 @@ static int object_constraints_clear_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { free_constraints(&ob->constraints); - DAG_id_flush_update(&ob->id, OB_RECALC_OB); + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } CTX_DATA_END; @@ -1020,14 +1057,19 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, bPoseChannel*, chan, selected_pose_bones) { /* if we're not handling the object we're copying from, copy all constraints over */ - if (pchan != chan) + if (pchan != chan) { copy_constraints(&chan->constraints, &pchan->constraints, TRUE); + /* update flags (need to add here, not just copy) */ + chan->constflag |= pchan->constflag; + } } CTX_DATA_END; /* force depsgraph to get recalculated since new relationships added */ DAG_scene_sort(bmain, scene); /* sort order of objects/bones */ + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL); + return OPERATOR_FINISHED; } @@ -1046,7 +1088,7 @@ void POSE_OT_constraints_copy(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int object_constraint_copy_exec(bContext *C, wmOperator *op) +static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain= CTX_data_main(C); Scene *scene = CTX_data_scene(C); @@ -1230,11 +1272,18 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase bPoseChannel *pchan; bConstraint *con; - if(list == &ob->constraints) + if (list == &ob->constraints) { pchan= NULL; - else + } + else { pchan= get_active_posechannel(ob); - + + /* ensure not to confuse object/pose adding */ + if (pchan == NULL) { + BKE_report(op->reports, RPT_ERROR, "No active pose bone to add a constraint to."); + return OPERATOR_CANCELLED; + } + } /* check if constraint to be added is valid for the given constraints stack */ if (type == CONSTRAINT_TYPE_NULL) { return OPERATOR_CANCELLED; @@ -1278,22 +1327,10 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase } /* do type-specific tweaking to the constraint settings */ - // TODO: does action constraint need anything here - i.e. spaceonce? 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->mode & OB_MODE_POSE) { - con->ownspace = CONSTRAINT_SPACE_POSE; - con->flag |= CONSTRAINT_SPACEONCE; - } - } - break; - case CONSTRAINT_TYPE_PYTHON: // FIXME: this code is not really valid anymore { -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON char *menustr; int scriptint= 0; /* popup a list of usable scripts */ @@ -1317,20 +1354,20 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase /* make sure all settings are valid - similar to above checks, but sometimes can be wrong */ object_test_constraints(ob); - - if (ob->pose) + + if (pchan) update_pose_constraint_flags(ob->pose); - - + + /* force depsgraph to get recalculated since new relationships added */ DAG_scene_sort(bmain, scene); /* sort order of objects */ if ((ob->type==OB_ARMATURE) && (pchan)) { ob->pose->flag |= POSE_RECALC; /* sort pose channels */ - DAG_id_flush_update(&ob->id, OB_RECALC_DATA|OB_RECALC_OB); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA|OB_RECALC_OB); } else - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_ADDED, ob); @@ -1364,7 +1401,7 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op) /* dummy operator callback */ static int pose_constraint_add_exec(bContext *C, wmOperator *op) { - Object *ob= ED_object_active_context(C); + Object *ob= ED_object_pose_armature(ED_object_active_context(C)); int type= RNA_enum_get(op->ptr, "type"); short with_targets= 0; @@ -1465,9 +1502,9 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot) // TODO: should these be here, or back in editors/armature/poseobject.c again? /* present menu with options + validation for targets to use */ -static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *evt) +static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); bPoseChannel *pchan= get_active_posechannel(ob); bConstraint *con= NULL; @@ -1492,7 +1529,7 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *evt) } /* prepare popup menu to choose targetting options */ - pup= uiPupMenuBegin(C, "Add IK", 0); + pup= uiPupMenuBegin(C, "Add IK", ICON_NULL); layout= uiPupMenuLayout(pup); /* the type of targets we'll set determines the menu entries to show... */ @@ -1501,14 +1538,14 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *evt) * - the only thing that matters is that we want a target... */ if (tar_pchan) - uiItemBooleanO(layout, "To Active Bone", 0, "POSE_OT_ik_add", "with_targets", 1); + uiItemBooleanO(layout, "To Active Bone", ICON_NULL, "POSE_OT_ik_add", "with_targets", 1); else - uiItemBooleanO(layout, "To Active Object", 0, "POSE_OT_ik_add", "with_targets", 1); + uiItemBooleanO(layout, "To Active Object", ICON_NULL, "POSE_OT_ik_add", "with_targets", 1); } else { /* we have a choice of adding to a new empty, or not setting any target (targetless IK) */ - uiItemBooleanO(layout, "To New Empty Object", 0, "POSE_OT_ik_add", "with_targets", 1); - uiItemBooleanO(layout, "Without Targets", 0, "POSE_OT_ik_add", "with_targets", 0); + uiItemBooleanO(layout, "To New Empty Object", ICON_NULL, "POSE_OT_ik_add", "with_targets", 1); + uiItemBooleanO(layout, "Without Targets", ICON_NULL, "POSE_OT_ik_add", "with_targets", 0); } /* finish building the menu, and process it (should result in calling self again) */ @@ -1549,9 +1586,9 @@ void POSE_OT_ik_add(wmOperatorType *ot) /* ------------------ */ /* remove IK constraints from selected bones */ -static int pose_ik_clear_exec(bContext *C, wmOperator *op) +static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); /* only remove IK Constraints */ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones) @@ -1570,7 +1607,7 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* refresh depsgraph */ - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, ob); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 78404959dff..93da3592275 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -36,6 +36,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLI_editVert.h" #include "BLI_ghash.h" #include "BLI_rand.h" @@ -49,6 +50,7 @@ #include "DNA_property_types.h" #include "DNA_scene_types.h" #include "DNA_object_types.h" +#include "DNA_object_force.h" #include "DNA_meshdata_types.h" #include "DNA_vfont_types.h" @@ -58,6 +60,7 @@ #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_curve.h" +#include "BKE_effect.h" #include "BKE_depsgraph.h" #include "BKE_font.h" #include "BKE_image.h" @@ -97,13 +100,13 @@ #include "object_intern.h" // own include /* ************* XXX **************** */ -static void error(const char *dummy) {} -static void waitcursor(int val) {} -static int pupmenu(const char *msg) {return 0;} +static void error(const char *UNUSED(arg)) {} +static void waitcursor(int UNUSED(val)) {} +static int pupmenu(const char *UNUSED(msg)) {return 0;} /* port over here */ -static bContext *C; -static void error_libdata() {} +static bContext *evil_C; +static void error_libdata(void) {} /* find the correct active object per context @@ -120,7 +123,7 @@ Object *ED_object_active_context(bContext *C) /* ********* clear/set restrict view *********/ -static int object_hide_view_clear_exec(bContext *C, wmOperator *op) +static int object_hide_view_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain= CTX_data_main(C); ScrArea *sa= CTX_wm_area(C); @@ -219,7 +222,7 @@ void OBJECT_OT_hide_view_set(wmOperatorType *ot) } /* 99% same as above except no need for scene refreshing (TODO, update render preview) */ -static int object_hide_render_clear_exec(bContext *C, wmOperator *op) +static int object_hide_render_clear_exec(bContext *C, wmOperator *UNUSED(op)) { short changed= 0; @@ -371,7 +374,7 @@ void ED_object_exit_editmode(bContext *C, int flag) BKE_ptcache_object_reset(scene, obedit, PTCACHE_RESET_OUTDATED); /* 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); + DAG_id_tag_update(&obedit->id, OB_RECALC_OB|OB_RECALC_DATA); if(flag & EM_DO_UNDO) ED_undo_push(C, "Editmode"); @@ -433,7 +436,7 @@ void ED_object_enter_editmode(bContext *C, int flag) if(ob->type==OB_MESH) { Mesh *me= ob->data; - if(me->pv) mesh_pmv_off(ob, me); + if(me->pv) mesh_pmv_off(me); ok= 1; scene->obedit= ob; // context sees this @@ -460,7 +463,7 @@ void ED_object_enter_editmode(bContext *C, int flag) scene->obedit= ob; ED_armature_to_edit(ob); /* to ensure all goes in restposition and without striding */ - DAG_id_flush_update(&ob->id, OB_RECALC_ALL); // XXX: should this be OB_RECALC_DATA? + DAG_id_tag_update(&ob->id, OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME); // XXX: should this be OB_RECALC_DATA? WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_ARMATURE, scene); } @@ -494,7 +497,7 @@ void ED_object_enter_editmode(bContext *C, int flag) } if(ok) { - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } else { scene->obedit= NULL; // XXX for context @@ -506,12 +509,12 @@ void ED_object_enter_editmode(bContext *C, int flag) if(flag & EM_WAITCURSOR) waitcursor(0); } -static int editmode_toggle_exec(bContext *C, wmOperator *op) +static int editmode_toggle_exec(bContext *C, wmOperator *UNUSED(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|EM_DO_UNDO); + ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* had EM_DO_UNDO but op flag calls undo too [#24685] */ return OPERATOR_FINISHED; } @@ -524,7 +527,10 @@ static int editmode_toggle_poll(bContext *C) if(ELEM(NULL, ob, ob->data) || ((ID *)ob->data)->lib) return 0; - return ob && (ob->type == OB_MESH || ob->type == OB_ARMATURE || + if (ob->restrictflag & OB_RESTRICT_VIEW) + return 0; + + return (ob->type == OB_MESH || ob->type == OB_ARMATURE || ob->type == OB_FONT || ob->type == OB_MBALL || ob->type == OB_LATTICE || ob->type == OB_SURF || ob->type == OB_CURVE); @@ -549,7 +555,7 @@ void OBJECT_OT_editmode_toggle(wmOperatorType *ot) /* *************************** */ -static int posemode_exec(bContext *C, wmOperator *op) +static int posemode_exec(bContext *C, wmOperator *UNUSED(op)) { Base *base= CTX_data_active_base(C); @@ -581,7 +587,7 @@ void OBJECT_OT_posemode_toggle(wmOperatorType *ot) ot->poll= ED_operator_object_active_editable; /* flag */ - ot->flag= OPTYPE_REGISTER; + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } /* *********************** */ @@ -777,7 +783,7 @@ void special_editmenu(Scene *scene, View3D *v3d) } } } - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } else if(ob->mode & OB_MODE_VERTEX_PAINT) { Mesh *me= get_mesh(ob); @@ -789,7 +795,7 @@ void special_editmenu(Scene *scene, View3D *v3d) // XXX do_shared_vertexcol(me); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } } else if(ob->mode & OB_MODE_WEIGHT_PAINT) { @@ -836,7 +842,7 @@ void special_editmenu(Scene *scene, View3D *v3d) break; } - DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); + DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); if(nr>0) waitcursor(0); #endif @@ -1052,7 +1058,7 @@ static void copymenu_modifiers(Main *bmain, Scene *scene, View3D *v3d, Object *o Base *base; int i, event; char str[512]; - char *errorstr= NULL; + const char *errorstr= NULL; strcpy(str, "Copy Modifiers %t"); @@ -1078,13 +1084,13 @@ static void copymenu_modifiers(Main *bmain, Scene *scene, View3D *v3d, Object *o for (base= FIRSTBASE; base; base= base->next) { if(base->object != ob) { if(TESTBASELIB(v3d, base)) { - ModifierData *md; base->object->recalc |= OB_RECALC_OB|OB_RECALC_DATA; if (base->object->type==ob->type) { /* copy all */ if (event==NUM_MODIFIER_TYPES) { + ModifierData *md; object_free_modifiers(base->object); for (md=ob->modifiers.first; md; md=md->next) { @@ -1235,9 +1241,9 @@ void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) else if(event==2) { /* rot */ VECCOPY(base->object->rot, ob->rot); VECCOPY(base->object->drot, ob->drot); - /* Quats arnt used yet */ - /*VECCOPY(base->object->quat, ob->quat); - VECCOPY(base->object->dquat, ob->dquat);*/ + + QUATCOPY(base->object->quat, ob->quat); + QUATCOPY(base->object->dquat, ob->dquat); } else if(event==3) { /* size */ VECCOPY(base->object->size, ob->size); @@ -1323,7 +1329,7 @@ void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) BKE_text_to_curve(scene, base->object, 0); /* needed? */ - strcpy(cu1->family, cu->family); + BLI_strncpy(cu1->family, cu->family, sizeof(cu1->family)); base->object->recalc |= OB_RECALC_DATA; } @@ -1496,6 +1502,39 @@ void copy_attr_menu(Main *bmain, Scene *scene, View3D *v3d) copy_attr(bmain, scene, v3d, event); } +/* ******************* force field toggle operator ***************** */ + +static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Object *ob = CTX_data_active_object(C); + + if(ob->pd == NULL) + ob->pd = object_add_collision_fields(PFIELD_FORCE); + + if(ob->pd->forcefield == 0) + ob->pd->forcefield = PFIELD_FORCE; + else + ob->pd->forcefield = 0; + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_forcefield_toggle(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name= "Toggle Force Field"; + ot->description = "Toggle object's force field"; + ot->idname= "OBJECT_OT_forcefield_toggle"; + + /* api callbacks */ + ot->exec= forcefield_toggle_exec; + ot->poll= ED_operator_object_active_editable; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /* ********************************************** */ /* Motion Paths */ @@ -1525,7 +1564,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene) /* For the object with pose/action: create path curves for selected bones * This recalculates the WHOLE path within the pchan->pathsf and pchan->pathef range */ -static int object_calculate_paths_exec (bContext *C, wmOperator *op) +static int object_calculate_paths_exec (bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); @@ -1565,7 +1604,7 @@ void OBJECT_OT_paths_calculate (wmOperatorType *ot) /* --------- */ /* for the object with pose/action: clear path curves for selected bones only */ -void ED_objects_clear_paths(bContext *C, Scene *scene) +void ED_objects_clear_paths(bContext *C) { /* loop over objects in scene */ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) @@ -1580,12 +1619,10 @@ void ED_objects_clear_paths(bContext *C, Scene *scene) } /* operator callback for this */ -static int object_clear_paths_exec (bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - +static int object_clear_paths_exec (bContext *C, wmOperator *UNUSED(op)) +{ /* use the backend function for this */ - ED_objects_clear_paths(C, scene); + ED_objects_clear_paths(C); /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); @@ -1623,7 +1660,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) if(ob->type==OB_MESH) { mesh_set_smooth_flag(ob, !clear); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); done= 1; @@ -1636,7 +1673,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) else nu->flag &= ~ME_SMOOTH; } - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); done= 1; @@ -1728,7 +1765,7 @@ void image_aspect(Scene *scene, View3D *v3d) else ob->size[1]= ob->size[0]*y/x; done= 1; - DAG_id_flush_update(&ob->id, OB_RECALC_OB); + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } } if(done) break; @@ -1807,7 +1844,7 @@ void ofs_timeoffs(Scene *scene, View3D *v3d) // XXX if(fbutton(&offset, -10000.0f, 10000.0f, 10, 10, "Offset")==0) return; /* make array of all bases, xco yco (screen) */ - CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN(evil_C, Object*, ob, selected_editable_objects) { ob->sf += offset; if (ob->sf < -MAXFRAMEF) ob->sf = -MAXFRAMEF; else if (ob->sf > MAXFRAMEF) ob->sf = MAXFRAMEF; @@ -1820,17 +1857,17 @@ void ofs_timeoffs(Scene *scene, View3D *v3d) void rand_timeoffs(Scene *scene, View3D *v3d) { Base *base; - float rand=0.0f; + float rand_ofs=0.0f; if(BASACT==0 || v3d==NULL) return; -// XXX if(fbutton(&rand, 0.0f, 10000.0f, 10, 10, "Randomize")==0) return; +// XXX if(fbutton(&rand_ofs, 0.0f, 10000.0f, 10, 10, "Randomize")==0) return; - rand *= 2; + rand_ofs *= 2; for(base= FIRSTBASE; base; base= base->next) { if(TESTBASELIB(v3d, base)) { - base->object->sf += (BLI_drand()-0.5) * rand; + base->object->sf += (BLI_drand()-0.5) * rand_ofs; if (base->object->sf < -MAXFRAMEF) base->object->sf = -MAXFRAMEF; else if (base->object->sf > MAXFRAMEF) base->object->sf = MAXFRAMEF; } @@ -1838,7 +1875,7 @@ void rand_timeoffs(Scene *scene, View3D *v3d) } -static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED(ptr), int *free) { EnumPropertyItem *input = object_mode_items; EnumPropertyItem *item= NULL; @@ -1890,7 +1927,7 @@ static const char *object_mode_op_string(int mode) /* checks the mode to be set is compatible with the object * should be made into a generic function */ -static int object_mode_set_compat(bContext *C, wmOperator *op, Object *ob) +static int object_mode_set_compat(bContext *UNUSED(C), wmOperator *op, Object *ob) { ObjectMode mode = RNA_enum_get(op->ptr, "mode"); @@ -1999,7 +2036,7 @@ void ED_object_toggle_modes(bContext *C, int mode) /************************ Game Properties ***********************/ -static int game_property_new(bContext *C, wmOperator *op) +static int game_property_new(bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_active_object(C); bProperty *prop; @@ -2082,7 +2119,7 @@ static EnumPropertyItem game_properties_copy_operations[] ={ static EnumPropertyItem gameprops_items[]= { {0, NULL, 0, NULL, NULL}}; -static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) { Object *ob= ED_object_active_context(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; @@ -2164,7 +2201,7 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot) ot->prop=prop; } -static int game_property_clear_exec(bContext *C, wmOperator *op) +static int game_property_clear_exec(bContext *C, wmOperator *UNUSED(op)) { CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) { free_properties(&ob_iter->prop); @@ -2190,35 +2227,34 @@ void OBJECT_OT_game_property_clear(wmOperatorType *ot) /************************ Copy Logic Bricks ***********************/ -static int logicbricks_copy_exec(bContext *C, wmOperator *op) +static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob=ED_object_active_context(C); CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) { if(ob != ob_iter) { - if (ob->data != ob_iter->data){ - /* first: free all logic */ - free_sensors(&ob_iter->sensors); - unlink_controllers(&ob_iter->controllers); - free_controllers(&ob_iter->controllers); - unlink_actuators(&ob_iter->actuators); - free_actuators(&ob_iter->actuators); - - /* now copy it, this also works without logicbricks! */ - clear_sca_new_poins_ob(ob); - copy_sensors(&ob_iter->sensors, &ob->sensors); - copy_controllers(&ob_iter->controllers, &ob->controllers); - copy_actuators(&ob_iter->actuators, &ob->actuators); - set_sca_new_poins_ob(ob_iter); - - /* some menu settings */ - ob_iter->scavisflag= ob->scavisflag; - ob_iter->scaflag= ob->scaflag; - - /* set the initial state */ - ob_iter->state= ob->state; - ob_iter->init_state= ob->init_state; - } + /* first: free all logic */ + free_sensors(&ob_iter->sensors); + unlink_controllers(&ob_iter->controllers); + free_controllers(&ob_iter->controllers); + unlink_actuators(&ob_iter->actuators); + free_actuators(&ob_iter->actuators); + + /* now copy it, this also works without logicbricks! */ + clear_sca_new_poins_ob(ob); + copy_sensors(&ob_iter->sensors, &ob->sensors); + copy_controllers(&ob_iter->controllers, &ob->controllers); + copy_actuators(&ob_iter->actuators, &ob->actuators); + set_sca_new_poins_ob(ob_iter); + + /* some menu settings */ + ob_iter->scavisflag= ob->scavisflag; + ob_iter->scaflag= ob->scaflag; + + /* set the initial state */ + ob_iter->state= ob->state; + ob_iter->init_state= ob->init_state; + if(ob_iter->totcol==ob->totcol) { ob_iter->actcol= ob->actcol; WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob_iter); diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index f000485466f..c26affc24a2 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -29,8 +29,8 @@ #include <string.h> - #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_group_types.h" #include "DNA_object_types.h" @@ -96,7 +96,7 @@ void GROUP_OT_objects_add_active(wmOperatorType *ot) /* api callbacks */ ot->exec= objects_add_active_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -143,13 +143,13 @@ void GROUP_OT_objects_remove_active(wmOperatorType *ot) /* api callbacks */ ot->exec= objects_remove_active_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int group_objects_remove_exec(bContext *C, wmOperator *op) +static int group_objects_remove_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); @@ -177,7 +177,7 @@ void GROUP_OT_objects_remove(wmOperatorType *ot) /* api callbacks */ ot->exec= group_objects_remove_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -214,7 +214,7 @@ void GROUP_OT_create(wmOperatorType *ot) /* api callbacks */ ot->exec= group_create_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -224,7 +224,7 @@ void GROUP_OT_create(wmOperatorType *ot) /****************** properties window operators *********************/ -static int group_add_exec(bContext *C, wmOperator *op) +static int group_add_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; @@ -293,7 +293,7 @@ void OBJECT_OT_group_link(wmOperatorType *ot) ot->prop= prop; } -static int group_remove_exec(bContext *C, wmOperator *op) +static int group_remove_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 75e22d5356f..92a53b834b0 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -34,6 +34,7 @@ #include "BLI_editVert.h" #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "DNA_curve_types.h" #include "DNA_lattice_types.h" @@ -447,7 +448,7 @@ static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *o hmd->indexar= indexar; copy_v3_v3(hmd->cent, cent); hmd->totindex= tot; - BLI_strncpy(hmd->name, name, 32); + BLI_strncpy(hmd->name, name, sizeof(hmd->name)); /* matrix calculus */ /* vert x (obmat x hook->imat) x hook->obmat x ob->imat */ @@ -504,7 +505,7 @@ void OBJECT_OT_hook_add_selobj(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int object_add_hook_newob_exec(bContext *C, wmOperator *op) +static int object_add_hook_newob_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); @@ -551,13 +552,13 @@ static int object_hook_remove_exec(bContext *C, wmOperator *op) BLI_remlink(&ob->modifiers, (ModifierData *)hmd); modifier_free((ModifierData *)hmd); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); return OPERATOR_FINISHED; } -static EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) { Object *ob = CTX_data_edit_object(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; @@ -646,7 +647,7 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) } } - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); return OPERATOR_FINISHED; @@ -702,7 +703,7 @@ static int object_hook_recenter_exec(bContext *C, wmOperator *op) sub_v3_v3v3(hmd->cent, scene->cursor, ob->obmat[3]); mul_m3_v3(imat, hmd->cent); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); return OPERATOR_FINISHED; @@ -765,7 +766,7 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op) hmd->indexar= indexar; hmd->totindex= tot; - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); return OPERATOR_FINISHED; diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 4dc5532e975..d3adb51d53c 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -84,6 +84,7 @@ void OBJECT_OT_shade_smooth(struct wmOperatorType *ot); void OBJECT_OT_shade_flat(struct wmOperatorType *ot); void OBJECT_OT_paths_calculate(struct wmOperatorType *ot); void OBJECT_OT_paths_clear(struct wmOperatorType *ot); +void OBJECT_OT_forcefield_toggle(struct wmOperatorType *ot); void OBJECT_OT_game_property_new(struct wmOperatorType *ot); void OBJECT_OT_game_property_remove(struct wmOperatorType *ot); @@ -151,6 +152,7 @@ void OBJECT_OT_modifier_copy(struct wmOperatorType *ot); void OBJECT_OT_multires_subdivide(struct wmOperatorType *ot); void OBJECT_OT_multires_reshape(struct wmOperatorType *ot); void OBJECT_OT_multires_higher_levels_delete(struct wmOperatorType *ot); +void OBJECT_OT_multires_base_apply(struct wmOperatorType *ot); void OBJECT_OT_multires_external_save(struct wmOperatorType *ot); void OBJECT_OT_multires_external_pack(struct wmOperatorType *ot); void OBJECT_OT_meshdeform_bind(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 9f82a1209cf..3647d32c28d 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -31,6 +31,9 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" +#include "BLI_utildefines.h" + #include "DNA_curve_types.h" #include "DNA_key_types.h" #include "DNA_lattice_types.h" @@ -46,8 +49,6 @@ #include "BKE_lattice.h" #include "BKE_mesh.h" -#include "BLI_listbase.h" - #include "ED_screen.h" #include "ED_view3d.h" #include "ED_util.h" @@ -85,8 +86,6 @@ void make_editLatt(Object *obedit) free_editLatt(obedit); - lt= obedit->data; - actkey= ob_get_keyblock(obedit); if(actkey) key_to_latt(actkey, lt); @@ -155,7 +154,7 @@ void load_editLatt(Object *obedit) } if(editlt->dvert) { - int tot= lt->pntsu*lt->pntsv*lt->pntsw; + tot= lt->pntsu*lt->pntsv*lt->pntsw; lt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert"); copy_dverts(lt->dvert, editlt->dvert, tot); @@ -259,7 +258,7 @@ int make_regular_poll(bContext *C) return (ob && ob->type==OB_LATTICE); } -int make_regular_exec(bContext *C, wmOperator *op) +int make_regular_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_edit_object(C); Lattice *lt; @@ -274,7 +273,7 @@ int make_regular_exec(bContext *C, wmOperator *op) resizelattice(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); } - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); return OPERATOR_FINISHED; @@ -414,7 +413,7 @@ static void *get_editlatt(bContext *C) } /* and this is all the undo system needs to know */ -void undo_push_lattice(bContext *C, char *name) +void undo_push_lattice(bContext *C, const char *name) { undo_editmode_push(C, name, get_editlatt, free_undoLatt, undoLatt_to_editLatt, editLatt_to_undoLatt, validate_undoLatt); } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 7cf24d5d07d..0ea1c00100a 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -42,6 +42,8 @@ #include "BLI_listbase.h" #include "BLI_string.h" #include "BLI_path_util.h" +#include "BLI_editVert.h" +#include "BLI_utildefines.h" #include "BKE_curve.h" #include "BKE_context.h" @@ -68,6 +70,7 @@ #include "ED_armature.h" #include "ED_object.h" #include "ED_screen.h" +#include "ED_mesh.h" #include "WM_api.h" #include "WM_types.h" @@ -76,18 +79,24 @@ /******************************** API ****************************/ -ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, char *name, int type) +ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, const char *name, int type) { ModifierData *md=NULL, *new_md=NULL; ModifierTypeInfo *mti = modifierType_getInfo(type); - + + /* only geometry objects should be able to get modifiers [#25291] */ + if(!ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { + BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to Object '%s'", ob->id.name+2); + return NULL; + } + if(mti->flags&eModifierTypeFlag_Single) { if(modifiers_findByType(ob, type)) { BKE_report(reports, RPT_WARNING, "Only one modifier of this type allowed."); return NULL; } } - + 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 @@ -132,9 +141,12 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc } else if(type == eModifierType_Surface) DAG_scene_sort(bmain, scene); + else if(type == eModifierType_Multires) + /* set totlvl from existing MDISPS layer if object already had it */ + multiresModifier_set_levels_from_disps((MultiresModifierData *)new_md, ob); } - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); return new_md; } @@ -189,14 +201,27 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob else if(md->type == eModifierType_Multires) { Mesh *me= ob->data; - CustomData_external_remove(&me->fdata, &me->id, CD_MDISPS, me->totface); - CustomData_free_layer_active(&me->fdata, CD_MDISPS, me->totface); + if(me->edit_mesh) { + EditMesh *em= me->edit_mesh; + /* CustomData_external_remove is used here only to mark layer as non-external + for further free-ing, so zero element count looks safer than em->totface */ + CustomData_external_remove(&em->fdata, &me->id, CD_MDISPS, 0); + EM_free_data_layer(em, &em->fdata, CD_MDISPS); + } else { + CustomData_external_remove(&me->fdata, &me->id, CD_MDISPS, me->totface); + CustomData_free_layer_active(&me->fdata, CD_MDISPS, me->totface); + } + } + + if(ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) && + ob->particlesystem.first == NULL) { + ob->mode &= ~OB_MODE_PARTICLE_EDIT; } BLI_remlink(&ob->modifiers, md); modifier_free(md); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sorting has to be done after the update so that dynamic systems can react properly */ if(sort_depsgraph) @@ -247,7 +272,7 @@ int ED_object_modifier_move_down(ReportList *reports, Object *ob, ModifierData * return 1; } -int ED_object_modifier_convert(ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md) +int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene *scene, Object *ob, ModifierData *md) { Object *obn; ParticleSystem *psys; @@ -362,7 +387,7 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to Shapes"); return 0; } - mesh_pmv_off(ob, me); + mesh_pmv_off(me); dm = mesh_create_derived_for_modifier(scene, ob, md); if (!dm) { @@ -410,7 +435,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, return 0; } - mesh_pmv_off(ob, me); + mesh_pmv_off(me); /* Multires: ensure that recent sculpting is applied */ if(md->type == eModifierType_Multires) @@ -431,6 +456,11 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, DM_to_mesh(dm, me); dm->release(dm); + + if(md->type == eModifierType_Multires) { + CustomData_external_remove(&me->fdata, &me->id, CD_MDISPS, me->totface); + CustomData_free_layer_active(&me->fdata, CD_MDISPS, me->totface); + } } } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { @@ -452,7 +482,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, MEM_freeN(vertexCos); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } else { BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type"); @@ -503,7 +533,7 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi return 1; } -int ED_object_modifier_copy(ReportList *reports, Object *ob, ModifierData *md) +int ED_object_modifier_copy(ReportList *UNUSED(reports), Object *ob, ModifierData *md) { ModifierData *nmd; @@ -532,7 +562,7 @@ static int modifier_add_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) { Object *ob= ED_object_active_context(C); EnumPropertyItem *item= NULL, *md_item; @@ -590,20 +620,21 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot) /************************ generic functions for operators using mod names and data context *********************/ -static int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type) +static int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag) { PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", rna_type); Object *ob= (ptr.id.data)?ptr.id.data:ED_object_active_context(C); if (!ob || ob->id.lib) return 0; - if (ptr.data && ((ID*)ptr.id.data)->lib) return 0; + if (obtype_flag && ((1<<ob->type) & obtype_flag)==0) return 0; + if (ptr.id.data && ((ID*)ptr.id.data)->lib) return 0; return 1; } static int edit_modifier_poll(bContext *C) { - return edit_modifier_poll_generic(C, &RNA_Modifier); + return edit_modifier_poll_generic(C, &RNA_Modifier, 0); } static void edit_modifier_properties(wmOperatorType *ot) @@ -628,7 +659,7 @@ static int edit_modifier_invoke_properties(bContext *C, wmOperator *op) return 0; } -static ModifierData *edit_modifier_property_get(bContext *C, wmOperator *op, Object *ob, int type) +static ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type) { char modifier_name[32]; ModifierData *md; @@ -649,17 +680,24 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob = ED_object_active_context(C); - ModifierData *md = edit_modifier_property_get(C, op, ob, 0); + ModifierData *md = edit_modifier_property_get(op, ob, 0); + int mode_orig = ob->mode; if(!ob || !md || !ED_object_modifier_remove(op->reports, bmain, scene, ob, md)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + + /* if cloth/softbody was removed, particle mode could be cleared */ + if(mode_orig & OB_MODE_PARTICLE_EDIT) + if((ob->mode & OB_MODE_PARTICLE_EDIT)==0) + if(scene->basact && scene->basact->object==ob) + WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); return OPERATOR_FINISHED; } -static int modifier_remove_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int modifier_remove_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_modifier_invoke_properties(C, op)) return modifier_remove_exec(C, op); @@ -687,18 +725,18 @@ void OBJECT_OT_modifier_remove(wmOperatorType *ot) static int modifier_move_up_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - ModifierData *md = edit_modifier_property_get(C, op, ob, 0); + ModifierData *md = edit_modifier_property_get(op, ob, 0); if(!ob || !md || !ED_object_modifier_move_up(op->reports, ob, md)) return OPERATOR_CANCELLED; - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); return OPERATOR_FINISHED; } -static int modifier_move_up_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int modifier_move_up_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_modifier_invoke_properties(C, op)) return modifier_move_up_exec(C, op); @@ -726,18 +764,18 @@ void OBJECT_OT_modifier_move_up(wmOperatorType *ot) static int modifier_move_down_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - ModifierData *md = edit_modifier_property_get(C, op, ob, 0); + ModifierData *md = edit_modifier_property_get(op, ob, 0); if(!ob || !md || !ED_object_modifier_move_down(op->reports, ob, md)) return OPERATOR_CANCELLED; - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); return OPERATOR_FINISHED; } -static int modifier_move_down_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int modifier_move_down_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_modifier_invoke_properties(C, op)) return modifier_move_down_exec(C, op); @@ -766,20 +804,20 @@ static int modifier_apply_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Object *ob = ED_object_active_context(C); - ModifierData *md = edit_modifier_property_get(C, op, ob, 0); + ModifierData *md = edit_modifier_property_get(op, ob, 0); int apply_as= RNA_enum_get(op->ptr, "apply_as"); if(!ob || !md || !ED_object_modifier_apply(op->reports, scene, ob, md, apply_as)) { return OPERATOR_CANCELLED; } - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); return OPERATOR_FINISHED; } -static int modifier_apply_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int modifier_apply_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_modifier_invoke_properties(C, op)) return modifier_apply_exec(C, op); @@ -816,18 +854,18 @@ static int modifier_convert_exec(bContext *C, wmOperator *op) Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob = ED_object_active_context(C); - ModifierData *md = edit_modifier_property_get(C, op, ob, 0); + ModifierData *md = edit_modifier_property_get(op, ob, 0); if(!ob || !md || !ED_object_modifier_convert(op->reports, bmain, scene, ob, md)) return OPERATOR_CANCELLED; - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); return OPERATOR_FINISHED; } -static int modifier_convert_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int modifier_convert_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_modifier_invoke_properties(C, op)) return modifier_convert_exec(C, op); @@ -855,18 +893,18 @@ void OBJECT_OT_modifier_convert(wmOperatorType *ot) static int modifier_copy_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - ModifierData *md = edit_modifier_property_get(C, op, ob, 0); + ModifierData *md = edit_modifier_property_get(op, ob, 0); if(!ob || !md || !ED_object_modifier_copy(op->reports, ob, md)) return OPERATOR_CANCELLED; - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); return OPERATOR_FINISHED; } -static int modifier_copy_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int modifier_copy_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_modifier_invoke_properties(C, op)) return modifier_copy_exec(C, op); @@ -893,13 +931,13 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot) static int multires_poll(bContext *C) { - return edit_modifier_poll_generic(C, &RNA_MultiresModifier); + return edit_modifier_poll_generic(C, &RNA_MultiresModifier, (1<<OB_MESH)); } static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(C, op, ob, eModifierType_Multires); + MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); if (!mmd) return OPERATOR_CANCELLED; @@ -911,7 +949,7 @@ static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int multires_higher_levels_delete_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int multires_higher_levels_delete_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_modifier_invoke_properties(C, op)) return multires_higher_levels_delete_exec(C, op); @@ -938,20 +976,20 @@ void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot) static int multires_subdivide_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(C, op, ob, eModifierType_Multires); + MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); if (!mmd) return OPERATOR_CANCELLED; multiresModifier_subdivide(mmd, ob, 0, mmd->simple); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); return OPERATOR_FINISHED; } -static int multires_subdivide_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int multires_subdivide_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_modifier_invoke_properties(C, op)) return multires_subdivide_exec(C, op); @@ -980,7 +1018,7 @@ static int multires_reshape_exec(bContext *C, wmOperator *op) { Object *ob= ED_object_active_context(C), *secondob= NULL; Scene *scene= CTX_data_scene(C); - MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(C, op, ob, eModifierType_Multires); + MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); if (!mmd) return OPERATOR_CANCELLED; @@ -1003,13 +1041,13 @@ static int multires_reshape_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); return OPERATOR_FINISHED; } -static int multires_reshape_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int multires_reshape_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_modifier_invoke_properties(C, op)) return multires_reshape_exec(C, op); @@ -1050,7 +1088,7 @@ static int multires_external_save_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", path); if(relative) - BLI_path_rel(path, G.sce); + BLI_path_rel(path, G.main->name); CustomData_external_add(&me->fdata, &me->id, CD_MDISPS, me->totface, path); CustomData_external_write(&me->fdata, &me->id, CD_MASK_MESH, me->totface, 0); @@ -1058,7 +1096,7 @@ static int multires_external_save_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int multires_external_save_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int multires_external_save_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { Object *ob = ED_object_active_context(C); MultiresModifierData *mmd; @@ -1068,7 +1106,7 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, wmEvent *e if (!edit_modifier_invoke_properties(C, op)) return OPERATOR_CANCELLED; - mmd = (MultiresModifierData *)edit_modifier_property_get(C, op, ob, eModifierType_Multires); + mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); if (!mmd) return OPERATOR_CANCELLED; @@ -1112,7 +1150,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot) /****************** multires pack operator *********************/ -static int multires_external_pack_exec(bContext *C, wmOperator *op) +static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_active_context(C); Mesh *me= ob->data; @@ -1139,18 +1177,60 @@ void OBJECT_OT_multires_external_pack(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +/********************* multires apply base ***********************/ +static int multires_base_apply_exec(bContext *C, wmOperator *op) +{ + Object *ob = ED_object_active_context(C); + MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); + + if (!mmd) + return OPERATOR_CANCELLED; + + multiresModifier_base_apply(mmd, ob); + + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + + return OPERATOR_FINISHED; +} + +static int multires_base_apply_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + if (edit_modifier_invoke_properties(C, op)) + return multires_base_apply_exec(C, op); + else + return OPERATOR_CANCELLED; +} + + +void OBJECT_OT_multires_base_apply(wmOperatorType *ot) +{ + ot->name= "Multires Apply Base"; + ot->description= "Modify the base mesh to conform to the displaced mesh"; + ot->idname= "OBJECT_OT_multires_base_apply"; + + ot->poll= multires_poll; + ot->invoke= multires_base_apply_invoke; + ot->exec= multires_base_apply_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + edit_modifier_properties(ot); +} + + /************************ mdef bind operator *********************/ static int meshdeform_poll(bContext *C) { - return edit_modifier_poll_generic(C, &RNA_MeshDeformModifier); + return edit_modifier_poll_generic(C, &RNA_MeshDeformModifier, (1<<OB_MESH)); } static int meshdeform_bind_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Object *ob = ED_object_active_context(C); - MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get(C, op, ob, eModifierType_MeshDeform); + MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_MeshDeform); if (!mmd) return OPERATOR_CANCELLED; @@ -1170,7 +1250,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) mmd->totcagevert= 0; mmd->totinfluence= 0; - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); } else { @@ -1202,7 +1282,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int meshdeform_bind_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int meshdeform_bind_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_modifier_invoke_properties(C, op)) return meshdeform_bind_exec(C, op); @@ -1231,26 +1311,26 @@ void OBJECT_OT_meshdeform_bind(wmOperatorType *ot) static int explode_poll(bContext *C) { - return edit_modifier_poll_generic(C, &RNA_ExplodeModifier); + return edit_modifier_poll_generic(C, &RNA_ExplodeModifier, 0); } static int explode_refresh_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - ExplodeModifierData *emd = (ExplodeModifierData *)edit_modifier_property_get(C, op, ob, eModifierType_Explode); + ExplodeModifierData *emd = (ExplodeModifierData *)edit_modifier_property_get(op, ob, eModifierType_Explode); if (!emd) return OPERATOR_CANCELLED; emd->flag |= eExplodeFlag_CalcFaces; - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); return OPERATOR_FINISHED; } -static int explode_refresh_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int explode_refresh_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (edit_modifier_invoke_properties(C, op)) return explode_refresh_exec(C, op); diff --git a/source/blender/editors/object/object_navmesh.cpp b/source/blender/editors/object/object_navmesh.cpp index 95738a05db4..8ee63296c70 100644 --- a/source/blender/editors/object/object_navmesh.cpp +++ b/source/blender/editors/object/object_navmesh.cpp @@ -26,6 +26,7 @@ * * ***** END GPL LICENSE BLOCK ***** */ + #include <math.h> #include "Recast.h" @@ -49,6 +50,7 @@ extern "C" #include "BKE_cdderivedmesh.h" #include "BLI_editVert.h" #include "BLI_listbase.h" +#include "BLI_utildefines.h" #include "ED_object.h" #include "BLI_math_vector.h" @@ -411,7 +413,7 @@ static Object* createRepresentation(bContext *C, rcPolyMesh*& pmesh, rcPolyMeshD BKE_mesh_end_editmesh((Mesh*)obedit->data, em); - DAG_id_flush_update((ID*)obedit->data, OB_RECALC_DATA); + DAG_id_tag_update((ID*)obedit->data, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); @@ -445,7 +447,14 @@ static int create_navmesh_exec(bContext *C, wmOperator *op) rcPolyMeshDetail* dmesh; LinkNode* obs = NULL; Base* navmeshBase = NULL; - CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) + //CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) //expand macros to avoid error in convertion from void* + { + ListBase ctx_data_list; + CollectionPointerLink *ctx_link; + CTX_data_selected_editable_bases(C, &ctx_data_list); + for(ctx_link = (CollectionPointerLink *)ctx_data_list.first; + ctx_link; ctx_link = (CollectionPointerLink *)ctx_link->next) { + Base* base= (Base*)ctx_link->ptr.data; { if (base->object->body_type==OB_BODY_TYPE_NAVMESH) { @@ -454,7 +463,7 @@ static int create_navmesh_exec(bContext *C, wmOperator *op) } else BLI_linklist_append(&obs, (void*)base->object); - } + } CTX_DATA_END; createVertsTrisData(C, obs, nverts, verts, ntris, tris); BLI_linklist_free(obs, NULL); @@ -518,7 +527,7 @@ static int assign_navpolygon_exec(bContext *C, wmOperator *op) } } - DAG_id_flush_update((ID*)obedit->data, OB_RECALC_DATA); + DAG_id_tag_update((ID*)obedit->data, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh((Mesh*)obedit->data, em); @@ -596,7 +605,7 @@ static int assign_new_navpolygon_exec(bContext *C, wmOperator *op) } } - DAG_id_flush_update((ID*)obedit->data, OB_RECALC_DATA); + DAG_id_tag_update((ID*)obedit->data, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); BKE_mesh_end_editmesh((Mesh*)obedit->data, em); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index ef68d5507d3..5c5f42b974f 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -29,12 +29,12 @@ #include <stdlib.h> #include <math.h> - #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_context.h" @@ -77,6 +77,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_shade_flat); WM_operatortype_append(OBJECT_OT_paths_calculate); WM_operatortype_append(OBJECT_OT_paths_clear); + WM_operatortype_append(OBJECT_OT_forcefield_toggle); WM_operatortype_append(OBJECT_OT_parent_set); WM_operatortype_append(OBJECT_OT_parent_no_inverse_set); @@ -134,6 +135,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_multires_subdivide); WM_operatortype_append(OBJECT_OT_multires_reshape); WM_operatortype_append(OBJECT_OT_multires_higher_levels_delete); + WM_operatortype_append(OBJECT_OT_multires_base_apply); WM_operatortype_append(OBJECT_OT_multires_external_save); WM_operatortype_append(OBJECT_OT_multires_external_pack); WM_operatortype_append(OBJECT_OT_meshdeform_bind); @@ -382,7 +384,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) ED_object_generic_keymap(keyconf, keymap, 2); } -void ED_object_generic_keymap(struct wmKeyConfig *keyconf, struct wmKeyMap *keymap, int do_pet) +void ED_object_generic_keymap(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyMap *keymap, int do_pet) { wmKeyMapItem *kmi; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 2a0289ca8b3..0f8e5cec21b 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -47,6 +47,7 @@ #include "BLI_editVert.h" #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "BKE_action.h" #include "BKE_animsys.h" @@ -57,6 +58,7 @@ #include "BKE_depsgraph.h" #include "BKE_displist.h" #include "BKE_global.h" +#include "BKE_fcurve.h" #include "BKE_lattice.h" #include "BKE_library.h" #include "BKE_main.h" @@ -82,6 +84,7 @@ #include "ED_armature.h" #include "ED_curve.h" +#include "ED_keyframing.h" #include "ED_object.h" #include "ED_screen.h" #include "ED_view3d.h" @@ -194,7 +197,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { if(ob != obedit) { - ob->recalc |= OB_RECALC_ALL; + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; par= obedit->parent; while(par) { @@ -260,7 +263,7 @@ void OBJECT_OT_vertex_parent_set(wmOperatorType *ot) static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) { Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_active_context(C); /* sanity checks */ if (!scene || scene->id.lib || !ob) @@ -277,10 +280,9 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) else if (ob->id.lib) { uiPopupMenu *pup= uiPupMenuBegin(C, "OK?", ICON_QUESTION); uiLayout *layout= uiPupMenuLayout(pup); - PointerRNA props_ptr; /* create operator menu item with relevant properties filled in */ - props_ptr= uiItemFullO(layout, op->idname, op->type->name, 0, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); + uiItemFullO(layout, op->idname, op->type->name, ICON_NULL, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); /* present the menu and be done... */ uiPupMenuEnd(C, pup); @@ -297,7 +299,7 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) static int make_proxy_exec (bContext *C, wmOperator *op) { Main *bmain= CTX_data_main(C); - Object *ob, *gob= CTX_data_active_object(C); + Object *ob, *gob= ED_object_active_context(C); GroupObject *go; Scene *scene= CTX_data_scene(C); @@ -341,7 +343,7 @@ static int make_proxy_exec (bContext *C, wmOperator *op) /* depsgraph flushes are needed for the new data */ DAG_scene_sort(bmain, scene); - DAG_id_flush_update(&newob->id, OB_RECALC_ALL); + DAG_id_tag_update(&newob->id, OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, newob); } else { @@ -353,19 +355,17 @@ static int make_proxy_exec (bContext *C, wmOperator *op) } /* Generic itemf's for operators that take library args */ -static EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) { - EnumPropertyItem *item= NULL, item_tmp; + EnumPropertyItem item_tmp= {0}, *item= NULL; int totitem= 0; int i= 0; - Object *ob= CTX_data_active_object(C); + Object *ob= ED_object_active_context(C); GroupObject *go; if(!ob || !ob->dup_group) return DummyRNA_DEFAULT_items; - memset(&item_tmp, 0, sizeof(item_tmp)); - /* find the object to affect */ for (go= ob->dup_group->gobject.first; go; go= go->next) { item_tmp.identifier= item_tmp.name= go->ob->id.name+2; @@ -429,12 +429,12 @@ static int parent_clear_exec(bContext *C, wmOperator *op) } else if(type == 1) { ob->parent= NULL; - object_apply_mat4(ob, ob->obmat); + object_apply_mat4(ob, ob->obmat, TRUE, FALSE); } else if(type == 2) unit_m4(ob->parentinv); - ob->recalc |= OB_RECALC_ALL; + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; } CTX_DATA_END; @@ -526,7 +526,7 @@ static int parent_set_exec(bContext *C, wmOperator *op) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - Object *par= CTX_data_active_object(C); + Object *par= ED_object_active_context(C); bPoseChannel *pchan= NULL; int partype= RNA_enum_get(op->ptr, "type"); int pararm= ELEM4(partype, PAR_ARMATURE, PAR_ARMATURE_NAME, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO); @@ -546,6 +546,17 @@ static int parent_set_exec(bContext *C, wmOperator *op) } else cu->flag |= CU_FOLLOW; + /* if follow, add F-Curve for ctime (i.e. "eval_time") so that path-follow works */ + if(partype == PAR_FOLLOW) { + /* get or create F-Curve */ + bAction *act = verify_adt_action(&cu->id, 1); + FCurve *fcu = verify_fcurve(act, NULL, "eval_time", 0, 1); + + /* setup dummy 'generator' modifier here to get 1-1 correspondance still working */ + if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) + add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR); + } + /* fall back on regular parenting now (for follow only) */ if(partype == PAR_FOLLOW) partype= PAR_OBJECT; @@ -560,7 +571,7 @@ static int parent_set_exec(bContext *C, wmOperator *op) } } - /* context itterator */ + /* context iterator */ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { if(ob!=par) { @@ -641,12 +652,14 @@ static int parent_set_exec(bContext *C, wmOperator *op) } else if(pararm && ob->type==OB_MESH && par->type == OB_ARMATURE) { if(partype == PAR_ARMATURE_NAME) - create_vgroups_from_armature(scene, ob, par, ARM_GROUPS_NAME, 0); + create_vgroups_from_armature(op->reports, scene, ob, par, ARM_GROUPS_NAME, 0); else if(partype == PAR_ARMATURE_ENVELOPE) - create_vgroups_from_armature(scene, ob, par, ARM_GROUPS_ENVELOPE, 0); - else if(partype == PAR_ARMATURE_AUTO) - create_vgroups_from_armature(scene, ob, par, ARM_GROUPS_AUTO, 0); - + create_vgroups_from_armature(op->reports, scene, ob, par, ARM_GROUPS_ENVELOPE, 0); + else if(partype == PAR_ARMATURE_AUTO) { + WM_cursor_wait(1); + create_vgroups_from_armature(op->reports, scene, ob, par, ARM_GROUPS_AUTO, 0); + WM_cursor_wait(0); + } /* get corrected inverse */ ob->partype= PAROBJECT; what_does_parent(scene, ob, &workob); @@ -668,14 +681,15 @@ static int parent_set_exec(bContext *C, wmOperator *op) DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL); return OPERATOR_FINISHED; } -static int parent_set_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { - Object *ob= CTX_data_active_object(C); - uiPopupMenu *pup= uiPupMenuBegin(C, "Set Parent To", 0); + Object *ob= ED_object_active_context(C); + uiPopupMenu *pup= uiPupMenuBegin(C, "Set Parent To", ICON_NULL); uiLayout *layout= uiPupMenuLayout(pup); uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); @@ -715,7 +729,7 @@ void OBJECT_OT_parent_set(wmOperatorType *ot) ot->invoke= parent_set_invoke; ot->exec= parent_set_exec; - ot->poll= ED_operator_object_active_editable; + ot->poll= ED_operator_object_active; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -728,11 +742,11 @@ void OBJECT_OT_parent_set(wmOperatorType *ot) static int parent_noinv_set_exec(bContext *C, wmOperator *op) { Main *bmain= CTX_data_main(C); - Object *par= CTX_data_active_object(C); + Object *par= ED_object_active_context(C); par->recalc |= OB_RECALC_OB; - /* context itterator */ + /* context iterator */ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { if (ob != par) { if (test_parent_loop(par, ob)) { @@ -779,7 +793,7 @@ void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot) /************************ Clear Slow Parent Operator *********************/ -static int object_slow_parent_clear_exec(bContext *C, wmOperator *op) +static int object_slow_parent_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); @@ -821,7 +835,7 @@ void OBJECT_OT_slow_parent_clear(wmOperatorType *ot) /********************** Make Slow Parent Operator *********************/ -static int object_slow_parent_set_exec(bContext *C, wmOperator *op) +static int object_slow_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); @@ -882,7 +896,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) /* remove track-object for old track */ ob->track= NULL; - ob->recalc |= OB_RECALC_ALL; + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; /* also remove all tracking constraints */ for (con= ob->constraints.last; con; con= pcon) { @@ -892,7 +906,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) } if(type == 1) - object_apply_mat4(ob, ob->obmat); + object_apply_mat4(ob, ob->obmat, TRUE, TRUE); } CTX_DATA_END; @@ -914,7 +928,7 @@ void OBJECT_OT_track_clear(wmOperatorType *ot) ot->invoke= WM_menu_invoke; ot->exec= object_track_clear_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -935,7 +949,7 @@ static int track_set_exec(bContext *C, wmOperator *op) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - Object *obact= CTX_data_active_object(C); + Object *obact= ED_object_active_context(C); int type= RNA_enum_get(op->ptr, "type"); @@ -949,7 +963,7 @@ static int track_set_exec(bContext *C, wmOperator *op) data = con->data; data->tar = obact; - ob->recalc |= OB_RECALC_ALL; + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; /* Lamp and Camera track differently by default */ if (ob->type == OB_LAMP || ob->type == OB_CAMERA) @@ -968,7 +982,7 @@ static int track_set_exec(bContext *C, wmOperator *op) data = con->data; data->tar = obact; - ob->recalc |= OB_RECALC_ALL; + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; /* Lamp and Camera track differently by default */ if (ob->type == OB_LAMP || ob->type == OB_CAMERA) { @@ -989,7 +1003,7 @@ static int track_set_exec(bContext *C, wmOperator *op) data = con->data; data->tar = obact; - ob->recalc |= OB_RECALC_ALL; + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; /* Lamp and Camera track differently by default */ if (ob->type == OB_LAMP || ob->type == OB_CAMERA) { @@ -1019,7 +1033,7 @@ void OBJECT_OT_track_set(wmOperatorType *ot) ot->invoke= WM_menu_invoke; ot->exec= track_set_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1036,7 +1050,8 @@ static unsigned int move_to_layer_init(bContext *C, wmOperator *op) unsigned int lay= 0; if(!RNA_property_is_set(op->ptr, "layers")) { - CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { + /* note: layers are set in bases, library objects work for this */ + CTX_DATA_BEGIN(C, Base*, base, selected_bases) { lay |= base->lay; } CTX_DATA_END; @@ -1084,8 +1099,8 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) 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) { + /* note: layers are set in bases, library objects work for this */ + CTX_DATA_BEGIN(C, Base*, base, selected_bases) { lay= base->lay & ~v3d->lay; base->lay= lay; base->object->lay= lay; @@ -1097,7 +1112,8 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) } else { /* normal non localview operation */ - CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { + /* note: layers are set in bases, library objects work for this */ + CTX_DATA_BEGIN(C, Base*, base, selected_bases) { /* upper byte is used for local view */ local= base->lay & 0xFF000000; base->lay= lay + local; @@ -1111,7 +1127,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|NC_OBJECT|ND_DRAW, scene); /* is NC_SCENE needed ? */ + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, scene); WM_event_add_notifier(C, NC_SCENE|ND_LAYER_CONTENT, scene); DAG_scene_sort(bmain, scene); @@ -1129,7 +1145,7 @@ void OBJECT_OT_move_to_layer(wmOperatorType *ot) /* api callbacks */ ot->invoke= move_to_layer_invoke; ot->exec= move_to_layer_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1140,7 +1156,7 @@ void OBJECT_OT_move_to_layer(wmOperatorType *ot) /************************** Link to Scene Operator *****************************/ -void link_to_scene(Main *bmain, unsigned short nr) +void link_to_scene(Main *UNUSED(bmain), unsigned short UNUSED(nr)) { #if 0 Scene *sce= (Scene*) BLI_findlink(&bmain->scene, G.curscreen->scenenr-1); @@ -1238,7 +1254,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) ID *id; int a; - ob= CTX_data_active_object(C); + ob= ED_object_active_context(C); CTX_DATA_BEGIN(C, Object*, obt, selected_editable_objects) { if(ob != obt) { @@ -1265,8 +1281,8 @@ static int make_links_data_exec(bContext *C, wmOperator *op) } break; case MAKE_LINKS_ANIMDATA: - BKE_copy_animdata_id((ID *)obt, (ID *)ob); - BKE_copy_animdata_id((ID *)obt->data, (ID *)ob->data); + BKE_copy_animdata_id((ID *)obt, (ID *)ob, FALSE); + BKE_copy_animdata_id((ID *)obt->data, (ID *)ob->data, FALSE); break; case MAKE_LINKS_DUPLIGROUP: obt->dup_group= ob->dup_group; @@ -1277,7 +1293,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) break; case MAKE_LINKS_MODIFIERS: object_link_modifiers(obt, ob); - obt->recalc |= OB_RECALC_ALL; + obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; break; } } @@ -1285,6 +1301,8 @@ static int make_links_data_exec(bContext *C, wmOperator *op) } CTX_DATA_END; + DAG_scene_sort(bmain, CTX_data_scene(C)); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C)); return OPERATOR_FINISHED; @@ -1301,6 +1319,7 @@ void OBJECT_OT_make_links_scene(wmOperatorType *ot) ot->idname= "OBJECT_OT_make_links_scene"; /* api callbacks */ + ot->invoke= WM_enum_search_invoke; ot->exec= make_links_scene_exec; /* better not run the poll check */ @@ -1323,8 +1342,6 @@ void OBJECT_OT_make_links_data(wmOperatorType *ot) {MAKE_LINKS_MODIFIERS, "MODIFIERS", 0, "Modifiers", ""}, {0, NULL, 0, NULL, NULL}}; - PropertyRNA *prop; - /* identifiers */ ot->name= "Link Data"; ot->description = "Make links from the active object to other selected objects"; @@ -1332,19 +1349,19 @@ void OBJECT_OT_make_links_data(wmOperatorType *ot) /* api callbacks */ ot->exec= make_links_data_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "type", make_links_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", make_links_items, 0, "Type", ""); } /**************************** Make Single User ********************************/ -static void single_object_users__forwardModifierLinks(void *userData, Object *ob, Object **obpoin) +static void single_object_users__forwardModifierLinks(void *UNUSED(userData), Object *UNUSED(ob), Object **obpoin) { ID_NEW(*obpoin); } @@ -1360,6 +1377,11 @@ void single_object_users(Scene *scene, View3D *v3d, int flag) for(base= FIRSTBASE; base; base= base->next) { ob= base->object; + /* newid may still have some trash from Outliner tree building, + * so clear that first to avoid errors [#26002] + */ + ob->id.newid = NULL; + if( (base->flag & flag)==flag ) { if(ob->id.lib==NULL && ob->id.us>1) { /* base gets copy of object */ @@ -1431,17 +1453,17 @@ void single_obdata_users(Main *bmain, Scene *scene, int flag) if(ob->id.lib==NULL && (base->flag & flag)==flag ) { id= ob->data; - if(id && id->us>1 && id->lib==0) { + if(id && id->us>1 && id->lib==NULL) { ob->recalc= OB_RECALC_DATA; + BKE_copy_animdata_id_action(id); + switch(ob->type) { case OB_LAMP: - if(id && id->us>1 && id->lib==NULL) { - ob->data= la= copy_lamp(ob->data); - for(a=0; a<MAX_MTEX; a++) { - if(la->mtex[a]) { - ID_NEW(la->mtex[a]->object); - } + ob->data= la= copy_lamp(ob->data); + for(a=0; a<MAX_MTEX; a++) { + if(la->mtex[a]) { + ID_NEW(la->mtex[a]->object); } } break; @@ -1449,7 +1471,8 @@ void single_obdata_users(Main *bmain, Scene *scene, int flag) ob->data= copy_camera(ob->data); break; case OB_MESH: - me= ob->data= copy_mesh(ob->data); + ob->data= copy_mesh(ob->data); + //me= ob->data; //if(me && me->key) // ipo_idnew(me->key->ipo); /* drivers */ break; @@ -1482,52 +1505,6 @@ void single_obdata_users(Main *bmain, Scene *scene, int flag) } -#if 0 // XXX old animation system - id= (ID *)ob->action; - if (id && id->us>1 && id->lib==NULL){ - if(id->newid){ - ob->action= (bAction *)id->newid; - id_us_plus(id->newid); - } - else { - ob->action= copy_action(ob->action); - id->us--; - id->newid=(ID *)ob->action; - } - } - id= (ID *)ob->ipo; - if(id && id->us>1 && id->lib==NULL) { - if(id->newid) { - ob->ipo= (Ipo *)id->newid; - id_us_plus(id->newid); - } - else { - ob->ipo= copy_ipo(ob->ipo); - id->us--; - id->newid= (ID *)ob->ipo; - } - ipo_idnew(ob->ipo); /* drivers */ - } - /* other ipos */ - switch(ob->type) { - case OB_LAMP: - la= ob->data; - if(la->ipo && la->ipo->id.us>1) { - la->ipo->id.us--; - la->ipo= copy_ipo(la->ipo); - ipo_idnew(la->ipo); /* drivers */ - } - break; - case OB_CAMERA: - cam= ob->data; - if(cam->ipo && cam->ipo->id.us>1) { - cam->ipo->id.us--; - cam->ipo= copy_ipo(cam->ipo); - ipo_idnew(cam->ipo); /* drivers */ - } - break; - } -#endif // XXX old animation system } } @@ -1538,27 +1515,18 @@ void single_obdata_users(Main *bmain, Scene *scene, int flag) } } -void single_ipo_users(Scene *scene, int flag) +static void single_object_action_users(Scene *scene, int flag) { -#if 0 // XXX old animation system Object *ob; Base *base; - ID *id; for(base= FIRSTBASE; base; base= base->next) { ob= base->object; if(ob->id.lib==NULL && (flag==0 || (base->flag & SELECT)) ) { ob->recalc= OB_RECALC_DATA; - - id= (ID *)ob->ipo; - if(id && id->us>1 && id->lib==NULL) { - ob->ipo= copy_ipo(ob->ipo); - id->us--; - ipo_idnew(ob->ipo); /* drivers */ - } + BKE_copy_animdata_id_action(&ob->id); } } -#endif // XXX old animation system } static void single_mat_users(Scene *scene, int flag, int do_textures) @@ -1580,17 +1548,11 @@ static void single_mat_users(Scene *scene, int flag, int do_textures) if(ma->id.us>1) { man= copy_material(ma); - + BKE_copy_animdata_id_action(&man->id); + man->id.us= 0; assign_material(ob, man, a); - -#if 0 // XXX old animation system - if(ma->ipo) { - man->ipo= copy_ipo(ma->ipo); - ma->ipo->id.us--; - ipo_idnew(ma->ipo); /* drivers */ - } -#endif // XXX old animation system + if(do_textures) { for(b=0; b<MAX_MTEX; b++) { if(ma->mtex[b] && ma->mtex[b]->tex) { @@ -1623,6 +1585,7 @@ void do_single_tex_user(Tex **from) } else if(tex->id.us>1) { texn= copy_texture(tex); + BKE_copy_animdata_id_action(&texn->id); tex->id.newid= (ID *)texn; tex->id.us--; *from= texn; @@ -1743,7 +1706,7 @@ static int make_local_exec(bContext *C, wmOperator *op) Material *ma, ***matarar; Lamp *la; ID *id; - int a, b, mode= RNA_enum_get(op->ptr, "type");; + int a, b, mode= RNA_enum_get(op->ptr, "type"); if(mode==3) { all_local(NULL, 0); /* NULL is all libs */ @@ -1774,6 +1737,16 @@ static int make_local_exec(bContext *C, wmOperator *op) id_make_local(id, 0); adt= BKE_animdata_from_id(id); if(adt) BKE_animdata_make_local(adt); + + /* tag indirect data direct */ + matarar= (Material ***)give_matarar(ob); + if(matarar) { + for(a=0; a<ob->totcol; a++) { + ma= (*matarar)[a]; + if(ma) + id_lib_extern(&ma->id); + } + } } for(psys=ob->particlesystem.first; psys; psys=psys->next) @@ -1834,7 +1807,7 @@ void OBJECT_OT_make_local(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_menu_invoke; ot->exec= make_local_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1863,7 +1836,7 @@ static int make_single_user_exec(bContext *C, wmOperator *op) single_mat_users(scene, flag, TRUE); if(RNA_boolean_get(op->ptr, "animation")) - single_ipo_users(scene, flag); + single_object_action_users(scene, flag); clear_id_newpoins(); @@ -1886,7 +1859,7 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_menu_invoke; ot->exec= make_single_user_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1898,7 +1871,7 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) RNA_def_boolean(ot->srna, "obdata", 0, "Object Data", "Make single user object data"); RNA_def_boolean(ot->srna, "material", 0, "Materials", "Make materials local to each datablock"); RNA_def_boolean(ot->srna, "texture", 0, "Textures", "Make textures local to each material"); - RNA_def_boolean(ot->srna, "animation", 0, "Animation Data", "Make animation data local to each object"); + RNA_def_boolean(ot->srna, "animation", 0, "Object Animation", "Make animation data local to each object"); } static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *event) @@ -1933,7 +1906,7 @@ void OBJECT_OT_drop_named_material(wmOperatorType *ot) /* api callbacks */ ot->invoke= drop_named_material_invoke; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_UNDO; diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index fa9a97f4e74..3cb20ebbac0 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -42,6 +42,7 @@ #include "BLI_listbase.h" #include "BLI_rand.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_group.h" @@ -51,6 +52,7 @@ #include "BKE_property.h" #include "BKE_report.h" #include "BKE_scene.h" +#include "BKE_library.h" #include "BKE_deform.h" #include "WM_api.h" @@ -72,7 +74,8 @@ * this takes into account the 'restrict selection in 3d view' flag. * deselect works always, the restriction just prevents selection */ -/* Note: send a NC_SCENE|ND_OB_SELECT notifier yourself! */ +/* Note: send a NC_SCENE|ND_OB_SELECT notifier yourself! (or + * or a NC_SCENE|ND_OB_VISIBLE in case of visibility toggling */ void ED_base_object_select(Base *base, short mode) { @@ -147,7 +150,7 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_menu_invoke; ot->exec= object_select_by_type_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -329,7 +332,7 @@ void OBJECT_OT_select_linked(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_menu_invoke; ot->exec= object_select_linked_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -429,7 +432,7 @@ static short select_grouped_group(bContext *C, Object *ob) /* Select objects in } /* build the menu. */ - pup= uiPupMenuBegin(C, "Select Group", 0); + pup= uiPupMenuBegin(C, "Select Group", ICON_NULL); layout= uiPupMenuLayout(pup); for (i=0; i<group_count; i++) { @@ -617,7 +620,7 @@ void OBJECT_OT_select_grouped(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_menu_invoke; ot->exec= object_select_grouped_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -659,14 +662,14 @@ static int object_select_by_layer_exec(bContext *C, wmOperator *op) void OBJECT_OT_select_by_layer(wmOperatorType *ot) { /* identifiers */ - ot->name= "select by layer"; + ot->name= "Select by Layer"; ot->description = "Select all visible objects on a layer"; ot->idname= "OBJECT_OT_select_by_layer"; /* api callbacks */ /*ot->invoke = XXX - need a int grid popup*/ ot->exec= object_select_by_layer_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -678,7 +681,7 @@ void OBJECT_OT_select_by_layer(wmOperatorType *ot) /************************** Select Inverse *************************/ -static int object_select_inverse_exec(bContext *C, wmOperator *op) +static int object_select_inverse_exec(bContext *C, wmOperator *UNUSED(op)) { CTX_DATA_BEGIN(C, Base*, base, visible_bases) { if (base->flag & SELECT) @@ -704,7 +707,7 @@ void OBJECT_OT_select_inverse(wmOperatorType *ot) /* api callbacks */ ot->exec= object_select_inverse_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -765,7 +768,7 @@ void OBJECT_OT_select_all(wmOperatorType *ot) /* api callbacks */ ot->exec= object_select_all_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -808,13 +811,13 @@ void OBJECT_OT_select_same_group(wmOperatorType *ot) { /* identifiers */ - ot->name= "select same group"; + ot->name= "Select Same Group"; ot->description = "Select object in the same group"; ot->idname= "OBJECT_OT_select_same_group"; /* api callbacks */ ot->exec= object_select_same_group_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -825,21 +828,26 @@ void OBJECT_OT_select_same_group(wmOperatorType *ot) /**************************** Select Mirror ****************************/ static int object_select_mirror_exec(bContext *C, wmOperator *op) { + Scene *scene= CTX_data_scene(C); short extend; extend= RNA_boolean_get(op->ptr, "extend"); CTX_DATA_BEGIN(C, Base*, primbase, selected_bases) { - char tmpname[32]; + flip_side_name(tmpname, primbase->object->id.name+2, TRUE); + + if(strcmp(tmpname, primbase->object->id.name+2)!=0) { /* names differ */ + Object *ob= (Object *)find_id("OB", tmpname); + if(ob) { + Base *secbase= object_in_scene(ob, scene); - CTX_DATA_BEGIN(C, Base*, secbase, visible_bases) { - if(!strcmp(secbase->object->id.name+2, tmpname)) { - ED_base_object_select(secbase, BA_SELECT); + if(secbase) { + ED_base_object_select(secbase, BA_SELECT); + } } } - CTX_DATA_END; if (extend == 0) ED_base_object_select(primbase, BA_DESELECT); @@ -862,7 +870,7 @@ void OBJECT_OT_select_mirror(wmOperatorType *ot) /* api callbacks */ ot->exec= object_select_mirror_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -878,8 +886,11 @@ static int object_select_name_exec(bContext *C, wmOperator *op) short changed = 0; if(!extend) { - CTX_DATA_BEGIN(C, Base*, base, visible_bases) { - ED_base_object_select(base, BA_DESELECT); + CTX_DATA_BEGIN(C, Base*, base, selectable_bases) { + if((base->flag & SELECT) == 0) { + ED_base_object_select(base, BA_DESELECT); + changed= 1; + } } CTX_DATA_END; } @@ -916,7 +927,7 @@ void OBJECT_OT_select_name(wmOperatorType *ot) /* api callbacks */ ot->exec= object_select_name_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -964,7 +975,7 @@ void OBJECT_OT_select_random(wmOperatorType *ot) /* api callbacks */ /*ot->invoke= object_select_random_invoke XXX - need a number popup ;*/ ot->exec = object_select_random_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 7b1ab933e28..d8e54a73500 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_curve_types.h" #include "DNA_key_types.h" @@ -53,6 +54,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_object.h" +#include "BKE_curve.h" #include "BLO_sys_types.h" // for intptr_t support @@ -100,8 +102,25 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob) BLI_remlink(&key->block, kb); key->totkey--; - if(key->refkey== kb) + if(key->refkey== kb) { key->refkey= key->block.first; + + if(key->refkey) { + /* apply new basis key on original data */ + switch(ob->type) { + case OB_MESH: + key_to_mesh(key->refkey, ob->data); + break; + case OB_CURVE: + case OB_SURF: + key_to_curve(key->refkey, ob->data, BKE_curve_nurbs(ob->data)); + break; + case OB_LATTICE: + key_to_latt(key->refkey, ob->data); + break; + } + } + } if(kb->data) MEM_freeN(kb->data); MEM_freeN(kb); @@ -137,13 +156,13 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob) free_libblock_us(&(bmain->key), key); } - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); return 1; } -static int ED_object_shape_key_mirror(bContext *C, Scene *scene, Object *ob) +static int object_shape_key_mirror(bContext *C, Object *ob) { KeyBlock *kb; Key *key; @@ -198,7 +217,7 @@ static int ED_object_shape_key_mirror(bContext *C, Scene *scene, Object *ob) MEM_freeN(tag_elem); } - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); return 1; @@ -235,8 +254,8 @@ void OBJECT_OT_shape_key_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Shape Key"; - ot->name= "Add shape key to the object."; ot->idname= "OBJECT_OT_shape_key_add"; + ot->description= "Add shape key to the object"; /* api callbacks */ ot->poll= shape_key_mode_poll; @@ -249,7 +268,7 @@ void OBJECT_OT_shape_key_add(wmOperatorType *ot) RNA_def_boolean(ot->srna, "from_mix", 1, "From Mix", "Create the new shape key from the existing mix of keys."); } -static int shape_key_remove_exec(bContext *C, wmOperator *op) +static int shape_key_remove_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; @@ -263,8 +282,8 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot) { /* identifiers */ ot->name= "Remove Shape Key"; - ot->name= "Remove shape key from the object."; ot->idname= "OBJECT_OT_shape_key_remove"; + ot->description= "Remove shape key from the object"; /* api callbacks */ ot->poll= shape_key_mode_poll; @@ -274,7 +293,7 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int shape_key_clear_exec(bContext *C, wmOperator *op) +static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; Key *key= ob_get_key(ob); @@ -286,7 +305,7 @@ static int shape_key_clear_exec(bContext *C, wmOperator *op) for(kb=key->block.first; kb; kb=kb->next) kb->curval= 0.0f; - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); return OPERATOR_FINISHED; @@ -307,12 +326,11 @@ void OBJECT_OT_shape_key_clear(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int shape_key_mirror_exec(bContext *C, wmOperator *op) +static int shape_key_mirror_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; - if(!ED_object_shape_key_mirror(C, scene, ob)) + if(!object_shape_key_mirror(C, ob)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -375,7 +393,7 @@ static int shape_key_move_exec(bContext *C, wmOperator *op) } } - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); return OPERATOR_FINISHED; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 5214676331c..355f1c153cf 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -39,6 +39,7 @@ #include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_listbase.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_curve.h" @@ -47,6 +48,7 @@ #include "BKE_mesh.h" #include "BKE_object.h" #include "BKE_report.h" +#include "BKE_multires.h" #include "RNA_define.h" #include "RNA_access.h" @@ -64,38 +66,171 @@ /*************************** Clear Transformation ****************************/ -static int object_location_clear_exec(bContext *C, wmOperator *op) +/* clear location of object */ +static void object_clear_loc(Object *ob) +{ + /* clear location if not locked */ + if ((ob->protectflag & OB_LOCK_LOCX)==0) + ob->loc[0]= ob->dloc[0]= 0.0f; + if ((ob->protectflag & OB_LOCK_LOCY)==0) + ob->loc[1]= ob->dloc[1]= 0.0f; + if ((ob->protectflag & OB_LOCK_LOCZ)==0) + ob->loc[2]= ob->dloc[2]= 0.0f; +} + +/* clear rotation of object */ +static void object_clear_rot(Object *ob) +{ + /* clear rotations that aren't locked */ + 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= ob->drotAngle= 0.0f; + if ((ob->protectflag & OB_LOCK_ROTX) == 0) + ob->rotAxis[0]= ob->drotAxis[0]= 0.0f; + if ((ob->protectflag & OB_LOCK_ROTY) == 0) + ob->rotAxis[1]= ob->drotAxis[1]= 0.0f; + if ((ob->protectflag & OB_LOCK_ROTZ) == 0) + ob->rotAxis[2]= ob->drotAxis[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; + if (IS_EQ(ob->drotAxis[0], ob->drotAxis[1]) && IS_EQ(ob->drotAxis[1], ob->drotAxis[2])) + ob->drotAxis[1]= 1.0f; + } + else if (ob->rotmode == ROT_MODE_QUAT) { + if ((ob->protectflag & OB_LOCK_ROTW) == 0) + ob->quat[0]= ob->dquat[0]= 1.0f; + if ((ob->protectflag & OB_LOCK_ROTX) == 0) + ob->quat[1]= ob->dquat[1]= 0.0f; + if ((ob->protectflag & OB_LOCK_ROTY) == 0) + ob->quat[2]= ob->dquat[2]= 0.0f; + if ((ob->protectflag & OB_LOCK_ROTZ) == 0) + ob->quat[3]= ob->dquat[3]= 0.0f; + + // TODO: does this quat need normalising now? + } + 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]= 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; + } + } + else { + /* perform clamping using euler form (3-components) */ + // FIXME: deltas are not handled for these cases yet... + float eul[3], oldeul[3], quat1[4] = {0}; + + if (ob->rotmode == ROT_MODE_QUAT) { + QUATCOPY(quat1, ob->quat); + quat_to_eul(oldeul, ob->quat); + } + else if (ob->rotmode == ROT_MODE_AXISANGLE) { + axis_angle_to_eulO(oldeul, EULER_ORDER_DEFAULT, ob->rotAxis, ob->rotAngle); + } + else { + copy_v3_v3(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) { + eul_to_quat(ob->quat, eul); + /* 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)) { + mul_qt_fl(ob->quat, -1.0f); + } + } + else if (ob->rotmode == ROT_MODE_AXISANGLE) { + eulO_to_axis_angle(ob->rotAxis, &ob->rotAngle,eul, EULER_ORDER_DEFAULT); + } + else { + copy_v3_v3(ob->rot, eul); + } + } + } // Duplicated in source/blender/editors/armature/editarmature.c + else { + if (ob->rotmode == ROT_MODE_QUAT) { + unit_qt(ob->quat); + unit_qt(ob->dquat); + } + else if (ob->rotmode == ROT_MODE_AXISANGLE) { + unit_axis_angle(ob->rotAxis, &ob->rotAngle); + unit_axis_angle(ob->drotAxis, &ob->drotAngle); + } + else { + zero_v3(ob->rot); + zero_v3(ob->drot); + } + } +} + +/* clear scale of object */ +static void object_clear_scale(Object *ob) +{ + /* clear scale factors which are not locked */ + if ((ob->protectflag & OB_LOCK_SCALEX)==0) { + ob->dsize[0]= 0.0f; + ob->size[0]= 1.0f; + } + if ((ob->protectflag & OB_LOCK_SCALEY)==0) { + ob->dsize[1]= 0.0f; + ob->size[1]= 1.0f; + } + if ((ob->protectflag & OB_LOCK_SCALEZ)==0) { + ob->dsize[2]= 0.0f; + ob->size[2]= 1.0f; + } +} + +/* --------------- */ + +/* generic exec for clear-transform operators */ +static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, + void (*clear_func)(Object*), const char default_ksName[]) { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); + Scene *scene= CTX_data_scene(C); KeyingSet *ks; - /* get KeyingSet to use - * - use the active KeyingSet if defined (and user wants to use it for all autokeying), - * or otherwise key transforms only - */ - if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset)) - ks = ANIM_scene_get_active_keyingset(scene); - else - ks = ANIM_builtin_keyingset_get_named(NULL, "Location"); + /* sanity checks */ + if ELEM(NULL, clear_func, default_ksName) { + BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform func or Keying Set Name"); + return OPERATOR_CANCELLED; + } - /* clear location of selected objects if not in weight-paint mode */ - CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { + /* get KeyingSet to use */ + ks = ANIM_get_keyingset_for_autokeying(scene, default_ksName); + + /* operate on selected objects only if they aren't in weight-paint mode + * (so that object-transform clearing won't be applied at same time as bone-clearing) + */ + CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) + { if (!(ob->mode & OB_MODE_WEIGHT_PAINT)) { - /* clear location if not locked */ - if ((ob->protectflag & OB_LOCK_LOCX)==0) - ob->loc[0]= ob->dloc[0]= 0.0f; - if ((ob->protectflag & OB_LOCK_LOCY)==0) - ob->loc[1]= ob->dloc[1]= 0.0f; - if ((ob->protectflag & OB_LOCK_LOCZ)==0) - ob->loc[2]= ob->dloc[2]= 0.0f; - + /* run provided clearing function */ + clear_func(ob); + /* auto keyframing */ if (autokeyframe_cfra_can_key(scene, &ob->id)) { ListBase dsources = {NULL, NULL}; /* now insert the keyframe(s) using the Keying Set - * 1) add datasource override for the PoseChannel + * 1) add datasource override for the Object * 2) insert keyframes * 3) free the extra info */ @@ -103,9 +238,10 @@ static int object_location_clear_exec(bContext *C, wmOperator *op) ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA); BLI_freelistN(&dsources); } + + /* tag for updates */ + ob->recalc |= OB_RECALC_OB; } - - ob->recalc |= OB_RECALC_OB; } CTX_DATA_END; @@ -117,6 +253,14 @@ static int object_location_clear_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +/* --------------- */ + + +static int object_location_clear_exec(bContext *C, wmOperator *op) +{ + return object_clear_transform_generic_exec(C, op, object_clear_loc, "Location"); +} + void OBJECT_OT_location_clear(wmOperatorType *ot) { /* identifiers */ @@ -126,7 +270,7 @@ void OBJECT_OT_location_clear(wmOperatorType *ot) /* api callbacks */ ot->exec= object_location_clear_exec; - ot->poll= ED_operator_object_active_editable; + ot->poll= ED_operator_scene_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -134,139 +278,7 @@ void OBJECT_OT_location_clear(wmOperatorType *ot) static int object_rotation_clear_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - KeyingSet *ks; - - /* get KeyingSet to use - * - use the active KeyingSet if defined (and user wants to use it for all autokeying), - * or otherwise key transforms only - */ - if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset)) - ks = ANIM_scene_get_active_keyingset(scene); - else - ks = ANIM_builtin_keyingset_get_named(NULL, "Rotation"); - - /* clear rotation of selected objects if not in weight-paint mode */ - CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if(!(ob->mode & OB_MODE_WEIGHT_PAINT)) { - /* clear rotations that aren't locked */ - 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] = {0}; - - if (ob->rotmode == ROT_MODE_QUAT) { - QUATCOPY(quat1, ob->quat); - quat_to_eul( oldeul,ob->quat); - } - else if (ob->rotmode == ROT_MODE_AXISANGLE) { - axis_angle_to_eulO( oldeul, EULER_ORDER_DEFAULT,ob->rotAxis, ob->rotAngle); - } - else { - copy_v3_v3(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) { - eul_to_quat( ob->quat,eul); - /* 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)) { - mul_qt_fl(ob->quat, -1.0f); - } - } - else if (ob->rotmode == ROT_MODE_AXISANGLE) { - eulO_to_axis_angle( ob->rotAxis, &ob->rotAngle,eul, EULER_ORDER_DEFAULT); - } - else { - copy_v3_v3(ob->rot, eul); - } - } - } // Duplicated in source/blender/editors/armature/editarmature.c - 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; - } - } - - /* auto keyframing */ - if (autokeyframe_cfra_can_key(scene, &ob->id)) { - ListBase dsources = {NULL, NULL}; - - /* now insert the keyframe(s) using the Keying Set - * 1) add datasource override for the PoseChannel - * 2) insert keyframes - * 3) free the extra info - */ - ANIM_relative_keyingset_add_source(&dsources, &ob->id, NULL, NULL); - ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA); - BLI_freelistN(&dsources); - } - } - - ob->recalc |= OB_RECALC_OB; - } - CTX_DATA_END; - - /* this is needed so children are also updated */ - DAG_ids_flush_update(bmain, 0); - - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); - - return OPERATOR_FINISHED; + return object_clear_transform_generic_exec(C, op, object_clear_rot, "Rotation"); } void OBJECT_OT_rotation_clear(wmOperatorType *ot) @@ -278,7 +290,7 @@ void OBJECT_OT_rotation_clear(wmOperatorType *ot) /* api callbacks */ ot->exec= object_rotation_clear_exec; - ot->poll= ED_operator_object_active_editable; + ot->poll= ED_operator_scene_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -286,60 +298,7 @@ void OBJECT_OT_rotation_clear(wmOperatorType *ot) static int object_scale_clear_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - KeyingSet *ks; - - /* get KeyingSet to use - * - use the active KeyingSet if defined (and user wants to use it for all autokeying), - * or otherwise key transforms only - */ - if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset)) - ks = ANIM_scene_get_active_keyingset(scene); - else - ks = ANIM_builtin_keyingset_get_named(NULL, "Scaling"); - - /* clear scales of selected objects if not in weight-paint mode */ - CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if(!(ob->mode & OB_MODE_WEIGHT_PAINT)) { - /* clear scale factors which are not locked */ - if ((ob->protectflag & OB_LOCK_SCALEX)==0) { - ob->dsize[0]= 0.0f; - ob->size[0]= 1.0f; - } - if ((ob->protectflag & OB_LOCK_SCALEY)==0) { - ob->dsize[1]= 0.0f; - ob->size[1]= 1.0f; - } - if ((ob->protectflag & OB_LOCK_SCALEZ)==0) { - ob->dsize[2]= 0.0f; - ob->size[2]= 1.0f; - } - - /* auto keyframing */ - if (autokeyframe_cfra_can_key(scene, &ob->id)) { - ListBase dsources = {NULL, NULL}; - - /* now insert the keyframe(s) using the Keying Set - * 1) add datasource override for the PoseChannel - * 2) insert keyframes - * 3) free the extra info - */ - ANIM_relative_keyingset_add_source(&dsources, &ob->id, NULL, NULL); - ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA); - BLI_freelistN(&dsources); - } - } - ob->recalc |= OB_RECALC_OB; - } - CTX_DATA_END; - - /* this is needed so children are also updated */ - DAG_ids_flush_update(bmain, 0); - - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); - - return OPERATOR_FINISHED; + return object_clear_transform_generic_exec(C, op, object_clear_scale, "Scaling"); } void OBJECT_OT_scale_clear(wmOperatorType *ot) @@ -351,20 +310,24 @@ void OBJECT_OT_scale_clear(wmOperatorType *ot) /* api callbacks */ ot->exec= object_scale_clear_exec; - ot->poll= ED_operator_object_active_editable; + ot->poll= ED_operator_scene_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int object_origin_clear_exec(bContext *C, wmOperator *op) +/* --------------- */ + +static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain= CTX_data_main(C); - float *v1, *v3, mat[3][3]; - int armature_clear= 0; + float *v1, *v3; + float mat[3][3]; - CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if(ob->parent) { + CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) + { + if (ob->parent) { + /* vectors pointed to by v1 and v3 will get modified */ v1= ob->loc; v3= ob->parentinv[3]; @@ -376,8 +339,7 @@ static int object_origin_clear_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - if(armature_clear==0) /* in this case flush was done */ - DAG_ids_flush_update(bmain, 0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); @@ -393,7 +355,7 @@ void OBJECT_OT_origin_clear(wmOperatorType *ot) /* api callbacks */ ot->exec= object_origin_clear_exec; - ot->poll= ED_operator_object_active_editable; + ot->poll= ED_operator_scene_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -411,7 +373,7 @@ static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob ) /* a change was made, adjust the children to compensate */ for(ob_child=bmain->object.first; ob_child; ob_child=ob_child->id.next) { if(ob_child->parent == ob) { - object_apply_mat4(ob_child, ob_child->obmat); + object_apply_mat4(ob_child, ob_child->obmat, TRUE, FALSE); what_does_parent(scene, ob_child, &workob); invert_m4_m4(ob_child->parentinv, workob.obmat); } @@ -478,8 +440,18 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo object_to_mat3(ob, rsmat); else if(apply_scale) object_scale_to_mat3(ob, rsmat); - else if(apply_rot) + else if(apply_rot) { + float tmat[3][3], timat[3][3]; + + /* simple rotation matrix */ object_rot_to_mat3(ob, rsmat); + + /* correct for scale, note mul_m3_m3m3 has swapped args! */ + object_scale_to_mat3(ob, tmat); + invert_m3_m3(timat, tmat); + mul_m3_m3m3(rsmat, timat, rsmat); + mul_m3_m3m3(rsmat, rsmat, tmat); + } else unit_m3(rsmat); @@ -502,6 +474,8 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo if(ob->type==OB_MESH) { me= ob->data; + multiresModifier_scale_disp(scene, ob); + /* adjust data */ mvert= me->mvert; for(a=0; a<me->totvert; a++, mvert++) @@ -550,22 +524,19 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo continue; if(apply_loc) - ob->loc[0]= ob->loc[1]= ob->loc[2]= 0.0f; + zero_v3(ob->loc); if(apply_scale) ob->size[0]= ob->size[1]= ob->size[2]= 1.0f; if(apply_rot) { - ob->rot[0]= ob->rot[1]= ob->rot[2]= 0.0f; - ob->quat[1]= ob->quat[2]= ob->quat[3]= 0.0f; - ob->rotAxis[0]= ob->rotAxis[2]= 0.0f; - ob->rotAngle= 0.0f; - - ob->quat[0]= ob->rotAxis[1]= 1.0f; + zero_v3(ob->rot); + unit_qt(ob->quat); + unit_axis_angle(ob->rotAxis, &ob->rotAngle); } where_is_object(scene, ob); ignore_parent_tx(bmain, scene, ob); - DAG_id_flush_update(&ob->id, OB_RECALC_OB|OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_OB|OB_RECALC_DATA); change = 1; } @@ -578,16 +549,19 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo return OPERATOR_FINISHED; } -static int visual_transform_apply_exec(bContext *C, wmOperator *op) +static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); int change = 0; CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { where_is_object(scene, ob); - object_apply_mat4(ob, ob->obmat); + object_apply_mat4(ob, ob->obmat, TRUE, TRUE); where_is_object(scene, ob); - + + /* update for any children that may get moved */ + DAG_id_tag_update(&ob->id, OB_RECALC_OB); + change = 1; } CTX_DATA_END; @@ -608,7 +582,7 @@ void OBJECT_OT_visual_transform_apply(wmOperatorType *ot) /* api callbacks */ ot->exec= visual_transform_apply_exec; - ot->poll= ED_operator_object_active_editable; + ot->poll= ED_operator_scene_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -628,7 +602,7 @@ void OBJECT_OT_location_apply(wmOperatorType *ot) /* api callbacks */ ot->exec= location_apply_exec; - ot->poll= ED_operator_object_active_editable; + ot->poll= ED_operator_scene_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -648,7 +622,7 @@ void OBJECT_OT_scale_apply(wmOperatorType *ot) /* api callbacks */ ot->exec= scale_apply_exec; - ot->poll= ED_operator_object_active_editable; + ot->poll= ED_operator_scene_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -668,7 +642,7 @@ void OBJECT_OT_rotation_apply(wmOperatorType *ot) /* api callbacks */ ot->exec= rotation_apply_exec; - ot->poll= ED_operator_object_active_editable; + ot->poll= ED_operator_scene_editable; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -770,7 +744,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) total++; add_v3_v3(cent, eve->co); } - mul_v3_fl(cent, 1.0f/(float)total); + if(total) { + mul_v3_fl(cent, 1.0f/(float)total); + } } else { for(eve= em->verts.first; eve; eve= eve->next) { @@ -779,13 +755,15 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) mid_v3_v3v3(cent, min, max); } - for(eve= em->verts.first; eve; eve= eve->next) { - sub_v3_v3(eve->co, cent); - } + if(!is_zero_v3(cent)) { + for(eve= em->verts.first; eve; eve= eve->next) { + sub_v3_v3(eve->co, cent); + } - recalc_editnormals(em); - tot_change++; - DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); + recalc_editnormals(em); + tot_change++; + DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); + } BKE_mesh_end_editmesh(me, em); } } @@ -877,7 +855,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if(obedit) { if (centermode == GEOMETRY_TO_ORIGIN) { - DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); + DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); } break; } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 76af8feda82..c673ea0fd2d 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -30,6 +30,7 @@ #include <string.h> #include <stddef.h> #include <math.h> +#include <assert.h> #include "MEM_guardedalloc.h" @@ -45,6 +46,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_customdata.h" @@ -68,6 +70,8 @@ /************************ Exported Functions **********************/ static void vgroup_remap_update_users(Object *ob, int *map); +static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *defgroup); +static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg); static Lattice *vgroup_edit_lattice(Object *ob) { @@ -79,7 +83,17 @@ static Lattice *vgroup_edit_lattice(Object *ob) return NULL; } -bDeformGroup *ED_vgroup_add_name(Object *ob, char *name) +int ED_vgroup_object_is_edit_mode(Object *ob) +{ + if(ob->type == OB_MESH) + return (((Mesh*)ob->data)->edit_mesh != NULL); + else if(ob->type == OB_LATTICE) + return (((Lattice*)ob->data)->editlatt != NULL); + + return 0; +} + +bDeformGroup *ED_vgroup_add_name(Object *ob, const char *name) { bDeformGroup *defgroup; @@ -103,6 +117,25 @@ bDeformGroup *ED_vgroup_add(Object *ob) return ED_vgroup_add_name(ob, "Group"); } +void ED_vgroup_delete(Object *ob, bDeformGroup *defgroup) +{ + bDeformGroup *dg = (bDeformGroup *)ob->defbase.first; + + while (dg) { + if (dg == defgroup) + break; + dg = dg->next; + } + + if (dg == NULL) + return; + + if(ED_vgroup_object_is_edit_mode(ob)) + vgroup_delete_edit_mode(ob, dg); + else + vgroup_delete_object_mode(ob, dg); +} + void ED_vgroup_data_create(ID *id) { /* create deform verts */ @@ -136,8 +169,7 @@ int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_tot) return 0; } - i = 0; - for (eve=em->verts.first; eve; eve=eve->next) i++; + i= BLI_countlist(&em->verts); *dvert_arr= MEM_mallocN(sizeof(void*)*i, "vgroup parray from me"); *dvert_tot = i; @@ -460,23 +492,10 @@ void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum) /* This routine removes the vertex from the specified * deform group. */ - - int def_nr; - - /* if the object is NULL abort - */ - if(!ob) + const int def_nr= defgroup_find_index(ob, dg); + if(def_nr < 0) return; - /* get the deform number that cooresponds - * to this deform group, and abort if it - * can not be found. - */ - def_nr = defgroup_find_index(ob, dg); - if(def_nr < 0) return; - - /* call another routine to do the work - */ ED_vgroup_nr_vert_remove(ob, def_nr, vertnum); } @@ -508,7 +527,7 @@ static float get_vert_def_nr(Object *ob, int def_nr, int vertnum) } if(dvert==NULL) - return 0.0f; + return -1; dvert += vertnum; @@ -516,22 +535,22 @@ static float get_vert_def_nr(Object *ob, int def_nr, int vertnum) if(dvert->dw[i].def_nr == def_nr) return dvert->dw[i].weight; - return 0.0f; + return -1; } float ED_vgroup_vert_weight(Object *ob, bDeformGroup *dg, int vertnum) { int def_nr; - if(!ob) return 0.0f; + if(!ob) return -1; def_nr = defgroup_find_index(ob, dg); - if(def_nr < 0) return 0.0f; + if(def_nr < 0) return -1; return get_vert_def_nr(ob, def_nr, vertnum); } -void ED_vgroup_select_by_name(Object *ob, char *name) +void ED_vgroup_select_by_name(Object *ob, const char *name) { /* note: ob->actdef==0 signals on painting to create a new one, if a bone in posemode is selected */ ob->actdef= defgroup_name_index(ob, name) + 1; } @@ -555,9 +574,10 @@ static void vgroup_select_verts(Object *ob, int select) if(dvert && dvert->totweight){ for(i=0; i<dvert->totweight; i++){ if(dvert->dw[i].def_nr == (ob->actdef-1)){ - if(select) eve->f |= SELECT; - else eve->f &= ~SELECT; - + if(!eve->h) { + if(select) eve->f |= SELECT; + else eve->f &= ~SELECT; + } break; } } @@ -596,7 +616,7 @@ static void vgroup_select_verts(Object *ob, int select) static void vgroup_duplicate(Object *ob) { bDeformGroup *dg, *cdg; - char name[32], s[32]; + char name[sizeof(dg->name)]; MDeformWeight *org, *cpy; MDeformVert *dvert, **dvert_array=NULL; int i, idg, icdg, dvert_tot=0; @@ -605,26 +625,17 @@ static void vgroup_duplicate(Object *ob) if(!dg) return; - if(strstr(dg->name, "_copy")) { - BLI_strncpy(name, dg->name, 32); /* will be renamed _copy.001... etc */ + if(!strstr(dg->name, "_copy")) { + BLI_snprintf(name, sizeof(name), "%s_copy", dg->name); } else { - BLI_snprintf(name, 32, "%s_copy", dg->name); - while(defgroup_find_name(ob, name)) { - if((strlen(name) + 6) > 32) { - if (G.f & G_DEBUG) - printf("Internal error: the name for the new vertex group is > 32 characters"); - return; - } - strcpy(s, name); - BLI_snprintf(name, 32, "%s_copy", s); - } - } + BLI_snprintf(name, sizeof(name), "%s", dg->name); + } cdg = defgroup_duplicate(dg); strcpy(cdg->name, name); defgroup_unique_name(cdg, ob); - + BLI_addtail(&ob->defbase, cdg); idg = (ob->actdef-1); @@ -1102,62 +1113,54 @@ static void vgroup_delete_update_users(Object *ob, int id) } -static void vgroup_delete_object_mode(Object *ob) +static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg) { - bDeformGroup *dg; - MDeformVert *dvert, *dvert_array=NULL; + MDeformVert *dvert_array=NULL; int i, e, dvert_tot=0; - - dg = BLI_findlink(&ob->defbase, (ob->actdef-1)); - if(!dg) - return; + const int dg_index= BLI_findindex(&ob->defbase, dg); + + assert(dg_index > -1); ED_vgroup_give_array(ob->data, &dvert_array, &dvert_tot); if(dvert_array) { - for(i = 0; i < dvert_tot; i++) { - dvert = dvert_array + i; - if(dvert) { - if(defvert_find_index(dvert, (ob->actdef-1))) - ED_vgroup_vert_remove(ob, dg, i); - } + MDeformVert *dvert; + for(i= 0, dvert= dvert_array; i < dvert_tot; i++, dvert++) { + ED_vgroup_vert_remove(ob, dg, i); /* ok if the dg isnt in this dvert, will continue silently */ } - for(i = 0; i < dvert_tot; i++) { - dvert = dvert_array+i; - if(dvert) { - for(e = 0; e < dvert->totweight; e++) { - if(dvert->dw[e].def_nr > (ob->actdef-1)) - dvert->dw[e].def_nr--; + for(i= 0, dvert= dvert_array; i < dvert_tot; i++, dvert++) { + for(e = 0; e < dvert->totweight; e++) { + if(dvert->dw[e].def_nr > dg_index) { + dvert->dw[e].def_nr--; } } } } - vgroup_delete_update_users(ob, ob->actdef); + vgroup_delete_update_users(ob, dg_index + 1); - /* Update the active deform index if necessary */ - if(ob->actdef == BLI_countlist(&ob->defbase)) - ob->actdef--; - /* Remove the group */ BLI_freelinkN(&ob->defbase, dg); + + /* Update the active deform index if necessary */ + if(ob->actdef > dg_index) + ob->actdef--; + if(ob->actdef < 1 && ob->defbase.first) + ob->actdef= 1; + } /* only in editmode */ /* removes from active defgroup, if allverts==0 only selected vertices */ -static void vgroup_active_remove_verts(Object *ob, int allverts) +static void vgroup_active_remove_verts(Object *ob, const int allverts, bDeformGroup *dg) { EditVert *eve; MDeformVert *dvert; MDeformWeight *newdw; - bDeformGroup *dg, *eg; + bDeformGroup *eg; int i; - dg=BLI_findlink(&ob->defbase, ob->actdef-1); - if(!dg) - return; - if(ob->type == OB_MESH) { Mesh *me= ob->data; EditMesh *em = BKE_mesh_get_editmesh(me); @@ -1207,20 +1210,15 @@ static void vgroup_active_remove_verts(Object *ob, int allverts) } } -static void vgroup_delete_edit_mode(Object *ob) +static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg) { - bDeformGroup *defgroup; int i; + const int dg_index= BLI_findindex(&ob->defbase, dg); - if(!ob->actdef) - return; - - defgroup = BLI_findlink(&ob->defbase, ob->actdef-1); - if(!defgroup) - return; + assert(dg_index > -1); /* Make sure that no verts are using this group */ - vgroup_active_remove_verts(ob, 1); + vgroup_active_remove_verts(ob, TRUE, dg); /* Make sure that any verts with higher indices are adjusted accordingly */ if(ob->type==OB_MESH) { @@ -1234,7 +1232,7 @@ static void vgroup_delete_edit_mode(Object *ob) if(dvert) for(i=0; i<dvert->totweight; i++) - if(dvert->dw[i].def_nr > (ob->actdef-1)) + if(dvert->dw[i].def_nr > dg_index) dvert->dw[i].def_nr--; } BKE_mesh_end_editmesh(me, em); @@ -1249,24 +1247,26 @@ static void vgroup_delete_edit_mode(Object *ob) tot= lt->pntsu*lt->pntsv*lt->pntsw; for(a=0, bp= lt->def; a<tot; a++, bp++, dvert++) { for(i=0; i<dvert->totweight; i++){ - if(dvert->dw[i].def_nr > (ob->actdef-1)) + if(dvert->dw[i].def_nr > dg_index) dvert->dw[i].def_nr--; } } } } - vgroup_delete_update_users(ob, ob->actdef); + vgroup_delete_update_users(ob, dg_index + 1); + + /* Remove the group */ + BLI_freelinkN (&ob->defbase, dg); /* Update the active deform index if necessary */ - if(ob->actdef==BLI_countlist(&ob->defbase)) + if(ob->actdef > dg_index) ob->actdef--; - - /* Remove the group */ - BLI_freelinkN (&ob->defbase, defgroup); - + if(ob->actdef < 1 && ob->defbase.first) + ob->actdef= 1; + /* remove all dverts */ - if(ob->actdef==0) { + if(ob->defbase.first == NULL) { if(ob->type==OB_MESH) { Mesh *me= ob->data; CustomData_free_layer_active(&me->vdata, CD_MDEFORMVERT, me->totvert); @@ -1294,10 +1294,14 @@ static int vgroup_object_in_edit_mode(Object *ob) static void vgroup_delete(Object *ob) { + bDeformGroup *dg = BLI_findlink(&ob->defbase, ob->actdef-1); + if(!dg) + return; + if(vgroup_object_in_edit_mode(ob)) - vgroup_delete_edit_mode(ob); + vgroup_delete_edit_mode(ob, dg); else - vgroup_delete_object_mode(ob); + vgroup_delete_object_mode(ob, dg); } static void vgroup_delete_all(Object *ob) @@ -1348,7 +1352,6 @@ static void vgroup_assign_verts(Object *ob, float weight) dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT); if(dvert && (eve->f & SELECT)){ - done=0; /* See if this vert already has a reference to this group */ /* If so: Change its weight */ done=0; @@ -1400,22 +1403,14 @@ static void vgroup_assign_verts(Object *ob, float weight) /* removes from all defgroup, if allverts==0 only selected vertices */ static void vgroup_remove_verts(Object *ob, int allverts) { - int actdef, defCount; - - actdef= ob->actdef; - defCount= BLI_countlist(&ob->defbase); - - if(defCount == 0) - return; - /* To prevent code redundancy, we just use vgroup_active_remove_verts, but that * only operates on the active vgroup. So we iterate through all groups, by changing * active group index */ - for(ob->actdef= 1; ob->actdef <= defCount; ob->actdef++) - vgroup_active_remove_verts(ob, allverts); - - ob->actdef= actdef; + bDeformGroup *dg; + for(dg= ob->defbase.first; dg; dg= dg->next) { + vgroup_active_remove_verts(ob, allverts, dg); + } } /********************** vertex group operators *********************/ @@ -1438,12 +1433,12 @@ static int vertex_group_poll_edit(bContext *C) return vgroup_object_in_edit_mode(ob); } -static int vertex_group_add_exec(bContext *C, wmOperator *op) +static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; ED_vgroup_add(ob); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); @@ -1473,7 +1468,7 @@ static int vertex_group_remove_exec(bContext *C, wmOperator *op) else vgroup_delete(ob); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); @@ -1506,7 +1501,7 @@ static int vertex_group_assign_exec(bContext *C, wmOperator *op) ED_vgroup_add(ob); vgroup_assign_verts(ob, ts->vgroup_weight); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); return OPERATOR_FINISHED; @@ -1535,10 +1530,17 @@ static int vertex_group_remove_from_exec(bContext *C, wmOperator *op) if(RNA_boolean_get(op->ptr, "all")) vgroup_remove_verts(ob, 0); - else - vgroup_active_remove_verts(ob, 0); + else { + bDeformGroup *dg= BLI_findlink(&ob->defbase, ob->actdef - 1); + + if(dg == NULL) { + return OPERATOR_CANCELLED; + } + + vgroup_active_remove_verts(ob, FALSE, dg); + } - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); return OPERATOR_FINISHED; @@ -1561,7 +1563,7 @@ void OBJECT_OT_vertex_group_remove_from(wmOperatorType *ot) RNA_def_boolean(ot->srna, "all", 0, "All", "Remove from all vertex groups."); } -static int vertex_group_select_exec(bContext *C, wmOperator *op) +static int vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_edit_object(C); @@ -1588,7 +1590,7 @@ void OBJECT_OT_vertex_group_select(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int vertex_group_deselect_exec(bContext *C, wmOperator *op) +static int vertex_group_deselect_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_edit_object(C); @@ -1612,12 +1614,12 @@ void OBJECT_OT_vertex_group_deselect(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int vertex_group_copy_exec(bContext *C, wmOperator *op) +static int vertex_group_copy_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; vgroup_duplicate(ob); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); @@ -1647,7 +1649,7 @@ static int vertex_group_levels_exec(bContext *C, wmOperator *op) vgroup_levels(ob, offset, gain); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); @@ -1671,13 +1673,13 @@ void OBJECT_OT_vertex_group_levels(wmOperatorType *ot) RNA_def_float(ot->srna, "gain", 1.f, 0.f, FLT_MAX, "Gain", "Value to multiply weights by.", 0.0f, 10.f); } -static int vertex_group_normalize_exec(bContext *C, wmOperator *op) +static int vertex_group_normalize_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; vgroup_normalize(ob); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); @@ -1705,7 +1707,7 @@ static int vertex_group_normalize_all_exec(bContext *C, wmOperator *op) vgroup_normalize_all(ob, lock_active); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); @@ -1735,7 +1737,7 @@ static int vertex_group_invert_exec(bContext *C, wmOperator *op) int auto_remove= RNA_boolean_get(op->ptr,"auto_remove"); vgroup_invert(ob, auto_assign, auto_remove); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); @@ -1760,13 +1762,13 @@ void OBJECT_OT_vertex_group_invert(wmOperatorType *ot) } -static int vertex_group_blend_exec(bContext *C, wmOperator *op) +static int vertex_group_blend_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; vgroup_blend(ob); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); @@ -1800,7 +1802,7 @@ static int vertex_group_clean_exec(bContext *C, wmOperator *op) if(all_groups) vgroup_clean_all(ob, limit, keep_single); else vgroup_clean(ob, limit, keep_single); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); @@ -1833,7 +1835,7 @@ static int vertex_group_mirror_exec(bContext *C, wmOperator *op) ED_vgroup_mirror(ob, RNA_boolean_get(op->ptr,"mirror_weights"), RNA_boolean_get(op->ptr,"flip_group_names")); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); @@ -1845,7 +1847,7 @@ void OBJECT_OT_vertex_group_mirror(wmOperatorType *ot) /* identifiers */ ot->name= "Mirror Vertex Group"; ot->idname= "OBJECT_OT_vertex_group_mirror"; - ot->description= "Mirror weights, and flip vertex group names, copying when only one side is selected"; + ot->description= "Mirror all vertex groups, flip weights and/or names, editing only selected vertices, flipping when both sides are selected otherwise copy from unselected"; /* api callbacks */ ot->poll= vertex_group_poll_edit; @@ -1856,11 +1858,11 @@ void OBJECT_OT_vertex_group_mirror(wmOperatorType *ot) /* properties */ RNA_def_boolean(ot->srna, "mirror_weights", TRUE, "Mirror Weights", "Mirror weights."); - RNA_def_boolean(ot->srna, "flip_group_names", TRUE, "Flip Groups", "Flip vertex group names while mirroring."); + RNA_def_boolean(ot->srna, "flip_group_names", TRUE, "Flip Groups", "Flip vertex group names."); } -static int vertex_group_copy_to_linked_exec(bContext *C, wmOperator *op) +static int vertex_group_copy_to_linked_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; @@ -1874,7 +1876,7 @@ static int vertex_group_copy_to_linked_exec(bContext *C, wmOperator *op) BLI_duplicatelist(&base->object->defbase, &ob->defbase); base->object->actdef= ob->actdef; - DAG_id_flush_update(&base->object->id, OB_RECALC_DATA); + DAG_id_tag_update(&base->object->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, base->object); WM_event_add_notifier(C, NC_GEOM|ND_DATA, base->object->data); @@ -1901,7 +1903,7 @@ void OBJECT_OT_vertex_group_copy_to_linked(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *op) +static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *UNUSED(op)) { Object *obact= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; @@ -1921,7 +1923,7 @@ void OBJECT_OT_vertex_group_copy_to_selected(wmOperatorType *ot) /* identifiers */ ot->name= "Copy Vertex Group to Selected"; ot->idname= "OBJECT_OT_vertex_group_copy_to_selected"; - ot->description= "Copy Vertex Groups to other selected objects with matching indicies"; + ot->description= "Copy Vertex Groups to other selected objects with matching indices"; /* api callbacks */ ot->poll= vertex_group_poll; @@ -1941,13 +1943,13 @@ static int set_active_group_exec(bContext *C, wmOperator *op) ob->actdef= nr+1; - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob); return OPERATOR_FINISHED; } -static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *ptr, int *free) +static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) { Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; EnumPropertyItem tmp = {0, "", 0, "", ""}; @@ -2097,7 +2099,7 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op) ret = vgroup_do_remap(ob, name_array, op); if (ret != OPERATOR_CANCELLED) { - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob); } @@ -2151,7 +2153,7 @@ static int vgroup_move_exec(bContext *C, wmOperator *op) if (name_array) MEM_freeN(name_array); if (ret != OPERATOR_CANCELLED) { - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob); } |