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.
This commit is contained in:
parent
a934116298
commit
b58dbbd51b
@ -56,31 +56,34 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
|
||||
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")
|
||||
|
||||
col = split.column()
|
||||
row.prop(cache, "frame_step")
|
||||
if cachetype != 'SMOKE':
|
||||
layout.label(text=cache.info)
|
||||
|
||||
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()
|
||||
|
@ -95,7 +95,7 @@ typedef struct PTCacheData {
|
||||
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 @@ void BKE_ptcache_update_info(PTCacheID *pid);
|
||||
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_get(void **data, int type, int index, void *to);
|
||||
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 @@ struct PointCache *BKE_ptcache_copy_list(struct ListBase *ptcaches_new, struct L
|
||||
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);
|
||||
|
@ -504,7 +504,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
|
||||
}
|
||||
|
||||
/* 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 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
|
||||
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 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
|
||||
|
||||
/* 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 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
|
||||
BKE_ptcache_invalidate(cache);
|
||||
}
|
||||
else
|
||||
BKE_ptcache_write_cache(&pid, framenr);
|
||||
BKE_ptcache_write(&pid, framenr);
|
||||
|
||||
cloth_to_object (ob, clmd, result);
|
||||
|
||||
|
@ -3793,7 +3793,7 @@ static void system_step(ParticleSimulationData *sim, float cfra)
|
||||
|
||||
/* 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 @@ static void system_step(ParticleSimulationData *sim, float cfra)
|
||||
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 @@ static void system_step(ParticleSimulationData *sim, float cfra)
|
||||
|
||||
/* 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 @@ static void system_step(ParticleSimulationData *sim, float cfra)
|
||||
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);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1376,7 +1376,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
|
||||
}
|
||||
|
||||
/* try to read from cache */
|
||||
if(BKE_ptcache_read_cache(&pid, (float)framenr, scene->r.frs_sec) == PTCACHE_READ_EXACT) {
|
||||
if(BKE_ptcache_read(&pid, (float)framenr, scene->r.frs_sec) == PTCACHE_READ_EXACT) {
|
||||
BKE_ptcache_validate(cache, framenr);
|
||||
smd->time = framenr;
|
||||
return;
|
||||
@ -1407,7 +1407,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
|
||||
smoke_turbulence_step(sds->wt, sds->fluid);
|
||||
}
|
||||
|
||||
BKE_ptcache_write_cache(&pid, startframe);
|
||||
BKE_ptcache_write(&pid, startframe);
|
||||
}
|
||||
|
||||
// set new time
|
||||
@ -1439,7 +1439,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
|
||||
|
||||
BKE_ptcache_validate(cache, framenr);
|
||||
if(framenr != startframe)
|
||||
BKE_ptcache_write_cache(&pid, framenr);
|
||||
BKE_ptcache_write(&pid, framenr);
|
||||
|
||||
tend();
|
||||
//printf ( "Frame: %d, Time: %f\n", (int)smd->time, ( float ) tval() );
|
||||
|
@ -4134,7 +4134,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
|
||||
}
|
||||
|
||||
/* try to read from cache */
|
||||
cache_result = BKE_ptcache_read_cache(&pid, framenr, scene->r.frs_sec);
|
||||
cache_result = BKE_ptcache_read(&pid, framenr, scene->r.frs_sec);
|
||||
|
||||
if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) {
|
||||
softbody_to_object(ob, vertexCos, numVerts, sb->local);
|
||||
@ -4142,7 +4142,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
|
||||
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;
|
||||
}
|
||||
@ -4157,7 +4157,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
|
||||
|
||||
/* 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);
|
||||
|
||||
softbody_update_positions(ob, sb, vertexCos, numVerts);
|
||||
|
||||
@ -4170,6 +4170,6 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
|
||||
softbody_to_object(ob, vertexCos, numVerts, 0);
|
||||
|
||||
BKE_ptcache_validate(cache, framenr);
|
||||
BKE_ptcache_write_cache(&pid, framenr);
|
||||
BKE_ptcache_write(&pid, framenr);
|
||||
}
|
||||
|
||||
|
@ -3797,7 +3797,7 @@ static void get_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo)
|
||||
|
||||
pm->index_array = MEM_dupallocN(pm->index_array);
|
||||
|
||||
BKE_ptcache_mem_init_pointers(pm);
|
||||
BKE_ptcache_mem_pointers_init(pm);
|
||||
|
||||
LOOP_POINTS {
|
||||
LOOP_KEYS {
|
||||
@ -3808,7 +3808,7 @@ static void get_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo)
|
||||
key->time = &key->ftime;
|
||||
}
|
||||
}
|
||||
BKE_ptcache_mem_incr_pointers(pm);
|
||||
BKE_ptcache_mem_pointers_incr(pm);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4061,13 +4061,13 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache,
|
||||
totframe++;
|
||||
|
||||
for(pm=cache->mem_cache.first; pm; pm=pm->next) {
|
||||
BKE_ptcache_mem_init_pointers(pm);
|
||||
BKE_ptcache_mem_pointers_init(pm);
|
||||
|
||||
LOOP_POINTS {
|
||||
if(psys) {
|
||||
if(pm->index_array) {
|
||||
if(pm->index_array[p])
|
||||
BKE_ptcache_mem_seek_pointers(p, pm);
|
||||
BKE_ptcache_mem_pointers_seek(p, pm);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
@ -4075,7 +4075,7 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache,
|
||||
pa = psys->particles + p;
|
||||
if((pm->next && pm->next->frame < pa->time)
|
||||
|| (pm->prev && pm->prev->frame >= pa->dietime)) {
|
||||
BKE_ptcache_mem_incr_pointers(pm);
|
||||
BKE_ptcache_mem_pointers_incr(pm);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -4093,7 +4093,7 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache,
|
||||
key->rot = pm->cur[BPHYS_DATA_ROTATION];
|
||||
key->ftime = (float)pm->frame;
|
||||
key->time = &key->ftime;
|
||||
BKE_ptcache_mem_incr_pointers(pm);
|
||||
BKE_ptcache_mem_pointers_incr(pm);
|
||||
|
||||
point->totkey++;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ static int ptcache_bake_all_exec(bContext *C, wmOperator *op)
|
||||
baker.progresscontext = NULL;
|
||||
}
|
||||
|
||||
BKE_ptcache_make_cache(&baker);
|
||||
BKE_ptcache_bake(&baker);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, NULL);
|
||||
@ -218,7 +218,7 @@ static int ptcache_bake_exec(bContext *C, wmOperator *op)
|
||||
baker.progresscontext = NULL;
|
||||
}
|
||||
|
||||
BKE_ptcache_make_cache(&baker);
|
||||
BKE_ptcache_bake(&baker);
|
||||
|
||||
BLI_freelistN(&pidlist);
|
||||
|
||||
|
@ -2794,7 +2794,7 @@ static void update_physics_cache(Render *re, Scene *scene, int UNUSED(anim_init)
|
||||
baker.break_data = re->tbh;
|
||||
baker.progressbar = NULL;
|
||||
|
||||
BKE_ptcache_make_cache(&baker);
|
||||
BKE_ptcache_bake(&baker);
|
||||
}
|
||||
/* evaluating scene options for general Blender render */
|
||||
static int render_initialize_from_main(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *srl, unsigned int lay, int anim, int anim_init)
|
||||
|
Loading…
Reference in New Issue
Block a user