Revision: 22396
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22396
Author:   jhk
Date:     2009-08-12 11:54:29 +0200 (Wed, 12 Aug 2009)

Log Message:
-----------
New point cache file format:
- HEADER (beginning of each file)
        * general header:
                + 8 char: "BPHYSICS"
                + 1 int: simulation type (same as PTCacheID->type)
        * custom header (same for sb, particles and cloth, but can be different 
for new dynamics)
                + 1 int: totpoint (number of points)
                + 1 int: data_types (bit flags for what the stored data is)
- DATA (directly after header)
        *totpoint times the data as specified in data_types flags

- simulation type
        soft body = 0, particles = 1, cloth = 2
- data types (more can be added easily when needed)
        data            flag            contains
        ----------------------------------------
        index           (1<<0)          1 int   (index of current point)
        location        (1<<1)          3 float
        velocity        (1<<2)          3 float
        rotation        (1<<3)          4 float (quaternion)
        avelocity       (1<<4)          3 float (used for particles)
        xconst          (1<<4)          3 float (used for cloth)
        size            (1<<5)          1 float
        times           (1<<6)          3 float (birth, die & lifetime of 
particle)
        boids           (1<<7)          1 BoidData
        
Notes:
- Every frame is not nescessary since data is interpolated for the inbetween 
frames.
- For now every point is needed for every cached frame, the "index" data type 
is reserved for future usage.
- For loading external particle caches only "location" data is necessary, other 
needed values are determined from the given data.
- Non-dynamic data should be written into an info file if external usage is 
desired.
        * Info file is named as normal cache files, but with frame number 0;
        * "Non-dynamic" means data such as particle times.
        * Written automatically when baking to disk so basically a library of 
particle simulations should be possible.
- Old disk cache format is supported for reading, so pre 2.5 files shouldn't 
break. However old style memory cache (added during 2.5 development) is not 
supported. To keep memory cached simulations convert the cache to disk cache 
before svn update and save the blend.
- External sb and cloth caches should be perfectly possible, but due to lack of 
testing these are not yet enabled in ui.
        
Other changes:
- Multiple point caches per dynamics system.
        * In the future these will hopefully be nla editable etc, but for now 
things are simple and the current (selected) point cache is used.
        * Changing the amount of cached points (for example particle count) is 
allowed, but might not give correct results if multiple caches are present.
- Generalization of point cache baking etc operator & rna code.
- Comb brushing particle hair didn't work smoothly.

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/buttons_particle.py
    branches/blender2.5/blender/release/ui/buttons_physics_cloth.py
    branches/blender2.5/blender/release/ui/buttons_physics_softbody.py
    branches/blender2.5/blender/source/blender/blenkernel/BKE_cloth.h
    branches/blender2.5/blender/source/blender/blenkernel/BKE_pointcache.h
    branches/blender2.5/blender/source/blender/blenkernel/BKE_softbody.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/cloth.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/modifier.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/particle.c
    
branches/blender2.5/blender/source/blender/blenkernel/intern/particle_system.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/pointcache.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/softbody.c
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c
    branches/blender2.5/blender/source/blender/editors/mesh/editmesh.c
    branches/blender2.5/blender/source/blender/editors/physics/ed_pointcache.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_modifier_types.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_object_force.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_particle_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_fluidsim.c
    
branches/blender2.5/blender/source/blender/makesrna/intern/rna_object_force.c

Modified: branches/blender2.5/blender/release/ui/buttons_particle.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_particle.py  2009-08-12 
08:16:10 UTC (rev 22395)
+++ branches/blender2.5/blender/release/ui/buttons_particle.py  2009-08-12 
09:54:29 UTC (rev 22396)
@@ -151,8 +151,15 @@
                psys = context.particle_system
                part = psys.settings
                cache = psys.point_cache
+               layout.set_context_pointer("PointCache", cache)
                
                row = layout.row()
