[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33398] trunk/blender: Smoke now uses only one point cache where both normal and high resolution smoke are stored together :

Janne Karhu jhkarh at gmail.com
Tue Nov 30 22:31:22 CET 2010


Revision: 33398
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33398
Author:   jhk
Date:     2010-11-30 22:31:18 +0100 (Tue, 30 Nov 2010)

Log Message:
-----------
Smoke now uses only one point cache where both normal and high resolution smoke are stored together:
* Separate caches were causing quite a lot of problems both in principle and practice.
* For example it doesn't really make sense to have different frame ranges for normal and high resolution smoke, but this was fully possible before.
* Also to fully bake the smoke you had to do a "Bake All Dynamics", which completely defeats the whole point of the feature!
* As a result of this change the smoke cache usage is much much simpler and less error prone.
* This is quite a big change, but hopefully there should be less rather than more problems as a result :)

Some other related changes:
* Changing the cache name now works for disk caches properly too, it now just renames the cache files so should be faster too!
* Smoke is now always forced to disk cache with step 1 on file load as there were some strange cases where smoke was trying to use memory cache.
* Disabled smoke debug prints from console.
* Disabled changing smoke parameters when smoke is baked.

Note to users: The unfortunate side effect of this is that old high resolution simulations have to be baked again, but in return you get much better and more logical functionality. Sorry none the less!

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_physics_smoke.py
    trunk/blender/source/blender/blenkernel/BKE_pointcache.h
    trunk/blender/source/blender/blenkernel/intern/pointcache.c
    trunk/blender/source/blender/blenkernel/intern/smoke.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/makesdna/DNA_object_force.h
    trunk/blender/source/blender/makesdna/DNA_smoke_types.h
    trunk/blender/source/blender/makesrna/intern/rna_object_force.c
    trunk/blender/source/blender/makesrna/intern/rna_smoke.c

Modified: trunk/blender/release/scripts/ui/properties_physics_smoke.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_physics_smoke.py	2010-11-30 20:22:26 UTC (rev 33397)
+++ trunk/blender/release/scripts/ui/properties_physics_smoke.py	2010-11-30 21:31:18 UTC (rev 33398)
@@ -69,6 +69,8 @@
 
                 split = layout.split()
 
+                split.enabled = not domain.point_cache.is_baked
+
                 col = split.column()
                 col.label(text="Resolution:")
                 col.prop(domain, "resolution_max", text="Divisions")
@@ -146,27 +148,6 @@
         col.prop(group, "collision_group", text="")
 
 
-class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, bpy.types.Panel):
-    bl_label = "Smoke Cache"
-    bl_options = {'DEFAULT_CLOSED'}
-
-    @classmethod
-    def poll(cls, context):
-        md = context.smoke
-        return md and (md.smoke_type == 'DOMAIN')
-
-    def draw(self, context):
-        layout = self.layout
-
-        md = context.smoke.domain_settings
-        cache = md.point_cache_low
-
-        layout.label(text="Compression:")
-        layout.prop(md, "point_cache_compress_type", expand=True)
-
-        point_cache_ui(self, context, cache, (cache.is_baked is False), 'SMOKE')
-
-
 class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, bpy.types.Panel):
     bl_label = "Smoke High Resolution"
     bl_options = {'DEFAULT_CLOSED'}
@@ -179,6 +160,7 @@
     def draw_header(self, context):
         md = context.smoke.domain_settings
 
+        self.layout.enabled = not md.point_cache.is_baked
         self.layout.prop(md, "use_high_resolution", text="")
 
     def draw(self, context):
@@ -189,36 +171,38 @@
         layout.active = md.use_high_resolution
 
         split = layout.split()
+        split.enabled = not md.point_cache.is_baked
 
         col = split.column()
         col.label(text="Resolution:")
         col.prop(md, "amplify", text="Divisions")
         col.prop(md, "smooth_emitter")
-        col.prop(md, "show_high_resolution")
 
         col = split.column()
         col.label(text="Noise Method:")
         col.row().prop(md, "noise_type", text="")
         col.prop(md, "strength")
 
+        layout.prop(md, "show_high_resolution")
 
-class PHYSICS_PT_smoke_cache_highres(PhysicButtonsPanel, bpy.types.Panel):
-    bl_label = "Smoke High Resolution Cache"
+
+class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, bpy.types.Panel):
+    bl_label = "Smoke Cache"
     bl_options = {'DEFAULT_CLOSED'}
 
     @classmethod
     def poll(cls, context):
         md = context.smoke
-        return md and (md.smoke_type == 'DOMAIN') and md.domain_settings.use_high_resolution
+        return md and (md.smoke_type == 'DOMAIN')
 
     def draw(self, context):
         layout = self.layout
 
         md = context.smoke.domain_settings
