[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11850] branches/particles/source/blender: *bug fixes:

Janne Karhu jhkarh at utu.fi
Mon Aug 27 23:15:50 CEST 2007


Revision: 11850
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11850
Author:   jhk
Date:     2007-08-27 23:15:50 +0200 (Mon, 27 Aug 2007)

Log Message:
-----------
*bug fixes:
	-infinite bake when e_freq ipo was used
	-geometry space didn't work correctly with "keep from emitter surface"
	-particles in group duplicated objects are drawn correctly
	-curve guides could be enabled for non-curve objects -> crash
	-autobaking wasn't available after bake and bake mode
	-bake timing wasn't sub-frame correct
	-child particle changes started unnescessary baking
	-virtual child parents resulted in segfault in other that path visualization
	-child particles weren't updated properly in bake mode
	-visualization changing was missing a check for dupli objects -> missing particles in render after using dupli objects
*new things:
	-new "time-index" uv channel for billboards
	-rebake from current frame, allows for example editing "bad bakes" at some point and rebaking with dynamics from that point onwards
	-some cleanup and reorganization of baking code
	-bakeable systems panel
		*removed particle and soft body "baking panels"
	-set/edit/free starting point for soft body (this may break backwards compatibility once again with baked systems, should be ok if bake is freed in old version)
	-cage editing is now on by default for the soft body modifier (allows instant editing of object soft body bakes)

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/particle.c
    branches/particles/source/blender/blenkernel/intern/particle_system.c
    branches/particles/source/blender/blenkernel/intern/softbody.c
    branches/particles/source/blender/blenloader/intern/readfile.c
    branches/particles/source/blender/blenloader/intern/writefile.c
    branches/particles/source/blender/include/butspace.h
    branches/particles/source/blender/makesdna/DNA_bake_types.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/editipo.c
    branches/particles/source/blender/src/header_ipo.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-27 20:29:32 UTC (rev 11849)
+++ branches/particles/source/blender/blenkernel/BKE_dynamics_bake.h	2007-08-27 21:15:50 UTC (rev 11850)
@@ -36,7 +36,7 @@
 	
 	int (*needs_autobake)(struct BakeableSystem *bsys);
 
-	void (*set_baking)(struct BakeableSystem *bsys);
+	void (*set_baking)(struct BakeableSystem *bsys, int *avg_keys);
 	void (*end_baking)(struct BakeableSystem *bsys);
 	int (*can_be_baked)(struct BakeableSystem *bsys);
 	
@@ -55,7 +55,7 @@
 
 	int (*key_needs_saving)(struct BakeableSystem *bsys, int index, float cfra);
 
-	int (*initialize_save_keys)(struct BakeableSystem *bsys, int *avg_keys);
+	void (*initialize_save_keys)(struct BakeableSystem *bsys);
 
 	void (*save_key_from_dynamics)(struct BakeableSystem *bsys, int index, float cfra, struct BakeKey *key, float *ckey);
 	void (*convert_dynamic_key)(struct BakeableSystem *bsys, void *dynkey, struct BakeKey *key, float *ckey);
@@ -65,23 +65,25 @@
 	void (*remove_set_elements)(struct BakeableSystem *bsys, int new_totbel);
 } BakeableAccess;
 
-#define BSYS_FIRST_KEY	-1
-#define BSYS_NO_KEY		0
-#define BSYS_BAKE_KEY	1
-#define BSYS_LAST_KEY	2
-
 int modifier_effects_baked(struct Object *ob, struct ModifierData *mod);
 int dynamicsbake_test();
 struct BakeableSystem *DB_find_bsys(struct ListBase *bakeable, void *system);
 struct BakeBase *DB_find_bbase(struct ListBase *bakeable, void *system);
 int DB_has_hair(struct ListBase *bakeable);
+void DB_free_bake_cb(void *bsys_v, void *arg2);
 void DB_free_bsys(struct BakeableSystem *bsys);
 void DB_free_bbase(struct BakeBase *bbase);
