Cleanup: get rid of last G.main in BMesh code.
This commit is contained in:
parent
5ff1d845ea
commit
f61c30f804
|
@ -703,7 +703,7 @@ static void sculptsession_bm_to_me_update_data_only(Object *ob, bool reorder)
|
|||
}
|
||||
if (reorder)
|
||||
BM_log_mesh_elems_reorder(ss->bm, ss->bm_log);
|
||||
BM_mesh_bm_to_me(ss->bm, ob->data, (&(struct BMeshToMeshParams){0}));
|
||||
BM_mesh_bm_to_me(NULL, ss->bm, ob->data, (&(struct BMeshToMeshParams){.calc_object_remap = false}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1827,7 +1827,7 @@ static void prepare_mesh_for_viewport_render(Main *bmain, Scene *scene)
|
|||
if (check_rendered_viewport_visible(bmain)) {
|
||||
BMesh *bm = mesh->edit_btmesh->bm;
|
||||
BM_mesh_bm_to_me(
|
||||
bm, mesh,
|
||||
bmain, bm, mesh,
|
||||
(&(struct BMeshToMeshParams){
|
||||
.calc_object_remap = true,
|
||||
}));
|
||||
|
|
|
@ -4501,12 +4501,12 @@ static void lib_link_mesh(FileData *fd, Main *main)
|
|||
if (me->totface && !me->totpoly) {
|
||||
/* temporarily switch main so that reading from
|
||||
* external CustomData works */
|
||||
Main *gmain = G.main;
|
||||
G.main = main;
|
||||
Main *gmain = G_MAIN;
|
||||
G_MAIN = main;
|
||||
|
||||
BKE_mesh_do_versions_convert_mfaces_to_mpolys(me);
|
||||
|
||||
G.main = gmain;
|
||||
G_MAIN = gmain;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -8447,17 +8447,18 @@ static void convert_tface_mt(FileData *fd, Main *main)
|
|||
|
||||
/* this is a delayed do_version (so it can create new materials) */
|
||||
if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 3)) {
|
||||
//XXX hack, material.c uses G.main all over the place, instead of main
|
||||
// temporarily set G.main to the current main
|
||||
gmain = G.main;
|
||||
G.main = main;
|
||||
//XXX hack, material.c uses G_MAIN all over the place, instead of main
|
||||
/* XXX NOTE: this hack should not beneeded anymore... but will check/remove this in 2.8 code rather */
|
||||
// temporarily set G_MAIN to the current main
|
||||
gmain = G_MAIN;
|
||||
G_MAIN = main;
|
||||
|
||||
if (!(do_version_tface(main))) {
|
||||
BKE_report(fd->reports, RPT_WARNING, "Texface conversion problem (see error in console)");
|
||||
}
|
||||
|
||||
//XXX hack, material.c uses G.main allover the place, instead of main
|
||||
G.main = gmain;
|
||||
//XXX hack, material.c uses G_MAIN allover the place, instead of main
|
||||
G_MAIN = gmain;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10324,7 +10325,7 @@ static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepa
|
|||
/**
|
||||
* Initialize the BlendHandle for linking library data.
|
||||
*
|
||||
* \param mainvar The current main database, e.g. G.main or CTX_data_main(C).
|
||||
* \param mainvar The current main database, e.g. G_MAIN or CTX_data_main(C).
|
||||
* \param bh A blender file handle as returned by \a BLO_blendhandle_from_file or \a BLO_blendhandle_from_memory.
|
||||
* \param filepath Used for relative linking, copied to the \a lib->name.
|
||||
* \return the library Main, to be passed to \a BLO_library_append_named_part as \a mainl.
|
||||
|
|
|
@ -4140,7 +4140,7 @@ bool BLO_write_file(
|
|||
if (G.relbase_valid) {
|
||||
/* blend may not have been saved before. Tn this case
|
||||
* we should not have any relative paths, but if there
|
||||
* is somehow, an invalid or empty G.main->name it will
|
||||
* is somehow, an invalid or empty G_MAIN->name it will
|
||||
* print an error, don't try make the absolute in this case. */
|
||||
BKE_bpath_absolute_convert(mainvar, BKE_main_blendfile_path_from_global(), NULL);
|
||||
}
|
||||
|
@ -4148,7 +4148,7 @@ bool BLO_write_file(
|
|||
}
|
||||
|
||||
if (write_flags & G_FILE_RELATIVE_REMAP) {
|
||||
/* note, making relative to something OTHER then G.main->name */
|
||||
/* note, making relative to something OTHER then G_MAIN->name */
|
||||
BKE_bpath_relative_convert(mainvar, filepath, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -590,8 +590,12 @@ BLI_INLINE void bmesh_quick_edgedraw_flag(MEdge *med, BMEdge *e)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* \param bmain May be NULL in case \a calc_object_remap parameter option is set.
|
||||
*/
|
||||
void BM_mesh_bm_to_me(
|
||||
BMesh *bm, Mesh *me,
|
||||
Main *bmain, BMesh *bm, Mesh *me,
|
||||
const struct BMeshToMeshParams *params)
|
||||
{
|
||||
MLoop *mloop;
|
||||
|
@ -752,11 +756,12 @@ void BM_mesh_bm_to_me(
|
|||
|
||||
/* patch hook indices and vertex parents */
|
||||
if (params->calc_object_remap && (ototvert > 0)) {
|
||||
BLI_assert(bmain != NULL);
|
||||
Object *ob;
|
||||
ModifierData *md;
|
||||
BMVert **vertMap = NULL;
|
||||
|
||||
for (ob = G.main->object.first; ob; ob = ob->id.next) {
|
||||
for (ob = bmain->object.first; ob; ob = ob->id.next) {
|
||||
if ((ob->parent) && (ob->parent->data == me) && ELEM(ob->partype, PARVERT1, PARVERT3)) {
|
||||
|
||||
if (vertMap == NULL) {
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
* \ingroup bmesh
|
||||
*/
|
||||
|
||||
struct Main;
|
||||
struct Mesh;
|
||||
|
||||
void BM_mesh_cd_validate(BMesh *bm);
|
||||
|
@ -60,8 +61,8 @@ struct BMeshToMeshParams {
|
|||
int64_t cd_mask_extra;
|
||||
};
|
||||
void BM_mesh_bm_to_me(
|
||||
BMesh *bm, struct Mesh *me,
|
||||
struct Main *bmain, BMesh *bm, struct Mesh *me,
|
||||
const struct BMeshToMeshParams *params)
|
||||
ATTR_NONNULL(1, 2, 3);
|
||||
ATTR_NONNULL(2, 3, 4);
|
||||
|
||||
#endif /* __BMESH_MESH_CONV_H__ */
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "bmesh.h"
|
||||
#include "intern/bmesh_operators_private.h"
|
||||
|
||||
#include "BKE_global.h"
|
||||
|
||||
void bmo_mesh_to_bmesh_exec(BMesh *bm, BMOperator *op)
|
||||
{
|
||||
|
@ -72,7 +73,7 @@ void bmo_bmesh_to_mesh_exec(BMesh *bm, BMOperator *op)
|
|||
/* Object *ob = BMO_slot_ptr_get(op, "object"); */
|
||||
|
||||
BM_mesh_bm_to_me(
|
||||
bm, me,
|
||||
G.main, bm, me,
|
||||
(&(struct BMeshToMeshParams){
|
||||
.calc_object_remap = true,
|
||||
}));
|
||||
|
|
|
@ -442,7 +442,8 @@ void bc_triangulate_mesh(Mesh *me)
|
|||
BM_mesh_triangulate(bm, quad_method, use_beauty, tag_only, NULL, NULL, NULL);
|
||||
|
||||
BMeshToMeshParams bm_to_me_params = {0};
|
||||
BM_mesh_bm_to_me(bm, me, &bm_to_me_params);
|
||||
bm_to_me_params.calc_object_remap = false;
|
||||
BM_mesh_bm_to_me(NULL, bm, me, &bm_to_me_params);
|
||||
BM_mesh_free(bm);
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ void EDBM_mesh_clear(struct BMEditMesh *em);
|
|||
void EDBM_selectmode_to_scene(struct bContext *C);
|
||||
void EDBM_mesh_make(struct Object *ob, const int select_mode, const bool add_key_index);
|
||||
void EDBM_mesh_free(struct BMEditMesh *em);
|
||||
void EDBM_mesh_load(struct Object *ob);
|
||||
void EDBM_mesh_load(struct Main *bmain, struct Object *ob);
|
||||
struct DerivedMesh *EDBM_mesh_deform_dm_get(struct BMEditMesh *em);
|
||||
|
||||
/* flushes based on the current select mode. if in vertex select mode,
|
||||
|
|
|
@ -3223,7 +3223,7 @@ static Base *mesh_separate_tagged(Main *bmain, Scene *scene, Base *base_old, BMe
|
|||
|
||||
BM_mesh_normals_update(bm_new);
|
||||
|
||||
BM_mesh_bm_to_me(bm_new, base_new->object->data, (&(struct BMeshToMeshParams){0}));
|
||||
BM_mesh_bm_to_me(bmain, bm_new, base_new->object->data, (&(struct BMeshToMeshParams){0}));
|
||||
|
||||
BM_mesh_free(bm_new);
|
||||
((Mesh *)base_new->object->data)->edit_btmesh = NULL;
|
||||
|
@ -3526,7 +3526,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op)
|
|||
|
||||
if (retval_iter) {
|
||||
BM_mesh_bm_to_me(
|
||||
bm_old, me,
|
||||
bmain, bm_old, me,
|
||||
(&(struct BMeshToMeshParams){
|
||||
.calc_object_remap = true,
|
||||
}));
|
||||
|
|
|
@ -502,8 +502,8 @@ static void *undomesh_from_editmesh(UndoMesh *um, BMEditMesh *em, Key *key)
|
|||
/* BM_mesh_validate(em->bm); */ /* for troubleshooting */
|
||||
|
||||
BM_mesh_bm_to_me(
|
||||
em->bm, &um->me, (&(struct BMeshToMeshParams){
|
||||
/* Undo code should not be manipulating 'G.main->object' hooks/vertex-parent. */
|
||||
NULL, em->bm, &um->me, (&(struct BMeshToMeshParams){
|
||||
/* Undo code should not be manipulating 'G_MAIN->object' hooks/vertex-parent. */
|
||||
.calc_object_remap = false,
|
||||
.cd_mask_extra = CD_MASK_SHAPE_KEYINDEX,
|
||||
}));
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "BKE_DerivedMesh.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_mesh_mapping.h"
|
||||
#include "BKE_report.h"
|
||||
|
@ -325,7 +326,7 @@ void EDBM_mesh_make(Object *ob, const int select_mode, const bool add_key_index)
|
|||
* \warning This can invalidate the #DerivedMesh cache of other objects (for linked duplicates).
|
||||
* Most callers should run #DAG_id_tag_update on \a ob->data, see: T46738, T46913
|
||||
*/
|
||||
void EDBM_mesh_load(Object *ob)
|
||||
void EDBM_mesh_load(Main *bmain, Object *ob)
|
||||
{
|
||||
Mesh *me = ob->data;
|
||||
BMesh *bm = me->edit_btmesh->bm;
|
||||
|
@ -337,7 +338,7 @@ void EDBM_mesh_load(Object *ob)
|
|||
}
|
||||
|
||||
BM_mesh_bm_to_me(
|
||||
bm, me, (&(struct BMeshToMeshParams){
|
||||
bmain, bm, me, (&(struct BMeshToMeshParams){
|
||||
.calc_object_remap = true,
|
||||
}));
|
||||
|
||||
|
|
|
@ -605,7 +605,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e
|
|||
ED_uvedit_assign_image(bmain, scene, obedit, ima, NULL);
|
||||
|
||||
if (exitmode) {
|
||||
EDBM_mesh_load(obedit);
|
||||
EDBM_mesh_load(bmain, obedit);
|
||||
EDBM_mesh_free(me->edit_btmesh);
|
||||
MEM_freeN(me->edit_btmesh);
|
||||
me->edit_btmesh = NULL;
|
||||
|
|
|
@ -365,7 +365,7 @@ static bool ED_object_editmode_load_ex(Main *bmain, Object *obedit, const bool f
|
|||
return false;
|
||||
}
|
||||
|
||||
EDBM_mesh_load(obedit);
|
||||
EDBM_mesh_load(bmain, obedit);
|
||||
|
||||
if (freedata) {
|
||||
EDBM_mesh_free(me->edit_btmesh);
|
||||
|
|
|
@ -315,7 +315,7 @@ static bool object_hook_index_array(Main *bmain, Scene *scene, Object *obedit,
|
|||
|
||||
BMEditMesh *em;
|
||||
|
||||
EDBM_mesh_load(obedit);
|
||||
EDBM_mesh_load(bmain, obedit);
|
||||
EDBM_mesh_make(obedit, scene->toolsettings->selectmode, true);
|
||||
|
||||
DAG_id_tag_update(obedit->data, 0);
|
||||
|
|
|
@ -139,7 +139,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
|
|||
Mesh *me = obedit->data;
|
||||
BMEditMesh *em;
|
||||
|
||||
EDBM_mesh_load(obedit);
|
||||
EDBM_mesh_load(bmain, obedit);
|
||||
EDBM_mesh_make(obedit, scene->toolsettings->selectmode, true);
|
||||
|
||||
DAG_id_tag_update(obedit->data, 0);
|
||||
|
|
|
@ -5889,6 +5889,7 @@ void PAINT_OT_delete_texture_paint_slot(wmOperatorType *ot)
|
|||
static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
/* no checks here, poll function does them for us */
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Mesh *me = ob->data;
|
||||
|
@ -5913,7 +5914,7 @@ static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
/* set the margin really quickly before the packing operation*/
|
||||
scene->toolsettings->uvcalc_margin = 0.001f;
|
||||
ED_uvedit_pack_islands(scene, ob, bm, false, false, true);
|
||||
BM_mesh_bm_to_me(bm, me, (&(struct BMeshToMeshParams){0}));
|
||||
BM_mesh_bm_to_me(bmain, bm, me, (&(struct BMeshToMeshParams){0}));
|
||||
BM_mesh_free(bm);
|
||||
|
||||
if (synch_selection)
|
||||
|
|
|
@ -273,7 +273,7 @@ static void rna_Object_active_shape_update(Main *bmain, Scene *scene, PointerRNA
|
|||
/* exit/enter editmode to get new shape */
|
||||
switch (ob->type) {
|
||||
case OB_MESH:
|
||||
EDBM_mesh_load(ob);
|
||||
EDBM_mesh_load(bmain, ob);
|
||||
EDBM_mesh_make(ob, scene->toolsettings->selectmode, true);
|
||||
|
||||
DAG_id_tag_update(ob->data, 0);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_customdata.h"
|
||||
#include "BKE_DerivedMesh.h"
|
||||
#include "BKE_global.h"
|
||||
|
||||
#include "bmesh.h"
|
||||
|
||||
|
@ -905,6 +906,7 @@ static PyObject *bpy_bmesh_to_mesh(BPy_BMesh *self, PyObject *args)
|
|||
BM_mesh_cd_validate(bm);
|
||||
|
||||
BM_mesh_bm_to_me(
|
||||
G.main, /* XXX UGLY! */
|
||||
bm, me,
|
||||
(&(struct BMeshToMeshParams){
|
||||
.calc_object_remap = true,
|
||||
|
|
|
@ -223,7 +223,7 @@ bool BPY_string_is_keyword(const char *str) { return false; }
|
|||
|
||||
/*new render funcs */
|
||||
void EDBM_selectmode_set(struct BMEditMesh *em) RET_NONE
|
||||
void EDBM_mesh_load(struct Object *ob) RET_NONE
|
||||
void EDBM_mesh_load(struct Main *bmain, struct Object *ob) RET_NONE
|
||||
void EDBM_mesh_make(struct Object *ob, const int select_mode, const bool use_key_index) RET_NONE
|
||||
void EDBM_mesh_normals_update(struct BMEditMesh *em) RET_NONE
|
||||
void *g_system;
|
||||
|
|
Loading…
Reference in New Issue