[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25929] trunk/blender/source/blender: bugfix for puff brush, it wasnt working if the object had any transformation.

Campbell Barton ideasman42 at gmail.com
Tue Jan 12 15:52:09 CET 2010


Revision: 25929
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25929
Author:   campbellbarton
Date:     2010-01-12 15:52:09 +0100 (Tue, 12 Jan 2010)

Log Message:
-----------
bugfix for puff brush, it wasnt working if the object had any transformation.
some dna comments too.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/physics/particle_edit.c
    trunk/blender/source/blender/makesdna/DNA_object_types.h

Modified: trunk/blender/source/blender/editors/physics/particle_edit.c
===================================================================
--- trunk/blender/source/blender/editors/physics/particle_edit.c	2010-01-12 14:12:44 UTC (rev 25928)
+++ trunk/blender/source/blender/editors/physics/particle_edit.c	2010-01-12 14:52:09 UTC (rev 25929)
@@ -2844,6 +2844,8 @@
 	PTCacheEditPoint *point = edit->points + point_index;
 	KEY_K;
 	float mat[4][4], imat[4][4];
+	float obmat[4][4], obimat[4][4];
+
 	float lastco[3], rootco[3] = {0.0f, 0.0f, 0.0f}, co[3], nor[3], kco[3], dco[3], fac=0.0f, length=0.0f;
 
 	if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
@@ -2855,17 +2857,23 @@
 		unit_m4(imat);
 	}
 
+	copy_m4_m4(obmat, data->ob->obmat);
+	invert_m4_m4(obimat, obmat);
+
 	LOOP_KEYS {
 		if(k==0) {
 			/* find root coordinate and normal on emitter */
 			VECCOPY(co, key->co);
 			mul_m4_v3(mat, co);
+			mul_v3_m4v3(kco, obimat, co); /* use 'kco' as the object space version of worldspace 'co' */
 
-			point_index= BLI_kdtree_find_nearest(edit->emitter_field, co, NULL, NULL);
+			point_index= BLI_kdtree_find_nearest(edit->emitter_field, kco, NULL, NULL);
 			if(point_index == -1) return;
 
 			VECCOPY(rootco, co);
 			copy_v3_v3(nor, &edit->emitter_cosnos[point_index*6+3]);
+			mul_mat3_m4_v3(obmat, nor); /* normal into worldspace */
+
 			normalize_v3(nor);
 			length= 0.0f;
 
@@ -3913,7 +3921,8 @@
 	
 		/* mesh may have changed since last entering editmode.
 		 * note, this may have run before if the edit data was just created, so could avoid this and speed up a little */
-		recalc_emitter_field(ob, edit->psys);
+		if(edit)
+			recalc_emitter_field(ob, edit->psys);
 		
 		toggle_particle_cursor(C, 1);
 		WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_PARTICLE, NULL);

Modified: trunk/blender/source/blender/makesdna/DNA_object_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_object_types.h	2010-01-12 14:12:44 UTC (rev 25928)
+++ trunk/blender/source/blender/makesdna/DNA_object_types.h	2010-01-12 14:52:09 UTC (rev 25929)
@@ -135,15 +135,15 @@
 	
 	/* rot en drot have to be together! (transform('r' en 's')) */
 	float loc[3], dloc[3], orig[3];
-	float size[3], dsize[3];
+	float size[3], dsize[3];	/* scale and delta scale */
 	float rot[3], drot[3];		/* euler rotation */
 	float quat[4], dquat[4];	/* quaternion rotation */
 	float rotAxis[3], drotAxis[3];	/* axis angle rotation - axis part */
 	float rotAngle, drotAngle;	/* axis angle rotation - angle part */
-	float obmat[4][4];
+	float obmat[4][4];		/* final worldspace matrix with constraints & animsys applied */
 	float parentinv[4][4]; /* inverse result of parent, so that object doesn't 'stick' to parent */
 	float constinv[4][4]; /* inverse result of constraints. doesn't include effect of parent or object local transform */
-	float imat[4][4];	/* for during render, old game engine, temporally: ipokeys of transform  */
+	float imat[4][4];	/* inverse matrix of 'obmat' for during render, old game engine, temporally: ipokeys of transform  */
 	
 	unsigned int lay;				/* copy of Base */
 	





More information about the Bf-blender-cvs mailing list