+               row.template_list(cache, "point_cache_list", cache, 
"active_point_cache_index")
+               col = row.column(align=True)
+               col.itemO("ptcache.add_new", icon="ICON_ZOOMIN", text="")
+               col.itemO("ptcache.remove", icon="ICON_ZOOMOUT", text="")
+               
+               row = layout.row()
                row.itemL(text="File Name:")
                row.itemR(cache, "external")
                
@@ -166,37 +173,38 @@
                        
                        layout.itemL(text=cache.info)
                        
-                       split = layout.split()
+                       #split = layout.split()
                        
-                       col = split.column(align=True)
-                       col.itemR(part, "start")
-                       col.itemR(part, "end")
+                       #col = split.column(align=True)
+                       #col.itemR(part, "start")
+                       #col.itemR(part, "end")
 
-                       col = split.column(align=True)
-                       col.itemR(part, "lifetime")
-                       col.itemR(part, "random_lifetime", slider=True)
+                       #col = split.column(align=True)
+                       #col.itemR(part, "lifetime")
+                       #col.itemR(part, "random_lifetime", slider=True)
                else:
                        layout.itemR(cache, "name", text="")
                        
                        row = layout.row()
                
                        if cache.baked == True:
-                               row.itemO("ptcache.free_bake_particle_system", 
text="Free Bake")
+                               row.itemO("ptcache.free_bake", text="Free Bake")
                        else:
-                               
row.item_booleanO("ptcache.cache_particle_system", "bake", True, text="Bake")
+                               row.item_booleanO("ptcache.bake", "bake", True, 
text="Bake")
                
                        subrow = row.row()
                        subrow.enabled = (cache.frames_skipped or 
cache.outdated) and particle_panel_enabled(psys)
-                       subrow.itemO("ptcache.cache_particle_system", 
text="Calculate to Current Frame")
+                       subrow.itemO("ptcache.bake", "bake", False, 
text="Calculate to Current Frame")
                        
                        row = layout.row()
                        row.enabled = particle_panel_enabled(psys)
