[Bf-blender-cvs] [1700c4c] alembic: Extend the cache reading function to take the result archive into account.

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


Commit: 1700c4c6fb6a87890a9072976cd0133da67aa57c
Author: Lukas Tönne
Date:   Tue Mar 31 11:26:17 2015 +0200
Branches: alembic
https://developer.blender.org/rB1700c4c6fb6a87890a9072976cd0133da67aa57c

Extend the cache reading function to take the result archive into account.

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

M	source/blender/blenkernel/intern/cache_library.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/editors/space_view3d/view3d_draw.c

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

diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 54e6a0f..3b26094 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -332,9 +332,20 @@ void BKE_cache_archive_output_path(CacheLibrary *cachelib, char *result, int max
 static struct PTCReaderArchive *find_active_cache(Scene *scene, CacheLibrary *cachelib)
 {
 	char filename[FILE_MAX];
+	struct PTCReaderArchive *archive = NULL;
 	
-	BKE_cache_archive_input_path(cachelib, filename, sizeof(filename));
-	return PTC_open_reader_archive(scene, filename);
+	if (cachelib->display_mode == CACHE_LIBRARY_DISPLAY_RESULT) {
+		/* try using the output cache */
+		BKE_cache_archive_output_path(cachelib, filename, sizeof(filename));
+		archive = PTC_open_reader_archive(scene, filename);
+	}
+	
+	if (!archive && cachelib->source_mode == CACHE_LIBRARY_SOURCE_CACHE) {
+		BKE_cache_archive_input_path(cachelib, filename, sizeof(filename));
+		archive = PTC_open_reader_archive(scene, filename);
+	}
+	
+	return archive;
 }
 
 bool BKE_cache_read_dupli_cache(Scene *scene, float frame, eCacheLibrary_EvalMode eval_mode,
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 9ee4921..e795710 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2881,7 +2881,7 @@ bool BKE_object_minmax_dupli(Scene *scene, Object *ob, float r_min[3], float r_m
 				BoundBox *bb = NULL;
 				if (ob->dup_cache) {
 					DupliObjectData *dob_data = BKE_dupli_cache_find_data(ob->dup_cache, dob->ob);
-					if (dob_data->dm) {
+					if (dob_data && dob_data->dm) {
 						bb = &dob_data->bb;
 					}
 				}
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 5df61f8..5d93248 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -1464,7 +1464,7 @@ void BKE_object_dupli_cache_update(Scene *scene, Object *ob, EvaluationContext *
 	const eCacheLibrary_EvalMode eval_mode = eval_ctx->mode == DAG_EVAL_RENDER ? CACHE_LIBRARY_EVAL_RENDER : CACHE_LIBRARY_EVAL_REALTIME;
 	
 	bool is_dupligroup = (ob->transflag & OB_DUPLIGROUP) && ob->dup_group;
-	bool is_cached = ob->cache_library && ob->cache_library->source_mode == CACHE_LIBRARY_SOURCE_CACHE;
+	bool is_cached = ob->cache_library && (ob->cache_library->source_mode == CACHE_LIBRARY_SOURCE_CACHE || ob->cache_library->display_mode == CACHE_LIBRARY_DISPLAY_RESULT);
 	
 	/* cache is a group duplicator feature only */
 	if (is_dupligroup && is_cached) {
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index b4fee27..c805b0a 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2119,7 +2119,7 @@ static void draw_dupli_objects_color(
 		tbase.object->transflag &= ~OB_IS_DUPLI_CACHE;
 		if (base->object->dup_cache) {
 			dob_data = BKE_dupli_cache_find_data(base->object->dup_cache, tbase.object);
-			if (dob_data->dm) {
+			if (dob_data && dob_data->dm) {
 				tbase.object->transflag |= OB_IS_DUPLI_CACHE;
 				
 				tbase.object->derivedFinal = dob_data->dm;




More information about the Bf-blender-cvs mailing list