From 3614d9d2a218bb5c739832484b98989cdee3b3d3 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 19 Sep 2018 16:59:05 +0200 Subject: [PATCH] Cleanup: Remove some DerivedMesh wrappers for modifiers Specifically the deformVerts_DM, deformMatrices_DM, deformVertsEM_DM and deformMatricesEM_DM functions are not used anymore. Reviewer: brecht --- source/blender/blenkernel/BKE_modifier.h | 48 +---- .../blender/blenkernel/intern/DerivedMesh.c | 2 +- source/blender/blenkernel/intern/crazyspace.c | 8 +- source/blender/blenkernel/intern/displist.c | 8 +- source/blender/blenkernel/intern/lattice.c | 2 +- .../blender/blenkernel/intern/mesh_convert.c | 2 +- source/blender/blenkernel/intern/modifier.c | 180 ++++-------------- .../blender/editors/object/object_modifier.c | 2 +- 8 files changed, 49 insertions(+), 203 deletions(-) diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 71d693f8b75..ec18e652aec 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -164,32 +164,10 @@ typedef struct ModifierTypeInfo { /********************* Deform modifier functions *********************/ /* DEPRECATED */ - /* Only for deform types, should apply the deformation - * to the given vertex array. If the deformer requires information from - * the object it can obtain it from the derivedData argument if non-NULL, - * and otherwise the ob argument. - */ - void (*deformVerts_DM)(struct ModifierData *md, const struct ModifierEvalContext *ctx, - struct DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts); - - /* Like deformMatricesEM but called from object mode (for supporting modifiers in sculpt mode) */ - void (*deformMatrices_DM)(struct ModifierData *md, const struct ModifierEvalContext *ctx, - struct DerivedMesh *derivedData, - float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); - - /* Like deformVerts but called during editmode (for supporting modifiers) - */ - void (*deformVertsEM_DM)(struct ModifierData *md, const struct ModifierEvalContext *ctx, - struct BMEditMesh *editData, - struct DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts); - - /* Set deform matrix per vertex for crazyspace correction */ - void (*deformMatricesEM_DM)(struct ModifierData *md, const struct ModifierEvalContext *ctx, - struct BMEditMesh *editData, - struct DerivedMesh *derivedData, - float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); + void (*deformVerts_DM_removed)(void); + void (*deformMatrices_DM_removed)(void); + void (*deformVertsEM_DM_removed)(void); + void (*deformMatricesEM_DM_removed)(void); /********************* Non-deform modifier functions *********************/ /* DEPRECATED */ @@ -490,28 +468,10 @@ void modwrap_deformVertsEM( * depending on if the modifier has been ported to Mesh or is still using DerivedMesh */ -void modifier_deformVerts( - struct ModifierData *md, const struct ModifierEvalContext *ctx, - struct Mesh *mesh, float (*vertexCos)[3], int numVerts); - void modifier_deformVerts_ensure_normals( struct ModifierData *md, const struct ModifierEvalContext *ctx, struct Mesh *mesh, float (*vertexCos)[3], int numVerts); -void modifier_deformMatrices( - struct ModifierData *md, const struct ModifierEvalContext *ctx, - struct Mesh *mesh, float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); - -void modifier_deformVertsEM( - struct ModifierData *md, const struct ModifierEvalContext *ctx, - struct BMEditMesh *editData, struct Mesh *mesh, - float (*vertexCos)[3], int numVerts); - -void modifier_deformMatricesEM( - struct ModifierData *md, const struct ModifierEvalContext *ctx, - struct BMEditMesh *editData, struct Mesh *mesh, - float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); - struct Mesh *modifier_applyModifier( struct ModifierData *md, const struct ModifierEvalContext *ctx, struct Mesh *mesh); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 27da612e960..0c8fcced59e 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2608,7 +2608,7 @@ static void editbmesh_calc_modifiers( } } - if (mti->deformVertsEM || mti->deformVertsEM_DM) + if (mti->deformVertsEM) modwrap_deformVertsEM(md, &mectx, em, dm, deformedVerts, numVerts); else modwrap_deformVerts(md, &mectx, dm, deformedVerts, numVerts); diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c index 2b4daae503d..539b4723121 100644 --- a/source/blender/blenkernel/intern/crazyspace.c +++ b/source/blender/blenkernel/intern/crazyspace.c @@ -277,7 +277,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh( if (!editbmesh_modifier_is_enabled(scene, md, dm)) continue; - if (mti->type == eModifierTypeType_OnlyDeform && (mti->deformMatricesEM || mti->deformMatricesEM_DM)) { + if (mti->type == eModifierTypeType_OnlyDeform && mti->deformMatricesEM) { if (!defmats) { const int required_mode = eModifierMode_Realtime | eModifierMode_Editmode; CustomDataMask data_mask = CD_MASK_BAREMESH; @@ -351,7 +351,7 @@ int BKE_sculpt_get_first_deform_matrices( unit_m3(defmats[a]); } - if (mti->deformMatrices || mti->deformMatrices_DM) { + if (mti->deformMatrices) { modifier_deformMatrices_DM_deprecated(md, &mectx, dm, deformedVerts, defmats, numVerts); } else break; @@ -401,10 +401,10 @@ void BKE_crazyspace_build_sculpt(struct Depsgraph *depsgraph, Scene *scene, Obje if (mti->type == eModifierTypeType_OnlyDeform) { /* skip leading modifiers which have been already * handled in sculpt_get_first_deform_matrices */ - if ((mti->deformMatrices || mti->deformMatrices_DM) && !deformed) + if (mti->deformMatrices && !deformed) continue; - modifier_deformVerts(md, &mectx, NULL, deformedVerts, me->totvert); + mti->deformVerts(md, &mectx, NULL, deformedVerts, me->totvert); deformed = 1; } } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 562e2257ea0..c9051313481 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -864,7 +864,7 @@ static void curve_calc_modifiers_pre( deformedVerts = BKE_curve_nurbs_vertexCos_get(nurb, &numVerts); } - modifier_deformVerts(md, &mectx, NULL, deformedVerts, numVerts); + mti->deformVerts(md, &mectx, NULL, deformedVerts, numVerts); if (md == pretessellatePoint) break; @@ -970,15 +970,13 @@ static void curve_calc_modifiers_post( if (!vertCos) { vertCos = BKE_mesh_vertexCos_get(modified, &totvert); } - - modifier_deformVerts(md, &mectx_deform, modified, vertCos, totvert); + mti->deformVerts(md, &mectx_deform, modified, vertCos, totvert); } else { if (!vertCos) { vertCos = displist_get_allverts(dispbase, &totvert); } - - modifier_deformVerts(md, &mectx_deform, NULL, vertCos, totvert); + mti->deformVerts(md, &mectx_deform, NULL, vertCos, totvert); } } else { diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 05502ad9e9e..a04f32adece 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -1052,7 +1052,7 @@ void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Objec if (mti->type != eModifierTypeType_OnlyDeform) continue; if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob_orig, &numVerts); - modifier_deformVerts(md, &mectx, NULL, vertexCos, numVerts); + mti->deformVerts(md, &mectx, NULL, vertexCos, numVerts); } if (ob->id.tag & LIB_TAG_COPIED_ON_WRITE) { diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c index 2d342de2c21..17d7276dfe7 100644 --- a/source/blender/blenkernel/intern/mesh_convert.c +++ b/source/blender/blenkernel/intern/mesh_convert.c @@ -1144,7 +1144,7 @@ Mesh *BKE_mesh_create_derived_for_modifier( int numVerts; float (*deformedVerts)[3] = BKE_mesh_vertexCos_get(me, &numVerts); - modifier_deformVerts(md, &mectx, NULL, deformedVerts, numVerts); + mti->deformVerts(md, &mectx, NULL, deformedVerts, numVerts); BKE_id_copy_ex( NULL, &me->id, (ID **)&result, LIB_ID_CREATE_NO_MAIN | diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index b877a08b6cf..039e57d8775 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -710,7 +710,7 @@ bool modifiers_usesArmature(Object *ob, bArmature *arm) bool modifier_isCorrectableDeformed(ModifierData *md) { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - return (mti->deformMatricesEM != NULL) || (mti->deformMatricesEM_DM != NULL); + return mti->deformMatricesEM != NULL; } bool modifiers_isCorrectableDeformed(struct Scene *scene, Object *ob) @@ -885,29 +885,6 @@ void modwrap_deformVertsEM( * depending on if the modifier has been ported to Mesh or is still using DerivedMesh */ -void modifier_deformVerts(struct ModifierData *md, const ModifierEvalContext *ctx, - struct Mesh *mesh, - float (*vertexCos)[3], int numVerts) -{ - const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - - if (mti->deformVerts) { - mti->deformVerts(md, ctx, mesh, vertexCos, numVerts); - } - else { - DerivedMesh *dm = NULL; - if (mesh) { - dm = CDDM_from_mesh_ex(mesh, CD_REFERENCE, CD_MASK_EVERYTHING); - } - - mti->deformVerts_DM(md, ctx, dm, vertexCos, numVerts); - - if (dm) { - dm->release(dm); - } - } -} - void modifier_deformVerts_ensure_normals(struct ModifierData *md, const ModifierEvalContext *ctx, struct Mesh *mesh, float (*vertexCos)[3], int numVerts) @@ -918,76 +895,7 @@ void modifier_deformVerts_ensure_normals(struct ModifierData *md, const Modifier if (mesh && mti->dependsOnNormals && mti->dependsOnNormals(md)) { BKE_mesh_calc_normals(mesh); } - modifier_deformVerts(md, ctx, mesh, vertexCos, numVerts); -} - -void modifier_deformMatrices(struct ModifierData *md, const ModifierEvalContext *ctx, - struct Mesh *mesh, - float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) -{ - const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - - if (mti->deformMatrices) { - mti->deformMatrices(md, ctx, mesh, vertexCos, defMats, numVerts); - } - else { - DerivedMesh *dm = NULL; - if (mesh) { - dm = CDDM_from_mesh_ex(mesh, CD_REFERENCE, CD_MASK_EVERYTHING); - } - - mti->deformMatrices_DM(md, ctx, dm, vertexCos, defMats, numVerts); - - if (dm) { - dm->release(dm); - } - } -} - -void modifier_deformVertsEM(struct ModifierData *md, const ModifierEvalContext *ctx, - struct BMEditMesh *editData, struct Mesh *mesh, - float (*vertexCos)[3], int numVerts) -{ - const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - - if (mti->deformVertsEM) { - mti->deformVertsEM(md, ctx, editData, mesh, vertexCos, numVerts); - } - else { - DerivedMesh *dm = NULL; - if (mesh) { - dm = CDDM_from_mesh_ex(mesh, CD_REFERENCE, CD_MASK_EVERYTHING); - } - - mti->deformVertsEM_DM(md, ctx, editData, dm, vertexCos, numVerts); - - if (dm) { - dm->release(dm); - } - } -} - -void modifier_deformMatricesEM(struct ModifierData *md, const ModifierEvalContext *ctx, - struct BMEditMesh *editData, struct Mesh *mesh, - float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) -{ - const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - - if (mti->deformMatricesEM) { - mti->deformMatricesEM(md, ctx, editData, mesh, vertexCos, defMats, numVerts); - } - else { - DerivedMesh *dm = NULL; - if (mesh) { - dm = CDDM_from_mesh_ex(mesh, CD_REFERENCE, CD_MASK_EVERYTHING); - } - - mti->deformMatricesEM_DM(md, ctx, editData, dm, vertexCos, defMats, numVerts); - - if (dm) { - dm->release(dm); - } - } + mti->deformVerts(md, &ctx, mesh, vertexCos, numVerts); } struct Mesh *modifier_applyModifier(struct ModifierData *md, const ModifierEvalContext *ctx, @@ -1057,22 +965,17 @@ void modifier_deformVerts_DM_deprecated(struct ModifierData *md, const ModifierE { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if (mti->deformVerts_DM) { - mti->deformVerts_DM(md, ctx, dm, vertexCos, numVerts); + /* 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); - } - mti->deformVerts(md, ctx, mesh, vertexCos, numVerts); + mti->deformVerts(md, ctx, mesh, vertexCos, numVerts); - if (mesh != NULL) { - BKE_id_free(NULL, mesh); - } + if (mesh != NULL) { + BKE_id_free(NULL, mesh); } } @@ -1083,22 +986,17 @@ void modifier_deformMatrices_DM_deprecated(struct ModifierData *md, const Modifi const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if (mti->deformMatrices_DM) { - mti->deformMatrices_DM(md, ctx, dm, vertexCos, defMats, numVerts); + /* 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); - } - mti->deformMatrices(md, ctx, mesh, vertexCos, defMats, numVerts); + mti->deformMatrices(md, ctx, mesh, vertexCos, defMats, numVerts); - if (mesh != NULL) { - BKE_id_free(NULL, mesh); - } + if (mesh != NULL) { + BKE_id_free(NULL, mesh); } } @@ -1108,22 +1006,17 @@ void modifier_deformVertsEM_DM_deprecated(struct ModifierData *md, const Modifie { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if (mti->deformVertsEM_DM) { - mti->deformVertsEM_DM(md, ctx, editData, dm, vertexCos, numVerts); + /* 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); - } - mti->deformVertsEM(md, ctx, editData, mesh, vertexCos, numVerts); + mti->deformVertsEM(md, ctx, editData, mesh, vertexCos, numVerts); - if (mesh != NULL) { - BKE_id_free(NULL, mesh); - } + if (mesh != NULL) { + BKE_id_free(NULL, mesh); } } @@ -1133,22 +1026,17 @@ void modifier_deformMatricesEM_DM_deprecated(struct ModifierData *md, const Modi { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if (mti->deformMatricesEM_DM) { - mti->deformMatricesEM_DM(md, ctx, editData, dm, vertexCos, defMats, numVerts); + /* 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); - } - mti->deformMatricesEM(md, ctx, editData, mesh, vertexCos, defMats, numVerts); + mti->deformMatricesEM(md, ctx, editData, mesh, vertexCos, defMats, numVerts); - if (mesh != NULL) { - BKE_id_free(NULL, mesh); - } + if (mesh != NULL) { + BKE_id_free(NULL, mesh); } } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 40f55c81a91..43fb3e43e55 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -638,7 +638,7 @@ static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scen BKE_report(reports, RPT_INFO, "Applied modifier only changed CV points, not tessellated/bevel vertices"); vertexCos = BKE_curve_nurbs_vertexCos_get(&cu->nurb, &numVerts); - modifier_deformVerts(md, &mectx, NULL, vertexCos, numVerts); + mti->deformVerts(md, &mectx, NULL, vertexCos, numVerts); BK_curve_nurbs_vertexCos_apply(&cu->nurb, vertexCos); MEM_freeN(vertexCos);