diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-07 13:47:00 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-07 13:48:29 +0300 |
commit | b3a7a75a266de6765d8c04953c0dabce3c30c359 (patch) | |
tree | 98d27c5eb1d6573235c42e6e4b14137a8cee5c49 /source/blender/editors/animation | |
parent | 16017178b24c9c84df5c1114fae8dce4796c6c26 (diff) |
Cleanup: remove moar G.main usages.
Notes:
* Really need to address RNA setters case, end up adding way too much
G.main here these days... :/
* Added Main pointer into bAnimContext, helps a lot in anim code ;)
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r-- | source/blender/editors/animation/anim_channels_defines.c | 4 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_deps.c | 16 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_filter.c | 14 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframes_general.c | 8 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 26 | ||||
-rw-r--r-- | source/blender/editors/animation/keyingsets.c | 3 |
6 files changed, 41 insertions, 30 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 304d548b01b..1ea4c7ead77 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -65,6 +65,7 @@ #include "BKE_animsys.h" #include "BKE_curve.h" #include "BKE_key.h" +#include "BKE_main.h" #include "BKE_nla.h" #include "BKE_context.h" @@ -4107,6 +4108,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi /* callback for shapekey widget sliders - insert keyframes */ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, void *kb_poin) { + Main *bmain = CTX_data_main(C); Key *key = (Key *)key_poin; KeyBlock *kb = (KeyBlock *)kb_poin; char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb); @@ -4133,7 +4135,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop)) { /* find or create new F-Curve */ // XXX is the group name for this ok? - bAction *act = verify_adt_action((ID *)key, 1); + bAction *act = verify_adt_action(bmain, (ID *)key, 1); FCurve *fcu = verify_fcurve(act, NULL, &ptr, rna_path, 0, 1); /* set the special 'replace' flag if on a keyframe */ diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index 7eddb3bc3b2..c71acd714d3 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -46,11 +46,11 @@ #include "BKE_animsys.h" #include "BKE_action.h" -#include "BKE_fcurve.h" -#include "BKE_gpencil.h" #include "BKE_context.h" #include "BKE_depsgraph.h" -#include "BKE_global.h" +#include "BKE_fcurve.h" +#include "BKE_gpencil.h" +#include "BKE_main.h" #include "BKE_node.h" #include "BKE_sequencer.h" @@ -63,7 +63,7 @@ /* tags the given anim list element for refreshes (if applicable) * due to Animation Editor editing */ -void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale) +void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale) { ID *id; FCurve *fcu; @@ -93,7 +93,7 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale) RNA_id_pointer_create(id, &id_ptr); if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) - RNA_property_update_main(G.main, scene, &ptr, prop); + RNA_property_update_main(bmain, scene, &ptr, prop); } else { /* in other case we do standard depsgraph update, ideally @@ -402,7 +402,7 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data) if (ale->update & ANIM_UPDATE_DEPS) { ale->update &= ~ANIM_UPDATE_DEPS; - ANIM_list_elem_update(ac->scene, ale); + ANIM_list_elem_update(ac->bmain, ac->scene, ale); } } else if (ale->datatype == ALE_FCURVE) { @@ -422,13 +422,13 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data) if (ale->update & ANIM_UPDATE_DEPS) { ale->update &= ~ANIM_UPDATE_DEPS; - ANIM_list_elem_update(ac->scene, ale); + ANIM_list_elem_update(ac->bmain, ac->scene, ale); } } else if (ale->datatype == ALE_NLASTRIP) { if (ale->update & ANIM_UPDATE_DEPS) { ale->update &= ~ANIM_UPDATE_DEPS; - ANIM_list_elem_update(ac->scene, ale); + ANIM_list_elem_update(ac->bmain, ac->scene, ale); } } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index b41302f4706..4659fc2ca18 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -365,6 +365,7 @@ bool ANIM_animdata_context_getdata(bAnimContext *ac) */ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) { + Main *bmain = CTX_data_main(C); ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); SpaceLink *sl = CTX_wm_space_data(C); @@ -375,6 +376,7 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) memset(ac, 0, sizeof(bAnimContext)); /* get useful default context settings from context */ + ac->bmain = bmain; ac->scene = scene; if (scene) { ac->markers = ED_context_get_markers(C); @@ -1726,7 +1728,7 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, ListBase *anim_data, voi bGPdata *gpd; /* Grab all Grease Pencil datablocks directly from main, but only those that seem to be useful somewhere */ - for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) { + for (gpd = ac->bmain->gpencil.first; gpd; gpd = gpd->id.next) { /* only show if gpd is used by something... */ if (ID_REAL_USERS(gpd) < 1) continue; @@ -1842,14 +1844,14 @@ static size_t animdata_filter_mask_data(ListBase *anim_data, Mask *mask, const i } /* Grab all mask data */ -static size_t animdata_filter_mask(ListBase *anim_data, void *UNUSED(data), int filter_mode) +static size_t animdata_filter_mask(Main *bmain, ListBase *anim_data, void *UNUSED(data), int filter_mode) { Mask *mask; size_t items = 0; /* for now, grab mask datablocks directly from main */ // XXX: this is not good... - for (mask = G.main->mask.first; mask; mask = mask->id.next) { + for (mask = bmain->mask.first; mask; mask = mask->id.next) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -2831,7 +2833,7 @@ static size_t animdata_filter_dopesheet_movieclips(bAnimContext *ac, ListBase *a { size_t items = 0; MovieClip *clip; - for (clip = G.main->movieclip.first; clip != NULL; clip = clip->id.next) { + for (clip = ac->bmain->movieclip.first; clip != NULL; clip = clip->id.next) { /* only show if gpd is used by something... */ if (ID_REAL_USERS(clip) < 1) { continue; @@ -2969,7 +2971,7 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBase *anim_data, b } /* Cache files level animations (frame duration and such). */ - CacheFile *cache_file = G.main->cachefiles.first; + CacheFile *cache_file = ac->bmain->cachefiles.first; for (; cache_file; cache_file = cache_file->id.next) { items += animdata_filter_ds_cachefile(ac, anim_data, ads, cache_file, filter_mode); } @@ -3233,7 +3235,7 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F case ANIMCONT_MASK: { if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) - items = animdata_filter_mask(anim_data, data, filter_mode); + items = animdata_filter_mask(ac->bmain, anim_data, data, filter_mode); break; } diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index f8af504f1ed..a6ed6643257 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -48,6 +48,7 @@ #include "BKE_fcurve.h" #include "BKE_report.h" #include "BKE_library.h" +#include "BKE_main.h" #include "BKE_global.h" #include "BKE_deform.h" @@ -729,7 +730,8 @@ static tAnimCopybufItem *pastebuf_match_path_full(FCurve *fcu, const short from_ } /* medium match strictness: path match only (i.e. ignore ID) */ -static tAnimCopybufItem *pastebuf_match_path_property(FCurve *fcu, const short from_single, const short UNUSED(to_simple)) +static tAnimCopybufItem *pastebuf_match_path_property( + Main *bmain, FCurve *fcu, const short from_single, const short UNUSED(to_simple)) { tAnimCopybufItem *aci; @@ -742,7 +744,7 @@ static tAnimCopybufItem *pastebuf_match_path_property(FCurve *fcu, const short f * resolve, or a bone could be renamed after copying for eg. but in normal copy & paste * this should work out ok. */ - if (BLI_findindex(which_libbase(G.main, aci->id_type), aci->id) == -1) { + if (BLI_findindex(which_libbase(bmain, aci->id_type), aci->id) == -1) { /* pedantic but the ID could have been removed, and beats crashing! */ printf("paste_animedit_keys: error ID has been removed!\n"); } @@ -996,7 +998,7 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, case 1: /* less strict, just compare property names */ - aci = pastebuf_match_path_property(fcu, from_single, to_simple); + aci = pastebuf_match_path_property(ac->bmain, fcu, from_single, to_simple); break; case 2: diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 0bb35dcbf3e..6386ad09e80 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -53,18 +53,19 @@ #include "DNA_object_types.h" #include "DNA_rigidbody_types.h" -#include "BKE_animsys.h" #include "BKE_action.h" +#include "BKE_animsys.h" #include "BKE_armature.h" +#include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_fcurve.h" -#include "BKE_idcode.h" -#include "BKE_nla.h" #include "BKE_global.h" -#include "BKE_context.h" -#include "BKE_report.h" +#include "BKE_idcode.h" #include "BKE_key.h" +#include "BKE_main.h" #include "BKE_material.h" +#include "BKE_nla.h" +#include "BKE_report.h" #include "ED_anim_api.h" #include "ED_keyframing.h" @@ -123,7 +124,7 @@ short ANIM_get_keyframing_flags(Scene *scene, short incl_mode) /* Get (or add relevant data to be able to do so) the Active Action for the given * Animation Data block, given an ID block where the Animation Data should reside. */ -bAction *verify_adt_action(ID *id, short add) +bAction *verify_adt_action(Main *bmain, ID *id, short add) { AnimData *adt; @@ -145,7 +146,7 @@ bAction *verify_adt_action(ID *id, short add) BLI_snprintf(actname, sizeof(actname), "%sAction", id->name + 2); /* create action */ - adt->action = BKE_action_add(G.main, actname); + adt->action = BKE_action_add(bmain, actname); /* set ID-type from ID-block that this is going to be assigned to * so that users can't accidentally break actions by assigning them @@ -155,7 +156,7 @@ bAction *verify_adt_action(ID *id, short add) /* tag depsgraph to be rebuilt to include time dependency */ /* XXX: we probably should have bmain passed down, but that involves altering too many API's */ - DAG_relations_tag_update(G.main); + DAG_relations_tag_update(bmain); } /* return the action */ @@ -1006,7 +1007,9 @@ bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *pr * * index of -1 keys all array indices */ -short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag) +short insert_keyframe( + Main *bmain, ReportList *reports, ID *id, bAction *act, + const char group[], const char rna_path[], int array_index, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag) { PointerRNA id_ptr, ptr; PropertyRNA *prop = NULL; @@ -1032,7 +1035,7 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou /* if no action is provided, keyframe to the default one attached to this ID-block */ if (act == NULL) { /* get action to add F-Curve+keyframe to */ - act = verify_adt_action(id, 1); + act = verify_adt_action(bmain, id, 1); if (act == NULL) { BKE_reportf(reports, RPT_ERROR, @@ -1757,6 +1760,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); ToolSettings *ts = scene->toolsettings; PointerRNA ptr = {{NULL}}; @@ -1817,7 +1821,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) index = -1; } - success = insert_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index, cfra, ts->keyframe_type, flag); + success = insert_keyframe(bmain, op->reports, ptr.id.data, NULL, NULL, path, index, cfra, ts->keyframe_type, flag); MEM_freeN(path); } diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 3e491ce3ade..a2a384832be 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -957,6 +957,7 @@ static short keyingset_apply_keying_flags(const short base_flags, const short ov */ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ReportList *reports = CTX_wm_reports(C); KS_Path *ksp; @@ -1037,7 +1038,7 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe for (; i < arraylen; i++) { /* action to take depends on mode */ if (mode == MODIFYKEY_MODE_INSERT) - success += insert_keyframe(reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, keytype, kflag2); + success += insert_keyframe(bmain, reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, keytype, kflag2); else if (mode == MODIFYKEY_MODE_DELETE) success += delete_keyframe(reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag2); } |