[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11764] branches/particles/source/blender: *bugs fixed

Janne Karhu jhkarh at utu.fi
Tue Aug 21 15:05:02 CEST 2007


Revision: 11764
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11764
Author:   jhk
Date:     2007-08-21 15:05:02 +0200 (Tue, 21 Aug 2007)

Log Message:
-----------
*bugs fixed
	-effector particles crashed sometimes
	-particle rotations weren't read properly from baked data
	-baking with 0 particles didn't work
	-edit points weren't converted to global space correctly
	-autobaked paths weren't drawn for current system in bake mode
	-cut brush removed from softbody editing as it really didn't make sense there
	-soft body point to hair key indexes weren't included in bake undo data
	-first baked keys were often wrong
	-particles had wrong locations after changing system type from hair
	-reactor or keyed particles with no proper targets resulted in infinite bake or crash
	-hair soft body was calculated even if it was disabled in ui
	-locally baked soft body keys weren't converted into paths properly
	-hair soft body wasn't duplicated properly
	-some overlapping text in outliner
*new things
	-soft body bakes can be edited in "direct mode" where the nearest key of every element is available for editing. After baking a soft body "direct mode" is accessed for "object soft body" by going into normal edit mode (cage for soft body modifier must be on), or for "hair soft body" by editing the hair system (not the baked hair soft body)
	-add brush uses different random distribution of particles every time the brush is used
	-clearer coloring for bake mode paths
	-billboard split uv indexes start can be offset randomly

Modified Paths:
--------------
    branches/particles/source/blender/blenkernel/BKE_dynamics_bake.h
    branches/particles/source/blender/blenkernel/BKE_particle.h
    branches/particles/source/blender/blenkernel/intern/dynamics_bake.c
    branches/particles/source/blender/blenkernel/intern/modifier.c
    branches/particles/source/blender/blenkernel/intern/object.c
    branches/particles/source/blender/blenkernel/intern/particle.c
    branches/particles/source/blender/blenkernel/intern/particle_system.c
    branches/particles/source/blender/blenkernel/intern/softbody.c
    branches/particles/source/blender/include/BIF_editbake.h
    branches/particles/source/blender/makesdna/DNA_particle_types.h
    branches/particles/source/blender/render/intern/source/convertblender.c
    branches/particles/source/blender/src/buttons_editing.c
    branches/particles/source/blender/src/buttons_object.c
    branches/particles/source/blender/src/drawobject.c
    branches/particles/source/blender/src/editbake.c
    branches/particles/source/blender/src/editobject.c
    branches/particles/source/blender/src/outliner.c
    branches/particles/source/blender/src/transform_conversions.c

Modified: branches/particles/source/blender/blenkernel/BKE_dynamics_bake.h
===================================================================
--- branches/particles/source/blender/blenkernel/BKE_dynamics_bake.h	2007-08-21 06:06:12 UTC (rev 11763)
+++ branches/particles/source/blender/blenkernel/BKE_dynamics_bake.h	2007-08-21 13:05:02 UTC (rev 11764)
@@ -38,6 +38,7 @@
 
 	void (*set_baking)(struct BakeableSystem *bsys);
 	void (*end_baking)(struct BakeableSystem *bsys);
+	int (*can_be_baked)(struct BakeableSystem *bsys);
 	
 	/* prepare system to continue baking from cfra */
 	void (*set_rebaking)(struct BakeableSystem *bsys, float cfra);
@@ -60,7 +61,6 @@
 	void (*convert_dynamic_key)(struct BakeableSystem *bsys, void *dynkey, struct BakeKey *key, float *ckey);
 	void (*convert_bake_key)(struct BakeableSystem *bsys, struct BakeKey *key, float *ckey, void *dynkey);
 	void (*interpolate_customkey)(struct BakeableSystem *bsys, float *ckey1, float *ckey2, float keytime, float *ckey);
-	void (*convert_to_global_space)(struct BakeableSystem *bsys, int index, struct BakeKey *key, float *ckey);
 
 	void (*remove_set_elements)(struct BakeableSystem *bsys, int new_totbel);
 } BakeableAccess;
@@ -82,6 +82,7 @@
 struct BakeBase *DB_new_BakeBase();
 void DB_copy_BakeableSystem(struct BakeableSystem *to, struct BakeableSystem *from);
 
