[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12617] branches/particles/source/blender:

Brecht Van Lommel brechtvanlommel at pandora.be
Sun Nov 18 22:27:20 CET 2007


Revision: 12617
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12617
Author:   blendix
Date:     2007-11-18 22:27:19 +0100 (Sun, 18 Nov 2007)

Log Message:
-----------

Particle Branch
===============

- Mirror editing, exists of two parts:
  - A "Mirror Particles" tool that mirrors particles to the other side. If
    a particle already exists in that place, it instead gets the same
    coordinates.
  - A "X-Axis Mirror" option to mirror edits to the other side while editing,
    should work for all tools: brushes, transform, delete, rekey, .. .

- (Again) modified the way particles are stored in faces. Now it is
  using mean value weights instead of bilinear, which means adding 
  particles with the add brush will put them exactly in the place they
  need to be, and the particles can be mirrored exactly, while keeping
  nice interpolation on quads. It also means I can now properly understand
  what is going in the code :). This breaks backwards compatibility (sorry).

- Proportional edit should now work, also optimized it to only do deflection
  etc on particles that are actually moved.

- Changed the way Even and Random distribution work. Previously small faces
  would get no particles at all, which meant that e.g. on our models the
  hands would get no particles.

- Made the radius for mouse selection bigger, is now 75 pixels like mesh edit
  mode. 

- Fixed the Remove Keys tool, didn't work correct.

- Added Select Linked to the menu, missed that before.

Modified Paths:
--------------
    branches/particles/source/blender/blenkernel/BKE_particle.h
    branches/particles/source/blender/blenkernel/BKE_utildefines.h
    branches/particles/source/blender/blenkernel/intern/customdata.c
    branches/particles/source/blender/blenkernel/intern/modifier.c
    branches/particles/source/blender/blenkernel/intern/particle.c
    branches/particles/source/blender/blenkernel/intern/particle_system.c
    branches/particles/source/blender/blenkernel/intern/pointcache.c
    branches/particles/source/blender/include/BIF_editparticle.h
    branches/particles/source/blender/include/BIF_meshtools.h
    branches/particles/source/blender/include/transform.h
    branches/particles/source/blender/makesdna/DNA_particle_types.h
    branches/particles/source/blender/makesdna/DNA_scene_types.h
    branches/particles/source/blender/render/intern/source/convertblender.c
    branches/particles/source/blender/src/edit.c
    branches/particles/source/blender/src/editobject.c
    branches/particles/source/blender/src/editparticle.c
    branches/particles/source/blender/src/header_view3d.c
    branches/particles/source/blender/src/meshtools.c
    branches/particles/source/blender/src/parametrizer.c
    branches/particles/source/blender/src/transform_conversions.c
    branches/particles/source/blender/src/transform_generics.c

Modified: branches/particles/source/blender/blenkernel/BKE_particle.h
===================================================================
--- branches/particles/source/blender/blenkernel/BKE_particle.h	2007-11-18 17:44:48 UTC (rev 12616)
+++ branches/particles/source/blender/blenkernel/BKE_particle.h	2007-11-18 21:27:19 UTC (rev 12617)
@@ -153,6 +153,7 @@
 	struct ParticleUndo *curundo;
 	struct KDTreeNode *emitter_field;
 	ParticleEditKey **keys;
+	int *mirror_cache;
 	float *emitter_cosnos;
 
 	int totkeys;
@@ -191,7 +192,7 @@
 
 void copy_particle_key(struct ParticleKey *to, struct ParticleKey *from, int time);
 
-void psys_particle_on_emitter(struct Object *ob, struct ParticleSystemModifierData *psmd, int distr, int index, int index_dmcache, float *fuv, float *vec, float *nor, float *utan, float *vtan);
+void psys_particle_on_emitter(struct Object *ob, struct ParticleSystemModifierData *psmd, int distr, int index, int index_dmcache, float *fuv, float foffset, float *vec, float *nor, float *utan, float *vtan);
 struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct ParticleSystem *psys);
 
 struct ParticleSettings *psys_new_settings(char *name, struct Main *main);
