diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-08-01 16:47:49 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-08-01 16:47:49 +0400 |
commit | 5fa7d1c1b4e7bde1d173caa60af0e273c86b6f0b (patch) | |
tree | 186a794aef722993c7067a657b4d007c62dd669b /source/blender/editors | |
parent | c34f831757e0985b7523b6e5bbfadd7dd6a2c161 (diff) |
2.5: code changes to reduce the usage of G.main and pass it along
or get it from the context instead.
Diffstat (limited to 'source/blender/editors')
37 files changed, 342 insertions, 390 deletions
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 3fc228e1c15..9edcf637cdc 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -389,7 +389,7 @@ static int add_driver_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(CTX_data_main(C), 0); WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX } @@ -440,7 +440,7 @@ static int remove_driver_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(CTX_data_main(C), 0); WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index f60181d7f6c..ea20a5c2c88 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -51,6 +51,7 @@ #include "BKE_constraint.h" #include "BKE_depsgraph.h" #include "BKE_fcurve.h" +#include "BKE_main.h" #include "BKE_nla.h" #include "BKE_global.h" #include "BKE_utildefines.h" @@ -1060,6 +1061,7 @@ static int modify_key_op_poll(bContext *C) static int insert_key_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); KeyingSet *ks= NULL; int type= RNA_int_get(op->ptr, "type"); @@ -1106,7 +1108,7 @@ static int insert_key_exec (bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "Keying Set failed to insert any keyframes"); /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); return OPERATOR_FINISHED; } @@ -1202,6 +1204,7 @@ void ANIM_OT_keyframe_insert_menu (wmOperatorType *ot) static int delete_key_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); KeyingSet *ks= NULL; int type= RNA_int_get(op->ptr, "type"); @@ -1248,7 +1251,7 @@ static int delete_key_exec (bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "Keying Set failed to remove any keyframes"); /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); return OPERATOR_FINISHED; } @@ -1287,6 +1290,7 @@ void ANIM_OT_keyframe_delete (wmOperatorType *ot) static int delete_key_v3d_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap @@ -1315,7 +1319,7 @@ static int delete_key_v3d_exec (bContext *C, wmOperator *op) CTX_DATA_END; /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL); @@ -1343,6 +1347,7 @@ void ANIM_OT_keyframe_delete_v3d (wmOperatorType *ot) static int insert_key_button_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); PointerRNA ptr; PropertyRNA *prop= NULL; @@ -1400,7 +1405,7 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); /* send notifiers that keyframes have been changed */ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); @@ -1430,6 +1435,7 @@ void ANIM_OT_keyframe_insert_button (wmOperatorType *ot) static int delete_key_button_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); PointerRNA ptr; PropertyRNA *prop= NULL; @@ -1470,7 +1476,7 @@ static int delete_key_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); /* send notifiers that keyframes have been changed */ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 301111d22fd..033c4713e01 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -289,6 +289,7 @@ void ANIM_OT_keying_set_path_remove (wmOperatorType *ot) static int add_keyingset_button_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); KeyingSet *ks = NULL; PropertyRNA *prop= NULL; @@ -359,7 +360,7 @@ static int add_keyingset_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); /* for now, only send ND_KEYS for KeyingSets */ WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); @@ -389,6 +390,7 @@ void ANIM_OT_keyingset_button_add (wmOperatorType *ot) static int remove_keyingset_button_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); KeyingSet *ks = NULL; PropertyRNA *prop= NULL; @@ -441,7 +443,7 @@ static int remove_keyingset_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); /* for now, only send ND_KEYS for KeyingSets */ WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 480bade1dc3..3b5c07a8001 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -809,6 +809,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann /* join armature exec is exported for use in object->join objects operator... */ int join_armature_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); bArmature *arm= (ob)? ob->data: NULL; @@ -901,12 +902,12 @@ int join_armature_exec(bContext *C, wmOperator *op) free_pose_channels_hash(pose); } - ED_base_object_free_and_unlink(scene, base); + ED_base_object_free_and_unlink(bmain, scene, base); } } CTX_DATA_END; - DAG_scene_sort(scene); // because we removed object(s) + DAG_scene_sort(bmain, scene); // because we removed object(s) ED_armature_from_edit(ob); ED_armature_edit_free(ob); @@ -1118,6 +1119,7 @@ static void separate_armature_bones (Scene *scene, Object *ob, short sel) /* separate selected bones into their armature */ static int separate_armature_exec (bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); Object *oldob, *newob; @@ -1158,7 +1160,7 @@ static int separate_armature_exec (bContext *C, wmOperator *op) ED_armature_edit_free(obedit); /* 2) duplicate base */ - newbase= ED_object_add_duplicate(scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */ + newbase= ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */ newob= newbase->object; newbase->flag &= ~SELECT; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index d38c91da5c5..16204e9f199 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1119,6 +1119,7 @@ void CU_select_swap(Object *obedit) static int separate_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Nurb *nu, *nu1; Object *oldob, *newob; @@ -1139,7 +1140,7 @@ static int separate_exec(bContext *C, wmOperator *op) WM_cursor_wait(1); /* 1. duplicate the object and data */ - newbase= ED_object_add_duplicate(scene, oldbase, 0); /* 0 = fully linked */ + newbase= ED_object_add_duplicate(bmain, scene, oldbase, 0); /* 0 = fully linked */ ED_base_object_select(newbase, BA_DESELECT); newob= newbase->object; @@ -5543,6 +5544,7 @@ void CURVE_OT_shade_flat(wmOperatorType *ot) int join_curve_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); Curve *cu; @@ -5594,7 +5596,7 @@ int join_curve_exec(bContext *C, wmOperator *op) } } - ED_base_object_free_and_unlink(scene, base); + ED_base_object_free_and_unlink(bmain, scene, base); } } } @@ -5603,7 +5605,7 @@ int join_curve_exec(bContext *C, wmOperator *op) cu= ob->data; addlisttolist(&cu->nurb, &tempbase); - DAG_scene_sort(scene); // because we removed object(s), call before editmode! + DAG_scene_sort(bmain, scene); // because we removed object(s), call before editmode! ED_object_enter_editmode(C, EM_WAITCURSOR); ED_object_exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR|EM_DO_UNDO); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index efa5d6c5dad..f243b4cc497 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -28,24 +28,25 @@ #ifndef ED_OBJECT_H #define ED_OBJECT_H -struct wmKeyConfig; -struct wmKeyMap; -struct Scene; -struct Object; -struct bContext; struct Base; -struct View3D; struct bConstraint; +struct bContext; struct bPoseChannel; +struct Curve; struct KeyBlock; struct Lattice; +struct Main; struct Mesh; -struct Curve; -struct ReportList; struct ModifierData; -struct wmOperatorType; -struct wmOperator; +struct Object; +struct ReportList; +struct Scene; +struct View3D; struct wmEvent; +struct wmKeyConfig; +struct wmKeyMap; +struct wmOperator; +struct wmOperatorType; /* object_edit.c */ struct Object *ED_object_active_context(struct bContext *C); @@ -69,10 +70,10 @@ void ED_base_object_select(struct Base *base, short mode); /* includes notifier */ void ED_base_object_activate(struct bContext *C, struct Base *base); -void ED_base_object_free_and_unlink(struct Scene *scene, struct Base *base); +void ED_base_object_free_and_unlink(struct Main *bmain, struct Scene *scene, struct Base *base); /* single object duplicate, if dupflag==0, fully linked, else it uses the flags given */ -struct Base *ED_object_add_duplicate(struct Scene *scene, struct Base *base, int dupflag); +struct Base *ED_object_add_duplicate(struct Main *bmain, struct Scene *scene, struct Base *base, int dupflag); void ED_object_parent(struct Object *ob, struct Object *parent, int type, const char *substr); @@ -97,7 +98,7 @@ int ED_object_add_generic_invoke(struct bContext *C, struct wmOperator *op, stru int ED_object_add_generic_get_opts(struct bContext *C, struct wmOperator *op, float *loc, float *rot, int *enter_editmode, unsigned int *layer); struct Object *ED_object_add_type(struct bContext *C, int type, float *loc, float *rot, int enter_editmode, unsigned int layer); -void ED_object_single_users(struct Scene *scene, int full); +void ED_object_single_users(struct Main *bmain, struct Scene *scene, int full); /* cleanup */ int object_is_libdata(struct Object *ob); @@ -116,7 +117,7 @@ void object_test_constraints(struct Object *ob); void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con); void ED_object_constraint_update(struct Object *ob); -void ED_object_constraint_dependency_update(struct Scene *scene, struct Object *ob); +void ED_object_constraint_dependency_update(struct Main *bmain, struct Scene *scene, struct Object *ob); /* object_lattice.c */ int mouse_lattice(struct bContext *C, short mval[2], int extend); @@ -132,11 +133,11 @@ enum { MODIFIER_APPLY_SHAPE, } eModifier_Apply_Mode; -struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Scene *scene, struct Object *ob, char *name, int type); -int ED_object_modifier_remove(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md); +struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, char *name, int type); +int ED_object_modifier_remove(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, struct ModifierData *md); int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob, struct ModifierData *md); int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md); -int ED_object_modifier_convert(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md); +int ED_object_modifier_convert(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, struct ModifierData *md); int ED_object_modifier_apply(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md, int mode); int ED_object_modifier_copy(struct ReportList *reports, struct Object *ob, struct ModifierData *md); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 1b600a26001..3d32030326f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -961,6 +961,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr, int void do_constraint_panels(bContext *C, void *arg, int event) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); @@ -972,7 +973,7 @@ void do_constraint_panels(bContext *C, void *arg, int event) break; // no handling case B_CONSTRAINT_CHANGETARGET: if (ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); break; default: break; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 3f943f7b1b0..4b02e4b1e65 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -979,6 +979,7 @@ void UI_make_axis_color(char *src_col, char *dst_col, char axis) /* patching UserDef struct and Themes */ void init_userdef_do_versions(void) { + Main *bmain= G.main; // countall(); /* the UserDef struct is not corrected with do_versions() .... ugh! */ @@ -1013,18 +1014,18 @@ void init_userdef_do_versions(void) if(U.flag & USER_CUSTOM_RANGE) vDM_ColorBand_store(&U.coba_weight); /* signal for derivedmesh to use colorband */ - if (G.main->versionfile <= 191) { + if (bmain->versionfile <= 191) { strcpy(U.plugtexdir, U.textudir); strcpy(U.sounddir, "/"); } /* patch to set Dupli Armature */ - if (G.main->versionfile < 220) { + if (bmain->versionfile < 220) { U.dupflag |= USER_DUP_ARM; } /* added seam, normal color, undo */ - if (G.main->versionfile <= 234) { + if (bmain->versionfile <= 234) { bTheme *btheme; U.uiflag |= USER_GLOBALUNDO; @@ -1047,12 +1048,12 @@ void init_userdef_do_versions(void) } } } - if (G.main->versionfile <= 235) { + if (bmain->versionfile <= 235) { /* illegal combo... */ if (U.flag & USER_LMOUSESELECT) U.flag &= ~USER_TWOBUTTONMOUSE; } - if (G.main->versionfile <= 236) { + if (bmain->versionfile <= 236) { bTheme *btheme; /* new space type */ for(btheme= U.themes.first; btheme; btheme= btheme->next) { @@ -1069,7 +1070,7 @@ void init_userdef_do_versions(void) } } } - if (G.main->versionfile <= 237) { + if (bmain->versionfile <= 237) { bTheme *btheme; /* bone colors */ for(btheme= U.themes.first; btheme; btheme= btheme->next) { @@ -1080,7 +1081,7 @@ void init_userdef_do_versions(void) } } } - if (G.main->versionfile <= 238) { + if (bmain->versionfile <= 238) { bTheme *btheme; /* bone colors */ for(btheme= U.themes.first; btheme; btheme= btheme->next) { @@ -1091,7 +1092,7 @@ void init_userdef_do_versions(void) } } } - if (G.main->versionfile <= 239) { + if (bmain->versionfile <= 239) { bTheme *btheme; for(btheme= U.themes.first; btheme; btheme= btheme->next) { @@ -1105,7 +1106,7 @@ void init_userdef_do_versions(void) } if(U.obcenter_dia==0) U.obcenter_dia= 6; } - if (G.main->versionfile <= 241) { + if (bmain->versionfile <= 241) { bTheme *btheme; for(btheme= U.themes.first; btheme; btheme= btheme->next) { /* Node editor theme, check for alpha==0 is safe, then color was never set */ @@ -1146,7 +1147,7 @@ void init_userdef_do_versions(void) } } - if (G.main->versionfile <= 242) { + if (bmain->versionfile <= 242) { bTheme *btheme; for(btheme= U.themes.first; btheme; btheme= btheme->next) { @@ -1164,11 +1165,11 @@ void init_userdef_do_versions(void) } } } - if (G.main->versionfile <= 243) { + if (bmain->versionfile <= 243) { /* set default number of recently-used files (if not set) */ if (U.recent_files == 0) U.recent_files = 10; } - if (G.main->versionfile < 245 || (G.main->versionfile == 245 && G.main->subversionfile < 3)) { + if (bmain->versionfile < 245 || (bmain->versionfile == 245 && bmain->subversionfile < 3)) { bTheme *btheme; for(btheme= U.themes.first; btheme; btheme= btheme->next) { SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128); @@ -1176,7 +1177,7 @@ void init_userdef_do_versions(void) if(U.coba_weight.tot==0) init_colorband(&U.coba_weight, 1); } - if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 11)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) { bTheme *btheme; for (btheme= U.themes.first; btheme; btheme= btheme->next) { /* these should all use the same colour */ @@ -1189,7 +1190,7 @@ void init_userdef_do_versions(void) SETCOL(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255); } } - if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 13)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 13)) { bTheme *btheme; for (btheme= U.themes.first; btheme; btheme= btheme->next) { /* action channel groups (recolor anyway) */ @@ -1262,10 +1263,10 @@ void init_userdef_do_versions(void) } } } - if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 16)) { + if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 16)) { U.flag |= USER_ADD_VIEWALIGNED|USER_ADD_EDITMODE; } - if ((G.main->versionfile < 247) || (G.main->versionfile == 247 && G.main->subversionfile <= 2)) { + if ((bmain->versionfile < 247) || (bmain->versionfile == 247 && bmain->subversionfile <= 2)) { bTheme *btheme; /* adjust themes */ @@ -1287,7 +1288,7 @@ void init_userdef_do_versions(void) SETCOL(btheme->tseq.vertex_select, col[0], col[1], col[2], 255); } } - if (G.main->versionfile < 250) { + if (bmain->versionfile < 250) { bTheme *btheme; for(btheme= U.themes.first; btheme; btheme= btheme->next) { @@ -1328,7 +1329,7 @@ void init_userdef_do_versions(void) U.ipo_new= BEZT_IPO_BEZ; } - if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 1)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) { bTheme *btheme; for(btheme= U.themes.first; btheme; btheme= btheme->next) { @@ -1351,7 +1352,7 @@ void init_userdef_do_versions(void) } } - if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 3)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 3)) { /* new audio system */ if(U.audiochannels == 0) U.audiochannels = 2; @@ -1369,10 +1370,10 @@ void init_userdef_do_versions(void) U.audiorate = 44100; } - if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 5)) + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 5)) U.gameflags |= USER_DISABLE_VBO; - if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 8)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) { wmKeyMap *km; for(km=U.keymaps.first; km; km=km->next) { @@ -1412,16 +1413,16 @@ void init_userdef_do_versions(void) strcpy(km->idname, "Property Editor"); } } - if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 16)) { + if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 16)) { if(U.wmdrawmethod == USER_DRAW_TRIPLE) U.wmdrawmethod = USER_DRAW_AUTOMATIC; } - if (G.main->versionfile < 252 || (G.main->versionfile == 252 && G.main->subversionfile < 3)) { + if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 3)) { if (U.flag & USER_LMOUSESELECT) U.flag &= ~USER_TWOBUTTONMOUSE; } - if (G.main->versionfile < 252 || (G.main->versionfile == 252 && G.main->subversionfile < 4)) { + if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 4)) { bTheme *btheme; /* default new handle type is auto handles */ @@ -1454,7 +1455,7 @@ void init_userdef_do_versions(void) SETCOLF(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0); } } - if (G.main->versionfile <= 252) { + if (bmain->versionfile <= 252) { bTheme *btheme; /* init new curve colors */ @@ -1463,7 +1464,7 @@ void init_userdef_do_versions(void) SETCOL(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255); } } - if (G.main->versionfile < 252 || (G.main->versionfile == 252 && G.main->subversionfile < 5)) { + if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) { bTheme *btheme; /* interface_widgets.c */ diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index cdcbb5cb461..a63f4995acc 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -1330,7 +1330,7 @@ static EnumPropertyItem prop_separate_types[] = { }; /* return 1: success */ -static int mesh_separate_selected(Scene *scene, Base *editbase) +static int mesh_separate_selected(Main *bmain, Scene *scene, Base *editbase) { EditMesh *em, *emnew; EditVert *eve, *v1; @@ -1372,7 +1372,7 @@ static int mesh_separate_selected(Scene *scene, Base *editbase) */ /* 1 */ - basenew= ED_object_add_duplicate(scene, editbase, 0); /* 0 = fully linked */ + basenew= ED_object_add_duplicate(bmain, scene, editbase, 0); /* 0 = fully linked */ ED_base_object_select(basenew, BA_DESELECT); /* 2 */ @@ -1441,7 +1441,7 @@ static int mesh_separate_selected(Scene *scene, Base *editbase) } /* return 1: success */ -static int mesh_separate_material(Scene *scene, Base *editbase) +static int mesh_separate_material(Main *bmain, Scene *scene, Base *editbase) { Mesh *me= editbase->object->data; EditMesh *em= BKE_mesh_get_editmesh(me); @@ -1453,7 +1453,7 @@ static int mesh_separate_material(Scene *scene, Base *editbase) /* select the material */ EM_select_by_material(em, curr_mat); /* and now separate */ - if(0==mesh_separate_selected(scene, editbase)) { + if(0==mesh_separate_selected(bmain, scene, editbase)) { BKE_mesh_end_editmesh(me, em); return 0; } @@ -1464,7 +1464,7 @@ static int mesh_separate_material(Scene *scene, Base *editbase) } /* return 1: success */ -static int mesh_separate_loose(Scene *scene, Base *editbase) +static int mesh_separate_loose(Main *bmain, Scene *scene, Base *editbase) { Mesh *me; EditMesh *em; @@ -1504,7 +1504,7 @@ static int mesh_separate_loose(Scene *scene, Base *editbase) tot= BLI_countlist(&em->verts); /* and now separate */ - doit= mesh_separate_selected(scene, editbase); + doit= mesh_separate_selected(bmain, scene, editbase); /* with hidden verts this can happen */ if(tot == BLI_countlist(&em->verts)) @@ -1518,16 +1518,17 @@ static int mesh_separate_loose(Scene *scene, Base *editbase) static int mesh_separate_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Base *base= CTX_data_active_base(C); int retval= 0, type= RNA_enum_get(op->ptr, "type"); if(type == 0) - retval= mesh_separate_selected(scene, base); + retval= mesh_separate_selected(bmain, scene, base); else if(type == 1) - retval= mesh_separate_material (scene, base); + retval= mesh_separate_material(bmain, scene, base); else if(type == 2) - retval= mesh_separate_loose(scene, base); + retval= mesh_separate_loose(bmain, scene, base); if(retval) { WM_event_add_notifier(C, NC_GEOM|ND_DATA, base->object->data); diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 87b5c886b4a..47b7b89ff7a 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -92,6 +92,7 @@ return 0 if no join is made (error) and 1 of the join is done */ int join_mesh_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); Material **matar, *ma; @@ -443,7 +444,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* free base, now that data is merged */ if(base->object != ob) - ED_base_object_free_and_unlink(scene, base); + ED_base_object_free_and_unlink(bmain, scene, base); } } CTX_DATA_END; @@ -503,17 +504,17 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* free it's ipo too - both are not actually freed from memory yet as ID-blocks */ if(nkey->ipo) { free_ipo(nkey->ipo); - BLI_remlink(&G.main->ipo, nkey->ipo); + BLI_remlink(&bmain->ipo, nkey->ipo); MEM_freeN(nkey->ipo); } #endif free_key(nkey); - BLI_remlink(&G.main->key, nkey); + BLI_remlink(&bmain->key, nkey); MEM_freeN(nkey); } - DAG_scene_sort(scene); // removed objects, need to rebuild dag before editmode call + DAG_scene_sort(bmain, scene); // removed objects, need to rebuild dag before editmode call ED_object_enter_editmode(C, EM_WAITCURSOR); ED_object_exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR|EM_DO_UNDO); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 50851b57a65..67cae8d4155 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -284,6 +284,7 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, floa /* for object add primitive operators */ 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); Scene *scene= CTX_data_scene(C); Object *ob; @@ -300,8 +301,8 @@ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, int en /* more editor stuff */ ED_object_base_init_transform(C, BASACT, loc, rot); - DAG_scene_sort(scene); - ED_render_id_flush_update(G.main, ob->data); + DAG_scene_sort(bmain, scene); + ED_render_id_flush_update(bmain, ob->data); if(enter_editmode) ED_object_enter_editmode(C, EM_IGNORE_LAYER); @@ -750,6 +751,8 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; if(group) { + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); Object *ob= ED_object_add_type(C, OB_EMPTY, loc, rot, FALSE, layer); rename_id(&ob->id, group->id.name+2); ob->dup_group= group; @@ -757,7 +760,7 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) id_lib_extern(&group->id); /* works without this except if you try render right after, see: 22027 */ - DAG_scene_sort(CTX_data_scene(C)); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, CTX_data_scene(C)); @@ -797,16 +800,17 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot) /* remove base from a specific scene */ /* note: now unlinks constraints as well */ -void ED_base_object_free_and_unlink(Scene *scene, Base *base) +void ED_base_object_free_and_unlink(Main *bmain, Scene *scene, Base *base) { BLI_remlink(&scene->base, base); - free_libblock_us(&G.main->object, base->object); + free_libblock_us(&bmain->object, base->object); if(scene->basact==base) scene->basact= NULL; MEM_freeN(base); } static int object_delete_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); int islamp= 0; @@ -817,14 +821,14 @@ static int object_delete_exec(bContext *C, wmOperator *op) if(base->object->type==OB_LAMP) islamp= 1; /* remove from current scene only */ - ED_base_object_free_and_unlink(scene, base); + ED_base_object_free_and_unlink(bmain, scene, base); } CTX_DATA_END; if(islamp) reshadeall_displist(scene); /* only frees displist */ - DAG_scene_sort(scene); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, scene); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, CTX_data_scene(C)); @@ -859,6 +863,7 @@ static void copy_object__forwardModifierLinks(void *userData, Object *ob, /* after copying objects, copied data should get new pointers */ static void copy_object_set_idnew(bContext *C, int dupflag) { + Main *bmain= CTX_data_main(C); Material *ma, *mao; ID *id; int a; @@ -881,7 +886,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag) /* materials */ if( dupflag & USER_DUP_MAT) { - mao= G.main->mat.first; + mao= bmain->mat.first; while(mao) { if(mao->id.newid) { @@ -915,7 +920,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag) #if 0 // XXX old animation system /* lamps */ if( dupflag & USER_DUP_IPO) { - Lamp *la= G.main->lamp.first; + Lamp *la= bmain->lamp.first; while(la) { if(la->id.newid) { Lamp *lan= (Lamp *)la->id.newid; @@ -931,7 +936,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag) } /* ipos */ - ipo= G.main->ipo.first; + ipo= bmain->ipo.first; while(ipo) { if(ipo->id.lib==NULL && ipo->id.newid) { Ipo *ipon= (Ipo *)ipo->id.newid; @@ -1000,6 +1005,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base) static int object_duplicates_make_real_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); clear_id_newpoins(); @@ -1009,8 +1015,8 @@ static int object_duplicates_make_real_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(scene); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, scene); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SCENE, scene); WM_main_add_notifier(NC_OBJECT|ND_DRAW, NULL); @@ -1089,6 +1095,7 @@ static Base *duplibase_for_convert(Scene *scene, Base *base, Object *ob) static int convert_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Base *basen=NULL, *basact=NULL, *basedel=NULL; Object *ob, *ob1, *newob, *obact= CTX_data_active_object(C); @@ -1214,7 +1221,7 @@ static int convert_exec(bContext *C, wmOperator *op) if (!keep_original) { /* other users */ if(cu->id.us>1) { - for(ob1= G.main->object.first; ob1; ob1=ob1->id.next) { + for(ob1= bmain->object.first; ob1; ob1=ob1->id.next) { if(ob1->data==ob->data) { ob1->type= OB_CURVE; ob1->recalc |= OB_RECALC_ALL; @@ -1321,7 +1328,7 @@ static int convert_exec(bContext *C, wmOperator *op) /* delete original if needed */ if(basedel) { if(!keep_original) - ED_base_object_free_and_unlink(scene, basedel); + ED_base_object_free_and_unlink(bmain, scene, basedel); basedel = NULL; } @@ -1337,13 +1344,13 @@ static int convert_exec(bContext *C, wmOperator *op) base= base->next; if (ob->type == OB_MBALL) { - ED_base_object_free_and_unlink(scene, tmpbase); + ED_base_object_free_and_unlink(bmain, scene, tmpbase); } } } /* delete object should renew depsgraph */ - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } // XXX ED_object_enter_editmode(C, 0); @@ -1357,7 +1364,7 @@ static int convert_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER|ND_DATA, BASACT->object); } - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_SCENE|NC_OBJECT|ND_DRAW, scene); /* is NC_SCENE needed ? */ return OPERATOR_FINISHED; @@ -1394,7 +1401,7 @@ void OBJECT_OT_convert(wmOperatorType *ot) /* used below, assumes id.new is correct */ /* leaves selection of base/object unaltered */ -static Base *object_add_duplicate_internal(Scene *scene, Base *base, int dupflag) +static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base, int dupflag) { Base *basen= NULL; Material ***matarar; @@ -1417,7 +1424,7 @@ static Base *object_add_duplicate_internal(Scene *scene, Base *base, int dupflag if(basen->flag & OB_FROMGROUP) { Group *group; - for(group= G.main->group.first; group; group= group->id.next) { + for(group= bmain->group.first; group; group= group->id.next) { if(object_in_group(ob, group)) add_to_group(group, obn, scene, basen); } @@ -1596,7 +1603,7 @@ static Base *object_add_duplicate_internal(Scene *scene, Base *base, int dupflag /* single object duplicate, if dupflag==0, fully linked, else it uses the flags given */ /* leaves selection of base/object unaltered */ -Base *ED_object_add_duplicate(Scene *scene, Base *base, int dupflag) +Base *ED_object_add_duplicate(Main *bmain, Scene *scene, Base *base, int dupflag) { Base *basen; Object *ob; @@ -1604,15 +1611,15 @@ Base *ED_object_add_duplicate(Scene *scene, Base *base, int dupflag) clear_id_newpoins(); clear_sca_new_poins(); /* sensor/contr/act */ - basen= object_add_duplicate_internal(scene, base, dupflag); + basen= object_add_duplicate_internal(bmain, scene, base, dupflag); if (basen == NULL) { return NULL; } ob= basen->object; - DAG_scene_sort(scene); - ED_render_id_flush_update(G.main, ob->data); + DAG_scene_sort(bmain, scene); + ED_render_id_flush_update(bmain, ob->data); return basen; } @@ -1620,6 +1627,7 @@ Base *ED_object_add_duplicate(Scene *scene, Base *base, int dupflag) /* contextual operator dupli */ static int duplicate_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); int linked= RNA_boolean_get(op->ptr, "linked"); int dupflag= (linked)? 0: U.dupflag; @@ -1628,7 +1636,7 @@ static int duplicate_exec(bContext *C, wmOperator *op) clear_sca_new_poins(); /* sensor/contr/act */ CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { - Base *basen= object_add_duplicate_internal(scene, base, dupflag); + Base *basen= object_add_duplicate_internal(bmain, scene, base, dupflag); /* note that this is safe to do with this context iterator, the list is made in advance */ @@ -1642,14 +1650,14 @@ static int duplicate_exec(bContext *C, wmOperator *op) if(BASACT==base) ED_base_object_activate(C, basen); - ED_render_id_flush_update(G.main, basen->object->data); + ED_render_id_flush_update(bmain, basen->object->data); } CTX_DATA_END; copy_object_set_idnew(C, dupflag); - DAG_scene_sort(scene); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, scene); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); @@ -1697,6 +1705,7 @@ static int add_named_poll(bContext *C) static int add_named_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Base *basen, *base; Object *ob; @@ -1718,7 +1727,7 @@ static int add_named_exec(bContext *C, wmOperator *op) clear_id_newpoins(); clear_sca_new_poins(); /* sensor/contr/act */ - basen= object_add_duplicate_internal(scene, base, dupflag); + basen= object_add_duplicate_internal(bmain, scene, base, dupflag); if (basen == NULL) { MEM_freeN(base); @@ -1732,8 +1741,8 @@ static int add_named_exec(bContext *C, wmOperator *op) copy_object_set_idnew(C, dupflag); - DAG_scene_sort(scene); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, scene); + DAG_ids_flush_update(bmain, 0); MEM_freeN(base); diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index b1dc41531ef..8f83a412c96 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -779,12 +779,12 @@ void ED_object_constraint_update(Object *ob) else DAG_id_flush_update(&ob->id, OB_RECALC_OB); } -void ED_object_constraint_dependency_update(Scene *scene, Object *ob) +void ED_object_constraint_dependency_update(Main *bmain, Scene *scene, Object *ob) { ED_object_constraint_update(ob); if(ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } static int constraint_poll(bContext *C) @@ -931,8 +931,9 @@ void CONSTRAINT_OT_move_up (wmOperatorType *ot) static int pose_constraints_clear_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_active_object(C); /* free constraints for all selected bones */ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones) @@ -943,7 +944,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* force depsgraph to get recalculated since relationships removed */ - DAG_scene_sort(scene); /* sort order of objects */ + DAG_scene_sort(bmain, scene); /* sort order of objects */ /* do updates */ DAG_id_flush_update(&ob->id, OB_RECALC_DATA); @@ -967,6 +968,7 @@ void POSE_OT_constraints_clear(wmOperatorType *ot) static int object_constraints_clear_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); /* do freeing */ @@ -978,7 +980,7 @@ static int object_constraints_clear_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* force depsgraph to get recalculated since relationships removed */ - DAG_scene_sort(scene); /* sort order of objects */ + DAG_scene_sort(bmain, scene); /* sort order of objects */ /* do updates */ WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL); @@ -1002,8 +1004,9 @@ void OBJECT_OT_constraints_clear(wmOperatorType *ot) static int pose_constraint_copy_exec(bContext *C, wmOperator *op) { - bPoseChannel *pchan = CTX_data_active_pose_bone(C); + Main *bmain= CTX_data_main(C); Scene *scene = CTX_data_scene(C); + bPoseChannel *pchan = CTX_data_active_pose_bone(C); /* don't do anything if bone doesn't exist or doesn't have any constraints */ if (ELEM(NULL, pchan, pchan->constraints.first)) { @@ -1021,7 +1024,7 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* force depsgraph to get recalculated since new relationships added */ - DAG_scene_sort(scene); /* sort order of objects/bones */ + DAG_scene_sort(bmain, scene); /* sort order of objects/bones */ return OPERATOR_FINISHED; } @@ -1043,8 +1046,9 @@ void POSE_OT_constraints_copy(wmOperatorType *ot) static int object_constraint_copy_exec(bContext *C, wmOperator *op) { - Object *obact = ED_object_active_context(C); + Main *bmain= CTX_data_main(C); Scene *scene = CTX_data_scene(C); + Object *obact = ED_object_active_context(C); /* copy all constraints from active object to all selected objects */ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) @@ -1056,7 +1060,7 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* force depsgraph to get recalculated since new relationships added */ - DAG_scene_sort(scene); /* sort order of objects */ + DAG_scene_sort(bmain, scene); /* sort order of objects */ return OPERATOR_FINISHED; } @@ -1219,6 +1223,7 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o /* used by add constraint operators to add the constraint required */ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase *list, int type, short setTarget) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); bPoseChannel *pchan; bConstraint *con; @@ -1316,7 +1321,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase /* force depsgraph to get recalculated since new relationships added */ - DAG_scene_sort(scene); /* sort order of objects */ + DAG_scene_sort(bmain, scene); /* sort order of objects */ if ((ob->type==OB_ARMATURE) && (pchan)) { ob->pose->flag |= POSE_RECALC; /* sort pose channels */ diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 0d3ebc7f669..18da264336e 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -137,6 +137,7 @@ Object *ED_object_active_context(bContext *C) /* ********* clear/set restrict view *********/ static int object_hide_view_clear_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); ScrArea *sa= CTX_wm_area(C); View3D *v3d= sa->spacedata.first; Scene *scene= CTX_data_scene(C); @@ -153,7 +154,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op) } } if (changed) { - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } @@ -178,6 +179,7 @@ void OBJECT_OT_hide_view_clear(wmOperatorType *ot) static int object_hide_view_set_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); short changed = 0; int unselected= RNA_boolean_get(op->ptr, "unselected"); @@ -204,7 +206,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) CTX_DATA_END; if (changed) { - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); @@ -965,144 +967,6 @@ void special_editmenu(Scene *scene, View3D *v3d) } -/* Change subdivision or particle properties of mesh object ob, if level==-1 - * then toggle subsurf, else set to level set allows to toggle multiple - * selections */ - -static void object_has_subdivision_particles(Object *ob, int *havesubdiv, int *havepart, int depth) -{ - if(ob->type==OB_MESH) { - if(modifiers_findByType(ob, eModifierType_Subsurf)) - *havesubdiv= 1; - if(modifiers_findByType(ob, eModifierType_ParticleSystem)) - *havepart= 1; - } - - if(ob->dup_group && depth <= 4) { - GroupObject *go; - - for(go= ob->dup_group->gobject.first; go; go= go->next) - object_has_subdivision_particles(go->ob, havesubdiv, havepart, depth+1); - } -} - -static void object_flip_subdivison_particles(Scene *scene, Object *ob, int *set, int level, int mode, int particles, int depth) -{ - ModifierData *md; - - if(ob->type==OB_MESH) { - if(particles) { - for(md=ob->modifiers.first; md; md=md->next) { - if(md->type == eModifierType_ParticleSystem) { - ParticleSystemModifierData *psmd = (ParticleSystemModifierData*)md; - - if(*set == -1) - *set= psmd->modifier.mode&(mode); - - if (*set) - psmd->modifier.mode &= ~(mode); - else - psmd->modifier.mode |= (mode); - } - } - } - else { - md = modifiers_findByType(ob, eModifierType_Subsurf); - - if (md) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; - - if (level == -1) { - if(*set == -1) - *set= smd->modifier.mode&(mode); - - if (*set) - smd->modifier.mode &= ~(mode); - else - smd->modifier.mode |= (mode); - } else { - smd->levels = level; - } - } - else if(depth == 0 && *set != 0) { - SubsurfModifierData *smd = (SubsurfModifierData*) modifier_new(eModifierType_Subsurf); - - BLI_addtail(&ob->modifiers, smd); - modifier_unique_name(&ob->modifiers, (ModifierData*)smd); - - if (level!=-1) { - smd->levels = level; - } - - if(*set == -1) - *set= 1; - } - } - - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); - } - - if(ob->dup_group && depth<=4) { - GroupObject *go; - - for(go= ob->dup_group->gobject.first; go; go= go->next) - object_flip_subdivison_particles(scene, go->ob, set, level, mode, particles, depth+1); - } -} - -/* Change subdivision properties of mesh object ob, if -* level==-1 then toggle subsurf, else set to level. -*/ - -void flip_subdivison(Scene *scene, View3D *v3d, int level) -{ - Base *base; - int set= -1; - int mode, pupmode, particles= 0, havesubdiv= 0, havepart= 0; - int alt= 0; // XXX - - if(alt) - mode= eModifierMode_Realtime; - else - mode= eModifierMode_Render|eModifierMode_Realtime; - - if(level == -1) { - if (scene->obedit) { // XXX get from context - object_has_subdivision_particles(scene->obedit, &havesubdiv, &havepart, 0); - } else { - for(base= scene->base.first; base; base= base->next) { - if(((level==-1) && (TESTBASE(v3d, base))) || (TESTBASELIB(v3d, base))) { - object_has_subdivision_particles(base->object, &havesubdiv, &havepart, 0); - } - } - } - } - else - havesubdiv= 1; - - if(havesubdiv && havepart) { - pupmode= pupmenu("Switch%t|Subsurf %x1|Particle Systems %x2"); - if(pupmode <= 0) - return; - else if(pupmode == 2) - particles= 1; - } - else if(havepart) - particles= 1; - - if (scene->obedit) { // XXX get from context - object_flip_subdivison_particles(scene, scene->obedit, &set, level, mode, particles, 0); - } else { - for(base= scene->base.first; base; base= base->next) { - if(((level==-1) && (TESTBASE(v3d, base))) || (TESTBASELIB(v3d, base))) { - object_flip_subdivison_particles(scene, base->object, &set, level, mode, particles, 0); - } - } - } - - DAG_ids_flush_update(0); -} - static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) { //XXX no longer used - to be removed - replaced by game_properties_copy_exec @@ -1197,7 +1061,7 @@ static void copymenu_logicbricks(Scene *scene, View3D *v3d, Object *ob) } } -static void copymenu_modifiers(Scene *scene, View3D *v3d, Object *ob) +static void copymenu_modifiers(Main *bmain, Scene *scene, View3D *v3d, Object *ob) { Base *base; int i, event; @@ -1296,7 +1160,7 @@ static void copymenu_modifiers(Scene *scene, View3D *v3d, Object *ob) // if(errorstr) notice(errorstr); - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } @@ -1344,7 +1208,7 @@ static void copy_texture_space(Object *to, Object *ob) } -void copy_attr(Scene *scene, View3D *v3d, short event) +void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) { Object *ob; Base *base; @@ -1369,7 +1233,7 @@ void copy_attr(Scene *scene, View3D *v3d, short event) return; } else if(event==24) { - copymenu_modifiers(scene, v3d, ob); + copymenu_modifiers(bmain, scene, v3d, ob); return; } @@ -1587,12 +1451,12 @@ void copy_attr(Scene *scene, View3D *v3d, short event) } if(do_scene_sort) - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); } -void copy_attr_menu(Scene *scene, View3D *v3d) +void copy_attr_menu(Main *bmain, Scene *scene, View3D *v3d) { Object *ob; short event; @@ -1643,7 +1507,7 @@ void copy_attr_menu(Scene *scene, View3D *v3d) event= pupmenu(str); if(event<= 0) return; - copy_attr(scene, v3d, event); + copy_attr(bmain, scene, v3d, event); } /* ********************************************** */ diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index ba609bd9bb3..b0a6c6471a2 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -60,6 +60,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= OBACT; Group *group; @@ -70,7 +71,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) /* linking to same group requires its own loop so we can avoid looking up the active objects groups each time */ - for(group= G.main->group.first; group; group=group->id.next) { + for(group= bmain->group.first; group; group=group->id.next) { if(object_in_group(ob, group)) { /* Assign groups to selected objects */ CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { @@ -83,7 +84,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) if(!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups"); - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -106,6 +107,7 @@ void GROUP_OT_objects_add_active(wmOperatorType *ot) static int objects_remove_active_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= OBACT; Group *group; @@ -116,7 +118,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) /* linking to same group requires its own loop so we can avoid looking up the active objects groups each time */ - for(group= G.main->group.first; group; group=group->id.next) { + for(group= bmain->group.first; group; group=group->id.next) { if(object_in_group(ob, group)) { /* Assign groups to selected objects */ CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { @@ -129,7 +131,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) if(!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups"); - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -152,6 +154,7 @@ void GROUP_OT_objects_remove_active(wmOperatorType *ot) static int group_objects_remove_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Group *group= NULL; @@ -162,7 +165,7 @@ static int group_objects_remove_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -185,6 +188,7 @@ void GROUP_OT_objects_remove(wmOperatorType *ot) static int group_create_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Group *group= NULL; char name[32]; /* id name */ @@ -198,7 +202,7 @@ static int group_create_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL); return OPERATOR_FINISHED; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 88e463039a1..fefefae586c 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -45,6 +45,7 @@ #include "BKE_context.h" #include "BKE_customdata.h" #include "BKE_depsgraph.h" +#include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object.h" @@ -413,7 +414,7 @@ static Object *add_hook_object_new(Scene *scene, Object *obedit) return ob; } -static void add_hook_object(Scene *scene, Object *obedit, Object *ob, int mode) +static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob, int mode) { ModifierData *md=NULL; HookModifierData *hmd = NULL; @@ -459,11 +460,12 @@ static void add_hook_object(Scene *scene, Object *obedit, Object *ob, int mode) mul_serie_m4(hmd->parentinv, ob->imat, obedit->obmat, NULL, NULL, NULL, NULL, NULL, NULL); - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } static int object_add_hook_selob_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); Object *obsel=NULL; @@ -482,7 +484,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - add_hook_object(scene, obedit, obsel, OBJECT_ADDHOOK_SELOB); + add_hook_object(bmain, scene, obedit, obsel, OBJECT_ADDHOOK_SELOB); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, obedit); return OPERATOR_FINISHED; @@ -505,10 +507,11 @@ void OBJECT_OT_hook_add_selobj(wmOperatorType *ot) static int object_add_hook_newob_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); - add_hook_object(scene, obedit, NULL, OBJECT_ADDHOOK_NEWOB); + add_hook_object(bmain, scene, obedit, NULL, OBJECT_ADDHOOK_NEWOB); WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, obedit); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 0661b675668..a54ed9bd239 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -53,6 +53,7 @@ #include "BKE_global.h" #include "BKE_key.h" #include "BKE_lattice.h" +#include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_multires.h" @@ -77,7 +78,7 @@ /******************************** API ****************************/ -ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, char *name, int type) +ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, char *name, int type) { ModifierData *md=NULL, *new_md=NULL; ModifierTypeInfo *mti = modifierType_getInfo(type); @@ -129,10 +130,10 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object * ob->pd= object_add_collision_fields(0); ob->pd->deflect= 1; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } else if(type == eModifierType_Surface) - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } DAG_id_flush_update(&ob->id, OB_RECALC_DATA); @@ -140,7 +141,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object * return new_md; } -int ED_object_modifier_remove(ReportList *reports, Scene *scene, Object *ob, ModifierData *md) +int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md) { ModifierData *obmd; @@ -175,13 +176,13 @@ int ED_object_modifier_remove(ReportList *reports, Scene *scene, Object *ob, Mod if(ob->pd) ob->pd->deflect= 0; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } else if(md->type == eModifierType_Surface) { if(ob->pd && ob->pd->shape == PFIELD_SHAPE_SURFACE) ob->pd->shape = PFIELD_SHAPE_PLANE; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); } else if(md->type == eModifierType_Smoke) { ob->dt = OB_TEXTURE; @@ -243,7 +244,7 @@ int ED_object_modifier_move_down(ReportList *reports, Object *ob, ModifierData * return 1; } -int ED_object_modifier_convert(ReportList *reports, Scene *scene, Object *ob, ModifierData *md) +int ED_object_modifier_convert(ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md) { Object *obn; ParticleSystem *psys; @@ -341,7 +342,7 @@ int ED_object_modifier_convert(ReportList *reports, Scene *scene, Object *ob, Mo } } - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); return 1; } @@ -500,11 +501,12 @@ int ED_object_modifier_copy(ReportList *reports, Object *ob, ModifierData *md) static int modifier_add_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob = ED_object_active_context(C); int type= RNA_enum_get(op->ptr, "type"); - if(!ED_object_modifier_add(op->reports, scene, ob, NULL, type)) + if(!ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, type)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); @@ -626,11 +628,12 @@ static ModifierData *edit_modifier_property_get(bContext *C, wmOperator *op, Obj 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); - if(!ob || !md || !ED_object_modifier_remove(op->reports, scene, ob, md)) + 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); @@ -792,11 +795,12 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) 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); - if(!ob || !md || !ED_object_modifier_convert(op->reports, scene, ob, md)) + 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); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 8d488eeabac..463db871f55 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -97,6 +97,7 @@ static int vertex_parent_set_poll(bContext *C) static int vertex_parent_set_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); EditVert *eve; @@ -230,7 +231,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_OBJECT, NULL); @@ -295,6 +296,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); GroupObject *go; Scene *scene= CTX_data_scene(C); @@ -338,7 +340,7 @@ static int make_proxy_exec (bContext *C, wmOperator *op) object_make_proxy(newob, ob, gob); /* depsgraph flushes are needed for the new data */ - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); DAG_id_flush_update(&newob->id, OB_RECALC_ALL); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, newob); } @@ -413,6 +415,8 @@ static EnumPropertyItem prop_clear_parent_types[] = { /* note, poll should check for editable scene */ static int parent_clear_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); int type= RNA_enum_get(op->ptr, "type"); CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { @@ -431,8 +435,8 @@ static int parent_clear_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(CTX_data_scene(C)); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, scene); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -517,6 +521,7 @@ void ED_object_parent(Object *ob, Object *par, int type, const char *substr) 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); bPoseChannel *pchan= NULL; @@ -594,15 +599,15 @@ static int parent_set_exec(bContext *C, wmOperator *op) switch (partype) { case PAR_CURVE: /* curve deform */ - md= ED_object_modifier_add(op->reports, scene, ob, NULL, eModifierType_Curve); + md= ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, eModifierType_Curve); ((CurveModifierData *)md)->object= par; break; case PAR_LATTICE: /* lattice deform */ - md= ED_object_modifier_add(op->reports, scene, ob, NULL, eModifierType_Lattice); + md= ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, eModifierType_Lattice); ((LatticeModifierData *)md)->object= par; break; default: /* armature deform */ - md= ED_object_modifier_add(op->reports, scene, ob, NULL, eModifierType_Armature); + md= ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, eModifierType_Armature); ((ArmatureModifierData *)md)->object= par; break; } @@ -657,8 +662,8 @@ static int parent_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(scene); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, scene); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -719,6 +724,7 @@ 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); par->recalc |= OB_RECALC_OB; @@ -745,8 +751,8 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(CTX_data_scene(C)); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, CTX_data_scene(C)); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -772,6 +778,7 @@ void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot) static int object_slow_parent_clear_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { @@ -786,7 +793,7 @@ static int object_slow_parent_clear_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SCENE, scene); return OPERATOR_FINISHED; @@ -813,6 +820,7 @@ void OBJECT_OT_slow_parent_clear(wmOperatorType *ot) static int object_slow_parent_set_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { @@ -824,7 +832,7 @@ static int object_slow_parent_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SCENE, scene); return OPERATOR_FINISHED; @@ -858,6 +866,8 @@ static EnumPropertyItem prop_clear_track_types[] = { /* note, poll should check for editable scene */ static int object_track_clear_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); int type= RNA_enum_get(op->ptr, "type"); if(CTX_data_edit_object(C)) { @@ -883,8 +893,8 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_ids_flush_update(0); - DAG_scene_sort(CTX_data_scene(C)); + DAG_ids_flush_update(bmain, 0); + DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -920,6 +930,7 @@ static EnumPropertyItem prop_make_track_types[] = { 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); @@ -987,8 +998,8 @@ static int track_set_exec(bContext *C, wmOperator *op) CTX_DATA_END; } - DAG_scene_sort(scene); - DAG_ids_flush_update(0); + DAG_scene_sort(bmain, scene); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -1057,6 +1068,7 @@ static int move_to_layer_invoke(bContext *C, wmOperator *op, wmEvent *event) static int move_to_layer_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); View3D *v3d= CTX_wm_view3d(C); unsigned int lay, local; @@ -1097,7 +1109,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 ? */ - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); return OPERATOR_FINISHED; } @@ -1123,10 +1135,10 @@ void OBJECT_OT_move_to_layer(wmOperatorType *ot) /************************** Link to Scene Operator *****************************/ -void link_to_scene(unsigned short nr) +void link_to_scene(Main *bmain, unsigned short nr) { #if 0 - Scene *sce= (Scene*) BLI_findlink(&G.main->scene, G.curscreen->scenenr-1); + Scene *sce= (Scene*) BLI_findlink(&bmain->scene, G.curscreen->scenenr-1); Base *base, *nbase; if(sce==0) return; @@ -1146,6 +1158,7 @@ void link_to_scene(unsigned short nr) static int make_links_scene_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene")); if(scene_to==NULL) { @@ -1174,7 +1187,7 @@ static int make_links_scene_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); /* one day multiple scenes will be visible, then we should have some update function for them */ return OPERATOR_FINISHED; @@ -1214,6 +1227,7 @@ static int allow_make_links_data(int ev, Object *ob, Object *obt) static int make_links_data_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); int event = RNA_int_get(op->ptr, "type"); Object *ob; ID *id; @@ -1266,7 +1280,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C)); return OPERATOR_FINISHED; } @@ -1396,7 +1410,7 @@ void new_id_matar(Material **matar, int totcol) } } -void single_obdata_users(Scene *scene, int flag) +void single_obdata_users(Main *bmain, Scene *scene, int flag) { Object *ob; Lamp *la; @@ -1512,7 +1526,7 @@ void single_obdata_users(Scene *scene, int flag) } } - me= G.main->mesh.first; + me= bmain->mesh.first; while(me) { ID_NEW(me->texcomesh); me= me->id.next; @@ -1610,10 +1624,9 @@ void do_single_tex_user(Tex **from) } } -void single_tex_users_expand() +void single_tex_users_expand(Main *bmain) { /* only when 'parent' blocks are LIB_NEW */ - Main *bmain= G.main; Material *ma; Lamp *la; World *wo; @@ -1650,10 +1663,9 @@ void single_tex_users_expand() } } -static void single_mat_users_expand(void) +static void single_mat_users_expand(Main *bmain) { /* only when 'parent' blocks are LIB_NEW */ - Main *bmain= G.main; Object *ob; Mesh *me; Curve *cu; @@ -1686,14 +1698,14 @@ static void single_mat_users_expand(void) } /* used for copying scenes */ -void ED_object_single_users(Scene *scene, int full) +void ED_object_single_users(Main *bmain, Scene *scene, int full) { single_object_users(scene, NULL, 0); if(full) { - single_obdata_users(scene, 0); - single_mat_users_expand(); - single_tex_users_expand(); + single_obdata_users(bmain, scene, 0); + single_mat_users_expand(bmain); + single_tex_users_expand(bmain); } clear_id_newpoins(); @@ -1828,6 +1840,7 @@ void OBJECT_OT_make_local(wmOperatorType *ot) static int make_single_user_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); View3D *v3d= CTX_wm_view3d(C); /* ok if this is NULL */ int flag= RNA_enum_get(op->ptr, "type"); /* 0==ALL, SELECTED==selected objecs */ @@ -1836,7 +1849,7 @@ static int make_single_user_exec(bContext *C, wmOperator *op) single_object_users(scene, v3d, flag); if(RNA_boolean_get(op->ptr, "obdata")) - single_obdata_users(scene, flag); + single_obdata_users(bmain, scene, flag); if(RNA_boolean_get(op->ptr, "material")) single_mat_users(scene, flag, FALSE); @@ -1885,6 +1898,7 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *event) { + Main *bmain= CTX_data_main(C); Base *base= ED_view3d_give_base_under_cursor(C, event->mval); Material *ma; char name[32]; @@ -1896,7 +1910,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *even assign_material(base->object, ma, 1); - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C)); return OPERATOR_FINISHED; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index bd23d3a4b67..d7961a8cd2b 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -68,6 +68,7 @@ static int object_location_clear_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, "Location"); @@ -102,7 +103,7 @@ static int object_location_clear_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* this is needed so children are also updated */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); @@ -126,6 +127,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= ANIM_builtin_keyingset_get_named(NULL, "Rotation"); @@ -244,7 +246,7 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* this is needed so children are also updated */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); @@ -268,6 +270,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= ANIM_builtin_keyingset_get_named(NULL, "Scaling"); @@ -307,7 +310,7 @@ static int object_scale_clear_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* this is needed so children are also updated */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); @@ -331,6 +334,7 @@ void OBJECT_OT_scale_clear(wmOperatorType *ot) static int object_origin_clear_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); float *v1, *v3, mat[3][3]; int armature_clear= 0; @@ -348,7 +352,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(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); @@ -767,7 +771,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - for (tob= G.main->object.first; tob; tob= tob->id.next) { + for (tob= bmain->object.first; tob; tob= tob->id.next) { if(tob->data) ((ID *)tob->data)->flag &= ~LIB_DOIT; } @@ -921,14 +925,14 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - for (tob= G.main->object.first; tob; tob= tob->id.next) { + for (tob= bmain->object.first; tob; tob= tob->id.next) { if(tob->data && (((ID *)tob->data)->flag & LIB_DOIT)) { tob->recalc= OB_RECALC_OB|OB_RECALC_DATA; } } if (tot_change) { - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); } diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c index 37de0d8f873..a18890881a8 100644 --- a/source/blender/editors/physics/particle_boids.c +++ b/source/blender/editors/physics/particle_boids.c @@ -35,6 +35,7 @@ #include "BKE_boids.h" #include "BKE_context.h" #include "BKE_depsgraph.h" +#include "BKE_main.h" #include "BKE_particle.h" #include "BLI_listbase.h" @@ -99,6 +100,7 @@ void BOID_OT_rule_add(wmOperatorType *ot) } static int rule_del_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; @@ -125,7 +127,7 @@ static int rule_del_exec(bContext *C, wmOperator *op) if(rule) rule->flag |= BOIDRULE_CURRENT; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); DAG_id_flush_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); @@ -266,6 +268,7 @@ void BOID_OT_state_add(wmOperatorType *ot) } static int state_del_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; @@ -297,7 +300,7 @@ static int state_del_exec(bContext *C, wmOperator *op) state->flag |= BOIDSTATE_CURRENT; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); DAG_id_flush_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 059805fdf2d..ba5d1ee5250 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -166,7 +166,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *op) psys_check_boid_data(psys); - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); @@ -193,6 +193,7 @@ void PARTICLE_OT_new(wmOperatorType *ot) static int new_particle_target_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; @@ -214,7 +215,7 @@ static int new_particle_target_exec(bContext *C, wmOperator *op) BLI_addtail(&psys->targets, pt); - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); @@ -238,6 +239,7 @@ void PARTICLE_OT_new_target(wmOperatorType *ot) static int remove_particle_target_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; @@ -262,7 +264,7 @@ static int remove_particle_target_exec(bContext *C, wmOperator *op) if(pt) pt->flag |= PTARGET_CURRENT; - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 7110c3aa7a7..b5392f6dede 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -403,6 +403,7 @@ static int screen_render_exec(bContext *C, wmOperator *op) Render *re= RE_NewRender(scene->id.name); Image *ima; View3D *v3d= CTX_wm_view3d(C); + Main *mainp= G.main; //BKE_undo_get_main(&scene); int lay= (v3d)? v3d->lay: scene->lay; if(re==NULL) { @@ -418,9 +419,11 @@ static int screen_render_exec(bContext *C, wmOperator *op) BKE_image_backup_render(scene, ima); if(RNA_boolean_get(op->ptr, "animation")) - RE_BlenderAnim(re, scene, lay, scene->r.sfra, scene->r.efra, scene->r.frame_step, op->reports); + RE_BlenderAnim(re, mainp, scene, lay, scene->r.sfra, scene->r.efra, scene->r.frame_step, op->reports); else - RE_BlenderFrame(re, scene, NULL, lay, scene->r.cfra); + RE_BlenderFrame(re, mainp, scene, NULL, lay, scene->r.cfra); + + //free_main(mainp); // no redraw needed, we leave state as we entered it ED_update_for_newframe(C, 1); @@ -555,19 +558,18 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec static void render_startjob(void *rjv, short *stop, short *do_update, float *progress) { RenderJob *rj= rjv; -// Main *mainp= BKE_undo_get_main(&rj->scene); + Main *mainp= G.main; //BKE_undo_get_main(&rj->scene); rj->stop= stop; rj->do_update= do_update; rj->progress= progress; if(rj->anim) - RE_BlenderAnim(rj->re, rj->scene, rj->lay, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step, rj->reports); + RE_BlenderAnim(rj->re, mainp, rj->scene, rj->lay, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step, rj->reports); else - RE_BlenderFrame(rj->re, rj->scene, rj->srl, rj->lay, rj->scene->r.cfra); + RE_BlenderFrame(rj->re, mainp, rj->scene, rj->srl, rj->lay, rj->scene->r.cfra); -// if(mainp) -// free_main(mainp); + //free_main(mainp); } static void render_endjob(void *rjv) diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 5881d50c309..524e36b3fc9 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -241,6 +241,7 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op) static void screen_opengl_render_end(bContext *C, OGLRender *oglrender) { + Main *bmain= CTX_data_main(C); Scene *scene= oglrender->scene; if(oglrender->mh) { @@ -250,7 +251,7 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender) if(oglrender->timer) { /* exec will not have a timer */ scene->r.cfra= oglrender->cfrao; - scene_update_for_newframe(scene, screen_opengl_layers(oglrender)); + scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), oglrender->timer); } @@ -297,6 +298,7 @@ static int screen_opengl_render_anim_initialize(bContext *C, wmOperator *op) } static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); OGLRender *oglrender= op->customdata; Scene *scene= oglrender->scene; ImBuf *ibuf; @@ -316,11 +318,11 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) if(lay & 0xFF000000) lay &= 0xFF000000; - scene_update_for_newframe(scene, lay); + scene_update_for_newframe(bmain, scene, lay); CFRA++; } - scene_update_for_newframe(scene, screen_opengl_layers(oglrender)); + scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); if(view_context) { if(oglrender->rv3d->persp==RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) { diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 4bb1f630dad..d4c90a7f24e 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -704,7 +704,7 @@ void BIF_view3d_previewrender_clear(ScrArea *sa) } /* afterqueue call */ -void BIF_view3d_previewrender(Scene *scene, ScrArea *sa) +void BIF_view3d_previewrender(Main *bmain, Scene *scene, ScrArea *sa) { View3D *v3d= sa->spacedata.first; RegionView3D *rv3d= NULL; // XXX @@ -804,7 +804,7 @@ void BIF_view3d_previewrender(Scene *scene, ScrArea *sa) /* database can have created render-resol data... */ if(rstats->convertdone) - DAG_scene_flush_update(scene, scene->lay, 0); + DAG_scene_flush_update(bmain, scene, scene->lay, 0); //printf("dbase update\n"); } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 5082992aaba..78ec4fe3a01 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1727,6 +1727,7 @@ void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh) /* results in fully updated anim system */ void ED_update_for_newframe(const bContext *C, int mute) { + Main *bmain= CTX_data_main(C); bScreen *screen= CTX_wm_screen(C); Scene *scene= CTX_data_scene(C); @@ -1750,7 +1751,7 @@ void ED_update_for_newframe(const bContext *C, int mute) /* this function applies the changes too */ /* XXX future: do all windows */ - scene_update_for_newframe(scene, BKE_screen_visible_layers(screen, scene)); /* BKE_scene.h */ + scene_update_for_newframe(bmain, scene, BKE_screen_visible_layers(screen, scene)); /* BKE_scene.h */ //if ( (CFRA>1) && (!mute) && (scene->r.audio.flag & AUDIO_SCRUB)) // audiostream_scrub( CFRA ); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index c8192996127..b085c8178b0 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2838,9 +2838,9 @@ static int scene_new_exec(bContext *C, wmOperator *op) /* these can't be handled in blenkernel curently, so do them here */ if(type == SCE_COPY_LINK_DATA) - ED_object_single_users(newscene, 0); + ED_object_single_users(bmain, newscene, 0); else if(type == SCE_COPY_FULL) - ED_object_single_users(newscene, 1); + ED_object_single_users(bmain, newscene, 1); WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene); diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index bf433923707..a6c57126cfe 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -299,16 +299,17 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) static void do_graph_region_driver_buttons(bContext *C, void *arg, int event) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); switch (event) { case B_IPO_DEPCHANGE: { /* rebuild depsgraph for the new deps */ - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); /* force an update of depsgraph */ - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); } break; } diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 98422ec2d9f..ae2cee64a23 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -359,6 +359,7 @@ static void old_sca_move_actuator(bContext *C, void *datav, void *move_up) void do_logic_buts(bContext *C, void *arg, int event) { + Main *bmain= CTX_data_main(C); bSensor *sens; bController *cont; bActuator *act; @@ -382,7 +383,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_ADD_SENS: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { if(ob->scaflag & OB_ADDSENS) { ob->scaflag &= ~OB_ADDSENS; sens= new_sensor(SENS_ALWAYS); @@ -396,7 +397,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_CHANGE_SENS: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { sens= ob->sensors.first; while(sens) { if(sens->type != sens->otype) { @@ -410,7 +411,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_DEL_SENS: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { sens= ob->sensors.first; while(sens) { if(sens->flag & SENS_DEL) { @@ -425,7 +426,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_ADD_CONT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { if(ob->scaflag & OB_ADDCONT) { ob->scaflag &= ~OB_ADDCONT; cont= new_controller(CONT_LOGIC_AND); @@ -450,7 +451,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_SET_STATE_BIT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { if(ob->scaflag & OB_ALLSTATE) { ob->scaflag &= ~OB_ALLSTATE; ob->state = 0x3FFFFFFF; @@ -459,7 +460,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_INIT_STATE_BIT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { if(ob->scaflag & OB_INITSTBIT) { ob->scaflag &= ~OB_INITSTBIT; ob->state = ob->init_state; @@ -470,7 +471,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_CHANGE_CONT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { cont= ob->controllers.first; while(cont) { if(cont->type != cont->otype) { @@ -485,7 +486,7 @@ void do_logic_buts(bContext *C, void *arg, int event) case B_DEL_CONT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { cont= ob->controllers.first; while(cont) { if(cont->flag & CONT_DEL) { @@ -501,7 +502,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_ADD_ACT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { if(ob->scaflag & OB_ADDACT) { ob->scaflag &= ~OB_ADDACT; act= new_actuator(ACT_OBJECT); @@ -514,7 +515,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_CHANGE_ACT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { act= ob->actuators.first; while(act) { if(act->type != act->otype) { @@ -528,7 +529,7 @@ void do_logic_buts(bContext *C, void *arg, int event) break; case B_DEL_ACT: - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { act= ob->actuators.first; while(act) { if(act->flag & ACT_DEL) { @@ -546,7 +547,7 @@ void do_logic_buts(bContext *C, void *arg, int event) case B_SOUNDACT_BROWSE: /* since we don't know which... */ didit= 0; - for(ob=G.main->object.first; ob; ob=ob->id.next) { + for(ob=bmain->object.first; ob; ob=ob->id.next) { act= ob->actuators.first; while(act) { @@ -555,11 +556,11 @@ void do_logic_buts(bContext *C, void *arg, int event) bSoundActuator *sa= act->data; if(sa->sndnr) { - bSound *sound= G.main->sound.first; + bSound *sound= bmain->sound.first; int nr= 1; if(sa->sndnr == -2) { -// XXX activate_databrowse((ID *)G.main->sound.first, ID_SO, 0, B_SOUNDACT_BROWSE, +// XXX activate_databrowse((ID *)bmain->sound.first, ID_SO, 0, B_SOUNDACT_BROWSE, // &sa->sndnr, do_logic_buts); break; } @@ -768,6 +769,7 @@ static void set_sca_ob(Object *ob) static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisflag) { Base *base; + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob, *obt, *obact= CTX_data_active_object(C); ID **idar; @@ -784,7 +786,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf if(scene==NULL) return NULL; - ob= G.main->object.first; + ob= bmain->object.first; while(ob) { ob->scavisflag= 0; set_sca_ob(ob); @@ -818,7 +820,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf while(doit) { doit= 0; - ob= G.main->object.first; + ob= bmain->object.first; while(ob) { /* 1st case: select sensor when controller selected */ @@ -899,7 +901,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf } /* now we count */ - ob= G.main->object.first; + ob= bmain->object.first; while(ob) { if( ob->scavisflag ) (*count)++; ob= ob->id.next; @@ -910,7 +912,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf idar= MEM_callocN( (*count)*sizeof(void *), "idar"); - ob= G.main->object.first; + ob= bmain->object.first; nr= 0; /* make the active object always the first one of the list */ @@ -1817,7 +1819,7 @@ static void check_armature_actuator(bContext *C, void *arg1_but, void *arg2_act) } -static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width) +static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width) { bSoundActuator *sa = NULL; bObjectActuator *oa = NULL; @@ -2142,8 +2144,8 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - if(G.main->sound.first) { - IDnames_to_pupstring(&str, "Sound files", NULL, &(G.main->sound), (ID *)sa->sound, &(sa->sndnr)); + if(bmain->sound.first) { + IDnames_to_pupstring(&str, "Sound files", NULL, &(bmain->sound), (ID *)sa->sound, &(sa->sndnr)); /* reset this value, it is for handling the event */ sa->sndnr = 0; uiDefButS(block, MENU, B_SOUNDACT_BROWSE, str, xco+10,yco-22,20,19, &(sa->sndnr), 0, 0, 0, 0, ""); @@ -4709,6 +4711,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) void logic_buttons(bContext *C, ARegion *ar) { + Main *bmain= CTX_data_main(C); SpaceLogic *slogic= CTX_wm_space_logic(C); Object *ob= CTX_data_active_object(C); ID **idar; @@ -5033,7 +5036,7 @@ void logic_buttons(bContext *C, ARegion *ar) uiButSetFunc(but, make_unique_prop_names_cb, act->name, (void*) 0); ycoo= yco; - yco= draw_actuatorbuttons(ob, act, block, xco, yco, width); + yco= draw_actuatorbuttons(bmain, ob, act, block, xco, yco, width); if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; } else { diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 082f3f97dfd..01992d225c7 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -190,6 +190,7 @@ static void node_buts_normal(uiLayout *layout, bContext *C, PointerRNA *ptr) #if 0 // not used in 2.5x yet static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v) { + Main *bmain= CTX_data_main(C); bNodeTree *ntree= ntree_v; bNode *node= node_v; Tex *tex; @@ -200,7 +201,7 @@ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v) node->id->us--; node->id= NULL; } - tex= BLI_findlink(&G.main->tex, node->menunr-1); + tex= BLI_findlink(&bmain->tex, node->menunr-1); node->id= &tex->id; id_us_plus(node->id); @@ -220,6 +221,7 @@ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v) #endif static void node_dynamic_update_cb(bContext *C, void *ntree_v, void *node_v) { + Main *bmain= CTX_data_main(C); Material *ma; bNode *node= (bNode *)node_v; ID *id= node->id; @@ -229,7 +231,7 @@ static void node_dynamic_update_cb(bContext *C, void *ntree_v, void *node_v) /* Users only have to press the "update" button in one pynode * and we also update all others sharing the same script */ - for (ma= G.main->mat.first; ma; ma= ma->id.next) { + for (ma= bmain->mat.first; ma; ma= ma->id.next) { if (ma->nodetree) { bNode *nd; for (nd= ma->nodetree->nodes.first; nd; nd= nd->next) { @@ -277,6 +279,7 @@ static void node_buts_math(uiLayout *layout, bContext *C, PointerRNA *ptr) static void node_browse_text_cb(bContext *C, void *ntree_v, void *node_v) { + Main *bmain= CTX_data_main(C); bNodeTree *ntree= ntree_v; bNode *node= node_v; ID *oldid; @@ -287,7 +290,7 @@ static void node_browse_text_cb(bContext *C, void *ntree_v, void *node_v) node->id->us--; } oldid= node->id; - node->id= BLI_findlink(&G.main->text, node->menunr-1); + node->id= BLI_findlink(&bmain->text, node->menunr-1); id_us_plus(node->id); BLI_strncpy(node->name, node->id->name+2, 21); /* huh? why 21? */ @@ -368,6 +371,7 @@ static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA *ptr) { + Main *bmain= CTX_data_main(C); uiBlock *block= uiLayoutAbsoluteBlock(layout); bNode *node= ptr->data; bNodeTree *ntree= ptr->id.data; @@ -380,7 +384,7 @@ static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA * /* B_NODE_EXEC is handled in butspace.c do_node_buts */ if(!node->id) { char *strp; - IDnames_to_pupstring(&strp, NULL, "", &(G.main->text), NULL, NULL); + IDnames_to_pupstring(&strp, NULL, "", &(bmain->text), NULL, NULL); node->menunr= 0; bt= uiDefButS(block, MENU, B_NODE_EXEC/*+node->nr*/, strp, butr->xmin, dy, 19, 19, diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index cea88c33c5b..dcd87b89ea0 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1852,6 +1852,7 @@ void NODE_OT_links_cut(wmOperatorType *ot) /* goes over all scenes, reads render layers */ static int node_read_renderlayers_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); SpaceNode *snode= CTX_wm_space_node(C); Scene *curscene= CTX_data_scene(C), *scene; bNode *node; @@ -1859,7 +1860,7 @@ static int node_read_renderlayers_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); /* first tag scenes unread */ - for(scene= G.main->scene.first; scene; scene= scene->id.next) + for(scene= bmain->scene.first; scene; scene= scene->id.next) scene->id.flag |= LIB_DOIT; for(node= snode->edittree->nodes.first; node; node= node->next) { diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 3cdc2437c45..ad04e28ee4a 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -3186,7 +3186,7 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto if(scene->obedit==base->object) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); - ED_base_object_free_and_unlink(scene, base); + ED_base_object_free_and_unlink(CTX_data_main(C), scene, base); te->directdata= NULL; tselem->id= NULL; } @@ -3337,7 +3337,7 @@ void outliner_del(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops) ;// del_seq(); else { outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb); - DAG_scene_sort(scene); + DAG_scene_sort(CTX_data_main(C), scene); ED_undo_push(C, "Delete Objects"); } } @@ -3356,6 +3356,7 @@ static EnumPropertyItem prop_object_op_types[] = { static int outliner_object_operation_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); SpaceOops *soops= CTX_wm_space_outliner(C); int event; @@ -3382,7 +3383,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) } else if(event==4) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb); - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); str= "Delete Objects"; } else if(event==5) { /* disabled, see above (ton) */ diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 5638cb6daf5..7a3f0ff80e5 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2359,6 +2359,7 @@ void TEXT_OT_insert(wmOperatorType *ot) static int find_and_replace(bContext *C, wmOperator *op, short mode) { + Main *bmain= CTX_data_main(C); SpaceText *st= CTX_wm_space_text(C); Text *start= NULL, *text= st->text; int flags, first= 1; @@ -2420,7 +2421,7 @@ static int find_and_replace(bContext *C, wmOperator *op, short mode) if(text->id.next) text= st->text= text->id.next; else - text= st->text= G.main->text.first; + text= st->text= bmain->text.first; txt_move_toline(text, 0, 0); text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text); diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 19aaff2cea9..f4ae87c5b60 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -53,6 +53,7 @@ #include "BKE_customdata.h" #include "BKE_depsgraph.h" #include "BKE_idprop.h" +#include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_object.h" #include "BKE_global.h" @@ -997,6 +998,7 @@ static int test_parent_loop(Object *par, Object *ob) static void do_view3d_region_buttons(bContext *C, void *arg, int event) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); // Object *obedit= CTX_data_edit_object(C); View3D *v3d= CTX_wm_view3d(C); @@ -1028,7 +1030,7 @@ static void do_view3d_region_buttons(bContext *C, void *arg, int event) if(ob->id.lib || test_parent_loop(ob->parent, ob) ) ob->parent= NULL; else { - DAG_scene_sort(scene); + DAG_scene_sort(bmain, scene); DAG_id_flush_update(&ob->id, OB_RECALC_OB); } } diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 14b769fdf39..761ef436d48 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -152,6 +152,7 @@ static void handle_view3d_lock(bContext *C) static int layers_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); ScrArea *sa= CTX_wm_area(C); View3D *v3d= sa->spacedata.first; @@ -213,7 +214,7 @@ static int layers_exec(bContext *C, wmOperator *op) if(v3d->scenelock) handle_view3d_lock(C); /* new layers might need unflushed events events */ - DAG_scene_update_flags(scene, v3d->lay); /* tags all that moves and flushes */ + DAG_scene_update_flags(bmain, scene, v3d->lay); /* tags all that moves and flushes */ ED_area_tag_redraw(sa); diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 9928ba1983e..b3763d6cb90 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -45,14 +45,15 @@ #include "BKE_action.h" #include "BKE_anim.h" -#include "BKE_context.h" #include "BKE_armature.h" +#include "BKE_context.h" #include "BKE_curve.h" #include "BKE_depsgraph.h" #include "BKE_DerivedMesh.h" #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_lattice.h" +#include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object.h" @@ -420,6 +421,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) static int snap_sel_to_grid(bContext *C, wmOperator *op) { extern float originmat[3][3]; /* XXX object.c */ + Main *bmain= CTX_data_main(C); Object *obedit= CTX_data_edit_object(C); Scene *scene= CTX_data_scene(C); RegionView3D *rv3d= CTX_wm_region_data(C); @@ -526,7 +528,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *op) CTX_DATA_END; } - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -553,6 +555,7 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot) static int snap_sel_to_curs(bContext *C, wmOperator *op) { extern float originmat[3][3]; /* XXX object.c */ + Main *bmain= CTX_data_main(C); Object *obedit= CTX_data_edit_object(C); Scene *scene= CTX_data_scene(C); View3D *v3d= CTX_wm_view3d(C); @@ -651,7 +654,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *op) CTX_DATA_END; } - DAG_ids_flush_update(0); + DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 8ec226ef57e..4de6a270245 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1344,7 +1344,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b /* ********************** local view operator ******************** */ -static unsigned int free_localbit(void) +static unsigned int free_localbit(Main *bmain) { unsigned int lay; ScrArea *sa; @@ -1354,7 +1354,7 @@ static unsigned int free_localbit(void) /* sometimes we loose a localview: when an area is closed */ /* check all areas: which localviews are in use? */ - for(sc= G.main->screen.first; sc; sc= sc->id.next) { + for(sc= bmain->screen.first; sc; sc= sc->id.next) { for(sa= sc->areabase.first; sa; sa= sa->next) { SpaceLink *sl= sa->spacedata.first; for(; sl; sl= sl->next) { @@ -1416,7 +1416,7 @@ int ED_view3d_scene_layer_set(int lay, const int *values, int *active) return lay; } -static void initlocalview(Scene *scene, ScrArea *sa) +static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) { View3D *v3d= sa->spacedata.first; Base *base; @@ -1428,7 +1428,7 @@ static void initlocalview(Scene *scene, ScrArea *sa) INIT_MINMAX(min, max); - locallay= free_localbit(); + locallay= free_localbit(bmain); if(locallay==0) { printf("Sorry, no more than 8 localviews\n"); // XXX error @@ -1592,7 +1592,7 @@ static int localview_exec(bContext *C, wmOperator *unused) if(v3d->localvd) endlocalview(CTX_data_scene(C), CTX_wm_area(C)); else - initlocalview(CTX_data_scene(C), CTX_wm_area(C)); + initlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C)); ED_area_tag_redraw(CTX_wm_area(C)); @@ -1806,7 +1806,7 @@ static int game_engine_exec(bContext *C, wmOperator *op) //XXX restore_all_scene_cfra(scene_cfra_store); set_scene_bg(startscene); - //XXX scene_update_for_newframe(G.scene, G.scene->lay); + //XXX scene_update_for_newframe(bmain, scene, scene->lay); ED_area_tag_redraw(CTX_wm_area(C)); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 2f8da7c2dd6..e71b9bd66e0 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4403,7 +4403,7 @@ static void set_trans_object_base_flags(bContext *C, TransInfo *t) } /* all recalc flags get flushed to all layers, so a layer flip later on works fine */ - DAG_scene_flush_update(t->scene, -1, 0); + DAG_scene_flush_update(G.main, t->scene, -1, 0); /* and we store them temporal in base (only used for transform code) */ /* this because after doing updates, the object->recalc is cleared */ @@ -4481,7 +4481,7 @@ static int count_proportional_objects(TransInfo *t) /* all recalc flags get flushed to all layers, so a layer flip later on works fine */ - DAG_scene_flush_update(t->scene, -1, 0); + DAG_scene_flush_update(G.main, t->scene, -1, 0); /* and we store them temporal in base (only used for transform code) */ /* this because after doing updates, the object->recalc is cleared */ diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index fbf2051f962..cd2b6a793b7 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -77,13 +77,14 @@ void ED_editors_init(bContext *C) /* frees all editmode stuff */ void ED_editors_exit(bContext *C) { + Main *bmain= CTX_data_main(C); Scene *sce; /* frees all editmode undos */ undo_editmode_clear(); ED_undo_paint_free(); - for(sce=G.main->scene.first; sce; sce= sce->id.next) { + for(sce=bmain->scene.first; sce; sce= sce->id.next) { if(sce->obedit) { Object *ob= sce->obedit; |