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:
authorSybren A. Stüvel <sybren@stuvel.eu>2018-05-02 12:39:23 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2018-05-02 13:15:00 +0300
commit81175eb40ddbbd8ea9c98eb71f590b148012eb06 (patch)
tree75c3942ed83873519c60733799e77d4e61953ba1 /source/blender/modifiers
parentbaf0547de57397d2f12404d1cc1e861aa1e90d83 (diff)
Modifiers: ported Bevel modifier DerivedMesh → Mesh
This introduces `BKE_mesh_to_bmesh_ex()`, which exposes all of the `BMeshFromMeshParams` parameters to the caller. This is required to enable the `calc_face_normal` flag, which is required for the Bevel modifier. This also introduces `BKE_bmesh_to_mesh()`, which allocates a new `Mesh`, converts the `BMesh` to it, and returns it. The returned mesh is owned by the caller.
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c10
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c28
2 files changed, 20 insertions, 18 deletions
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index f354ed3aada..d48c4e2549d 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -136,12 +136,9 @@ static void deformVertsEM(
ArmatureModifierData *amd = (ArmatureModifierData *) md;
Mesh *mesh_src = mesh;
- /* TODO(sybren): possibly lift this code to modifier.c and use it for all modifiers */
if (!mesh) {
struct BMeshToMeshParams params = {0};
- mesh_src = BKE_libblock_alloc_notest(ID_ME);
- BKE_mesh_init(mesh_src);
- BM_mesh_bm_to_me(em->bm, mesh_src, &params);
+ mesh_src = BKE_bmesh_to_mesh(em->bm, &params);
}
modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
@@ -169,12 +166,9 @@ static void deformMatricesEM(
ArmatureModifierData *amd = (ArmatureModifierData *) md;
Mesh *mesh_src = mesh;
- /* TODO(sybren): possibly lift this code to modifier.c and use it for all modifiers */
if (!mesh) {
struct BMeshToMeshParams params = {0};
- mesh_src = BKE_libblock_alloc_notest(ID_ME);
- BKE_mesh_init(mesh_src);
- BM_mesh_bm_to_me(em->bm, mesh_src, &params);
+ mesh_src = BKE_bmesh_to_mesh(em->bm, &params);
}
armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, defMats, numVerts,
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 4134314bd85..325b70ddc5e 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -33,6 +33,7 @@
*/
#include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
#include "BLI_utildefines.h"
#include "BLI_math.h"
@@ -40,6 +41,7 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_deform.h"
+#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "MOD_util.h"
@@ -86,10 +88,9 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
/*
* This calls the new bevel code (added since 2.64)
*/
-static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
- DerivedMesh *dm)
+static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
{
- DerivedMesh *result;
+ Mesh *result;
BMesh *bm;
BMIter iter;
BMEdge *e;
@@ -105,9 +106,17 @@ static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *c
const int mat = CLAMPIS(bmd->mat, -1, ctx->object->totcol - 1);
const bool loop_slide = (bmd->flags & MOD_BEVEL_EVEN_WIDTHS) == 0;
- bm = DM_to_bmesh(dm, true);
+ const struct BMeshCreateParams bmcp = {0};
+ const struct BMeshFromMeshParams bmfmp = {
+ .calc_face_normal = true,
+ .add_key_index = false,
+ .use_shapekey = true,
+ .active_shapekey = ctx->object->shapenr,
+ };
+ bm = BKE_mesh_to_bmesh_ex(mesh, &bmcp, &bmfmp);
+
if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0])
- modifier_get_vgroup(ctx->object, dm, bmd->defgrp_name, &dvert, &vgroup);
+ modifier_get_vgroup_mesh(ctx->object, mesh, bmd->defgrp_name, &dvert, &vgroup);
if (vertex_only) {
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
@@ -167,15 +176,14 @@ static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *c
vertex_only, bmd->lim_flags & MOD_BEVEL_WEIGHT, do_clamp,
dvert, vgroup, mat, loop_slide);
- result = CDDM_from_bmesh(bm, true);
+ struct BMeshToMeshParams bmmp = {0};
+ result = BKE_bmesh_to_mesh(bm, &bmmp);
BLI_assert(bm->vtoolflagpool == NULL &&
bm->etoolflagpool == NULL &&
bm->ftoolflagpool == NULL); /* make sure we never alloc'd these */
BM_mesh_free(bm);
- result->dirty |= DM_DIRTY_NORMALS;
-
return result;
}
@@ -199,14 +207,14 @@ ModifierTypeInfo modifierType_Bevel = {
/* deformMatrices_DM */ NULL,
/* deformVertsEM_DM */ NULL,
/* deformMatricesEM_DM*/NULL,
- /* applyModifier_DM */ applyModifier,
+ /* applyModifier_DM */ NULL,
/* applyModifierEM_DM */NULL,
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
- /* applyModifier */ NULL,
+ /* applyModifier */ applyModifier,
/* applyModifierEM */ NULL,
/* initData */ initData,