[Bf-blender-cvs] [54c2e62] alembic: Removed the redundant cache exporter class from the pointcache lib.

Lukas Tönne noreply at git.blender.org
Tue Mar 31 16:53:38 CEST 2015


Commit: 54c2e625e589893f0e1ec1d980078c42e437da39
Author: Lukas Tönne
Date:   Tue Mar 31 14:25:10 2015 +0200
Branches: alembic
https://developer.blender.org/rB54c2e625e589893f0e1ec1d980078c42e437da39

Removed the redundant cache exporter class from the pointcache lib.

Writing in C++ is a little bit more convenient, but this functionality
does not require the additional level of complexity.

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

M	source/blender/blenkernel/BKE_cache_library.h
M	source/blender/blenkernel/intern/cache_library.c
M	source/blender/editors/io/io_cache_library.c
M	source/blender/pointcache/CMakeLists.txt
M	source/blender/pointcache/PTC_api.cpp
M	source/blender/pointcache/PTC_api.h
D	source/blender/pointcache/intern/export.cpp
D	source/blender/pointcache/intern/export.h

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

diff --git a/source/blender/blenkernel/BKE_cache_library.h b/source/blender/blenkernel/BKE_cache_library.h
index f14ffa8..feb7cff 100644
--- a/source/blender/blenkernel/BKE_cache_library.h
+++ b/source/blender/blenkernel/BKE_cache_library.h
@@ -175,6 +175,4 @@ struct CacheModifier *BKE_cache_modifier_copy(struct CacheLibrary *cachelib, str
 
 void BKE_cache_modifier_foreachIDLink(struct CacheLibrary *cachelib, struct CacheModifier *md, CacheModifier_IDWalkFunc walk, void *userdata);
 
-void BKE_cache_modifier_bake(const struct bContext *C, struct Group *group, struct CacheLibrary *cachelib, struct CacheModifier *md, struct Scene *scene, int startframe, int endframe);
-
 #endif
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 655513e..376e46c 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -555,105 +555,6 @@ void BKE_cache_modifier_foreachIDLink(struct CacheLibrary *cachelib, struct Cach
 		mti->foreachIDLink(md, cachelib, walk, userdata);
 }
 
-#if 0
-/* Warning! Deletes existing files if possible, operator should show confirm dialog! */
-static bool cache_modifier_bake_ensure_file_target(CacheLibrary *cachelib, CacheModifier *md)
-{
-	char filename[FILE_MAX];
-	
-	BKE_cache_modifier_archive_path(cachelib, md, filename, sizeof(filename));
-	
-	if (BLI_exists(filename)) {
-		if (BLI_is_dir(filename)) {
-			return false;
-		}
-		else if (BLI_is_file(filename)) {
-			if (BLI_file_is_writable(filename)) {
-				/* returns 0 on success */
-				return (BLI_delete(filename, false, false) == 0);
-			}
-			else {
-				return false;
-			}
-		}
-		else {
-			return false;
-		}
-	}
-	return true;
-}
-
-static void cache_modifier_bake_freejob(void *customdata)
-{
-	CacheBakeContext *ctx = (CacheBakeContext *)customdata;
-	MEM_freeN(ctx);
-}
-
-static void cache_modifier_bake_startjob(void *customdata, short *stop, short *do_update, float *progress)
-{
-	CacheBakeContext *ctx = (CacheBakeContext *)customdata;
-	CacheModifierTypeInfo *mti = cache_modifier_type_get(ctx->md->type);
-	
-	ctx->stop = stop;
-	ctx->do_update = do_update;
-	ctx->progress = progress;
-	
-	if (mti->bake)
-		mti->bake(ctx->md, ctx->cachelib, ctx);
-	
-	*do_update = true;
-	*stop = 0;
-}
-
-static void cache_modifier_bake_endjob(void *UNUSED(customdata))
-{
-	/*CacheBakeContext *ctx = (CacheBakeContext *)customdata;*/
-	
-	G.is_rendering = false;
-	BKE_spacedata_draw_locks(false);
-}
-#endif
-
-void BKE_cache_modifier_bake(const bContext *C, Group *group, CacheLibrary *cachelib, CacheModifier *md, Scene *scene, int startframe, int endframe)
-{
-#if 0
-	CacheBakeContext *ctx;
-	wmJob *wm_job;
-	
-	/* make sure we can write */
-	cache_modifier_bake_ensure_file_target(cachelib, md);
-	
-	/* XXX annoying hack: needed to prevent data corruption when changing
-		 * scene frame in separate threads
-		 */
-	G.is_rendering = true;
-	
-	BKE_spacedata_draw_locks(true);
-	
-	/* XXX set WM_JOB_EXCL_RENDER to prevent conflicts with render jobs,
-		 * since we need to set G.is_rendering
-		 */
-	wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Cache Modifier Bake",
-	                     WM_JOB_PROGRESS | WM_JOB_EXCL_RENDER, WM_JOB_TYPE_CACHELIBRARY_BAKE);
-	
-	/* setup job */
-	ctx = MEM_callocN(sizeof(CacheBakeContext), "Cache Bake Context");
-	ctx->cachelib = cachelib;
-	ctx->md = md;
-	ctx->bmain = CTX_data_main(C);
-	ctx->scene = scene;
-	ctx->startframe = startframe;
-	ctx->endframe = endframe;
-	ctx->group = group;
-	
-	WM_jobs_customdata_set(wm_job, ctx, cache_modifier_bake_freejob);
-	WM_jobs_timer(wm_job, 0.1, NC_SCENE|ND_FRAME, NC_SCENE|ND_FRAME);
-	WM_jobs_callbacks(wm_job, cache_modifier_bake_startjob, NULL, NULL, cache_modifier_bake_endjob);
-	
-	WM_jobs_start(CTX_wm_manager(C), wm_job);
-#endif
-}
-
 /* ------------------------------------------------------------------------- */
 
 static void hairsim_init(HairSimCacheModifier *UNUSED(md))
