• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ BKE_reports_init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中BKE_reports_init函数的典型用法代码示例。如果您正苦于以下问题:C++ BKE_reports_init函数的具体用法?C++ BKE_reports_init怎么用?C++ BKE_reports_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了BKE_reports_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: PYRNA_STRUCT_CHECK_OBJ

PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyObject *kw)
{
	/* args, pyrna_struct_keyframe_parse handles these */
	const char *path_full = NULL;
	int index = -1;
	float cfra = FLT_MAX;
	const char *group_name = NULL;
	char keytype = BEZT_KEYTYPE_KEYFRAME; /* XXX: Expose this as a one-off option... */
	int options = 0;

	PYRNA_STRUCT_CHECK_OBJ(self);

	if (pyrna_struct_keyframe_parse(&self->ptr, args, kw,
	                                "s|ifsO!:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()",
	                                &path_full, &index, &cfra, &group_name, &options) == -1)
	{
		return NULL;
	}
	else {
		short result;
		ReportList reports;

		BKE_reports_init(&reports, RPT_STORE);

		result = insert_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, keytype, options);
		MEM_freeN((void *)path_full);

		if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
			return NULL;

		return PyBool_FromLong(result);
	}
}
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:33,代码来源:bpy_rna_anim.c


示例2: PYRNA_STRUCT_CHECK_OBJ

PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
{
	const char *path, *path_full;
	int index = -1;

	PYRNA_STRUCT_CHECK_OBJ(self);

	if (!PyArg_ParseTuple(args, "s|i:driver_remove", &path, &index))
		return NULL;

	if (pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) == -1) {
		return NULL;
	}
	else {
		short result;
		ReportList reports;

		BKE_reports_init(&reports, RPT_STORE);

		result = ANIM_remove_driver(&reports, (ID *)self->ptr.id.data, path_full, index, 0);

		MEM_freeN((void *)path_full);

		if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
			return NULL;
		
		WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);

		return PyBool_FromLong(result);
	}
}
开发者ID:DrangPo,项目名称:blender,代码行数:31,代码来源:bpy_rna_anim.c


示例3: BKE_reports_init

static BlendFileData *load_game_data(char *progname, char *filename = NULL, char *relativename = NULL)
{
    ReportList reports;
    BlendFileData *bfd = NULL;

    BKE_reports_init(&reports, RPT_STORE);

    /* try to load ourself, will only work if we are a runtime */
    if (BLO_is_a_runtime(progname)) {
        bfd= BLO_read_runtime(progname, &reports);
        if (bfd) {
            bfd->type= BLENFILETYPE_RUNTIME;
            strcpy(bfd->main->name, progname);
        }
    } else {
        bfd= BLO_read_from_file(progname, &reports);
    }

    if (!bfd && filename) {
        bfd = load_game_data(filename);
        if (!bfd) {
            printf("Loading %s failed: ", filename);
            BKE_reports_print(&reports, RPT_ERROR);
        }
    }

    BKE_reports_clear(&reports);

    return bfd;
}
开发者ID:rexbron,项目名称:blender-ocio,代码行数:30,代码来源:GPG_ghost.cpp


示例4: wm_init_reports

