diff options
Diffstat (limited to 'source/blender/modifiers/intern/MOD_simpledeform.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_simpledeform.c | 74 |
1 files changed, 32 insertions, 42 deletions
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index d14310d9199..f9da939b21b 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -32,22 +32,24 @@ * \ingroup modifiers */ +#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "BLI_math.h" #include "BLI_utildefines.h" -#include "BKE_cdderivedmesh.h" +#include "BKE_editmesh.h" +#include "BKE_mesh.h" +#include "BKE_library.h" #include "BKE_library_query.h" #include "BKE_modifier.h" #include "BKE_deform.h" - -#include "depsgraph_private.h" - #include "MOD_util.h" +#include "bmesh.h" + #define BEND_EPS 0.000001f /* Re-maps the indices for X Y Z by shifting them up and wrapping, such that @@ -184,11 +186,10 @@ static void simpleDeform_bend(const float factor, const int axis, const float dc /* simple deform modifier */ static void SimpleDeformModifier_do( - SimpleDeformModifierData *smd, struct Object *ob, struct DerivedMesh *dm, + SimpleDeformModifierData *smd, struct Object *ob, struct Mesh *mesh, float (*vertexCos)[3], int numVerts) { const float base_limit[2] = {0.0f, 0.0f}; - int i; float smd_limit[2], smd_factor; SpaceTransform *transf = NULL, tmp_transf; @@ -285,7 +286,7 @@ static void SimpleDeformModifier_do( } } - modifier_get_vgroup(ob, dm, smd->vgroup_name, &dvert, &vgroup); + MOD_get_vgroup(ob, mesh, smd->vgroup_name, &dvert, &vgroup); const bool invert_vgroup = (smd->flag & MOD_SIMPLEDEFORM_FLAG_INVERT_VGROUP) != 0; const uint *axis_map = axis_map_table[(smd->mode != MOD_SIMPLEDEFORM_MODE_BEND) ? deform_axis : 2]; @@ -370,14 +371,6 @@ static void foreachObjectLink( walk(userData, ob, &smd->origin, IDWALK_CB_NOP); } -static void updateDepgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) -{ - SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md; - - if (smd->origin) - dag_add_relation(ctx->forest, dag_get_node(ctx->forest, smd->origin), ctx->obNode, DAG_RL_OB_DATA, "SimpleDeform Modifier"); -} - static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md; @@ -387,45 +380,34 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } static void deformVerts( - ModifierData *md, Object *ob, - DerivedMesh *derivedData, + ModifierData *md, const ModifierEvalContext *ctx, + struct Mesh *mesh, float (*vertexCos)[3], - int numVerts, - ModifierApplyFlag UNUSED(flag)) + int numVerts) { - DerivedMesh *dm = derivedData; - CustomDataMask dataMask = requiredDataMask(ob, md); - - /* we implement requiredDataMask but thats not really useful since - * mesh_calc_modifiers pass a NULL derivedData */ - if (dataMask) - dm = get_dm(ob, NULL, dm, NULL, false, false); + Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false); - SimpleDeformModifier_do((SimpleDeformModifierData *)md, ob, dm, vertexCos, numVerts); + SimpleDeformModifier_do((SimpleDeformModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts); - if (dm != derivedData) - dm->release(dm); + if (mesh_src != mesh) { + BKE_id_free(NULL, mesh_src); + } } static void deformVertsEM( - ModifierData *md, Object *ob, + ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *editData, - DerivedMesh *derivedData, + struct Mesh *mesh, float (*vertexCos)[3], int numVerts) { - DerivedMesh *dm = derivedData; - CustomDataMask dataMask = requiredDataMask(ob, md); - - /* we implement requiredDataMask but thats not really useful since - * mesh_calc_modifiers pass a NULL derivedData */ - if (dataMask) - dm = get_dm(ob, editData, dm, NULL, false, false); + Mesh *mesh_src = MOD_get_mesh_eval(ctx->object, editData, mesh, NULL, false, false); - SimpleDeformModifier_do((SimpleDeformModifierData *)md, ob, dm, vertexCos, numVerts); + SimpleDeformModifier_do((SimpleDeformModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts); - if (dm != derivedData) - dm->release(dm); + if (mesh_src != mesh) { + BKE_id_free(NULL, mesh_src); + } } @@ -442,17 +424,25 @@ ModifierTypeInfo modifierType_SimpleDeform = { 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 */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, /* deformMatricesEM */ NULL, /* applyModifier */ NULL, /* applyModifierEM */ NULL, + /* initData */ initData, /* requiredDataMask */ requiredDataMask, /* freeData */ NULL, /* isDisabled */ NULL, - /* updateDepgraph */ updateDepgraph, /* updateDepsgraph */ updateDepsgraph, /* dependsOnTime */ NULL, /* dependsOnNormals */ NULL, |