Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-11-27 16:26:43 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-11-27 23:17:06 +0300
commit9c82cc5123fb841f4ae87ddc0ceb61538c70da0f (patch)
tree6e28d55a8685ac162fd9aaa9d9f4383cc7985156 /source
parentbd957435ac0573d2e1fcbd19edd814476d2ed900 (diff)
MOD_smooth: do not compute mesh when not needed.
Also fixes potential memory leak. Related to T57972.
Diffstat (limited to 'source')
-rw-r--r--source/blender/modifiers/intern/MOD_smooth.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index 100d49f1c89..f7efd2dbd1b 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -109,7 +109,7 @@ static void smoothModifier_do(
fac = smd->fac;
facm = 1 - fac;
- if (mesh->totvert == numVerts) {
+ if (mesh != NULL) {
medges = mesh->medge;
numDMEdges = mesh->totedge;
}
@@ -213,22 +213,27 @@ static void deformVerts(
ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
- Mesh *mesh_src = mesh;
+ SmoothModifierData *smd = (SmoothModifierData *)md;
+ Mesh *mesh_src = NULL;
- if (mesh_src == NULL) {
- mesh_src = ctx->object->data;
+ if (ctx->object->type == OB_MESH) {
+ /* mesh_src is needed for vgroups, and taking edges into account. */
+ mesh_src = MOD_get_mesh_eval(ctx->object, NULL, mesh, NULL, false, false);
+ BLI_assert(mesh_src->totvert == numVerts);
}
- BLI_assert(mesh_src->totvert == numVerts);
+ smoothModifier_do(smd, ctx->object, mesh_src, vertexCos, numVerts);
- smoothModifier_do((SmoothModifierData *)md, ctx->object, mesh_src,
- vertexCos, numVerts);
+ if (!ELEM(mesh_src, NULL, 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)
{
+ SmoothModifierData *smd = (SmoothModifierData *)md;
Mesh *mesh_src = mesh;
if (mesh_src == NULL) {
@@ -237,10 +242,9 @@ static void deformVertsEM(
BLI_assert(mesh_src->totvert == numVerts);
- smoothModifier_do((SmoothModifierData *)md, ctx->object, mesh_src,
- vertexCos, numVerts);
+ smoothModifier_do(smd, ctx->object, mesh_src, vertexCos, numVerts);
- if (!mesh) {
+ if (!ELEM(mesh_src, NULL, mesh)) {
BKE_id_free(NULL, mesh_src);
}
}