static void wm_init_reports(bContext *C)
{
	ReportList *reports = CTX_wm_reports(C);

	BLI_assert(!reports || BLI_listbase_is_empty(&reports->list));

	BKE_reports_init(reports, RPT_STORE);
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:8,代码来源:wm_init_exit.c


示例5: _PyDict_NewPresized

static PyObject *bpy_lib_enter(BPy_Library *self)
{
	PyObject *ret;
	BPy_Library *self_from;
	PyObject *from_dict = _PyDict_NewPresized(MAX_LIBARRAY);
	ReportList reports;

	BKE_reports_init(&reports, RPT_STORE);

	self->blo_handle = BLO_blendhandle_from_file(self->abspath, &reports);

	if (self->blo_handle == NULL) {
		if (BPy_reports_to_error(&reports, PyExc_IOError, true) != -1) {
			PyErr_Format(PyExc_IOError,
			             "load: %s failed to open blend file",
			             self->abspath);
		}
		return NULL;
	}
	else {
		int i = 0, code;
		while ((code = BKE_idcode_iter_step(&i))) {
			if (BKE_idcode_is_linkable(code)) {
				const char *name_plural = BKE_idcode_to_name_plural(code);
				PyObject *str = PyUnicode_FromString(name_plural);
				PyObject *item;

				PyDict_SetItem(self->dict, str, item = PyList_New(0));
				Py_DECREF(item);
				PyDict_SetItem(from_dict, str, item = _bpy_names(self, code));
				Py_DECREF(item);

				Py_DECREF(str);
			}
		}
	}

	/* create a dummy */
	self_from = PyObject_New(BPy_Library, &bpy_lib_Type);
	BLI_strncpy(self_from->relpath, self->relpath, sizeof(self_from->relpath));
	BLI_strncpy(self_from->abspath, self->abspath, sizeof(self_from->abspath));

	self_from->blo_handle = NULL;
	self_from->flag = 0;
	self_from->dict = from_dict; /* owns the dict */

	/* return pair */
	ret = PyTuple_New(2);
	PyTuple_SET_ITEMS(ret,
	        (PyObject *)self_from,
	        (PyObject *)self);
	Py_INCREF(self);

	BKE_reports_clear(&reports);

	return ret;
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:57,代码来源:bpy_library_load.c


示例6: screencast_exec

static int screencast_exec(bContext *C, wmOperator *op)
{
    wmWindowManager *wm = CTX_wm_manager(C);
    wmWindow *win = CTX_wm_window(C);
    bScreen *screen = CTX_wm_screen(C);
    wmJob *wm_job;
    ScreenshotJob *sj;

    /* if called again, stop the running job */
    if (WM_jobs_test(wm, screen, WM_JOB_TYPE_SCREENCAST))
        WM_jobs_stop(wm, screen, screenshot_startjob);

    wm_job = WM_jobs_get(wm, win, screen, "Screencast", 0, WM_JOB_TYPE_SCREENCAST);
    sj = MEM_callocN(sizeof(ScreenshotJob), "screenshot job");

    /* setup sj */
    if (RNA_boolean_get(op->ptr, "full")) {
        sj->x = 0;
        sj->y = 0;
        sj->dumpsx = WM_window_pixels_x(win);
        sj->dumpsy = WM_window_pixels_y(win);
    }
    else {
        ScrArea *curarea = CTX_wm_area(C);
        sj->x = curarea->totrct.xmin;
        sj->y = curarea->totrct.ymin;
        sj->dumpsx = curarea->totrct.xmax - sj->x;
        sj->dumpsy = curarea->totrct.ymax - sj->y;
    }
    sj->bmain = CTX_data_main(C);
    sj->scene = CTX_data_scene(C);
    sj->wm = wm;

    BKE_reports_init(&sj->reports, RPT_PRINT);

    /* setup job */
    WM_jobs_customdata_set(wm_job, sj, screenshot_freejob);
    WM_jobs_timer(wm_job, 0.1, 0, NC_SCREEN | ND_SCREENCAST);
    WM_jobs_callbacks(wm_job, screenshot_startjob, NULL, screenshot_updatejob, screenshot_endjob);

    WM_jobs_start(sj->wm, wm_job);

    screencast_cursor_toggle(sj->wm, 1);

    WM_event_add_notifier(C, NC_SCREEN | ND_SCREENCAST, screen);

    return OPERATOR_FINISHED;
}
开发者ID:caomw,项目名称:blender-ui,代码行数:48,代码来源:screendump.c


示例7: UNUSED

static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData,
                                  ModifierApplyFlag UNUSED(flag))
{
	DataTransferModifierData *dtmd = (DataTransferModifierData *) md;
	DerivedMesh *dm = derivedData;
	ReportList reports;

	/* Only used to check wehther we are operating on org data or not... */
	Mesh *me = ob->data;
	MVert *mvert;

	const bool invert_vgroup = (dtmd->flags & MOD_DATATRANSFER_INVERT_VGROUP) != 0;

	const float max_dist = (dtmd->flags & MOD_DATATRANSFER_MAP_MAXDIST) ? dtmd->map_max_distance : FLT_MAX;

	SpaceTransform space_transform_data;
	SpaceTransform *space_transform = (dtmd->flags & MOD_DATATRANSFER_OBSRC_TRANSFORM) ? &space_transform_data : NULL;

	if (space_transform) {
		BLI_SPACE_TRANSFORM_SETUP(space_transform, ob, dtmd->ob_source);
	}

	mvert = dm->getVertArray(dm);
	if ((me->mvert == mvert) && (dtmd->data_types & DT_TYPES_AFFECT_MESH)) {
		/* We need to duplicate data here, otherwise setting custom normals, edges' shaprness, etc., could
		 * modify org mesh, see T43671. */
		dm = CDDM_copy(dm);
	}

	BKE_reports_init(&reports, RPT_STORE);

	/* Note: no islands precision for now here. */
	BKE_object_data_transfer_dm(md->scene, dtmd->ob_source, ob, dm, dtmd->data_types, false,
	                     dtmd->vmap_mode, dtmd->emap_mode, dtmd->lmap_mode, dtmd->pmap_mode,
	                     space_transform, max_dist, dtmd->map_ray_radius, 0.0f,
	                     dtmd->layers_select_src, dtmd->layers_select_dst,
	                     dtmd->mix_mode, dtmd->mix_factor, dtmd->defgrp_name, invert_vgroup, &reports);

	if (BKE_reports_contain(&reports, RPT_ERROR)) {
		modifier_setError(md, "%s", BKE_reports_string(&reports, RPT_ERROR));
	}
	else if (dm->getNumVerts(dm) > HIGH_POLY_WARNING || ((Mesh *)(dtmd->ob_source->data))->totvert > HIGH_POLY_WARNING) {
		modifier_setError(md, "You are using a rather high poly as source or destination, computation might be slow");
	}

	return dm;
}
开发者ID:mistajuliax,项目名称:OctaneBlender,代码行数:47,代码来源:MOD_datatransfer.c


示例8: render_frame

static int render_frame(int argc, const char **argv, void *data)
{
	bContext *C = data;
	Scene *scene = CTX_data_scene(C);
	if (scene) {
		Main *bmain = CTX_data_main(C);

		if (argc > 1) {
			Render *re = RE_NewRender(scene->id.name);
			int frame;
			ReportList reports;

			switch (*argv[1]) {
				case '+':
					frame = scene->r.sfra + atoi(argv[1] + 1);
					break;
				case '-':
					frame = (scene->r.efra - atoi(argv[1] + 1)) + 1;
					break;
				default:
					frame = atoi(argv[1]);
					break;
			}

			BLI_begin_threaded_malloc();
			BKE_reports_init(&reports, RPT_PRINT);

			frame = CLAMPIS(frame, MINAFRAME, MAXFRAME);

			RE_SetReports(re, &reports);
			RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, frame, frame, scene->r.frame_step);
			RE_SetReports(re, NULL);
			BLI_end_threaded_malloc();
			return 1;
		}
		else {
			printf("\nError: frame number must follow '-f / --render-frame'.\n");
			return 0;
		}
	}
	else {
		printf("\nError: no blend loaded. cannot use '-f / --render-frame'.\n");
		return 0;
	}
}
开发者ID:SuriyaaKudoIsc,项目名称:blender-git,代码行数:45,代码来源:creator.c


