[Bf-blender-cvs] [6789e32] alembic_pointcache: Completely removed the "bake" operators for point cache. This feature will get a complete replacement, removing it altogether makes this much easier.
Lukas Tönne
noreply at git.blender.org
Thu Oct 16 16:54:01 CEST 2014
Commit: 6789e32e1d807789da9ab5b2a88c9f38a148d3d5
Author: Lukas Tönne
Date: Sat Dec 7 12:24:05 2013 +0100
Branches: alembic_pointcache
https://developer.blender.org/rB6789e32e1d807789da9ab5b2a88c9f38a148d3d5
Completely removed the "bake" operators for point cache. This feature
will get a complete replacement, removing it altogether makes this much
easier.
===================================================================
M release/scripts/startup/bl_ui/properties_physics_common.py
M source/blender/blenkernel/BKE_pointcache.h
M source/blender/blenkernel/intern/pointcache.c
M source/blender/editors/physics/physics_intern.h
M source/blender/editors/physics/physics_ops.c
M source/blender/editors/physics/physics_pointcache.c
M source/blender/render/intern/source/pipeline.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py
index 89df251..b8bffa8 100644
--- a/release/scripts/startup/bl_ui/properties_physics_common.py
+++ b/release/scripts/startup/bl_ui/properties_physics_common.py
@@ -181,24 +181,6 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
col = split.column()
- if cache.state.is_baked is True:
- col.operator("ptcache.free_bake", text="Free Bake")
- else:
- col.operator("ptcache.bake", text="Bake").bake = True
-
- sub = col.row()
- sub.enabled = (cache.state.frames_skipped or cache.state.is_outdated) and enabled
- sub.operator("ptcache.bake", text="Calculate To Frame").bake = False
-
- sub = col.column()
- sub.enabled = enabled
- sub.operator("ptcache.bake_from_cache", text="Current Cache to Bake")
-
- col = split.column()
- col.operator("ptcache.bake_all", text="Bake All Dynamics").bake = True
- col.operator("ptcache.free_bake_all", text="Free All Bakes")
- col.operator("ptcache.bake_all", text="Update All To Frame").bake = False
-
col.operator("ptcache.export", text="Export")
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index 7d31397..90fa504 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -167,21 +167,6 @@ typedef struct PTCacheID {
struct PointCache *cache;
} PTCacheID;
-typedef struct PTCacheBaker {
- struct Main *main;
- struct Scene *scene;
- int bake;
- int render;
- int anim_init;
- int quick_step;
- struct PTCacheID *pid;
- int (*break_test)(void *data);
- void *break_data;
- void (*progressbar)(void *data, int num);
- void (*progressend)(void *data);
- void *progresscontext;
-} PTCacheBaker;
-
/* PTCacheEditKey->flag */
#define PEK_SELECT 1
#define PEK_TAG 2
@@ -305,12 +290,6 @@ struct PointCache *BKE_ptcache_copy(struct PointCache *cache, int copy_data);
/********************** Baking *********************/
-/* Bakes cache with cache_step sized jumps in time, not accurate but very fast. */
-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_bake(struct PTCacheBaker *baker);
-
/* Convert disk cache to memory cache. */
void BKE_ptcache_to_mem(struct PTCacheID *pid, struct ListBase *mem_cache);
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 6aa5432..345a8e1 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -2906,308 +2906,6 @@ PointCache *BKE_ptcache_copy(PointCache *cache, int copy_data)
return ncache;
}
-/* Disabled this code; this is being called on scene_update_tagged, and that in turn gets called on
- * every user action changing stuff, and then it runs a complete bake??? (ton) */
-
-/* Baking */
-void BKE_ptcache_quick_cache_all(Main *bmain, Scene *scene)
-{
- PTCacheBaker baker;
-
- baker.bake=0;
- baker.break_data=NULL;
- baker.break_test=NULL;
- baker.pid=NULL;
- baker.progressbar=NULL;
- baker.progressend=NULL;
- baker.progresscontext=NULL;
- baker.render=0;
- baker.anim_init = 0;
- baker.main=bmain;
- baker.scene=scene;
- baker.quick_step=scene->physics_settings.quick_cache_step;
-
- BKE_ptcache_bake(&baker);
-}
-
-/* Simulation thread, no need for interlocks as data written in both threads
- * are only unitary integers (I/O assumed to be atomic for them) */
-typedef struct {
- int break_operation;
- int thread_ended;
- int endframe;
- int step;
- int *cfra_ptr;
- Main *main;
- Scene *scene;
-} ptcache_bake_data;
-
-static void ptcache_dt_to_str(char *str, double dtime)
-{
- if (dtime > 60.0) {
- if (dtime > 3600.0)
- sprintf(str, "%ih %im %is", (int)(dtime/3600), ((int)(dtime/60))%60, ((int)dtime) % 60);
- else
- sprintf(str, "%im %is", ((int)(dtime/60))%60, ((int)dtime) % 60);
- }
- else
- sprintf(str, "%is", ((int)dtime) % 60);
-}
-
-static void *ptcache_bake_thread(void *ptr)
-{
- int use_timer = FALSE, sfra, efra;
- double stime, ptime, ctime, fetd;
- char run[32], cur[32], etd[32];
-
- ptcache_bake_data *data = (ptcache_bake_data*)ptr;
-
- stime = ptime = PIL_check_seconds_timer();
- sfra = *data->cfra_ptr;
- efra = data->endframe;
-
- for (; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step) {
- BKE_scene_update_for_newframe(data->main, data->scene, data->scene->lay);
- if (G.background) {
- printf("bake: frame %d :: %d\n", (int)*data->cfra_ptr, data->endframe);
- }
- else {
- ctime = PIL_check_seconds_timer();
-
- fetd = (ctime-ptime)*(efra-*data->cfra_ptr)/data->step;
-
- if (use_timer || fetd > 60.0) {
- use_timer = TRUE;
-
- ptcache_dt_to_str(cur, ctime-ptime);
- ptcache_dt_to_str(run, ctime-stime);
- ptcache_dt_to_str(etd, fetd);
-
- printf("Baked for %s, current frame: %i/%i (%.3fs), ETC: %s\r", run, *data->cfra_ptr-sfra+1, efra-sfra+1, ctime-ptime, etd);
- }
- ptime = ctime;
- }
- }
-
- if (use_timer) {
- /* start with newline because of \r above */
- ptcache_dt_to_str(run, PIL_check_seconds_timer()-stime);
- printf("\nBake %s %s (%i frames simulated).\n", (data->break_operation ? "canceled after" : "finished in"), run, *data->cfra_ptr-sfra);
- }
-
- data->thread_ended = TRUE;
- return NULL;
-}
-
-/* if bake is not given run simulations to current frame */
-void BKE_ptcache_bake(PTCacheBaker *baker)
-{
- Main *bmain = baker->main;
- Scene *scene = baker->scene;
- Scene *sce_iter; /* SETLOOPER macro only */
- Base *base;
- ListBase pidlist;
- PTCacheID *pid = baker->pid;
- PointCache *cache = NULL;
- float frameleno = scene->r.framelen;
- int cfrao = CFRA;
- int startframe = MAXFRAME;
- int bake = baker->bake;
- int render = baker->render;
- ListBase threads;
- ptcache_bake_data thread_data;
- int progress, old_progress;
-
- thread_data.endframe = baker->anim_init ? scene->r.sfra : CFRA;
- thread_data.step = baker->quick_step;
- thread_data.cfra_ptr = &CFRA;
- thread_data.scene = baker->scene;
- thread_data.main = baker->main;
-
- G.is_break = FALSE;
-
- /* set caches to baking mode and figure out start frame */
- if (pid) {
- /* cache/bake a single object */
- cache = pid->cache;
- if ((cache->state.flag & PTC_STATE_BAKED)==0) {
- if (pid->type==PTCACHE_TYPE_PARTICLES) {
- ParticleSystem *psys= pid->calldata;
-
- /* a bit confusing, could make this work better in the UI */
- if (psys->part->type == PART_EMITTER)
- psys_get_pointcache_start_end(scene, pid->calldata, &cache->startframe, &cache->endframe);
- }
- else if (pid->type == PTCACHE_TYPE_SMOKE_HIGHRES) {
- /* get all pids from the object and search for smoke low res */
- ListBase pidlist2;
- PTCacheID *pid2;
- BKE_ptcache_ids_from_object(&pidlist2, pid->ob, scene, MAX_DUPLI_RECUR);
- for (pid2=pidlist2.first; pid2; pid2=pid2->next) {
- if (pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN) {
- if (pid2->cache && !(pid2->cache->state.flag & PTC_STATE_BAKED)) {
- if (bake || pid2->cache->state.flag & PTC_STATE_REDO_NEEDED)
- BKE_ptcache_id_clear(pid2, PTCACHE_CLEAR_ALL, 0);
- if (bake) {
- pid2->cache->state.flag |= PTC_STATE_BAKING;
- pid2->cache->state.flag &= ~PTC_STATE_BAKED;
- }
- }
- }
- }
- BLI_freelistN(&pidlist2);
- }
-
- if (bake || cache->state.flag & PTC_STATE_REDO_NEEDED)
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
-
- startframe = MAX2(cache->state.last_exact, cache->startframe);
-
- if (bake) {
- thread_data.endframe = cache->endframe;
- cache->state.flag |= PTC_STATE_BAKING;
- }
- else {
- thread_data.endframe = MIN2(thread_data.endframe, cache->endframe);
- }
-
- cache->state.flag &= ~PTC_STATE_BAKED;
- }
- }
- else {
- for (SETLOOPER(scene, sce_iter, base)) {
- /* cache/bake everything in the scene */
- BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
-
- for (pid=pidlist.first; pid; pid=pid->next) {
- cache = pid->cache;
- if ((cache->state.flag & PTC_STATE_BAKED)==0) {
- if (pid->type==PTCACHE_TYPE_PARTICLES) {
- ParticleSystem *psys = (ParticleSystem*)pid->calldata;
- /* skip hair & keyed particles */
- if (psys->part->type == PART_HAIR || psys->part->phystype == PART_PHYS_KEYED)
- continue;
-
- psys_get_pointcache_start_end(scene, pid->calldata, &cache->startframe, &cache->endframe);
- }
-
- if ((cache->state.flag & PTC_STATE_REDO_NEEDED || (cache->state.flag & PTC_STATE_SIMULATION_VALID_DEPRECATED)==0) &&
- (render || bake))
- {
- BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
- }
-
- startframe = MIN2(startframe, cache->startframe);
-
- if (bake || render) {
- cache->state.flag |= PTC_STATE_BAKING;
-
- if (bake)
- thread_data.endframe = MAX2(thread_data.endframe, cache->endframe);
- }
-
- cache->state.flag &= ~PTC_STATE_BAKED;
-
- }
- }
- BLI_freelistN(&pidlist);
- }
- }
-
- CFRA = startframe;
- scene->r.framelen = 1.0;
- thread_data.break_operation = FALSE;
- thread_data.thread_ended = FALSE;
- old_progress = -1;
-
- WM_cursor_wait(1);
-
- if (G.background) {
- ptcache_bake_thread((void*)&thread_data);
- }
- else {
- BLI_init_threads(&threads, ptcache_bake_thread, 1);
- BLI_insert_thread(&threads, (void*)&thread_data);
-
- while (thread_data.thread_ended == FALSE) {
-
- if (bake)
- progress = (int)(100.0f * (float)(CFRA - startframe)/(float)(thread_data.endframe-startframe));
- else
- progress = CFRA;
-
- /* NOTE: baking should not redraw whole ui as this slows things down */
- if ((baker->progressbar) && (progress != old_progress)) {
- baker->progressbar(baker->progresscontext, progress);
- old_progress = progress;
- }
-
- /* Delay to lessen CPU load from UI thread */
- PIL_sleep_ms(200);
-
- /* NOTE: breaking baking should leave calculated frames in cache, not clear it */
- if (blender_t
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list