@@ -240,17 +241,17 @@
 float *psys_cache_vgroup(struct DerivedMesh *dm, struct ParticleSystem *psys, int vgroup);
 void psys_get_texture(struct Object *ob, struct Material *ma, struct ParticleSystemModifierData *psmd, struct ParticleSystem *psys, struct ParticleData *pa, struct ParticleTexture *ptex, int event);
 void psys_interpolate_face(struct MVert *mvert, struct MFace *mface, struct MTFace *tface, float *uv, float *vec, float *nor, float *utan, float *vtan);
-float psys_interpolate_value_from_verts(struct DerivedMesh *dm, short from, int index, float *fuv, float *values);
+float psys_interpolate_value_from_verts(struct DerivedMesh *dm, short from, int index, float *fw, float *values);
 void psys_get_from_key(struct ParticleKey *key, float *loc, float *vel, float *rot, float *time);
 
 int psys_intersect_dm(struct Object *ob, struct DerivedMesh *dm, float *vert_cos, float *co1, float* co2, float *min_d, int *min_face, float *min_uv, float *face_minmax, float *pa_minmax, float radius, float *ipoint);
-void psys_particle_on_dm(struct Object *ob, struct DerivedMesh *dm, int from, int index, int index_dmcache, float *fuv, float *vec, float *nor, float *utan, float *vtan);
+void psys_particle_on_dm(struct Object *ob, struct DerivedMesh *dm, int from, int index, int index_dmcache, float *fw, float foffset, float *vec, float *nor, float *utan, float *vtan);
 
 /* particle_system.c */
 void initialize_particle(struct ParticleData *pa, int p, struct Object *ob, struct ParticleSystem *psys, struct ParticleSystemModifierData *psmd);
 void reset_particle(struct ParticleData *pa, struct ParticleSystem *psys, struct ParticleSystemModifierData *psmd, struct Object *ob, float dtime, float cfra, float *vg_vel, float *vg_tan, float *vg_rot);
 
-int psys_particle_dm_face_lookup(struct Object *ob, struct DerivedMesh *dm, int index, float *fuv, struct LinkNode *node);
+int psys_particle_dm_face_lookup(struct Object *ob, struct DerivedMesh *dm, int index, float *fw, struct LinkNode *node);
 
 /* ParticleEffectorCache->type */
 #define PSYS_EC_EFFECTOR	1
@@ -261,7 +262,11 @@
 /* ParticleEditKey->flag */
 #define PEK_SELECT		1
 #define PEK_TO_SELECT	2
-#define PEK_REMOVE		4
+#define PEK_TAG			4
 #define PEK_HIDE		8
 
+/* index_dmcache */
+#define DMCACHE_NOTFOUND	-1
+#define DMCACHE_ISCHILD		-2
+
 #endif

Modified: branches/particles/source/blender/blenkernel/BKE_utildefines.h
===================================================================
--- branches/particles/source/blender/blenkernel/BKE_utildefines.h	2007-11-18 17:44:48 UTC (rev 12616)
+++ branches/particles/source/blender/blenkernel/BKE_utildefines.h	2007-11-18 21:27:19 UTC (rev 12617)
@@ -59,6 +59,10 @@
 #define ELEM8(a, b, c, d, e, f, g, h, i)        ( ELEM4(a, b, c, d, e) || ELEM4(a, f, g, h, i) )
 #define ELEM9(a, b, c, d, e, f, g, h, i, j)        ( ELEM4(a, b, c, d, e) || ELEM5(a, f, g, h, i, j) )
 
+/* shift around elements */
+#define SHIFT3(type, a, b, c) { type tmp; tmp = a; a = c; c = b; b = tmp; }
+#define SHIFT4(type, a, b, c, d) { type tmp; tmp = a; a = d; d = c; c = b; b = tmp; }
+
 /* string compare */
 #define STREQ(str, a)           ( strcmp((str), (a))==0 )
 #define STREQ2(str, a, b)       ( STREQ(str, a) || STREQ(str, b) )