-        cache = md.point_cache_high
+        cache = md.point_cache
 
         layout.label(text="Compression:")
-        layout.prop(md, "point_cache_compress_high_type", expand=True)
+        layout.prop(md, "point_cache_compress_type", expand=True)
 
         point_cache_ui(self, context, cache, (cache.is_baked is False), 'SMOKE')
 

Modified: trunk/blender/source/blender/blenkernel/BKE_pointcache.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_pointcache.h	2010-11-30 20:22:26 UTC (rev 33397)
+++ trunk/blender/source/blender/blenkernel/BKE_pointcache.h	2010-11-30 21:31:18 UTC (rev 33398)
@@ -32,6 +32,7 @@
 #include "DNA_ID.h"
 #include "DNA_object_force.h"
 #include "DNA_boid_types.h"
+#include <stdio.h> /* for FILE */
 
 /* Point cache clearing option, for BKE_ptcache_id_clear, before
  * and after are non inclusive (they wont remove the cfra) */
@@ -234,7 +235,6 @@
 void BKE_ptcache_id_from_particles(PTCacheID *pid, struct Object *ob, struct ParticleSystem *psys);
 void BKE_ptcache_id_from_cloth(PTCacheID *pid, struct Object *ob, struct ClothModifierData *clmd);
 void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd);
-void BKE_ptcache_id_from_smoke_turbulence(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd);
 
 void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob, struct Scene *scene, int duplis);
 
@@ -300,6 +300,9 @@
 /* Convert disk cache to memory cache and vice versa. Clears the cache that was converted. */
 void BKE_ptcache_toggle_disk_cache(struct PTCacheID *pid);
 
+/* Rename all disk cache files with a new name. Doesn't touch the actual content of the files. */
+void BKE_ptcache_disk_cache_rename(struct PTCacheID *pid, char *from, char *to);
+
 /* Loads simulation from external (disk) cache files. */
 void BKE_ptcache_load_external(struct PTCacheID *pid);
 

Modified: trunk/blender/source/blender/blenkernel/intern/pointcache.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/pointcache.c	2010-11-30 20:22:26 UTC (rev 33397)
+++ trunk/blender/source/blender/blenkernel/intern/pointcache.c	2010-11-30 21:31:18 UTC (rev 33398)
@@ -725,6 +725,7 @@
 {	
 	SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
 	SmokeDomainSettings *sds = smd->domain;
+	int ret = 0;
 	
 	if(sds->fluid) {
 		size_t res = sds->res[0]*sds->res[1]*sds->res[2];
@@ -755,16 +756,9 @@
 
 		MEM_freeN(out);
 		
-		return 1;
+		ret = 1;
 	}
-	return 0;
-}
 
-static int ptcache_write_smoke_turbulence(PTCacheFile *pf, void *smoke_v)
-{
-	SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
-	SmokeDomainSettings *sds = smd->domain;
-	
 	if(sds->wt) {
 		int res_big_array[3];
 		int res_big;
@@ -796,11 +790,13 @@
 		ptcache_compress_write(pf, (unsigned char *)tcw, in_len, out, mode);
 		MEM_freeN(out);
 		
-		return 1;
+		ret = 1;
 	}
-	return 0;
+
+	return ret;
 }
 
+
 // forward decleration
 static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, int size);
 
@@ -877,33 +873,27 @@
 		ptcache_compress_read(pf, (unsigned char*)obstacles, (unsigned int)res);
 		ptcache_file_read(pf, &dt, 1, sizeof(float));
 		ptcache_file_read(pf, &dx, 1, sizeof(float));
-	}
-}
 
