Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/pointcache.c
| Show First 20 Lines • Show All 4,019 Lines • ▼ Show 20 Lines | static void ptcache_dt_to_str(char *str, double dtime) | ||||
| else { | else { | ||||
| sprintf(str, "%is", ((int)dtime) % 60); | sprintf(str, "%is", ((int)dtime) % 60); | ||||
| } | } | ||||
| } | } | ||||
| /* if bake is not given run simulations to current frame */ | /* if bake is not given run simulations to current frame */ | ||||
| void BKE_ptcache_bake(PTCacheBaker *baker) | void BKE_ptcache_bake(PTCacheBaker *baker) | ||||
| { | { | ||||
| Main *bmain = baker->bmain; | |||||
| Scene *scene = baker->scene; | Scene *scene = baker->scene; | ||||
| ViewLayer *view_layer = baker->view_layer; | ViewLayer *view_layer = baker->view_layer; | ||||
| struct Depsgraph *depsgraph = baker->depsgraph; | struct Depsgraph *depsgraph = baker->depsgraph; | ||||
| Scene *sce_iter; /* SETLOOPER macro only */ | Scene *sce_iter; /* SETLOOPER macro only */ | ||||
| Base *base; | Base *base; | ||||
| ListBase pidlist; | ListBase pidlist; | ||||
| PTCacheID *pid = &baker->pid; | PTCacheID *pid = &baker->pid; | ||||
| PointCache *cache = NULL; | PointCache *cache = NULL; | ||||
| ▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | void BKE_ptcache_bake(PTCacheBaker *baker) | ||||
| bool use_timer = false; | bool use_timer = false; | ||||
| double stime, ptime, ctime, fetd; | double stime, ptime, ctime, fetd; | ||||
| char run[32], cur[32], etd[32]; | char run[32], cur[32], etd[32]; | ||||
| int cancel = 0; | int cancel = 0; | ||||
| stime = ptime = PIL_check_seconds_timer(); | stime = ptime = PIL_check_seconds_timer(); | ||||
| for (int fr = CFRA; fr <= endframe; fr += baker->quick_step, CFRA = fr) { | for (int fr = CFRA; fr <= endframe; fr += baker->quick_step, CFRA = fr) { | ||||
| BKE_scene_graph_update_for_newframe(depsgraph, bmain); | BKE_scene_graph_update_for_newframe(depsgraph); | ||||
| if (baker->update_progress) { | if (baker->update_progress) { | ||||
| float progress = ((float)(CFRA - startframe) / (float)(endframe - startframe)); | float progress = ((float)(CFRA - startframe) / (float)(endframe - startframe)); | ||||
| baker->update_progress(baker->bake_job, progress, &cancel); | baker->update_progress(baker->bake_job, progress, &cancel); | ||||
| } | } | ||||
| if (G.background) { | if (G.background) { | ||||
| printf("bake: frame %d :: %d\n", CFRA, endframe); | printf("bake: frame %d :: %d\n", CFRA, endframe); | ||||
| ▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | for (SETLOOPER_VIEW_LAYER(scene, view_layer, sce_iter, base)) { | ||||
| BLI_freelistN(&pidlist); | BLI_freelistN(&pidlist); | ||||
| } | } | ||||
| } | } | ||||
| scene->r.framelen = frameleno; | scene->r.framelen = frameleno; | ||||
| CFRA = cfrao; | CFRA = cfrao; | ||||
| if (bake) { /* already on cfra unless baking */ | if (bake) { /* already on cfra unless baking */ | ||||
| BKE_scene_graph_update_for_newframe(depsgraph, bmain); | BKE_scene_graph_update_for_newframe(depsgraph); | ||||
| } | } | ||||
| /* TODO: call redraw all windows somehow */ | /* TODO: call redraw all windows somehow */ | ||||
| } | } | ||||
| /* Helpers */ | /* Helpers */ | ||||
| void BKE_ptcache_disk_to_mem(PTCacheID *pid) | void BKE_ptcache_disk_to_mem(PTCacheID *pid) | ||||
| { | { | ||||
| PointCache *cache = pid->cache; | PointCache *cache = pid->cache; | ||||
| ▲ Show 20 Lines • Show All 376 Lines • Show Last 20 Lines | |||||