diff options
author | Joshua Leung <aligorith@gmail.com> | 2007-08-28 12:43:38 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2007-08-28 12:43:38 +0400 |
commit | 2252b636a3887ec82e2b06212a752ac193219bea (patch) | |
tree | 6e98cd7e14af0fd6fe6123aeac1eab712c64c233 /source/blender/blenkernel/intern/constraint.c | |
parent | 3049b89e364ee63437693c5251c0da7fa8d23b81 (diff) |
Bugfix: Constraint Geometry Targets didn't work yet when the Target Mesh was in EditMode
It turns out that a DerivedMesh needs to be generated explicitly if one needs to be used when the Mesh is in EditMode.
Diffstat (limited to 'source/blender/blenkernel/intern/constraint.c')
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 38f067f53ab..8bd925e0500 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -51,13 +51,14 @@ #include "BKE_utildefines.h" #include "BKE_action.h" -#include "BKE_anim.h" // for the curve calculation part +#include "BKE_anim.h" /* for the curve calculation part */ #include "BKE_armature.h" #include "BKE_blender.h" #include "BKE_constraint.h" #include "BKE_displist.h" #include "BKE_deform.h" -#include "BKE_DerivedMesh.h" +#include "BKE_DerivedMesh.h" /* for geometry targets */ +#include "BKE_cdderivedmesh.h" /* for geometry targets */ #include "BKE_object.h" #include "BKE_ipo.h" #include "BKE_global.h" @@ -1114,7 +1115,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 /* function that sets the given matrix based on given vertex group in mesh */ static void contarget_get_mesh_mat (Object *ob, char *substring, float mat[][4]) { - DerivedMesh *dm = (DerivedMesh *)ob->derivedFinal; + DerivedMesh *dm; float vec[3] = {0.0f, 0.0f, 0.0f}, tvec[3]; float normal[3] = {0.0f, 0.0f, 0.0f}, plane[3]; float imat[3][3], tmat[3][3]; @@ -1127,6 +1128,16 @@ static void contarget_get_mesh_mat (Object *ob, char *substring, float mat[][4]) dgroup = get_named_vertexgroup_num(ob, substring); if (dgroup < 0) return; + /* get DerivedMesh */ + if (G.obedit && G.editMesh) { + /* we are in editmode, so get a special derived mesh */ + dm = CDDM_from_editmesh(G.editMesh, ob->data); + } + else { + /* when not in EditMode, this should exist */ + dm = (DerivedMesh *)ob->derivedFinal; + } + /* only continue if there's a valid DerivedMesh */ if (dm) { MDeformVert *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); @@ -1186,6 +1197,11 @@ static void contarget_get_mesh_mat (Object *ob, char *substring, float mat[][4]) VecMat4MulVecfl(tvec, ob->obmat, vec); VECCOPY(mat[3], tvec); } + + /* free temporary DerivedMesh created (in EditMode case) */ + if (G.editMesh) { + if (dm) dm->release(dm); + } } /* function that sets the given matrix based on given vertex group in lattice */ |