[Bf-blender-cvs] [bea5cec] alembic_pointcache: Marked the PTC_STATE_SIMULATION_VALID flag as deprecated. This is only used by the bake operator, but keeping track of the sync state of cache data vs. simulation settings needs to be radically simplified.

Lukas Tönne noreply at git.blender.org
Thu Oct 16 16:54:00 CEST 2014


Commit: bea5cec25eaff415a46d72f4a437b62cf9118e7a
Author: Lukas Tönne
Date:   Fri Dec 6 11:26:06 2013 +0100
Branches: alembic_pointcache
https://developer.blender.org/rBbea5cec25eaff415a46d72f4a437b62cf9118e7a

Marked the PTC_STATE_SIMULATION_VALID flag as deprecated. This is only
used by the bake operator, but keeping track of the sync state of cache
data vs. simulation settings needs to be radically simplified.

The API should provide a way of detecting whether a valid simulation
state can be obtained for a certain frame.

  /* check if a frame can be read from the cache (no data is modified) */
  PTCReadSampleResult PTC_test_sample(struct PTCReader *reader, float frame);
  /* try to obtain a cache sample and write to DNA data */
  PTCReadSampleResult PTC_read_sample(struct PTCReader *reader, float frame);

Beyond that the cache should be oblivious of the simulation state. When
settings or dependencies are changed which invalidate the simulation
cache state this should invalidate all cache samples (or possible a
certain frame range), but the cache itself should not need to keep track
of the simulation as a whole.

===================================================================

M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/makesdna/DNA_pointcache_types.h
M	source/blender/pointcache/PTC_api.cpp

===================================================================

diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 68d1e12..6aa5432 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -3091,7 +3091,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
 						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)==0) &&
+					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);
@@ -3159,7 +3159,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
 	/* clear baking flag */
 	if (pid) {
 		cache->state.flag &= ~(PTC_STATE_BAKING|PTC_STATE_REDO_NEEDED);
-		cache->state.flag |= PTC_STATE_SIMULATION_VALID;
+		cache->state.flag |= PTC_STATE_SIMULATION_VALID_DEPRECATED;
 		if (bake) {
 			cache->state.flag |= PTC_STATE_BAKED;
 			/* write info file */
@@ -3182,7 +3182,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
 				else
 					cache->state.flag &= ~(PTC_STATE_BAKING|PTC_STATE_REDO_NEEDED);
 
-				cache->state.flag |= PTC_STATE_SIMULATION_VALID;
+				cache->state.flag |= PTC_STATE_SIMULATION_VALID_DEPRECATED;
 
 				if (bake) {
 					cache->state.flag |= PTC_STATE_BAKED;
@@ -3408,7 +3408,7 @@ void BKE_ptcache_load_external(PTCacheID *pid)
 				ptcache_file_close(pf);
 			}
 		}
-		cache->state.flag |= (PTC_STATE_BAKED|PTC_STATE_SIMULATION_VALID);
+		cache->state.flag |= (PTC_STATE_BAKED|PTC_STATE_SIMULATION_VALID_DEPRECATED);
 		cache->state.flag &= ~(PTC_STATE_OUTDATED|PTC_STATE_FRAMES_SKIPPED);
 	}
 
@@ -3478,14 +3478,14 @@ void BKE_ptcache_update_info(PTCacheID *pid)
 void BKE_ptcache_validate(PointCache *cache, int framenr)
 {
 	if (cache) {
-		cache->state.flag |= PTC_STATE_SIMULATION_VALID;
+		cache->state.flag |= PTC_STATE_SIMULATION_VALID_DEPRECATED;
 		cache->state.simframe = framenr;
 	}
 }
 void BKE_ptcache_invalidate(PointCache *cache)
 {
 	if (cache) {
-		cache->state.flag &= ~PTC_STATE_SIMULATION_VALID;
+		cache->state.flag &= ~PTC_STATE_SIMULATION_VALID_DEPRECATED;
 		cache->state.simframe = 0;
 		cache->state.last_exact = MIN2(cache->startframe, 0);
 	}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 3f256c6..104f983 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3580,7 +3580,7 @@ static void direct_link_pointcache(FileData *UNUSED(fd), PointCache *cache)
 	if (!cache)
 		return;
 	
-	cache->state.flag &= ~PTC_STATE_SIMULATION_VALID;
+	cache->state.flag &= ~PTC_STATE_SIMULATION_VALID_DEPRECATED;
 	cache->state.simframe = 0;
 	cache->edit = NULL;
 	cache->free_edit = NULL;
@@ -7369,7 +7369,7 @@ static void do_versions_pointcache(ID *UNUSED(id), PointCache *cache)
 	/* BAKED is not copied, force a rebake */
 	/* REDO_NEEDED is combination of OUTDATED and FRAMES_SKIPPED, no need to copy */
 	if (oldflag & _PTCACHE_OUTDATED_DEPRECATED) cache_state_flag |= PTC_STATE_OUTDATED;
-	if (oldflag & _PTCACHE_SIMULATION_VALID_DEPRECATED) cache_state_flag |= PTC_STATE_SIMULATION_VALID;
+	if (oldflag & _PTCACHE_SIMULATION_VALID_DEPRECATED) cache_state_flag |= PTC_STATE_SIMULATION_VALID_DEPRECATED;
 	if (oldflag & _PTCACHE_BAKING_DEPRECATED) cache_state_flag |= PTC_STATE_BAKING;
 	if (oldflag & _PTCACHE_FRAMES_SKIPPED_DEPRECATED) cache_state_flag |= PTC_STATE_FRAMES_SKIPPED;
 	if (oldflag & _PTCACHE_READ_INFO_DEPRECATED) cache_state_flag |= PTC_STATE_READ_INFO;
diff --git a/source/blender/makesdna/DNA_pointcache_types.h b/source/blender/makesdna/DNA_pointcache_types.h
index 4ae67e0..2979cfa 100644
--- a/source/blender/makesdna/DNA_pointcache_types.h
+++ b/source/blender/makesdna/DNA_pointcache_types.h
@@ -98,7 +98,7 @@ typedef struct PointCacheState {
 typedef enum ePointCacheStateFlag {
 	PTC_STATE_BAKED				= 1,
 	PTC_STATE_OUTDATED			= 2,
-	PTC_STATE_SIMULATION_VALID	= 4,
+	PTC_STATE_SIMULATION_VALID_DEPRECATED	= 4,
 	PTC_STATE_BAKING			= 8,
 	PTC_STATE_FRAMES_SKIPPED	= 16,
 	PTC_STATE_READ_INFO			= 32,
diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index 7e50cdc..1524328 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -40,7 +40,6 @@ using namespace PTC;
 void PTC_validate(PointCache *cache, int framenr)
 {
 	if (cache) {
-		cache->state.flag |= PTC_STATE_SIMULATION_VALID;
 		cache->state.simframe = framenr;
 	}
 }
@@ -48,7 +47,6 @@ void PTC_validate(PointCache *cache, int framenr)
 void PTC_invalidate(PointCache *cache)
 {
 	if (cache) {
-		cache->state.flag &= ~PTC_STATE_SIMULATION_VALID;
 		cache->state.simframe = 0;
 		cache->state.last_exact = min_ii(cache->startframe, 0);
 	}




More information about the Bf-blender-cvs mailing list