diff --git a/release/scripts/ui/properties_particle.py b/release/scripts/ui/properties_particle.py index 6ec396bf7a1..a1bc4019c6d 100644 --- a/release/scripts/ui/properties_particle.py +++ b/release/scripts/ui/properties_particle.py @@ -269,10 +269,9 @@ class PARTICLE_PT_cache(ParticleButtonsPanel): return psys.settings.type in ('EMITTER', 'REACTOR') or (psys.settings.type == 'HAIR' and psys.hair_dynamics) def draw(self, context): - psys = context.particle_system - point_cache_ui(self, context, psys.point_cache, particle_panel_enabled(context, psys), not psys.hair_dynamics, 0) + point_cache_ui(self, context, psys.point_cache, True, 'HAIR' if psys.hair_dynamics else 'PSYS') class PARTICLE_PT_velocity(ParticleButtonsPanel): diff --git a/release/scripts/ui/properties_physics_cloth.py b/release/scripts/ui/properties_physics_cloth.py index 5aa15fe9403..67fc79eb4d1 100644 --- a/release/scripts/ui/properties_physics_cloth.py +++ b/release/scripts/ui/properties_physics_cloth.py @@ -142,7 +142,7 @@ class PHYSICS_PT_cloth_cache(PhysicButtonsPanel): def draw(self, context): md = context.cloth - point_cache_ui(self, context, md.point_cache, cloth_panel_enabled(md), 0, 0) + point_cache_ui(self, context, md.point_cache, cloth_panel_enabled(md), 'CLOTH') class PHYSICS_PT_cloth_collision(PhysicButtonsPanel): diff --git a/release/scripts/ui/properties_physics_common.py b/release/scripts/ui/properties_physics_common.py index cad1229a0de..eac2bc60f35 100644 --- a/release/scripts/ui/properties_physics_common.py +++ b/release/scripts/ui/properties_physics_common.py @@ -22,7 +22,8 @@ narrowui = 180 import bpy -def point_cache_ui(self, context, cache, enabled, particles, smoke): +#cachetype can be 'PSYS' 'HAIR' 'SMOKE' etc +def point_cache_ui(self, context, cache, enabled, cachetype): layout = self.layout wide_ui = context.region.width > narrowui @@ -35,7 +36,7 @@ def point_cache_ui(self, context, cache, enabled, particles, smoke): col.operator("ptcache.remove", icon='ZOOMOUT', text="") row = layout.row() - if particles: + if cachetype in {'PSYS', 'HAIR'}: row.prop(cache, "external") if cache.external: @@ -53,17 +54,17 @@ def point_cache_ui(self, context, cache, enabled, particles, smoke): split = layout.split() col = split.column(align=True) - if not particles: + if cachetype != 'PSYS': col.enabled = enabled col.prop(cache, "frame_start") col.prop(cache, "frame_end") - if not smoke: + if cachetype != 'SMOKE': col.prop(cache, "step") if wide_ui: col = split.column() - if not smoke: + if cachetype != 'SMOKE': sub = col.column() sub.enabled = enabled sub.prop(cache, "quick_cache") @@ -102,7 +103,6 @@ def point_cache_ui(self, context, cache, enabled, particles, smoke): col.operator("ptcache.free_bake_all", text="Free All Bakes") col.operator("ptcache.bake_all", text="Update All To Frame").bake = False - def effector_weights_ui(self, context, weights): layout = self.layout diff --git a/release/scripts/ui/properties_physics_smoke.py b/release/scripts/ui/properties_physics_smoke.py index b1cec9bb120..d4a40dc6788 100644 --- a/release/scripts/ui/properties_physics_smoke.py +++ b/release/scripts/ui/properties_physics_smoke.py @@ -166,7 +166,7 @@ class PHYSICS_PT_smoke_cache(PhysicButtonsPanel): md = context.smoke.domain_settings cache = md.point_cache_low - point_cache_ui(self, context, cache, (cache.baked is False), 0, 1) + point_cache_ui(self, context, cache, (cache.baked is False), 'SMOKE') class PHYSICS_PT_smoke_highres(PhysicButtonsPanel): @@ -222,7 +222,7 @@ class PHYSICS_PT_smoke_cache_highres(PhysicButtonsPanel): md = context.smoke.domain_settings cache = md.point_cache_high - point_cache_ui(self, context, cache, (cache.baked is False), 0, 1) + point_cache_ui(self, context, cache, (cache.baked is False), 'SMOKE') class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel): diff --git a/release/scripts/ui/properties_physics_softbody.py b/release/scripts/ui/properties_physics_softbody.py index 1cef6291c78..8e685b8a66c 100644 --- a/release/scripts/ui/properties_physics_softbody.py +++ b/release/scripts/ui/properties_physics_softbody.py @@ -97,7 +97,7 @@ class PHYSICS_PT_softbody_cache(PhysicButtonsPanel): def draw(self, context): md = context.soft_body - point_cache_ui(self, context, md.point_cache, softbody_panel_enabled(md), 0, 0) + point_cache_ui(self, context, md.point_cache, softbody_panel_enabled(md), 'SOFTBODY') class PHYSICS_PT_softbody_goal(PhysicButtonsPanel): diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 557c1fe0d46..160f8a35520 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1712,14 +1712,13 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) int totpoint = pid->totpoint(pid->calldata, cfra); int add = 0, overwrite = 0; - if(totpoint == 0 || cfra < 0 - || (cfra ? pid->data_types == 0 : pid->info_types == 0)) + if(totpoint == 0 || (cfra ? pid->data_types == 0 : pid->info_types == 0)) return 0; if(cache->flag & PTCACHE_DISK_CACHE) { int ofra=0, efra = cache->endframe; - if(cfra==0) + if(cfra==0 && cache->startframe > 0) add = 1; /* allways start from scratch on the first frame */ else if(cfra == cache->startframe) { @@ -1931,7 +1930,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */ if (mode == PTCACHE_CLEAR_ALL) { - pid->cache->last_exact = 0; + pid->cache->last_exact = MIN2(pid->cache->startframe, 0); BLI_join_dirfile(path_full, path, de->d_name); BLI_delete(path_full, 0, 0); } else { @@ -1963,7 +1962,8 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) pm= pid->cache->mem_cache.first; if(mode == PTCACHE_CLEAR_ALL) { - pid->cache->last_exact = 0; + /*we want startframe if the cache starts before zero*/ + pid->cache->last_exact = MIN2(pid->cache->startframe, 0); for(; pm; pm=pm->next) ptcache_free_data(pm); BLI_freelistN(&pid->cache->mem_cache); @@ -2880,6 +2880,6 @@ void BKE_ptcache_invalidate(PointCache *cache) { cache->flag &= ~PTCACHE_SIMULATION_VALID; cache->simframe = 0; - cache->last_exact = 0; + cache->last_exact = MIN2(cache->startframe, 0); }