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>2021-01-05 14:27:49 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-01-05 14:48:12 +0300
commit105d385e4b73f353350a3a1894eb0d9e933130c3 (patch)
tree601a0689e7caeeae235a45dc9f06266ab5a5176a /source/blender/blenkernel/intern/mesh_mirror.c
parent724110487721226812a111cb147b85622f2c19e4 (diff)
Fix T84364: Sculpt symmetrize fails with shape keys
Use the BMesh symmetrize operator instead of using the modifier code. While we could support shape-keys with the existing code used by the mirror modifier, we'd need to add code-paths for evaluated mesh & bmesh conversion to handle shape-keys differently just for this one case, since we want to avoid copying & processing shape-keys layers for evaluated meshes in general.
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_mirror.c')
-rw-r--r--source/blender/blenkernel/intern/mesh_mirror.c59
1 files changed, 48 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/mesh_mirror.c b/source/blender/blenkernel/intern/mesh_mirror.c
index 46764a56e60..a22b52d68d5 100644
--- a/source/blender/blenkernel/intern/mesh_mirror.c
+++ b/source/blender/blenkernel/intern/mesh_mirror.c
@@ -41,11 +41,11 @@
#include "MOD_modifiertypes.h"
-Mesh *BKE_mesh_mirror_bisect_on_mirror_plane(MirrorModifierData *mmd,
- const Mesh *mesh,
- int axis,
- const float plane_co[3],
- float plane_no[3])
+Mesh *BKE_mesh_mirror_bisect_on_mirror_plane_for_modifier(MirrorModifierData *mmd,
+ const Mesh *mesh,
+ int axis,
+ const float plane_co[3],
+ float plane_no[3])
{
bool do_bisect_flip_axis = ((axis == 0 && mmd->flag & MOD_MIR_BISECT_FLIP_AXIS_X) ||
(axis == 1 && mmd->flag & MOD_MIR_BISECT_FLIP_AXIS_Y) ||
@@ -97,11 +97,47 @@ Mesh *BKE_mesh_mirror_bisect_on_mirror_plane(MirrorModifierData *mmd,
return result;
}
-Mesh *BKE_mesh_mirror_apply_mirror_on_axis(MirrorModifierData *mmd,
- const ModifierEvalContext *UNUSED(ctx),
- Object *ob,
- const Mesh *mesh,
- int axis)
+void BKE_mesh_mirror_apply_mirror_on_axis(struct Main *bmain,
+ Mesh *mesh,
+ const int axis,
+ const float dist)
+{
+ BMesh *bm = BKE_mesh_to_bmesh_ex(mesh,
+ &(struct BMeshCreateParams){
+ .use_toolflags = 1,
+ },
+ &(struct BMeshFromMeshParams){
+ .calc_face_normal = true,
+ .cd_mask_extra =
+ {
+ .vmask = CD_MASK_SHAPEKEY,
+ },
+ });
+ BMO_op_callf(bm,
+ (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE),
+ "symmetrize input=%avef direction=%i dist=%f use_shapekey=%b",
+ axis,
+ dist,
+ true);
+
+ BM_mesh_bm_to_me(bmain,
+ bm,
+ mesh,
+ (&(struct BMeshToMeshParams){
+ .calc_object_remap = true,
+
+ }));
+ BM_mesh_free(bm);
+}
+
+/**
+ * \warning This should _not_ be used to modify original meshes since
+ * it doesn't handle shape-keys, use #BKE_mesh_mirror_apply_mirror_on_axis instead.
+ */
+Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
+ Object *ob,
+ const Mesh *mesh,
+ const int axis)
{
const float tolerance_sq = mmd->tolerance * mmd->tolerance;
const bool do_vtargetmap = (mmd->flag & MOD_MIR_NO_MERGE) == 0;
@@ -157,7 +193,8 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis(MirrorModifierData *mmd,
Mesh *mesh_bisect = NULL;
if (do_bisect) {
- mesh_bisect = BKE_mesh_mirror_bisect_on_mirror_plane(mmd, mesh, axis, plane_co, plane_no);
+ mesh_bisect = BKE_mesh_mirror_bisect_on_mirror_plane_for_modifier(
+ mmd, mesh, axis, plane_co, plane_no);
mesh = mesh_bisect;
}