[Bf-blender-cvs] [e615009] asset-engine: Revert "Revert "Merge branch 'asset-engine' into asset-experiments""

Bastien Montagne noreply at git.blender.org
Fri Mar 13 15:23:06 CET 2015


Commit: e615009ae4a0ba7adf82a9e61a360d827342aefd
Author: Bastien Montagne
Date:   Fri Mar 13 15:21:55 2015 +0100
Branches: asset-engine
https://developer.blender.org/rBe615009ae4a0ba7adf82a9e61a360d827342aefd

Revert "Revert "Merge branch 'asset-engine' into asset-experiments""

This reverts commit f751e34f91f63b97ffd31821beacfae79335777e.

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

M	release/scripts/modules/bpy_types.py
M	release/scripts/startup/bl_operators/__init__.py
A	release/scripts/startup/bl_operators/amber.py
M	release/scripts/startup/bl_ui/space_filebrowser.py
A	source/blender/blenkernel/BKE_asset.h
M	source/blender/blenkernel/CMakeLists.txt
A	source/blender/blenkernel/intern/asset.c
M	source/blender/editors/space_file/file_intern.h
M	source/blender/editors/space_file/file_ops.c
M	source/blender/editors/space_file/filelist.c
M	source/blender/editors/space_file/filelist.h
M	source/blender/editors/space_file/space_file.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/CMakeLists.txt
M	source/blender/makesrna/intern/makesrna.c
A	source/blender/makesrna/intern/rna_asset.c
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/python/intern/bpy_rna.c
M	source/blender/windowmanager/intern/wm_init_exit.c
M	source/blenderplayer/bad_level_call_stubs/stubs.c
M	source/creator/creator.c

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

diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index c7ec7e1..38b3c8c 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -634,6 +634,10 @@ class RenderEngine(StructRNA, metaclass=RNAMeta):
     __slots__ = ()
 
 
+class AssetEngine(StructRNA, metaclass=RNAMeta):
+    __slots__ = ()
+
+
 class KeyingSetInfo(StructRNA, metaclass=RNAMeta):
     __slots__ = ()
 
diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py
index 65f7bde..0854f85 100644
--- a/release/scripts/startup/bl_operators/__init__.py
+++ b/release/scripts/startup/bl_operators/__init__.py
@@ -48,6 +48,8 @@ _modules = [
     "wm",
 ]
 
+_modules.append("amber")
+
 import bpy
 
 if bpy.app.build_options.freestyle:
diff --git a/release/scripts/startup/bl_operators/amber.py b/release/scripts/startup/bl_operators/amber.py
new file mode 100644
index 0000000..c42c01d
--- /dev/null
+++ b/release/scripts/startup/bl_operators/amber.py
@@ -0,0 +1,83 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+# Note: This will be a simple addon later, but until it gets to master, it's simpler to have it
+#       as a startup module!
+
+import bpy
+from bpy.types import AssetEngine
+from bpy.props import (
+        StringProperty,
+        BoolProperty,
+        IntProperty,
+        FloatProperty,
+        EnumProperty,
+        CollectionProperty,
+        )
+
+class AssetEngineAmber(AssetEngine):
+    bl_label = "Amber"
+
+    def __init__(self):
+        self.jobs = {}
+        self.uuids = {}
+
+    def status(self, job_id):
+        if job_id:
+            job = self.jobs.get(job_id, None)
+            #~ if job is not None:
+                #~ return {'VALID'}
+            return set()
+        else:
+            return {'VALID'}
+
+    def progress(self, job_id):
+        return 0.5
+
+    def kill(self, job_id):
+        pass
+
+    def list_dir(self, job_id, entries):
+        if len(entries.entries) == 0:
+            entry = entries.entries.add()
+            entry.type = {'BLENDER'}
+            entry.relpath = "foobar.blend"
+            entry.name = "MyLittleTest"
+            entry.uuid = entry.relpath.encode()[:8] + b"|0000000001"
+            self.uuids[entry.uuid] = "/home/i74700deb64/Téléchargements/wall_UE_D_01.blend"
+            variant = entry.variants.add()
+            entry.variants.active = variant
+            rev = variant.revisions.add()
+            variant.revisions.active = rev
+        return 1
+
+    def load_pre(self, uuids, entries):
+        # Not quite sure this engine will need it in the end, but for sake of testing...
+        entries.root_path = "/"
+        for uuid in uuids.uuids[:1]:
+            entry = entries.entries.add()
+            entry.type = {'BLENDER'}
+            entry.relpath = self.uuids[uuid.uuid_asset]
+        return True
+
+
+if __name__ == "__main__":  # only for live edit.
+    bpy.utils.register_module(__name__)
+    bpy.utils.register_class(AssetEngineFlame)
diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index a99f915..2cf2e8e 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -34,6 +34,7 @@ class FILEBROWSER_HT_header(Header):
         layout.template_header()
 
         row = layout.row()
+        row.prop(st, "asset_engine", text="")
         row.separator()
 
         row = layout.row(align=True)
