[Bf-blender-cvs] [f000702] gooseberry: Nicer default filename for cache library paths.
Lukas Tönne
noreply at git.blender.org
Mon Mar 23 13:02:11 CET 2015
Commit: f0007025325a6ca298007c1c7c9427789e7ffb41
Author: Lukas Tönne
Date: Mon Mar 2 18:17:02 2015 +0100
Branches: gooseberry
https://developer.blender.org/rBf0007025325a6ca298007c1c7c9427789e7ffb41
Nicer default filename for cache library paths.
This now appends a default extension based on the cache backend used.
At this point this is always Alembic (.abc) but would allow other
backend formats in the future.
===================================================================
M source/blender/blenkernel/intern/cache_library.c
M source/blender/pointcache/PTC_api.cpp
M source/blender/pointcache/PTC_api.h
M source/blender/pointcache/alembic/alembic.cpp
M source/blender/pointcache/intern/ptc_types.h
===================================================================
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 6850b91..bcd573f 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -54,10 +54,13 @@
CacheLibrary *BKE_cache_library_add(Main *bmain, const char *name)
{
CacheLibrary *cachelib;
+ char basename[MAX_NAME];
cachelib = BKE_libblock_alloc(bmain, ID_CL, name);
- BLI_strncpy(cachelib->filepath, "//cache/", sizeof(cachelib->filepath));
+ BLI_strncpy(basename, cachelib->id.name+2, sizeof(basename));
+ BLI_filename_make_safe(basename);
+ BLI_snprintf(cachelib->filepath, sizeof(cachelib->filepath), "//cache/%s.%s", basename, PTC_get_default_archive_extension());
return cachelib;
}
diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index bd2a75d..a744d54 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -93,6 +93,11 @@ void PTC_error_handler_modifier(struct ModifierData *md)
}
+const char *PTC_get_default_archive_extension(void)
+{
+ return PTC::Factory::alembic->get_default_extension().c_str();
+}
+
PTCWriterArchive *PTC_open_writer_archive(Scene *scene, const char *path)
{
return (PTCWriterArchive *)PTC::Factory::alembic->create_writer_archive(scene, path, NULL);
diff --git a/source/blender/pointcache/PTC_api.h b/source/blender/pointcache/PTC_api.h
index 2f2f67c..f232cf3 100644
--- a/source/blender/pointcache/PTC_api.h
+++ b/source/blender/pointcache/PTC_api.h
@@ -62,6 +62,8 @@ void PTC_bake(struct Main *bmain, struct Scene *scene, struct EvaluationContext
/*** Archive ***/
+const char *PTC_get_default_archive_extension(void);
+
struct PTCWriterArchive *PTC_open_writer_archive(struct Scene *scene, const char *path);
void PTC_close_writer_archive(struct PTCWriterArchive *archive);
diff --git a/source/blender/pointcache/alembic/alembic.cpp b/source/blender/pointcache/alembic/alembic.cpp
index ce43f78..b67fee8 100644
--- a/source/blender/pointcache/alembic/alembic.cpp
+++ b/source/blender/pointcache/alembic/alembic.cpp
@@ -29,6 +29,12 @@
namespace PTC {
class AbcFactory : public Factory {
+ const std::string &get_default_extension()
+ {
+ static std::string ext = "abc";
+ return ext;
+ }
+
WriterArchive *create_writer_archive(Scene *scene, const std::string &name, ErrorHandler *error_handler)
{
return new AbcWriterArchive(scene, name, error_handler);
diff --git a/source/blender/pointcache/intern/ptc_types.h b/source/blender/pointcache/intern/ptc_types.h
index 1c448ad..cbbe0c6 100644
--- a/source/blender/pointcache/intern/ptc_types.h
+++ b/source/blender/pointcache/intern/ptc_types.h
@@ -141,6 +141,7 @@ protected:
};
struct Factory {
+ virtual const std::string &get_default_extension() = 0;
virtual WriterArchive *create_writer_archive(Scene *scene, const std::string &name, ErrorHandler *error_handler) = 0;
virtual ReaderArchive *create_reader_archive(Scene *scene, const std::string &name, ErrorHandler *error_handler) = 0;
More information about the Bf-blender-cvs
mailing list