+
+void DB_set_start_cb(void *bsys_v, void *arg2);
+void DB_free_start_cb(void *bsys_v, void *arg2);
+
 void DB_copy_key(struct BakeKey *to, struct BakeKey *from);
 int DB_count_keys(struct BakeableSystem *bsys);
 struct BakeBase *DB_new_BakeBase();
 void DB_copy_BakeableSystem(struct BakeableSystem *to, struct BakeableSystem *from);
 
+void key_from_geometry(struct BakeableSystem *bsys, int v1, int v2, int v3, struct BakeKey *key, float *ckey);
+void key_to_geometry(struct BakeableSystem *bsys, int v1, int v2, int v3, struct BakeKey *key, float *ckey);
 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);
@@ -92,6 +94,8 @@
 
 char *DB_menu_string(struct Object *ob, int for_soft);
 
+void DB_psys_set_key(struct BakeableSystem *bsys, int index, struct ParticleKey *key, float time);
+
 void free_cached_child_paths(struct BakeableSystem *bsys);
 void DB_free_cached_paths(struct BakeableSystem *bsys);
 void DB_cache_paths(struct BakeableSystem *bsys, float time);
@@ -102,6 +106,7 @@
 struct ListBase *DB_get_all_autobake_systems();
 void DB_unified_bake_cb(void *arg1, void *arg2);
 void DB_single_bake_cb(void *bsys, void *arg2);
+void DB_single_bake_from_cfra_cb(void *bsys_v, void *arg2);
 void DB_unified_bake(struct ListBase *bakelist, int from_cfra, int autobake);
 
 struct BakeBase *DB_psys_to_BakeBase(struct Object *ob, struct ParticleSystem *psys);

Modified: branches/particles/source/blender/blenkernel/BKE_particle.h
===================================================================
--- branches/particles/source/blender/blenkernel/BKE_particle.h	2007-08-27 20:29:32 UTC (rev 11849)
+++ branches/particles/source/blender/blenkernel/BKE_particle.h	2007-08-27 21:15:50 UTC (rev 11850)
@@ -112,7 +112,7 @@
 
 struct ParticleSettings *psys_new_settings(char *name);
 struct ParticleSettings *psys_copy_settings(struct ParticleSettings *part);
-void psys_flush_settings(struct ParticleSettings *part, int event);
+void psys_flush_settings(struct ParticleSettings *part, int event, int autobake);
 
 void psys_find_parents(struct ParticleSystemModifierData *psmd, struct ParticleSystem *psys);
 

Modified: branches/particles/source/blender/blenkernel/intern/dynamics_bake.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/dynamics_bake.c	2007-08-27 20:29:32 UTC (rev 11849)
+++ branches/particles/source/blender/blenkernel/intern/dynamics_bake.c	2007-08-27 21:15:50 UTC (rev 11850)
@@ -47,6 +47,7 @@
 #include "mydevice.h"
 
 static void psys_end_baking(BakeableSystem *bsys);
