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

Brecht Van Lommel brechtvanlommel at pandora.be
Tue Nov 13 23:03:42 CET 2007


Revision: 12582
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12582
Author:   blendix
Date:     2007-11-13 23:03:42 +0100 (Tue, 13 Nov 2007)

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

Particle Edit Mode
==================

- Brushes and other settings are now saved in the scene toolsettings,
  and saved to file.
- Made the button value range of emitter distance bigger (1.0 -> 10.0).

Modified Paths:
--------------
    branches/particles/source/blender/blenkernel/BKE_particle.h
    branches/particles/source/blender/blenkernel/intern/particle.c
    branches/particles/source/blender/blenkernel/intern/particle_system.c
    branches/particles/source/blender/blenkernel/intern/scene.c
    branches/particles/source/blender/blenloader/intern/readfile.c
    branches/particles/source/blender/blenloader/intern/writefile.c
    branches/particles/source/blender/include/BIF_editparticle.h
    branches/particles/source/blender/makesdna/DNA_scene_types.h
    branches/particles/source/blender/src/buttons_editing.c
    branches/particles/source/blender/src/drawobject.c
    branches/particles/source/blender/src/drawview.c
    branches/particles/source/blender/src/editobject.c
    branches/particles/source/blender/src/editparticle.c
    branches/particles/source/blender/src/space.c
    branches/particles/source/blender/src/transform_conversions.c

Modified: branches/particles/source/blender/blenkernel/BKE_particle.h
===================================================================
--- branches/particles/source/blender/blenkernel/BKE_particle.h	2007-11-13 21:32:53 UTC (rev 12581)
+++ branches/particles/source/blender/blenkernel/BKE_particle.h	2007-11-13 22:03:42 UTC (rev 12582)
@@ -148,8 +148,6 @@
 	char name[64];
 } ParticleUndo;
 
-#define PE_TOT_BRUSH		7
-
 typedef struct ParticleEdit{
 	ListBase undo;
 	struct ParticleUndo *curundo;
@@ -157,15 +155,7 @@
 	ParticleEditKey **keys;
 	float *emitter_cosnos;
 
-	float keytime, o_keytime;
-	float emitter_dist;
-	
 	int totkeys;
-	
-	short flag, brush, totrekey, totaddkey, draw_timed;
-	short brushsize[PE_TOT_BRUSH];
-	short brushpow[PE_TOT_BRUSH];
-	short average, brushstep;
 } ParticleEdit;
 
 /* ----------- functions needed outside particlesystem ---------------- */
@@ -262,6 +252,7 @@
 
 int psys_particle_dm_face_lookup(struct DerivedMesh *dm, int index, float *fuv, struct LinkNode *node);
 
+/* ParticleEffectorCache->type */
 #define PSYS_EC_EFFECTOR	1
 #define PSYS_EC_DEFLECT		2
 #define PSYS_EC_PARTICLE	4
@@ -273,24 +264,4 @@
 #define PEK_REMOVE		4
 #define PEK_HIDE		8
 
-/* ParticleEdit->flag */
-#define PE_KEEP_LENGTHS		1
-#define PE_LOCK_FIRST		2
-#define PE_DEFLECT_EMITTER	4
-#define PE_INTERPOLATE_ADDED	8
-#define PE_SHOW_CHILD		16
-#define PE_SHOW_TIME		32
-#define PE_ROT_VEL			64
-#define PE_ROT_ROT			128
-
-/* ParticleEdit->brush */
-#define PE_BRUSH_NO			-1
-#define PE_BRUSH_COMB		0
-#define PE_BRUSH_CUT		1
-#define PE_BRUSH_GROW		2
-#define PE_BRUSH_SHRINK		3
-#define PE_BRUSH_ADD		4
-#define PE_BRUSH_WEIGHT		5
-#define PE_BRUSH_SMOOTH		6
-
 #endif