Modified: branches/particles/source/blender/blenkernel/intern/customdata.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/customdata.c	2007-11-18 17:44:48 UTC (rev 12616)
+++ branches/particles/source/blender/blenkernel/intern/customdata.c	2007-11-18 21:27:19 UTC (rev 12617)
@@ -271,7 +271,7 @@
 
 static void layerDefault_tface(void *data, int count)
 {
-	static MTFace default_tf = {{{0, 1}, {0, 0}, {1, 0}, {1, 1}}, NULL,
+	static MTFace default_tf = {{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, NULL,
 	                           0, 0, TF_DYNAMIC, 0, 0};
 	MTFace *tf = (MTFace*)data;
 	int i;
@@ -345,7 +345,7 @@
 
 static void layerDefault_origspace_face(void *data, int count)
 {
-	static OrigSpaceFace default_osf = {{{0, 1}, {0, 0}, {1, 0}, {1, 1}}};
+	static OrigSpaceFace default_osf = {{{0, 0}, {1, 0}, {1, 1}, {0, 1}}};
 	OrigSpaceFace *osf = (OrigSpaceFace*)data;
 	int i;
 

Modified: branches/particles/source/blender/blenkernel/intern/modifier.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/modifier.c	2007-11-18 17:44:48 UTC (rev 12616)
+++ branches/particles/source/blender/blenkernel/intern/modifier.c	2007-11-18 21:27:19 UTC (rev 12617)
@@ -5429,7 +5429,7 @@
 	/* make tree of emitter locations */
 	tree=alloc_kdtree(totpart);
 	for(p=0,pa=psys->particles,cur=tree; p<totpart; p++,pa++,cur++){
-		psys_particle_on_dm(ob,dm,psys->part->from,pa->num,pa->num_dmcache,pa->fuv,cur->co,0,0,0);
+		psys_particle_on_dm(ob,dm,psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,cur->co,0,0,0);
 		cur->nbr=p;
 		if(p) insert_into_kdtree(tree,cur);
 	}
@@ -5999,9 +5999,8 @@
 
 	/*duplicate & displace vertices*/
 	for(i=0, pa=pars; i<=totpart; i++, pa++){
-
 		if(i!=totpart){
-			psys_particle_on_emitter(ob, psmd,part->from,pa->num,-1,pa->fuv,loc0,nor,0,0);
+			psys_particle_on_emitter(ob, psmd,part->from,pa->num,-1,pa->fuv,pa->foffset,loc0,nor,0,0);
 			Mat4MulVecfl(ob->obmat,loc0);
 
 			state.time=cfra;

Modified: branches/particles/source/blender/blenkernel/intern/particle.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle.c	2007-11-18 17:44:48 UTC (rev 12616)
+++ branches/particles/source/blender/blenkernel/intern/particle.c	2007-11-18 21:27:19 UTC (rev 12617)
@@ -548,27 +548,15 @@
 /************************************************/
 /*			Interpolated Particles				*/
 /************************************************/
-static float interpolate_particle_value(float v1, float v2, float v3, float v4, float *uv, int four){
-	float u=uv[0],v=uv[1];
-	if(four) {
-		float uv= u*v;
-		float muv= (1.0f-u)*(v);
-		float umv= (u)*(1.0f-v);
-		/*float mumv= (1.0f-u)*(1.0f-v); assigns -1.#IND000 to mumv!!! Wooot???*/
-		float tu = 1.0f-u;
-		float tv = 1.0f-v;
-		float mumv= tu*tv;
-		
-		return mumv*v1 + muv*v2 + uv*v3 + umv*v4;
-	}
-	else {
-		/* mirror triangle uv coordinates when on other side */
-		if(u + v > 1.0f) {
-			u= 1.0f-u;
-			v= 1.0f-v;
-		}
-		return v1 + u*(v3-v1) + v*(v2-v1);
-	}
+static float interpolate_particle_value(float v1, float v2, float v3, float v4, float *w, int four)
+{
+	float value;
+
+	value= w[0]*v1 + w[1]*v2 + w[2]*v3;
+	if(four)
+		value += w[3]*v4;
+	
+	return value;
 }
 static void weighted_particle_vector(float *v1, float *v2, float *v3, float *v4, float *weights, float *vec)
 {
@@ -609,12 +597,12 @@
 /*			Particles on a dm					*/
 /************************************************/
 /* interpolate a location on a face based on face coordinates */
-void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float *uv, float *vec, float *nor, float *utan, float *vtan){
+void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float *w, float *vec, float *nor, float *utan, float *vtan){
 	float *v1=0, *v2=0, *v3=0, *v4=0;
 	float e1[3],e2[3],s1,s2,t1,t2;
 	float *uv1, *uv2, *uv3, *uv4;
 	float n1[3], n2[3], n3[3], n4[3];
-	float tuv[4][2], u=uv[0], v=uv[1];
+	float tuv[4][2];
 
 	v1= (mvert+mface->v1)->co;
 	v2= (mvert+mface->v2)->co;
@@ -626,59 +614,35 @@
 	Normalize(n2);
 	Normalize(n3);
 
-	if(mface->v4 && uv[2]<0.0f){
-		u=(u-0.5f)*(-1.0f-uv[2])+0.5f;
-		v=(v-0.5f)*(-1.0f-uv[2])+0.5f;
-	}
-	
 	if(mface->v4) {
-		float uv= u*v;
-		float muv= (1.0f-u)*(v);
-		float umv= (u)*(1.0f-v);
-		/*float mumv= (1.0f-u)*(1.0f-v); assigns -1.#IND000 to mumv!!! Wooot???*/
-		float tu = 1.0f-u;
-		float tv = 1.0f-v;
-		float mumv= tu*tv;
-
 		v4= (mvert+mface->v4)->co;
 		VECCOPY(n4,(mvert+mface->v4)->no);
 		Normalize(n4);
 		
-		vec[0]= mumv*v1[0] + muv*v2[0] + uv*v3[0] + umv*v4[0];
-		vec[1]= mumv*v1[1] + muv*v2[1] + uv*v3[1] + umv*v4[1];
-		vec[2]= mumv*v1[2] + muv*v2[2] + uv*v3[2] + umv*v4[2];
+		vec[0]= w[0]*v1[0] + w[1]*v2[0] + w[2]*v3[0] + w[3]*v4[0];
+		vec[1]= w[0]*v1[1] + w[1]*v2[1] + w[2]*v3[1] + w[3]*v4[1];
+		vec[2]= w[0]*v1[2] + w[1]*v2[2] + w[2]*v3[2] + w[3]*v4[2];
 
 		if(nor){
 			if(mface->flag & ME_SMOOTH){
-				nor[0]= mumv*n1[0] + muv*n2[0] + uv*n3[0] + umv*n4[0];
-				nor[1]= mumv*n1[1] + muv*n2[1] + uv*n3[1] + umv*n4[1];
-				nor[2]= mumv*n1[2] + muv*n2[2] + uv*n3[2] + umv*n4[2];
+				nor[0]= w[0]*n1[0] + w[1]*n2[0] + w[2]*n3[0] + w[3]*n4[0];
+				nor[1]= w[0]*n1[1] + w[1]*n2[1] + w[2]*n3[1] + w[3]*n4[1];
+				nor[2]= w[0]*n1[2] + w[1]*n2[2] + w[2]*n3[2] + w[3]*n4[2];
 			}
 			else
 				CalcNormFloat4(v1,v2,v3,v4,nor);
 		}
 	}
 	else {
-		/* mirror triangle uv coordinates when on other side */
-		if(u + v > 1.0f) {
-			u= 1.0f-u;
-			v= 1.0f-v;
-		}
-
-		if(uv[2]<0.0f){
-			u=(u-0.5f)*(-1.0f-uv[2])+0.5f + 0.16667f*(-2.0f-uv[2]);
-			v=(v-0.5f)*(-1.0f-uv[2])+0.5f + 0.16667f*(-2.0f-uv[2]);
-		}
-
-		vec[0]= v1[0] + u*(v3[0]-v1[0]) + v*(v2[0]-v1[0]);
-		vec[1]= v1[1] + u*(v3[1]-v1[1]) + v*(v2[1]-v1[1]);
-		vec[2]= v1[2] + u*(v3[2]-v1[2]) + v*(v2[2]-v1[2]);
+		vec[0]= w[0]*v1[0] + w[1]*v2[0] + w[2]*v3[0];

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list