+static void sb_save_key_from_dynamics(BakeableSystem *bsys, int index, float cfra, BakeKey *bkey, float *ckey_f);
 
 int modifier_effects_baked(Object *ob, ModifierData *mod)
 {
@@ -79,10 +80,13 @@
 int dynamicsbake_test()
 {
 	BakeBase *bbase = OBACT->bakeable.first;
+	BakeableSystem *bsys;
 	
 	for(; bbase; bbase=bbase->next){
-		if(bbase->bsys->flag & BSYS_DONE && (bbase->bsys->flag&BSYS_AUTOBAKE)==0){
-			error("Unable to complete action with dynamics baked.");
+		bsys=bbase->bsys;
+		if((bsys->flag & BSYS_DONE && (bsys->flag&BSYS_AUTOBAKE)==0)
+			|| bsys->flag & BSYS_HAS_START){
+			error("Unable to complete action with dynamics baked or starting point set.");
 			return 1;
 		}
 	}
@@ -136,7 +140,6 @@
 }
 void DB_copy_BakeableSystem(BakeableSystem *to, BakeableSystem *from)
 {
-	BakeableSystem *bsys;
 	BakeElement *nbel, *bel;
 	int i;
 
@@ -215,21 +218,37 @@
 }
 static void key_from_object(BakeableSystem *bsys, BakeKey *key, float *ckey){
 	Object *ob=bsys->ob;
-	float q[4];
 
-	VECADD(key->vel,key->vel,key->co);
-
 	Mat4MulVecfl(ob->obmat,key->co);
-	Mat4MulVecfl(ob->obmat,key->vel);
-	Mat4ToQuat(ob->obmat,q);
+	Mat4Mul3Vecfl(ob->obmat,key->vel);
 
-	VECSUB(key->vel,key->vel,key->co);
+	if(bsys->type==BAKEABLE_PARTICLE && ckey){
+		BakeKeyParticle *pkey = (BakeKeyParticle*)ckey;
+		float q[4];
+		
+		Mat4Mul3Vecfl(ob->obmat,pkey->ave);
+		
+		Mat4ToQuat(ob->obmat,q);
+		QuatMul(pkey->rot,q,pkey->rot);
+	}
+}
+static void key_to_object(BakeableSystem *bsys, BakeKey *key, float *ckey){
+	Object *ob=bsys->ob;
 
+	Mat4MulVecfl(ob->imat,key->co);
+	Mat4Mul3Vecfl(ob->imat,key->vel);
+
 	if(bsys->type==BAKEABLE_PARTICLE && ckey){
-		QuatMul(ckey+3,q,ckey+3);
+		BakeKeyParticle *pkey = (BakeKeyParticle*)ckey;
+		float q[4];
+
+		Mat4Mul3Vecfl(ob->imat,pkey->ave);
+
+		Mat4ToQuat(ob->imat,q);
+		QuatMul(pkey->rot,q,pkey->rot);
 	}
 }
-static void key_from_geometry(BakeableSystem *bsys, int v1, int v2, int v3, BakeKey *key, float *ckey)
+void key_from_geometry(BakeableSystem *bsys, int v1, int v2, int v3, BakeKey *key, float *ckey)
 {
 	float q[4], ve1[3], ve2[3], ve3[3];
 
@@ -254,6 +273,33 @@
 			QuatMul(ckey+3,q,ckey+3);
 	}
 }
+void key_to_geometry(BakeableSystem *bsys, int v1, int v2, int v3, BakeKey *key, float *ckey)
+{
+	float q[4], ve1[3], ve2[3], ve3[3];
+
+	if(bsys->type==BAKEABLE_PARTICLE){
+		DerivedMesh *dm=psys_get_modifier(bsys->ob,(ParticleSystem*)bsys->system)->dm;
+		dm->getVertCo(dm,v1,ve1);
+		dm->getVertCo(dm,v2,ve2);
+		dm->getVertCo(dm,v3,ve3);
+
+		triatoquat(ve1, ve2, ve3, q);
+		
+		QuatInv(q);
+		
+		VECSUB(key->co,key->co,ve1);
+
+		VECADD(key->vel,key->vel,key->co);
+
+		QuatMulVecf(q, key->co);
+		QuatMulVecf(q, key->vel);
+		
+		VECSUB(key->vel,key->vel,key->co);
+
+		if(ckey)
+			QuatMul(ckey+3,q,ckey+3);
+	}
+}
 void DB_key_to_global_space(BakeableSystem *bsys, short from_space, int index, BakeKey *key, float *ckey)
 {
 	if(from_space){
@@ -726,81 +772,53 @@
 float bsys_timestep_one(BakeableSystem *bsys){
 	return 1.0f;
 }
+/* check if more space is needed to hold the keys */
+static void check_key_space(BakeableSystem *bsys, BakeElement *bel){
+	BakeableAccess *bacc=access_BakeableSystem(bsys);
+	BakeKey *key;
+	float *ckey;
+	int csize=bacc->custom_size;
+
+	if(bel->totkey*sizeof(BakeKey)==MEM_allocN_len(bel->keys)){
+		key=bel->keys;
+		bel->keys=MEM_callocN((bel->totkey+5)*sizeof(BakeKey),"BakeKeys");
+		memcpy(bel->keys,key,bel->totkey*sizeof(BakeKey));
+		MEM_freeN(key);
+
+		if(csize){
+			ckey=bel->custom;
+			bel->custom=MEM_callocN((bel->totkey+5)*csize*sizeof(float),"BakeKeys custom data");
+			memcpy(bel->custom,ckey,bel->totkey*csize*sizeof(float));
+			MEM_freeN(ckey);
+		}
+	}
+}
 void DB_save_keys(BakeableSystem *bsys, float cfra){
 	BakeableAccess *bacc=access_BakeableSystem(bsys);
 	BakeElement *bel;
 	BakeKey *key;
 	float *cus;
 
-	int avg_keys=10;	/* estimated amount of keys needed */
+	//int avg_keys=10;	/* estimated amount of keys needed */
 	int totbel;
 	int csize=bacc->custom_size;
 	int i, need_key;
 
-	if(bacc->initialize_save_keys(bsys,&avg_keys)==0)
-		return;
+	bacc->initialize_save_keys(bsys);
 
+	if(bsys->totbel==0) return;
+
 	totbel=bsys->totbel;
-
-	if(bsys->elements==0)
-		bsys->elements=MEM_callocN(totbel*sizeof(BakeElement),"BakeElement array");
 	
 	/* save new keys for elements if needed */
 	for(i=0,bel=bsys->elements; i<totbel; i++,bel++){
-		if(bel->flag & BEL_DONE) continue;
+		if(bacc->key_needs_saving(bsys,i,cfra)){
+			check_key_space(bsys,bel);
 
-		need_key=BSYS_NO_KEY;
+			bacc->save_key_from_dynamics(bsys,i,cfra,bel->keys+bel->totkey,(csize?bel->custom+csize*(bel->totkey):0));
 
-		/* first time allocation */
-		if(bel->keys==0){
-			bel->keys=MEM_callocN(avg_keys*sizeof(BakeKey),"BakeKeys");
-			if(csize)
-				bel->custom=MEM_callocN(avg_keys*csize*sizeof(float),"BakeKeys");
-
-			bel->totkey=1;
-
-			need_key=BSYS_FIRST_KEY;
-		}
-		else
-			need_key=bacc->key_needs_saving(bsys,i,cfra);
-
-		if(need_key==BSYS_BAKE_KEY){
-			/* check if more space is needed to hold the keys */
-			if(bel->totkey*sizeof(BakeKey)==MEM_allocN_len(bel->keys)){
-				key=bel->keys;
-				bel->keys=MEM_callocN((bel->totkey+5)*sizeof(BakeKey),"BakeKeys");
-				memcpy(bel->keys,key,bel->totkey*sizeof(BakeKey));
-				MEM_freeN(key);
-
-				if(csize){
-					cus=bel->custom;
-					bel->custom=MEM_callocN((bel->totkey+5)*csize*sizeof(float),"BakeKeys custom data");
-					memcpy(bel->custom,cus,bel->totkey*csize*sizeof(float));
-					MEM_freeN(cus);
-				}
-			}
 			bel->totkey++;
 		}
-		else if(need_key==BSYS_LAST_KEY){
-			/* last key so cut out excess allocations */
-			key=bel->keys;
-			bel->keys=MEM_callocN((bel->totkey+1)*sizeof(BakeKey),"BakeKeys");
-			memcpy(bel->keys,key,bel->totkey*sizeof(BakeKey));
-			MEM_freeN(key);
-
-			if(csize){
-				cus=bel->custom;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list