Merge branch 'master' into blender2.8
[blender.git] / source / blender / modifiers / intern / MOD_wireframe.c
index 84a507cd35cf19d465b431fbc332d0b556ad28aa..9dfc23fbf5f071c324ef61ce70bf437a9e25daaf 100644 (file)
  *  \ingroup modifiers
  */
 
+#include "DNA_mesh_types.h"
 #include "DNA_object_types.h"
 
 #include "BLI_utildefines.h"
 
 #include "BKE_cdderivedmesh.h"
 #include "BKE_deform.h"
+#include "BKE_mesh.h"
 
 #include "MOD_modifiertypes.h"
 
@@ -60,14 +62,22 @@ static bool dependsOnNormals(ModifierData *UNUSED(md))
        return true;
 }
 
-static DerivedMesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob, DerivedMesh *dm)
+static Mesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob, Mesh *mesh)
 {
-       DerivedMesh *result;
+       Mesh *result;
        BMesh *bm;
 
        const int defgrp_index = defgroup_name_index(ob, wmd->defgrp_name);
 
-       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 = ob->shapenr,
+               });
 
        BM_mesh_wireframe(
               bm,
@@ -84,18 +94,21 @@ static DerivedMesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob,
               MAX2(ob->totcol - 1, 0),
               false);
 
-       result = CDDM_from_bmesh(bm, true);
+       result = BKE_bmesh_to_mesh_nomain(bm, &(struct BMeshToMeshParams){0});
        BM_mesh_free(bm);
 
-       result->dirty |= DM_DIRTY_NORMALS;
+       result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
 
        return result;
 
 }
 
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, ModifierApplyFlag UNUSED(flag))
+static Mesh *applyModifier(
+        ModifierData *md,
+        const struct ModifierEvalContext *ctx,
+        struct Mesh *mesh)
 {
-       return WireframeModifier_do((WireframeModifierData *)md, ob, dm);
+       return WireframeModifier_do((WireframeModifierData *)md, ctx->object, mesh);
 }
 
 
@@ -108,18 +121,26 @@ ModifierTypeInfo modifierType_Wireframe = {
                                eModifierTypeFlag_SupportsEditmode,
 
        /* 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,
        /* foreachObjectLink */ NULL,