diff options
author | Jacques Lucke <mail@jlucke.com> | 2018-09-20 13:04:17 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2018-09-20 13:04:17 +0300 |
commit | b5dbe43d3ebfdc238d56bbb71ec17735cebdc951 (patch) | |
tree | 09e09ea4d5d78887e048b214f7ca9a0011641e5d /source/blender/blenkernel/intern/modifier.c | |
parent | add8e1c018bb5342cdad14a7d143d2b38ffa5bf5 (diff) |
Cleanup: move DerivedMesh wrappers for modifiers further down the hierarchy
The main goal of this patch is to cleanup the interface of every modifier. More specifically the interface of modifiers should be DerivedMesh-free.
Internally some modifiers still use DerivedMesh. However I think it is better when the wrappers are in the modifiers so that higher level functions can use the simplified interface.
This patch removes the applyModifier_DM and applyModifierEM_DM functions. In a previous patch (rB3614d9d) the other functions that used DerivedMesh have been removed.
Reviewers: brecht
Diffstat (limited to 'source/blender/blenkernel/intern/modifier.c')
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 121 |
1 files changed, 33 insertions, 88 deletions
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index a233f4294c0..dae941668ca 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -898,29 +898,6 @@ void modifier_deformVerts_ensure_normals(struct ModifierData *md, const Modifier mti->deformVerts(md, ctx, mesh, vertexCos, numVerts); } -struct Mesh *modifier_applyModifier(struct ModifierData *md, const ModifierEvalContext *ctx, - struct Mesh *mesh) -{ - const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - - if (mti->applyModifier) { - return mti->applyModifier(md, ctx, mesh); - } - else { - DerivedMesh *dm = CDDM_from_mesh_ex(mesh, CD_REFERENCE, CD_MASK_EVERYTHING); - - DerivedMesh *ndm = mti->applyModifier_DM(md, ctx, dm); - - if (ndm != dm) { - dm->release(dm); - } - - DM_to_mesh(ndm, mesh, ctx->object, CD_MASK_EVERYTHING, true); - - return mesh; - } -} - struct Mesh *modifier_applyModifier_ensure_normals(struct ModifierData *md, const ModifierEvalContext *ctx, struct Mesh *mesh) { @@ -930,31 +907,7 @@ struct Mesh *modifier_applyModifier_ensure_normals(struct ModifierData *md, cons if (mti->dependsOnNormals && mti->dependsOnNormals(md)) { BKE_mesh_calc_normals(mesh); } - return modifier_applyModifier(md, ctx, mesh); -} - -struct Mesh *modifier_applyModifierEM(struct ModifierData *md, const ModifierEvalContext *ctx, - struct BMEditMesh *editData, - struct Mesh *mesh) -{ - const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - - if (mti->applyModifierEM) { - return mti->applyModifierEM(md, ctx, editData, mesh); - } - else { - DerivedMesh *dm = CDDM_from_mesh_ex(mesh, CD_REFERENCE, CD_MASK_EVERYTHING); - - DerivedMesh *ndm = mti->applyModifierEM_DM(md, ctx, editData, dm); - - if (ndm != dm) { - dm->release(dm); - } - - DM_to_mesh(ndm, mesh, ctx->object, CD_MASK_EVERYTHING, true); - - return mesh; - } + return mti->applyModifier(md, ctx, mesh); } /* depricated variants of above that accept DerivedMesh */ @@ -1045,31 +998,27 @@ struct DerivedMesh *modifier_applyModifier_DM_deprecated(struct ModifierData *md { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if (mti->applyModifier_DM) { - return mti->applyModifier_DM(md, ctx, dm); + /* TODO(sybren): deduplicate all the copies of this code in this file. */ + Mesh *mesh = NULL; + if (dm != NULL) { + mesh = BKE_id_new_nomain(ID_ME, NULL); + DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false); } - else { - /* TODO(sybren): deduplicate all the copies of this code in this file. */ - Mesh *mesh = NULL; - if (dm != NULL) { - mesh = BKE_id_new_nomain(ID_ME, NULL); - DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false); - } - struct Mesh *new_mesh = mti->applyModifier(md, ctx, mesh); + struct Mesh *new_mesh = mti->applyModifier(md, ctx, mesh); - /* Make a DM that doesn't reference new_mesh so we can free the latter. */ - DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE, CD_MASK_EVERYTHING); + /* Make a DM that doesn't reference new_mesh so we can free the latter. */ + DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE, CD_MASK_EVERYTHING); - if (new_mesh != mesh) { - BKE_id_free(NULL, new_mesh); - } - if (mesh != NULL) { - BKE_id_free(NULL, mesh); - } - - return ndm; + if (new_mesh != mesh) { + BKE_id_free(NULL, new_mesh); + } + if (mesh != NULL) { + BKE_id_free(NULL, mesh); } + + return ndm; + } struct DerivedMesh *modifier_applyModifierEM_DM_deprecated(struct ModifierData *md, const ModifierEvalContext *ctx, @@ -1078,31 +1027,27 @@ struct DerivedMesh *modifier_applyModifierEM_DM_deprecated(struct ModifierData * { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if (mti->applyModifierEM_DM) { - return mti->applyModifierEM_DM(md, ctx, editData, dm); + /* TODO(sybren): deduplicate all the copies of this code in this file. */ + Mesh *mesh = NULL; + if (dm != NULL) { + mesh = BKE_id_new_nomain(ID_ME, NULL); + DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false); } - else { - /* TODO(sybren): deduplicate all the copies of this code in this file. */ - Mesh *mesh = NULL; - if (dm != NULL) { - mesh = BKE_id_new_nomain(ID_ME, NULL); - DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false); - } - - struct Mesh *new_mesh = mti->applyModifierEM(md, ctx, editData, mesh); - /* Make a DM that doesn't reference new_mesh so we can free the latter. */ - DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE, CD_MASK_EVERYTHING); + struct Mesh *new_mesh = mti->applyModifierEM(md, ctx, editData, mesh); - if (new_mesh != mesh) { - BKE_id_free(NULL, new_mesh); - } - if (mesh != NULL) { - BKE_id_free(NULL, mesh); - } + /* Make a DM that doesn't reference new_mesh so we can free the latter. */ + DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE, CD_MASK_EVERYTHING); - return ndm; + if (new_mesh != mesh) { + BKE_id_free(NULL, new_mesh); } + if (mesh != NULL) { + BKE_id_free(NULL, mesh); + } + + return ndm; + } /** |