+void DB_key_to_global_space(struct BakeableSystem *bsys, short from_space, int index, struct BakeKey *key, float *ckey);
 int DB_get_key_at_time(struct BakeableSystem *bsys, int index, float time, struct BakeKey *key, float *ckey);
 void DB_get_key_on_path(struct BakeableSystem *bsys, int index, float path, struct BakeKey *key, float *ckey);
 void DB_save_keys(struct BakeableSystem *bsys, float cfra);

Modified: branches/particles/source/blender/blenkernel/BKE_particle.h
===================================================================
--- branches/particles/source/blender/blenkernel/BKE_particle.h	2007-08-21 06:06:12 UTC (rev 11763)
+++ branches/particles/source/blender/blenkernel/BKE_particle.h	2007-08-21 13:05:02 UTC (rev 11764)
@@ -135,33 +135,6 @@
 
 void particle_system_update(struct Object *ob, struct ParticleSystem *psys);
 
-/* particle_edit.c */
-//void foreach_particle(struct ParticleSystem *psys, void (*func)(ParticleSystem *psys, int index, void *userData), void *userData);
-//void particle_select_root(struct ParticleSystem *psys, int index, void *userData);
-//void particle_select_tip(struct ParticleSystem *psys, int index, void *userData);
-//void pe_apply_averages(void);
-//void pe_keytime_change(void);
-//void set_particle_edit(void);
-//void mouse_particles(void);
-//void select_linked_particles(void);
-//void particle_borderselect(void);
-//void pe_brush_particles(void);
-//void deselectall_particle(void);
-//void particle_selectionCB(short selecting, struct Object *editobj, short *mval, float rad);
-//void do_lasso_select_particles(short mcords[][2], short moves, short select);
-//void select_less_particle(void);
-//void select_more_particle(void);
-//void hide_particles(void);
-//void pe_rekey(void);
-//void pe_subdivide(void);
-//void pe_delete_particle(void);
-//void pe_averages_change(void);
-//
-//void undo_push_particle(char *str);
-//void particle_undo(void);
-//void particle_redo(void);
-//void particle_undo_menu(void);
-
 /* ----------- functions needed only inside particlesystem ------------ */
 /* particle.c */
 void psys_key_to_object(struct Object *ob, struct ParticleKey *key, float imat[][4]);

Modified: branches/particles/source/blender/blenkernel/intern/dynamics_bake.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/dynamics_bake.c	2007-08-21 06:06:12 UTC (rev 11763)
+++ branches/particles/source/blender/blenkernel/intern/dynamics_bake.c	2007-08-21 13:05:02 UTC (rev 11764)
@@ -46,6 +46,8 @@
 
 #include "mydevice.h"
 
+static void psys_end_baking(BakeableSystem *bsys);
+
 int modifier_effects_baked(Object *ob, ModifierData *mod)
 {
 	ModifierTypeInfo *mti = modifierType_getInfo(mod->type);
@@ -134,12 +136,13 @@
 }
 void DB_copy_BakeableSystem(BakeableSystem *to, BakeableSystem *from)
 {
+	BakeableSystem *bsys;
 	BakeElement *nbel, *bel;
 	int i;
 
 	memcpy(to,from,sizeof(BakeableSystem));
 	
-	if(to->elements){
+	if(from->elements){
 		nbel = to->elements = MEM_dupallocN(from->elements);
 		for(i=0,bel=from->elements; i<to->totbel; i++, nbel++,bel++)
 		{
@@ -148,8 +151,12 @@
 		}
 	}
 
+	if(from->bp_key_index)
+		to->bp_key_index = MEM_dupallocN(from->bp_key_index);
+
 	to->pathcache=to->childcache=0;
 	to->totcached=to->totchildcache=0;
+	to->edit=0;
 }
 void DB_copy_key(BakeKey *to, BakeKey *from){
 	memcpy(to,from,sizeof(BakeKey));
@@ -247,7 +254,7 @@
 			QuatMul(ckey+3,q,ckey+3);
 	}
 }