示例9: BKE_reports_init

bool GPC_Engine::Start(char *filename)
{
	ReportList reports;
	BlendFileData *bfd;
	
	BKE_reports_init(&reports, RPT_STORE);
	bfd= BLO_read_from_file(filename, &reports);
	BKE_reports_clear(&reports);

	if (!bfd) {
			// XXX, deal with error here
		cout << "Unable to load: " << filename << endl;
		return false;
	}

	StartKetsji();

	if(bfd->type == BLENFILETYPE_PUB)
		m_canvas->SetBannerDisplayEnabled(false);

	return true;
}
开发者ID:BHCLL,项目名称:blendocv,代码行数:22,代码来源:GPC_Engine.cpp


示例10: thumbnails_start

void thumbnails_start(FileList *filelist, const bContext *C)
{
	wmJob *wm_job;
	ThumbnailJob *tj;
	int idx;

	/* prepare job data */
	tj = MEM_callocN(sizeof(*tj), __func__);
	tj->filelist = filelist;
	for (idx = 0; idx < filelist->numfiles; idx++) {
		if (!filelist->filelist[idx].path) {
			continue;
		}
		if (!filelist->filelist[idx].image) {
			if (filelist->filelist[idx].flags & (FILE_TYPE_IMAGE | FILE_TYPE_MOVIE | FILE_TYPE_FTFONT |
			                                     FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP))
			{
				FileImage *limg = MEM_callocN(sizeof(*limg), __func__);
				BLI_strncpy(limg->path, filelist->filelist[idx].path, sizeof(limg->path));
				limg->index = idx;
				limg->flags = filelist->filelist[idx].flags;
				BLI_addtail(&tj->loadimages, limg);
			}
		}
	}

	BKE_reports_init(&tj->reports, RPT_PRINT);

	/* setup job */
	wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), filelist, "Thumbnails",
	                     0, WM_JOB_TYPE_FILESEL_THUMBNAIL);
	WM_jobs_customdata_set(wm_job, tj, thumbnails_free);
	WM_jobs_timer(wm_job, 0.5, NC_WINDOW, NC_WINDOW);
	WM_jobs_callbacks(wm_job, thumbnails_startjob, NULL, thumbnails_update, thumbnails_endjob);

	/* start the job */
	WM_jobs_start(CTX_wm_manager(C), wm_job);
}
开发者ID:bitfusionio,项目名称:blender,代码行数:38,代码来源:filelist.c