Modified: branches/particles/source/blender/blenkernel/intern/particle.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle.c	2007-11-13 21:32:53 UTC (rev 12581)
+++ branches/particles/source/blender/blenkernel/intern/particle.c	2007-11-13 22:03:42 UTC (rev 12582)
@@ -1505,6 +1505,7 @@
 void cache_psys_child_paths(Object *ob, ParticleSystem *psys, float cfra)
 {
 	ParticleSettings *part = psys->part;
+	ParticleEditSettings *pset = &G.scene->toolsettings->particle;
 	ParticleSystemModifierData *psmd = psys_get_modifier(ob,psys);
 	ParticleData *pa;
 	ChildParticle *cpa;
@@ -1534,7 +1535,7 @@
 
 	/*---start figuring out what is actually wanted---*/
 	if(psys_in_edit_mode(psys)){
-		if(G.rendering==0 && (psys->edit==NULL || psys->edit->flag & PE_SHOW_CHILD)==0)
+		if(G.rendering==0 && (psys->edit==NULL || pset->flag & PE_SHOW_CHILD)==0)
 			totchild=0;
 		edit=1;
 	}
@@ -1847,6 +1848,7 @@
 {
 	ParticleCacheKey *ca, **cache=psys->pathcache;
 	ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
+	ParticleEditSettings *pset = &G.scene->toolsettings->particle;
 	
 	ParticleData *pa;
 	ParticleKey keys[4], result, *kkey[2] = {NULL, NULL};
@@ -1884,7 +1886,7 @@
 		//timed = edit->draw_timed;
 
 		PE_get_colors(sel,nosel);
-		if(psys->edit->brush == PE_BRUSH_WEIGHT){
+		if(pset->brushtype == PE_BRUSH_WEIGHT){
 			sel_col[0] = sel_col[1] = sel_col[2] = 1.0f;
 			nosel_col[0] = nosel_col[1] = nosel_col[2] = 0.0f;
 		}
@@ -2087,7 +2089,7 @@
 
 			/* selection coloring in edit mode */
 			if(edit){
-				if(edit->brush==PE_BRUSH_WEIGHT){
+				if(pset->brushtype==PE_BRUSH_WEIGHT){
 					if(k==steps)
 						VecLerpf(ca->col, nosel_col, sel_col, hkey[0]->weight);
 					else

Modified: branches/particles/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle_system.c	2007-11-13 21:32:53 UTC (rev 12581)
+++ branches/particles/source/blender/blenkernel/intern/particle_system.c	2007-11-13 22:03:42 UTC (rev 12582)
@@ -3941,6 +3941,7 @@
 static void psys_update_path_cache(Object *ob, ParticleSystemModifierData *psmd, ParticleSystem *psys, float cfra)
 {
 	ParticleSettings *part=psys->part;
+	ParticleEditSettings *pset=&G.scene->toolsettings->particle;
 	int distr=0,alloc=0;
 
 	if((psys->part->childtype && psys->totchild != psys->totpart*part->child_nbr) || psys->recalc&PSYS_ALLOC)
@@ -3967,7 +3968,7 @@
 
 		if(part->childtype){
 			if((G.rendering || (part->flag&PART_CHILD_RENDER)==0)
-				|| (psys_in_edit_mode(psys) && (psys->edit->flag&PE_SHOW_CHILD)))
+				|| (psys_in_edit_mode(psys) && (pset->flag&PE_SHOW_CHILD)))
 				cache_psys_child_paths(ob, psys, cfra);
 		}
 	}

Modified: branches/particles/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/scene.c	2007-11-13 21:32:53 UTC (rev 12581)
+++ branches/particles/source/blender/blenkernel/intern/scene.c	2007-11-13 22:03:42 UTC (rev 12582)
@@ -174,6 +174,8 @@
 Scene *add_scene(char *name)
 {
 	Scene *sce;
+	ParticleEditSettings *pset;
+	int a;
 
 	sce= alloc_libblock(&G.main->scene, ID_SCE, name);
 	sce->lay= 1;
@@ -232,6 +234,19 @@
 	sce->toolsettings->unwrapper = 1;
 	sce->toolsettings->select_thresh= 0.01f;
 	sce->toolsettings->jointrilimit = 0.8f;
+
+	pset= &sce->toolsettings->particle;
+	pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER;
+	pset->emitterdist= 0.25f;
+	pset->totrekey= 5;
+	pset->totaddkey= 5;
+	pset->brushtype= PE_BRUSH_NONE;
+	for(a=0; a<PE_TOT_BRUSH; a++) {
+		pset->brush[a].strength= 50;
+		pset->brush[a].size= 50;
+		pset->brush[a].step= 10;
+	}
+	pset->brush[PE_BRUSH_CUT].strength= 100;
 	
 	sce->jumpframe = 10;
 	sce->audio.mixrate = 44100;

Modified: branches/particles/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/particles/source/blender/blenloader/intern/readfile.c	2007-11-13 21:32:53 UTC (rev 12581)
+++ branches/particles/source/blender/blenloader/intern/readfile.c	2007-11-13 22:03:42 UTC (rev 12582)
@@ -7182,6 +7182,32 @@
 			}
 		}
 	}
+
+	if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 8)) {
+		Scene *sce;
+
+		for(sce= main->scene.first; sce; sce=sce->id.next) {
+			ParticleEditSettings *pset= &sce->toolsettings->particle;
+			int a;
+
+			if(pset->brush[0].size == 0) {
+				pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER;
+				pset->emitterdist= 0.25f;
+				pset->totrekey= 5;
+				pset->totaddkey= 5;
+				pset->brushtype= PE_BRUSH_NONE;
+
+				for(a=0; a<PE_TOT_BRUSH; a++) {
+					pset->brush[a].strength= 50;
+					pset->brush[a].size= 50;
+					pset->brush[a].step= 10;
+				}
+
+				pset->brush[PE_BRUSH_CUT].strength= 100;
+			}
+		}
+
+	}
 	/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
 	/* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
 

Modified: branches/particles/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/particles/source/blender/blenloader/intern/writefile.c	2007-11-13 21:32:53 UTC (rev 12581)
+++ branches/particles/source/blender/blenloader/intern/writefile.c	2007-11-13 22:03:42 UTC (rev 12582)
@@ -850,7 +850,6 @@
 static void write_objects(WriteData *wd, ListBase *idbase)
 {
 	Object *ob;
-	int a;
 	
 	ob= idbase->first;
 	while(ob) {

Modified: branches/particles/source/blender/include/BIF_editparticle.h
===================================================================
--- branches/particles/source/blender/include/BIF_editparticle.h	2007-11-13 21:32:53 UTC (rev 12581)
+++ branches/particles/source/blender/include/BIF_editparticle.h	2007-11-13 22:03:42 UTC (rev 12582)
@@ -37,6 +37,7 @@
 
 struct Object;
 struct ParticleSystem;
+struct ParticleEditSettings;
 
 /* particle edit mode */
 void PE_set_particle_edit(void);
@@ -51,6 +52,7 @@
 short PE_get_current_num(struct Object *ob);
 int PE_minmax(float *min, float *max);
 void PE_get_colors(char sel[4], char nosel[4]);
+struct ParticleEditSettings *PE_settings(void);
 
 /* update calls */
 void PE_hide_keys_time(struct ParticleSystem *psys, float cfra);

Modified: branches/particles/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/particles/source/blender/makesdna/DNA_scene_types.h	2007-11-13 21:32:53 UTC (rev 12581)
+++ branches/particles/source/blender/makesdna/DNA_scene_types.h	2007-11-13 22:03:42 UTC (rev 12582)
@@ -314,6 +314,23 @@
 	int pad3;
 } ImagePaintSettings;
 
