[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11859] trunk/blender/source/blender/ blenkernel/intern/constraint.c: Bugfix: Constraint Geometry Targets didn' t work yet when the Target Mesh was in EditMode

Joshua Leung aligorith at gmail.com
Tue Aug 28 10:43:38 CEST 2007


Revision: 11859
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11859
Author:   aligorith
Date:     2007-08-28 10:43:38 +0200 (Tue, 28 Aug 2007)

Log Message:
-----------
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.  

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/constraint.c

Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c	2007-08-28 08:32:06 UTC (rev 11858)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2007-08-28 08:43:38 UTC (rev 11859)
@@ -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 @@
 /* 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 @@
 	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 @@
 		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 */





More information about the Bf-blender-cvs mailing list