示例11: BLI_strncpy

static PyObject *bpy_lib_write(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
{
	static const char *kwlist[] = {
		"filepath", "datablocks",
		/* optional */
		"relative_remap", "fake_user", "compress",
		NULL,
	};

	/* args */
	const char *filepath;
	char filepath_abs[FILE_MAX];
	PyObject *datablocks = NULL;
	bool use_relative_remap = false, use_fake_user = false, use_compress = false;

	if (!PyArg_ParseTupleAndKeywords(
	        args, kwds,
	        "sO!|$O&O&O&:write", (char **)kwlist,
	        &filepath,
	        &PySet_Type, &datablocks,
	        PyC_ParseBool, &use_relative_remap,
	        PyC_ParseBool, &use_fake_user,
	        PyC_ParseBool, &use_compress))
	{
		return NULL;
	}

	Main *bmain_src = G.main;
	int write_flags = 0;

	if (use_relative_remap) {
		write_flags |= G_FILE_RELATIVE_REMAP;
	}

	if (use_compress) {
		write_flags |= G_FILE_COMPRESS;
	}

	BLI_strncpy(filepath_abs, filepath, FILE_MAX);
	BLI_path_abs(filepath_abs, G.main->name);

	BKE_blendfile_write_partial_begin(bmain_src);

	/* array of ID's and backup any data we modify */
	struct {
		ID *id;
		/* original values */
		short id_flag;
		short id_us;
	} *id_store_array, *id_store;
	int id_store_len = 0;

	PyObject *ret;

	/* collect all id data from the set and store in 'id_store_array' */
	{
		Py_ssize_t pos, hash;
		PyObject *key;

		id_store_array = MEM_mallocN(sizeof(*id_store_array) * PySet_Size(datablocks), __func__);
		id_store = id_store_array;

		pos = hash = 0;
		while (_PySet_NextEntry(datablocks, &pos, &key, &hash)) {

			if (!pyrna_id_FromPyObject(key, &id_store->id)) {
				PyErr_Format(PyExc_TypeError,
				             "Expected and ID type, not %.200s",
				             Py_TYPE(key)->tp_name);
				ret = NULL;
				goto finally;
			}
			else {
				id_store->id_flag = id_store->id->flag;
				id_store->id_us = id_store->id->us;

				if (use_fake_user) {
					id_store->id->flag |= LIB_FAKEUSER;
				}
				id_store->id->us = 1;

				BKE_blendfile_write_partial_tag_ID(id_store->id, true);

				id_store_len += 1;
				id_store++;
			}
		}
	}

	/* write blend */
	int retval = 0;
	ReportList reports;

	BKE_reports_init(&reports, RPT_STORE);

	retval = BKE_blendfile_write_partial(bmain_src, filepath_abs, write_flags, &reports);

	/* cleanup state */
	BKE_blendfile_write_partial_end(bmain_src);

//.........这里部分代码省略.........
开发者ID:diekev,项目名称:blender,代码行数:101,代码来源:bpy_library_write.c


示例12: load_file

static int load_file(int UNUSED(argc), const char **argv, void *data)
{
	bContext *C = data;

	/* Make the path absolute because its needed for relative linked blends to be found */
	char filename[FILE_MAX];

	/* note, we could skip these, but so far we always tried to load these files */
	if (argv[0][0] == '-') {
		fprintf(stderr, "unknown argument, loading as file: %s\n", argv[0]);
	}

	BLI_strncpy(filename, argv[0], sizeof(filename));
	BLI_path_cwd(filename);

	if (G.background) {
		int retval = BKE_read_file(C, filename, NULL);

		/* we successfully loaded a blend file, get sure that
		 * pointcache works */
		if (retval != BKE_READ_FILE_FAIL) {
			wmWindowManager *wm = CTX_wm_manager(C);

			/* special case, 2.4x files */
			if (wm == NULL && CTX_data_main(C)->wm.first == NULL) {
				extern void wm_add_default(bContext *C);

				/* wm_add_default() needs the screen to be set. */
				CTX_wm_screen_set(C, CTX_data_main(C)->screen.first);
				wm_add_default(C);
			}

			CTX_wm_manager_set(C, NULL); /* remove wm to force check */
			WM_check(C);
			G.relbase_valid = 1;
			if (CTX_wm_manager(C) == NULL) CTX_wm_manager_set(C, wm);  /* reset wm */

			DAG_on_visible_update(CTX_data_main(C), TRUE);
		}
		else {
			/* failed to load file, stop processing arguments */
			return -1;
		}

		/* WM_file_read() runs normally but since we're in background mode do here */
#ifdef WITH_PYTHON
		/* run any texts that were loaded in and flagged as modules */
		BPY_python_reset(C);
#endif

		/* happens for the UI on file reading too (huh? (ton))*/
		// XXX		BKE_reset_undo();
		//			BKE_write_undo("original");	/* save current state */
	}
	else {
		/* we are not running in background mode here, but start blender in UI mode with
		 * a file - this should do everything a 'load file' does */
		ReportList reports;
		BKE_reports_init(&reports, RPT_PRINT);
		WM_file_autoexec_init(filename);
		WM_file_read(C, filename, &reports);
		BKE_reports_clear(&reports);
	}

	G.file_loaded = 1;

	return 0;
}
开发者ID:JasonWilkins,项目名称:blender-wayland,代码行数:68,代码来源:creator.c


示例13: PyErr_SetString

static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
{
	wmOperatorType *ot;
	int error_val = 0;
	PointerRNA ptr;
	int operator_ret = OPERATOR_CANCELLED;

	char     *opname;
	char     *context_str = NULL;
	PyObject *kw = NULL; /* optional args */
	PyObject *context_dict = NULL; /* optional args */
	PyObject *context_dict_back;

	/* note that context is an int, python does the conversion in this case */
	int context = WM_OP_EXEC_DEFAULT;
	int is_undo = false;

	/* XXX Todo, work out a better solution for passing on context,
	 * could make a tuple from self and pack the name and Context into it... */
	bContext *C = (bContext *)BPy_GetContext();
	
	if (C == NULL) {
		PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any operators");
		return NULL;
	}
	
	if (!PyArg_ParseTuple(args, "sO|O!si:_bpy.ops.call",
	                      &opname, &context_dict, &PyDict_Type, &kw, &context_str, &is_undo))
	{
		return NULL;
	}

	ot = WM_operatortype_find(opname, true);

	if (ot == NULL) {
		PyErr_Format(PyExc_AttributeError,
		             "Calling operator \"bpy.ops.%s\" error, "
		             "could not be found", opname);
		return NULL;
	}
	
	if (!pyrna_write_check()) {
		PyErr_Format(PyExc_RuntimeError,
		             "Calling operator \"bpy.ops.%s\" error, "
		             "can't modify blend data in this state (drawing/rendering)",
		             opname);
		return NULL;
	}

	if (context_str) {
		if (RNA_enum_value_from_id(operator_context_items, context_str, &context) == 0) {
			char *enum_str = BPy_enum_as_string(operator_context_items);
			PyErr_Format(PyExc_TypeError,
			             "Calling operator \"bpy.ops.%s\" error, "
			             "expected a string enum in (%.200s)",
			             opname, enum_str);
			MEM_freeN(enum_str);
			return NULL;
		}
	}

	if (context_dict == NULL || context_dict == Py_None) {
		context_dict = NULL;
	}
	else if (!PyDict_Check(context_dict)) {
		PyErr_Format(PyExc_TypeError,
		             "Calling operator \"bpy.ops.%s\" error, "
		             "custom context expected a dict or None, got a %.200s",
		             opname, Py_TYPE(context_dict)->tp_name);
		return NULL;
	}

	context_dict_back = CTX_py_dict_get(C);

	CTX_py_dict_set(C, (void *)context_dict);
	Py_XINCREF(context_dict); /* so we done loose it */

	if (WM_operator_poll_context((bContext *)C, ot, context) == false) {
		const char *msg = CTX_wm_operator_poll_msg_get(C);
		PyErr_Format(PyExc_RuntimeError,
		             "Operator bpy.ops.%.200s.poll() %.200s",
		             opname, msg ? msg : "failed, context is incorrect");
		CTX_wm_operator_poll_msg_set(C, NULL); /* better set to NULL else it could be used again */
		error_val = -1;
	}
	else {
		WM_operator_properties_create_ptr(&ptr, ot);
		WM_operator_properties_sanitize(&ptr, 0);

		if (kw && PyDict_Size(kw))
			error_val = pyrna_pydict_to_props(&ptr, kw, 0, "Converting py args to operator properties: ");


		if (error_val == 0) {
			ReportList *reports;

			reports = MEM_mallocN(sizeof(ReportList), "wmOperatorReportList");
			BKE_reports_init(reports, RPT_STORE | RPT_OP_HOLD); /* own so these don't move into global reports */

#ifdef BPY_RELEASE_GIL
//.........这里部分代码省略.........
开发者ID:Walid-Shouman,项目名称:Blender,代码行数:101,代码来源:bpy_operator.c


示例14: BKE_idcode_from_name

KX_LibLoadStatus *KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options)
{
	Main *main_newlib; /* stored as a dynamic 'main' until we free it */
	const int idcode = BKE_idcode_from_name(group);
	ReportList reports;
	static char err_local[255];

//	TIMEIT_START(bge_link_blend_file);

	KX_LibLoadStatus *status;

	/* only scene and mesh supported right now */
	if (idcode != ID_SCE && idcode != ID_ME && idcode != ID_AC) {
		snprintf(err_local, sizeof(err_local), "invalid ID type given \"%s\"\n", group);
		*err_str = err_local;
		BLO_blendhandle_close(bpy_openlib);
		return NULL;
	}
	
	if (GetMainDynamicPath(path)) {
		snprintf(err_local, sizeof(err_local), "blend file already open \"%s\"\n", path);
		*err_str = err_local;
		BLO_blendhandle_close(bpy_openlib);
		return NULL;
	}

	if (bpy_openlib == NULL) {
		snprintf(err_local, sizeof(err_local), "could not open blendfile \"%s\"\n", path);
		*err_str = err_local;
		return NULL;
	}

	main_newlib = BKE_main_new();
	BKE_reports_init(&reports, RPT_STORE);

	short flag = 0; /* don't need any special options */
	/* created only for linking, then freed */
	Main *main_tmp = BLO_library_link_begin(main_newlib, &bpy_openlib, (char *)path);

	load_datablocks(main_tmp, bpy_openlib, path, idcode);

	if (idcode == ID_SCE && options & LIB_LOAD_LOAD_SCRIPTS) {
		load_datablocks(main_tmp, bpy_openlib, path, ID_TXT);
	}

	/* now do another round of linking for Scenes so all actions are properly loaded */
	if (idcode == ID_SCE && options & LIB_LOAD_LOAD_ACTIONS) {
		load_datablocks(main_tmp, bpy_openlib, path, ID_AC);
	}

	BLO_library_link_end(main_tmp, &bpy_openlib, flag, NULL, NULL);

	BLO_blendhandle_close(bpy_openlib);

	BKE_reports_clear(&reports);
	/* done linking */
	
	/* needed for lookups*/
	GetMainDynamic().push_back(main_newlib);
	BLI_strncpy(main_newlib->name, path, sizeof(main_newlib->name));
	
	
	status = new KX_LibLoadStatus(this, m_ketsjiEngine, scene_merge, path);

	if (idcode == ID_ME) {
		/* Convert all new meshes into BGE meshes */
		ID *mesh;
	
		for (mesh = (ID *)main_newlib->mesh.first; mesh; mesh = (ID *)mesh->next ) {
			if (options & LIB_LOAD_VERBOSE)
				printf("MeshName: %s\n", mesh->name + 2);
			RAS_MeshObject *meshobj = BL_ConvertMesh((Mesh *)mesh, NULL, scene_merge, this, false); // For now only use the libloading option for scenes, which need to handle materials/shaders
			scene_merge->GetLogicManager()->RegisterMeshName(meshobj->GetName(), meshobj);
		}
	}
	else if (idcode == ID_AC) {
		/* Convert all actions */
		ID *action;

		for (action= (ID *)main_newlib->action.first; action; action = (ID *)action->next) {
			if (options & LIB_LOAD_VERBOSE)
				printf("ActionName: %s\n", action->name + 2);
			scene_merge->GetLogicManager()->RegisterActionName(action->name + 2, action);
		}
	}
	else if (idcode == ID_SCE) {
		/* Merge all new linked in scene into the existing one */
		ID *scene;
		// scenes gets deleted by the thread when it's done using it (look in async_convert())
		vector<Scene *> *scenes = (options & LIB_LOAD_ASYNC) ? new vector<Scene *>() : NULL;

		for (scene = (ID *)main_newlib->scene.first; scene; scene = (ID *)scene->next ) {
			if (options & LIB_LOAD_VERBOSE)
				printf("SceneName: %s\n", scene->name + 2);
			
			if (options & LIB_LOAD_ASYNC) {
				scenes->push_back((Scene *)scene);
			} 
			else {
				/* merge into the base  scene */
//.........这里部分代码省略.........
开发者ID:sadmansk,项目名称:blender,代码行数:101,代码来源:KX_BlenderSceneConverter.cpp


示例15: wm_init_reports

static void wm_init_reports(bContext *C)
{
	BKE_reports_init(CTX_wm_reports(C), RPT_STORE);
}
开发者ID:jinjoh,项目名称:NOOR,代码行数:4,代码来源:wm_init_exit.c



注:本文中的BKE_reports_init函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ BKP_WriteBackupRegister函数代码示例发布时间:2022-05-30
下一篇:
C++ BKE_reportf函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap