Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/pointcache.c
| Show First 20 Lines • Show All 3,503 Lines • ▼ Show 20 Lines | PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, const ListBase *ptcaches_old, const int flag) | ||||
| return ptcaches_new->first; | return ptcaches_new->first; | ||||
| } | } | ||||
| /* Disabled this code; this is being called on scene_update_tagged, and that in turn gets called on | /* 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) */ | * every user action changing stuff, and then it runs a complete bake??? (ton) */ | ||||
| /* Baking */ | /* Baking */ | ||||
| void BKE_ptcache_quick_cache_all(Main *bmain, Scene *scene) | void BKE_ptcache_quick_cache_all(Main *bmain, Scene *scene, SceneLayer *scene_layer) | ||||
| { | { | ||||
| PTCacheBaker baker; | PTCacheBaker baker; | ||||
| memset(&baker, 0, sizeof(baker)); | memset(&baker, 0, sizeof(baker)); | ||||
| baker.main = bmain; | baker.main = bmain; | ||||
| baker.scene = scene; | baker.scene = scene; | ||||
| baker.scene_layer = scene_layer; | |||||
| baker.bake = 0; | baker.bake = 0; | ||||
| baker.render = 0; | baker.render = 0; | ||||
| baker.anim_init = 0; | baker.anim_init = 0; | ||||
| baker.quick_step = scene->physics_settings.quick_cache_step; | baker.quick_step = scene->physics_settings.quick_cache_step; | ||||
| BKE_ptcache_bake(&baker); | BKE_ptcache_bake(&baker); | ||||
| } | } | ||||
| Show All 9 Lines | 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->main; | Main *bmain = baker->main; | ||||
| Scene *scene = baker->scene; | Scene *scene = baker->scene; | ||||
| SceneLayer *scene_layer = baker->scene_layer; | |||||
| 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; | ||||
| float frameleno = scene->r.framelen; | float frameleno = scene->r.framelen; | ||||
| int cfrao = CFRA; | int cfrao = CFRA; | ||||
| int startframe = MAXFRAME, endframe = baker->anim_init ? scene->r.sfra : CFRA; | int startframe = MAXFRAME, endframe = baker->anim_init ? scene->r.sfra : CFRA; | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | if ((cache->flag & PTCACHE_BAKED)==0) { | ||||
| else { | else { | ||||
| endframe = MIN2(endframe, cache->endframe); | endframe = MIN2(endframe, cache->endframe); | ||||
| } | } | ||||
| cache->flag &= ~PTCACHE_BAKED; | cache->flag &= ~PTCACHE_BAKED; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| for (SETLOOPER(scene, sce_iter, base)) { | for (SETLOOPER_SCENE_LAYER(scene, scene_layer, sce_iter, base)) { | ||||
| /* cache/bake everything in the scene */ | /* cache/bake everything in the scene */ | ||||
| BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); | BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); | ||||
| for (pid=pidlist.first; pid; pid=pid->next) { | for (pid=pidlist.first; pid; pid=pid->next) { | ||||
| cache = pid->cache; | cache = pid->cache; | ||||
| if ((cache->flag & PTCACHE_BAKED)==0) { | if ((cache->flag & PTCACHE_BAKED)==0) { | ||||
| if (pid->type==PTCACHE_TYPE_PARTICLES) { | if (pid->type==PTCACHE_TYPE_PARTICLES) { | ||||
| ParticleSystem *psys = (ParticleSystem*)pid->calldata; | ParticleSystem *psys = (ParticleSystem*)pid->calldata; | ||||
| ▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | if (pid) { | ||||
| if (bake) { | if (bake) { | ||||
| cache->flag |= PTCACHE_BAKED; | cache->flag |= PTCACHE_BAKED; | ||||
| /* write info file */ | /* write info file */ | ||||
| if (cache->flag & PTCACHE_DISK_CACHE) | if (cache->flag & PTCACHE_DISK_CACHE) | ||||
| BKE_ptcache_write(pid, 0); | BKE_ptcache_write(pid, 0); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| for (SETLOOPER(scene, sce_iter, base)) { | for (SETLOOPER_SCENE_LAYER(scene, scene_layer, sce_iter, base)) { | ||||
| BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); | BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); | ||||
| for (pid=pidlist.first; pid; pid=pid->next) { | for (pid=pidlist.first; pid; pid=pid->next) { | ||||
| /* skip hair particles */ | /* skip hair particles */ | ||||
| if (pid->type==PTCACHE_TYPE_PARTICLES && ((ParticleSystem*)pid->calldata)->part->type == PART_HAIR) | if (pid->type==PTCACHE_TYPE_PARTICLES && ((ParticleSystem*)pid->calldata)->part->type == PART_HAIR) | ||||
| continue; | continue; | ||||
| cache = pid->cache; | cache = pid->cache; | ||||
| ▲ Show 20 Lines • Show All 375 Lines • Show Last 20 Lines | |||||