diff --git a/source/blender/blenkernel/BKE_asset.h b/source/blender/blenkernel/BKE_asset.h
new file mode 100644
index 0000000..c26797d
--- /dev/null
+++ b/source/blender/blenkernel/BKE_asset.h
@@ -0,0 +1,168 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2015 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file BKE_asset.h
+ *  \ingroup bke
+ */
+
+#ifndef __BKE_ASSET_H__
+#define __BKE_ASSET_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "DNA_space_types.h"
+
+struct AssetEngine;
+struct AssetEngineType;
+struct AssetUUIDList;
+struct FileDirEntryArr;
+struct FileDirEntry;
+struct FileDirEntryVariant;
+struct FileDirEntryRevision;
+struct ExtensionRNA;
+struct ID;
+struct ListBase;
+struct uiLayout;
+
+enum {
+	AE_STATUS_VALID   = 1 << 0,
+	AE_STATUS_RUNNING = 1 << 1,  /* Asset engine is performing some background tasks... */
+};
+
+#define AE_FAKE_ENGINE_ID "none"
+
+extern ListBase asset_engines;
+
+/* AE instance/job is valid, is running, is idle, etc. */
+typedef int (*ae_status)(struct AssetEngine *engine, const int job_id);
+typedef float (*ae_progress)(struct AssetEngine *engine, const int job_id);
+
+/* To force end of given job (e.g. because it was cancelled by user...). */
+typedef void (*ae_kill)(struct AssetEngine *engine, const int job_id);
+
+/* ***** All callbacks below shall be non-blocking (i.e. return immediately). ***** */
+/* Those callbacks will be called from a 'fake-job' start *and* update functions (i.e. main thread, working one will
+ * just sleep).
+ * If given id is not null, engine should update from a running job if available, otherwise it should start a new one.
+ * It is the responsability of the engine to start/stop background processes to actually perform tasks as/if needed.
+ */
+
+/* Return (list) everything available at given root path. */
+typedef int (*ae_list_dir)(struct AssetEngine *engine, const int job_id, struct FileDirEntryArr *entries_r);
+/* Ensure given direntries are really available for append/link (some kind of 'anticipated loading'...). */
+typedef int (*ae_ensure_entries)(struct AssetEngine *engine, const int job_id, struct AssetUUIDList *uuids);
+
+/* ***** All callbacks below are blocking. They shall be completed upon return. ***** */
+
+/* 'pre-loading' hook, called before opening/appending/linking given entries.
+ * Note first given uuid is the one of 'active' entry, and first entry in returned list will be considered as such too.
+ * E.g. allows the engine to ensure entries' paths are actually valid by downloading requested data, etc.
+ * If is_virtual is True, then there is no requirement that returned paths actually exist.
+ * Note that the generated list shall be simpler than the one generated by ae_list_dir, since only the path from
+ * active revision is used, no need to bother with variants, previews, etc.
+ * This allows to present 'fake' entries to user, and then import actual data.
+ */
+typedef bool (*ae_load_pre)(struct AssetEngine *engine, struct AssetUUIDList *uuids,
+                            struct FileDirEntryArr *entries_r);
+
+/* 'post-loading' hook, called after opening/appending/linking given entries.
+ * E.g. allows an advanced engine to make fancy scripted operations over loaded items. */
+typedef bool (*ae_load_post)(struct AssetEngine *engine, struct ID *items, const int *num_items);
+
+typedef struct AssetEngineType {
+	struct AssetEngineType *next, *prev;
+
+	/* type info */
+	char idname[64]; /* best keep the same size as BKE_ST_MAXNAME */
+	char name[64];
+	int flag;
+
+	/* API */
+	ae_status status;
+	ae_progress progress;
+
+	ae_kill kill;
+
+	ae_list_dir list_dir;
+	ae_ensure_entries ensure_entries;
+
+	ae_load_pre load_pre;
+	ae_load_post load_post;
+
+	/* RNA integration */
+	struct ExtensionRNA ext;
+} AssetEngineType;
+
+typedef struct AssetEngine {
+	AssetEngineType *type;
+	void *py_instance;
+
+	int flag;
+	int refcount;
+
+	struct ReportList *reports;
+} AssetEngine;
+
+/* Engine Types */
+void BKE_asset_engines_init(void);
+void BKE_asset_engines_exit(void);
+
+AssetEngineType *BKE_asset_engines_find(const char *idname);
+
+/* Engine Instances */
+AssetEngine *BKE_asset_engine_create(AssetEngineType *type);
+AssetEngine *BKE_asset_engine_copy(AssetEngine *engine);
+void BKE_asset_engine_free(AssetEngine *engine);
+
+void BKE_asset_engine_load_pre(AssetEngine *engine, struct FileDirEntryArr *r_entries);
+
+/* File listing utils... */
+
+typedef enum FileCheckType {
+	CHECK_NONE  = 0,
+	CHECK_DIRS  = 1 << 0,
+	CHECK_FILES = 1 << 1,
+	CHECK_ALL   = CHECK_DIRS | CHECK_FILES,
+} FileCheckType;
+
+void BKE_filedir_variant_free(struct FileDirEntryVariant *var);
+
+void BKE_filedir_entry_free(struct FileDirEntry *entry);
+void BKE_filedir_entry_clear(struct FileDirEntry *entry);
+struct FileDirEntry *BKE_filedir_entry_copy(struct FileDirEntry *entry);
+
+void BKE_filedir_entryarr_clear(struct FileDirEntryArr *array);
+
+bool BKE_filedir_entry_is_selected(struct FileDirEntry *entry, FileC

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list