2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2012-02-17 19:59:41 +01:00
|
|
|
#pragma once
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup blenloader
|
2023-07-31 03:50:54 +02:00
|
|
|
* \brief external `writefile.cc` function prototypes.
|
2011-02-18 00:34:07 +01:00
|
|
|
*/
|
|
|
|
|
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;
|
2008-12-19 17:36:15 +01:00
|
|
|
struct Main;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct MemFile;
|
2008-12-19 01:50:21 +01:00
|
|
|
struct ReportList;
|
2004-09-05 15:43:51 +02:00
|
|
|
|
2020-06-23 08:38:52 +02:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name BLO Write File API
|
|
|
|
*
|
|
|
|
* \see #BLO_read_from_file for file reading.
|
|
|
|
* \{ */
|
|
|
|
|
2020-06-18 07:25:22 +02:00
|
|
|
/**
|
2020-06-27 06:34:16 +02:00
|
|
|
* Adjust paths when saving (kept unless #BlendFileWriteParams.use_save_as_copy is set).
|
2020-06-18 07:25:22 +02:00
|
|
|
*/
|
2024-01-04 21:07:48 +01:00
|
|
|
enum eBLO_WritePathRemap {
|
2020-06-18 07:25:22 +02:00
|
|
|
/** No path manipulation. */
|
2020-06-19 07:41:07 +02:00
|
|
|
BLO_WRITE_PATH_REMAP_NONE = 0,
|
2020-06-18 07:25:22 +02:00
|
|
|
/** Remap existing relative paths (default). */
|
2020-06-19 07:41:07 +02:00
|
|
|
BLO_WRITE_PATH_REMAP_RELATIVE = 1,
|
2020-06-18 07:25:22 +02:00
|
|
|
/** Remap paths making all paths relative to the new location. */
|
2020-06-19 07:41:07 +02:00
|
|
|
BLO_WRITE_PATH_REMAP_RELATIVE_ALL = 2,
|
2020-06-18 07:25:22 +02:00
|
|
|
/** Make all paths absolute. */
|
2020-06-19 07:41:07 +02:00
|
|
|
BLO_WRITE_PATH_REMAP_ABSOLUTE = 3,
|
2024-01-04 21:07:48 +01:00
|
|
|
};
|
2020-06-18 07:25:22 +02:00
|
|
|
|
2020-06-19 07:41:07 +02:00
|
|
|
/** Similar to #BlendFileReadParams. */
|
|
|
|
struct BlendFileWriteParams {
|
|
|
|
eBLO_WritePathRemap remap_mode;
|
|
|
|
/** Save `.blend1`, `.blend2`... etc. */
|
|
|
|
uint use_save_versions : 1;
|
|
|
|
/** On write, restore paths after editing them (see #BLO_WRITE_PATH_REMAP_RELATIVE). */
|
|
|
|
uint use_save_as_copy : 1;
|
|
|
|
uint use_userdef : 1;
|
2024-01-04 21:07:48 +01:00
|
|
|
const BlendThumbnail *thumb;
|
2020-06-19 07:41:07 +02:00
|
|
|
};
|
|
|
|
|
2021-12-08 07:37:44 +01:00
|
|
|
/**
|
|
|
|
* \return Success.
|
|
|
|
*/
|
2024-01-04 21:07:48 +01:00
|
|
|
extern bool BLO_write_file(Main *mainvar,
|
2016-03-03 03:35:21 +01:00
|
|
|
const char *filepath,
|
2022-01-07 01:38:08 +01:00
|
|
|
int write_flags,
|
2024-01-04 21:07:48 +01:00
|
|
|
const BlendFileWriteParams *params,
|
|
|
|
ReportList *reports);
|
2020-06-18 07:25:22 +02:00
|
|
|
|
2021-12-08 07:37:44 +01:00
|
|
|
/**
|
|
|
|
* \return Success.
|
|
|
|
*/
|
2024-01-04 21:07:48 +01:00
|
|
|
extern bool BLO_write_file_mem(Main *mainvar, MemFile *compare, MemFile *current, int write_flags);
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2020-06-23 08:38:52 +02:00
|
|
|
/** \} */
|