[Bf-blender-cvs] [af12668] alembic: Improved Alembic archive examination tool for cache libraries.
Lukas Tönne
noreply at git.blender.org
Tue Apr 21 13:37:54 CEST 2015
Commit: af12668c28dab3a36bacc02db24587235691694d
Author: Lukas Tönne
Date: Tue Apr 21 13:35:25 2015 +0200
Branches: alembic
https://developer.blender.org/rBaf12668c28dab3a36bacc02db24587235691694d
Improved Alembic archive examination tool for cache libraries.
A new panel is added for showing the structure and contents of archives
of a cache library (instead of simply dumping on the terminal). The
archive structure is stored in a lightweight tree structure, mirroring
the hierarchy of objects and properties in Alembic. These
object/property nodes can be expanded individually for easier navigation
through the archive.
===================================================================
M release/scripts/startup/bl_ui/properties_object.py
M source/blender/blenkernel/BKE_cache_library.h
M source/blender/blenkernel/intern/cache_library.c
M source/blender/blenloader/intern/readfile.c
M source/blender/editors/io/io_cache_library.c
M source/blender/makesdna/DNA_cache_library_types.h
M source/blender/makesrna/RNA_access.h
M source/blender/makesrna/intern/rna_cache_library.c
M source/blender/pointcache/PTC_api.cpp
M source/blender/pointcache/PTC_api.h
M source/blender/pointcache/alembic/abc_info.cpp
M source/blender/pointcache/alembic/abc_reader.cpp
M source/blender/pointcache/alembic/abc_reader.h
M source/blender/pointcache/alembic/alembic.h
M source/blender/pointcache/intern/reader.h
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index 7e61ded..8071b6a 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -501,6 +501,67 @@ class OBJECT_PT_cache_library(ObjectButtonsPanel, Panel):
layout.prop(md, "use_double_sided")
+class OBJECT_PT_cache_archive_info(ObjectButtonsPanel, Panel):
+ bl_label = "Cache Archive Info"
+ bl_options = {'DEFAULT_CLOSED'}
+
+ @classmethod
+ def poll(cls, context):
+ ob = context.object
+ return (ob and ob.dupli_type == 'GROUP' and ob.dupli_group and ob.cache_library)
+
+ def draw_node_structure(self, context, layout, node, indent):
+ row = layout.row()
+ for i in range(indent):
+ row.label(text="", icon='BLANK1')
+
+ if not node.child_nodes:
+ row.label(text="", icon='DOT')
+ elif not node.expand:
+ row.prop(node, "expand", text="", icon='DISCLOSURE_TRI_RIGHT', icon_only=True, emboss=False)
+ else:
+ row.prop(node, "expand", text="", icon='DISCLOSURE_TRI_DOWN', icon_only=True, emboss=False)
+
+ for child in node.child_nodes:
+ self.draw_node_structure(context, layout, child, indent + 1)
+
+
+ def draw_node_info(self, context, layout, node):
+ row = layout.row(align=True)
+ row.prop(node, "name", text="")
+ row.prop(node, "type", text="")
+
+ if node.expand:
+ for child in node.child_nodes:
+ self.draw_node_info(context, layout, child)
+
+ def draw(self, context):
+ ob = context.object
+ cachelib = ob.cache_library
+
+ layout = self.layout
+ row = layout.row()
+
+ props = row.operator("cachelibrary.archive_info", text="Input", icon='QUESTION')
+ props.filepath = cachelib.input_filepath
+ props.use_cache_info = True
+
+ props = row.operator("cachelibrary.archive_info", text="Output", icon='QUESTION')
+ props.filepath = cachelib.output_filepath
+ props.use_cache_info = True
+
+ layout.separator()
+
+ info = cachelib.archive_info
+ if info:
+ layout.prop(info, "filepath")
+
+ if info.root_node:
+ row = layout.row()
+ self.draw_node_structure(context, row.column(), info.root_node, 0)
+ self.draw_node_info(context, row.column(), info.root_node)
+
+
class OBJECT_PT_relations_extras(ObjectButtonsPanel, Panel):
bl_label = "Relations Extras"
bl_options = {'DEFAULT_CLOSED'}
diff --git a/source/blender/blenkernel/BKE_cache_library.h b/source/blender/blenkernel/BKE_cache_library.h
index 9edd8aa..0716b21 100644
--- a/source/blender/blenkernel/BKE_cache_library.h
+++ b/source/blender/blenkernel/BKE_cache_library.h
@@ -169,6 +169,8 @@ 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);
+/* ========================================================================= */
+
typedef struct CacheEffectorInstance {
struct CacheEffectorInstance *next, *prev;
@@ -206,4 +208,15 @@ int BKE_cache_effectors_get(struct CacheEffector *effectors, int max, struct Cac
void BKE_cache_effectors_free(struct CacheEffector *effectors, int tot);
int BKE_cache_effectors_eval(struct CacheEffector *effectors, int tot, struct CacheEffectorPoint *point, struct CacheEffectorResult *result);
+/* ========================================================================= */
+
+struct CacheArchiveInfo *BKE_cache_archive_info_new(void);
+void BKE_cache_archive_info_free(struct CacheArchiveInfo *info);
+void BKE_cache_archive_info_clear(struct CacheArchiveInfo *info);
+
+struct CacheArchiveInfoNode *BKE_cache_archive_info_find_node(struct CacheArchiveInfo *info, struct CacheArchiveInfoNode *parent,
+ eCacheArchiveInfoNode_Type type, const char *name);
+struct CacheArchiveInfoNode *BKE_cache_archive_info_add_node(struct CacheArchiveInfo *info, struct CacheArchiveInfoNode *parent,
+ eCacheArchiveInfoNode_Type type, const char *name);
+
#endif
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 7b49b08..99b6e9d 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -109,6 +109,8 @@ CacheLibrary *BKE_cache_library_copy(CacheLibrary *cachelib)
}
}
+ cachelibn->archive_info = NULL;
+
if (cachelib->id.lib) {
BKE_id_lib_local_paths(G.main, cachelib->id.lib, &cachelibn->id);
}
@@ -119,6 +121,9 @@ CacheLibrary *BKE_cache_library_copy(CacheLibrary *cachelib)
void BKE_cache_library_free(CacheLibrary *cachelib)
{
BKE_cache_modifier_clear(cachelib);
+
+ if (cachelib->archive_info)
+ BKE_cache_archive_info_free(cachelib->archive_info);
}
void BKE_cache_library_unlink(CacheLibrary *UNUSED(cachelib))
@@ -1014,3 +1019,124 @@ void BKE_cache_modifier_init(void)
cache_modifier_type_set(eCacheModifierType_HairSimulation, &cacheModifierType_HairSimulation);
cache_modifier_type_set(eCacheModifierType_ForceField, &cacheModifierType_ForceField);
}
+
+/* ========================================================================= */
+
+#if 0
+static unsigned int hash_combine(unsigned int kx, unsigned int ky)
+{
+#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
+
+ unsigned int a, b, c;
+
+ a = b = c = 0xdeadbeef + (2 << 2) + 13;
+ a += kx;
+ b += ky;
+
+ c ^= b; c -= rot(b,14);
+ a ^= c; a -= rot(c,11);
+ b ^= a; b -= rot(a,25);
+ c ^= b; c -= rot(b,16);
+ a ^= c; a -= rot(c,4);
+ b ^= a; b -= rot(a,14);
+ c ^= b; c -= rot(b,24);
+
+ return c;
+
+#undef rot
+}
+
+static unsigned int cache_archive_info_node_hash(const void *key)
+{
+ const CacheArchiveInfoNode *node = key;
+
+ unsigned int hash = hash_combine(BLI_ghashutil_strhash(node->name), BLI_ghashutil_inthash(node->type));
+ if (node->parent_hash != 0)
+ hash = hash_combine(hash, node->parent_hash);
+ return hash;
+}
+
+static bool cache_archive_info_node_cmp(const CacheArchiveInfoNode *a, const CacheArchiveInfoNode *b)
+{
+ if (a->parent_hash != b->parent_hash)
+ return true;
+ else if (a->type != b->type)
+ return true;
+ else if (!STREQ(a->name, b->name))
+ return true;
+ else
+ return false;
+}
+#endif
+
+static void cache_archive_info_node_free(CacheArchiveInfoNode *node)
+{
+ CacheArchiveInfoNode *child, *child_next;
+ for (child = node->child_nodes.first; child; child = child_next) {
+ child_next = child->next;
+ cache_archive_info_node_free(child);
+ }
+
+ MEM_freeN(node);
+}
+
+CacheArchiveInfo *BKE_cache_archive_info_new(void)
+{
+ CacheArchiveInfo *info = MEM_callocN(sizeof(CacheArchiveInfo), "cache archive info");
+
+ return info;
+}
+
+void BKE_cache_archive_info_free(CacheArchiveInfo *info)
+{
+ if (info) {
+ if (info->root_node)
+ cache_archive_info_node_free(info->root_node);
+
+ MEM_freeN(info);
+ }
+}
+
+void BKE_cache_archive_info_clear(CacheArchiveInfo *info)
+{
+ if (info->root_node) {
+ cache_archive_info_node_free(info->root_node);
+ info->root_node = NULL;
+ }
+}
+
+CacheArchiveInfoNode *BKE_cache_archive_info_find_node(CacheArchiveInfo *info, CacheArchiveInfoNode *parent,
+ eCacheArchiveInfoNode_Type type, const char *name)
+{
+ if (parent) {
+ CacheArchiveInfoNode *child;
+ for (child = parent->child_nodes.first; child; child = child->next) {
+ if (STREQ(child->name, name) && child->type == type)
+ return child;
+ }
+ }
+ else if (info->root_node) {
+ if (STREQ(info->root_node->name, name) && info->root_node->type == type)
+ return info->root_node;
+ }
+ return NULL;
+}
+
+CacheArchiveInfoNode *BKE_cache_archive_info_add_node(CacheArchiveInfo *info, CacheArchiveInfoNode *parent,
+ eCacheArchiveInfoNode_Type type, const char *name)
+{
+ CacheArchiveInfoNode *node;
+
+ BLI_assert(parent || !info->root_node);
+
+ node = MEM_callocN(sizeof(CacheArchiveInfoNode), "cache archive info node");
+ node->type = type;
+ BLI_strncpy(node->name, name, sizeof(node->name));
+
+ if (parent)
+ BLI_addtail(&parent->child_nodes, node);
+ else
+ info->root_node = node;
+
+ return node;
+}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 8bd8411..5bad669 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2049,6 +2049,8 @@ static void direct_link_cache_modifiers(FileData *fd, ListBase *modifiers)
static void direct_link_cache_library(FileData *fd, CacheLibrary *cachelib)
{
direct_link_cache_modifiers(fd, &cachelib->modifiers);
+
+ cachelib->archive_info = NULL; /* runtime */
}
diff --git a/source/blender/editors/io/io_cache_library.c b/source/blender/editors/io/io_cache_library.c
index 090d3a5..2dcadcb 100644
--- a/source/blender/editors/io/io_cache_library.c
+++ b/source/blender/editors/io/io_cache_library.c
@@ -578,6 +578,7 @@ static int cache_library_archive_info_exec(bContext *C, wmOperator *op)
CacheLibrary *cachelib = ob->cache_library;
Scene *scene = CTX_data_scene(C);
+ const bool use_cache_info = RNA_boolean_get(op->ptr, "use_cache_info");
const bool use_stdout = RNA_boolean_get(op->ptr, "use_stdout");
const bool use_popup = RNA_boolean_get(op->ptr, "use_popup");
const bool use_clipboard = RNA_boolean_get(op->ptr, "use_clipboard");
@@ -596,8 +597,19 @@ static int cache_library_archive_info_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ if (use_cache_info) {
+ if (cachelib->archive_info)
+ BKE_cache_archive_info_clear(cachelib->archive_info);
+ else
+ cachelib->archive_info = BKE_cache_archive_info_new();
+
+ BLI_strncpy(cachelib->archive_info->filepath, filename, sizeof(cachelib->archive_info->filepath));
+
+ PTC_get_archive_i
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list