+typedef struct ParticleBrushData {
+	short size, strength;	/* commong settings */
+	short step, pad;		/* for add brush only */
+} ParticleBrushData;
+
+typedef struct ParticleEditSettings {
+	short flag;
+	short totrekey;
+	short totaddkey;
+	short brushtype;
+
+	ParticleBrushData brush[7]; /* 7 = PE_TOT_BRUSH */
+
+	float emitterdist;
+	int draw_timed;
+} ParticleEditSettings;
+
 typedef struct ToolSettings {
 	/* Subdivide Settings */
 	short cornertype;
@@ -348,6 +365,9 @@
 	
 	/* Image Paint (8 byte aligned please!) */
 	struct ImagePaintSettings imapaint;
+
+	/* Particle Editing */
+	struct ParticleEditSettings particle;
 	
 	/* Select Group Threshold */
 	float select_thresh;
@@ -663,6 +683,27 @@
 #define IMAGEPAINT_DRAW_TOOL			2
 #define IMAGEPAINT_DRAW_TOOL_DRAWING	4
 
+/* toolsettings->particle flag */
+#define PE_KEEP_LENGTHS			1
+#define PE_LOCK_FIRST			2
+#define PE_DEFLECT_EMITTER		4
+#define PE_INTERPOLATE_ADDED	8
+#define PE_SHOW_CHILD			16
+#define PE_SHOW_TIME			32
+
+/* toolsetting->particle brushtype */
+#define PE_BRUSH_NONE		-1
+#define PE_BRUSH_COMB		0
+#define PE_BRUSH_CUT		1
+#define PE_BRUSH_GROW		2
+#define PE_BRUSH_SHRINK		3
+#define PE_BRUSH_ADD		4
+#define PE_BRUSH_WEIGHT		5
+#define PE_BRUSH_SMOOTH		6
+
+/* this must equal ParticleEditSettings.brush array size */
+#define PE_TOT_BRUSH		7  
+
 /* toolsettings->retopo_mode */
 #define RETOPO 1
 #define RETOPO_PAINT 2

Modified: branches/particles/source/blender/src/buttons_editing.c
===================================================================
--- branches/particles/source/blender/src/buttons_editing.c	2007-11-13 21:32:53 UTC (rev 12581)
+++ branches/particles/source/blender/src/buttons_editing.c	2007-11-13 22:03:42 UTC (rev 12582)
@@ -5385,7 +5385,7 @@
 		psys=PE_get_current(ob);
 		PE_hide_keys_time(psys,CFRA);
 		psys_cache_paths(ob,psys,CFRA);
-		if(psys->edit->flag & PE_SHOW_CHILD)
+		if(PE_settings()->flag & PE_SHOW_CHILD)
 			cache_psys_child_paths(ob,psys,CFRA);
 		
 		allqueue(REDRAWVIEW3D, 0);
@@ -5740,6 +5740,7 @@
 {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list