Revert "Modifiers: every modifier now copies mesh settings, fixing texture space issues"

This reverts commit e7a514369f, it introduces
a bug in selection in edit mode.

Fixes T70103: can't select extruded Vertex

Ref T64739
This commit is contained in:
2019-09-21 00:01:09 +02:00
parent bf14e323e6
commit 7926e8ea4c
20 changed files with 76 additions and 93 deletions

View File

@@ -729,7 +729,7 @@ static Mesh *create_orco_mesh(Object *ob, Mesh *me, BMEditMesh *em, int layer)
int free;
if (em) {
mesh = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, NULL, me);
mesh = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, NULL);
}
else {
mesh = BKE_mesh_copy_for_eval(me, true);
@@ -797,6 +797,14 @@ static void editmesh_update_statvis_color(const Scene *scene, Object *ob)
BKE_editmesh_statvis_calc(em, me->runtime.edit_data, &scene->toolsettings->statvis);
}
static void mesh_copy_autosmooth(Mesh *me, Mesh *me_orig)
{
if (me_orig->flag & ME_AUTOSMOOTH) {
me->flag |= ME_AUTOSMOOTH;
me->smoothresh = me_orig->smoothresh;
}
}
static void mesh_calc_modifier_final_normals(const Mesh *mesh_input,
const CustomData_MeshMasks *final_datamask,
const bool sculpt_dyntopo,
@@ -873,8 +881,18 @@ static void mesh_calc_finalize(const Mesh *mesh_input, Mesh *mesh_eval)
/* Make sure the name is the same. This is because mesh allocation from template does not
* take care of naming. */
BLI_strncpy(mesh_eval->id.name, mesh_input->id.name, sizeof(mesh_eval->id.name));
/* Make sure materials are preserved from the input. */
if (mesh_eval->mat != NULL) {
MEM_freeN(mesh_eval->mat);
}
mesh_eval->mat = MEM_dupallocN(mesh_input->mat);
mesh_eval->totcol = mesh_input->totcol;
/* Make evaluated mesh to share same edit mesh pointer as original and copied meshes. */
mesh_eval->edit_mesh = mesh_input->edit_mesh;
/* Copy auth-smooth settings which are also not taken care about by mesh allocation from a
* template. */
mesh_eval->flag |= (mesh_input->flag & ME_AUTOSMOOTH);
mesh_eval->smoothresh = mesh_input->smoothresh;
}
static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
@@ -1202,6 +1220,8 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
MEM_freeN(deformed_verts);
deformed_verts = NULL;
}
mesh_copy_autosmooth(mesh_final, mesh_input);
}
/* create an orco mesh in parallel */
@@ -1513,8 +1533,8 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
/* Evaluate modifiers up to certain index to get the mesh cage. */
int cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1);
if (r_cage && cageIndex == -1) {
mesh_cage = BKE_mesh_from_editmesh_with_coords_thin_wrap(
em_input, &final_datamask, NULL, mesh_input);
mesh_cage = BKE_mesh_from_editmesh_with_coords_thin_wrap(em_input, &final_datamask, NULL);
mesh_copy_autosmooth(mesh_cage, mesh_input);
}
/* Clear errors before evaluation. */
@@ -1554,8 +1574,9 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
}
else if (isPrevDeform && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
if (mesh_final == NULL) {
mesh_final = BKE_mesh_from_bmesh_for_eval_nomain(em_input->bm, NULL, mesh_input);
mesh_final = BKE_mesh_from_bmesh_for_eval_nomain(em_input->bm, NULL);
ASSERT_IS_VALID_MESH(mesh_final);
mesh_copy_autosmooth(mesh_final, mesh_input);
}
BLI_assert(deformed_verts != NULL);
BKE_mesh_vert_coords_apply(mesh_final, deformed_verts);
@@ -1586,9 +1607,11 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
}
}
else {
mesh_final = BKE_mesh_from_bmesh_for_eval_nomain(em_input->bm, NULL, mesh_input);
mesh_final = BKE_mesh_from_bmesh_for_eval_nomain(em_input->bm, NULL);
ASSERT_IS_VALID_MESH(mesh_final);
mesh_copy_autosmooth(mesh_final, mesh_input);
if (deformed_verts) {
BKE_mesh_vert_coords_apply(mesh_final, deformed_verts);
}
@@ -1651,6 +1674,8 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
MEM_freeN(deformed_verts);
deformed_verts = NULL;
}
mesh_copy_autosmooth(mesh_final, mesh_input);
}
mesh_final->runtime.deformed_only = false;
}
@@ -1670,10 +1695,8 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
me_orig->runtime.edit_data->vertexCos = MEM_dupallocN(deformed_verts);
}
mesh_cage = BKE_mesh_from_editmesh_with_coords_thin_wrap(
em_input,
&final_datamask,
deformed_verts ? MEM_dupallocN(deformed_verts) : NULL,
mesh_input);
em_input, &final_datamask, deformed_verts ? MEM_dupallocN(deformed_verts) : NULL);
mesh_copy_autosmooth(mesh_cage, mesh_input);
}
}
@@ -1707,9 +1730,11 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
else {
/* this is just a copy of the editmesh, no need to calc normals */
mesh_final = BKE_mesh_from_editmesh_with_coords_thin_wrap(
em_input, &final_datamask, deformed_verts, mesh_input);
em_input, &final_datamask, deformed_verts);
deformed_verts = NULL;
mesh_copy_autosmooth(mesh_final, mesh_input);
/* In this case, we should never have weight-modifying modifiers in stack... */
if (do_init_statvis) {
editmesh_update_statvis_color(scene, ob);
@@ -1829,6 +1854,11 @@ static void mesh_build_data(struct Depsgraph *depsgraph,
&ob->runtime.mesh_eval);
BKE_object_boundbox_calc_from_mesh(ob, ob->runtime.mesh_eval);
/* Only copy texspace from orig mesh if some modifier (hint: smoke sim, see T58492)
* did not re-enable that flag (which always get disabled for eval mesh as a start). */
if (!(ob->runtime.mesh_eval->texflag & ME_AUTOSPACE)) {
BKE_mesh_texspace_copy_from_object(ob->runtime.mesh_eval, ob);
}
assign_object_mesh_eval(ob);