-static void ptcache_read_smoke_turbulence(PTCacheFile *pf, void *smoke_v)
-{
-	SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
-	SmokeDomainSettings *sds = smd->domain;
-	
-	if(sds->fluid) {
-		int res = sds->res[0]*sds->res[1]*sds->res[2];
-		int res_big, res_big_array[3];
-		float *dens, *densold, *tcu, *tcv, *tcw;
-		unsigned int out_len = sizeof(float)*(unsigned int)res;
-		unsigned int out_len_big;
+		if(pf->data_types & (1<<BPHYS_DATA_SMOKE_HIGH) && sds->wt) {
+			int res = sds->res[0]*sds->res[1]*sds->res[2];
+			int res_big, res_big_array[3];
+			float *dens, *densold, *tcu, *tcv, *tcw;
+			unsigned int out_len = sizeof(float)*(unsigned int)res;
+			unsigned int out_len_big;
 
-		smoke_turbulence_get_res(sds->wt, res_big_array);
-		res_big = res_big_array[0]*res_big_array[1]*res_big_array[2];
-		out_len_big = sizeof(float) * (unsigned int)res_big;
+			smoke_turbulence_get_res(sds->wt, res_big_array);
+			res_big = res_big_array[0]*res_big_array[1]*res_big_array[2];
+			out_len_big = sizeof(float) * (unsigned int)res_big;
 
-		smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw);
+			smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw);
 
-		ptcache_compress_read(pf, (unsigned char*)dens, out_len_big);
-		ptcache_compress_read(pf, (unsigned char*)densold, out_len_big);
+			ptcache_compress_read(pf, (unsigned char*)dens, out_len_big);
+			ptcache_compress_read(pf, (unsigned char*)densold, out_len_big);
 
-		ptcache_compress_read(pf, (unsigned char*)tcu, out_len);
-		ptcache_compress_read(pf, (unsigned char*)tcv, out_len);
-		ptcache_compress_read(pf, (unsigned char*)tcw, out_len);		
+			ptcache_compress_read(pf, (unsigned char*)tcu, out_len);
+			ptcache_compress_read(pf, (unsigned char*)tcv, out_len);
+			ptcache_compress_read(pf, (unsigned char*)tcw, out_len);
+		}
 	}
 }
 
@@ -936,41 +926,13 @@
 	pid->write_header= ptcache_write_basic_header;
 	pid->read_header= ptcache_read_basic_header;
 
-	pid->data_types= (1<<BPHYS_DATA_LOCATION); // bogus values to make pointcache happy
+	pid->data_types= 0;
 	pid->info_types= 0;
-}
 
-void BKE_ptcache_id_from_smoke_turbulence(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd)
-{
-	SmokeDomainSettings *sds = smd->domain;
-
-	memset(pid, 0, sizeof(PTCacheID));
-
-	pid->ob= ob;
-	pid->calldata= smd;
-	
-	pid->type= PTCACHE_TYPE_SMOKE_HIGHRES;
-	pid->stack_index= sds->point_cache[1]->index;
-
-	pid->cache= sds->point_cache[1];
-	pid->cache_ptr= &sds->point_cache[1];
-	pid->ptcaches= &sds->ptcaches[1];
-
-	pid->totpoint= pid->totwrite= ptcache_totpoint_smoke_turbulence;
-
-	pid->write_elem= NULL;
-	pid->read_elem= NULL;
-
-	pid->read_stream = ptcache_read_smoke_turbulence;
-	pid->write_stream = ptcache_write_smoke_turbulence;
-	
-	pid->interpolate_elem= NULL;
-
-	pid->write_header= ptcache_write_basic_header;
-	pid->read_header= ptcache_read_basic_header;
-
-	pid->data_types= (1<<BPHYS_DATA_LOCATION); // bogus values tot make pointcache happy
-	pid->info_types= 0;
+	if(sds->fluid)
+		pid->data_types |= (1<<BPHYS_DATA_SMOKE_LOW);
+	if(sds->wt)
+		pid->data_types |= (1<<BPHYS_DATA_SMOKE_HIGH);
 }
 
 void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *clmd)
@@ -1046,10 +1008,6 @@
 				pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
 				BKE_ptcache_id_from_smoke(pid, ob, (SmokeModifierData*)md);
 				BLI_addtail(lb, pid);
-
-				pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
-				BKE_ptcache_id_from_smoke_turbulence(pid, ob, (SmokeModifierData*)md);
-				BLI_addtail(lb, pid);
 			}
 		}
 	}
@@ -2289,9 +2247,6 @@
 			{
 				BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData*)md);
 				reset |= BKE_ptcache_id_reset(scene, &pid, mode);
-
-				BKE_ptcache_id_from_smoke_turbulence(&pid, ob, (SmokeModifierData*)md);
-				reset |= BKE_ptcache_id_reset(scene, &pid, mode);
 			}
 		}
 	}
@@ -2841,6 +2796,61 @@
 	BKE_ptcache_update_info(pid);
 }
 
+void BKE_ptcache_disk_cache_rename(PTCacheID *pid, char *from, char *to)
+{
+	char old_name[80];
+	int len; /* store the length of the string */
+	/* mode is same as fopen's modes */
+	DIR *dir; 
+	struct dirent *de;
+	char path[MAX_PTCACHE_PATH];
+	char old_filename[MAX_PTCACHE_FILE];
+	char new_path_full[MAX_PTCACHE_FILE];
+	char old_path_full[MAX_PTCACHE_FILE];
+	char ext[MAX_PTCACHE_PATH];
+

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list