[Bf-blender-cvs] [2975632] alembic: Store the overall result of cache reading in the DupliCache.

Lukas Tönne noreply at git.blender.org
Tue Mar 31 11:50:47 CEST 2015


Commit: 297563286e40cd2a9460ff102c85d8c4ae96aab2
Author: Lukas Tönne
Date:   Tue Mar 31 11:49:41 2015 +0200
Branches: alembic
https://developer.blender.org/rB297563286e40cd2a9460ff102c85d8c4ae96aab2

Store the overall result of cache reading in the DupliCache.

This is used to prevent empty dupli lists when reading the cache fails.
In that case the duplilist function will now revert to default scene
evaluation.

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

M	source/blender/blenkernel/intern/cache_library.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/makesdna/DNA_object_types.h

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

diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 3b26094..655513e 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -349,13 +349,17 @@ static struct PTCReaderArchive *find_active_cache(Scene *scene, CacheLibrary *ca
 }
 
 bool BKE_cache_read_dupli_cache(Scene *scene, float frame, eCacheLibrary_EvalMode eval_mode,
-                               struct Group *dupgroup, struct DupliCache *dupcache, CacheLibrary *cachelib)
+                                struct Group *dupgroup, struct DupliCache *dupcache, CacheLibrary *cachelib)
 {
 	struct PTCReaderArchive *archive;
 	struct PTCReader *reader;
-	/*eCacheReadSampleResult result;*/ /* unused */
 	
-	if (!dupcache || !dupgroup || !cachelib)
+	if (!dupcache)
+		return false;
+	
+	dupcache->result = CACHE_READ_SAMPLE_INVALID;
+	
+	if (!dupgroup || !cachelib)
 		return false;
 	if (!(cachelib->eval_mode & eval_mode))
 		return false;
@@ -367,12 +371,12 @@ bool BKE_cache_read_dupli_cache(Scene *scene, float frame, eCacheLibrary_EvalMod
 	reader = PTC_reader_duplicache(dupgroup->id.name, dupgroup, dupcache);
 	PTC_reader_init(reader, archive);
 	
-	/*result = */BKE_cache_read_result(PTC_read_sample(reader, frame));
+	dupcache->result = BKE_cache_read_result(PTC_read_sample(reader, frame));
 	
 	PTC_reader_free(reader);
 	PTC_close_reader_archive(archive);
 	
-	return true;
+	return (dupcache->result != CACHE_READ_SAMPLE_INVALID);
 }
 
 bool BKE_cache_read_dupli_object(Scene *scene, float frame, eCacheLibrary_EvalMode eval_mode,
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 5d93248..ee5e37c 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -1231,7 +1231,7 @@ ListBase *object_duplilist_ex(EvaluationContext *eval_ctx, Scene *scene, Object
 		BKE_object_dupli_cache_update(scene, ob, eval_ctx, (float)scene->r.cfra);
 	}
 	
-	if (ob->dup_cache) {
+	if (ob->dup_cache && (ob->dup_cache->result != CACHE_READ_SAMPLE_INVALID)) {
 		/* Note: duplis in the cache don't have the main duplicator obmat applied.
 		 * duplilist also should return a full copy of duplis, so we copy
 		 * the cached list and apply the obmat to each.
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 7bb0cfc..2bf76c7 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -347,7 +347,8 @@ typedef struct DupliObjectData {
 } DupliObjectData;
 
 typedef struct DupliCache {
-	int flag;
+	short flag;
+	short result;
 	float cfra; /* frame for which the cache was constructed */
 	
 	struct GHash *ghash;




More information about the Bf-blender-cvs mailing list