Merge branch 'master' into blender2.8

Conflicts:
	source/blender/blenloader/intern/readfile.c
	source/blender/editors/mesh/editmesh_utils.c
	source/blenderplayer/bad_level_call_stubs/stubs.c
This commit is contained in:
Bastien Montagne 2018-06-13 16:42:56 +02:00
commit 4943739b89
21 changed files with 43 additions and 30 deletions

View File

@ -728,8 +728,9 @@ BMesh *BKE_mesh_to_bmesh(
Mesh *BKE_bmesh_to_mesh_nomain(BMesh *bm, const struct BMeshToMeshParams *params)
{
BLI_assert(params->calc_object_remap == false);
Mesh *mesh = BKE_id_new_nomain(ID_ME, NULL);
BM_mesh_bm_to_me(bm, mesh, params);
BM_mesh_bm_to_me(NULL, bm, mesh, params);
return mesh;
}

View File

@ -709,7 +709,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}));
}
}
}

View File

@ -1322,7 +1322,7 @@ static void prepare_mesh_for_viewport_render(
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,
}));

View File

@ -4531,12 +4531,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;
}
/*
@ -10336,7 +10336,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.

View File

@ -4091,7 +4091,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);
}
@ -4099,7 +4099,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);
}

View File

@ -548,8 +548,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;
@ -710,11 +714,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) {

View File

@ -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__ */

View File

@ -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,
}));

View File

@ -449,7 +449,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);
}

View File

@ -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,

View File

@ -3642,7 +3642,7 @@ static Base *mesh_separate_tagged(Main *bmain, Scene *scene, ViewLayer *view_lay
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;
@ -3955,7 +3955,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,
}));

View File

@ -511,8 +511,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,
}));

View File

@ -43,6 +43,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_context.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_report.h"
@ -330,7 +331,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 #DEG_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;
@ -342,7 +343,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,
}));

View File

@ -538,6 +538,7 @@ void MESH_OT_uv_texture_add(wmOperatorType *ot)
static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
Base *base;
@ -578,7 +579,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e
return OPERATOR_CANCELLED;
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;

View File

@ -191,7 +191,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);

View File

@ -318,7 +318,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);
DEG_id_tag_update(obedit->data, 0);

View File

@ -145,7 +145,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);
DEG_id_tag_update(obedit->data, 0);

View File

@ -5791,6 +5791,7 @@ void PAINT_OT_add_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;
@ -5815,7 +5816,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)

View File

@ -278,7 +278,7 @@ static void rna_Object_active_shape_update(bContext *C, PointerRNA *ptr)
/* 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);
DEG_id_tag_update(ob->data, 0);

View File

@ -107,8 +107,7 @@ static Mesh *doEdgeSplit(Mesh *mesh, EdgeSplitModifierData *emd, const ModifierE
/* BM_mesh_validate(bm); */ /* for troubleshooting */
result = BKE_id_new_nomain(ID_ME, mesh->id.name);
BM_mesh_bm_to_me(bm, result, &((struct BMeshToMeshParams){0}));
result = BKE_bmesh_to_mesh_nomain(bm, &((struct BMeshToMeshParams){0}));
BM_mesh_free(bm);
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;

View File

@ -36,6 +36,7 @@
#include "BKE_customdata.h"
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
#include "DEG_depsgraph.h"
@ -903,6 +904,7 @@ static PyObject *bpy_bmesh_to_mesh(BPy_BMesh *self, PyObject *args)
bm = self->bm;
BM_mesh_bm_to_me(
G.main, /* XXX UGLY! */
bm, me,
(&(struct BMeshToMeshParams){
.calc_object_remap = true,