[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33767] trunk/blender: Extreme makeover of pointcache code:
Janne Karhu
jhkarh at gmail.com
Sat Dec 18 16:03:31 CET 2010
Revision: 33767
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33767
Author: jhk
Date: 2010-12-18 16:03:31 +0100 (Sat, 18 Dec 2010)
Log Message:
-----------
Extreme makeover of pointcache code:
* Pointcache code was quite ugly looking and complicated, so here are mostly just cosmetic adjustments, but some improved logic also.
* Slight cleanup of pointcache ui too.
* Shouldn't have any functional changes what so ever, so poke me right away if something seems off.
Modified Paths:
--------------
trunk/blender/release/scripts/ui/properties_physics_common.py
trunk/blender/source/blender/blenkernel/BKE_pointcache.h
trunk/blender/source/blender/blenkernel/intern/cloth.c
trunk/blender/source/blender/blenkernel/intern/particle_system.c
trunk/blender/source/blender/blenkernel/intern/pointcache.c
trunk/blender/source/blender/blenkernel/intern/smoke.c
trunk/blender/source/blender/blenkernel/intern/softbody.c
trunk/blender/source/blender/editors/physics/particle_edit.c
trunk/blender/source/blender/editors/physics/physics_pointcache.c
trunk/blender/source/blender/render/intern/source/pipeline.c
Modified: trunk/blender/release/scripts/ui/properties_physics_common.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_physics_common.py 2010-12-18 11:49:12 UTC (rev 33766)
+++ trunk/blender/release/scripts/ui/properties_physics_common.py 2010-12-18 15:03:31 UTC (rev 33767)
@@ -56,31 +56,34 @@
layout.label(text="Cache is disabled until the file is saved")
layout.enabled = False
- layout.prop(cache, "name", text="File Name")
+ if cache.use_disk_cache:
+ layout.prop(cache, "name", text="File Name")
+ else:
+ layout.prop(cache, "name", text="Cache Name")
- split = layout.split()
- col = split.column(align=True)
+ row = layout.row(align=True)
if cachetype != 'PSYS':
- col.enabled = enabled
- col.prop(cache, "frame_start")
- col.prop(cache, "frame_end")
+ row.enabled = enabled
+ row.prop(cache, "frame_start")
+ row.prop(cache, "frame_end")
if cachetype not in ('SMOKE', 'CLOTH'):
- col.prop(cache, "frame_step")
+ row.prop(cache, "frame_step")
+ if cachetype != 'SMOKE':
+ layout.label(text=cache.info)
- col = split.column()
-
if cachetype != 'SMOKE':
- sub = col.column()
- sub.enabled = enabled
- sub.prop(cache, "use_quick_cache")
+ split = layout.split()
- sub = col.column()
- sub.enabled = (not bpy.data.is_dirty)
- sub.prop(cache, "use_disk_cache")
- col.label(text=cache.info)
+ col = split.column()
+ col.enabled = enabled
+ col.prop(cache, "use_quick_cache")
+ col = split.column()
+ col.enabled = (not bpy.data.is_dirty)
+ col.prop(cache, "use_disk_cache")
sub = col.column()
+ sub.enabled = cache.use_disk_cache
sub.prop(cache, "use_library_path", "Use Lib Path")
layout.separator()
Modified: trunk/blender/source/blender/blenkernel/BKE_pointcache.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_pointcache.h 2010-12-18 11:49:12 UTC (rev 33766)
+++ trunk/blender/source/blender/blenkernel/BKE_pointcache.h 2010-12-18 15:03:31 UTC (rev 33767)
@@ -95,7 +95,7 @@
typedef struct PTCacheFile {
FILE *fp;
- int totpoint, type;
+ int totpoint, type, frame, old_format;
unsigned int data_types;
struct PTCacheData data;
@@ -256,9 +256,9 @@
int BKE_ptcache_data_size(int data_type);
/* Memory cache read/write helpers. */
-void BKE_ptcache_mem_init_pointers(struct PTCacheMem *pm);
-void BKE_ptcache_mem_incr_pointers(struct PTCacheMem *pm);
-int BKE_ptcache_mem_seek_pointers(int point_index, struct PTCacheMem *pm);
+void BKE_ptcache_mem_pointers_init(struct PTCacheMem *pm);
+void BKE_ptcache_mem_pointers_incr(struct PTCacheMem *pm);
+int BKE_ptcache_mem_pointers_seek(int point_index, struct PTCacheMem *pm);
/* Copy a specific data type from cache data to point data. */
void BKE_ptcache_data_get(void **data, int type, int index, void *to);
@@ -267,10 +267,10 @@
void BKE_ptcache_data_set(void **data, int type, void *from);
/* Main cache reading call. */
-int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec);
+int BKE_ptcache_read(PTCacheID *pid, float cfra, float frs_sec);
/* Main cache writing call. */
-int BKE_ptcache_write_cache(PTCacheID *pid, int cfra);
+int BKE_ptcache_write(PTCacheID *pid, int cfra);
/****************** Continue physics ***************/
void BKE_ptcache_set_continue_physics(struct Main *bmain, struct Scene *scene, int enable);
@@ -289,7 +289,7 @@
void BKE_ptcache_quick_cache_all(struct Main *bmain, struct Scene *scene);
/* Bake cache or simulate to current frame with settings defined in the baker. */
-void BKE_ptcache_make_cache(struct PTCacheBaker* baker);
+void BKE_ptcache_bake(struct PTCacheBaker* baker);
/* Convert disk cache to memory cache. */
void BKE_ptcache_disk_to_mem(struct PTCacheID *pid);
Modified: trunk/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/cloth.c 2010-12-18 11:49:12 UTC (rev 33766)
+++ trunk/blender/source/blender/blenkernel/intern/cloth.c 2010-12-18 15:03:31 UTC (rev 33767)
@@ -504,7 +504,7 @@
}
/* try to read from cache */
- cache_result = BKE_ptcache_read_cache(&pid, (float)framenr+scene->r.subframe, scene->r.frs_sec);
+ cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe, scene->r.frs_sec);
if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) {
implicit_set_positions(clmd);
@@ -513,7 +513,7 @@
BKE_ptcache_validate(cache, framenr);
if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
- BKE_ptcache_write_cache(&pid, framenr);
+ BKE_ptcache_write(&pid, framenr);
return result;
}
@@ -528,7 +528,7 @@
/* if on second frame, write cache for first frame */
if(cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
- BKE_ptcache_write_cache(&pid, startframe);
+ BKE_ptcache_write(&pid, startframe);
clmd->sim_parms->timescale *= framenr - cache->simframe;
@@ -539,7 +539,7 @@
BKE_ptcache_invalidate(cache);
}
else
- BKE_ptcache_write_cache(&pid, framenr);
+ BKE_ptcache_write(&pid, framenr);
cloth_to_object (ob, clmd, result);
Modified: trunk/blender/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle_system.c 2010-12-18 11:49:12 UTC (rev 33766)
+++ trunk/blender/source/blender/blenkernel/intern/particle_system.c 2010-12-18 15:03:31 UTC (rev 33767)
@@ -3793,7 +3793,7 @@
/* 2. try to read from the cache */
if(pid) {
- int cache_result = BKE_ptcache_read_cache(pid, cache_cfra, sim->scene->r.frs_sec);
+ int cache_result = BKE_ptcache_read(pid, cache_cfra, sim->scene->r.frs_sec);
if(ELEM(cache_result, PTCACHE_READ_EXACT, PTCACHE_READ_INTERPOLATED)) {
cached_step(sim, cfra);
@@ -3803,7 +3803,7 @@
BKE_ptcache_validate(cache, (int)cache_cfra);
if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
- BKE_ptcache_write_cache(pid, (int)cache_cfra);
+ BKE_ptcache_write(pid, (int)cache_cfra);
return;
}
@@ -3818,7 +3818,7 @@
/* if on second frame, write cache for first frame */
if(psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
- BKE_ptcache_write_cache(pid, startframe);
+ BKE_ptcache_write(pid, startframe);
}
else
BKE_ptcache_invalidate(cache);
@@ -3859,7 +3859,7 @@
if(pid) {
BKE_ptcache_validate(cache, (int)cache_cfra);
if((int)cache_cfra != startframe)
- BKE_ptcache_write_cache(pid, (int)cache_cfra);
+ BKE_ptcache_write(pid, (int)cache_cfra);
}
update_children(sim);
Modified: trunk/blender/source/blender/blenkernel/intern/pointcache.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/pointcache.c 2010-12-18 11:49:12 UTC (rev 33766)
+++ trunk/blender/source/blender/blenkernel/intern/pointcache.c 2010-12-18 15:03:31 UTC (rev 33767)
@@ -106,8 +106,12 @@
sizeof(BoidData) // case BPHYS_DATA_BOIDS:
};
+/* forward declerations */
+static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size);
+static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, int size);
+
/* Common functions */
-static int ptcache_read_basic_header(PTCacheFile *pf)
+static int ptcache_basic_header_read(PTCacheFile *pf)
{
int error=0;
@@ -120,7 +124,7 @@
return !error;
}
-static int ptcache_write_basic_header(PTCacheFile *pf)
+static int ptcache_basic_header_write(PTCacheFile *pf)
{
/* Custom functions should write these basic elements too! */
if(!fwrite(&pf->totpoint, sizeof(int), 1, pf->fp))
@@ -132,7 +136,7 @@
return 1;
}
/* Softbody functions */
-static int ptcache_write_softbody(int index, void *soft_v, void **data, int UNUSED(cfra))
+static int ptcache_softbody_write(int index, void *soft_v, void **data, int UNUSED(cfra))
{
SoftBody *soft= soft_v;
BodyPoint *bp = soft->bpoint + index;
@@ -142,7 +146,7 @@
return 1;
}
-static void ptcache_read_softbody(int index, void *soft_v, void **data, float UNUSED(frs_sec), float UNUSED(cfra), float *old_data)
+static void ptcache_softbody_read(int index, void *soft_v, void **data, float UNUSED(frs_sec), float UNUSED(cfra), float *old_data)
{
SoftBody *soft= soft_v;
BodyPoint *bp = soft->bpoint + index;
@@ -156,7 +160,7 @@
PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, 0, bp->vec);
}
}
-static void ptcache_interpolate_softbody(int index, void *soft_v, void **data, float UNUSED(frs_sec), float cfra, float cfra1, float cfra2, float *old_data)
+static void ptcache_softbody_interpolate(int index, void *soft_v, void **data, float UNUSED(frs_sec), float cfra, float cfra1, float cfra2, float *old_data)
{
SoftBody *soft= soft_v;
BodyPoint *bp = soft->bpoint + index;
@@ -188,14 +192,30 @@
VECCOPY(bp->pos, keys->co);
VECCOPY(bp->vec, keys->vel);
}
-static int ptcache_totpoint_softbody(void *soft_v, int UNUSED(cfra))
+static int ptcache_softbody_totpoint(void *soft_v, int UNUSED(cfra))
{
SoftBody *soft= soft_v;
return soft->totpoint;
}
/* Particle functions */
-static int ptcache_write_particle(int index, void *psys_v, void **data, int cfra)
+void BKE_ptcache_make_particle_key(ParticleKey *key, int index, void **data, float time)
{
+ PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, index, key->co);
+ PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, index, key->vel);
+
+ /* no rotation info, so make something nice up */
+ if(data[BPHYS_DATA_ROTATION]==NULL) {
+ vec_to_quat( key->rot, key->vel, OB_NEGX, OB_POSZ);
+ }
+ else {
+ PTCACHE_DATA_TO(data, BPHYS_DATA_ROTATION, index, key->rot);
+ }
+
+ PTCACHE_DATA_TO(data, BPHYS_DATA_AVELOCITY, index, key->ave);
+ key->time = time;
+}
+static int ptcache_particle_write(int index, void *psys_v, void **data, int cfra)
+{
ParticleSystem *psys= psys_v;
ParticleData *pa = psys->particles + index;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list