diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-12-11 19:22:14 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-12-11 19:26:21 +0300 |
commit | e089b1f08bdf72eb4441e62f9c99e01ace0ef5c4 (patch) | |
tree | 8d7cdf29769cb6485a15010a9b23ab26b55843fa | |
parent | 8729e23f2dc245d7c73d98262d3b651b7c284249 (diff) |
Fix T46945: Mesh Deform binding to a cage object with modifiers is unreliable.
Binding code was re-building its own DM for the cage, now it uses given one instead.
I cannot see really any good reason not to use 'visual' modified cage for binding process,
using base mesh instead was breaking any 'advanced' binding as described in the report.
-rw-r--r-- | source/blender/editors/armature/meshlaplacian.c | 8 | ||||
-rw-r--r-- | source/blender/editors/include/ED_armature.h | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 2 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_meshdeform.c | 2 |
4 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 6bf75413e81..ce87ffb3494 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -1633,7 +1633,9 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa free_bvhtree_from_mesh(&mdb->bvhdata); } -void mesh_deform_bind(Scene *scene, MeshDeformModifierData *mmd, float *vertexcos, int totvert, float cagemat[4][4]) +void mesh_deform_bind( + Scene *scene, MeshDeformModifierData *mmd, DerivedMesh *cagedm, + float *vertexcos, int totvert, float cagemat[4][4]) { MeshDeformBind mdb; MVert *mvert; @@ -1648,7 +1650,7 @@ void mesh_deform_bind(Scene *scene, MeshDeformModifierData *mmd, float *vertexco mdb.vertexcos = MEM_callocN(sizeof(float) * 3 * totvert, "MeshDeformCos"); mdb.totvert = totvert; - mdb.cagedm = mesh_create_derived_no_deform(scene, mmd->object, NULL, CD_MASK_BAREMESH); + mdb.cagedm = cagedm; mdb.totcagevert = mdb.cagedm->getNumVerts(mdb.cagedm); mdb.cagecos = MEM_callocN(sizeof(*mdb.cagecos) * mdb.totcagevert, "MeshDeformBindCos"); copy_m4_m4(mdb.cagemat, cagemat); @@ -1673,7 +1675,6 @@ void mesh_deform_bind(Scene *scene, MeshDeformModifierData *mmd, float *vertexco mul_m4_v3(mmd->object->obmat, mmd->bindcagecos + a * 3); /* free */ - mdb.cagedm->release(mdb.cagedm); MEM_freeN(mdb.vertexcos); /* compact weights */ @@ -1682,4 +1683,3 @@ void mesh_deform_bind(Scene *scene, MeshDeformModifierData *mmd, float *vertexco end_progress_bar(); waitcursor(0); } - diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 7d7ee33bde4..15c68378b9a 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -42,6 +42,7 @@ struct bPoseChannel; struct IDProperty; struct ListBase; struct MeshDeformModifierData; +struct DerivedMesh; struct Object; struct ReportList; struct Scene; @@ -208,6 +209,7 @@ int BDR_drawSketchNames(struct ViewContext *vc); /* meshlaplacian.c */ void mesh_deform_bind(struct Scene *scene, struct MeshDeformModifierData *mmd, + struct DerivedMesh *cagedm, float *vertexcos, int totvert, float cagemat[4][4]); #ifdef __cplusplus diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 525e267e537..7bd29137aeb 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -698,7 +698,7 @@ typedef struct MeshDeformModifierData { float *bindcos; /* deprecated storage of cage coords */ /* runtime */ - void (*bindfunc)(struct Scene *scene, struct MeshDeformModifierData *mmd, + void (*bindfunc)(struct Scene *scene, struct MeshDeformModifierData *mmd, struct DerivedMesh *cagedm, float *vertexcos, int totvert, float cagemat[4][4]); } MeshDeformModifierData; diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index cdf1f85ade5..5f2f51df528 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -352,7 +352,7 @@ static void meshdeformModifier_do( /* progress bar redraw can make this recursive .. */ if (!recursive) { recursive = 1; - mmd->bindfunc(md->scene, mmd, (float *)vertexCos, numVerts, cagemat); + mmd->bindfunc(md->scene, mmd, cagedm, (float *)vertexCos, numVerts, cagemat); recursive = 0; } } |