Merge branch 'master' into blender2.8
[blender.git] / source / blender / modifiers / intern / MOD_bevel.c
index bd37358011b9d872a62ae9d1819200765d113cae..81a4e94386fa0c8709e1222c128e05b59bd2ed70 100644 (file)
@@ -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"
@@ -77,11 +79,9 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
 /*
  * This calls the new bevel code (added since 2.64)
  */
-static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob,
-                                  DerivedMesh *dm,
-                                  ModifierApplyFlag UNUSED(flag))
+static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
 {
-       DerivedMesh *result;
+       Mesh *result;
        BMesh *bm;
        BMIter iter;
        BMEdge *e;
@@ -94,12 +94,21 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob,
        const bool vertex_only = (bmd->flags & MOD_BEVEL_VERT) != 0;
        const bool do_clamp = !(bmd->flags & MOD_BEVEL_OVERLAP_OK);
        const int offset_type = bmd->val_flags;
-       const int mat = CLAMPIS(bmd->mat, -1, ob->totcol - 1);
+       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);
+       bm = BKE_mesh_to_bmesh_ex(
+               mesh,
+               &(struct BMeshCreateParams){0},
+               &(struct BMeshFromMeshParams){
+                   .calc_face_normal = true,
+                   .add_key_index = false,
+                   .use_shapekey = true,
+                   .active_shapekey = ctx->object->shapenr,
+               });
+
        if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0])
-               modifier_get_vgroup(ob, 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) {
@@ -159,14 +168,14 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob,
                      vertex_only, bmd->lim_flags & MOD_BEVEL_WEIGHT, do_clamp,
                      dvert, vgroup, mat, loop_slide);
 
-       result = CDDM_from_bmesh(bm, true);
+       result = BKE_bmesh_to_mesh_nomain(bm, &(struct BMeshToMeshParams){0});
 
        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;
+       result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
 
        return result;
 }
@@ -186,17 +195,25 @@ ModifierTypeInfo modifierType_Bevel = {
                                eModifierTypeFlag_EnableInEditmode,
 
        /* copyData */          modifier_copyData_generic,
+
+       /* deformVerts_DM */    NULL,
+       /* deformMatrices_DM */ NULL,
+       /* deformVertsEM_DM */  NULL,
+       /* deformMatricesEM_DM*/NULL,
+       /* applyModifier_DM */  NULL,
+       /* applyModifierEM_DM */NULL,
+
        /* deformVerts */       NULL,
        /* deformMatrices */    NULL,
        /* deformVertsEM */     NULL,
        /* deformMatricesEM */  NULL,
        /* applyModifier */     applyModifier,
        /* applyModifierEM */   NULL,
+
        /* initData */          initData,
        /* requiredDataMask */  requiredDataMask,
        /* freeData */          NULL,
        /* isDisabled */        NULL,
-       /* updateDepgraph */    NULL,
        /* updateDepsgraph */   NULL,
        /* dependsOnTime */     NULL,
        /* dependsOnNormals */  dependsOnNormals,