[Bf-blender-cvs] [beee21d] asset-engine: Void skeleton of asset engine.

Bastien Montagne noreply at git.blender.org
Thu Mar 5 10:10:39 CET 2015


Commit: beee21d04599748c32964df9ab4da50ad052ca3a
Author: Bastien Montagne
Date:   Tue Jan 27 14:45:10 2015 +0100
Branches: asset-engine
https://developer.blender.org/rBbeee21d04599748c32964df9ab4da50ad052ca3a

Void skeleton of asset engine.

Mostly copied from RenderEngines code. Compiles, now we have to flesh this!

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

M	release/scripts/modules/bpy_types.py
A	source/blender/blenkernel/BKE_asset.h
M	source/blender/blenkernel/CMakeLists.txt
A	source/blender/blenkernel/intern/asset.c
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/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/source/blender/blenkernel/BKE_asset.h b/source/blender/blenkernel/BKE_asset.h
new file mode 100644
index 0000000..bc3d656
--- /dev/null
+++ b/source/blender/blenkernel/BKE_asset.h
@@ -0,0 +1,163 @@
+/*
+ * ***** 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
+
+struct AssetEngine;
+struct AssetEngineType;
+struct ExtensionRNA;
+struct ListBase;
+
+#if 0
+#include "DNA_scene_types.h"
+#include "RE_bake.h"
+#include "RNA_types.h"
+
+
+struct bNode;
+struct bNodeTree;
+struct Object;
+struct Render;
+struct RenderData;
+struct RenderLayer;
+struct RenderResult;
+struct ReportList;
+struct Scene;
+struct BakePixel;
+
+/* External Engine */
+
+/* RenderEngineType.flag */
+#define RE_INTERNAL				1
+#define RE_GAME					2
+#define RE_USE_PREVIEW			4
+#define RE_USE_POSTPROCESS		8
+#define RE_USE_SHADING_NODES	16
+#define RE_USE_EXCLUDE_LAYERS	32
+#define RE_USE_SAVE_BUFFERS		64
+#define RE_USE_TEXTURE_PREVIEW		128
+
+/* RenderEngine.flag */
+#define RE_ENGINE_ANIMATION		1
+#define RE_ENGINE_PREVIEW		2
+#define RE_ENGINE_DO_DRAW		4
+#define RE_ENGINE_DO_UPDATE		8
+#define RE_ENGINE_RENDERING		16
+#define RE_ENGINE_HIGHLIGHT_TILES	32
+#define RE_ENGINE_USED_FOR_VIEWPORT	64
+
+/* RenderEngine.update_flag, used by internal now */
+#define RE_ENGINE_UPDATE_MA			1
+#define RE_ENGINE_UPDATE_OTHER		2
+#define RE_ENGINE_UPDATE_DATABASE	4
+
+#endif
+
+extern ListBase asset_engines;
+
+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;
+
+#if 0
+	void (*update)(struct RenderEngine *engine, struct Main *bmain, struct Scene *scene);
+	void (*render)(struct RenderEngine *engine, struct Scene *scene);
+	void (*bake)(struct RenderEngine *engine, struct Scene *scene, struct Object *object, const int pass_type, const struct BakePixel *pixel_array, const int num_pixels, const int depth, void *result);
+
+	void (*view_update)(struct RenderEngine *engine, const struct bContext *context);
+	void (*view_draw)(struct RenderEngine *engine, const struct bContext *context);
+
+	void (*update_script_node)(struct RenderEngine *engine, struct bNodeTree *ntree, struct bNode *node);
+#endif
+
+	/* RNA integration */
+	struct ExtensionRNA ext;
+} AssetEngineType;
+
+typedef struct AssetEngine {
+	AssetEngineType *type;
+	void *py_instance;
+
+	int flag;
+
+	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);
+void BKE_asset_engine_free(AssetEngine *engine);
+
+#if 0
+void RE_layer_load_from_file(struct RenderLayer *layer, struct ReportList *reports, const char *filename, int x, int y);
+void RE_result_load_from_file(struct RenderResult *result, struct ReportList *reports, const char *filename);
+
+struct RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h, const char *layername);
+void RE_engine_update_result(RenderEngine *engine, struct RenderResult *result);
+void RE_engine_end_result(RenderEngine *engine, struct RenderResult *result, int cancel, int merge_results);
+
+int RE_engine_test_break(RenderEngine *engine);
+void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info);
+void RE_engine_update_progress(RenderEngine *engine, float progress);
+void RE_engine_update_memory_stats(RenderEngine *engine, float mem_used, float mem_peak);
+void RE_engine_report(RenderEngine *engine, int type, const char *msg);
+void RE_engine_set_error_message(RenderEngine *engine, const char *msg);
+
+int RE_engine_render(struct Render *re, int do_all);
+
+bool RE_engine_is_external(struct Render *re);
+
+void RE_engine_frame_set(struct RenderEngine *engine, int frame, float subframe);
+
+void RE_engine_get_current_tiles(struct Render *re, int *total_tiles_r, rcti **tiles_r);
+struct RenderData *RE_engine_get_render_data(struct Render *re);
+void RE_bake_engine_set_engine_parameters(struct Render *re, struct Main *bmain, struct Scene *scene);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BKE_ASSET_H__ */
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index b3469ce..f13585b 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -67,6 +67,7 @@ set(SRC
 	intern/anim_sys.c
 	intern/appdir.c
 	intern/armature.c
+	intern/asset.c
 	intern/autoexec.c
 	intern/blender.c
 	intern/bmfont.c
@@ -184,6 +185,7 @@ set(SRC
 	BKE_animsys.h
 	BKE_appdir.h
 	BKE_armature.h
+	BKE_asset.h
 	BKE_autoexec.h
 	BKE_blender.h
 	BKE_bmfont.h
diff --git a/source/blender/blenkernel/intern/asset.c b/source/blender/blenkernel/intern/asset.c
new file mode 100644
index 0000000..22c9f38
--- /dev/null
+++ b/source/blender/blenkernel/intern/asset.c
@@ -0,0 +1,653 @@
+/*
+ * ***** 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 blender/blenkernel/intern/asset.c
+ *  \ingroup bke
+ */
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+#include "RNA_types.h"
+
+#include "BLF_translation.h"
+
+#include "BLI_listbase.h"
+#include "BLI_string.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_global.h"
+#include "BKE_report.h"
+#include "BKE_asset.h"
+
+#ifdef WITH_PYTHON
+#include "BPY_extern.h"
+#endif
+
+/* Asset engine types (none intern!). */
+
+ListBase asset_engines = {NULL, NULL};
+
+void BKE_asset_engines_init(void)
+{
+}
+
+void BKE_asset_engines_exit(void)
+{
+	AssetEngineType *type, *next;
+
+	for (type = asset_engines.first; type; type = next) {
+		next = type->next;
+
+		BLI_remlink(&asset_engines, type);
+
+		if (type->ext.free) {
+			type->ext.free(type->ext.data);
+		}
+
+		MEM_freeN(type);
+	}
+}
+
+AssetEngineType *BKE_asset_engines_find(const char *idname)
+{
+	AssetEngineType *type;
+
+	type = BLI_findstring(&asset_engines, idname, offsetof(AssetEngineType, idname));
+//	if (!type)
+//		type = &internal_render_type;
+
+	return type;
+}
+
+/* Asset engine instances. */
+
+/* Create, Free */
+
+AssetEngine *BKE_asset_engine_create(AssetEngineType *type)
+{
+	AssetEngine *engine = MEM_callocN(sizeof(AssetEngine), __func__);
+	engine->type = type;
+
+	return engine;
+}
+
+void BKE_asset_engine_free(AssetEngine *engine)
+{
+#ifdef WITH_PYTHON
+	if (engine->py_instance) {
+		BPY_DECREF_RNA_INVALIDATE(engine->py_instance);
+	}
+#endif
+
+	MEM_freeN(engine);
+}
+
+#if 0
+bool RE_engine_is_external(Render *re)
+{
+	RenderEngineType *type = RE_engines_find(re->r.engine);
+	return (type && type->render);
+}
+
+/* Render Results */
+
+static RenderPart *get_part_from_result(Render *re, RenderResult *result)
+{
+	RenderPart *pa;
+
+	for (pa = re->parts.first; pa; pa = pa->next) {
+		if (result->tilerect.xmin == pa->disprect.xmin - re->disprect.xmin &&
+		    result->tilerect.ymin == pa->disprect.ymin - re->disprect.ymin &&
+		    result->tilerect.xmax == pa->disprect.xmax - re->disprect.xmin &&
+		    result->tilerect.ymax == pa->disprect.ymax - re->disprect.ymin)
+		{
+			return pa;
+		}
+	}
+
+	return NULL;
+}
+
+RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h, const char *layername)
+{
+	Render *re = engine->re;
+	RenderResult *result;
+	rcti disprect;
+
+	/* ensure the coordinates are within the right limits */
+	CLAMP(x, 0, re->result->rectx);
+	CLAMP(y, 0, re->result->recty);
+	CLAMP(w, 0, re->result->rectx);
+	CLAMP(h, 0, re->result->recty);
+
+	if (x + w > re->result->rectx)
+		w = re->result->rectx - x;
+	if (y + h > re->result->recty)
+

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list