[Bf-blender-cvs] [699c280] alembic: Added a new "Modifiers" display mode for cache libraries, which reads the source cache and then applies modifiers afterward.
Lukas Tönne
noreply at git.blender.org
Sun May 3 19:21:09 CEST 2015
Commit: 699c280a3f474ed47c7fc861a41a01b9c8641381
Author: Lukas Tönne
Date: Sun May 3 19:19:43 2015 +0200
Branches: alembic
https://developer.blender.org/rB699c280a3f474ed47c7fc861a41a01b9c8641381
Added a new "Modifiers" display mode for cache libraries, which reads
the source cache and then applies modifiers afterward.
This only performs non-iterative modifiers, which don't require the
passage of time to work (e.g. shrinkwrap).
===================================================================
M source/blender/blenkernel/BKE_cache_library.h
M source/blender/blenkernel/intern/cache_library.c
M source/blender/blenkernel/intern/object_dupli.c
M source/blender/makesdna/DNA_cache_library_types.h
M source/blender/makesrna/intern/rna_cache_library.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_cache_library.h b/source/blender/blenkernel/BKE_cache_library.h
index 86dd1dc..435cd7b 100644
--- a/source/blender/blenkernel/BKE_cache_library.h
+++ b/source/blender/blenkernel/BKE_cache_library.h
@@ -98,7 +98,7 @@ typedef struct CacheProcessContext {
} CacheProcessContext;
typedef struct CacheProcessData {
- int lay;
+ unsigned int lay;
float mat[4][4];
struct DupliCache *dupcache;
} CacheProcessData;
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index cbb68e7..cbb3cbf 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -86,7 +86,7 @@ CacheLibrary *BKE_cache_library_add(Main *bmain, const char *name)
BLI_snprintf(cachelib->output_filepath, sizeof(cachelib->output_filepath), "//cache/%s.%s", basename, PTC_get_default_archive_extension());
cachelib->source_mode = CACHE_LIBRARY_SOURCE_SCENE;
- cachelib->display_mode = CACHE_LIBRARY_DISPLAY_RESULT;
+ cachelib->display_mode = CACHE_LIBRARY_DISPLAY_MODIFIERS;
cachelib->display_flag = CACHE_LIBRARY_DISPLAY_MOTION | CACHE_LIBRARY_DISPLAY_CHILDREN;
cachelib->render_flag = CACHE_LIBRARY_RENDER_MOTION | CACHE_LIBRARY_RENDER_CHILDREN;
cachelib->eval_mode = CACHE_LIBRARY_EVAL_REALTIME | CACHE_LIBRARY_EVAL_RENDER;
@@ -321,7 +321,7 @@ static bool has_active_cache(CacheLibrary *cachelib)
}
}
- if (cachelib->source_mode == CACHE_LIBRARY_SOURCE_CACHE) {
+ if (ELEM(cachelib->source_mode, CACHE_LIBRARY_SOURCE_CACHE, CACHE_LIBRARY_DISPLAY_MODIFIERS)) {
return true;
}
@@ -344,7 +344,7 @@ static struct PTCReaderArchive *find_active_cache(Scene *scene, CacheLibrary *ca
}
}
- if (!archive && cachelib->source_mode == CACHE_LIBRARY_SOURCE_CACHE) {
+ if (!archive && ELEM(cachelib->source_mode, CACHE_LIBRARY_SOURCE_CACHE, CACHE_LIBRARY_DISPLAY_MODIFIERS)) {
BKE_cache_archive_input_path(cachelib, filename, sizeof(filename));
archive = PTC_open_reader_archive(scene, filename);
}
@@ -1179,10 +1179,6 @@ static void shrinkwrap_process(ShrinkWrapCacheModifier *smd, CacheProcessContext
ShrinkWrapCacheData shrinkwrap;
- /* skip first step and potential backward steps */
- if (frame <= frame_prev)
- return;
-
if (!BKE_cache_modifier_find_strands(data->dupcache, ob, smd->hair_system, NULL, &strands))
return;
if (!BKE_cache_modifier_find_object(data->dupcache, smd->target, &target_data))
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 1574c4a..b652128 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -1717,12 +1717,26 @@ void BKE_dupli_cache_from_group(Scene *scene, Group *group, CacheLibrary *cachel
/* ------------------------------------------------------------------------- */
+static void object_dupli_cache_apply_modifiers(Object *ob, Scene *scene, eCacheLibrary_EvalMode eval_mode)
+{
+ CacheLibrary *cachelib = ob->cache_library;
+ int frame = scene->r.cfra;
+ CacheProcessData process_data;
+
+ process_data.lay = ob->lay;
+ copy_m4_m4(process_data.mat, ob->obmat);
+ process_data.dupcache = ob->dup_cache;
+
+ BKE_cache_process_dupli_cache(cachelib, &process_data, scene, ob->dup_group, (float)frame, (float)frame, eval_mode);
+}
+
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_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 || ob->cache_library->display_mode == CACHE_LIBRARY_DISPLAY_RESULT);
+ bool do_modifiers = ob->cache_library && ob->cache_library->display_mode == CACHE_LIBRARY_DISPLAY_MODIFIERS;
/* cache is a group duplicator feature only */
if (is_dupligroup && is_cached) {
@@ -1745,6 +1759,10 @@ void BKE_object_dupli_cache_update(Scene *scene, Object *ob, EvaluationContext *
if (!(ob->cache_library->flag & CACHE_LIBRARY_BAKING)) {
/* TODO at this point we could apply animation offset */
BKE_cache_read_dupli_cache(ob->cache_library, ob->dup_cache, scene, ob->dup_group, frame, eval_mode, true);
+
+ if (do_modifiers) {
+ object_dupli_cache_apply_modifiers(ob, scene, eval_mode);
+ }
}
ob->dup_cache->flag &= ~DUPCACHE_FLAG_DIRTY;
diff --git a/source/blender/makesdna/DNA_cache_library_types.h b/source/blender/makesdna/DNA_cache_library_types.h
index 02d73a7..bf15a4c 100644
--- a/source/blender/makesdna/DNA_cache_library_types.h
+++ b/source/blender/makesdna/DNA_cache_library_types.h
@@ -46,6 +46,7 @@ typedef enum eCacheLibrary_SourceMode {
typedef enum eCacheLibrary_DisplayMode {
CACHE_LIBRARY_DISPLAY_SOURCE = 0, /* display source data */
CACHE_LIBRARY_DISPLAY_RESULT = 1, /* display result data */
+ CACHE_LIBRARY_DISPLAY_MODIFIERS = 2, /* display input with modifiers */
} eCacheLibrary_DisplayMode;
typedef enum eCacheLibrary_EvalMode {
diff --git a/source/blender/makesrna/intern/rna_cache_library.c b/source/blender/makesrna/intern/rna_cache_library.c
index 86d7b3c..8120b4c 100644
--- a/source/blender/makesrna/intern/rna_cache_library.c
+++ b/source/blender/makesrna/intern/rna_cache_library.c
@@ -750,6 +750,7 @@ static void rna_def_cache_library(BlenderRNA *brna)
static EnumPropertyItem display_mode_items[] = {
{CACHE_LIBRARY_DISPLAY_SOURCE, "SOURCE", 0, "Source", "Display source data unmodified"},
+ {CACHE_LIBRARY_DISPLAY_MODIFIERS, "MODIFIERS", 0, "Modifiers", "Display source data with modifiers applied"},
{CACHE_LIBRARY_DISPLAY_RESULT, "RESULT", 0, "Result", "Display resulting data"},
{0, NULL, 0, NULL, NULL}
};
More information about the Bf-blender-cvs
mailing list