2002-10-12 11:37:38 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00: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-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00: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 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00: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-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
* blenloader readfile private function prototypes
|
|
|
|
*/
|
2011-02-27 20:35:41 +00:00
|
|
|
|
|
|
|
/** \file blender/blenloader/intern/readfile.h
|
|
|
|
* \ingroup blenloader
|
|
|
|
*/
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __READFILE_H__
|
|
|
|
#define __READFILE_H__
|
2002-10-12 11:37:38 +00:00
|
|
|
|
Patch provided by Shaul Kedem: Compressed files are back!
He even made a nice doc in wiki:
http://wiki.blender.org/bin/view.pl/Blenderdev/Blendgz
Usage: set the option "Compress File" in the main "File" pulldown menu.
This setting is a user-def, meaning it is not changed on reading files.
If you want it default, save it with CTRL+U.
The longest debate went over the file naming convention. Shaul started
with .blend.gz files, which gave issues in Blender because of the code
hanging out everywhere that detects blender files, and that appends the
.blend extension if needed.
Daniel Dunbar proposed to just save it as .blend, and not bother users
with such details. This is indeed the most elegant solution, with as
only drawback that old Blender executables cannot read it.
This drawback isn't very relevant at the moment, since we're heading
towards a release that isn't upward compatible anyway... the recode
going on on Meshes, Modfiers, Armatures, Poses, Actions, NLA already
have upward compatibility issues.
We might check - during the next month(s) - on a builtin system to
warn users in the future when we change things that make a file risky
to read in an older release.
2005-07-27 19:46:06 +00:00
|
|
|
#include "zlib.h"
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
#include "DNA_sdna_types.h"
|
|
|
|
#include "DNA_space_types.h"
|
2013-11-29 23:16:13 +06:00
|
|
|
#include "DNA_windowmanager_types.h" /* for ReportType */
|
Patch provided by Shaul Kedem: Compressed files are back!
He even made a nice doc in wiki:
http://wiki.blender.org/bin/view.pl/Blenderdev/Blendgz
Usage: set the option "Compress File" in the main "File" pulldown menu.
This setting is a user-def, meaning it is not changed on reading files.
If you want it default, save it with CTRL+U.
The longest debate went over the file naming convention. Shaul started
with .blend.gz files, which gave issues in Blender because of the code
hanging out everywhere that detects blender files, and that appends the
.blend extension if needed.
Daniel Dunbar proposed to just save it as .blend, and not bother users
with such details. This is indeed the most elegant solution, with as
only drawback that old Blender executables cannot read it.
This drawback isn't very relevant at the moment, since we're heading
towards a release that isn't upward compatible anyway... the recode
going on on Meshes, Modfiers, Armatures, Poses, Actions, NLA already
have upward compatibility issues.
We might check - during the next month(s) - on a builtin system to
warn users in the future when we change things that make a file risky
to read in an older release.
2005-07-27 19:46:06 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
struct OldNewMap;
|
2004-09-05 13:43:51 +00:00
|
|
|
struct MemFile;
|
2008-12-19 00:50:21 +00:00
|
|
|
struct ReportList;
|
2012-05-04 15:42:49 +00:00
|
|
|
struct Object;
|
|
|
|
struct PartEff;
|
|
|
|
struct View3D;
|
2013-11-29 23:16:13 +06:00
|
|
|
struct Key;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
typedef struct FileData {
|
|
|
|
// linked list of BHeadN's
|
|
|
|
ListBase listbase;
|
|
|
|
int flags;
|
|
|
|
int eof;
|
|
|
|
int buffersize;
|
|
|
|
int seek;
|
2009-01-02 19:10:35 +00:00
|
|
|
int (*read)(struct FileData *filedata, void *buffer, unsigned int size);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
// variables needed for reading from memory / stream
|
2013-03-17 19:13:04 +00:00
|
|
|
const char *buffer;
|
2004-09-05 13:43:51 +00:00
|
|
|
// variables needed for reading from memfile (undo)
|
|
|
|
struct MemFile *memfile;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
// variables needed for reading from file
|
|
|
|
int filedes;
|
Patch provided by Shaul Kedem: Compressed files are back!
He even made a nice doc in wiki:
http://wiki.blender.org/bin/view.pl/Blenderdev/Blendgz
Usage: set the option "Compress File" in the main "File" pulldown menu.
This setting is a user-def, meaning it is not changed on reading files.
If you want it default, save it with CTRL+U.
The longest debate went over the file naming convention. Shaul started
with .blend.gz files, which gave issues in Blender because of the code
hanging out everywhere that detects blender files, and that appends the
.blend extension if needed.
Daniel Dunbar proposed to just save it as .blend, and not bother users
with such details. This is indeed the most elegant solution, with as
only drawback that old Blender executables cannot read it.
This drawback isn't very relevant at the moment, since we're heading
towards a release that isn't upward compatible anyway... the recode
going on on Meshes, Modfiers, Armatures, Poses, Actions, NLA already
have upward compatibility issues.
We might check - during the next month(s) - on a builtin system to
warn users in the future when we change things that make a file risky
to read in an older release.
2005-07-27 19:46:06 +00:00
|
|
|
gzFile gzfiledes;
|
|
|
|
|
2005-06-02 17:38:42 +00:00
|
|
|
// now only in use for library appending
|
2011-11-26 04:07:38 +00:00
|
|
|
char relabase[FILE_MAX];
|
2018-06-17 17:06:07 +02:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
// variables needed for reading from stream
|
|
|
|
char headerdone;
|
|
|
|
int inbuffer;
|
2018-06-17 17:06:07 +02:00
|
|
|
|
2012-12-27 15:07:19 +00:00
|
|
|
// gzip stream for memory decompression
|
|
|
|
z_stream strm;
|
2018-06-17 17:06:07 +02:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
// general reading variables
|
|
|
|
struct SDNA *filesdna;
|
2016-07-12 12:53:49 +10:00
|
|
|
const struct SDNA *memsdna;
|
2016-07-21 11:49:30 +10:00
|
|
|
const char *compflags; /* array of eSDNA_StructCompare */
|
2018-06-17 17:06:07 +02:00
|
|
|
|
2006-11-27 18:58:33 +00:00
|
|
|
int fileversion;
|
2012-05-12 20:39:39 +00:00
|
|
|
int id_name_offs; /* used to retrieve ID names from (bhead+1) */
|
|
|
|
int globalf, fileflags; /* for do_versions patching */
|
2018-06-17 17:06:07 +02:00
|
|
|
|
2017-03-16 03:54:58 +11:00
|
|
|
eBLOReadSkip skip_flags; /* skip some data-blocks */
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
struct OldNewMap *datamap;
|
|
|
|
struct OldNewMap *globmap;
|
|
|
|
struct OldNewMap *libmap;
|
2006-11-10 10:17:04 +00:00
|
|
|
struct OldNewMap *imamap;
|
2011-11-07 12:55:18 +00:00
|
|
|
struct OldNewMap *movieclipmap;
|
2018-07-10 15:02:25 +02:00
|
|
|
struct OldNewMap *scenemap;
|
2014-11-24 18:18:35 +01:00
|
|
|
struct OldNewMap *soundmap;
|
2012-12-27 15:07:19 +00:00
|
|
|
struct OldNewMap *packedmap;
|
2018-06-17 17:06:07 +02:00
|
|
|
|
2012-08-04 19:34:38 +00:00
|
|
|
struct BHeadSort *bheadmap;
|
2008-01-30 18:18:33 +00:00
|
|
|
int tot_bheadmap;
|
2015-03-11 00:33:44 +11:00
|
|
|
|
|
|
|
/* see: USE_GHASH_BHEAD */
|
|
|
|
struct GHash *bhead_idname_hash;
|
2018-06-17 17:06:07 +02:00
|
|
|
|
2012-05-25 17:13:30 +00:00
|
|
|
ListBase *mainlist;
|
Fix T34446: Make Local on linked mesh object: object gets removed if redo function is used.
Root of the issue is that we do not re-read lib data blocks and ID placholders (ID_ID bheads)
in undo context (in `blo_read_file_internal`), because `BLO_read_from_memfile` copies
lib datablocks and Main data directly from oldmain.
The idea being, linked data do not change from undo/redo.
This is valid as long as linked data was not changed by the undo step - but if some
was deleted or localized, it will be missing from oldmain, leading to data loss
(note that does not only concern objects, all linkable data types can be affected,
at least in theory).
This commit addresses that issue by carefully mixing reuse of needed data from oldmain,
and "normal" re-reading of missing one. Makes us swimming in some rather dark waters,
and gives a rather non-easy-to-follow code, but it seems to work quite well,
and only other solution would be to get rid of that optimization
(not re-reading all libs on undo/redo), which is not acceptable.
Also, thanks to @carlosdp for initial investigation of the issue.
Differential Revision: https://developer.blender.org/D1485
2015-10-12 12:15:05 +02:00
|
|
|
ListBase *old_mainlist; /* Used for undo. */
|
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
/* ick ick, used to return
|
|
|
|
* data through streamglue.
|
|
|
|
*/
|
2002-10-12 11:37:38 +00:00
|
|
|
BlendFileData **bfd_r;
|
2008-12-19 00:50:21 +00:00
|
|
|
struct ReportList *reports;
|
2002-10-12 11:37:38 +00:00
|
|
|
} FileData;
|
|
|
|
|
|
|
|
typedef struct BHeadN {
|
|
|
|
struct BHeadN *next, *prev;
|
|
|
|
struct BHead bhead;
|
|
|
|
} BHeadN;
|
|
|
|
|
2016-02-01 14:03:31 +01:00
|
|
|
/* FileData->flags */
|
|
|
|
enum {
|
|
|
|
FD_FLAGS_SWITCH_ENDIAN = 1 << 0,
|
|
|
|
FD_FLAGS_FILE_POINTSIZE_IS_4 = 1 << 1,
|
|
|
|
FD_FLAGS_POINTSIZE_DIFFERS = 1 << 2,
|
|
|
|
FD_FLAGS_FILE_OK = 1 << 3,
|
|
|
|
FD_FLAGS_NOT_MY_BUFFER = 1 << 4,
|
|
|
|
FD_FLAGS_NOT_MY_LIBMAP = 1 << 5, /* XXX Unused in practice (checked once but never set). */
|
|
|
|
};
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#define SIZEOFBLENDERHEADER 12
|
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
/***/
|
2006-11-25 13:07:28 +00:00
|
|
|
struct Main;
|
2002-10-12 11:37:38 +00:00
|
|
|
void blo_join_main(ListBase *mainlist);
|
2006-11-25 13:07:28 +00:00
|
|
|
void blo_split_main(ListBase *mainlist, struct Main *main);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-05-18 06:27:32 +00:00
|
|
|
BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-05-18 06:27:32 +00:00
|
|
|
FileData *blo_openblenderfile(const char *filepath, struct ReportList *reports);
|
2013-03-17 19:13:04 +00:00
|
|
|
FileData *blo_openblendermemory(const void *buffer, int buffersize, struct ReportList *reports);
|
2008-12-19 00:50:21 +00:00
|
|
|
FileData *blo_openblendermemfile(struct MemFile *memfile, struct ReportList *reports);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
void blo_clear_proxy_pointers_from_lib(Main *oldmain);
|
2008-12-19 16:36:15 +00:00
|
|
|
void blo_make_image_pointer_map(FileData *fd, Main *oldmain);
|
|
|
|
void blo_end_image_pointer_map(FileData *fd, Main *oldmain);
|
2018-07-10 15:02:25 +02:00
|
|
|
void blo_make_scene_pointer_map(FileData *fd, Main *oldmain);
|
|
|
|
void blo_end_scene_pointer_map(FileData *fd, Main *oldmain);
|
2011-11-07 12:55:18 +00:00
|
|
|
void blo_make_movieclip_pointer_map(FileData *fd, Main *oldmain);
|
|
|
|
void blo_end_movieclip_pointer_map(FileData *fd, Main *oldmain);
|
2014-11-24 18:18:35 +01:00
|
|
|
void blo_make_sound_pointer_map(FileData *fd, Main *oldmain);
|
|
|
|
void blo_end_sound_pointer_map(FileData *fd, Main *oldmain);
|
2012-12-27 15:07:19 +00:00
|
|
|
void blo_make_packed_pointer_map(FileData *fd, Main *oldmain);
|
|
|
|
void blo_end_packed_pointer_map(FileData *fd, Main *oldmain);
|
Fix T34446: Make Local on linked mesh object: object gets removed if redo function is used.
Root of the issue is that we do not re-read lib data blocks and ID placholders (ID_ID bheads)
in undo context (in `blo_read_file_internal`), because `BLO_read_from_memfile` copies
lib datablocks and Main data directly from oldmain.
The idea being, linked data do not change from undo/redo.
This is valid as long as linked data was not changed by the undo step - but if some
was deleted or localized, it will be missing from oldmain, leading to data loss
(note that does not only concern objects, all linkable data types can be affected,
at least in theory).
This commit addresses that issue by carefully mixing reuse of needed data from oldmain,
and "normal" re-reading of missing one. Makes us swimming in some rather dark waters,
and gives a rather non-easy-to-follow code, but it seems to work quite well,
and only other solution would be to get rid of that optimization
(not re-reading all libs on undo/redo), which is not acceptable.
Also, thanks to @carlosdp for initial investigation of the issue.
Differential Revision: https://developer.blender.org/D1485
2015-10-12 12:15:05 +02:00
|
|
|
void blo_add_library_pointer_map(ListBase *old_mainlist, FileData *fd);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
void blo_freefiledata(FileData *fd);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-09-05 13:43:51 +00:00
|
|
|
BHead *blo_firstbhead(FileData *fd);
|
|
|
|
BHead *blo_nextbhead(FileData *fd, BHead *thisblock);
|
|
|
|
BHead *blo_prevbhead(FileData *fd, BHead *thisblock);
|
2007-04-28 16:15:00 +00:00
|
|
|
|
2015-03-10 23:40:39 +11:00
|
|
|
const char *bhead_id_name(const FileData *fd, const BHead *bhead);
|
2007-04-28 16:15:00 +00:00
|
|
|
|
2012-05-04 15:42:49 +00:00
|
|
|
/* do versions stuff */
|
|
|
|
|
2013-11-29 23:16:13 +06:00
|
|
|
void blo_reportf_wrap(struct ReportList *reports, ReportType type, const char *format, ...) ATTR_PRINTF_FORMAT(3, 4);
|
|
|
|
|
2016-06-06 18:03:45 +10:00
|
|
|
void blo_do_versions_oldnewmap_insert(struct OldNewMap *onm, const void *oldaddr, void *newaddr, int nr);
|
|
|
|
void *blo_do_versions_newlibadr(struct FileData *fd, const void *lib, const void *adr);
|
|
|
|
void *blo_do_versions_newlibadr_us(struct FileData *fd, const void *lib, const void *adr);
|
2012-05-04 15:42:49 +00:00
|
|
|
|
|
|
|
struct PartEff *blo_do_version_give_parteff_245(struct Object *ob);
|
|
|
|
void blo_do_version_old_trackto_to_constraints(struct Object *ob);
|
|
|
|
void blo_do_versions_view3d_split_250(struct View3D *v3d, struct ListBase *regions);
|
2013-11-29 23:16:13 +06:00
|
|
|
void blo_do_versions_key_uidgen(struct Key *key);
|
2012-05-04 15:42:49 +00:00
|
|
|
|
2018-06-05 15:10:33 +02:00
|
|
|
void blo_do_versions_pre250(struct FileData *fd, struct Library *lib, struct Main *bmain);
|
|
|
|
void blo_do_versions_250(struct FileData *fd, struct Library *lib, struct Main *bmain);
|
|
|
|
void blo_do_versions_260(struct FileData *fd, struct Library *lib, struct Main *bmain);
|
|
|
|
void blo_do_versions_270(struct FileData *fd, struct Library *lib, struct Main *bmain);
|
2018-06-05 17:02:50 +02:00
|
|
|
void blo_do_versions_280(struct FileData *fd, struct Library *lib, struct Main *bmain);
|
2012-05-04 15:42:49 +00:00
|
|
|
|
2018-06-05 15:10:33 +02:00
|
|
|
void do_versions_after_linking_270(struct Main *bmain);
|
2018-06-05 17:02:50 +02:00
|
|
|
void do_versions_after_linking_280(struct Main *bmain);
|
2016-12-07 13:52:12 +01:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif
|