2011-02-18 14:05:18 +01:00
|
|
|
/*
|
2008-01-07 20:13:47 +01:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 13:37:38 +02:00
|
|
|
*
|
|
|
|
* 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
|
2008-01-07 20:13:47 +01:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 13:37:38 +02:00
|
|
|
*
|
|
|
|
* 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,
|
2010-02-12 14:34:04 +01:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 13:37:38 +02:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-01-07 20:13:47 +01:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 13:37:38 +02:00
|
|
|
*/
|
2012-02-17 19:59:41 +01:00
|
|
|
#ifndef __BKE_LIBRARY_H__
|
|
|
|
#define __BKE_LIBRARY_H__
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2011-02-18 14:05:18 +01:00
|
|
|
/** \file BKE_library.h
|
|
|
|
* \ingroup bke
|
|
|
|
* \since March 2001
|
|
|
|
* \author nzc
|
|
|
|
*/
|
2010-10-05 02:05:14 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-09-01 17:01:15 +02:00
|
|
|
#include "BLI_compiler_attrs.h"
|
|
|
|
|
Make .blend file thumbnail reading simpler and more coherent, read/store them when reading in background mode.
Primary goal of this commit is to fix an annoying issue - when processing and saving .blend
files in background mode you lose their thumbnails, since it can only be generated with
an OpenGL context.
Solution to that is to read .blend thumbnail while reading .blend file (only done in background
mode currently), and store it in Main struct.
Also, this lead to removing .blend file reading code from thumb_blend (no need to have doublons).
We now have a small interface in regular reading code area, which keeps it reasonbaly light
by only reading/parsing header info, and first few BHead blocks.
This makes code reading .blend thumbnail about 3 to 4 times slower than previous highly specialized
one in blend_thumb.c, but overall thumbnail generation of a big .blend files folder only grows
of about 1%, think we can bare with it.
Finally, since thumbnail is now optionally stored in Main struct, it makes it easy to allow user
to define their own custom one (instead of auto-generated one). RNA API for this was not added though,
accessing that kind of .blend meta-data has to be rethought a bit on a bigger level first.
Reviewers: sergey, campbellbarton
Subscribers: Severin, psy-fi
Differential Revision: https://developer.blender.org/D1469
2015-08-27 15:53:23 +02:00
|
|
|
struct BlendThumbnail;
|
2002-10-12 13:37:38 +02:00
|
|
|
struct ListBase;
|
|
|
|
struct ID;
|
Make .blend file thumbnail reading simpler and more coherent, read/store them when reading in background mode.
Primary goal of this commit is to fix an annoying issue - when processing and saving .blend
files in background mode you lose their thumbnails, since it can only be generated with
an OpenGL context.
Solution to that is to read .blend thumbnail while reading .blend file (only done in background
mode currently), and store it in Main struct.
Also, this lead to removing .blend file reading code from thumb_blend (no need to have doublons).
We now have a small interface in regular reading code area, which keeps it reasonbaly light
by only reading/parsing header info, and first few BHead blocks.
This makes code reading .blend thumbnail about 3 to 4 times slower than previous highly specialized
one in blend_thumb.c, but overall thumbnail generation of a big .blend files folder only grows
of about 1%, think we can bare with it.
Finally, since thumbnail is now optionally stored in Main struct, it makes it easy to allow user
to define their own custom one (instead of auto-generated one). RNA API for this was not added though,
accessing that kind of .blend meta-data has to be rethought a bit on a bigger level first.
Reviewers: sergey, campbellbarton
Subscribers: Severin, psy-fi
Differential Revision: https://developer.blender.org/D1469
2015-08-27 15:53:23 +02:00
|
|
|
struct ImBuf;
|
2002-10-12 13:37:38 +02:00
|
|
|
struct Main;
|
|
|
|
struct Library;
|
2007-12-24 19:38:03 +01:00
|
|
|
struct wmWindowManager;
|
|
|
|
struct bContext;
|
2011-06-29 06:34:20 +02:00
|
|
|
struct PointerRNA;
|
|
|
|
struct PropertyRNA;
|
2002-10-12 13:37:38 +02:00
|
|
|
|
First step to handle missing libs/datablocks when reading a file.
Idea is, instead of ignoring completely missing linked datablocks, to
create void placeholders for them.
That way, you can work on your file, save it, and find again your missing data once
lib becomes available again. Or you can edit missing lib's path (in Outliner),
save and reload the file, and you are done.
Also, Outliner now shows broken libraries (and placeholders) with a 'broken lib' icon.
Future plans are also to be able to relocate missing libs and reload them at runtime.
Code notes:
- Placeholder ID is just a regular datablock of same type as expected linked one,
with 'default' data, and a LIB_MISSING bitflag set.
- To allow creation of such datablocks, creation of datablocks in BKE was split in two step:
+ Allocation of memory itself.
+ Setting of all internal data to default values.
See also the design task (T43351).
Reviewed by @campbellbarton, thanks a bunch!
Differential Revision: https://developer.blender.org/D1394
2015-10-20 14:44:57 +02:00
|
|
|
void *BKE_libblock_alloc_notest(short type);
|
2014-01-15 16:37:03 +01:00
|
|
|
void *BKE_libblock_alloc(struct Main *bmain, short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
First step to handle missing libs/datablocks when reading a file.
Idea is, instead of ignoring completely missing linked datablocks, to
create void placeholders for them.
That way, you can work on your file, save it, and find again your missing data once
lib becomes available again. Or you can edit missing lib's path (in Outliner),
save and reload the file, and you are done.
Also, Outliner now shows broken libraries (and placeholders) with a 'broken lib' icon.
Future plans are also to be able to relocate missing libs and reload them at runtime.
Code notes:
- Placeholder ID is just a regular datablock of same type as expected linked one,
with 'default' data, and a LIB_MISSING bitflag set.
- To allow creation of such datablocks, creation of datablocks in BKE was split in two step:
+ Allocation of memory itself.
+ Setting of all internal data to default values.
See also the design task (T43351).
Reviewed by @campbellbarton, thanks a bunch!
Differential Revision: https://developer.blender.org/D1394
2015-10-20 14:44:57 +02:00
|
|
|
void BKE_libblock_init_empty(struct ID *id);
|
2013-09-01 17:01:15 +02:00
|
|
|
void *BKE_libblock_copy_ex(struct Main *bmain, struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
2014-05-09 14:59:14 +02:00
|
|
|
void *BKE_libblock_copy_nolib(struct ID *id, const bool do_action) ATTR_NONNULL();
|
2013-09-01 17:01:15 +02:00
|
|
|
void *BKE_libblock_copy(struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
2013-03-10 06:46:24 +01:00
|
|
|
void BKE_libblock_copy_data(struct ID *id, const struct ID *id_from, const bool do_action);
|
2015-10-08 11:29:49 +02:00
|
|
|
void BKE_libblock_relink(struct ID *id);
|
2015-12-28 07:17:25 +01:00
|
|
|
void BKE_libblock_rename(struct Main *bmain, struct ID *id, const char *name) ATTR_NONNULL();
|
|
|
|
void BLI_libblock_ensure_unique_name(struct Main *bmain, const char *name) ATTR_NONNULL();
|
|
|
|
|
|
|
|
void BKE_libblock_free(struct Main *bmain, void *idv) ATTR_NONNULL();
|
|
|
|
void BKE_libblock_free_ex(struct Main *bmain, void *idv, bool do_id_user) ATTR_NONNULL();
|
|
|
|
void BKE_libblock_free_us(struct Main *bmain, void *idv) ATTR_NONNULL();
|
|
|
|
void BKE_libblock_free_data(struct Main *bmain, struct ID *id) ATTR_NONNULL();
|
|
|
|
|
|
|
|
struct ID *BKE_libblock_find_name_ex(struct Main *bmain, const short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
|
|
|
struct ID *BKE_libblock_find_name(const short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2011-11-30 01:32:13 +01:00
|
|
|
void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id);
|
2002-10-12 13:37:38 +02:00
|
|
|
void id_lib_extern(struct ID *id);
|
2011-10-23 19:52:20 +02:00
|
|
|
void BKE_library_filepath_set(struct Library *lib, const char *filepath);
|
2012-12-18 09:41:38 +01:00
|
|
|
void id_us_ensure_real(struct ID *id);
|
2016-02-22 12:09:36 +01:00
|
|
|
void id_us_clear_real(struct ID *id);
|
2002-10-12 13:37:38 +02:00
|
|
|
void id_us_plus(struct ID *id);
|
2009-05-27 02:03:49 +02:00
|
|
|
void id_us_min(struct ID *id);
|
2015-11-09 20:59:42 +01:00
|
|
|
void id_fake_user_set(struct ID *id);
|
|
|
|
void id_fake_user_clear(struct ID *id);
|
2012-05-05 16:03:12 +02:00
|
|
|
|
2013-03-10 06:46:24 +01:00
|
|
|
bool id_make_local(struct ID *id, bool test);
|
|
|
|
bool id_single_user(struct bContext *C, struct ID *id, struct PointerRNA *ptr, struct PropertyRNA *prop);
|
|
|
|
bool id_copy(struct ID *id, struct ID **newid, bool test);
|
|
|
|
bool id_unlink(struct ID *id, int test);
|
2012-04-06 18:19:30 +02:00
|
|
|
void id_sort_by_name(struct ListBase *lb, struct ID *id);
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2013-03-10 06:46:24 +01:00
|
|
|
bool new_id(struct ListBase *lb, struct ID *id, const char *name);
|
2011-10-26 23:22:35 +02:00
|
|
|
void id_clear_lib_data(struct Main *bmain, struct ID *id);
|
2016-02-11 22:32:11 +01:00
|
|
|
void id_clear_lib_data_ex(struct Main *bmain, struct ID *id, bool id_in_mainlist);
|
2002-10-12 13:37:38 +02:00
|
|
|
|
* Multiply for panorama cameras
* Some cases of struct name being set where it shouldnt have been.
* Spelling: wich --> which
* Copy and initialize uv modifier scale, remove unneeded enum.
* Ability to pin any object into the context.
* Update uv window while transforming (useful when used with UVProject modifier)
* Patch by Wahooney, so new template's are internal text and dont get saved over
by mistake.
* Fix for https://bugzilla.redhat.com/show_bug.cgi?id=572186
Bug 572186 - [abrt] crash in blender-2.49b-5.fc12: Process
/usr/bin/blender.bin was killed by signal 6 (SIGABRT). Original fix submitted
by Jochen Schmitt.
* [#21816] bpy.data.add_image has stopped working on Windows. moved to
bpy.data.images.load(), missed this call.
(commits 27726,27825,27828,27831,27832,27833,27834,27836,27837,27838,27839,27858 by Campbell from render25 branch)
2010-03-30 14:15:16 +02:00
|
|
|
struct ListBase *which_libbase(struct Main *mainlib, short type);
|
2006-09-06 11:51:30 +02:00
|
|
|
|
2015-10-22 16:20:01 +02:00
|
|
|
#define MAX_LIBARRAY 34
|
2014-09-22 05:23:42 +02:00
|
|
|
int set_listbasepointers(struct Main *main, struct ListBase *lb[MAX_LIBARRAY]);
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2013-12-30 03:25:27 +01:00
|
|
|
/* Main API */
|
2013-12-26 12:24:42 +01:00
|
|
|
struct Main *BKE_main_new(void);
|
2013-12-30 03:25:27 +01:00
|
|
|
void BKE_main_free(struct Main *mainvar);
|
|
|
|
|
2014-06-26 10:55:40 +02:00
|
|
|
void BKE_main_lock(struct Main *bmain);
|
|
|
|
void BKE_main_unlock(struct Main *bmain);
|
|
|
|
|
Make .blend file thumbnail reading simpler and more coherent, read/store them when reading in background mode.
Primary goal of this commit is to fix an annoying issue - when processing and saving .blend
files in background mode you lose their thumbnails, since it can only be generated with
an OpenGL context.
Solution to that is to read .blend thumbnail while reading .blend file (only done in background
mode currently), and store it in Main struct.
Also, this lead to removing .blend file reading code from thumb_blend (no need to have doublons).
We now have a small interface in regular reading code area, which keeps it reasonbaly light
by only reading/parsing header info, and first few BHead blocks.
This makes code reading .blend thumbnail about 3 to 4 times slower than previous highly specialized
one in blend_thumb.c, but overall thumbnail generation of a big .blend files folder only grows
of about 1%, think we can bare with it.
Finally, since thumbnail is now optionally stored in Main struct, it makes it easy to allow user
to define their own custom one (instead of auto-generated one). RNA API for this was not added though,
accessing that kind of .blend meta-data has to be rethought a bit on a bigger level first.
Reviewers: sergey, campbellbarton
Subscribers: Severin, psy-fi
Differential Revision: https://developer.blender.org/D1469
2015-08-27 15:53:23 +02:00
|
|
|
struct BlendThumbnail *BKE_main_thumbnail_from_imbuf(struct Main *bmain, struct ImBuf *img);
|
|
|
|
struct ImBuf *BKE_main_thumbnail_to_imbuf(struct Main *bmain, struct BlendThumbnail *data);
|
|
|
|
void BKE_main_thumbnail_create(struct Main *bmain);
|
|
|
|
|
2016-02-15 19:35:35 +01:00
|
|
|
void BKE_main_id_tag_idcode(struct Main *mainvar, const short type, const int tag, const bool value);
|
|
|
|
void BKE_main_id_tag_listbase(struct ListBase *lb, const int tag, const bool value);
|
|
|
|
void BKE_main_id_tag_all(struct Main *mainvar, const int tag, const bool value);
|
2013-12-30 03:25:27 +01:00
|
|
|
|
2016-03-03 11:11:22 +01:00
|
|
|
void BKE_main_id_flag_listbase(struct ListBase *lb, const int flag, const bool value);
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
void BKE_main_id_flag_all(struct Main *bmain, const int flag, const bool value);
|
2013-12-30 03:25:27 +01:00
|
|
|
|
|
|
|
void BKE_main_id_clear_newpoins(struct Main *bmain);
|
2011-01-05 06:33:27 +01:00
|
|
|
|
2013-12-30 03:25:27 +01:00
|
|
|
void BKE_main_lib_objects_recalc_all(struct Main *bmain);
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2015-12-28 07:17:25 +01:00
|
|
|
/* (MAX_ID_NAME - 2) + 3 */
|
|
|
|
void BKE_id_ui_prefix(char name[66 + 1], const struct ID *id);
|
2013-12-30 03:25:27 +01:00
|
|
|
|
2016-01-04 14:02:05 +01:00
|
|
|
void BKE_library_make_local(struct Main *bmain, struct Library *lib, bool untagged_only, bool set_fake);
|
2013-12-30 03:25:27 +01:00
|
|
|
|
2015-11-10 20:34:59 +01:00
|
|
|
typedef void (*BKE_library_free_window_manager_cb)(struct bContext *, struct wmWindowManager *);
|
|
|
|
typedef void (*BKE_library_free_notifier_reference_cb)(const void *);
|
|
|
|
typedef void (*BKE_library_free_editor_id_reference_cb)(const struct ID *);
|
|
|
|
|
|
|
|
void BKE_library_callback_free_window_manager_set(BKE_library_free_window_manager_cb func);
|
|
|
|
void BKE_library_callback_free_notifier_reference_set(BKE_library_free_notifier_reference_cb func);
|
|
|
|
void BKE_library_callback_free_editor_id_reference_set(BKE_library_free_editor_id_reference_cb func);
|
2007-12-24 19:38:03 +01:00
|
|
|
|
2010-03-06 19:21:57 +01:00
|
|
|
/* use when "" is given to new_id() */
|
2013-03-25 09:29:06 +01:00
|
|
|
#define ID_FALLBACK_NAME N_("Untitled")
|
2010-03-06 19:21:57 +01:00
|
|
|
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->tag & LIB_TAG_DOIT))
|
2010-12-20 08:21:08 +01:00
|
|
|
|
2010-10-05 02:05:14 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-03-10 06:46:24 +01:00
|
|
|
#endif /* __BKE_LIBRARY_H__ */
|