-                       row.itemO("ptcache.bake_from_particles_cache", 
text="Current Cache to Bake")
+                       row.itemO("ptcache.bake_from_cache", text="Current 
Cache to Bake")
                        row.itemR(cache, "step");
                
                        row = layout.row()
-                       row.enabled = particle_panel_enabled(psys)
-                       row.itemR(cache, "quick_cache")
+                       subrow = row.row()
+                       subrow.enabled = particle_panel_enabled(psys)
+                       subrow.itemR(cache, "quick_cache")
                        row.itemR(cache, "disk_cache")
                
                        layout.itemL(text=cache.info)
@@ -206,7 +214,7 @@
                        row = layout.row()
                        row.item_booleanO("ptcache.bake_all", "bake", True, 
text="Bake All Dynamics")
                        row.itemO("ptcache.free_bake_all", text="Free All 
Bakes")
-                       layout.itemO("ptcache.bake_all", text="Update All 
Dynamics to current frame")
+                       layout.itemO("ptcache.bake_all", "bake", False, 
text="Update All Dynamics to current frame")
                
                # for particles these are figured out automatically
                #row.itemR(cache, "start_frame")

Modified: branches/blender2.5/blender/release/ui/buttons_physics_cloth.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_physics_cloth.py     
2009-08-12 08:16:10 UTC (rev 22395)
+++ branches/blender2.5/blender/release/ui/buttons_physics_cloth.py     
2009-08-12 09:54:29 UTC (rev 22396)
@@ -85,8 +85,15 @@
                layout = self.layout
 
                cache = context.cloth.point_cache
+               layout.set_context_pointer("PointCache", cache)
                
                row = layout.row()
+               row.template_list(cache, "point_cache_list", cache, 
"active_point_cache_index")
+               col = row.column(align=True)
+               col.itemO("ptcache.add_new", icon="ICON_ZOOMIN", text="")
+               col.itemO("ptcache.remove", icon="ICON_ZOOMOUT", text="")
+               
+               row = layout.row()
                row.itemR(cache, "name")
                
                row = layout.row()
@@ -96,17 +103,17 @@
                row = layout.row()
                
                if cache.baked == True:
-                       row.itemO("ptcache.free_bake_cloth", text="Free Bake")
+                       row.itemO("ptcache.free_bake", text="Free Bake")
                else:
-                       row.item_booleanO("ptcache.cache_cloth", "bake", True, 
text="Bake")
+                       row.item_booleanO("ptcache.bake", "bake", True, 
text="Bake")
                
                subrow = row.row()
                subrow.enabled = cache.frames_skipped or cache.outdated
-               subrow.itemO("ptcache.cache_cloth", text="Calculate to Current 
Frame")
+               subrow.itemO("ptcache.bake", "bake", False, text="Calculate to 
Current Frame")
                        
                row = layout.row()
                #row.enabled = particle_panel_enabled(psys)
-               row.itemO("ptcache.bake_from_cloth_cache", text="Current Cache 
to Bake")
+               row.itemO("ptcache.bake_from_cache", text="Current Cache to 
Bake")
                row.itemR(cache, "step");
        
                row = layout.row()
@@ -121,7 +128,7 @@
                row = layout.row()
                row.itemO("ptcache.bake_all", "bake", True, text="Bake All 
Dynamics")
                row.itemO("ptcache.free_bake_all", text="Free All Bakes")
-               layout.itemO("ptcache.bake_all", text="Update All Dynamics to 
current frame")
+               layout.itemO("ptcache.bake_all", "bake", False, text="Update 
All Dynamics to current frame")
                
 class PHYSICS_PT_cloth_collision(PhysicButtonsPanel):
        __label__ = "Cloth Collision"

Modified: branches/blender2.5/blender/release/ui/buttons_physics_softbody.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_physics_softbody.py  
2009-08-12 08:16:10 UTC (rev 22395)
+++ branches/blender2.5/blender/release/ui/buttons_physics_softbody.py  
2009-08-12 09:54:29 UTC (rev 22396)
@@ -63,8 +63,15 @@
                layout = self.layout
 
                cache = context.soft_body.point_cache
+               layout.set_context_pointer("PointCache", cache)
                
                row = layout.row()
+               row.template_list(cache, "point_cache_list", cache, 
"active_point_cache_index")
+               col = row.column(align=True)
+               col.itemO("ptcache.add_new", icon="ICON_ZOOMIN", text="")
+               col.itemO("ptcache.remove", icon="ICON_ZOOMOUT", text="")
+               
+               row = layout.row()
                row.itemR(cache, "name")
                
                row = layout.row()
@@ -74,16 +81,16 @@
                row = layout.row()
                
                if cache.baked == True:
-                       row.itemO("ptcache.free_bake_softbody", text="Free 
Bake")
+                       row.itemO("ptcache.free_bake", text="Free Bake")
                else:
-                       row.item_booleanO("ptcache.cache_softbody", "bake", 
True, text="Bake")
+                       row.item_booleanO("ptcache.bake", "bake", True, 
text="Bake")
                
                sub = row.row()
                sub.enabled = cache.frames_skipped or cache.outdated
-               sub.itemO("ptcache.cache_softbody", text="Calculate to Current 
Frame")
+               sub.itemO("ptcache.bake", "bake", False, text="Calculate to 
Current Frame")
                        
                row = layout.row()
-               row.itemO("ptcache.bake_from_softbody_cache", text="Current 
Cache to Bake")
+               row.itemO("ptcache.bake_from_cache", text="Current Cache to 
Bake")
                row.itemR(cache, "step");
        
                row = layout.row()
@@ -97,7 +104,7 @@
                row = layout.row()
                row.itemO("ptcache.bake_all", "bake", True, text="Bake All 
Dynamics")
                row.itemO("ptcache.free_bake_all", text="Free All Bakes")
-               layout.itemO("ptcache.bake_all", text="Update All Dynamics to 
current frame")
+               layout.itemO("ptcache.bake_all", "bake", False, text="Update 
All Dynamics to current frame")
                
 class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
        __label__ = "Soft Body Goal"

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_cloth.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_cloth.h   
2009-08-12 08:16:10 UTC (rev 22395)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_cloth.h   
2009-08-12 09:54:29 UTC (rev 22396)
@@ -244,10 +244,6 @@
 void bvhtree_update_from_cloth ( ClothModifierData *clmd, int moving );
 void bvhselftree_update_from_cloth ( ClothModifierData *clmd, int moving );
 
-// needed for editmesh.c
-void cloth_write_cache( Object *ob, ClothModifierData *clmd, int framenr );
-int cloth_read_cache( Scene *scene, Object *ob, ClothModifierData *clmd, float 
framenr, int *old_framenr );
-
 // needed for button_object.c
 void cloth_clear_cache ( Object *ob, ClothModifierData *clmd, float framenr );
 

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_pointcache.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_pointcache.h      
2009-08-12 08:16:10 UTC (rev 22395)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_pointcache.h      
2009-08-12 09:54:29 UTC (rev 22396)
@@ -30,6 +30,8 @@
 #define BKE_POINTCACHE_H
 
 #include "DNA_ID.h"
+#include "DNA_object_force.h"
+#include "DNA_boid_types.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -73,43 +75,53 @@
 struct PointCache;
 struct ListBase;
 
+/* temp structure for read/write */
+typedef struct PTCacheData {
+       int index;
+       float loc[3];
+       float vel[3];
+       float rot[4];
+       float ave[3];
+       float size;
+       float times[3];
+       struct BoidData boids;
+} PTCacheData;
+
 typedef struct PTCacheFile {
        FILE *fp;
+
+       int totpoint, type;
+       unsigned int data_types;
+
+       struct PTCacheData data;
+       void *cur[BPHYS_TOT_DATA];
 } PTCacheFile;
 
 typedef struct PTCacheID {
        struct PTCacheID *next, *prev;
 
+       struct Scene *scene;
        struct Object *ob;
-       void *data;
+       void *calldata;
        int type;
        int stack_index;
+       unsigned int data_types, info_types;
 
-       struct PointCache *cache;
-} PTCacheID;
+       int (*write_elem)(int index, void *calldata, void **data);
+       void (*read_elem)(int index, void *calldata, void **data, float 
frs_sec, float cfra, float *old_data);
+       void (*interpolate_elem)(int index, void *calldata, void **data, float 
frs_sec, float cfra, float cfra1, float cfra2, float *old_data);
 
-typedef struct PTCacheWriter {
-       struct PTCacheID *pid;
-       int cfra;
-       int totelem;
+       int (*totpoint)(void *calldata);
+       int (*totwrite)(void *calldata);
 
-       void (*set_elem)(int index, void *calldata, float *data);
-       void *calldata;
-} PTCacheWriter;
+       int (*write_header)(PTCacheFile *pf);
+       int (*read_header)(PTCacheFile *pf);
 
-typedef struct PTCacheReader {
-       struct Scene *scene;
-       struct PTCacheID *pid;
-       float cfra;
-       int totelem;
+       struct PointCache *cache;
+       struct PointCache **cache_ptr;
+       struct ListBase *ptcaches;
+} PTCacheID;
 
-       void (*set_elem)(int elem_index, void *calldata, float *data);
-       void (*interpolate_elem)(int index, void *calldata, float frs_sec, 
float cfra, float cfra1, float cfra2, float *data1, float *data2);
-       void *calldata;
-
-       int *old_frame;
-} PTCacheReader;
-

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to