diff options
Diffstat (limited to 'source/blender/modifiers/intern/MOD_curve.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_curve.c | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c index 90cfc6ba076..55837eb00e4 100644 --- a/source/blender/modifiers/intern/MOD_curve.c +++ b/source/blender/modifiers/intern/MOD_curve.c @@ -34,20 +34,24 @@ #include <string.h> +#include "DNA_mesh_types.h" #include "DNA_scene_types.h" #include "DNA_object_types.h" #include "BLI_utildefines.h" -#include "BKE_cdderivedmesh.h" +#include "BKE_editmesh.h" #include "BKE_lattice.h" +#include "BKE_library.h" #include "BKE_library_query.h" +#include "BKE_mesh.h" #include "BKE_modifier.h" -#include "depsgraph_private.h" +#include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" #include "MOD_modifiertypes.h" +#include "MOD_util.h" static void initData(ModifierData *md) { @@ -67,7 +71,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -static bool isDisabled(ModifierData *md, int UNUSED(userRenderParams)) +static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, int UNUSED(userRenderParams)) { CurveModifierData *cmd = (CurveModifierData *) md; @@ -83,19 +87,6 @@ static void foreachObjectLink( walk(userData, ob, &cmd->object, IDWALK_CB_NOP); } -static void updateDepgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) -{ - CurveModifierData *cmd = (CurveModifierData *) md; - - if (cmd->object) { - DagNode *curNode = dag_get_node(ctx->forest, cmd->object); - curNode->eval_flags |= DAG_EVAL_NEED_CURVE_PATH; - - dag_add_relation(ctx->forest, curNode, ctx->obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Curve Modifier"); - } -} - static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { CurveModifierData *cmd = (CurveModifierData *)md; @@ -115,31 +106,43 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } static void deformVerts( - ModifierData *md, Object *ob, - DerivedMesh *derivedData, + ModifierData *md, + const ModifierEvalContext *ctx, + Mesh *mesh, float (*vertexCos)[3], - int numVerts, - ModifierApplyFlag UNUSED(flag)) + int numVerts) { CurveModifierData *cmd = (CurveModifierData *) md; + Mesh *mesh_src = get_mesh(ctx->object, NULL, mesh, NULL, false, false); + + BLI_assert(mesh_src->totvert == numVerts); /* silly that defaxis and curve_deform_verts are off by 1 * but leave for now to save having to call do_versions */ - curve_deform_verts(md->scene, cmd->object, ob, derivedData, vertexCos, numVerts, - cmd->name, cmd->defaxis - 1); + curve_deform_verts(cmd->object, ctx->object, mesh_src, vertexCos, numVerts, cmd->name, cmd->defaxis - 1); + + if (mesh_src != mesh) { + BKE_id_free(NULL, mesh_src); + } } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *em, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, + const ModifierEvalContext *ctx, + struct BMEditMesh *em, + Mesh *mesh, + float (*vertexCos)[3], + int numVerts) { - DerivedMesh *dm = derivedData; + Mesh *mesh_src = get_mesh(ctx->object, em, mesh, NULL, false, false); - if (!derivedData) dm = CDDM_from_editbmesh(em, false, false); + BLI_assert(mesh_src->totvert == numVerts); - deformVerts(md, ob, dm, vertexCos, numVerts, 0); + deformVerts(md, ctx, mesh_src, vertexCos, numVerts); - if (!derivedData) dm->release(dm); + if (mesh_src != mesh) { + BKE_id_free(NULL, mesh_src); + } } @@ -153,17 +156,25 @@ ModifierTypeInfo modifierType_Curve = { 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 */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, /* deformMatricesEM */ NULL, /* applyModifier */ NULL, /* applyModifierEM */ NULL, + /* initData */ initData, /* requiredDataMask */ requiredDataMask, /* freeData */ NULL, /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, /* updateDepsgraph */ updateDepsgraph, /* dependsOnTime */ NULL, /* dependsOnNormals */ NULL, |