@@ -667,55 +568,10 @@ static void hairsim_copy(HairSimCacheModifier *UNUSED(md), HairSimCacheModifier
 static void hairsim_bake_do(CacheBakeContext *ctx, short *stop, short *do_update, float *progress,
                             struct PTCWriterArchive *archive, EvaluationContext *eval_ctx)
 {
-	Scene *scene = ctx->scene;
-	struct PTCWriter *writer;
-	
-	if ((*stop) || (G.is_break))
-		return;
-	
-	writer = PTC_writer_dupligroup(ctx->group->id.name, eval_ctx, scene, ctx->group, ctx->cachelib);
-	if (writer) {
-		PTC_writer_init(writer, archive);
-		
-		PTC_bake(ctx->bmain, scene, eval_ctx, writer, ctx->startframe, ctx->endframe, stop, do_update, progress);
-		
-		PTC_writer_free(writer);
-		writer = NULL;
-	}
 }
 
 static void hairsim_bake(HairSimCacheModifier *hsmd, CacheLibrary *cachelib, CacheBakeContext *ctx)
 {
-	Scene *scene = ctx->scene;
-	const int origframe = scene->r.cfra;
-	const float origframelen = scene->r.framelen;
-	
-	struct PTCWriterArchive *archive;
-	char filename[FILE_MAX];
-	EvaluationContext eval_ctx;
-	
-	scene->r.framelen = 1.0f;
-	
-	BKE_cache_archive_output_path(cachelib, filename, sizeof(filename));
-	archive = PTC_open_writer_archive(scene, filename);
-	
-	if (archive) {
-		
-		G.is_break = false;
-		
-		eval_ctx.mode = DAG_EVAL_VIEWPORT;
-		PTC_writer_archive_use_render(archive, false);
-		hairsim_bake_do(ctx, ctx->stop, ctx->do_update, ctx->progress, archive, &eval_ctx);
-		
-	}
-	
-	if (archive)
-		PTC_close_writer_archive(archive);
-	
-	/* reset scene frame */
-	scene->r.cfra = origframe;
-	scene->r.framelen = origframelen;
-	BKE_scene_update_for_newframe(&eval_ctx, ctx->bmain, scene, scene->lay);
 }
 
 CacheModifierTypeInfo cacheModifierType_HairSimulation = {
diff --git a/source/blender/editors/io/io_cache_library.c b/source/blender/editors/io/io_cache_library.c
index 948c9c4..7c7c839 100644
--- a/source/blender/editors/io/io_cache_library.c
+++ b/source/blender/editors/io/io_cache_library.c
@@ -217,12 +217,23 @@ static void cache_library_bake_freejob(void *customdata)
 	MEM_freeN(data);
 }
 
-static void cache_library_bake_do(CacheLibraryBakeJob *data, short *stop, short *do_update, float *progress)
+static bool cache_library_bake_stop(CacheLibraryBakeJob *data)
+{
+	return (*data->stop) || G.is_break;
+}
+
+static void cache_library_bake_set_progress(CacheLibraryBakeJob *data, float progress)
+{
+	*data->do_update = 1;
+	*data->progress = progress;
+}
+
+static void cache_library_bake_do(CacheLibraryBakeJob *data)
 {
 	Scene *scene = data->scene;
-	int start_frame, end_frame;
+	int cfra, start_frame, end_frame;
 	
-	if ((*stop) || (G.is_break))
+	if (cache_library_bake_stop(data))
 		return;
 	
 	data->writer = PTC_writer_dupligroup(data->group->id.name, &data->eval_ctx, scene, data->group, data->cachelib);
@@ -231,7 +242,20 @@ static void cache_library_bake_do(CacheLibraryBakeJob *data, short *stop, short
 	/* XXX where to get this from? */
 	start_frame = scene->r.sfra;
 	end_frame = scene->r.efra;
-	PTC_bake(data->bmain, scene, &data->eval_ctx, data->writer, start_frame, end_frame, stop, do_update, progress);
+	
+	cache_library_bake_set_progress(data, 0.0f);
+	
+	for (cfra = start_frame; cfra <= end_frame; ++cfra) {
+		scene->r.cfra = cfra;
+		BKE_scene_update_for_newframe(&data->eval_ctx, data->bmain, scene, scene->lay);
+		
+		PTC_write_sample(data->writer);
+		
+		cache_library_bake_set_progress(data, (float)(cfra - start_frame + 1) / (float)(end_frame - start_frame + 1));
+		
+		if (cache_library_bake_stop(data))
+			break;
+	}
 	
 	if (data->writer) {
 		PTC_writer_free(data->writer);
@@ -263,13 +287,13 @@ static void cache_library_bake_startjob(void *customdata, short *stop, short *do
 		if (data->cachelib->eval_mode & CACHE_LIBRARY_EVAL_REALTIME) {
 			data->eval_ctx.mode = DAG_EVAL_VIEWPORT;
 			PTC_writer_archive_use_render(data->archive, false);
-			cache_library_bake_do(data, stop, do_update, progress);
+			cache_library_bake_do(data);
 		}
 		
 		if (data->cachelib->eval_mode & CACHE_LIBRARY_EVAL_RENDER) {
 			data->eval_ctx.mode = DAG_EVAL_RENDER;
 			PTC_writer_archive_use_render(data->archive, true);
-			cache_library_bake_do(data, stop, do_update, progress);
+			cache_library_bake_do(data);
 		}
 		
 	}
diff --git a/source/blender/pointcache/CMakeLists.txt b/source/blender/pointcache/CMakeLists.txt
index 5bac46b..52f62af 100644
--- a/source/blender/pointcache/CMakeLists.txt
+++ b/source/blender/pointcache/CMakeLists.txt
@@ -36,8 +36,6 @@ set(INC_SYS
 )
 
 set(SRC
-	intern/export.h
-	intern/export.cpp
 	intern/ptc_types.h
 	intern/ptc_types.cpp
 	intern/reader.h
diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index f1f2096..934b506 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -28,7 +28,6 @@
 
 #include "reader.h"
 #include "writer.h"
-#include "export.h"
 
 #include "ptc_types.h"
 
@@ -204,14 +203,6 @@ void PTC_write_sample(struct PTCWriter *_writer)
 	writer->write_sample();
 }
 
-void PTC_bake(struct Main *bmain, struct Scene *scene, struct EvaluationContext *evalctx,
-              PTCWriter *writer, int start_frame, int end_frame,
-              short *stop, short *do_update, float *progress)
-{
-	PTC::Exporter exporter(bmain, scene, evalctx, stop, do_update, progress);
-	exporter.bake(writer, start_frame, end_frame);
-}
-
 
 void PTC_reader_free(PTCReader *_reader)
 {
diff --git a/source/blender/pointcache/PTC_api.h b/source/blender/pointcache/PTC_api.h
index b6c3789..a4a126e 100644
--- a/source/blender/pointcache/PTC_api.h
+++ b/source/blender/pointcache/PTC_api.h
@@ -55,10 +55,6 @@ void PTC_error_handler_callback(PTCErrorCallback cb, void *userdata);
 void PTC_error_handler_reports(struct ReportList *reports);
 void PTC_error_handler_modifier(struct ModifierData *md);
 
-void PTC_bake(struct Main *bmain, struct Scene *scene, struct EvaluationContext *evalctx,
-              struct PTCWriter *writer, int start_frame, int end_frame,
-              short *stop, short *do_update, float *progress);
-
 /*** Archive ***/
 
 const char *PTC_get_default_archive_extension(void);
diff --git a/source/blender/pointcache/intern/export.cpp b/source/blend

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list