diff options
Diffstat (limited to 'source/blender/modifiers/intern/MOD_hook.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_hook.c | 86 |
1 files changed, 38 insertions, 48 deletions
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index 05defc85024..05fb6bb43bc 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -33,6 +33,7 @@ */ +#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" @@ -40,14 +41,14 @@ #include "BLI_utildefines.h" #include "BKE_action.h" -#include "BKE_cdderivedmesh.h" +#include "BKE_editmesh.h" +#include "BKE_library.h" #include "BKE_library_query.h" +#include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_deform.h" #include "BKE_colortools.h" - -#include "depsgraph_private.h" #include "MEM_guardedalloc.h" #include "MOD_util.h" @@ -111,20 +112,6 @@ static void foreachObjectLink( walk(userData, ob, &hmd->object, IDWALK_CB_NOP); } -static void updateDepgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) -{ - HookModifierData *hmd = (HookModifierData *) md; - - if (hmd->object) { - DagNode *curNode = dag_get_node(ctx->forest, hmd->object); - - if (hmd->subtarget[0]) - dag_add_relation(ctx->forest, curNode, ctx->obNode, DAG_RL_OB_DATA | DAG_RL_DATA_DATA, "Hook Modifier"); - else - dag_add_relation(ctx->forest, curNode, ctx->obNode, DAG_RL_OB_DATA, "Hook Modifier"); - } -} - static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { HookModifierData *hmd = (HookModifierData *)md; @@ -265,7 +252,7 @@ static void hook_co_apply(struct HookData_cb *hd, const int j) } static void deformVerts_do( - HookModifierData *hmd, Object *ob, DerivedMesh *dm, + HookModifierData *hmd, Object *ob, Mesh *mesh, float (*vertexCos)[3], int numVerts) { bPoseChannel *pchan = BKE_pose_channel_find_name(hmd->object->pose, hmd->subtarget); @@ -284,7 +271,7 @@ static void deformVerts_do( /* Generic data needed for applying per-vertex calculations (initialize all members) */ hd.vertexCos = vertexCos; - modifier_get_vgroup(ob, dm, hmd->name, &hd.dvert, &hd.defgrp_index); + modifier_get_vgroup_mesh(ob, mesh, hmd->name, &hd.dvert, &hd.defgrp_index); hd.curfalloff = hmd->curfalloff; @@ -321,7 +308,7 @@ static void deformVerts_do( /* Regarding index range checking below. * - * This should always be true and I don't generally like + * This should always be true and I don't generally like * "paranoid" style code like this, but old files can have * indices that are out of range because old blender did * not correct them on exit editmode. - zr @@ -332,13 +319,13 @@ static void deformVerts_do( } else if (hmd->indexar) { /* vertex indices? */ const int *origindex_ar; - - /* if DerivedMesh is present and has original index data, use it */ - if (dm && (origindex_ar = dm->getVertDataArray(dm, CD_ORIGINDEX))) { + + /* if mesh is present and has original index data, use it */ + if (mesh && (origindex_ar = CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX))) { for (i = 0, index_pt = hmd->indexar; i < hmd->totindex; i++, index_pt++) { if (*index_pt < numVerts) { int j; - + for (j = 0; j < numVerts; j++) { if (origindex_ar[j] == *index_pt) { hook_co_apply(&hd, j); @@ -347,7 +334,7 @@ static void deformVerts_do( } } } - else { /* missing dm or ORIGINDEX */ + else { /* missing mesh or ORIGINDEX */ for (i = 0, index_pt = hmd->indexar; i < hmd->totindex; i++, index_pt++) { if (*index_pt < numVerts) { hook_co_apply(&hd, *index_pt); @@ -363,39 +350,34 @@ static void deformVerts_do( } static void deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, - ModifierApplyFlag UNUSED(flag)) + struct ModifierData *md, const struct ModifierEvalContext *ctx, struct Mesh *mesh, + float (*vertexCos)[3], int numVerts) { - HookModifierData *hmd = (HookModifierData *) md; - DerivedMesh *dm = derivedData; - /* We need a valid dm for meshes when a vgroup is set... */ - if (!dm && ob->type == OB_MESH && hmd->name[0] != '\0') - dm = get_dm(ob, NULL, dm, NULL, false, false); + HookModifierData *hmd = (HookModifierData *)md; + Mesh *mesh_src = get_mesh(ctx->object, NULL, mesh, NULL, false, false); - deformVerts_do(hmd, ob, dm, vertexCos, numVerts); + deformVerts_do(hmd, ctx->object, mesh_src, vertexCos, numVerts); - if (derivedData != dm) - dm->release(dm); + if (mesh_src != mesh) { + BKE_id_free(NULL, mesh_src); + } } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + struct ModifierData *md, const struct ModifierEvalContext *ctx, + struct BMEditMesh *editData, + struct Mesh *mesh, float (*vertexCos)[3], int numVerts) { - HookModifierData *hmd = (HookModifierData *) md; - DerivedMesh *dm = derivedData; - /* We need a valid dm for meshes when a vgroup is set... */ - if (!dm && ob->type == OB_MESH && hmd->name[0] != '\0') - dm = get_dm(ob, editData, dm, NULL, false, false); + HookModifierData *hmd = (HookModifierData *)md; + Mesh *mesh_src = get_mesh(ctx->object, editData, mesh, NULL, false, false); - deformVerts_do(hmd, ob, dm, vertexCos, numVerts); + deformVerts_do(hmd, ctx->object, mesh_src, vertexCos, numVerts); - if (derivedData != dm) - dm->release(dm); + if (mesh_src != mesh) { + BKE_id_free(NULL, mesh_src); + } } - ModifierTypeInfo modifierType_Hook = { /* name */ "Hook", /* structName */ "HookModifierData", @@ -405,17 +387,25 @@ ModifierTypeInfo modifierType_Hook = { eModifierTypeFlag_AcceptsLattice | eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, + + /* 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 */ freeData, /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, /* updateDepsgraph */ updateDepsgraph, /* dependsOnTime */ NULL, /* dependsOnNormals */ NULL, |