diff options
19 files changed, 83 insertions, 75 deletions
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index b6de922c245..c7ea73463e3 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -56,7 +56,7 @@ void BKE_gpencil_stroke_sync_selection(struct bGPDstroke *gps); struct bGPDframe *BKE_gpencil_frame_addnew(struct bGPDlayer *gpl, int cframe); struct bGPDframe *BKE_gpencil_frame_addcopy(struct bGPDlayer *gpl, int cframe); struct bGPDlayer *BKE_gpencil_layer_addnew(struct bGPdata *gpd, const char *name, bool setactive); -struct bGPdata *BKE_gpencil_data_addnew(const char name[]); +struct bGPdata *BKE_gpencil_data_addnew(struct Main *bmain, const char name[]); struct bGPDframe *BKE_gpencil_frame_duplicate(const struct bGPDframe *gpf_src); struct bGPDlayer *BKE_gpencil_layer_duplicate(const struct bGPDlayer *gpl_src); diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 734eb8cfa09..0a5bac267ac 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -331,9 +331,10 @@ void psys_particle_on_emitter(struct ParticleSystemModifierData *psmd, int distr float utan[3], float vtan[3], float orco[3]); struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct ParticleSystem *psys); -struct ModifierData *object_add_particle_system(struct Scene *scene, struct Object *ob, const char *name); -void object_remove_particle_system(struct Scene *scene, struct Object *ob); -struct ParticleSettings *BKE_particlesettings_add(struct Main *main, const char *name); +struct ModifierData *object_add_particle_system( + struct Main *bmain, struct Scene *scene, struct Object *ob, const char *name); +void object_remove_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob); +struct ParticleSettings *BKE_particlesettings_add(struct Main *bmain, const char *name); void BKE_particlesettings_copy_data( struct Main *bmain, struct ParticleSettings *part_dst, const struct ParticleSettings *part_src, const int flag); diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 89f1aa5eadd..501c9964aa3 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -185,7 +185,7 @@ typedef struct PTCacheID { } PTCacheID; typedef struct PTCacheBaker { - struct Main *main; + struct Main *bmain; struct Scene *scene; struct ViewLayer *view_layer; struct Depsgraph *depsgraph; diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 3f78b096115..1ec5b347168 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -81,9 +81,9 @@ char versionstr[48] = ""; /* only to be called on exit blender */ void BKE_blender_free(void) { - /* samples are in a global list..., also sets G.main->sound->sample NULL */ - BKE_main_free(G.main); - G.main = NULL; + /* samples are in a global list..., also sets G_MAIN->sound->sample NULL */ + BKE_main_free(G_MAIN); + G_MAIN = NULL; if (G.log.file != NULL) { fclose(G.log.file); @@ -125,7 +125,7 @@ void BKE_blender_globals_init(void) U.savetime = 1; - G.main = BKE_main_new(); + G_MAIN = BKE_main_new(); strcpy(G.ima, "//"); @@ -142,9 +142,9 @@ void BKE_blender_globals_init(void) void BKE_blender_globals_clear(void) { - BKE_main_free(G.main); /* free all lib data */ + BKE_main_free(G_MAIN); /* free all lib data */ - G.main = NULL; + G_MAIN = NULL; } /***/ diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 597c69408b5..27b5089b092 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -116,7 +116,7 @@ static void setup_app_data( bContext *C, BlendFileData *bfd, const char *filepath, ReportList *reports) { - Main *bmain = G.main; /* Valid usage */ + Main *bmain = G_MAIN; Scene *curscene = NULL; const bool is_startup = (bfd->filename[0] == '\0'); const bool recover = (G.fileflags & G_FILE_RECOVER) != 0; @@ -207,7 +207,7 @@ static void setup_app_data( win->scene = curscene; } - /* BKE_blender_globals_clear will free G.main, here we can still restore pointers */ + /* BKE_blender_globals_clear will free G_MAIN, here we can still restore pointers */ blo_lib_link_restore(bfd->main, CTX_wm_manager(C), curscene, cur_view_layer); if (win) { curscene = win->scene; @@ -230,14 +230,14 @@ static void setup_app_data( } } - /* free G.main Main database */ + /* free G_MAIN Main database */ // CTX_wm_manager_set(C, NULL); BKE_blender_globals_clear(); /* clear old property update cache, in case some old references are left dangling */ RNA_property_update_cache_free(); - bmain = G.main = bfd->main; + bmain = G_MAIN = bfd->main; CTX_data_main_set(C, bmain); diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index aa67eafaa98..2f33ca3210d 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -3483,7 +3483,7 @@ bool CustomData_verify_versions(struct CustomData *data, int index) static void customdata_external_filename(char filename[FILE_MAX], ID *id, CustomDataExternal *external) { BLI_strncpy(filename, external->filename, FILE_MAX); - BLI_path_abs(filename, ID_BLEND_PATH(G.main, id)); + BLI_path_abs(filename, ID_BLEND_PATH_FROM_GLOBAL(id)); } void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask mask, int totelem) diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index ee0d0b41898..9b79415f006 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -622,12 +622,12 @@ bGPDpalettecolor *BKE_gpencil_palettecolor_addnew(bGPDpalette *palette, const ch } /* add a new gp-datablock */ -bGPdata *BKE_gpencil_data_addnew(const char name[]) +bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[]) { bGPdata *gpd; /* allocate memory for a new block */ - gpd = BKE_libblock_alloc(G.main, ID_GD, name, 0); + gpd = BKE_libblock_alloc(bmain, ID_GD, name, 0); /* initial settings */ gpd->flag = (GP_DATA_DISPINFO | GP_DATA_EXPAND); diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 82178096b46..f3f690b92da 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1509,7 +1509,7 @@ static void action_to_animato(ID *id, bAction *act, ListBase *groups, ListBase * * This assumes that AnimData has been added already. Separation of drivers * from animation data is accomplished here too... */ -static void ipo_to_animdata(ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq) +static void ipo_to_animdata(Main *bmain, ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq) { AnimData *adt = BKE_animdata_from_id(id); ListBase anim = {NULL, NULL}; @@ -1544,7 +1544,7 @@ static void ipo_to_animdata(ID *id, Ipo *ipo, char actname[], char constname[], BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name + 2); - adt->action = BKE_action_add(G.main, nameBuf); + adt->action = BKE_action_add(bmain, nameBuf); if (G.debug & G_DEBUG) printf("\t\tadded new action - '%s'\n", nameBuf); } @@ -1680,19 +1680,19 @@ static void nlastrips_to_animdata(ID *id, ListBase *strips) * clear which datablocks have yet to be converted, and also prevent freeing errors when we exit. */ // XXX currently done after all file reading... -void do_versions_ipos_to_animato(Main *main) +void do_versions_ipos_to_animato(Main *bmain) { ListBase drivers = {NULL, NULL}; ID *id; - if (main == NULL) { + if (bmain == NULL) { printf("Argh! Main is NULL in do_versions_ipos_to_animato()\n"); return; } /* only convert if version is right */ - if (main->versionfile >= 250) { - printf("WARNING: Animation data too new to convert (Version %d)\n", main->versionfile); + if (bmain->versionfile >= 250) { + printf("WARNING: Animation data too new to convert (Version %d)\n", bmain->versionfile); return; } else if (G.debug & G_DEBUG) @@ -1701,7 +1701,7 @@ void do_versions_ipos_to_animato(Main *main) /* ----------- Animation Attached to Data -------------- */ /* objects */ - for (id = main->object.first; id; id = id->next) { + for (id = bmain->object.first; id; id = id->next) { Object *ob = (Object *)id; bPoseChannel *pchan; bConstraint *con; @@ -1716,7 +1716,7 @@ void do_versions_ipos_to_animato(Main *main) /* IPO first to take into any non-NLA'd Object Animation */ if (ob->ipo) { - ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, ob->ipo, NULL, NULL, NULL); id_us_min(&ob->ipo->id); ob->ipo = NULL; @@ -1750,7 +1750,7 @@ void do_versions_ipos_to_animato(Main *main) /* IPO second... */ if (ob->ipo) { - ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, ob->ipo, NULL, NULL, NULL); id_us_min(&ob->ipo->id); ob->ipo = NULL; } @@ -1770,7 +1770,7 @@ void do_versions_ipos_to_animato(Main *main) /* although this was the constraint's local IPO, we still need to provide pchan + con * so that drivers can be added properly... */ - ipo_to_animdata(id, con->ipo, pchan->name, con->name, NULL); + ipo_to_animdata(bmain, id, con->ipo, pchan->name, con->name, NULL); id_us_min(&con->ipo->id); con->ipo = NULL; } @@ -1790,7 +1790,7 @@ void do_versions_ipos_to_animato(Main *main) /* although this was the constraint's local IPO, we still need to provide con * so that drivers can be added properly... */ - ipo_to_animdata(id, con->ipo, NULL, con->name, NULL); + ipo_to_animdata(bmain, id, con->ipo, NULL, con->name, NULL); id_us_min(&con->ipo->id); con->ipo = NULL; } @@ -1810,7 +1810,7 @@ void do_versions_ipos_to_animato(Main *main) /* convert Constraint Channel's IPO data */ if (conchan->ipo) { - ipo_to_animdata(id, conchan->ipo, NULL, conchan->name, NULL); + ipo_to_animdata(bmain, id, conchan->ipo, NULL, conchan->name, NULL); id_us_min(&conchan->ipo->id); conchan->ipo = NULL; } @@ -1829,7 +1829,7 @@ void do_versions_ipos_to_animato(Main *main) } /* shapekeys */ - for (id = main->key.first; id; id = id->next) { + for (id = bmain->key.first; id; id = id->next) { Key *key = (Key *)id; if (G.debug & G_DEBUG) printf("\tconverting key %s\n", id->name + 2); @@ -1843,7 +1843,7 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt = BKE_animdata_add_id(id); /* Convert Shapekey data... */ - ipo_to_animdata(id, key->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, key->ipo, NULL, NULL, NULL); if (adt->action) adt->action->idroot = key->ipo->blocktype; @@ -1854,7 +1854,7 @@ void do_versions_ipos_to_animato(Main *main) } /* materials */ - for (id = main->mat.first; id; id = id->next) { + for (id = bmain->mat.first; id; id = id->next) { Material *ma = (Material *)id; if (G.debug & G_DEBUG) printf("\tconverting material %s\n", id->name + 2); @@ -1865,7 +1865,7 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt = BKE_animdata_add_id(id); /* Convert Material data... */ - ipo_to_animdata(id, ma->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, ma->ipo, NULL, NULL, NULL); if (adt->action) adt->action->idroot = ma->ipo->blocktype; @@ -1876,7 +1876,7 @@ void do_versions_ipos_to_animato(Main *main) } /* worlds */ - for (id = main->world.first; id; id = id->next) { + for (id = bmain->world.first; id; id = id->next) { World *wo = (World *)id; if (G.debug & G_DEBUG) printf("\tconverting world %s\n", id->name + 2); @@ -1887,7 +1887,7 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt = BKE_animdata_add_id(id); /* Convert World data... */ - ipo_to_animdata(id, wo->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, wo->ipo, NULL, NULL, NULL); if (adt->action) adt->action->idroot = wo->ipo->blocktype; @@ -1898,7 +1898,7 @@ void do_versions_ipos_to_animato(Main *main) } /* sequence strips */ - for (id = main->scene.first; id; id = id->next) { + for (id = bmain->scene.first; id; id = id->next) { Scene *scene = (Scene *)id; Editing *ed = scene->ed; if (ed && ed->seqbasep) { @@ -1938,7 +1938,7 @@ void do_versions_ipos_to_animato(Main *main) icu->adrcode = adrcode; /* convert IPO */ - ipo_to_animdata((ID *)scene, seq->ipo, NULL, NULL, seq); + ipo_to_animdata(bmain, (ID *)scene, seq->ipo, NULL, NULL, seq); if (adt->action) adt->action->idroot = ID_SCE; /* scene-rooted */ @@ -1952,7 +1952,7 @@ void do_versions_ipos_to_animato(Main *main) /* textures */ - for (id = main->tex.first; id; id = id->next) { + for (id = bmain->tex.first; id; id = id->next) { Tex *te = (Tex *)id; if (G.debug & G_DEBUG) printf("\tconverting texture %s\n", id->name + 2); @@ -1963,7 +1963,7 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt = BKE_animdata_add_id(id); /* Convert Texture data... */ - ipo_to_animdata(id, te->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, te->ipo, NULL, NULL, NULL); if (adt->action) adt->action->idroot = te->ipo->blocktype; @@ -1974,7 +1974,7 @@ void do_versions_ipos_to_animato(Main *main) } /* cameras */ - for (id = main->camera.first; id; id = id->next) { + for (id = bmain->camera.first; id; id = id->next) { Camera *ca = (Camera *)id; if (G.debug & G_DEBUG) printf("\tconverting camera %s\n", id->name + 2); @@ -1985,7 +1985,7 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt = BKE_animdata_add_id(id); /* Convert Camera data... */ - ipo_to_animdata(id, ca->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, ca->ipo, NULL, NULL, NULL); if (adt->action) adt->action->idroot = ca->ipo->blocktype; @@ -1996,7 +1996,7 @@ void do_versions_ipos_to_animato(Main *main) } /* lamps */ - for (id = main->lamp.first; id; id = id->next) { + for (id = bmain->lamp.first; id; id = id->next) { Lamp *la = (Lamp *)id; if (G.debug & G_DEBUG) printf("\tconverting lamp %s\n", id->name + 2); @@ -2007,7 +2007,7 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt = BKE_animdata_add_id(id); /* Convert Lamp data... */ - ipo_to_animdata(id, la->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, la->ipo, NULL, NULL, NULL); if (adt->action) adt->action->idroot = la->ipo->blocktype; @@ -2018,7 +2018,7 @@ void do_versions_ipos_to_animato(Main *main) } /* curves */ - for (id = main->curve.first; id; id = id->next) { + for (id = bmain->curve.first; id; id = id->next) { Curve *cu = (Curve *)id; if (G.debug & G_DEBUG) printf("\tconverting curve %s\n", id->name + 2); @@ -2029,7 +2029,7 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt = BKE_animdata_add_id(id); /* Convert Curve data... */ - ipo_to_animdata(id, cu->ipo, NULL, NULL, NULL); + ipo_to_animdata(bmain, id, cu->ipo, NULL, NULL, NULL); if (adt->action) adt->action->idroot = cu->ipo->blocktype; @@ -2051,7 +2051,7 @@ void do_versions_ipos_to_animato(Main *main) */ /* actions */ - for (id = main->action.first; id; id = id->next) { + for (id = bmain->action.first; id; id = id->next) { bAction *act = (bAction *)id; if (G.debug & G_DEBUG) printf("\tconverting action %s\n", id->name + 2); @@ -2065,7 +2065,7 @@ void do_versions_ipos_to_animato(Main *main) } /* ipo's */ - for (id = main->ipo.first; id; id = id->next) { + for (id = bmain->ipo.first; id; id = id->next) { Ipo *ipo = (Ipo *)id; if (G.debug & G_DEBUG) printf("\tconverting ipo %s\n", id->name + 2); @@ -2075,7 +2075,7 @@ void do_versions_ipos_to_animato(Main *main) bAction *new_act; /* add a new action for this, and convert all data into that action */ - new_act = BKE_action_add(main, id->name + 2); + new_act = BKE_action_add(bmain, id->name + 2); ipo_to_animato(NULL, ipo, NULL, NULL, NULL, NULL, &new_act->curves, &drivers); new_act->idroot = ipo->blocktype; } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 2bba32ff592..127ef840027 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2975,7 +2975,7 @@ void psys_mat_hair_to_global(Object *ob, Mesh *mesh, short from, ParticleData *p /************************************************/ /* ParticleSettings handling */ /************************************************/ -ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *name) +ModifierData *object_add_particle_system(Main *bmain, Scene *scene, Object *ob, const char *name) { ParticleSystem *psys; ModifierData *md; @@ -2992,7 +2992,7 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n psys->pointcache = BKE_ptcache_add(&psys->ptcaches); BLI_addtail(&ob->particlesystem, psys); - psys->part = BKE_particlesettings_add(NULL, DATA_("ParticleSettings")); + psys->part = BKE_particlesettings_add(bmain, DATA_("ParticleSettings")); if (BLI_listbase_count_at_most(&ob->particlesystem, 2) > 1) BLI_snprintf(psys->name, sizeof(psys->name), DATA_("ParticleSystem %i"), BLI_listbase_count(&ob->particlesystem)); @@ -3015,12 +3015,12 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n psys->flag = PSYS_CURRENT; psys->cfra = BKE_scene_frame_get_from_ctime(scene, CFRA + 1); - DEG_relations_tag_update(G.main); + DEG_relations_tag_update(bmain); DEG_id_tag_update(&ob->id, OB_RECALC_DATA); return md; } -void object_remove_particle_system(Scene *UNUSED(scene), Object *ob) +void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob) { ParticleSystem *psys = psys_get_current(ob); ParticleSystemModifierData *psmd; @@ -3061,7 +3061,7 @@ void object_remove_particle_system(Scene *UNUSED(scene), Object *ob) else ob->mode &= ~OB_MODE_PARTICLE_EDIT; - DEG_relations_tag_update(G.main); + DEG_relations_tag_update(bmain); DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* Flush object mode. */ @@ -3155,14 +3155,11 @@ static void default_particle_settings(ParticleSettings *part) } -ParticleSettings *BKE_particlesettings_add(Main *main, const char *name) +ParticleSettings *BKE_particlesettings_add(Main *bmain, const char *name) { ParticleSettings *part; - if (main == NULL) - main = G.main; - - part = BKE_libblock_alloc(main, ID_PA, name, 0); + part = BKE_libblock_alloc(bmain, ID_PA, name, 0); default_particle_settings(part); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 8d55a1d2690..10050e5e083 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -3536,7 +3536,7 @@ void BKE_ptcache_quick_cache_all(Main *bmain, Scene *scene, ViewLayer *view_laye PTCacheBaker baker; memset(&baker, 0, sizeof(baker)); - baker.main = bmain; + baker.bmain = bmain; baker.scene = scene; baker.view_layer = view_layer; baker.bake = 0; @@ -3562,7 +3562,7 @@ static void ptcache_dt_to_str(char *str, double dtime) /* if bake is not given run simulations to current frame */ void BKE_ptcache_bake(PTCacheBaker *baker) { - Main *bmain = baker->main; + Main *bmain = baker->bmain; Scene *scene = baker->scene; ViewLayer *view_layer = baker->view_layer; struct Depsgraph *depsgraph = baker->depsgraph; diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 2e8e48b2f15..9f437f28f0f 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -52,14 +52,15 @@ #include "DNA_view3d_types.h" #include "DNA_gpencil_types.h" +#include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_gpencil.h" #include "BKE_library.h" +#include "BKE_main.h" #include "BKE_object.h" #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h" -#include "BKE_colortools.h" #include "UI_interface.h" #include "UI_resources.h" @@ -83,6 +84,7 @@ /* add new datablock - wrapper around API */ static int gp_data_add_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL); ToolSettings *ts = CTX_data_tool_settings(C); @@ -95,7 +97,7 @@ static int gp_data_add_exec(bContext *C, wmOperator *op) bGPdata *gpd = (*gpd_ptr); id_us_min(&gpd->id); - *gpd_ptr = BKE_gpencil_data_addnew(DATA_("GPencil")); + *gpd_ptr = BKE_gpencil_data_addnew(bmain, DATA_("GPencil")); /* if not exist brushes, create a new set */ if (ts) { @@ -183,6 +185,7 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot) /* add new layer - wrapper around API */ static int gp_layer_add_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL); ToolSettings *ts = CTX_data_tool_settings(C); @@ -192,7 +195,7 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } if (*gpd_ptr == NULL) - *gpd_ptr = BKE_gpencil_data_addnew(DATA_("GPencil")); + *gpd_ptr = BKE_gpencil_data_addnew(bmain, DATA_("GPencil")); /* if not exist brushes, create a new set */ if (ts) { @@ -1376,6 +1379,7 @@ void GPENCIL_OT_brush_select(wmOperatorType *ot) /* add new palette - wrapper around API */ static int gp_palette_add_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL); /* if there's no existing Grease-Pencil data there, add some */ @@ -1384,7 +1388,7 @@ static int gp_palette_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } if (*gpd_ptr == NULL) - *gpd_ptr = BKE_gpencil_data_addnew(DATA_("GPencil")); + *gpd_ptr = BKE_gpencil_data_addnew(bmain, DATA_("GPencil")); /* add new palette now */ BKE_gpencil_palette_addnew(*gpd_ptr, DATA_("GP_Palette"), true); @@ -1588,6 +1592,7 @@ void GPENCIL_OT_palette_lock_layer(wmOperatorType *ot) /* add new palette - wrapper around API */ static int gp_palettecolor_add_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL); /* if there's no existing Grease-Pencil data there, add some */ @@ -1596,7 +1601,7 @@ static int gp_palettecolor_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } if (*gpd_ptr == NULL) - *gpd_ptr = BKE_gpencil_data_addnew(DATA_("GPencil")); + *gpd_ptr = BKE_gpencil_data_addnew(bmain, DATA_("GPencil")); /* verify palette */ bGPDpalette *palette = BKE_gpencil_palette_getactive(*gpd_ptr); diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 437d5cef6f8..6afa6f41828 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1387,6 +1387,7 @@ static void gp_init_palette(tGPsdata *p) /* (re)init new painting data */ static bool gp_session_initdata(bContext *C, tGPsdata *p) { + Main *bmain = CTX_data_main(C); bGPdata **gpd_ptr = NULL; ScrArea *curarea = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); @@ -1537,7 +1538,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) else { /* if no existing GPencil block exists, add one */ if (*gpd_ptr == NULL) - *gpd_ptr = BKE_gpencil_data_addnew("GPencil"); + *gpd_ptr = BKE_gpencil_data_addnew(bmain, "GPencil"); p->gpd = *gpd_ptr; } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 8395eea336c..425a0acff17 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -119,7 +119,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc /* don't need to worry about the new modifier's name, since that is set to the number * of particle systems which shouldn't have too many duplicates */ - new_md = object_add_particle_system(scene, ob, name); + new_md = object_add_particle_system(bmain, scene, ob, name); } else { /* get new modifier data to add */ diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index fbccdcfcdba..8a9eb369e66 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -82,13 +82,14 @@ static float I[4][4] = {{1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f, 0.0f}, {0.0 static int particle_system_add_exec(bContext *C, wmOperator *UNUSED(op)) { + Main *bmain = CTX_data_main(C); Object *ob= ED_object_context(C); Scene *scene = CTX_data_scene(C); if (!scene || !ob) return OPERATOR_CANCELLED; - object_add_particle_system(scene, ob, NULL); + object_add_particle_system(bmain, scene, ob, NULL); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); @@ -113,6 +114,7 @@ void OBJECT_OT_particle_system_add(wmOperatorType *ot) static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op)) { + Main *bmain = CTX_data_main(C); Object *ob = ED_object_context(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -122,7 +124,7 @@ static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; mode_orig = ob->mode; - object_remove_particle_system(scene, ob); + object_remove_particle_system(bmain, scene, ob); /* possible this isn't the active object * object_remove_particle_system() clears the mode on the last psys diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index 45172774d55..a66dbfc789d 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -164,7 +164,7 @@ static PTCacheBaker *ptcache_baker_create(bContext *C, wmOperator *op, bool all) { PTCacheBaker *baker = MEM_callocN(sizeof(PTCacheBaker), "PTCacheBaker"); - baker->main = CTX_data_main(C); + baker->bmain = CTX_data_main(C); baker->scene = CTX_data_scene(C); baker->view_layer = CTX_data_view_layer(C); baker->depsgraph = CTX_data_depsgraph(C); diff --git a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c index cd918695f60..8178c2f5be9 100644 --- a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c +++ b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c @@ -382,6 +382,7 @@ static bool view3d_ruler_item_mousemove( static bool view3d_ruler_to_gpencil(bContext *C, wmManipulatorGroup *mgroup) { // RulerInfo *ruler_info = mgroup->customdata; + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); bGPDlayer *gpl; bGPDframe *gpf; @@ -393,7 +394,7 @@ static bool view3d_ruler_to_gpencil(bContext *C, wmManipulatorGroup *mgroup) bool changed = false; if (scene->gpd == NULL) { - scene->gpd = BKE_gpencil_data_addnew("GPencil"); + scene->gpd = BKE_gpencil_data_addnew(bmain, "GPencil"); } gpl = BLI_findstring(&scene->gpd->layers, ruler_name, offsetof(bGPDlayer, info)); diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index c30b72bfb95..e001ed9112b 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -297,6 +297,7 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state) #define RULER_ID "RulerData3D" static bool view3d_ruler_to_gpencil(bContext *C, RulerInfo *ruler_info) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); bGPDlayer *gpl; bGPDframe *gpf; @@ -308,7 +309,7 @@ static bool view3d_ruler_to_gpencil(bContext *C, RulerInfo *ruler_info) bool changed = false; if (scene->gpd == NULL) { - scene->gpd = BKE_gpencil_data_addnew("GPencil"); + scene->gpd = BKE_gpencil_data_addnew(bmain, "GPencil"); } gpl = BLI_findstring(&scene->gpd->layers, ruler_name, offsetof(bGPDlayer, info)); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 331bf4a580d..6ff3849e295 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -1642,7 +1642,7 @@ void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); func = RNA_def_function(srna, "new", "BKE_gpencil_data_addnew"); - RNA_def_function_flag(func, FUNC_NO_SELF); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_MAIN); parm = RNA_def_string(func, "name", "GreasePencil", 0, "", "New name for the data-block"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); /* return type */ diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 648fbff7b23..809faeb87a4 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1892,7 +1892,7 @@ static void update_physics_cache(Render *re, Scene *scene, ViewLayer *view_layer PTCacheBaker baker; memset(&baker, 0, sizeof(baker)); - baker.main = re->main; + baker.bmain = re->main; baker.scene = scene; baker.view_layer = view_layer; baker.depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true); |