[Bf-blender-cvs] [523ea57] alembic: Make size calculation in cache archive info operators an optional extra step.
Lukas Tönne
noreply at git.blender.org
Wed Apr 22 15:50:30 CEST 2015
Commit: 523ea570e7e33afba1e05a8a8f8c93e1bec808d3
Author: Lukas Tönne
Date: Wed Apr 22 15:48:46 2015 +0200
Branches: alembic
https://developer.blender.org/rB523ea570e7e33afba1e05a8a8f8c93e1bec808d3
Make size calculation in cache archive info operators an optional extra
step.
This calculate can take a bit of time (some seconds to a minute in
tests), due to having to loop through all array samples. In many cases
only the basic structure is wanted.
===================================================================
M release/scripts/startup/bl_ui/properties_object.py
M source/blender/blenkernel/intern/cache_library.c
M source/blender/editors/io/io_cache_library.c
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 5e231d4..cb88f38 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -549,7 +549,7 @@ class OBJECT_PT_cache_archive_info(ObjectButtonsPanel, Panel):
layout.label(" ")
if column == 3:
size = int(node.bytes_size)
- layout.label(sizeof_fmt(size))
+ layout.label(sizeof_fmt(size) if size >= 0 else "-")
if column == 4:
if node.type in {'SCALAR_PROPERTY', 'ARRAY_PROPERTY'}:
layout.prop(node, "datatype", text="")
@@ -562,7 +562,7 @@ class OBJECT_PT_cache_archive_info(ObjectButtonsPanel, Panel):
layout.label(" ")
if column == 6:
if node.type in {'ARRAY_PROPERTY'}:
- layout.prop(node, "array_size", text="")
+ layout.label(node.array_size if node.array_size >= 0 else "-")
else:
layout.label(" ")
@@ -573,22 +573,28 @@ class OBJECT_PT_cache_archive_info(ObjectButtonsPanel, Panel):
def draw(self, context):
ob = context.object
cachelib = ob.cache_library
+ info = cachelib.archive_info
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:
+ row = layout.row()
+ row.enabled = bool(info.filepath)
+ props = layout.operator("cachelibrary.archive_info", text="Calculate Size", icon='FILE_REFRESH')
+ props.filepath = info.filepath
+ props.use_cache_info = True
+ props.calc_bytes_size = True
+
+ layout.separator()
+
layout.prop(info, "filepath")
if info.root_node:
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 99b6e9d..81b9967 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -1133,6 +1133,10 @@ CacheArchiveInfoNode *BKE_cache_archive_info_add_node(CacheArchiveInfo *info, Ca
node->type = type;
BLI_strncpy(node->name, name, sizeof(node->name));
+ /* these values are only optionally calculated, -1 indicates unknown */
+ node->bytes_size = -1;
+ node->array_size = -1;
+
if (parent)
BLI_addtail(&parent->child_nodes, node);
else
diff --git a/source/blender/editors/io/io_cache_library.c b/source/blender/editors/io/io_cache_library.c
index 2dcadcb..a35402c 100644
--- a/source/blender/editors/io/io_cache_library.c
+++ b/source/blender/editors/io/io_cache_library.c
@@ -579,6 +579,7 @@ static int cache_library_archive_info_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
const bool use_cache_info = RNA_boolean_get(op->ptr, "use_cache_info");
+ const bool calc_bytes_size = RNA_boolean_get(op->ptr, "calc_bytes_size");
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");
@@ -605,7 +606,7 @@ static int cache_library_archive_info_exec(bContext *C, wmOperator *op)
BLI_strncpy(cachelib->archive_info->filepath, filename, sizeof(cachelib->archive_info->filepath));
- PTC_get_archive_info_nodes(archive, cachelib->archive_info);
+ PTC_get_archive_info_nodes(archive, cachelib->archive_info, calc_bytes_size);
}
if (use_stdout) {
@@ -641,6 +642,7 @@ void CACHELIBRARY_OT_archive_info(wmOperatorType *ot)
RNA_def_string(ot->srna, "filepath", NULL, FILE_MAX, "File Path", "Path to the cache archive");
RNA_def_boolean(ot->srna, "use_cache_info", false, "Use Cache Library Info", "Store info in the cache library");
+ RNA_def_boolean(ot->srna, "calc_bytes_size", false, "Calculate Size", "Calculate overall size of nodes in bytes (can take a while)");
RNA_def_boolean(ot->srna, "use_stdout", false, "Use stdout", "Print info in standard output");
RNA_def_boolean(ot->srna, "use_popup", false, "Show Popup", "Display archive info in a popup");
RNA_def_boolean(ot->srna, "use_clipboard", false, "Copy to Clipboard", "Copy archive info to the clipboard");
diff --git a/source/blender/makesrna/intern/rna_cache_library.c b/source/blender/makesrna/intern/rna_cache_library.c
index 521f2d5..7b286a7 100644
--- a/source/blender/makesrna/intern/rna_cache_library.c
+++ b/source/blender/makesrna/intern/rna_cache_library.c
@@ -237,7 +237,7 @@ static int rna_HairSimulationCacheModifier_hair_system_poll(PointerRNA *ptr, Poi
static void rna_CacheArchiveInfoNode_bytes_size_get(PointerRNA *ptr, char *value)
{
CacheArchiveInfoNode *node = ptr->data;
- BLI_snprintf(value, MAX_NAME, "%lu", node->bytes_size);
+ BLI_snprintf(value, MAX_NAME, "%lld", (long long int)node->bytes_size);
}
static int rna_CacheArchiveInfoNode_bytes_size_length(PointerRNA *ptr)
@@ -245,7 +245,7 @@ static int rna_CacheArchiveInfoNode_bytes_size_length(PointerRNA *ptr)
char buf[MAX_NAME];
/* theoretically could do a dummy BLI_snprintf here, but BLI does not allow NULL buffer ... */
CacheArchiveInfoNode *node = ptr->data;
- return BLI_snprintf(buf, sizeof(buf), "%lu", node->bytes_size);
+ return BLI_snprintf(buf, sizeof(buf), "%lld", (long long int)node->bytes_size);
}
#else
diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index 437b1de..77f378f 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -241,10 +241,10 @@ void PTC_get_archive_info_stream(PTCReaderArchive *_archive, void (*stream)(void
archive->get_info_stream(stream, userdata);
}
-void PTC_get_archive_info_nodes(PTCReaderArchive *_archive, struct CacheArchiveInfo *info)
+void PTC_get_archive_info_nodes(PTCReaderArchive *_archive, struct CacheArchiveInfo *info, bool calc_bytes_size)
{
PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
- archive->get_info_nodes(info);
+ archive->get_info_nodes(info, calc_bytes_size);
}
diff --git a/source/blender/pointcache/PTC_api.h b/source/blender/pointcache/PTC_api.h
index dac432d..4437015 100644
--- a/source/blender/pointcache/PTC_api.h
+++ b/source/blender/pointcache/PTC_api.h
@@ -82,7 +82,7 @@ PTCReadSampleResult PTC_read_sample(struct PTCReader *reader, float frame);
PTCReadSampleResult PTC_test_sample(struct PTCReader *reader, float frame);
void PTC_get_archive_info_stream(struct PTCReaderArchive *archive, void (*stream)(void *, const char *), void *userdata);
-void PTC_get_archive_info_nodes(struct PTCReaderArchive *_archive, struct CacheArchiveInfo *info);
+void PTC_get_archive_info_nodes(struct PTCReaderArchive *_archive, struct CacheArchiveInfo *info, bool calc_bytes_size);
struct PTCWriter *PTC_writer_dupligroup(const char *name, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Group *group, struct CacheLibrary *cachelib);
struct PTCWriter *PTC_writer_duplicache(const char *name, struct Group *group, struct DupliCache *dupcache, int datatypes, bool do_sim_debug);
diff --git a/source/blender/pointcache/alembic/abc_info.cpp b/source/blender/pointcache/alembic/abc_info.cpp
index 721623e..589987b 100644
--- a/source/blender/pointcache/alembic/abc_info.cpp
+++ b/source/blender/pointcache/alembic/abc_info.cpp
@@ -283,38 +283,41 @@ void abc_archive_info_stream(IArchive &archive, void (*stream)(void *, const cha
/* ========================================================================= */
-static void info_nodes_properties(CacheArchiveInfo *info, ICompoundProperty, CacheArchiveInfoNode *parent);
+static void info_nodes_properties(CacheArchiveInfo *info, ICompoundProperty, CacheArchiveInfoNode *parent, bool calc_bytes_size);
template <class PROP>
-static void info_nodes_array_property(CacheArchiveInfo *info, PROP iProp, CacheArchiveInfoNode *parent)
+static void info_nodes_array_property(CacheArchiveInfo *info, PROP iProp, CacheArchiveInfoNode *parent, bool calc_bytes_size)
{
CacheArchiveInfoNode *node = BKE_cache_archive_info_add_node(info, parent, eCacheArchiveInfoNode_Type_ArrayProperty, iProp.getName().c_str());
index_t num_samples = iProp.getNumSamples();
- size_t max_array_size = 0;
- size_t tot_array_size = 0;
- for (index_t i = 0; i < num_samples; ++i) {
- AbcA::ArraySamplePtr samp;
- iProp.get(samp, ISampleSelector(i));
- size_t array_size = samp->size();
- max_array_size = std::max(max_array_size, array_size);
- tot_array_size += array_size;
- }
const DataType &datatype = iProp.getDataType();
node->num_samples = num_samples;
BLI_strncpy(node->datatype_name, PODName(datatype.getPod()), sizeof(node->datatype_name));
node->datatype_extent = (short)datatype.getExtent();
- node->bytes_size = datatype.getNumBytes() * tot_array_size;
- node->array_size = max_array_size;
- if (parent)
- parent->bytes_size += node->bytes_size;
+ if (calc_bytes_size) {
+ size_t max_array_size = 0;
+ size_t tot_array_size = 0;
+ for (index_t i = 0; i < num_samples; ++i) {
+ AbcA::ArraySamplePtr samp;
+ iProp.get(samp, ISampleSelector(i));
+ size_t array_size = samp->size();
+ max_array_size = std::max(max_array_size, array_size);
+ tot_array_size += array_size;
+ }
+ node->bytes_size = datatype.getNumBytes() * tot_array_size;
+ node->array_size = max_array_size;
+
+ if (parent)
+ parent->bytes_size += node->bytes_size;
+ }
}
template <class PROP>
-static void info_nodes_scalar_property(CacheArchiveInfo *info, PROP iProp, CacheArchiveInfoNode *parent)
+static void info_nodes_scalar_property(CacheArchiveInfo *info, PROP iProp, CacheArchiveInfoNode *parent, bool calc_bytes_size)
{
CacheArchiveInfoNode *node = BKE_cache_archive_info_a
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list