[Bf-blender-cvs] [d8c3a95] alembic_basic_io: Add a data block for easier handling of references to an Alembic archive.

Kévin Dietrich noreply at git.blender.org
Wed Jun 8 15:02:52 CEST 2016


Commit: d8c3a95d12e89bd2348432115098aeb2e2de1f7e
Author: Kévin Dietrich
Date:   Wed Jun 8 15:00:56 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rBd8c3a95d12e89bd2348432115098aeb2e2de1f7e

Add a data block for easier handling of references to an Alembic
archive.

For now this ID-block only stores the filepath of the archive and it is
referenced by the Mesh Sequence Cache modifier and the Transform Cache
constraint.

The data block itself is called CacheFile for it to stay generic and be
reused for other file types other than Alembic files (similar to images
basically).

===================================================================

M	release/scripts/startup/bl_ui/properties_constraint.py
M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/alembic/intern/abc_object.cc
M	source/blender/alembic/intern/abc_object.h
M	source/blender/alembic/intern/alembic_capi.cc
M	source/blender/blenkernel/BKE_library.h
M	source/blender/blenkernel/BKE_main.h
M	source/blender/blenkernel/intern/constraint.c
M	source/blender/blenkernel/intern/idcode.c
M	source/blender/blenkernel/intern/library.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/blentranslation/BLT_translation.h
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/io/CMakeLists.txt
A	source/blender/editors/io/io_cache.c
A	source/blender/editors/io/io_cache.h
M	source/blender/editors/io/io_ops.c
M	source/blender/editors/object/object_constraint.c
M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/makesdna/DNA_ID.h
M	source/blender/makesdna/DNA_constraint_types.h
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_ID.c
M	source/blender/makesrna/intern/rna_constraint.c
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_main.c
M	source/blender/makesrna/intern/rna_main_api.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/makesrna/intern/rna_ui_api.c
M	source/blender/modifiers/intern/MOD_meshsequencecache.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_constraint.py b/release/scripts/startup/bl_ui/properties_constraint.py
index 6ae2c8b..6cfcd68 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -881,7 +881,7 @@ class ConstraintButtonsPanel:
         layout.operator("clip.constraint_to_fcurve")
 
     def TRANSFORMCACHE(self, context, layout, con):
-        layout.prop(con, "filepath")
+        layout.template_cache_file(con, "cache_file")
         layout.prop(con, "abc_object_path")
         layout.prop(con, "scale")
 
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index d5f3882..5c14cea 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -223,7 +223,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         row.prop(md, "flip_axis")
 
     def MESH_SEQUENCE_CACHE(self, layout, ob, md):
-        layout.prop(md, "filepath")
+        layout.template_cache_file(md, "cache_file")
         layout.prop(md, "abc_object_path")
 
     def CAST(self, layout, ob, md):
diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc
index 3376a22..80d27ff 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -403,7 +403,7 @@ void AbcObjectReader::readObjectMatrix(const float time)
 	if (!schema.isConstant()) {
 		bConstraint *con = BKE_constraint_add_for_object(m_object, NULL, CONSTRAINT_TYPE_TRANSFORMCACHE);
 		bTransformCacheConstraint *data = static_cast<bTransformCacheConstraint *>(con->data);
-		BLI_strncpy(data->filepath, m_iobject.getArchive().getName().c_str(), 1024);
+		data->cache_file = m_settings->cache_file;
 		BLI_strncpy(data->abc_object_path, m_iobject.getFullName().c_str(), 1024);
 		data->scale = m_settings->scale;
 	}
@@ -416,7 +416,7 @@ void AbcObjectReader::addDefaultModifier(Main *bmain) const
 
 	MeshSeqCacheModifierData *mcmd = reinterpret_cast<MeshSeqCacheModifierData *>(md);
 
-	BLI_strncpy(mcmd->filepath, m_iobject.getArchive().getName().c_str(), 1024);
+	mcmd->cache_file = m_settings->cache_file;
 	BLI_strncpy(mcmd->abc_object_path, m_iobject.getFullName().c_str(), 1024);
 	mcmd->is_sequence = m_settings->is_sequence;
 
diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h
index c050286..1b89739 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -86,6 +86,8 @@ protected:
 
 /* ************************************************************************** */
 
+class CacheFile;
+
 struct ImportSettings {
 	bool do_convert_mat;
 	float conversion_mat[4][4];
@@ -95,6 +97,8 @@ struct ImportSettings {
 	float scale;
 	bool is_sequence;
 	bool set_frame_range;
+
+	CacheFile *cache_file;
 };
 
 /* ************************************************************************** */
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 349e0d9..43849b1 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -37,6 +37,7 @@
 extern "C" {
 #include "MEM_guardedalloc.h"
 
+#include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 
@@ -44,6 +45,7 @@ extern "C" {
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
 #include "BKE_global.h"
+#include "BKE_library.h"
 
 /* SpaceType struct has a member called 'new' which obviously conflicts with C++
  * so temporarily redefining the new keyword to make it compile. */
@@ -53,6 +55,7 @@ extern "C" {
 
 #include "BLI_ghash.h"
 #include "BLI_math.h"
+#include "BLI_path_util.h"
 #include "BLI_string.h"
 
 #include "WM_api.h"
@@ -460,6 +463,9 @@ static void import_startjob(void *cjv, short *stop, short *do_update, float *pro
 		return;
 	}
 
+	data->settings.cache_file = static_cast<CacheFile *>(BKE_libblock_alloc(data->bmain, ID_CF, BLI_path_basename(data->filename)));
+	BLI_strncpy(data->settings.cache_file->filepath, data->filename, 1024);
+
 	*data->do_update = true;
 	*data->progress = 0.05f;
 
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 2215fbf..2593d63 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -91,7 +91,7 @@ void id_clear_lib_data_ex(struct Main *bmain, struct ID *id, bool id_in_mainlist
 
 struct ListBase *which_libbase(struct Main *mainlib, short type);
 
-#define MAX_LIBARRAY    34
+#define MAX_LIBARRAY    35
 int set_listbasepointers(struct Main *main, struct ListBase *lb[MAX_LIBARRAY]);
 
 /* Main API */
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index 44e4da4..29219a4 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -102,6 +102,7 @@ typedef struct Main {
 	ListBase movieclip;
 	ListBase mask;
 	ListBase linestyle;
+	ListBase cachefiles;
 
 	char id_tag_update[256];
 
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 199d950..6e4e3cd 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -4339,6 +4339,12 @@ static bConstraintTypeInfo CTI_OBJECTSOLVER = {
 #include "ABC_alembic.h"
 #endif
 
+static void transformcache_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata)
+{
+	bTransformCacheConstraint *data = con->data;
+	func(con, (ID **)&data->cache_file, false, userdata);
+}
+
 static void transformcache_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets)
 {
 	bTransformCacheConstraint *data = con->data;
@@ -4346,7 +4352,8 @@ static void transformcache_evaluate(bConstraint *con, bConstraintOb *cob, ListBa
 
 	const float ctime = BKE_scene_frame_get(scene) / (float)scene->r.frs_sec;
 
-	ABC_get_transform(cob->ob, data->filepath, data->abc_object_path, cob->matrix, ctime, data->scale);
+	ABC_get_transform(cob->ob, data->cache_file->filepath, data->abc_object_path,
+	                  cob->matrix, ctime, data->scale);
 
 	UNUSED_VARS(targets);
 }
@@ -4357,7 +4364,7 @@ static bConstraintTypeInfo CTI_TRANSFORMCACHE = {
 	"Transform Cache", /* name */
 	"bTransformCacheConstraint", /* struct name */
 	NULL,  /* free data */
-	NULL,  /* id looper */
+	transformcache_id_looper,  /* id looper */
 	NULL,  /* copy data */
 	NULL,  /* new data */
 	NULL,  /* get constraint targets */
diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c
index 899ed54..b72c9cd 100644
--- a/source/blender/blenkernel/intern/idcode.c
+++ b/source/blender/blenkernel/intern/idcode.c
@@ -60,6 +60,7 @@ static IDType idtypes[] = {
 	{ ID_AR,   "Armature",           "armatures",       BLT_I18NCONTEXT_ID_ARMATURE,           IDTYPE_FLAGS_ISLINKABLE },
 	{ ID_BR,   "Brush",              "brushes",         BLT_I18NCONTEXT_ID_BRUSH,              IDTYPE_FLAGS_ISLINKABLE },
 	{ ID_CA,   "Camera",             "cameras",         BLT_I18NCONTEXT_ID_CAMERA,             IDTYPE_FLAGS_ISLINKABLE },
+    { ID_CF,   "CacheFile",          "cachefiles",      BLT_I18NCONTEXT_ID_CACHEFILE,          IDTYPE_FLAGS_ISLINKABLE },
 	{ ID_CU,   "Curve",              "curves",          BLT_I18NCONTEXT_ID_CURVE,              IDTYPE_FLAGS_ISLINKABLE },
 	{ ID_GD,   "GPencil",            "grease_pencil",   BLT_I18NCONTEXT_ID_GPENCIL,            IDTYPE_FLAGS_ISLINKABLE }, /* rename gpencil */
 	{ ID_GR,   "Group",              "groups",          BLT_I18NCONTEXT_ID_GROUP,              IDTYPE_FLAGS_ISLINKABLE },
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 961b45d..03c32ce 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -56,6 +56,7 @@
 #include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meta_types.h"
+#include "DNA_modifier_types.h"
 #include "DNA_movieclip_types.h"
 #include "DNA_mask_types.h"
 #include "DNA_node_types.h"
@@ -590,6 +591,8 @@ ListBase *which_libbase(Main *mainlib, short type)
 			return &(mainlib->palettes);
 		case ID_PC:
 			return &(mainlib->paintcurves);
+		case ID_CF:
+			return &(mainlib->cachefiles);
 	}
 	return NULL;
 }
@@ -713,6 +716,7 @@ int set_listbasepointers(Main *main, ListBase **lb)
 
 	lb[a++] = &(main->armature);
 
+	lb[a++] = &(main->cachefiles);
 	lb[a++] = &(main->mesh);
 	lb[a++] = &(main->curve);
 	lb[a++] = &(main->mball);
@@ -864,6 +868,9 @@ void *BKE_libblock_alloc_notest(short type)
 		case ID_PC:
 			id = MEM_callocN(sizeof(PaintCurve), "Paint Curve");
 			break;
+		case ID_CF:
+			id = MEM_callocN(sizeof(CacheFile), "Cache File");
+			break;
 	}
 	return id;
 }
@@ -1003,6 +1010,9 @@ void BKE_libblock_init_empty(ID *id)
 		case ID_LS:
 			BKE_linestyle_init((FreestyleLineStyle *)id);
 			break;
+		case ID_CF:
+			/* Nothing to do. */
+			break;
 	}
 }
 
@@ -1286,6 +1296,9 @@ void BKE_libblock_free_ex(Main *bmain, void *idv, bool do_id_user)
 		case ID_PC:
 			BKE_paint_curve_free((PaintCurve *)id);
 			break;
+		case ID_CF:
+			/* Nothing to do. */
+			break;
 	}
 
 	/* avoid notifying on removed data */
@@ -1402,6 +1415,7 @@ void BKE_main_free(Main *mainvar)
 				case  31: BKE_libblock_free_ex(mainvar, id, false); break;
 				case  32: BKE_libblock_free_ex(mainvar, id, false); break;
 				case  33: BKE_libblock_free_ex(mainvar, id, false); break;
+				case  34: BKE_libblock_free_ex(mainvar, id, false); break;
 				default:
 					BLI_assert(0);
 					break;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 621088c..772ded7 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2250,6 +2250,22 @@ static PackedFile *direct_link_packedfile(FileData *fd, PackedFile *oldpf)
 	return pf;
 }
 
+/* ************ READ CACHEFILES *************** */
+
+static void lib_link_cachef

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list