Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2016-04-29 15:33:06 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-04-29 16:39:50 +0300
commit6d0cae56e84306ed64a51005c4fb1811a40822b7 (patch)
treede25f4c347865a2aefe7d33b8ab5920d35718254 /source/blender/editors
parentb5ce2bbef7a91f81c3556f2ddf6dd5f21161bc91 (diff)
Fix T48290: Hook fails after deleting geometry
Now CD_SHAPEKEY_INDEX customdata is stored in edit-mode when hooks and vertex parents are used. This also fixes a bug where undo would loose key-index data. Move to structs for BM_mesh_bm_to/from_me to avoid passing many argument, which mostly aren't used.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/ED_mesh.h2
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c6
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c16
-rw-r--r--source/blender/editors/mesh/mesh_data.c2
-rw-r--r--source/blender/editors/mesh/meshtools.c2
-rw-r--r--source/blender/editors/object/object_edit.c25
-rw-r--r--source/blender/editors/object/object_hook.c2
-rw-r--r--source/blender/editors/object/object_relations.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c8
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c5
10 files changed, 52 insertions, 18 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 5436ef4b06b..de798b1fce2 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -80,7 +80,7 @@ void EDBM_mesh_normals_update(struct BMEditMesh *em);
void EDBM_mesh_clear(struct BMEditMesh *em);
void EDBM_selectmode_to_scene(struct bContext *C);
-void EDBM_mesh_make(struct ToolSettings *ts, struct Object *ob);
+void EDBM_mesh_make(struct ToolSettings *ts, struct Object *ob, const bool add_key_index);
void EDBM_mesh_free(struct BMEditMesh *em);
void EDBM_mesh_load(struct Object *ob);
struct DerivedMesh *EDBM_mesh_deform_dm_get(struct BMEditMesh *em);
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 44f0c6f2248..49794d2e5cd 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -3011,7 +3011,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, false);
+ BM_mesh_bm_to_me(bm_new, base_new->object->data, (&(struct BMeshToMeshParams){0}));
BM_mesh_free(bm_new);
((Mesh *)base_new->object->data)->edit_btmesh = NULL;
@@ -3294,7 +3294,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op)
bm_old = BM_mesh_create(&bm_mesh_allocsize_default);
- BM_mesh_bm_from_me(bm_old, me, false, false, 0);
+ BM_mesh_bm_from_me(bm_old, me, (&(struct BMeshFromMeshParams){0}));
switch (type) {
case MESH_SEPARATE_MATERIAL:
@@ -3309,7 +3309,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op)
}
if (retval_iter) {
- BM_mesh_bm_to_me(bm_old, me, false);
+ BM_mesh_bm_to_me(bm_old, me, (&(struct BMeshToMeshParams){0}));
DAG_id_tag_update(&me->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 33f8455e614..82ec93c162f 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -347,7 +347,7 @@ void EDBM_selectmode_to_scene(bContext *C)
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, scene);
}
-void EDBM_mesh_make(ToolSettings *ts, Object *ob)
+void EDBM_mesh_make(ToolSettings *ts, Object *ob, const bool add_key_index)
{
Mesh *me = ob->data;
BMesh *bm;
@@ -356,7 +356,7 @@ void EDBM_mesh_make(ToolSettings *ts, Object *ob)
BKE_mesh_convert_mfaces_to_mpolys(me);
}
- bm = BKE_mesh_to_bmesh(me, ob);
+ bm = BKE_mesh_to_bmesh(me, ob, add_key_index);
if (me->edit_btmesh) {
/* this happens when switching shape keys */
@@ -395,7 +395,7 @@ void EDBM_mesh_load(Object *ob)
bm->shapenr = 1;
}
- BM_mesh_bm_to_me(bm, me, false);
+ BM_mesh_bm_to_me(bm, me, (&(struct BMeshToMeshParams){0}));
#ifdef USE_TESSFACE_DEFAULT
BKE_mesh_tessface_calc(me);
@@ -533,7 +533,10 @@ static void *editbtMesh_to_undoMesh(void *emv, void *obdata)
/* BM_mesh_validate(em->bm); */ /* for troubleshooting */
- BM_mesh_bm_to_me(em->bm, &um->me, false);
+ BM_mesh_bm_to_me(
+ em->bm, &um->me, (&(struct BMeshToMeshParams){
+ .cd_mask_extra = CD_MASK_SHAPE_KEYINDEX,
+ }));
um->selectmode = em->selectmode;
um->shapenr = em->bm->shapenr;
@@ -557,7 +560,10 @@ static void undoMesh_to_editbtMesh(void *umv, void *em_v, void *obdata)
bm = BM_mesh_create(&allocsize);
- BM_mesh_bm_from_me(bm, &um->me, true, false, um->shapenr);
+ BM_mesh_bm_from_me(
+ bm, &um->me, (&(struct BMeshFromMeshParams){
+ .calc_face_normal = true, .active_shapekey = um->shapenr,
+ }));
em_tmp = BKE_editmesh_create(bm, true);
*em = *em_tmp;
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index a2054a5f43c..e0ddc017e93 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -582,7 +582,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e
obedit = base->object;
me = obedit->data;
if (me->edit_btmesh == NULL) {
- EDBM_mesh_make(scene->toolsettings, obedit);
+ EDBM_mesh_make(scene->toolsettings, obedit, false);
exitmode = 1;
}
if (me->edit_btmesh == NULL)
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index bad835b13e7..90676d2b951 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -572,7 +572,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR | EM_DO_UNDO);
#else
/* toggle editmode using lower level functions so this can be called from python */
- EDBM_mesh_make(scene->toolsettings, ob);
+ EDBM_mesh_make(scene->toolsettings, ob, false);
EDBM_mesh_load(ob);
EDBM_mesh_free(me->edit_btmesh);
MEM_freeN(me->edit_btmesh);
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 56d27bfd727..06200778ee5 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -316,6 +316,27 @@ void OBJECT_OT_hide_render_set(wmOperatorType *ot)
/* ******************* toggle editmode operator ***************** */
+static bool mesh_needs_keyindex(const Mesh *me)
+{
+ if (me->key) {
+ return false; /* will be added */
+ }
+
+ for (const Object *ob = G.main->object.first; ob; ob = ob->id.next) {
+ if ((ob->parent) && (ob->parent->data == me) && ELEM(ob->partype, PARVERT1, PARVERT3)) {
+ return true;
+ }
+ if (ob->data == me) {
+ for (const ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Hook) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
/**
* Load EditMode data back into the object,
* optionally freeing the editmode data.
@@ -494,7 +515,9 @@ void ED_object_editmode_enter(bContext *C, int flag)
ok = 1;
scene->obedit = ob; /* context sees this */
- EDBM_mesh_make(scene->toolsettings, ob);
+ const bool use_key_index = mesh_needs_keyindex(ob->data);
+
+ EDBM_mesh_make(scene->toolsettings, ob, use_key_index);
em = BKE_editmesh_from_object(ob);
if (LIKELY(em)) {
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index 492b6724f93..438c10c51fa 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -316,7 +316,7 @@ static bool object_hook_index_array(Scene *scene, Object *obedit,
BMEditMesh *em;
EDBM_mesh_load(obedit);
- EDBM_mesh_make(scene->toolsettings, obedit);
+ EDBM_mesh_make(scene->toolsettings, obedit, true);
DAG_id_tag_update(obedit->data, 0);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 84cf97ecb7c..2f10f83e276 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -136,7 +136,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
BMEditMesh *em;
EDBM_mesh_load(obedit);
- EDBM_mesh_make(scene->toolsettings, obedit);
+ EDBM_mesh_make(scene->toolsettings, obedit, true);
DAG_id_tag_update(obedit->data, 0);
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index f614025fa0e..bce3b46010b 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -5866,15 +5866,17 @@ static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op))
ED_mesh_uv_texture_ensure(me, NULL);
- BM_mesh_bm_from_me(bm, me, true, false, 0);
-
+ BM_mesh_bm_from_me(
+ bm, me,(&(struct BMeshFromMeshParams){
+ .calc_face_normal = true,
+ }));
/* select all uv loops first - pack parameters needs this to make sure charts are registered */
ED_uvedit_select_all(bm);
ED_uvedit_unwrap_cube_project(ob, bm, 1.0, false);
/* 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, false);
+ BM_mesh_bm_to_me(bm, me, (&(struct BMeshToMeshParams){0}));
BM_mesh_free(bm);
if (synch_selection)
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 40ff662a2c2..7ebc050978a 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5003,7 +5003,10 @@ void sculpt_dynamic_topology_enable(bContext *C)
/* Create triangles-only BMesh */
ss->bm = BM_mesh_create(&allocsize);
- BM_mesh_bm_from_me(ss->bm, me, true, true, ob->shapenr);
+ BM_mesh_bm_from_me(
+ ss->bm, me, (&(struct BMeshFromMeshParams){
+ .calc_face_normal = true, .use_shapekey = true, .active_shapekey = ob->shapenr,
+ }));
sculpt_dynamic_topology_triangulate(ss->bm);
BM_data_layer_add(ss->bm, &ss->bm->vdata, CD_PAINT_MASK);
sculpt_dyntopo_node_layers_add(ss);