diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/modifiers/intern/MOD_armature.c | 22 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_cast.c | 20 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_curve.c | 20 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_displace.c | 18 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_hook.c | 11 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_lattice.c | 15 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_simpledeform.c | 18 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_util.c | 4 |
8 files changed, 61 insertions, 67 deletions
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index fc077a4ca61..26fe2ff2e4c 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -135,11 +135,7 @@ static void deformVertsEM( Mesh *mesh, float (*vertexCos)[3], int numVerts) { ArmatureModifierData *amd = (ArmatureModifierData *) md; - Mesh *mesh_src = mesh; - - if (!mesh) { - mesh_src = BKE_bmesh_to_mesh_nomain(em->bm, &(struct BMeshToMeshParams){0}); - } + Mesh *mesh_src = get_mesh(ctx->object, em, mesh, NULL, false, false); modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ @@ -152,7 +148,7 @@ static void deformVertsEM( amd->prevCos = NULL; } - if (!mesh) { + if (mesh_src != mesh) { BKE_id_free(NULL, mesh_src); } } @@ -163,16 +159,12 @@ static void deformMatricesEM( float (*defMats)[3][3], int numVerts) { ArmatureModifierData *amd = (ArmatureModifierData *) md; - Mesh *mesh_src = mesh; - - if (!mesh) { - mesh_src = BKE_bmesh_to_mesh_nomain(em->bm, &(struct BMeshToMeshParams){0}); - } + Mesh *mesh_src = get_mesh(ctx->object, em, mesh, NULL, false, false); armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, defMats, numVerts, amd->deformflag, NULL, amd->defgrp_name); - if (!mesh) { + if (mesh_src != mesh) { BKE_id_free(NULL, mesh_src); } } @@ -181,10 +173,14 @@ static void deformMatrices(ModifierData *md, const ModifierEvalContext *ctx, Mes float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) { ArmatureModifierData *amd = (ArmatureModifierData *) md; - Mesh *mesh_src = mesh ? mesh : ctx->object->data; + Mesh *mesh_src = get_mesh(ctx->object, NULL, mesh, NULL, false, false); armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, defMats, numVerts, amd->deformflag, NULL, amd->defgrp_name); + + if (mesh_src != mesh) { + BKE_id_free(NULL, mesh_src); + } } ModifierTypeInfo modifierType_Armature = { diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index a2283fd66e9..2eee77c4dd7 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -428,12 +428,7 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, int numVerts) { CastModifierData *cmd = (CastModifierData *)md; - - Mesh *mesh_src = mesh; - - if (mesh_src == NULL) { - mesh_src = ctx->object->data; - } + Mesh *mesh_src = get_mesh(ctx->object, NULL, mesh, NULL, false, false); BLI_assert(mesh_src->totvert == numVerts); @@ -443,6 +438,10 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */ sphere_do(cmd, ctx->object, mesh_src, vertexCos, numVerts); } + + if (mesh_src != mesh) { + BKE_id_free(NULL, mesh_src); + } } static void deformVertsEM( @@ -451,12 +450,7 @@ static void deformVertsEM( Mesh *mesh, float (*vertexCos)[3], int numVerts) { CastModifierData *cmd = (CastModifierData *)md; - - Mesh *mesh_src = mesh; - - if (mesh_src == NULL) { - mesh_src = BKE_bmesh_to_mesh_nomain(editData->bm, &(struct BMeshToMeshParams){0}); - } + Mesh *mesh_src = get_mesh(ctx->object, editData, mesh, NULL, false, false); BLI_assert(mesh_src->totvert == numVerts); @@ -467,7 +461,7 @@ static void deformVertsEM( sphere_do(cmd, ctx->object, mesh_src, vertexCos, numVerts); } - if (!mesh) { + if (mesh_src != mesh) { BKE_id_free(NULL, mesh_src); } } diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c index 805d27de273..deda8213a65 100644 --- a/source/blender/modifiers/intern/MOD_curve.c +++ b/source/blender/modifiers/intern/MOD_curve.c @@ -51,6 +51,7 @@ #include "DEG_depsgraph_build.h" #include "MOD_modifiertypes.h" +#include "MOD_util.h" static void initData(ModifierData *md) { @@ -112,18 +113,17 @@ static void deformVerts( int numVerts) { CurveModifierData *cmd = (CurveModifierData *) md; - - Mesh *mesh_src = mesh; - - if (mesh_src == NULL) { - mesh_src = ctx->object->data; - } + 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(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( @@ -134,17 +134,13 @@ static void deformVertsEM( float (*vertexCos)[3], int numVerts) { - Mesh *mesh_src = mesh; - - if (mesh_src == NULL) { - mesh_src = BKE_bmesh_to_mesh_nomain(em->bm, &(struct BMeshToMeshParams){0}); - } + Mesh *mesh_src = get_mesh(ctx->object, em, mesh, NULL, false, false); BLI_assert(mesh_src->totvert == numVerts); deformVerts(md, ctx, mesh_src, vertexCos, numVerts); - if (!mesh) { + if (mesh_src != mesh) { BKE_id_free(NULL, mesh_src); } } diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index c28bb41647f..853787245a4 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -367,33 +367,29 @@ static void deformVerts( float (*vertexCos)[3], int numVerts) { - Mesh *mesh_src = mesh; - - if (mesh_src == NULL) { - mesh_src = ctx->object->data; - } + Mesh *mesh_src = get_mesh(ctx->object, NULL, mesh, NULL, false, false); BLI_assert(mesh_src->totvert == numVerts); displaceModifier_do((DisplaceModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts); + + if (mesh_src != mesh) { + BKE_id_free(NULL, mesh_src); + } } static void deformVertsEM( ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], int numVerts) { - Mesh *mesh_src = mesh; - - if (mesh_src == NULL) { - mesh_src = BKE_bmesh_to_mesh_nomain(editData->bm, &(struct BMeshToMeshParams){0}); - } + Mesh *mesh_src = get_mesh(ctx->object, editData, mesh, NULL, false, false); BLI_assert(mesh_src->totvert == numVerts); displaceModifier_do((DisplaceModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts); - if (!mesh) { + if (mesh_src != mesh) { BKE_id_free(NULL, mesh_src); } } diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index 572254bbbf6..0a2510ba2be 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -352,9 +352,13 @@ static void deformVerts(struct ModifierData *md, const struct ModifierEvalContex float (*vertexCos)[3], int numVerts) { HookModifierData *hmd = (HookModifierData *)md; - Mesh *mesh_src = mesh ? mesh : ctx->object->data; + Mesh *mesh_src = get_mesh(ctx->object, NULL, mesh, NULL, false, false); deformVerts_do(hmd, ctx->object, mesh_src, vertexCos, numVerts); + + if (mesh_src != mesh) { + BKE_id_free(NULL, mesh_src); + } } static void deformVertsEM(struct ModifierData *md, const struct ModifierEvalContext *ctx, @@ -362,10 +366,7 @@ static void deformVertsEM(struct ModifierData *md, const struct ModifierEvalCont struct Mesh *mesh, float (*vertexCos)[3], int numVerts) { HookModifierData *hmd = (HookModifierData *)md; - Mesh *mesh_src = mesh; - if (!mesh) { - mesh_src = BKE_bmesh_to_mesh_nomain(editData->bm, &(struct BMeshToMeshParams){0}); - } + Mesh *mesh_src = get_mesh(ctx->object, editData, mesh, NULL, false, false); deformVerts_do(hmd, ctx->object, mesh_src, vertexCos, numVerts); diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c index 548480acdd8..9487841af95 100644 --- a/source/blender/modifiers/intern/MOD_lattice.c +++ b/source/blender/modifiers/intern/MOD_lattice.c @@ -99,27 +99,26 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, int numVerts) { LatticeModifierData *lmd = (LatticeModifierData *) md; - struct Mesh *mesh_src = mesh ? mesh : ctx->object->data; + struct Mesh *mesh_src = get_mesh(ctx->object, NULL, mesh, NULL, false, false); modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ lattice_deform_verts(lmd->object, ctx->object, mesh_src, vertexCos, numVerts, lmd->name, lmd->strength); -} + + if (mesh_src != mesh) { + BKE_id_free(NULL, mesh_src); + }} static void deformVertsEM( ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *em, struct Mesh *mesh, float (*vertexCos)[3], int numVerts) { - struct Mesh *mesh_src = mesh; - - if (!mesh) { - mesh_src = BKE_bmesh_to_mesh_nomain(em->bm, &(struct BMeshToMeshParams){0}); - } + struct Mesh *mesh_src = get_mesh(ctx->object, em, mesh, NULL, false, false); deformVerts(md, ctx, mesh_src, vertexCos, numVerts); - if (!mesh) { + if (mesh_src != mesh) { BKE_id_free(NULL, mesh_src); } } diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index 4e9b5b20871..f054c89ea90 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -42,6 +42,7 @@ #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" @@ -383,8 +384,13 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, float (*vertexCos)[3], int numVerts) { - Mesh *mesh_src = mesh ? mesh : ctx->object->data; + Mesh *mesh_src = get_mesh(ctx->object, NULL, mesh, NULL, false, false); + SimpleDeformModifier_do((SimpleDeformModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts); + + if (mesh_src != mesh) { + BKE_id_free(NULL, mesh_src); + } } static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx, @@ -393,11 +399,13 @@ static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx, float (*vertexCos)[3], int numVerts) { - Mesh *mesh_src = mesh; - if (!mesh) { - mesh_src = BKE_bmesh_to_mesh_nomain(editData->bm, &(struct BMeshToMeshParams){0}); - } + Mesh *mesh_src = get_mesh(ctx->object, editData, mesh, NULL, false, false); + SimpleDeformModifier_do((SimpleDeformModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts); + + if (mesh_src != mesh) { + BKE_id_free(NULL, mesh_src); + } } diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index 95d75174b0c..818c13b4e44 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -300,6 +300,8 @@ Mesh *get_mesh(Object *ob, struct BMEditMesh *em, Mesh *mesh, struct BMeshToMeshParams bmtmp = {0}; if (em) mesh = BKE_bmesh_to_mesh_nomain(em->bm, &bmtmp); else { + /* TODO(sybren): after modifier conversion of DM to Mesh is done, check whether + * we really need a copy here. Maybe the CoW ob->data can be directly used. */ BKE_id_copy_ex( NULL, ob->data, (ID **)&mesh, LIB_ID_CREATE_NO_MAIN | @@ -308,6 +310,8 @@ Mesh *get_mesh(Object *ob, struct BMEditMesh *em, Mesh *mesh, false); } + /* TODO(sybren): after modifier conversion of DM to Mesh is done, check whether + * we really need vertexCos here. */ if (vertexCos) { BKE_mesh_apply_vert_coords(mesh, vertexCos); mesh->runtime.cd_dirty_vert |= CD_MASK_NORMAL; |