Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorLukas Tönne <lukas.toenne@gmail.com>2015-03-19 21:19:23 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2015-03-19 21:19:23 +0300
commit0a7a4d504b6790d8768d8e86bf0e8765c39aec71 (patch)
tree50c7b7deee178cc047acba1d1fffb88b66d49e35 /source
parent08017eef6238006f27068c8eaead3f8bd2a0d719 (diff)
Allow cache libraries to store both render and realtime (viewport) data.
This is the default now. It should make workflow a lot more foolproof and convenient, since having only one of these modes active at a time very easily leads to broken renders and confusing situations. The problem is mostly due to the complicated way the depsgraph layer feature is used to handle duplicator visibility. The duplicator is declared as a child of its group's objects (even though no real dependency exists!), so that a visible duplicator triggers updates of invisible group objects, making instances of hidden groups possible. However, dupli caches have to disable this dependency in order to avoid unnecessary costly updates in hidden layers which are overridden by cached data anyway. At the point where these dependencies are created the evaluation context is unknown though, which means we cannot distinguish between render and realtime evaluation for the purpose of cache reading ...
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/cache_library.c6
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c2
-rw-r--r--source/blender/editors/io/io_cache_library.c46
-rw-r--r--source/blender/makesdna/DNA_cache_library_types.h4
-rw-r--r--source/blender/makesrna/intern/rna_cache_library.c4
5 files changed, 39 insertions, 23 deletions
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index bdb7a8a605e..c4dc4dadd26 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -69,6 +69,8 @@ CacheLibrary *BKE_cache_library_add(Main *bmain, const char *name)
BLI_filename_make_safe(basename);
BLI_snprintf(cachelib->filepath, sizeof(cachelib->filepath), "//cache/%s.%s", basename, PTC_get_default_archive_extension());
+ cachelib->eval_mode = CACHE_LIBRARY_EVAL_REALTIME | CACHE_LIBRARY_EVAL_RENDER;
+
return cachelib;
}
@@ -658,7 +660,7 @@ bool BKE_cache_read_dupligroup(Scene *scene, float frame, eCacheLibrary_EvalMode
if (!dupcache || !dupgroup || !cachelib)
return false;
- if (cachelib->eval_mode != eval_mode)
+ if (!(cachelib->eval_mode & eval_mode))
return false;
BKE_cache_archive_path(cachelib->filepath, (ID *)cachelib, cachelib->id.lib, filename, sizeof(filename));
@@ -681,7 +683,7 @@ bool BKE_cache_read_dupligroup(Scene *scene, float frame, eCacheLibrary_EvalMode
void BKE_cache_library_dag_recalc_tag(EvaluationContext *eval_ctx, Main *bmain)
{
#if 0
- eCacheLibrary_EvalMode eval_mode = (eval_ctx->mode == DAG_EVAL_RENDER) ? CACHE_LIBRARY_EVAL_RENDER : CACHE_LIBRARY_EVAL_VIEWPORT;
+ eCacheLibrary_EvalMode eval_mode = (eval_ctx->mode == DAG_EVAL_RENDER) ? CACHE_LIBRARY_EVAL_RENDER : CACHE_LIBRARY_EVAL_REALTIME;
CacheLibrary *cachelib;
FOREACH_CACHELIB_READ(bmain, cachelib, eval_mode) {
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index d1dbf288609..fa4c20abf06 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -1394,7 +1394,7 @@ static DupliObject *dupli_cache_add_object(DupliCache *dupcache)
void BKE_object_dupli_cache_update(Scene *scene, Object *ob, EvaluationContext *eval_ctx, float frame)
{
- const eCacheLibrary_EvalMode eval_mode = eval_ctx->mode == DAG_EVAL_RENDER ? CACHE_LIBRARY_EVAL_RENDER : CACHE_LIBRARY_EVAL_VIEWPORT;
+ 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->transflag & OB_DUPLI_READ_CACHE) && ob->cache_library;
diff --git a/source/blender/editors/io/io_cache_library.c b/source/blender/editors/io/io_cache_library.c
index 1cf7fda270f..edb1901f9ba 100644
--- a/source/blender/editors/io/io_cache_library.c
+++ b/source/blender/editors/io/io_cache_library.c
@@ -260,11 +260,29 @@ static void cache_library_bake_freejob(void *customdata)
MEM_freeN(data);
}
-static void cache_library_bake_startjob(void *customdata, short *stop, short *do_update, float *progress)
+static void cache_library_bake_do(CacheLibraryBakeJob *data, short *stop, short *do_update, float *progress)
{
- CacheLibraryBakeJob *data= (CacheLibraryBakeJob *)customdata;
Scene *scene = data->scene;
int start_frame, end_frame;
+
+ data->writer = PTC_writer_dupligroup(data->group->id.name, &data->eval_ctx, scene, data->group);
+ PTC_writer_init(data->writer, data->archive);
+
+ /* 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);
+
+ if (data->writer) {
+ PTC_writer_free(data->writer);
+ data->writer = NULL;
+ }
+}
+
+static void cache_library_bake_startjob(void *customdata, short *stop, short *do_update, float *progress)
+{
+ CacheLibraryBakeJob *data = (CacheLibraryBakeJob *)customdata;
+ Scene *scene = data->scene;
char filename[FILE_MAX];
data->stop = stop;
@@ -274,28 +292,24 @@ static void cache_library_bake_startjob(void *customdata, short *stop, short *do
data->origfra = scene->r.cfra;
data->origframelen = scene->r.framelen;
scene->r.framelen = 1.0f;
- memset(&data->eval_ctx, 0, sizeof(EvaluationContext));
- /* use evaluation mode defined by the cachelib */
- if (data->cachelib->eval_mode == CACHE_LIBRARY_EVAL_VIEWPORT) {
- data->eval_ctx.mode = DAG_EVAL_VIEWPORT;
- }
- else {
- data->eval_ctx.mode = DAG_EVAL_RENDER;
- }
BKE_cache_archive_path(data->cachelib->filepath, (ID *)data->cachelib, data->cachelib->id.lib, filename, sizeof(filename));
data->archive = PTC_open_writer_archive(scene, filename);
if (data->archive) {
- data->writer = PTC_writer_dupligroup(data->group->id.name, &data->eval_ctx, scene, data->group);
- PTC_writer_init(data->writer, data->archive);
G.is_break = false;
- /* 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);
+ if (data->cachelib->eval_mode & CACHE_LIBRARY_EVAL_REALTIME) {
+ data->eval_ctx.mode = DAG_EVAL_VIEWPORT;
+ cache_library_bake_do(data, stop, do_update, progress);
+ }
+
+ if (data->cachelib->eval_mode & CACHE_LIBRARY_EVAL_RENDER) {
+ data->eval_ctx.mode = DAG_EVAL_RENDER;
+ cache_library_bake_do(data, stop, do_update, progress);
+ }
+
}
*do_update = true;
diff --git a/source/blender/makesdna/DNA_cache_library_types.h b/source/blender/makesdna/DNA_cache_library_types.h
index baa5bee7512..114b86952a9 100644
--- a/source/blender/makesdna/DNA_cache_library_types.h
+++ b/source/blender/makesdna/DNA_cache_library_types.h
@@ -87,8 +87,8 @@ typedef struct CacheLibrary {
//} eCacheLibrary_Flag;
typedef enum eCacheLibrary_EvalMode {
- CACHE_LIBRARY_EVAL_VIEWPORT = 0, /* evaluate data with viewport settings */
- CACHE_LIBRARY_EVAL_RENDER = 1, /* evaluate data with render settings */
+ CACHE_LIBRARY_EVAL_REALTIME = (1 << 0), /* evaluate data with realtime settings */
+ CACHE_LIBRARY_EVAL_RENDER = (1 << 1), /* evaluate data with render settings */
} eCacheLibrary_EvalMode;
#endif
diff --git a/source/blender/makesrna/intern/rna_cache_library.c b/source/blender/makesrna/intern/rna_cache_library.c
index 83a47fe03af..975201f31f8 100644
--- a/source/blender/makesrna/intern/rna_cache_library.c
+++ b/source/blender/makesrna/intern/rna_cache_library.c
@@ -286,7 +286,7 @@ static void rna_def_cache_library(BlenderRNA *brna)
PropertyRNA *prop, *parm;
static EnumPropertyItem eval_mode_items[] = {
- {CACHE_LIBRARY_EVAL_VIEWPORT, "VIEWPORT", ICON_RESTRICT_VIEW_OFF, "Viewport", "Evaluate data with viewport settings"},
+ {CACHE_LIBRARY_EVAL_REALTIME, "REALTIME", ICON_RESTRICT_VIEW_OFF, "Realtime", "Evaluate data with realtime settings"},
{CACHE_LIBRARY_EVAL_RENDER, "RENDER", ICON_RESTRICT_RENDER_OFF, "Render", "Evaluate data with render settings"},
{0, NULL, 0, NULL, NULL}
};
@@ -303,7 +303,7 @@ static void rna_def_cache_library(BlenderRNA *brna)
prop = RNA_def_property(srna, "eval_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "eval_mode");
RNA_def_property_enum_items(prop, eval_mode_items);
- RNA_def_property_enum_default(prop, CACHE_LIBRARY_EVAL_VIEWPORT);
+ RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_ui_text(prop, "Evaluation Mode", "Mode to use when evaluating data");
RNA_def_property_update(prop, 0, "rna_CacheLibrary_update");