-static void key_to_global_space(BakeableSystem *bsys, short from_space, int index, BakeKey *key, float *ckey)
+void DB_key_to_global_space(BakeableSystem *bsys, short from_space, int index, BakeKey *key, float *ckey)
 {
 	if(from_space){
 		if(from_space==BSYS_SPACE_GEOMETRY && bsys->type==BAKEABLE_PARTICLE){
@@ -268,9 +275,8 @@
 	float *ckey1=0, *ckey2=0;
 	int soft=0, edit=0;
 	short interpolation = bsys->interpolation;
-
 	float keytime,dfra,frs_sec=G.scene->r.frs_sec;
-	int k;
+	int k, csize=bacc->custom_size;
 
 	if(bsys->elements==0) return 0;
 
@@ -296,7 +302,7 @@
 		if(soft)
 			VecCopyf(key->co,(bp+bsys->bp_key_index[index])->pos);
 		if(ckey)
-			memcpy(ckey,ckey1,bacc->custom_size*sizeof(float));
+			memcpy(ckey,ckey1,csize*sizeof(float));
 		return 0;
 	}
 	
@@ -305,7 +311,7 @@
 		if(soft)
 			VecCopyf(key->co,(bp+bsys->bp_key_index[index]+bel->totkey-1)->pos);
 		if(ckey)
-			memcpy(ckey,ckey1+(bel->totkey-1)*bacc->custom_size,bacc->custom_size*sizeof(float));
+			memcpy(ckey,ckey1+(bel->totkey-1)*csize,csize*sizeof(float));
 		return 0;
 	}
 
@@ -314,7 +320,7 @@
 		if(soft)
 			VecCopyf(key->co,(bp+bsys->bp_key_index[index])->pos);
 		if(ckey)
-			memcpy(ckey,ckey1,bacc->custom_size*sizeof(float));
+			memcpy(ckey,ckey1,csize*sizeof(float));
 		return 1;
 	}
 
@@ -322,12 +328,12 @@
 
 	while((key1+1)->time < time){ /* TODO: binary search here */
 		key1++;
-		if(ckey) ckey1++;
+		if(ckey) ckey1+=csize;
 		k++;
 	}
 
 	key2=key1+1;
-	if(ckey) ckey2=ckey1+1;
+	if(ckey) ckey2=ckey1+csize;
 
 	DB_copy_key(&k2,key1);
 	if(soft)
@@ -435,7 +441,7 @@
 	int k,i;
 	int steps=(int)pow(2.0,(double)bsys->draw_step);
 	int totbel=bsys->totbel;
-	short interpolation=bsys->interpolation;
+	short interpolation=bsys->interpolation, key_space=bsys->key_space;
 	int edit=0,timed=0, soft=0;
 	char nosel[4], sel[4];
 	float sel_col[3];
@@ -448,8 +454,8 @@
 		
 		timed=bsys->edit->draw_timed;
 
