[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35331] trunk/blender/source/blender/ editors/util/crazyspace.c: Fix #26273: mirror mod.

Sergey Sharybin g.ulairi at gmail.com
Thu Mar 3 16:17:58 CET 2011


Revision: 35331
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35331
Author:   nazgul
Date:     2011-03-03 15:17:57 +0000 (Thu, 03 Mar 2011)
Log Message:
-----------
Fix #26273: mirror mod. + armature mod. + rotated armature == wrong reference axis for moving verts (when mirror comes first)

Do not overwrite coord of vertices in mapped vertex array used for crazyspace
corrections. This should make stuff use position of mesh vertex after
deformation, not possible generated images of this vertices.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/util/crazyspace.c

Modified: trunk/blender/source/blender/editors/util/crazyspace.c
===================================================================
--- trunk/blender/source/blender/editors/util/crazyspace.c	2011-03-03 13:55:15 UTC (rev 35330)
+++ trunk/blender/source/blender/editors/util/crazyspace.c	2011-03-03 15:17:57 UTC (rev 35331)
@@ -50,6 +50,11 @@
 
 #include "ED_util.h"
 
+typedef struct {
+	float *vertexcos;
+	short *flags;
+} MappedUserData;
+
 #define TAN_MAKE_VEC(a, b, c)	a[0]= b[0] + 0.2f*(b[0]-c[0]); a[1]= b[1] + 0.2f*(b[1]-c[1]); a[2]= b[2] + 0.2f*(b[2]-c[2])
 static void set_crazy_vertex_quat(float *quat, float *v1, float *v2, float *v3, float *def1, float *def2, float *def3)
 {
@@ -70,10 +75,16 @@
 
 static void make_vertexcos__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
 {
-	float *vec = userData;
+	MappedUserData *mappedData= (MappedUserData*)userData;
+	float *vec = mappedData->vertexcos;
 
 	vec+= 3*index;
-	VECCOPY(vec, co);
+	if(!mappedData->flags[index]) {
+		/* we need coord from prototype vertex, not it clones or images,
+		   suppose they stored in the beginning of vertex array stored in DM */
+		VECCOPY(vec, co);
+		mappedData->flags[index]= 1;
+	}
 }
 
 static int modifiers_disable_subsurf_temporary(Object *ob)
@@ -97,6 +108,9 @@
 	Mesh *me= obedit->data;
 	DerivedMesh *dm;
 	float *vertexcos;
+	int nverts= me->edit_mesh->totvert;
+	short *flags;
+	MappedUserData userData;
 
 	/* disable subsurf temporal, get mapped cos, and enable it */
 	if(modifiers_disable_subsurf_temporary(obedit)) {
@@ -107,14 +121,20 @@
 	/* now get the cage */
 	dm= editmesh_get_derived_cage(scene, obedit, me->edit_mesh, CD_MASK_BAREMESH);
 
-	vertexcos= MEM_mallocN(3*sizeof(float)*me->edit_mesh->totvert, "vertexcos map");
-	dm->foreachMappedVert(dm, make_vertexcos__mapFunc, vertexcos);
+	vertexcos= MEM_callocN(3*sizeof(float)*nverts, "vertexcos map");
+	flags= MEM_callocN(sizeof(short)*nverts, "vertexcos flags");
 
+	userData.vertexcos= vertexcos;
+	userData.flags= flags;
+	dm->foreachMappedVert(dm, make_vertexcos__mapFunc, &userData);
+
 	dm->release(dm);
 
 	/* set back the flag, no new cage needs to be built, transform does it */
 	modifiers_disable_subsurf_temporary(obedit);
 
+	MEM_freeN(flags);
+
 	return vertexcos;
 }
 




More information about the Bf-blender-cvs mailing list