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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-09-21 01:01:09 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-09-21 01:35:46 +0300
commit7926e8ea4c11e55c56b1d051e9ccb68dbfddb58b (patch)
tree500317d9bc743835c8262bc308ef586b069154ea /source/blender/blenkernel
parentbf14e323e67f5cc7721a088bc8ea5fe00f2f7296 (diff)
Revert "Modifiers: every modifier now copies mesh settings, fixing texture space issues"
This reverts commit e7a514369fe700dcc5a1fe433c8f709ed9595ded, it introduces a bug in selection in edit mode. Fixes T70103: can't select extruded Vertex Ref T64739
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_mesh.h13
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c50
-rw-r--r--source/blender/blenkernel/intern/crazyspace.c6
-rw-r--r--source/blender/blenkernel/intern/mesh.c51
-rw-r--r--source/blender/blenkernel/intern/smoke.c10
5 files changed, 60 insertions, 70 deletions
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index b60702269a4..af40eef6ab5 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -78,18 +78,12 @@ struct BMesh *BKE_mesh_to_bmesh(struct Mesh *me,
const bool add_key_index,
const struct BMeshCreateParams *params);
-struct Mesh *BKE_mesh_from_bmesh_nomain(struct BMesh *bm,
- const struct BMeshToMeshParams *params,
- const struct Mesh *me_settings);
+struct Mesh *BKE_mesh_from_bmesh_nomain(struct BMesh *bm, const struct BMeshToMeshParams *params);
struct Mesh *BKE_mesh_from_bmesh_for_eval_nomain(struct BMesh *bm,
- const struct CustomData_MeshMasks *cd_mask_extra,
- const struct Mesh *me_settings);
+ const struct CustomData_MeshMasks *cd_mask_extra);
struct Mesh *BKE_mesh_from_editmesh_with_coords_thin_wrap(
- struct BMEditMesh *em,
- const struct CustomData_MeshMasks *data_mask,
- float (*vertexCos)[3],
- const struct Mesh *me_settings);
+ struct BMEditMesh *em, const struct CustomData_MeshMasks *data_mask, float (*vertexCos)[3]);
int poly_find_loop_from_vert(const struct MPoly *poly,
const struct MLoop *loopstart,
@@ -113,7 +107,6 @@ void BKE_mesh_copy_data(struct Main *bmain,
const struct Mesh *me_src,
const int flag);
struct Mesh *BKE_mesh_copy(struct Main *bmain, const struct Mesh *me);
-void BKE_mesh_copy_settings(struct Mesh *me_dst, const struct Mesh *me_src);
void BKE_mesh_update_customdata_pointers(struct Mesh *me, const bool do_ensure_tess_cd);
void BKE_mesh_ensure_skin_customdata(struct Mesh *me);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 4849d631493..010e162f49d 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -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);
diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c
index 6740fc985e9..af4bd5d2ebd 100644
--- a/source/blender/blenkernel/intern/crazyspace.c
+++ b/source/blender/blenkernel/intern/crazyspace.c
@@ -261,8 +261,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct Depsgraph *depsgra
float (**deformcos)[3])
{
ModifierData *md;
- Mesh *me_input = ob->data;
- Mesh *me = NULL;
+ Mesh *me;
int i, a, numleft = 0, numVerts = 0;
int cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1);
float(*defmats)[3][3] = NULL, (*deformedVerts)[3] = NULL;
@@ -271,6 +270,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct Depsgraph *depsgra
modifiers_clearErrors(ob);
+ me = NULL;
md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
/* compute the deformation matrices and coordinates for the first
@@ -292,7 +292,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct Depsgraph *depsgra
data_mask = datamasks->mask;
BLI_linklist_free((LinkNode *)datamasks, NULL);
- me = BKE_mesh_from_editmesh_with_coords_thin_wrap(em, &data_mask, NULL, me_input);
+ me = BKE_mesh_from_editmesh_with_coords_thin_wrap(em, &data_mask, NULL);
deformedVerts = editbmesh_vert_coords_alloc(em, &numVerts);
defmats = MEM_mallocN(sizeof(*defmats) * numVerts, "defmats");
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 6c3c083b39a..c108ff90850 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -659,35 +659,6 @@ Mesh *BKE_mesh_new_nomain(
return mesh;
}
-/* Copy user editable settings that we want to preserve through the modifier stack
- * or operations where a mesh with new topology is created based on another mesh. */
-void BKE_mesh_copy_settings(Mesh *me_dst, const Mesh *me_src)
-{
- /* Copy general settings. */
- me_dst->editflag = me_src->editflag;
- me_dst->flag = me_src->flag;
- me_dst->smoothresh = me_src->smoothresh;
- me_dst->remesh_voxel_size = me_src->remesh_voxel_size;
- me_dst->remesh_mode = me_src->remesh_mode;
-
- /* Copy texture space. */
- me_dst->texflag = me_src->texflag;
- if (me_dst->bb != NULL && me_dst->bb != me_src->bb) {
- MEM_freeN(me_dst->bb);
- }
- me_dst->bb = MEM_dupallocN(me_src->bb);
- copy_v3_v3(me_dst->loc, me_src->loc);
- copy_v3_v3(me_dst->rot, me_src->rot);
- copy_v3_v3(me_dst->size, me_src->size);
-
- /* Copy materials. */
- if (me_dst->mat != NULL && me_dst->mat != me_src->mat) {
- MEM_freeN(me_dst->mat);
- }
- me_dst->mat = MEM_dupallocN(me_src->mat);
- me_dst->totcol = me_src->totcol;
-}
-
Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
int verts_len,
int edges_len,
@@ -701,6 +672,7 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
Mesh *me_dst = BKE_id_new_nomain(ID_ME, NULL);
+ me_dst->mat = MEM_dupallocN(me_src->mat);
me_dst->mselect = MEM_dupallocN(me_dst->mselect);
me_dst->totvert = verts_len;
@@ -710,7 +682,8 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
me_dst->totpoly = polys_len;
me_dst->cd_flag = me_src->cd_flag;
- BKE_mesh_copy_settings(me_dst, me_src);
+ me_dst->editflag = me_src->editflag;
+ me_dst->texflag = me_src->texflag;
CustomData_copy(&me_src->vdata, &me_dst->vdata, mask.vmask, CD_CALLOC, verts_len);
CustomData_copy(&me_src->edata, &me_dst->edata, mask.emask, CD_CALLOC, edges_len);
@@ -799,24 +772,18 @@ BMesh *BKE_mesh_to_bmesh(Mesh *me,
});
}
-Mesh *BKE_mesh_from_bmesh_nomain(BMesh *bm,
- const struct BMeshToMeshParams *params,
- const Mesh *me_settings)
+Mesh *BKE_mesh_from_bmesh_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(NULL, bm, mesh, params);
- BKE_mesh_copy_settings(mesh, me_settings);
return mesh;
}
-Mesh *BKE_mesh_from_bmesh_for_eval_nomain(BMesh *bm,
- const CustomData_MeshMasks *cd_mask_extra,
- const Mesh *me_settings)
+Mesh *BKE_mesh_from_bmesh_for_eval_nomain(BMesh *bm, const CustomData_MeshMasks *cd_mask_extra)
{
Mesh *mesh = BKE_id_new_nomain(ID_ME, NULL);
BM_mesh_bm_to_me_for_eval(bm, mesh, cd_mask_extra);
- BKE_mesh_copy_settings(mesh, me_settings);
return mesh;
}
@@ -825,10 +792,9 @@ Mesh *BKE_mesh_from_bmesh_for_eval_nomain(BMesh *bm,
*/
Mesh *BKE_mesh_from_editmesh_with_coords_thin_wrap(BMEditMesh *em,
const CustomData_MeshMasks *data_mask,
- float (*vertexCos)[3],
- const Mesh *me_settings)
+ float (*vertexCos)[3])
{
- Mesh *me = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, data_mask, me_settings);
+ Mesh *me = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, data_mask);
/* Use editmesh directly where possible. */
me->runtime.is_original = true;
if (vertexCos) {
@@ -1983,6 +1949,9 @@ void BKE_mesh_eval_geometry(Depsgraph *depsgraph, Mesh *mesh)
{
DEG_debug_print_eval(depsgraph, __func__, mesh->id.name, mesh);
BKE_mesh_texspace_calc(mesh);
+ /* Clear autospace flag in evaluated mesh, so that texspace does not get recomputed when bbox is
+ * (e.g. after modifiers, etc.) */
+ mesh->texflag &= ~ME_AUTOSPACE;
/* We are here because something did change in the mesh. This means we can not trust the existing
* evaluated mesh, and we don't know what parts of the mesh did change. So we simply delete the
* evaluated mesh and let objects to re-create it with updated settings. */
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index e6c414b92da..74873db179d 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -3352,16 +3352,14 @@ struct Mesh *smokeModifier_do(
if (smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain &&
smd->domain->flags & MOD_SMOKE_ADAPTIVE_DOMAIN && smd->domain->base_res[0]) {
result = createDomainGeometry(smd->domain, ob);
- BKE_mesh_copy_settings(result, me);
}
else {
result = BKE_mesh_copy_for_eval(me, false);
}
-
- /* Smoke simulation needs a texture space relative to the adaptive domain bounds, not the
- * original mesh. So recompute it at this point in the modifier stack. See T58492. */
- BKE_mesh_texspace_calc(result);
-
+ /* XXX This is really not a nice hack, but until root of the problem is understood,
+ * this should be an acceptable workaround I think.
+ * See T58492 for details on the issue. */
+ result->texflag |= ME_AUTOSPACE;
return result;
}