-		BIF_GetThemeColor3ubv(TH_VERTEX_SELECT, sel);
-		BIF_GetThemeColor3ubv(TH_VERTEX, nosel);
+		BIF_GetThemeColor3ubv(TH_EDGE_SELECT, sel);
+		BIF_GetThemeColor3ubv(TH_WIRE, nosel);
 		if(bsys->edit->brush==EB_BRUSH_WEIGHT){
 			sel_col[0]=sel_col[1]=sel_col[2]=1.0f;
 			nosel_col[0]=nosel_col[1]=nosel_col[2]=0.0f;
@@ -471,9 +477,17 @@
 	for(i=0; i<totbel; i++)
 		cache[i]=MEM_callocN((steps+1)*sizeof(BakeCacheKey), "Path cache");
 
-	if(edit==0 && bsys->flag&BSYS_DONE && (bsys->flag&BSYS_AUTOBAKE)==0 && bsys->soft && bsys->softflag&OB_SB_ENABLE){
-		soft=1;
-		bp=bsys->soft->bpoint;
+	if(bsys->flag&BSYS_DONE && (bsys->flag&BSYS_AUTOBAKE)==0 && bsys->soft && bsys->softflag&OB_SB_ENABLE){
+		BakeableSystem *sbsys=DB_find_bsys(&bsys->ob->bakeable,bsys->soft);
+
+		if(edit==0 || (sbsys->flag&BSYS_DONE && (sbsys->flag&BSYS_AUTOBAKE)==0)){
+			soft=1;
+			bp=bsys->soft->bpoint;
+			if(sbsys->flag & BSYS_DONE)
+				key_space=sbsys->key_space;
+			else
+				key_space=BSYS_SPACE_GLOBAL;
+		}
 	}
 	
 	if(bsys->type==BAKEABLE_PARTICLE){
@@ -590,9 +604,9 @@
 					VecMulf(state.vel,1.0/dfra);
 			}
 
-			if(soft==0)
-				key_to_global_space(bsys,bsys->key_space,i,&state,0);
 			
+			DB_key_to_global_space(bsys,key_space,i,&state,0);
+			
 			/* apply guide curves to path data */
 			if(bsys->type==BAKEABLE_PARTICLE){
 				ParticleSystem *psys = bsys->system;
@@ -665,8 +679,9 @@
 						VecLerpf(cstate->col,sel_col,nosel_col,(1.0-keytime)*ckey->weight+keytime*(ckey+1)->weight);
 				}
 				else{
-					if((bek+(key[0]-bel->keys))->flag&BEK_SELECT){
-						if((bek+(key[1]-bel->keys))->flag&BEK_SELECT){
+					BakeKey *belkeys = soft?sbel.keys:bel->keys;
+					if((bek+(key[0]-belkeys))->flag&BEK_SELECT){
+						if((bek+(key[1]-belkeys))->flag&BEK_SELECT){
 							VECCOPY(cstate->col,sel_col);
 						}
 						else{
@@ -674,7 +689,7 @@
 						}
 					}
 					else{
-						if((bek+(key[1]-bel->keys))->flag&BEK_SELECT){
+						if((bek+(key[1]-belkeys))->flag&BEK_SELECT){
 							VecLerpf(cstate->col,nosel_col,sel_col,keytime);
 						}
 						else{
@@ -816,6 +831,7 @@
 
 	if(bsys->soft){
 		DB_free_bake(DB_find_bsys(&bsys->ob->bakeable,bsys->soft));
+		bsys->softflag &= ~OB_SB_ENABLE;
 	}
 
 	bsys->flag &= ~BSYS_DONE;
@@ -840,6 +856,15 @@
 	BakeElement *bel;
 	int i, totbel=bsys->totbel, done=0;
 
+	/* exception for particlesystems with no particles */
+	if(bsys->type==BAKEABLE_PARTICLE){
+		ParticleSystem *psys = (ParticleSystem*)bsys->system;
+		if(totbel==0 && psys->particles==0){
+			psys_end_baking(bsys);
+			return 1;
+		}
+	}
+
 	if(bsys->flag & BSYS_DONE)
 		done=bsys->totbel;
 	else{
@@ -997,6 +1022,8 @@
 
 	short ret=0;
 
+	if(psys->part->phystype==PART_PHYS_KEYED) return 0;
+
 	if(psys->recalc & PSYS_TYPE){
 		if(psys->part->type==PART_HAIR)
 			bsys->flag |= BSYS_AUTOBAKE;
@@ -1040,6 +1067,27 @@
 	psys->flag &= ~PSYS_BAKING;
 	bsys->flag |= BSYS_DONE;
 }
+static int psys_can_be_baked(BakeableSystem *bsys)
+{
+	ParticleSystem *psys=(ParticleSystem*)bsys->system;
+
+	/* exception for reactor particles with no valid target */
+	if(psys->part->type==PART_REACTOR){
+		if(psys->target_ob==0 || BLI_findlink(&psys->target_ob->particlesystem,psys->target_psys-1)==0){
+			error("No valid target for reactor particles");
+			return 0;
+		}
+	}
+	else if(psys->part->phystype==PART_PHYS_KEYED){
+		psys_count_keyed_targets(bsys->ob,psys);
+		if(psys->totkeyed==0){
+			error("No valid target for keyed particles");
+			return 0;
+		}
+	}
+
+	return 1;
+}
 static void psys_set_rebaking(BakeableSystem *bsys, float cfra)
 {
 	return;
@@ -1080,8 +1128,7 @@
 		return BSYS_BAKE_KEY;
 	}
 	else{
-		//if(cfra <= pa->time)
-		if(bel->totkey==0)
+		if(cfra <= pa->time)
 			return BSYS_FIRST_KEY;
 		if(cfra >= pa->time && cfra < pa->dietime &&

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list