2008-01-01 15:53:38 +00:00
|
|
|
/*
|
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.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup blenloader
|
2011-02-27 20:35:41 +00:00
|
|
|
*/
|
|
|
|
|
|
2016-06-27 11:21:03 +10:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* FILE FORMAT
|
|
|
|
|
* ===========
|
|
|
|
|
*
|
2019-10-15 12:02:40 +11:00
|
|
|
* IFF-style structure (but not IFF compatible!)
|
2012-10-04 13:26:15 +00:00
|
|
|
*
|
2019-10-15 12:02:40 +11:00
|
|
|
* Start file:
|
2016-06-27 11:21:03 +10:00
|
|
|
* <pre>
|
2019-10-15 12:02:40 +11:00
|
|
|
* `BLENDER_V100` `12` bytes (version 1.00 is just an example).
|
|
|
|
|
* `V` = big endian, `v` = little endian.
|
|
|
|
|
* `_` = 4 byte pointer, `-` = 8 byte pointer.
|
2016-06-27 11:21:03 +10:00
|
|
|
* </pre>
|
2012-10-04 13:26:15 +00:00
|
|
|
*
|
2019-06-12 09:04:10 +10:00
|
|
|
* data-blocks: (also see struct #BHead).
|
2016-06-27 11:21:03 +10:00
|
|
|
* <pre>
|
2019-10-15 12:02:40 +11:00
|
|
|
* `bh.code` `char[4]` see `BLO_blend_defs.h` for a list of known types.
|
|
|
|
|
* `bh.len` `int32` length data after #BHead in bytes.
|
|
|
|
|
* `bh.old` `void *` old pointer (the address at the time of writing the file).
|
|
|
|
|
* `bh.SDNAnr` `int32` struct index of structs stored in #DNA1 data.
|
|
|
|
|
* `bh.nr` `int32` in case of array: number of structs.
|
|
|
|
|
* data
|
|
|
|
|
* ...
|
|
|
|
|
* ...
|
2016-06-27 11:21:03 +10:00
|
|
|
* </pre>
|
2012-10-04 13:26:15 +00:00
|
|
|
*
|
|
|
|
|
* Almost all data in Blender are structures. Each struct saved
|
|
|
|
|
* gets a BHead header. With BHead the struct can be linked again
|
2019-10-15 12:02:40 +11:00
|
|
|
* and compared with #StructDNA.
|
|
|
|
|
|
2012-10-04 13:26:15 +00:00
|
|
|
* WRITE
|
2016-06-27 11:21:03 +10:00
|
|
|
* =====
|
2012-10-04 13:26:15 +00:00
|
|
|
*
|
|
|
|
|
* Preferred writing order: (not really a must, but why would you do it random?)
|
2019-10-15 12:02:40 +11:00
|
|
|
* Any case: direct data is ALWAYS after the lib block.
|
2012-10-04 13:26:15 +00:00
|
|
|
*
|
|
|
|
|
* (Local file data)
|
|
|
|
|
* - for each LibBlock
|
2016-06-27 11:21:03 +10:00
|
|
|
* - write LibBlock
|
|
|
|
|
* - write associated direct data
|
2012-10-04 13:26:15 +00:00
|
|
|
* (External file data)
|
|
|
|
|
* - per library
|
2016-06-27 11:21:03 +10:00
|
|
|
* - write library block
|
|
|
|
|
* - per LibBlock
|
|
|
|
|
* - write the ID of LibBlock
|
|
|
|
|
* - write #TEST (#RenderInfo struct. 128x128 blend file preview is optional).
|
|
|
|
|
* - write #GLOB (#FileGlobal struct) (some global vars).
|
|
|
|
|
* - write #DNA1 (#SDNA struct)
|
2017-02-15 14:10:42 +11:00
|
|
|
* - write #USER (#UserDef struct) if filename is ``~/.config/blender/X.XX/config/startup.blend``.
|
2012-10-04 13:26:15 +00:00
|
|
|
*/
|
2003-04-26 18:01:01 +00:00
|
|
|
|
2009-09-06 13:20:05 +00:00
|
|
|
#include <fcntl.h>
|
2013-03-18 16:34:57 +00:00
|
|
|
#include <limits.h>
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <math.h>
|
2009-09-06 13:20:05 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <string.h>
|
2009-09-06 13:20:05 +00:00
|
|
|
|
2014-04-02 11:43:54 +02:00
|
|
|
#ifdef WIN32
|
2020-03-19 09:33:03 +01:00
|
|
|
# include "BLI_winstuff.h"
|
2012-04-15 07:54:07 +00:00
|
|
|
# include "winsock2.h"
|
|
|
|
|
# include <io.h>
|
2020-03-19 09:33:03 +01:00
|
|
|
# include <zlib.h> /* odd include order-issue */
|
2014-04-03 09:20:04 +02:00
|
|
|
#else
|
2019-04-17 06:17:24 +02:00
|
|
|
# include <unistd.h> /* FreeBSD, for write() and close(). */
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif
|
|
|
|
|
|
2013-02-22 13:35:32 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2012-01-21 11:15:01 +00:00
|
|
|
/* allow writefile to use deprecated functionality (for forward compatibility code) */
|
|
|
|
|
#define DNA_DEPRECATED_ALLOW
|
|
|
|
|
|
2009-01-18 10:41:45 +00:00
|
|
|
#include "DNA_anim_types.h"
|
2005-05-02 13:28:13 +00:00
|
|
|
#include "DNA_armature_types.h"
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
#include "DNA_cachefile_types.h"
|
2008-01-29 21:01:12 +00:00
|
|
|
#include "DNA_cloth_types.h"
|
2018-08-29 15:32:50 +02:00
|
|
|
#include "DNA_collection_types.h"
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
#include "DNA_constraint_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_curveprofile_types.h"
|
2011-05-24 07:08:58 +00:00
|
|
|
#include "DNA_dynamicpaint_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_fileglobal_types.h"
|
|
|
|
|
#include "DNA_fluid_types.h"
|
2008-10-31 23:50:02 +00:00
|
|
|
#include "DNA_genfile.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_lightprobe_types.h"
|
2004-03-20 22:55:42 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_movieclip_types.h"
|
2018-02-07 11:14:08 +11:00
|
|
|
#include "DNA_object_force_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_object_types.h"
|
2016-12-28 17:30:58 +01:00
|
|
|
#include "DNA_particle_types.h"
|
2020-06-09 17:01:44 +02:00
|
|
|
#include "DNA_pointcache_types.h"
|
2013-01-23 05:56:22 +00:00
|
|
|
#include "DNA_rigidbody_types.h"
|
2005-05-02 13:28:13 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_screen_types.h"
|
2005-05-02 13:28:13 +00:00
|
|
|
#include "DNA_sdna_types.h"
|
|
|
|
|
#include "DNA_sequence_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_shader_fx_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_space_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_view3d_types.h"
|
2007-12-24 18:53:37 +00:00
|
|
|
#include "DNA_windowmanager_types.h"
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
#include "DNA_workspace_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-03-14 06:31:38 +00:00
|
|
|
#include "BLI_bitmap.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2013-08-03 11:35:09 +00:00
|
|
|
#include "BLI_mempool.h"
|
2020-10-10 18:19:55 +11:00
|
|
|
#include "MEM_guardedalloc.h" /* MEM_freeN */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
#include "BKE_action.h"
|
2020-08-21 15:58:28 +02:00
|
|
|
#include "BKE_anim_data.h"
|
2020-09-10 11:17:35 +02:00
|
|
|
#include "BKE_animsys.h"
|
2020-08-10 10:43:26 +02:00
|
|
|
#include "BKE_armature.h"
|
2016-04-24 22:42:41 +10:00
|
|
|
#include "BKE_blender_version.h"
|
2013-08-03 11:35:09 +00:00
|
|
|
#include "BKE_bpath.h"
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
#include "BKE_collection.h"
|
2020-06-16 16:59:52 +02:00
|
|
|
#include "BKE_colortools.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_constraint.h"
|
2020-06-23 17:02:49 +02:00
|
|
|
#include "BKE_curveprofile.h"
|
2020-08-28 13:58:39 +02:00
|
|
|
#include "BKE_deform.h"
|
2018-11-07 18:00:24 +01:00
|
|
|
#include "BKE_fcurve.h"
|
2020-05-01 12:43:12 +02:00
|
|
|
#include "BKE_fcurve_driver.h"
|
2020-10-10 18:19:55 +11:00
|
|
|
#include "BKE_global.h" /* for G */
|
2018-07-31 10:22:19 +02:00
|
|
|
#include "BKE_gpencil_modifier.h"
|
2020-09-10 10:33:05 +02:00
|
|
|
#include "BKE_icons.h"
|
2020-08-21 12:45:33 +02:00
|
|
|
#include "BKE_idprop.h"
|
2020-03-19 19:37:00 +01:00
|
|
|
#include "BKE_idtype.h"
|
2018-07-04 13:00:46 +02:00
|
|
|
#include "BKE_layer.h"
|
2020-06-03 12:07:45 +02:00
|
|
|
#include "BKE_lib_id.h"
|
2020-02-10 12:58:59 +01:00
|
|
|
#include "BKE_lib_override.h"
|
2008-12-19 16:36:15 +00:00
|
|
|
#include "BKE_main.h"
|
2018-11-07 18:00:24 +01:00
|
|
|
#include "BKE_modifier.h"
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
#include "BKE_node.h"
|
2020-04-01 09:58:37 +02:00
|
|
|
#include "BKE_object.h"
|
2020-09-10 14:35:09 +02:00
|
|
|
#include "BKE_packedFile.h"
|
2018-11-07 18:00:24 +01:00
|
|
|
#include "BKE_pointcache.h"
|
2008-12-19 00:50:21 +00:00
|
|
|
#include "BKE_report.h"
|
2009-12-13 14:56:45 +00:00
|
|
|
#include "BKE_sequencer.h"
|
2018-07-31 10:22:19 +02:00
|
|
|
#include "BKE_shader_fx.h"
|
2012-05-10 20:33:24 +00:00
|
|
|
#include "BKE_subsurf.h"
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
#include "BKE_workspace.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-01-25 17:31:32 +01:00
|
|
|
#include "BLO_blend_defs.h"
|
|
|
|
|
#include "BLO_blend_validate.h"
|
2020-06-05 11:44:36 +02:00
|
|
|
#include "BLO_read_write.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BLO_readfile.h"
|
2004-09-05 13:43:51 +00:00
|
|
|
#include "BLO_undofile.h"
|
2019-01-25 17:31:32 +01:00
|
|
|
#include "BLO_writefile.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
#include "readfile.h"
|
|
|
|
|
|
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 <errno.h>
|
2004-09-05 13:43:51 +00:00
|
|
|
|
2019-11-24 22:54:51 +11:00
|
|
|
/* Make preferences read-only. */
|
|
|
|
|
#define U (*((const UserDef *)&U))
|
|
|
|
|
|
2008-03-05 15:13:41 +00:00
|
|
|
/* ********* my write, buffered writing with minimum size chunks ************ */
|
|
|
|
|
|
2016-07-08 14:32:29 +10:00
|
|
|
/* Use optimal allocation since blocks of this size are kept in memory for undo. */
|
2019-04-17 06:17:24 +02:00
|
|
|
#define MYWRITE_BUFFER_SIZE (MEM_SIZE_OPTIMAL(1 << 17)) /* 128kb */
|
|
|
|
|
#define MYWRITE_MAX_CHUNK (MEM_SIZE_OPTIMAL(1 << 15)) /* ~32kb */
|
2014-09-04 21:48:36 +10:00
|
|
|
|
2018-04-14 13:17:11 +02:00
|
|
|
/** Use if we want to store how many bytes have been written to the file. */
|
|
|
|
|
// #define USE_WRITE_DATA_LEN
|
2014-09-04 21:48:36 +10:00
|
|
|
|
2018-04-14 13:17:11 +02:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Internal Write Wrapper's (Abstracts Compression)
|
2014-09-04 21:48:36 +10:00
|
|
|
* \{ */
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
2019-04-17 06:17:24 +02:00
|
|
|
WW_WRAP_NONE = 1,
|
|
|
|
|
WW_WRAP_ZLIB,
|
2014-09-04 21:48:36 +10:00
|
|
|
} eWriteWrapType;
|
|
|
|
|
|
|
|
|
|
typedef struct WriteWrap WriteWrap;
|
|
|
|
|
struct WriteWrap {
|
2019-04-17 06:17:24 +02:00
|
|
|
/* callbacks */
|
|
|
|
|
bool (*open)(WriteWrap *ww, const char *filepath);
|
|
|
|
|
bool (*close)(WriteWrap *ww);
|
|
|
|
|
size_t (*write)(WriteWrap *ww, const char *data, size_t data_len);
|
|
|
|
|
|
|
|
|
|
/* Buffer output (we only want when output isn't already buffered). */
|
|
|
|
|
bool use_buf;
|
|
|
|
|
|
|
|
|
|
/* internal */
|
|
|
|
|
union {
|
|
|
|
|
int file_handle;
|
|
|
|
|
gzFile gz_handle;
|
|
|
|
|
} _user_data;
|
2014-09-04 21:48:36 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* none */
|
2019-04-17 06:17:24 +02:00
|
|
|
#define FILE_HANDLE(ww) (ww)->_user_data.file_handle
|
2014-09-04 21:48:36 +10:00
|
|
|
|
|
|
|
|
static bool ww_open_none(WriteWrap *ww, const char *filepath)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int file;
|
2014-09-04 21:48:36 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
file = BLI_open(filepath, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666);
|
2014-09-04 21:48:36 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (file != -1) {
|
|
|
|
|
FILE_HANDLE(ww) = file;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-08-07 12:31:44 +02:00
|
|
|
|
|
|
|
|
return false;
|
2014-09-04 21:48:36 +10:00
|
|
|
}
|
|
|
|
|
static bool ww_close_none(WriteWrap *ww)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return (close(FILE_HANDLE(ww)) != -1);
|
2014-09-04 21:48:36 +10:00
|
|
|
}
|
|
|
|
|
static size_t ww_write_none(WriteWrap *ww, const char *buf, size_t buf_len)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return write(FILE_HANDLE(ww), buf, buf_len);
|
2014-09-04 21:48:36 +10:00
|
|
|
}
|
|
|
|
|
#undef FILE_HANDLE
|
|
|
|
|
|
|
|
|
|
/* zlib */
|
2019-04-17 06:17:24 +02:00
|
|
|
#define FILE_HANDLE(ww) (ww)->_user_data.gz_handle
|
2014-09-04 21:48:36 +10:00
|
|
|
|
|
|
|
|
static bool ww_open_zlib(WriteWrap *ww, const char *filepath)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
gzFile file;
|
2014-09-04 21:48:36 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
file = BLI_gzopen(filepath, "wb1");
|
2014-09-04 21:48:36 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (file != Z_NULL) {
|
|
|
|
|
FILE_HANDLE(ww) = file;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-08-07 12:31:44 +02:00
|
|
|
|
|
|
|
|
return false;
|
2014-09-04 21:48:36 +10:00
|
|
|
}
|
|
|
|
|
static bool ww_close_zlib(WriteWrap *ww)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return (gzclose(FILE_HANDLE(ww)) == Z_OK);
|
2014-09-04 21:48:36 +10:00
|
|
|
}
|
|
|
|
|
static size_t ww_write_zlib(WriteWrap *ww, const char *buf, size_t buf_len)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return gzwrite(FILE_HANDLE(ww), buf, buf_len);
|
2014-09-04 21:48:36 +10:00
|
|
|
}
|
|
|
|
|
#undef FILE_HANDLE
|
|
|
|
|
|
|
|
|
|
/* --- end compression types --- */
|
|
|
|
|
|
|
|
|
|
static void ww_handle_init(eWriteWrapType ww_type, WriteWrap *r_ww)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
memset(r_ww, 0, sizeof(*r_ww));
|
|
|
|
|
|
|
|
|
|
switch (ww_type) {
|
|
|
|
|
case WW_WRAP_ZLIB: {
|
|
|
|
|
r_ww->open = ww_open_zlib;
|
|
|
|
|
r_ww->close = ww_close_zlib;
|
|
|
|
|
r_ww->write = ww_write_zlib;
|
|
|
|
|
r_ww->use_buf = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: {
|
|
|
|
|
r_ww->open = ww_open_none;
|
|
|
|
|
r_ww->close = ww_close_none;
|
|
|
|
|
r_ww->write = ww_write_none;
|
|
|
|
|
r_ww->use_buf = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-09-04 21:48:36 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \} */
|
|
|
|
|
|
2018-04-14 13:17:11 +02:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Write Data Type & Functions
|
|
|
|
|
* \{ */
|
2014-09-04 21:48:36 +10:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
typedef struct {
|
2019-04-17 06:17:24 +02:00
|
|
|
const struct SDNA *sdna;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/** Use for file and memory writing (fixed size of #MYWRITE_BUFFER_SIZE). */
|
|
|
|
|
uchar *buf;
|
|
|
|
|
/** Number of bytes used in #WriteData.buf (flushed when exceeded). */
|
2020-09-20 18:41:50 +02:00
|
|
|
size_t buf_used_len;
|
2018-04-14 13:17:11 +02:00
|
|
|
|
|
|
|
|
#ifdef USE_WRITE_DATA_LEN
|
2019-04-17 06:17:24 +02:00
|
|
|
/** Total number of bytes written. */
|
|
|
|
|
size_t write_len;
|
2018-04-14 13:17:11 +02:00
|
|
|
#endif
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/** Set on unlikely case of an error (ignores further file writing). */
|
|
|
|
|
bool error;
|
|
|
|
|
|
|
|
|
|
/** #MemFile writing (used for undo). */
|
2020-06-03 12:07:45 +02:00
|
|
|
MemFileWriteData mem;
|
2019-04-17 06:17:24 +02:00
|
|
|
/** When true, write to #WriteData.current, could also call 'is_undo'. */
|
|
|
|
|
bool use_memfile;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Wrap writing, so we can use zlib or
|
|
|
|
|
* other compression types later, see: G_FILE_COMPRESS
|
|
|
|
|
* Will be NULL for UNDO.
|
|
|
|
|
*/
|
|
|
|
|
WriteWrap *ww;
|
2002-10-12 11:37:38 +00:00
|
|
|
} WriteData;
|
|
|
|
|
|
2020-06-05 11:44:36 +02:00
|
|
|
typedef struct BlendWriter {
|
|
|
|
|
WriteData *wd;
|
|
|
|
|
} BlendWriter;
|
|
|
|
|
|
2014-09-04 21:48:36 +10:00
|
|
|
static WriteData *writedata_new(WriteWrap *ww)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
WriteData *wd = MEM_callocN(sizeof(*wd), "writedata");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
wd->sdna = DNA_sdna_current_get();
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
wd->ww = ww;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if ((ww == NULL) || (ww->use_buf)) {
|
|
|
|
|
wd->buf = MEM_mallocN(MYWRITE_BUFFER_SIZE, "wd->buf");
|
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return wd;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2020-09-20 18:41:50 +02:00
|
|
|
static void writedata_do_write(WriteData *wd, const void *mem, size_t memlen)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if ((wd == NULL) || wd->error || (mem == NULL) || memlen < 1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-20 18:41:50 +02:00
|
|
|
if (memlen > INT_MAX) {
|
|
|
|
|
BLI_assert(!"Cannot write chunks bigger than INT_MAX.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (UNLIKELY(wd->error)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* memory based save */
|
|
|
|
|
if (wd->use_memfile) {
|
2020-06-03 12:07:45 +02:00
|
|
|
BLO_memfile_chunk_add(&wd->mem, mem, memlen);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (wd->ww->write(wd->ww, mem, memlen) != memlen) {
|
|
|
|
|
wd->error = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2004-06-23 18:22:51 +00:00
|
|
|
static void writedata_free(WriteData *wd)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (wd->buf) {
|
|
|
|
|
MEM_freeN(wd->buf);
|
|
|
|
|
}
|
|
|
|
|
MEM_freeN(wd);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2018-04-14 13:17:11 +02:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Local Writing API 'mywrite'
|
|
|
|
|
* \{ */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2016-07-07 16:02:45 +10:00
|
|
|
/**
|
|
|
|
|
* Flush helps the de-duplicating memory for undo-save by logically segmenting data,
|
|
|
|
|
* so differences in one part of memory won't cause unrelated data to be duplicated.
|
|
|
|
|
*/
|
|
|
|
|
static void mywrite_flush(WriteData *wd)
|
|
|
|
|
{
|
2020-09-20 18:41:50 +02:00
|
|
|
if (wd->buf_used_len != 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
writedata_do_write(wd, wd->buf, wd->buf_used_len);
|
|
|
|
|
wd->buf_used_len = 0;
|
|
|
|
|
}
|
2016-07-07 16:02:45 +10:00
|
|
|
}
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* Low level WRITE(2) wrapper that buffers data
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param adr: Pointer to new chunk of data
|
|
|
|
|
* \param len: Length of new chunk of data
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2020-09-20 18:41:50 +02:00
|
|
|
static void mywrite(WriteData *wd, const void *adr, size_t len)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (UNLIKELY(wd->error)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (UNLIKELY(adr == NULL)) {
|
|
|
|
|
BLI_assert(0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2018-04-14 13:17:11 +02:00
|
|
|
#ifdef USE_WRITE_DATA_LEN
|
2019-04-17 06:17:24 +02:00
|
|
|
wd->write_len += len;
|
2018-04-14 13:17:11 +02:00
|
|
|
#endif
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (wd->buf == NULL) {
|
|
|
|
|
writedata_do_write(wd, adr, len);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* if we have a single big chunk, write existing data in
|
|
|
|
|
* buffer and write out big chunk in smaller pieces */
|
|
|
|
|
if (len > MYWRITE_MAX_CHUNK) {
|
2020-09-20 18:41:50 +02:00
|
|
|
if (wd->buf_used_len != 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
writedata_do_write(wd, wd->buf, wd->buf_used_len);
|
|
|
|
|
wd->buf_used_len = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
do {
|
2020-09-20 18:41:50 +02:00
|
|
|
size_t writelen = MIN2(len, MYWRITE_MAX_CHUNK);
|
2019-04-17 06:17:24 +02:00
|
|
|
writedata_do_write(wd, adr, writelen);
|
|
|
|
|
adr = (const char *)adr + writelen;
|
|
|
|
|
len -= writelen;
|
|
|
|
|
} while (len > 0);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* if data would overflow buffer, write out the buffer */
|
|
|
|
|
if (len + wd->buf_used_len > MYWRITE_BUFFER_SIZE - 1) {
|
|
|
|
|
writedata_do_write(wd, wd->buf, wd->buf_used_len);
|
|
|
|
|
wd->buf_used_len = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* append data at end of buffer */
|
|
|
|
|
memcpy(&wd->buf[wd->buf_used_len], adr, len);
|
|
|
|
|
wd->buf_used_len += len;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* BeGiN initializer for mywrite
|
2015-05-20 12:54:45 +10:00
|
|
|
* \param ww: File write wrapper.
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param compare: Previous memory file (can be NULL).
|
|
|
|
|
* \param current: The current memory file (can be NULL).
|
2012-03-02 16:05:54 +00:00
|
|
|
* \warning Talks to other functions with global parameters
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2018-04-14 13:17:11 +02:00
|
|
|
static WriteData *mywrite_begin(WriteWrap *ww, MemFile *compare, MemFile *current)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
WriteData *wd = writedata_new(ww);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (current != NULL) {
|
2020-06-03 12:07:45 +02:00
|
|
|
BLO_memfile_write_init(&wd->mem, current, compare);
|
2019-04-17 06:17:24 +02:00
|
|
|
wd->use_memfile = true;
|
|
|
|
|
}
|
2006-10-27 18:24:10 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return wd;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* END the mywrite wrapper
|
2012-03-02 16:05:54 +00:00
|
|
|
* \return 1 if write failed
|
|
|
|
|
* \return unknown global variable otherwise
|
|
|
|
|
* \warning Talks to other functions with global parameters
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2018-04-14 13:17:11 +02:00
|
|
|
static bool mywrite_end(WriteData *wd)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2020-09-20 18:41:50 +02:00
|
|
|
if (wd->buf_used_len != 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
writedata_do_write(wd, wd->buf, wd->buf_used_len);
|
|
|
|
|
wd->buf_used_len = 0;
|
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2020-06-03 12:07:45 +02:00
|
|
|
if (wd->use_memfile) {
|
|
|
|
|
BLO_memfile_write_finalize(&wd->mem);
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
const bool err = wd->error;
|
|
|
|
|
writedata_free(wd);
|
2007-02-14 11:00:05 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return err;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-03 12:07:45 +02:00
|
|
|
/**
|
|
|
|
|
* Start writing of data related to a single ID.
|
|
|
|
|
*
|
|
|
|
|
* Only does something when storing an undo step.
|
|
|
|
|
*/
|
|
|
|
|
static void mywrite_id_begin(WriteData *wd, ID *id)
|
|
|
|
|
{
|
|
|
|
|
if (wd->use_memfile) {
|
|
|
|
|
wd->mem.current_id_session_uuid = id->session_uuid;
|
|
|
|
|
|
|
|
|
|
/* If current next memchunk does not match the ID we are about to write, try to find the
|
|
|
|
|
* correct memchunk in the mapping using ID's session_uuid. */
|
|
|
|
|
if (wd->mem.id_session_uuid_mapping != NULL &&
|
|
|
|
|
(wd->mem.reference_current_chunk == NULL ||
|
|
|
|
|
wd->mem.reference_current_chunk->id_session_uuid != id->session_uuid)) {
|
|
|
|
|
void *ref = BLI_ghash_lookup(wd->mem.id_session_uuid_mapping,
|
|
|
|
|
POINTER_FROM_UINT(id->session_uuid));
|
|
|
|
|
if (ref != NULL) {
|
|
|
|
|
wd->mem.reference_current_chunk = ref;
|
|
|
|
|
}
|
|
|
|
|
/* Else, no existing memchunk found, i.e. this is supposed to be a new ID. */
|
|
|
|
|
}
|
|
|
|
|
/* Otherwise, we try with the current memchunk in any case, whether it is matching current
|
|
|
|
|
* ID's session_uuid or not. */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Start writing of data related to a single ID.
|
|
|
|
|
*
|
|
|
|
|
* Only does something when storing an undo step.
|
|
|
|
|
*/
|
2020-06-04 01:18:14 +10:00
|
|
|
static void mywrite_id_end(WriteData *wd, ID *UNUSED(id))
|
2020-06-03 12:07:45 +02:00
|
|
|
{
|
|
|
|
|
if (wd->use_memfile) {
|
|
|
|
|
/* Very important to do it after every ID write now, otherwise we cannot know whether a
|
|
|
|
|
* specific ID changed or not. */
|
|
|
|
|
mywrite_flush(wd);
|
|
|
|
|
wd->mem.current_id_session_uuid = MAIN_ID_SESSION_UUID_UNSET;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-14 13:17:11 +02:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Generic DNA File Writing
|
|
|
|
|
* \{ */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
static void writestruct_at_address_nr(
|
2019-04-17 06:17:24 +02:00
|
|
|
WriteData *wd, int filecode, const int struct_nr, int nr, const void *adr, const void *data)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BHead bh;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_assert(struct_nr > 0 && struct_nr < SDNA_TYPE_MAX);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (adr == NULL || data == NULL || nr == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* init BHead */
|
|
|
|
|
bh.code = filecode;
|
|
|
|
|
bh.old = adr;
|
|
|
|
|
bh.nr = nr;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
bh.SDNAnr = struct_nr;
|
2020-09-29 12:12:09 +02:00
|
|
|
const SDNA_Struct *struct_info = wd->sdna->structs[bh.SDNAnr];
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2020-09-29 12:12:09 +02:00
|
|
|
bh.len = nr * wd->sdna->types_size[struct_info->type];
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (bh.len == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
mywrite(wd, &bh, sizeof(BHead));
|
2020-09-20 18:41:50 +02:00
|
|
|
mywrite(wd, data, (size_t)bh.len);
|
2013-04-12 15:33:09 +00:00
|
|
|
}
|
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
static void writestruct_nr(
|
2019-04-17 06:17:24 +02:00
|
|
|
WriteData *wd, int filecode, const int struct_nr, int nr, const void *adr)
|
2016-06-28 20:05:42 +10:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
writestruct_at_address_nr(wd, filecode, struct_nr, nr, adr, adr);
|
2016-06-28 20:05:42 +10:00
|
|
|
}
|
|
|
|
|
|
2019-07-10 14:41:19 +10:00
|
|
|
/* do not use for structs */
|
2020-09-20 18:41:50 +02:00
|
|
|
static void writedata(WriteData *wd, int filecode, size_t len, const void *adr)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BHead bh;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (adr == NULL || len == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2020-09-20 18:41:50 +02:00
|
|
|
if (len > INT_MAX) {
|
|
|
|
|
BLI_assert(!"Cannot write chunks bigger than INT_MAX.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* align to 4 (writes uninitialized bytes in some cases) */
|
2020-09-20 18:41:50 +02:00
|
|
|
len = (len + 3) & ~((size_t)3);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* init BHead */
|
|
|
|
|
bh.code = filecode;
|
|
|
|
|
bh.old = adr;
|
|
|
|
|
bh.nr = 1;
|
|
|
|
|
bh.SDNAnr = 0;
|
2020-09-20 18:41:50 +02:00
|
|
|
bh.len = (int)len;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
mywrite(wd, &bh, sizeof(BHead));
|
|
|
|
|
mywrite(wd, adr, len);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-07 16:57:53 +00:00
|
|
|
/* use this to force writing of lists in same order as reading (using link_list) */
|
2016-06-28 20:05:42 +10:00
|
|
|
static void writelist_nr(WriteData *wd, int filecode, const int struct_nr, const ListBase *lb)
|
2013-03-07 16:57:53 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const Link *link = lb->first;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
while (link) {
|
|
|
|
|
writestruct_nr(wd, filecode, struct_nr, 1, link);
|
|
|
|
|
link = link->next;
|
|
|
|
|
}
|
2013-03-07 16:57:53 +00:00
|
|
|
}
|
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
#if 0
|
|
|
|
|
static void writelist_id(WriteData *wd, int filecode, const char *structname, const ListBase *lb)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const Link *link = lb->first;
|
|
|
|
|
if (link) {
|
|
|
|
|
|
|
|
|
|
const int struct_nr = DNA_struct_find_nr(wd->sdna, structname);
|
|
|
|
|
if (struct_nr == -1) {
|
|
|
|
|
printf("error: can't find SDNA code <%s>\n", structname);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (link) {
|
|
|
|
|
writestruct_nr(wd, filecode, struct_nr, 1, link);
|
|
|
|
|
link = link->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-06-28 20:05:42 +10:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define writestruct_at_address(wd, filecode, struct_id, nr, adr, data) \
|
2019-04-17 06:17:24 +02:00
|
|
|
writestruct_at_address_nr(wd, filecode, SDNA_TYPE_FROM_STRUCT(struct_id), nr, adr, data)
|
2016-06-28 20:05:42 +10:00
|
|
|
|
|
|
|
|
#define writestruct(wd, filecode, struct_id, nr, adr) \
|
2019-04-17 06:17:24 +02:00
|
|
|
writestruct_nr(wd, filecode, SDNA_TYPE_FROM_STRUCT(struct_id), nr, adr)
|
2016-06-28 20:05:42 +10:00
|
|
|
|
|
|
|
|
#define writelist(wd, filecode, struct_id, lb) \
|
2019-04-17 06:17:24 +02:00
|
|
|
writelist_nr(wd, filecode, SDNA_TYPE_FROM_STRUCT(struct_id), lb)
|
2016-06-28 20:05:42 +10:00
|
|
|
|
2018-04-14 13:17:11 +02:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Typed DNA File Writing
|
|
|
|
|
*
|
|
|
|
|
* These functions are used by blender's .blend system for file saving/loading.
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2015-02-10 05:45:57 +11:00
|
|
|
/**
|
|
|
|
|
* Take care using 'use_active_win', since we wont want the currently active window
|
|
|
|
|
* to change which scene renders (currently only used for undo).
|
|
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
static void current_screen_compat(Main *mainvar,
|
|
|
|
|
bool use_active_win,
|
|
|
|
|
bScreen **r_screen,
|
|
|
|
|
Scene **r_scene,
|
|
|
|
|
ViewLayer **r_view_layer)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
wmWindowManager *wm;
|
|
|
|
|
wmWindow *window = NULL;
|
|
|
|
|
|
|
|
|
|
/* find a global current screen in the first open window, to have
|
|
|
|
|
* a reasonable default for reading in older versions */
|
|
|
|
|
wm = mainvar->wm.first;
|
|
|
|
|
|
|
|
|
|
if (wm) {
|
|
|
|
|
if (use_active_win) {
|
|
|
|
|
/* write the active window into the file, needed for multi-window undo T43424 */
|
|
|
|
|
for (window = wm->windows.first; window; window = window->next) {
|
|
|
|
|
if (window->active) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* fallback */
|
|
|
|
|
if (window == NULL) {
|
|
|
|
|
window = wm->windows.first;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
window = wm->windows.first;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*r_screen = (window) ? BKE_workspace_active_screen_get(window->workspace_hook) : NULL;
|
|
|
|
|
*r_scene = (window) ? window->scene : NULL;
|
|
|
|
|
*r_view_layer = (window && *r_scene) ? BKE_view_layer_find(*r_scene, window->view_layer_name) :
|
|
|
|
|
NULL;
|
2008-12-19 16:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
2012-04-26 04:03:25 +00:00
|
|
|
typedef struct RenderInfo {
|
2019-04-17 06:17:24 +02:00
|
|
|
int sfra;
|
|
|
|
|
int efra;
|
|
|
|
|
char scene_name[MAX_ID_NAME - 2];
|
2012-04-26 04:03:25 +00:00
|
|
|
} RenderInfo;
|
|
|
|
|
|
2019-08-17 00:54:22 +10:00
|
|
|
/**
|
|
|
|
|
* This was originally added for the historic render-daemon feature,
|
|
|
|
|
* now write because it can be easily extracted without reading the whole blend file.
|
|
|
|
|
*
|
|
|
|
|
* See: `release/scripts/modules/blend_render_info.py`
|
|
|
|
|
*/
|
2012-10-15 02:15:07 +00:00
|
|
|
static void write_renderinfo(WriteData *wd, Main *mainvar)
|
2008-12-19 16:36:15 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bScreen *curscreen;
|
2020-08-21 13:14:41 +02:00
|
|
|
Scene *curscene = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
ViewLayer *view_layer;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* XXX in future, handle multiple windows with multiple screens? */
|
|
|
|
|
current_screen_compat(mainvar, false, &curscreen, &curscene, &view_layer);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (Scene *, sce, &mainvar->scenes) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (sce->id.lib == NULL && (sce == curscene || (sce->r.scemode & R_BG_RENDER))) {
|
2020-08-21 13:14:41 +02:00
|
|
|
RenderInfo data;
|
2019-04-17 06:17:24 +02:00
|
|
|
data.sfra = sce->r.sfra;
|
|
|
|
|
data.efra = sce->r.efra;
|
|
|
|
|
memset(data.scene_name, 0, sizeof(data.scene_name));
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_strncpy(data.scene_name, sce->id.name + 2, sizeof(data.scene_name));
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
writedata(wd, REND, sizeof(data), &data);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 21:19:03 +02:00
|
|
|
static void write_keymapitem(BlendWriter *writer, const wmKeyMapItem *kmi)
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
{
|
2020-06-05 21:19:03 +02:00
|
|
|
BLO_write_struct(writer, wmKeyMapItem, kmi);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (kmi->properties) {
|
2020-08-21 12:45:33 +02:00
|
|
|
IDP_BlendWrite(writer, kmi->properties);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 21:19:03 +02:00
|
|
|
static void write_userdef(BlendWriter *writer, const UserDef *userdef)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2020-06-05 21:19:03 +02:00
|
|
|
writestruct(writer->wd, USER, UserDef, 1, userdef);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (const bTheme *, btheme, &userdef->themes) {
|
2020-06-05 21:19:03 +02:00
|
|
|
BLO_write_struct(writer, bTheme, btheme);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (const wmKeyMap *, keymap, &userdef->user_keymaps) {
|
2020-06-05 21:19:03 +02:00
|
|
|
BLO_write_struct(writer, wmKeyMap, keymap);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (const wmKeyMapDiffItem *, kmdi, &keymap->diff_items) {
|
2020-06-05 21:19:03 +02:00
|
|
|
BLO_write_struct(writer, wmKeyMapDiffItem, kmdi);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (kmdi->remove_item) {
|
2020-06-05 21:19:03 +02:00
|
|
|
write_keymapitem(writer, kmdi->remove_item);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
if (kmdi->add_item) {
|
2020-06-05 21:19:03 +02:00
|
|
|
write_keymapitem(writer, kmdi->add_item);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (const wmKeyMapItem *, kmi, &keymap->items) {
|
2020-06-05 21:19:03 +02:00
|
|
|
write_keymapitem(writer, kmi);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (const wmKeyConfigPref *, kpt, &userdef->user_keyconfig_prefs) {
|
2020-06-05 21:19:03 +02:00
|
|
|
BLO_write_struct(writer, wmKeyConfigPref, kpt);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (kpt->prop) {
|
2020-08-21 12:45:33 +02:00
|
|
|
IDP_BlendWrite(writer, kpt->prop);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (const bUserMenu *, um, &userdef->user_menus) {
|
2020-06-05 21:19:03 +02:00
|
|
|
BLO_write_struct(writer, bUserMenu, um);
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (const bUserMenuItem *, umi, &um->items) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (umi->type == USER_MENU_TYPE_OPERATOR) {
|
|
|
|
|
const bUserMenuItem_Op *umi_op = (const bUserMenuItem_Op *)umi;
|
2020-06-05 21:19:03 +02:00
|
|
|
BLO_write_struct(writer, bUserMenuItem_Op, umi_op);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (umi_op->prop) {
|
2020-08-21 12:45:33 +02:00
|
|
|
IDP_BlendWrite(writer, umi_op->prop);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (umi->type == USER_MENU_TYPE_MENU) {
|
|
|
|
|
const bUserMenuItem_Menu *umi_mt = (const bUserMenuItem_Menu *)umi;
|
2020-06-05 21:19:03 +02:00
|
|
|
BLO_write_struct(writer, bUserMenuItem_Menu, umi_mt);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else if (umi->type == USER_MENU_TYPE_PROP) {
|
|
|
|
|
const bUserMenuItem_Prop *umi_pr = (const bUserMenuItem_Prop *)umi;
|
2020-06-05 21:19:03 +02:00
|
|
|
BLO_write_struct(writer, bUserMenuItem_Prop, umi_pr);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2020-06-05 21:19:03 +02:00
|
|
|
BLO_write_struct(writer, bUserMenuItem, umi);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (const bAddon *, bext, &userdef->addons) {
|
2020-06-05 21:19:03 +02:00
|
|
|
BLO_write_struct(writer, bAddon, bext);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (bext->prop) {
|
2020-08-21 12:45:33 +02:00
|
|
|
IDP_BlendWrite(writer, bext->prop);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (const bPathCompare *, path_cmp, &userdef->autoexec_paths) {
|
2020-06-05 21:19:03 +02:00
|
|
|
BLO_write_struct(writer, bPathCompare, path_cmp);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (const uiStyle *, style, &userdef->uistyles) {
|
2020-06-05 21:19:03 +02:00
|
|
|
BLO_write_struct(writer, uiStyle, style);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-07 12:22:19 +02:00
|
|
|
static void write_boid_state(BlendWriter *writer, BoidState *state)
|
2016-12-28 17:30:58 +01:00
|
|
|
{
|
2020-06-07 12:22:19 +02:00
|
|
|
BLO_write_struct(writer, BoidState, state);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
|
2019-04-17 06:17:24 +02:00
|
|
|
switch (rule->type) {
|
|
|
|
|
case eBoidRuleType_Goal:
|
|
|
|
|
case eBoidRuleType_Avoid:
|
2020-06-07 12:22:19 +02:00
|
|
|
BLO_write_struct(writer, BoidRuleGoalAvoid, rule);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case eBoidRuleType_AvoidCollision:
|
2020-06-07 12:22:19 +02:00
|
|
|
BLO_write_struct(writer, BoidRuleAvoidCollision, rule);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case eBoidRuleType_FollowLeader:
|
2020-06-07 12:22:19 +02:00
|
|
|
BLO_write_struct(writer, BoidRuleFollowLeader, rule);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case eBoidRuleType_AverageSpeed:
|
2020-06-07 12:22:19 +02:00
|
|
|
BLO_write_struct(writer, BoidRuleAverageSpeed, rule);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case eBoidRuleType_Fight:
|
2020-06-07 12:22:19 +02:00
|
|
|
BLO_write_struct(writer, BoidRuleFight, rule);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
default:
|
2020-06-07 12:22:19 +02:00
|
|
|
BLO_write_struct(writer, BoidRule, rule);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-28 17:30:58 +01:00
|
|
|
#if 0
|
2019-04-17 06:17:24 +02:00
|
|
|
BoidCondition *cond = state->conditions.first;
|
|
|
|
|
for (; cond; cond = cond->next) {
|
2020-06-07 12:22:19 +02:00
|
|
|
BLO_write_struct(writer, BoidCondition, cond);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2016-12-28 17:30:58 +01:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* update this also to readfile.c */
|
|
|
|
|
static const char *ptcache_data_struct[] = {
|
2019-04-17 06:17:24 +02:00
|
|
|
"", // BPHYS_DATA_INDEX
|
|
|
|
|
"", // BPHYS_DATA_LOCATION
|
|
|
|
|
"", // BPHYS_DATA_VELOCITY
|
|
|
|
|
"", // BPHYS_DATA_ROTATION
|
|
|
|
|
"", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
|
|
|
|
|
"", // BPHYS_DATA_SIZE:
|
|
|
|
|
"", // BPHYS_DATA_TIMES:
|
|
|
|
|
"BoidData", // case BPHYS_DATA_BOIDS:
|
2016-12-28 17:30:58 +01:00
|
|
|
};
|
|
|
|
|
static const char *ptcache_extra_struct[] = {
|
2019-04-17 06:17:24 +02:00
|
|
|
"",
|
|
|
|
|
"ParticleSpring",
|
2020-06-10 18:10:07 +03:00
|
|
|
"vec3f",
|
2016-12-28 17:30:58 +01:00
|
|
|
};
|
2020-06-05 20:40:38 +02:00
|
|
|
static void write_pointcaches(BlendWriter *writer, ListBase *ptcaches)
|
2016-12-28 17:30:58 +01:00
|
|
|
{
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (PointCache *, cache, ptcaches) {
|
2020-06-05 20:40:38 +02:00
|
|
|
BLO_write_struct(writer, PointCache, cache);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (PTCacheMem *, pm, &cache->mem_cache) {
|
2020-06-05 20:40:38 +02:00
|
|
|
BLO_write_struct(writer, PTCacheMem, pm);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-21 13:14:41 +02:00
|
|
|
for (int i = 0; i < BPHYS_TOT_DATA; i++) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (pm->data[i] && pm->data_types & (1 << i)) {
|
|
|
|
|
if (ptcache_data_struct[i][0] == '\0') {
|
2020-06-05 20:40:38 +02:00
|
|
|
BLO_write_raw(writer, MEM_allocN_len(pm->data[i]), pm->data[i]);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2020-06-05 20:40:38 +02:00
|
|
|
BLO_write_struct_array_by_name(
|
|
|
|
|
writer, ptcache_data_struct[i], pm->totpoint, pm->data[i]);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (PTCacheExtra *, extra, &pm->extradata) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ptcache_extra_struct[extra->type][0] == '\0') {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2020-06-05 20:40:38 +02:00
|
|
|
BLO_write_struct(writer, PTCacheExtra, extra);
|
|
|
|
|
BLO_write_struct_array_by_name(
|
|
|
|
|
writer, ptcache_extra_struct[extra->type], extra->totdata, extra->data);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-28 17:30:58 +01:00
|
|
|
}
|
Refactor writefile handling of data-blocks.
Instead of calling a function looping over whole list of a given ID
type, make whole loop over Main in parent function, and call functions
writing a single datablock at a time.
This design is more in line with all other places in Blender where we
handle whole content of Main (including readfile.c), and much more easy
to extend and add e.g. some generic processing of IDs before/after
writing, etc.
From user point, there should be no change at all, only difference is
that data-block types won't be saved in same order as before (.blend
file specs enforces no order here, so this is not an issue, but it could
bug some third party users using other, simplified .blend file reader maybe).
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D2510
2017-03-17 10:02:08 +01:00
|
|
|
|
2020-06-05 14:41:42 +02:00
|
|
|
static void write_particlesettings(BlendWriter *writer,
|
|
|
|
|
ParticleSettings *part,
|
|
|
|
|
const void *id_address)
|
2016-12-28 17:30:58 +01:00
|
|
|
{
|
2020-06-05 14:41:42 +02:00
|
|
|
if (part->id.us > 0 || BLO_write_is_undo(writer)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
/* write LibData */
|
2020-06-05 14:41:42 +02:00
|
|
|
BLO_write_id_struct(writer, ParticleSettings, id_address, &part->id);
|
2020-08-28 15:45:11 +02:00
|
|
|
BKE_id_blend_write(writer, &part->id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (part->adt) {
|
2020-08-21 15:58:28 +02:00
|
|
|
BKE_animdata_blend_write(writer, part->adt);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-06-05 14:41:42 +02:00
|
|
|
BLO_write_struct(writer, PartDeflect, part->pd);
|
|
|
|
|
BLO_write_struct(writer, PartDeflect, part->pd2);
|
|
|
|
|
BLO_write_struct(writer, EffectorWeights, part->effector_weights);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (part->clumpcurve) {
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, part->clumpcurve);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
if (part->roughcurve) {
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, part->roughcurve);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
if (part->twistcurve) {
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, part->twistcurve);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
|
2019-04-17 06:17:24 +02:00
|
|
|
/* update indices, but only if dw->ob is set (can be NULL after loading e.g.) */
|
|
|
|
|
if (dw->ob != NULL) {
|
|
|
|
|
dw->index = 0;
|
|
|
|
|
if (part->instance_collection) { /* can be NULL if lining fails or set to None */
|
|
|
|
|
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (part->instance_collection, object) {
|
|
|
|
|
if (object == dw->ob) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
dw->index++;
|
|
|
|
|
}
|
|
|
|
|
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-05 14:41:42 +02:00
|
|
|
BLO_write_struct(writer, ParticleDupliWeight, dw);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (part->boids && part->phystype == PART_PHYS_BOIDS) {
|
2020-06-05 14:41:42 +02:00
|
|
|
BLO_write_struct(writer, BoidSettings, part->boids);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
|
2020-06-07 12:22:19 +02:00
|
|
|
write_boid_state(writer, state);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (part->fluid && part->phystype == PART_PHYS_FLUID) {
|
2020-06-05 14:41:42 +02:00
|
|
|
BLO_write_struct(writer, SPHFluidSettings, part->fluid);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int a = 0; a < MAX_MTEX; a++) {
|
|
|
|
|
if (part->mtex[a]) {
|
2020-06-05 14:41:42 +02:00
|
|
|
BLO_write_struct(writer, MTex, part->mtex[a]);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-28 17:30:58 +01:00
|
|
|
}
|
Refactor writefile handling of data-blocks.
Instead of calling a function looping over whole list of a given ID
type, make whole loop over Main in parent function, and call functions
writing a single datablock at a time.
This design is more in line with all other places in Blender where we
handle whole content of Main (including readfile.c), and much more easy
to extend and add e.g. some generic processing of IDs before/after
writing, etc.
From user point, there should be no change at all, only difference is
that data-block types won't be saved in same order as before (.blend
file specs enforces no order here, so this is not an issue, but it could
bug some third party users using other, simplified .blend file reader maybe).
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D2510
2017-03-17 10:02:08 +01:00
|
|
|
|
2020-06-05 20:40:38 +02:00
|
|
|
static void write_particlesystems(BlendWriter *writer, ListBase *particles)
|
2016-12-28 17:30:58 +01:00
|
|
|
{
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (ParticleSystem *, psys, particles) {
|
2020-06-05 20:40:38 +02:00
|
|
|
BLO_write_struct(writer, ParticleSystem, psys);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (psys->particles) {
|
2020-06-05 20:40:38 +02:00
|
|
|
BLO_write_struct_array(writer, ParticleData, psys->totpart, psys->particles);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (psys->particles->hair) {
|
|
|
|
|
ParticleData *pa = psys->particles;
|
|
|
|
|
|
2020-08-21 13:14:41 +02:00
|
|
|
for (int a = 0; a < psys->totpart; a++, pa++) {
|
2020-06-05 20:40:38 +02:00
|
|
|
BLO_write_struct_array(writer, HairKey, pa->totkey, pa->hair);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (psys->particles->boid && (psys->part->phystype == PART_PHYS_BOIDS)) {
|
2020-06-05 20:40:38 +02:00
|
|
|
BLO_write_struct_array(writer, BoidParticle, psys->totpart, psys->particles->boid);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (psys->part->fluid && (psys->part->phystype == PART_PHYS_FLUID) &&
|
|
|
|
|
(psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS)) {
|
2020-06-05 20:40:38 +02:00
|
|
|
BLO_write_struct_array(
|
|
|
|
|
writer, ParticleSpring, psys->tot_fluidsprings, psys->fluid_springs);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (ParticleTarget *, pt, &psys->targets) {
|
2020-06-05 20:40:38 +02:00
|
|
|
BLO_write_struct(writer, ParticleTarget, pt);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (psys->child) {
|
2020-06-05 20:40:38 +02:00
|
|
|
BLO_write_struct_array(writer, ChildParticle, psys->totchild, psys->child);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (psys->clmd) {
|
2020-06-05 20:40:38 +02:00
|
|
|
BLO_write_struct(writer, ClothModifierData, psys->clmd);
|
|
|
|
|
BLO_write_struct(writer, ClothSimSettings, psys->clmd->sim_parms);
|
|
|
|
|
BLO_write_struct(writer, ClothCollSettings, psys->clmd->coll_parms);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:40:38 +02:00
|
|
|
write_pointcaches(writer, &psys->ptcaches);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2016-12-28 17:30:58 +01:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:46:27 +02:00
|
|
|
static void write_motionpath(BlendWriter *writer, bMotionPath *mpath)
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* sanity checks */
|
|
|
|
|
if (mpath == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* firstly, just write the motionpath struct */
|
2020-06-05 20:46:27 +02:00
|
|
|
BLO_write_struct(writer, bMotionPath, mpath);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* now write the array of data */
|
2020-06-05 20:46:27 +02:00
|
|
|
BLO_write_struct_array(writer, bMotionPathVert, mpath->length, mpath->points);
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:46:27 +02:00
|
|
|
static void write_constraints(BlendWriter *writer, ListBase *conlist)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (bConstraint *, con, conlist) {
|
2019-04-17 06:17:24 +02:00
|
|
|
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
|
|
|
|
|
|
|
|
|
|
/* Write the specific data */
|
|
|
|
|
if (cti && con->data) {
|
|
|
|
|
/* firstly, just write the plain con->data struct */
|
2020-06-05 20:46:27 +02:00
|
|
|
BLO_write_struct_by_name(writer, cti->structName, con->data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* do any constraint specific stuff */
|
|
|
|
|
switch (con->type) {
|
|
|
|
|
case CONSTRAINT_TYPE_PYTHON: {
|
|
|
|
|
bPythonConstraint *data = con->data;
|
|
|
|
|
|
|
|
|
|
/* write targets */
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (bConstraintTarget *, ct, &data->targets) {
|
2020-06-05 20:46:27 +02:00
|
|
|
BLO_write_struct(writer, bConstraintTarget, ct);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
|
|
|
|
|
* of library blocks that implement this.*/
|
2020-08-21 12:45:33 +02:00
|
|
|
IDP_BlendWrite(writer, data->prop);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case CONSTRAINT_TYPE_ARMATURE: {
|
|
|
|
|
bArmatureConstraint *data = con->data;
|
|
|
|
|
|
|
|
|
|
/* write targets */
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (bConstraintTarget *, ct, &data->targets) {
|
2020-06-05 20:46:27 +02:00
|
|
|
BLO_write_struct(writer, bConstraintTarget, ct);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case CONSTRAINT_TYPE_SPLINEIK: {
|
|
|
|
|
bSplineIKConstraint *data = con->data;
|
|
|
|
|
|
|
|
|
|
/* write points array */
|
2020-06-05 20:46:27 +02:00
|
|
|
BLO_write_float_array(writer, data->numpoints, data->points);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Write the constraint */
|
2020-06-05 20:46:27 +02:00
|
|
|
BLO_write_struct(writer, bConstraint, con);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2020-08-10 10:43:26 +02:00
|
|
|
static void write_pose(BlendWriter *writer, bPose *pose, bArmature *arm)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Write each channel */
|
|
|
|
|
if (pose == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-10 10:43:26 +02:00
|
|
|
BLI_assert(arm != NULL);
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Write channels */
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (bPoseChannel *, chan, &pose->chanbase) {
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
|
|
|
|
|
* of library blocks that implement this.*/
|
|
|
|
|
if (chan->prop) {
|
2020-08-21 12:45:33 +02:00
|
|
|
IDP_BlendWrite(writer, chan->prop);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:46:27 +02:00
|
|
|
write_constraints(writer, &chan->constraints);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-05 20:46:27 +02:00
|
|
|
write_motionpath(writer, chan->mpath);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-10 10:43:26 +02:00
|
|
|
/* Prevent crashes with autosave,
|
2020-09-15 10:23:41 +10:00
|
|
|
* when a bone duplicated in edit-mode has not yet been assigned to its pose-channel.
|
2020-08-10 10:43:26 +02:00
|
|
|
* Also needed with memundo, in some cases we can store a step before pose has been
|
|
|
|
|
* properly rebuilt from previous undo step. */
|
|
|
|
|
Bone *bone = (pose->flag & POSE_RECALC) ? BKE_armature_find_bone_name(arm, chan->name) :
|
|
|
|
|
chan->bone;
|
|
|
|
|
if (bone != NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
/* gets restored on read, for library armatures */
|
2020-08-10 10:43:26 +02:00
|
|
|
chan->selectflag = bone->flag & BONE_SELECTED;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:46:27 +02:00
|
|
|
BLO_write_struct(writer, bPoseChannel, chan);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Write groups */
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (bActionGroup *, grp, &pose->agroups) {
|
2020-06-05 20:46:27 +02:00
|
|
|
BLO_write_struct(writer, bActionGroup, grp);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* write IK param */
|
|
|
|
|
if (pose->ikparam) {
|
|
|
|
|
const char *structname = BKE_pose_ikparam_get_name(pose);
|
|
|
|
|
if (structname) {
|
2020-06-05 20:46:27 +02:00
|
|
|
BLO_write_struct_by_name(writer, structname, pose->ikparam);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Write this pose */
|
2020-06-05 20:46:27 +02:00
|
|
|
BLO_write_struct(writer, bPose, pose);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:46:27 +02:00
|
|
|
static void write_defgroups(BlendWriter *writer, ListBase *defbase)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (bDeformGroup *, defgroup, defbase) {
|
2020-06-05 20:46:27 +02:00
|
|
|
BLO_write_struct(writer, bDeformGroup, defgroup);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:46:27 +02:00
|
|
|
static void write_fmaps(BlendWriter *writer, ListBase *fbase)
|
2017-05-30 17:58:24 +10:00
|
|
|
{
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (bFaceMap *, fmap, fbase) {
|
2020-06-05 20:46:27 +02:00
|
|
|
BLO_write_struct(writer, bFaceMap, fmap);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2017-05-30 17:58:24 +10:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 15:38:36 +02:00
|
|
|
static void write_modifiers(BlendWriter *writer, ListBase *modbase)
|
2005-07-19 20:14:17 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (modbase == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (ModifierData *, md, modbase) {
|
2020-05-08 10:14:02 +02:00
|
|
|
const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (mti == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-05 15:38:36 +02:00
|
|
|
BLO_write_struct_by_name(writer, mti->structName, md);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-23 16:42:00 +02:00
|
|
|
if (md->type == eModifierType_Cloth) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ClothModifierData *clmd = (ClothModifierData *)md;
|
|
|
|
|
|
2020-06-05 15:38:36 +02:00
|
|
|
BLO_write_struct(writer, ClothSimSettings, clmd->sim_parms);
|
|
|
|
|
BLO_write_struct(writer, ClothCollSettings, clmd->coll_parms);
|
|
|
|
|
BLO_write_struct(writer, EffectorWeights, clmd->sim_parms->effector_weights);
|
2020-06-05 20:40:38 +02:00
|
|
|
write_pointcaches(writer, &clmd->ptcaches);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-12-16 15:50:14 +01:00
|
|
|
else if (md->type == eModifierType_Fluid) {
|
2020-07-03 11:51:15 +02:00
|
|
|
FluidModifierData *fmd = (FluidModifierData *)md;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-03 11:51:15 +02:00
|
|
|
if (fmd->type & MOD_FLUID_TYPE_DOMAIN) {
|
|
|
|
|
BLO_write_struct(writer, FluidDomainSettings, fmd->domain);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-03 11:51:15 +02:00
|
|
|
if (fmd->domain) {
|
|
|
|
|
write_pointcaches(writer, &(fmd->domain->ptcaches[0]));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* create fake pointcache so that old blender versions can read it */
|
2020-07-03 11:51:15 +02:00
|
|
|
fmd->domain->point_cache[1] = BKE_ptcache_add(&fmd->domain->ptcaches[1]);
|
|
|
|
|
fmd->domain->point_cache[1]->flag |= PTCACHE_DISK_CACHE | PTCACHE_FAKE_SMOKE;
|
|
|
|
|
fmd->domain->point_cache[1]->step = 1;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-03 11:51:15 +02:00
|
|
|
write_pointcaches(writer, &(fmd->domain->ptcaches[1]));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-03 11:51:15 +02:00
|
|
|
if (fmd->domain->coba) {
|
|
|
|
|
BLO_write_struct(writer, ColorBand, fmd->domain->coba);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* cleanup the fake pointcache */
|
2020-07-03 11:51:15 +02:00
|
|
|
BKE_ptcache_free_list(&fmd->domain->ptcaches[1]);
|
|
|
|
|
fmd->domain->point_cache[1] = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-03 11:51:15 +02:00
|
|
|
BLO_write_struct(writer, EffectorWeights, fmd->domain->effector_weights);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2020-07-03 11:51:15 +02:00
|
|
|
else if (fmd->type & MOD_FLUID_TYPE_FLOW) {
|
|
|
|
|
BLO_write_struct(writer, FluidFlowSettings, fmd->flow);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-07-03 11:51:15 +02:00
|
|
|
else if (fmd->type & MOD_FLUID_TYPE_EFFEC) {
|
|
|
|
|
BLO_write_struct(writer, FluidEffectorSettings, fmd->effector);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (md->type == eModifierType_Fluidsim) {
|
|
|
|
|
FluidsimModifierData *fluidmd = (FluidsimModifierData *)md;
|
|
|
|
|
|
2020-06-05 15:38:36 +02:00
|
|
|
BLO_write_struct(writer, FluidsimSettings, fluidmd->fss);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else if (md->type == eModifierType_DynamicPaint) {
|
|
|
|
|
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
|
|
|
|
|
|
|
|
|
|
if (pmd->canvas) {
|
2020-06-05 15:38:36 +02:00
|
|
|
BLO_write_struct(writer, DynamicPaintCanvasSettings, pmd->canvas);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* write surfaces */
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (DynamicPaintSurface *, surface, &pmd->canvas->surfaces) {
|
2020-06-05 15:38:36 +02:00
|
|
|
BLO_write_struct(writer, DynamicPaintSurface, surface);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
/* write caches and effector weights */
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (DynamicPaintSurface *, surface, &pmd->canvas->surfaces) {
|
2020-06-05 20:40:38 +02:00
|
|
|
write_pointcaches(writer, &(surface->ptcaches));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-05 15:38:36 +02:00
|
|
|
BLO_write_struct(writer, EffectorWeights, surface->effector_weights);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (pmd->brush) {
|
2020-06-05 15:38:36 +02:00
|
|
|
BLO_write_struct(writer, DynamicPaintBrushSettings, pmd->brush);
|
|
|
|
|
BLO_write_struct(writer, ColorBand, pmd->brush->paint_ramp);
|
|
|
|
|
BLO_write_struct(writer, ColorBand, pmd->brush->vel_ramp);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (md->type == eModifierType_Collision) {
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2012-06-30 22:49:33 +00:00
|
|
|
#if 0
|
2019-04-17 06:17:24 +02:00
|
|
|
CollisionModifierData *collmd = (CollisionModifierData *)md;
|
|
|
|
|
// TODO: CollisionModifier should use pointcache
|
|
|
|
|
// + have proper reset events before enabling this
|
|
|
|
|
writestruct(wd, DATA, MVert, collmd->numverts, collmd->x);
|
|
|
|
|
writestruct(wd, DATA, MVert, collmd->numverts, collmd->xnew);
|
|
|
|
|
writestruct(wd, DATA, MFace, collmd->numfaces, collmd->mfaces);
|
2012-06-30 22:49:33 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-06-15 17:55:06 +02:00
|
|
|
|
|
|
|
|
if (mti->blendWrite != NULL) {
|
|
|
|
|
mti->blendWrite(writer, md);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2005-07-19 20:14:17 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 15:38:36 +02:00
|
|
|
static void write_gpencil_modifiers(BlendWriter *writer, ListBase *modbase)
|
2018-07-31 10:22:19 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (modbase == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (GpencilModifierData *, md, modbase) {
|
2020-05-08 10:32:30 +02:00
|
|
|
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (mti == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-05 15:38:36 +02:00
|
|
|
BLO_write_struct_by_name(writer, mti->struct_name, md);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (md->type == eGpencilModifierType_Thick) {
|
|
|
|
|
ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md;
|
|
|
|
|
|
|
|
|
|
if (gpmd->curve_thickness) {
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, gpmd->curve_thickness);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2020-03-09 16:27:24 +01:00
|
|
|
else if (md->type == eGpencilModifierType_Noise) {
|
|
|
|
|
NoiseGpencilModifierData *gpmd = (NoiseGpencilModifierData *)md;
|
|
|
|
|
|
|
|
|
|
if (gpmd->curve_intensity) {
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, gpmd->curve_intensity);
|
2020-03-09 16:27:24 +01:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (md->type == eGpencilModifierType_Hook) {
|
|
|
|
|
HookGpencilModifierData *gpmd = (HookGpencilModifierData *)md;
|
|
|
|
|
|
|
|
|
|
if (gpmd->curfalloff) {
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, gpmd->curfalloff);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2020-03-13 10:28:30 +01:00
|
|
|
else if (md->type == eGpencilModifierType_Tint) {
|
|
|
|
|
TintGpencilModifierData *gpmd = (TintGpencilModifierData *)md;
|
2020-03-09 16:27:24 +01:00
|
|
|
if (gpmd->colorband) {
|
2020-06-05 15:38:36 +02:00
|
|
|
BLO_write_struct(writer, ColorBand, gpmd->colorband);
|
2020-03-09 16:27:24 +01:00
|
|
|
}
|
|
|
|
|
if (gpmd->curve_intensity) {
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, gpmd->curve_intensity);
|
2020-03-09 16:27:24 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (md->type == eGpencilModifierType_Smooth) {
|
|
|
|
|
SmoothGpencilModifierData *gpmd = (SmoothGpencilModifierData *)md;
|
|
|
|
|
if (gpmd->curve_intensity) {
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, gpmd->curve_intensity);
|
2020-03-09 16:27:24 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (md->type == eGpencilModifierType_Color) {
|
|
|
|
|
ColorGpencilModifierData *gpmd = (ColorGpencilModifierData *)md;
|
|
|
|
|
if (gpmd->curve_intensity) {
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, gpmd->curve_intensity);
|
2020-03-09 16:27:24 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (md->type == eGpencilModifierType_Opacity) {
|
|
|
|
|
OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md;
|
|
|
|
|
if (gpmd->curve_intensity) {
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, gpmd->curve_intensity);
|
2020-03-09 16:27:24 +01:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-07-31 10:22:19 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:46:27 +02:00
|
|
|
static void write_shaderfxs(BlendWriter *writer, ListBase *fxbase)
|
2018-07-31 10:22:19 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (fxbase == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-07-31 10:22:19 +02:00
|
|
|
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (ShaderFxData *, fx, fxbase) {
|
2020-05-08 10:32:30 +02:00
|
|
|
const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(fx->type);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (fxi == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-07-31 10:22:19 +02:00
|
|
|
|
2020-06-05 20:46:27 +02:00
|
|
|
BLO_write_struct_by_name(writer, fxi->struct_name, fx);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-07-31 10:22:19 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 14:41:42 +02:00
|
|
|
static void write_object(BlendWriter *writer, Object *ob, const void *id_address)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2020-09-14 14:55:48 +02:00
|
|
|
const bool is_undo = BLO_write_is_undo(writer);
|
|
|
|
|
if (ob->id.us > 0 || is_undo) {
|
2020-09-15 10:23:41 +10:00
|
|
|
/* Clean up, important in undo case to reduce false detection of changed data-blocks. */
|
2020-04-01 09:58:37 +02:00
|
|
|
BKE_object_runtime_reset(ob);
|
|
|
|
|
|
2020-09-14 14:55:48 +02:00
|
|
|
if (is_undo) {
|
2020-09-15 10:23:41 +10:00
|
|
|
/* For undo we stay in object mode during undo presses, so keep edit-mode disabled on save as
|
|
|
|
|
* well, can help reducing false detection of changed data-blocks. */
|
2020-09-14 14:55:48 +02:00
|
|
|
ob->mode &= ~OB_MODE_EDIT;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* write LibData */
|
2020-06-05 14:41:42 +02:00
|
|
|
BLO_write_id_struct(writer, Object, id_address, &ob->id);
|
2020-08-28 15:45:11 +02:00
|
|
|
BKE_id_blend_write(writer, &ob->id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (ob->adt) {
|
2020-08-21 15:58:28 +02:00
|
|
|
BKE_animdata_blend_write(writer, ob->adt);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* direct data */
|
2020-06-05 14:41:42 +02:00
|
|
|
BLO_write_pointer_array(writer, ob->totcol, ob->mat);
|
|
|
|
|
BLO_write_raw(writer, sizeof(char) * ob->totcol, ob->matbits);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-10 10:43:26 +02:00
|
|
|
bArmature *arm = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ob->type == OB_ARMATURE) {
|
2020-08-10 10:43:26 +02:00
|
|
|
arm = ob->data;
|
2019-04-17 06:17:24 +02:00
|
|
|
if (arm && ob->pose && arm->act_bone) {
|
|
|
|
|
BLI_strncpy(
|
|
|
|
|
ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-10 10:43:26 +02:00
|
|
|
write_pose(writer, ob->pose, arm);
|
2020-06-05 20:46:27 +02:00
|
|
|
write_defgroups(writer, &ob->defbase);
|
|
|
|
|
write_fmaps(writer, &ob->fmaps);
|
|
|
|
|
write_constraints(writer, &ob->constraints);
|
|
|
|
|
write_motionpath(writer, ob->mpath);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-05 14:41:42 +02:00
|
|
|
BLO_write_struct(writer, PartDeflect, ob->pd);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ob->soft) {
|
|
|
|
|
/* Set deprecated pointers to prevent crashes of older Blenders */
|
|
|
|
|
ob->soft->pointcache = ob->soft->shared->pointcache;
|
|
|
|
|
ob->soft->ptcaches = ob->soft->shared->ptcaches;
|
2020-06-05 14:41:42 +02:00
|
|
|
BLO_write_struct(writer, SoftBody, ob->soft);
|
|
|
|
|
BLO_write_struct(writer, SoftBody_Shared, ob->soft->shared);
|
2020-06-05 20:40:38 +02:00
|
|
|
write_pointcaches(writer, &(ob->soft->shared->ptcaches));
|
2020-06-05 14:41:42 +02:00
|
|
|
BLO_write_struct(writer, EffectorWeights, ob->soft->effector_weights);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ob->rigidbody_object) {
|
|
|
|
|
/* TODO: if any extra data is added to handle duplis, will need separate function then */
|
2020-06-05 14:41:42 +02:00
|
|
|
BLO_write_struct(writer, RigidBodyOb, ob->rigidbody_object);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
if (ob->rigidbody_constraint) {
|
2020-06-05 14:41:42 +02:00
|
|
|
BLO_write_struct(writer, RigidBodyCon, ob->rigidbody_constraint);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
|
2020-06-05 14:41:42 +02:00
|
|
|
BLO_write_struct(writer, ImageUser, ob->iuser);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:40:38 +02:00
|
|
|
write_particlesystems(writer, &ob->particlesystem);
|
2020-06-05 15:38:36 +02:00
|
|
|
write_modifiers(writer, &ob->modifiers);
|
|
|
|
|
write_gpencil_modifiers(writer, &ob->greasepencil_modifiers);
|
2020-06-05 20:46:27 +02:00
|
|
|
write_shaderfxs(writer, &ob->shader_fx);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-05 14:41:42 +02:00
|
|
|
BLO_write_struct_list(writer, LinkData, &ob->pc_ids);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-10 10:33:05 +02:00
|
|
|
BKE_previewimg_blend_write(writer, ob->preview);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
static void write_collection_nolib(BlendWriter *writer, Collection *collection)
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
{
|
2019-06-12 09:04:10 +10:00
|
|
|
/* Shared function for collection data-blocks and scene master collection. */
|
2020-09-10 10:33:05 +02:00
|
|
|
BKE_previewimg_blend_write(writer, collection->preview);
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, CollectionObject, cob);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, CollectionChild, child);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 14:09:35 +02:00
|
|
|
static void write_collection(BlendWriter *writer, Collection *collection, const void *id_address)
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
{
|
2020-06-05 14:09:35 +02:00
|
|
|
if (collection->id.us > 0 || BLO_write_is_undo(writer)) {
|
2020-09-15 10:23:41 +10:00
|
|
|
/* Clean up, important in undo case to reduce false detection of changed data-blocks. */
|
2020-04-01 11:50:42 +02:00
|
|
|
collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
|
|
|
|
|
collection->tag = 0;
|
|
|
|
|
BLI_listbase_clear(&collection->object_cache);
|
|
|
|
|
BLI_listbase_clear(&collection->parents);
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* write LibData */
|
2020-06-05 14:09:35 +02:00
|
|
|
BLO_write_id_struct(writer, Collection, id_address, &collection->id);
|
2020-08-28 15:45:11 +02:00
|
|
|
BKE_id_blend_write(writer, &collection->id);
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
write_collection_nolib(writer, collection);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:55:42 +02:00
|
|
|
static void write_sequence_modifiers(BlendWriter *writer, ListBase *modbase)
|
2012-08-19 15:41:56 +00:00
|
|
|
{
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (SequenceModifierData *, smd, modbase) {
|
2019-04-17 06:17:24 +02:00
|
|
|
const SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type);
|
2012-08-19 15:41:56 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (smti) {
|
2020-06-05 20:55:42 +02:00
|
|
|
BLO_write_struct_by_name(writer, smti->struct_name, smd);
|
2012-08-19 15:41:56 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (smd->type == seqModifierType_Curves) {
|
|
|
|
|
CurvesModifierData *cmd = (CurvesModifierData *)smd;
|
2012-08-19 15:41:56 +00:00
|
|
|
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, &cmd->curve_mapping);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else if (smd->type == seqModifierType_HueCorrect) {
|
|
|
|
|
HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
|
2012-08-19 15:41:56 +00:00
|
|
|
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, &hcmd->curve_mapping);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2020-06-05 20:55:42 +02:00
|
|
|
BLO_write_struct(writer, SequenceModifierData, smd);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2012-08-19 15:41:56 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2020-06-05 20:55:42 +02:00
|
|
|
static void write_view_settings(BlendWriter *writer, ColorManagedViewSettings *view_settings)
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (view_settings->curve_mapping) {
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, view_settings->curve_mapping);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
static void write_view3dshading(BlendWriter *writer, View3DShading *shading)
|
2019-09-05 12:47:20 +02:00
|
|
|
{
|
|
|
|
|
if (shading->prop) {
|
2020-08-21 12:45:33 +02:00
|
|
|
IDP_BlendWrite(writer, shading->prop);
|
2019-09-05 12:47:20 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:55:42 +02:00
|
|
|
static void write_paint(BlendWriter *writer, Paint *p)
|
2015-02-11 15:07:04 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (p->cavity_curve) {
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, p->cavity_curve);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-06-05 20:55:42 +02:00
|
|
|
BLO_write_struct_array(writer, PaintToolSlot, p->tool_slots_len, p->tool_slots);
|
2015-02-11 15:07:04 +01:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 21:22:43 +02:00
|
|
|
static void write_layer_collections(BlendWriter *writer, ListBase *lb)
|
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
|
|
|
{
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (LayerCollection *, lc, lb) {
|
2020-06-05 21:22:43 +02:00
|
|
|
BLO_write_struct(writer, LayerCollection, lc);
|
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
|
|
|
|
2020-06-05 21:22:43 +02:00
|
|
|
write_layer_collections(writer, &lc->layer_collections);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
2020-06-05 21:22:43 +02:00
|
|
|
static void write_view_layer(BlendWriter *writer, ViewLayer *view_layer)
|
2017-12-01 11:24:21 -02:00
|
|
|
{
|
2020-06-05 21:22:43 +02:00
|
|
|
BLO_write_struct(writer, ViewLayer, view_layer);
|
|
|
|
|
BLO_write_struct_list(writer, Base, &view_layer->object_bases);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (view_layer->id_properties) {
|
2020-08-21 12:45:33 +02:00
|
|
|
IDP_BlendWrite(writer, view_layer->id_properties);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) {
|
2020-06-05 21:22:43 +02:00
|
|
|
BLO_write_struct(writer, FreestyleModuleConfig, fmc);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) {
|
2020-06-05 21:22:43 +02:00
|
|
|
BLO_write_struct(writer, FreestyleLineSet, fls);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-06-05 21:22:43 +02:00
|
|
|
write_layer_collections(writer, &view_layer->layer_collections);
|
2017-12-01 11:24:21 -02:00
|
|
|
}
|
|
|
|
|
|
2020-06-07 12:22:19 +02:00
|
|
|
static void write_lightcache_texture(BlendWriter *writer, LightCacheTexture *tex)
|
2018-07-10 15:02:25 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (tex->data) {
|
|
|
|
|
size_t data_size = tex->components * tex->tex_size[0] * tex->tex_size[1] * tex->tex_size[2];
|
|
|
|
|
if (tex->data_type == LIGHTCACHETEX_FLOAT) {
|
|
|
|
|
data_size *= sizeof(float);
|
|
|
|
|
}
|
|
|
|
|
else if (tex->data_type == LIGHTCACHETEX_UINT) {
|
|
|
|
|
data_size *= sizeof(uint);
|
|
|
|
|
}
|
2020-08-05 02:25:31 +02:00
|
|
|
|
|
|
|
|
/* FIXME: We can't save more than what 32bit systems can handle.
|
|
|
|
|
* The solution would be to split the texture but it is too late for 2.90. (see T78529) */
|
|
|
|
|
if (data_size < INT_MAX) {
|
|
|
|
|
BLO_write_raw(writer, data_size, tex->data);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-07-10 15:02:25 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-07 12:22:19 +02:00
|
|
|
static void write_lightcache(BlendWriter *writer, LightCache *cache)
|
2018-07-10 15:02:25 +02:00
|
|
|
{
|
2020-06-07 12:22:19 +02:00
|
|
|
write_lightcache_texture(writer, &cache->grid_tx);
|
|
|
|
|
write_lightcache_texture(writer, &cache->cube_tx);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (cache->cube_mips) {
|
2020-06-07 12:22:19 +02:00
|
|
|
BLO_write_struct_array(writer, LightCacheTexture, cache->mips_len, cache->cube_mips);
|
2019-09-08 00:12:26 +10:00
|
|
|
for (int i = 0; i < cache->mips_len; i++) {
|
2020-06-07 12:22:19 +02:00
|
|
|
write_lightcache_texture(writer, &cache->cube_mips[i]);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-07 12:22:19 +02:00
|
|
|
BLO_write_struct_array(writer, LightGridCache, cache->grid_len, cache->grid_data);
|
|
|
|
|
BLO_write_struct_array(writer, LightProbeCache, cache->cube_len, cache->cube_data);
|
2018-07-10 15:02:25 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 13:55:33 +02:00
|
|
|
static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2020-06-05 13:55:33 +02:00
|
|
|
if (BLO_write_is_undo(writer)) {
|
2020-09-15 10:23:41 +10:00
|
|
|
/* Clean up, important in undo case to reduce false detection of changed data-blocks. */
|
2020-04-22 11:35:28 +02:00
|
|
|
/* XXX This UI data should not be stored in Scene at all... */
|
|
|
|
|
memset(&sce->cursor, 0, sizeof(sce->cursor));
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* write LibData */
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_id_struct(writer, Scene, id_address, &sce->id);
|
2020-08-28 15:45:11 +02:00
|
|
|
BKE_id_blend_write(writer, &sce->id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (sce->adt) {
|
2020-08-21 15:58:28 +02:00
|
|
|
BKE_animdata_blend_write(writer, sce->adt);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-09-10 11:17:35 +02:00
|
|
|
BKE_keyingsets_blend_write(writer, &sce->keyingsets);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* direct data */
|
|
|
|
|
ToolSettings *tos = sce->toolsettings;
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, ToolSettings, tos);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (tos->vpaint) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, VPaint, tos->vpaint);
|
2020-06-05 20:55:42 +02:00
|
|
|
write_paint(writer, &tos->vpaint->paint);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
if (tos->wpaint) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, VPaint, tos->wpaint);
|
2020-06-05 20:55:42 +02:00
|
|
|
write_paint(writer, &tos->wpaint->paint);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
if (tos->sculpt) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, Sculpt, tos->sculpt);
|
2020-06-05 20:55:42 +02:00
|
|
|
write_paint(writer, &tos->sculpt->paint);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
if (tos->uvsculpt) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, UvSculpt, tos->uvsculpt);
|
2020-06-05 20:55:42 +02:00
|
|
|
write_paint(writer, &tos->uvsculpt->paint);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
if (tos->gp_paint) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, GpPaint, tos->gp_paint);
|
2020-06-05 20:55:42 +02:00
|
|
|
write_paint(writer, &tos->gp_paint->paint);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-03-09 16:27:24 +01:00
|
|
|
if (tos->gp_vertexpaint) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, GpVertexPaint, tos->gp_vertexpaint);
|
2020-06-05 20:55:42 +02:00
|
|
|
write_paint(writer, &tos->gp_vertexpaint->paint);
|
2020-03-09 16:27:24 +01:00
|
|
|
}
|
|
|
|
|
if (tos->gp_sculptpaint) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, GpSculptPaint, tos->gp_sculptpaint);
|
2020-06-05 20:55:42 +02:00
|
|
|
write_paint(writer, &tos->gp_sculptpaint->paint);
|
2020-03-09 16:27:24 +01:00
|
|
|
}
|
|
|
|
|
if (tos->gp_weightpaint) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, GpWeightPaint, tos->gp_weightpaint);
|
2020-06-05 20:55:42 +02:00
|
|
|
write_paint(writer, &tos->gp_weightpaint->paint);
|
2020-03-09 16:27:24 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
/* write grease-pencil custom ipo curve to file */
|
|
|
|
|
if (tos->gp_interpolate.custom_ipo) {
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, tos->gp_interpolate.custom_ipo);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
/* write grease-pencil multiframe falloff curve to file */
|
|
|
|
|
if (tos->gp_sculpt.cur_falloff) {
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, tos->gp_sculpt.cur_falloff);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
/* write grease-pencil primitive curve to file */
|
|
|
|
|
if (tos->gp_sculpt.cur_primitive) {
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_blend_write(writer, tos->gp_sculpt.cur_primitive);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-11-20 16:12:32 -05:00
|
|
|
/* Write the curve profile to the file. */
|
|
|
|
|
if (tos->custom_bevel_profile_preset) {
|
2020-06-23 17:02:49 +02:00
|
|
|
BKE_curveprofile_blend_write(writer, tos->custom_bevel_profile_preset);
|
2019-11-20 16:12:32 -05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-05 20:55:42 +02:00
|
|
|
write_paint(writer, &tos->imapaint.paint);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
Editing *ed = sce->ed;
|
|
|
|
|
if (ed) {
|
|
|
|
|
Sequence *seq;
|
|
|
|
|
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, Editing, ed);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* reset write flags too */
|
|
|
|
|
|
2020-08-21 18:55:27 +02:00
|
|
|
SEQ_ALL_BEGIN (ed, seq) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (seq->strip) {
|
|
|
|
|
seq->strip->done = false;
|
|
|
|
|
}
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, Sequence, seq);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-08-21 18:55:27 +02:00
|
|
|
SEQ_ALL_END;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-21 18:55:27 +02:00
|
|
|
SEQ_ALL_BEGIN (ed, seq) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (seq->strip && seq->strip->done == 0) {
|
|
|
|
|
/* write strip with 'done' at 0 because readfile */
|
|
|
|
|
|
|
|
|
|
if (seq->effectdata) {
|
|
|
|
|
switch (seq->type) {
|
|
|
|
|
case SEQ_TYPE_COLOR:
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, SolidColorVars, seq->effectdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case SEQ_TYPE_SPEED:
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, SpeedControlVars, seq->effectdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case SEQ_TYPE_WIPE:
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, WipeVars, seq->effectdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case SEQ_TYPE_GLOW:
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, GlowVars, seq->effectdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case SEQ_TYPE_TRANSFORM:
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, TransformVars, seq->effectdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case SEQ_TYPE_GAUSSIAN_BLUR:
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, GaussianBlurVars, seq->effectdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case SEQ_TYPE_TEXT:
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, TextVars, seq->effectdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case SEQ_TYPE_COLORMIX:
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, ColorMixVars, seq->effectdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, Stereo3dFormat, seq->stereo3d_format);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
Strip *strip = seq->strip;
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, Strip, strip);
|
2019-05-31 14:40:41 +02:00
|
|
|
if (strip->crop) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, StripCrop, strip->crop);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-05-31 14:40:41 +02:00
|
|
|
if (strip->transform) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, StripTransform, strip->transform);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-05-31 14:40:41 +02:00
|
|
|
if (strip->proxy) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, StripProxy, strip->proxy);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
if (seq->type == SEQ_TYPE_IMAGE) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct_array(writer,
|
|
|
|
|
StripElem,
|
|
|
|
|
MEM_allocN_len(strip->stripdata) / sizeof(struct StripElem),
|
|
|
|
|
strip->stripdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, StripElem, strip->stripdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strip->done = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (seq->prop) {
|
2020-08-21 12:45:33 +02:00
|
|
|
IDP_BlendWrite(writer, seq->prop);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:55:42 +02:00
|
|
|
write_sequence_modifiers(writer, &seq->modifiers);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-08-21 18:55:27 +02:00
|
|
|
SEQ_ALL_END;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* new; meta stack too, even when its nasty restore code */
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (MetaStack *, ms, &ed->metastack) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, MetaStack, ms);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sce->r.avicodecdata) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, AviCodecData, sce->r.avicodecdata);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (sce->r.avicodecdata->lpFormat) {
|
2020-09-20 18:41:50 +02:00
|
|
|
BLO_write_raw(writer, (size_t)sce->r.avicodecdata->cbFormat, sce->r.avicodecdata->lpFormat);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
if (sce->r.avicodecdata->lpParms) {
|
2020-09-20 18:41:50 +02:00
|
|
|
BLO_write_raw(writer, (size_t)sce->r.avicodecdata->cbParms, sce->r.avicodecdata->lpParms);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (sce->r.ffcodecdata.properties) {
|
2020-08-21 12:45:33 +02:00
|
|
|
IDP_BlendWrite(writer, sce->r.ffcodecdata.properties);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* writing dynamic list of TimeMarkers to the blend file */
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, TimeMarker, marker);
|
2020-09-18 16:57:33 +02:00
|
|
|
|
|
|
|
|
if (marker->prop != NULL) {
|
|
|
|
|
IDP_BlendWrite(writer, marker->prop);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* writing dynamic list of TransformOrientations to the blend file */
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (TransformOrientation *, ts, &sce->transform_spaces) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, TransformOrientation, ts);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* writing MultiView to the blend file */
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (SceneRenderView *, srv, &sce->r.views) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, SceneRenderView, srv);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sce->nodetree) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, bNodeTree, sce->nodetree);
|
2020-09-10 13:33:29 +02:00
|
|
|
ntreeBlendWrite(writer, sce->nodetree);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:55:42 +02:00
|
|
|
write_view_settings(writer, &sce->view_settings);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* writing RigidBodyWorld data to the blend file */
|
|
|
|
|
if (sce->rigidbody_world) {
|
|
|
|
|
/* Set deprecated pointers to prevent crashes of older Blenders */
|
|
|
|
|
sce->rigidbody_world->pointcache = sce->rigidbody_world->shared->pointcache;
|
|
|
|
|
sce->rigidbody_world->ptcaches = sce->rigidbody_world->shared->ptcaches;
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, RigidBodyWorld, sce->rigidbody_world);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, RigidBodyWorld_Shared, sce->rigidbody_world->shared);
|
|
|
|
|
BLO_write_struct(writer, EffectorWeights, sce->rigidbody_world->effector_weights);
|
2020-06-05 20:40:38 +02:00
|
|
|
write_pointcaches(writer, &(sce->rigidbody_world->shared->ptcaches));
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-09-10 10:33:05 +02:00
|
|
|
BKE_previewimg_blend_write(writer, sce->preview);
|
2020-06-16 17:04:03 +02:00
|
|
|
BKE_curvemapping_curves_blend_write(writer, &sce->r.mblur_shutter_curve);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
|
2020-06-05 21:22:43 +02:00
|
|
|
write_view_layer(writer, view_layer);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sce->master_collection) {
|
2020-06-05 13:55:33 +02:00
|
|
|
BLO_write_struct(writer, Collection, sce->master_collection);
|
2020-06-05 20:34:43 +02:00
|
|
|
write_collection_nolib(writer, sce->master_collection);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Eevee Lightcache */
|
2020-06-05 13:55:33 +02:00
|
|
|
if (sce->eevee.light_cache_data && !BLO_write_is_undo(writer)) {
|
|
|
|
|
BLO_write_struct(writer, LightCache, sce->eevee.light_cache_data);
|
2020-06-07 12:22:19 +02:00
|
|
|
write_lightcache(writer, sce->eevee.light_cache_data);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
write_view3dshading(writer, &sce->display.shading);
|
2019-09-05 12:47:20 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Freed on doversion. */
|
|
|
|
|
BLI_assert(sce->layer_properties == NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
static void write_wm_xr_data(BlendWriter *writer, wmXrData *xr_data)
|
VR: Initial Virtual Reality support - Milestone 1, Scene Inspection
NOTE: While most of the milestone 1 goals are there, a few smaller features and
improvements are still to be done.
Big picture of this milestone: Initial, OpenXR-based virtual reality support
for users and foundation for advanced use cases.
Maniphest Task: https://developer.blender.org/T71347
The tasks contains more information about this milestone.
To be clear: This is not a feature rich VR implementation, it's focused on the
initial scene inspection use case. We intentionally focused on that, further
features like controller support are part of the next milestone.
- How to use?
Instructions on how to use this are here:
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/How_to_Test
These will be updated and moved to a more official place (likely the manual) soon.
Currently Windows Mixed Reality and Oculus devices are usable. Valve/HTC
headsets don't support the OpenXR standard yet and hence, do not work with this
implementation.
---------------
This is the C-side implementation of the features added for initial VR
support as per milestone 1. A "VR Scene Inspection" Add-on will be
committed separately, to expose the VR functionality in the UI. It also
adds some further features for milestone 1, namely a landmarking system
(stored view locations in the VR space)
Main additions/features:
* Support for rendering viewports to an HMD, with good performance.
* Option to sync the VR view perspective with a fully interactive,
regular 3D View (VR-Mirror).
* Option to disable positional tracking. Keeps the current position (calculated
based on the VR eye center pose) when enabled while a VR session is running.
* Some regular viewport settings for the VR view
* RNA/Python-API to query and set VR session state information.
* WM-XR: Layer tying Ghost-XR to the Blender specific APIs/data
* wmSurface API: drawable, non-window container (manages Ghost-OpenGL and GPU
context)
* DNA/RNA for management of VR session settings
* `--debug-xr` and `--debug-xr-time` commandline options
* Utility batch & config file for using the Oculus runtime on Windows.
* Most VR data is runtime only. The exception is user settings which are saved
to files (`XrSessionSettings`).
* VR support can be disabled through the `WITH_XR_OPENXR` compiler flag.
For architecture and code documentation, see
https://wiki.blender.org/wiki/Source/Interface/XR.
---------------
A few thank you's:
* A huge shoutout to Ray Molenkamp for his help during the project - it would
have not been that successful without him!
* Sebastian Koenig and Simeon Conzendorf for testing and feedback!
* The reviewers, especially Brecht Van Lommel!
* Dalai Felinto for pushing and managing me to get this done ;)
* The OpenXR working group for providing an open standard. I think we're the
first bigger application to adopt OpenXR. Congratulations to them and
ourselves :)
This project started as a Google Summer of Code 2019 project - "Core Support of
Virtual Reality Headsets through OpenXR" (see
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/).
Some further information, including ideas for further improvements can be found
in the final GSoC report:
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/Final_Report
Differential Revisions: D6193, D7098
Reviewed by: Brecht Van Lommel, Jeroen Bakker
2020-03-17 20:20:55 +01:00
|
|
|
{
|
2020-06-05 20:34:43 +02:00
|
|
|
write_view3dshading(writer, &xr_data->session_settings.shading);
|
VR: Initial Virtual Reality support - Milestone 1, Scene Inspection
NOTE: While most of the milestone 1 goals are there, a few smaller features and
improvements are still to be done.
Big picture of this milestone: Initial, OpenXR-based virtual reality support
for users and foundation for advanced use cases.
Maniphest Task: https://developer.blender.org/T71347
The tasks contains more information about this milestone.
To be clear: This is not a feature rich VR implementation, it's focused on the
initial scene inspection use case. We intentionally focused on that, further
features like controller support are part of the next milestone.
- How to use?
Instructions on how to use this are here:
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/How_to_Test
These will be updated and moved to a more official place (likely the manual) soon.
Currently Windows Mixed Reality and Oculus devices are usable. Valve/HTC
headsets don't support the OpenXR standard yet and hence, do not work with this
implementation.
---------------
This is the C-side implementation of the features added for initial VR
support as per milestone 1. A "VR Scene Inspection" Add-on will be
committed separately, to expose the VR functionality in the UI. It also
adds some further features for milestone 1, namely a landmarking system
(stored view locations in the VR space)
Main additions/features:
* Support for rendering viewports to an HMD, with good performance.
* Option to sync the VR view perspective with a fully interactive,
regular 3D View (VR-Mirror).
* Option to disable positional tracking. Keeps the current position (calculated
based on the VR eye center pose) when enabled while a VR session is running.
* Some regular viewport settings for the VR view
* RNA/Python-API to query and set VR session state information.
* WM-XR: Layer tying Ghost-XR to the Blender specific APIs/data
* wmSurface API: drawable, non-window container (manages Ghost-OpenGL and GPU
context)
* DNA/RNA for management of VR session settings
* `--debug-xr` and `--debug-xr-time` commandline options
* Utility batch & config file for using the Oculus runtime on Windows.
* Most VR data is runtime only. The exception is user settings which are saved
to files (`XrSessionSettings`).
* VR support can be disabled through the `WITH_XR_OPENXR` compiler flag.
For architecture and code documentation, see
https://wiki.blender.org/wiki/Source/Interface/XR.
---------------
A few thank you's:
* A huge shoutout to Ray Molenkamp for his help during the project - it would
have not been that successful without him!
* Sebastian Koenig and Simeon Conzendorf for testing and feedback!
* The reviewers, especially Brecht Van Lommel!
* Dalai Felinto for pushing and managing me to get this done ;)
* The OpenXR working group for providing an open standard. I think we're the
first bigger application to adopt OpenXR. Congratulations to them and
ourselves :)
This project started as a Google Summer of Code 2019 project - "Core Support of
Virtual Reality Headsets through OpenXR" (see
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/).
Some further information, including ideas for further improvements can be found
in the final GSoC report:
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/Final_Report
Differential Revisions: D6193, D7098
Reviewed by: Brecht Van Lommel, Jeroen Bakker
2020-03-17 20:20:55 +01:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
static void write_region(BlendWriter *writer, ARegion *region, int spacetype)
|
2016-06-28 17:35:35 +10:00
|
|
|
{
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, ARegion, region);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
if (region->regiondata) {
|
|
|
|
|
if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (spacetype) {
|
|
|
|
|
case SPACE_VIEW3D:
|
2020-03-06 16:56:42 +01:00
|
|
|
if (region->regiontype == RGN_TYPE_WINDOW) {
|
|
|
|
|
RegionView3D *rv3d = region->regiondata;
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, RegionView3D, rv3d);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (rv3d->localvd) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, RegionView3D, rv3d->localvd);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
if (rv3d->clipbb) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, BoundBox, rv3d->clipbb);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-22 09:13:00 +10:00
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
printf("regiondata write missing!\n");
|
2019-04-22 09:13:00 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
printf("regiondata write missing!\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
static void write_uilist(BlendWriter *writer, uiList *ui_list)
|
2013-08-29 12:55:31 +00:00
|
|
|
{
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, uiList, ui_list);
|
2013-08-29 12:55:31 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ui_list->properties) {
|
2020-08-21 12:45:33 +02:00
|
|
|
IDP_BlendWrite(writer, ui_list->properties);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-08-29 12:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
2020-08-07 11:47:23 -06:00
|
|
|
static void write_space_outliner(BlendWriter *writer, SpaceOutliner *space_outliner)
|
2013-08-03 11:35:09 +00:00
|
|
|
{
|
2020-08-07 11:47:23 -06:00
|
|
|
BLI_mempool *ts = space_outliner->treestore;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (ts) {
|
2020-08-07 11:47:23 -06:00
|
|
|
SpaceOutliner space_outliner_flat = *space_outliner;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
int elems = BLI_mempool_len(ts);
|
|
|
|
|
/* linearize mempool to array */
|
|
|
|
|
TreeStoreElem *data = elems ? BLI_mempool_as_arrayN(ts, "TreeStoreElem") : NULL;
|
|
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
|
/* In this block we use the memory location of the treestore
|
|
|
|
|
* but _not_ its data, the addresses in this case are UUID's,
|
|
|
|
|
* since we can't rely on malloc giving us different values each time.
|
|
|
|
|
*/
|
|
|
|
|
TreeStore ts_flat = {0};
|
|
|
|
|
|
|
|
|
|
/* we know the treestore is at least as big as a pointer,
|
|
|
|
|
* so offsetting works to give us a UUID. */
|
|
|
|
|
void *data_addr = (void *)POINTER_OFFSET(ts, sizeof(void *));
|
|
|
|
|
|
|
|
|
|
ts_flat.usedelem = elems;
|
|
|
|
|
ts_flat.totelem = elems;
|
|
|
|
|
ts_flat.data = data_addr;
|
|
|
|
|
|
2020-08-07 11:47:23 -06:00
|
|
|
BLO_write_struct(writer, SpaceOutliner, space_outliner);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-05 21:51:07 +02:00
|
|
|
BLO_write_struct_at_address(writer, TreeStore, ts, &ts_flat);
|
|
|
|
|
BLO_write_struct_array_at_address(writer, TreeStoreElem, elems, data_addr, data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
MEM_freeN(data);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2020-08-07 11:47:23 -06:00
|
|
|
space_outliner_flat.treestore = NULL;
|
|
|
|
|
BLO_write_struct_at_address(writer, SpaceOutliner, space_outliner, &space_outliner_flat);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2020-08-07 11:47:23 -06:00
|
|
|
BLO_write_struct(writer, SpaceOutliner, space_outliner);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-08-03 11:35:09 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
static void write_panel_list(BlendWriter *writer, ListBase *lb)
|
2018-06-03 13:32:36 +02:00
|
|
|
{
|
2020-04-03 22:20:25 -05:00
|
|
|
LISTBASE_FOREACH (Panel *, panel, lb) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, Panel, panel);
|
|
|
|
|
write_panel_list(writer, &panel->children);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-06-03 13:32:36 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
static void write_area_regions(BlendWriter *writer, ScrArea *area)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
2020-06-05 20:34:43 +02:00
|
|
|
write_region(writer, region, area->spacetype);
|
|
|
|
|
write_panel_list(writer, ®ion->panels);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (PanelCategoryStack *, pc_act, ®ion->panels_category_active) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, PanelCategoryStack, pc_act);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (uiList *, ui_list, ®ion->ui_lists) {
|
2020-06-05 20:34:43 +02:00
|
|
|
write_uilist(writer, ui_list);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (uiPreview *, ui_preview, ®ion->ui_previews) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, uiPreview, ui_preview);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
|
|
|
|
LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
|
2020-06-05 20:34:43 +02:00
|
|
|
write_region(writer, region, sl->spacetype);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sl->spacetype == SPACE_VIEW3D) {
|
|
|
|
|
View3D *v3d = (View3D *)sl;
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, View3D, v3d);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (v3d->localvd) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, View3D, v3d->localvd);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
write_view3dshading(writer, &v3d->shading);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_GRAPH) {
|
|
|
|
|
SpaceGraph *sipo = (SpaceGraph *)sl;
|
|
|
|
|
ListBase tmpGhosts = sipo->runtime.ghost_curves;
|
|
|
|
|
|
|
|
|
|
/* temporarily disable ghost curves when saving */
|
|
|
|
|
BLI_listbase_clear(&sipo->runtime.ghost_curves);
|
|
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceGraph, sl);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (sipo->ads) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, bDopeSheet, sipo->ads);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* reenable ghost curves */
|
|
|
|
|
sipo->runtime.ghost_curves = tmpGhosts;
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_PROPERTIES) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceProperties, sl);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_FILE) {
|
|
|
|
|
SpaceFile *sfile = (SpaceFile *)sl;
|
|
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceFile, sl);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (sfile->params) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, FileSelectParams, sfile->params);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_SEQ) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceSeq, sl);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_OUTLINER) {
|
2020-08-07 11:47:23 -06:00
|
|
|
SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
|
|
|
|
|
write_space_outliner(writer, space_outliner);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_IMAGE) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceImage, sl);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_TEXT) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceText, sl);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_SCRIPT) {
|
|
|
|
|
SpaceScript *scr = (SpaceScript *)sl;
|
|
|
|
|
scr->but_refs = NULL;
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceScript, sl);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_ACTION) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceAction, sl);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_NLA) {
|
|
|
|
|
SpaceNla *snla = (SpaceNla *)sl;
|
|
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceNla, snla);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (snla->ads) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, bDopeSheet, snla->ads);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_NODE) {
|
|
|
|
|
SpaceNode *snode = (SpaceNode *)sl;
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceNode, snode);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (bNodeTreePath *, path, &snode->treepath) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, bNodeTreePath, path);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_CONSOLE) {
|
|
|
|
|
SpaceConsole *con = (SpaceConsole *)sl;
|
|
|
|
|
|
2020-08-21 13:14:41 +02:00
|
|
|
LISTBASE_FOREACH (ConsoleLine *, cl, &con->history) {
|
2019-04-17 06:17:24 +02:00
|
|
|
/* 'len_alloc' is invalid on write, set from 'len' on read */
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, ConsoleLine, cl);
|
2020-09-20 18:41:50 +02:00
|
|
|
BLO_write_raw(writer, (size_t)cl->len + 1, cl->line);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceConsole, sl);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-05-23 22:38:25 +02:00
|
|
|
#ifdef WITH_GLOBAL_AREA_WRITING
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (sl->spacetype == SPACE_TOPBAR) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceTopBar, sl);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_STATUSBAR) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceStatusBar, sl);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
else if (sl->spacetype == SPACE_USERPREF) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceUserPref, sl);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_CLIP) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceClip, sl);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else if (sl->spacetype == SPACE_INFO) {
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, SpaceInfo, sl);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
static void write_area_map(BlendWriter *writer, ScrAreaMap *area_map)
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
{
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct_list(writer, ScrVert, &area_map->vertbase);
|
|
|
|
|
BLO_write_struct_list(writer, ScrEdge, &area_map->edgebase);
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (ScrArea *, area, &area_map->areabase) {
|
2019-04-17 06:17:24 +02:00
|
|
|
area->butspacetype = area->spacetype; /* Just for compatibility, will be reset below. */
|
2018-04-22 19:58:27 +02:00
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, ScrArea, area);
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
|
2018-05-23 22:38:25 +02:00
|
|
|
#ifdef WITH_GLOBAL_AREA_WRITING
|
2020-06-05 20:34:43 +02:00
|
|
|
BLO_write_struct(writer, ScrGlobalAreaData, area->global);
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
#endif
|
2011-07-08 12:22:48 +00:00
|
|
|
|
2020-06-05 20:34:43 +02:00
|
|
|
write_area_regions(writer, area);
|
2018-04-22 19:58:27 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
area->butspacetype = SPACE_EMPTY; /* Unset again, was changed above. */
|
|
|
|
|
}
|
2018-04-13 20:29:16 +02:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2020-06-05 12:29:40 +02:00
|
|
|
static void write_windowmanager(BlendWriter *writer, wmWindowManager *wm, const void *id_address)
|
2018-04-13 20:29:16 +02:00
|
|
|
{
|
2020-06-05 12:29:40 +02:00
|
|
|
BLO_write_id_struct(writer, wmWindowManager, id_address, &wm->id);
|
2020-08-28 15:45:11 +02:00
|
|
|
BKE_id_blend_write(writer, &wm->id);
|
2020-06-05 20:34:43 +02:00
|
|
|
write_wm_xr_data(writer, &wm->xr);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
2018-05-23 22:38:25 +02:00
|
|
|
#ifndef WITH_GLOBAL_AREA_WRITING
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Don't write global areas yet, while we make changes to them. */
|
|
|
|
|
ScrAreaMap global_areas = win->global_areas;
|
|
|
|
|
memset(&win->global_areas, 0, sizeof(win->global_areas));
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
#endif
|
2010-04-23 09:24:22 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* update deprecated screen member (for so loading in 2.7x uses the correct screen) */
|
|
|
|
|
win->screen = BKE_workspace_active_screen_get(win->workspace_hook);
|
Refactor writefile handling of data-blocks.
Instead of calling a function looping over whole list of a given ID
type, make whole loop over Main in parent function, and call functions
writing a single datablock at a time.
This design is more in line with all other places in Blender where we
handle whole content of Main (including readfile.c), and much more easy
to extend and add e.g. some generic processing of IDs before/after
writing, etc.
From user point, there should be no change at all, only difference is
that data-block types won't be saved in same order as before (.blend
file specs enforces no order here, so this is not an issue, but it could
bug some third party users using other, simplified .blend file reader maybe).
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D2510
2017-03-17 10:02:08 +01:00
|
|
|
|
2020-06-05 12:29:40 +02:00
|
|
|
BLO_write_struct(writer, wmWindow, win);
|
|
|
|
|
BLO_write_struct(writer, WorkSpaceInstanceHook, win->workspace_hook);
|
|
|
|
|
BLO_write_struct(writer, Stereo3dFormat, win->stereo3d_format);
|
Refactor writefile handling of data-blocks.
Instead of calling a function looping over whole list of a given ID
type, make whole loop over Main in parent function, and call functions
writing a single datablock at a time.
This design is more in line with all other places in Blender where we
handle whole content of Main (including readfile.c), and much more easy
to extend and add e.g. some generic processing of IDs before/after
writing, etc.
From user point, there should be no change at all, only difference is
that data-block types won't be saved in same order as before (.blend
file specs enforces no order here, so this is not an issue, but it could
bug some third party users using other, simplified .blend file reader maybe).
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D2510
2017-03-17 10:02:08 +01:00
|
|
|
|
2018-05-23 22:38:25 +02:00
|
|
|
#ifdef WITH_GLOBAL_AREA_WRITING
|
2020-06-05 20:34:43 +02:00
|
|
|
write_area_map(writer, &win->global_areas);
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
#else
|
2019-04-17 06:17:24 +02:00
|
|
|
win->global_areas = global_areas;
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
#endif
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* data is written, clear deprecated data again */
|
|
|
|
|
win->screen = NULL;
|
|
|
|
|
}
|
2018-04-13 20:29:16 +02:00
|
|
|
}
|
Refactor writefile handling of data-blocks.
Instead of calling a function looping over whole list of a given ID
type, make whole loop over Main in parent function, and call functions
writing a single datablock at a time.
This design is more in line with all other places in Blender where we
handle whole content of Main (including readfile.c), and much more easy
to extend and add e.g. some generic processing of IDs before/after
writing, etc.
From user point, there should be no change at all, only difference is
that data-block types won't be saved in same order as before (.blend
file specs enforces no order here, so this is not an issue, but it could
bug some third party users using other, simplified .blend file reader maybe).
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D2510
2017-03-17 10:02:08 +01:00
|
|
|
|
2020-06-05 12:53:39 +02:00
|
|
|
static void write_screen(BlendWriter *writer, bScreen *screen, const void *id_address)
|
2018-04-13 20:29:16 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Screens are reference counted, only saved if used by a workspace. */
|
2020-06-05 12:53:39 +02:00
|
|
|
if (screen->id.us > 0 || BLO_write_is_undo(writer)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
/* write LibData */
|
|
|
|
|
/* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
|
2020-06-05 12:53:39 +02:00
|
|
|
writestruct_at_address(writer->wd, ID_SCRN, bScreen, 1, id_address, screen);
|
2020-08-28 15:45:11 +02:00
|
|
|
BKE_id_blend_write(writer, &screen->id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-10 10:33:05 +02:00
|
|
|
BKE_previewimg_blend_write(writer, screen->preview);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* direct data */
|
2020-06-05 20:34:43 +02:00
|
|
|
write_area_map(writer, AREAMAP_FROM_SCREEN(screen));
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2020-06-05 12:35:03 +02:00
|
|
|
static void write_workspace(BlendWriter *writer, WorkSpace *workspace, const void *id_address)
|
|
|
|
|
{
|
|
|
|
|
BLO_write_id_struct(writer, WorkSpace, id_address, &workspace->id);
|
2020-08-28 15:45:11 +02:00
|
|
|
BKE_id_blend_write(writer, &workspace->id);
|
2020-06-05 12:35:03 +02:00
|
|
|
BLO_write_struct_list(writer, WorkSpaceLayout, &workspace->layouts);
|
|
|
|
|
BLO_write_struct_list(writer, WorkSpaceDataRelation, &workspace->hook_layout_relations);
|
|
|
|
|
BLO_write_struct_list(writer, wmOwnerID, &workspace->owner_ids);
|
|
|
|
|
BLO_write_struct_list(writer, bToolRef, &workspace->tools);
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (tref->properties) {
|
2020-08-21 12:45:33 +02:00
|
|
|
IDP_BlendWrite(writer, tref->properties);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
}
|
|
|
|
|
|
2016-06-14 14:53:39 +02:00
|
|
|
/* Keep it last of write_foodata functions. */
|
|
|
|
|
static void write_libraries(WriteData *wd, Main *main)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ListBase *lbarray[MAX_LIBARRAY];
|
|
|
|
|
ID *id;
|
|
|
|
|
int a, tot;
|
|
|
|
|
bool found_one;
|
|
|
|
|
|
|
|
|
|
for (; main; main = main->next) {
|
|
|
|
|
a = tot = set_listbasepointers(main, lbarray);
|
|
|
|
|
|
|
|
|
|
/* test: is lib being used */
|
|
|
|
|
if (main->curlib && main->curlib->packedfile) {
|
|
|
|
|
found_one = true;
|
|
|
|
|
}
|
2020-05-25 17:39:16 +02:00
|
|
|
else if (wd->use_memfile) {
|
|
|
|
|
/* When writing undo step we always write all existing libraries, makes reading undo step
|
|
|
|
|
* much easier when dealing with purely indirectly used libraries. */
|
|
|
|
|
found_one = true;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
else {
|
|
|
|
|
found_one = false;
|
|
|
|
|
while (!found_one && tot--) {
|
|
|
|
|
for (id = lbarray[tot]->first; id; id = id->next) {
|
2019-09-16 14:52:06 +02:00
|
|
|
if (id->us > 0 &&
|
|
|
|
|
((id->tag & LIB_TAG_EXTERN) ||
|
|
|
|
|
((id->tag & LIB_TAG_INDIRECT) && (id->flag & LIB_INDIRECT_WEAK_LINK)))) {
|
2019-04-17 06:17:24 +02:00
|
|
|
found_one = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-22 01:10:29 +10:00
|
|
|
/* To be able to restore 'quit.blend' and temp saves,
|
|
|
|
|
* the packed blend has to be in undo buffers... */
|
|
|
|
|
/* XXX needs rethink, just like save UI in undo files now -
|
|
|
|
|
* would be nice to append things only for the 'quit.blend' and temp saves. */
|
2019-04-17 06:17:24 +02:00
|
|
|
if (found_one) {
|
|
|
|
|
/* Not overridable. */
|
|
|
|
|
|
2020-06-05 14:45:32 +02:00
|
|
|
BlendWriter writer = {wd};
|
2019-04-17 06:17:24 +02:00
|
|
|
writestruct(wd, ID_LI, Library, 1, main->curlib);
|
2020-08-28 15:45:11 +02:00
|
|
|
BKE_id_blend_write(&writer, &main->curlib->id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (main->curlib->packedfile) {
|
2020-09-10 14:35:09 +02:00
|
|
|
BKE_packedfile_blend_write(&writer, main->curlib->packedfile);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (wd->use_memfile == false) {
|
2020-06-23 09:54:14 +10:00
|
|
|
printf("write packed .blend: %s\n", main->curlib->filepath);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Write link placeholders for all direct linked IDs. */
|
|
|
|
|
while (a--) {
|
|
|
|
|
for (id = lbarray[a]->first; id; id = id->next) {
|
2019-09-16 14:52:06 +02:00
|
|
|
if (id->us > 0 &&
|
|
|
|
|
((id->tag & LIB_TAG_EXTERN) ||
|
|
|
|
|
((id->tag & LIB_TAG_INDIRECT) && (id->flag & LIB_INDIRECT_WEAK_LINK)))) {
|
2020-03-19 19:37:00 +01:00
|
|
|
if (!BKE_idtype_idcode_is_linkable(GS(id->name))) {
|
2019-04-17 06:17:24 +02:00
|
|
|
printf(
|
|
|
|
|
"ERROR: write file: data-block '%s' from lib '%s' is not linkable "
|
|
|
|
|
"but is flagged as directly linked",
|
|
|
|
|
id->name,
|
2020-06-23 09:54:07 +10:00
|
|
|
main->curlib->filepath_abs);
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_assert(0);
|
|
|
|
|
}
|
|
|
|
|
writestruct(wd, ID_LINK_PLACEHOLDER, ID, 1, id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mywrite_flush(wd);
|
2016-06-14 14:53:39 +02:00
|
|
|
}
|
|
|
|
|
|
2007-12-24 18:53:37 +00:00
|
|
|
/* context is usually defined by WM, two cases where no WM is available:
|
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
later added in trunk also, but reverted partially, specifically revision
16683. I have left out this reversion in the 2.5 branch since I think it is
needed there.
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
-W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
differently. Since this is changed so much, and I don't think those fixes
would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
initialized when running with -P. The code that initializes the screen there
I had to disable, that can't work in 2.5 anymore but left it commented as a
reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
still use changes that were done in trunk.
2008-11-12 21:16:53 +00:00
|
|
|
* - for forward compatibility, curscreen has to be saved
|
|
|
|
|
* - for undofile, curscene needs to be saved */
|
2009-10-20 13:58:53 +00:00
|
|
|
static void write_global(WriteData *wd, int fileflags, Main *mainvar)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const bool is_undo = wd->use_memfile;
|
|
|
|
|
FileGlobal fg;
|
|
|
|
|
bScreen *screen;
|
|
|
|
|
Scene *scene;
|
|
|
|
|
ViewLayer *view_layer;
|
|
|
|
|
char subvstr[8];
|
|
|
|
|
|
|
|
|
|
/* prevent mem checkers from complaining */
|
|
|
|
|
memset(fg._pad, 0, sizeof(fg._pad));
|
|
|
|
|
memset(fg.filename, 0, sizeof(fg.filename));
|
|
|
|
|
memset(fg.build_hash, 0, sizeof(fg.build_hash));
|
|
|
|
|
fg._pad1 = NULL;
|
|
|
|
|
|
|
|
|
|
current_screen_compat(mainvar, is_undo, &screen, &scene, &view_layer);
|
|
|
|
|
|
|
|
|
|
/* XXX still remap G */
|
|
|
|
|
fg.curscreen = screen;
|
|
|
|
|
fg.curscene = scene;
|
|
|
|
|
fg.cur_view_layer = view_layer;
|
|
|
|
|
|
|
|
|
|
/* prevent to save this, is not good convention, and feature with concerns... */
|
|
|
|
|
fg.fileflags = (fileflags & ~G_FILE_FLAG_ALL_RUNTIME);
|
|
|
|
|
|
|
|
|
|
fg.globalf = G.f;
|
|
|
|
|
BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename));
|
Blender: change bugfix release versioning from a/b/c to .1/.2/.3
The file subversion is no longer used in the Python API or user interface,
and is now internal to Blender.
User interface, Python API and file I/O metadata now use more consistent
formatting for version numbers. Official releases use "2.83.0", "2.83.1",
and releases under development use "2.90.0 Alpha", "2.90.0 Beta".
Some Python add-ons may need to lower the Blender version in bl_info to
(2, 83, 0) or (2, 90, 0) if they used a subversion number higher than 0.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Python_API#Compatibility
This change is in preparation of LTS releases, and also brings us more
in line with semantic versioning.
Fixes T76058.
Differential Revision: https://developer.blender.org/D7748
2020-05-25 10:49:04 +02:00
|
|
|
sprintf(subvstr, "%4d", BLENDER_FILE_SUBVERSION);
|
2019-04-17 06:17:24 +02:00
|
|
|
memcpy(fg.subvstr, subvstr, 4);
|
|
|
|
|
|
Blender: change bugfix release versioning from a/b/c to .1/.2/.3
The file subversion is no longer used in the Python API or user interface,
and is now internal to Blender.
User interface, Python API and file I/O metadata now use more consistent
formatting for version numbers. Official releases use "2.83.0", "2.83.1",
and releases under development use "2.90.0 Alpha", "2.90.0 Beta".
Some Python add-ons may need to lower the Blender version in bl_info to
(2, 83, 0) or (2, 90, 0) if they used a subversion number higher than 0.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Python_API#Compatibility
This change is in preparation of LTS releases, and also brings us more
in line with semantic versioning.
Fixes T76058.
Differential Revision: https://developer.blender.org/D7748
2020-05-25 10:49:04 +02:00
|
|
|
fg.subversion = BLENDER_FILE_SUBVERSION;
|
|
|
|
|
fg.minversion = BLENDER_FILE_MIN_VERSION;
|
|
|
|
|
fg.minsubversion = BLENDER_FILE_MIN_SUBVERSION;
|
2011-08-22 16:54:26 +00:00
|
|
|
#ifdef WITH_BUILDINFO
|
2019-04-17 06:17:24 +02:00
|
|
|
{
|
|
|
|
|
extern unsigned long build_commit_timestamp;
|
|
|
|
|
extern char build_hash[];
|
|
|
|
|
/* TODO(sergey): Add branch name to file as well? */
|
|
|
|
|
fg.build_commit_timestamp = build_commit_timestamp;
|
|
|
|
|
BLI_strncpy(fg.build_hash, build_hash, sizeof(fg.build_hash));
|
|
|
|
|
}
|
2011-01-02 13:33:32 +00:00
|
|
|
#else
|
2019-04-17 06:17:24 +02:00
|
|
|
fg.build_commit_timestamp = 0;
|
|
|
|
|
BLI_strncpy(fg.build_hash, "unknown", sizeof(fg.build_hash));
|
2011-01-02 13:33:32 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
writestruct(wd, GLOB, FileGlobal, 1, &fg);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-24 21:52:18 +00:00
|
|
|
/* preview image, first 2 values are width and height
|
2018-11-30 14:51:16 +11:00
|
|
|
* second are an RGBA image (uchar)
|
2010-05-24 21:52:18 +00:00
|
|
|
* note, this uses 'TEST' since new types will segfault on file load for older blender versions.
|
|
|
|
|
*/
|
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
|
|
|
static void write_thumb(WriteData *wd, const BlendThumbnail *thumb)
|
2010-05-24 21:52:18 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (thumb) {
|
|
|
|
|
writedata(wd, TEST, BLEN_THUMB_MEMSIZE_FILE(thumb->width, thumb->height), thumb);
|
|
|
|
|
}
|
2010-05-24 21:52:18 +00:00
|
|
|
}
|
|
|
|
|
|
2018-04-14 13:17:11 +02:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name File Writing (Private)
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2006-11-25 13:07:28 +00:00
|
|
|
/* if MemFile * there's filesave to memory */
|
2019-04-17 06:17:24 +02:00
|
|
|
static bool write_file_handle(Main *mainvar,
|
|
|
|
|
WriteWrap *ww,
|
|
|
|
|
MemFile *compare,
|
|
|
|
|
MemFile *current,
|
|
|
|
|
int write_flags,
|
2020-06-19 15:41:07 +10:00
|
|
|
bool use_userdef,
|
2019-04-17 06:17:24 +02:00
|
|
|
const BlendThumbnail *thumb)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BHead bhead;
|
|
|
|
|
ListBase mainlist;
|
|
|
|
|
char buf[16];
|
|
|
|
|
WriteData *wd;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
blo_split_main(&mainlist, mainvar);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
wd = mywrite_begin(ww, compare, current);
|
2020-06-05 21:19:03 +02:00
|
|
|
BlendWriter writer = {wd};
|
2011-12-27 13:17:58 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
sprintf(buf,
|
|
|
|
|
"BLENDER%c%c%.3d",
|
|
|
|
|
(sizeof(void *) == 8) ? '-' : '_',
|
|
|
|
|
(ENDIAN_ORDER == B_ENDIAN) ? 'V' : 'v',
|
Blender: change bugfix release versioning from a/b/c to .1/.2/.3
The file subversion is no longer used in the Python API or user interface,
and is now internal to Blender.
User interface, Python API and file I/O metadata now use more consistent
formatting for version numbers. Official releases use "2.83.0", "2.83.1",
and releases under development use "2.90.0 Alpha", "2.90.0 Beta".
Some Python add-ons may need to lower the Blender version in bl_info to
(2, 83, 0) or (2, 90, 0) if they used a subversion number higher than 0.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Python_API#Compatibility
This change is in preparation of LTS releases, and also brings us more
in line with semantic versioning.
Fixes T76058.
Differential Revision: https://developer.blender.org/D7748
2020-05-25 10:49:04 +02:00
|
|
|
BLENDER_FILE_VERSION);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
mywrite(wd, buf, 12);
|
|
|
|
|
|
|
|
|
|
write_renderinfo(wd, mainvar);
|
|
|
|
|
write_thumb(wd, thumb);
|
|
|
|
|
write_global(wd, write_flags, mainvar);
|
|
|
|
|
|
|
|
|
|
/* The windowmanager and screen often change,
|
|
|
|
|
* avoid thumbnail detecting changes because of this. */
|
|
|
|
|
mywrite_flush(wd);
|
|
|
|
|
|
2020-08-05 11:56:14 +10:00
|
|
|
OverrideLibraryStorage *override_storage = wd->use_memfile ?
|
|
|
|
|
NULL :
|
|
|
|
|
BKE_lib_override_library_operations_store_init();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-01 09:40:11 +02:00
|
|
|
#define ID_BUFFER_STATIC_SIZE 8192
|
2019-06-12 09:04:10 +10:00
|
|
|
/* This outer loop allows to save first data-blocks from real mainvar,
|
2019-04-22 01:10:29 +10:00
|
|
|
* then the temp ones from override process,
|
2019-04-17 06:17:24 +02:00
|
|
|
* if needed, without duplicating whole code. */
|
|
|
|
|
Main *bmain = mainvar;
|
|
|
|
|
do {
|
|
|
|
|
ListBase *lbarray[MAX_LIBARRAY];
|
|
|
|
|
int a = set_listbasepointers(bmain, lbarray);
|
|
|
|
|
while (a--) {
|
|
|
|
|
ID *id = lbarray[a]->first;
|
|
|
|
|
|
2020-04-01 09:40:11 +02:00
|
|
|
if (id == NULL || GS(id->name) == ID_LI) {
|
2019-04-17 06:17:24 +02:00
|
|
|
continue; /* Libraries are handled separately below. */
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 09:40:11 +02:00
|
|
|
char id_buffer_static[ID_BUFFER_STATIC_SIZE];
|
|
|
|
|
void *id_buffer = id_buffer_static;
|
|
|
|
|
const size_t idtype_struct_size = BKE_idtype_get_info_from_id(id)->struct_size;
|
|
|
|
|
if (idtype_struct_size > ID_BUFFER_STATIC_SIZE) {
|
|
|
|
|
BLI_assert(0);
|
|
|
|
|
id_buffer = MEM_mallocN(idtype_struct_size, __func__);
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (; id; id = id->next) {
|
2019-04-22 01:10:29 +10:00
|
|
|
/* We should never attempt to write non-regular IDs
|
|
|
|
|
* (i.e. all kind of temp/runtime ones). */
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_assert(
|
|
|
|
|
(id->tag & (LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT | LIB_TAG_NOT_ALLOCATED)) == 0);
|
|
|
|
|
|
2020-06-30 10:52:02 +02:00
|
|
|
const bool do_override = !ELEM(override_storage, NULL, bmain) &&
|
2020-06-30 11:33:36 +02:00
|
|
|
ID_IS_OVERRIDE_LIBRARY_REAL(id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (do_override) {
|
2020-02-10 18:05:19 +01:00
|
|
|
BKE_lib_override_library_operations_store_start(bmain, override_storage, id);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-13 17:38:34 +02:00
|
|
|
if (wd->use_memfile) {
|
|
|
|
|
/* Record the changes that happened up to this undo push in
|
|
|
|
|
* recalc_up_to_undo_push, and clear recalc_after_undo_push again
|
|
|
|
|
* to start accumulating for the next undo push. */
|
|
|
|
|
id->recalc_up_to_undo_push = id->recalc_after_undo_push;
|
|
|
|
|
id->recalc_after_undo_push = 0;
|
|
|
|
|
|
|
|
|
|
bNodeTree *nodetree = ntreeFromID(id);
|
|
|
|
|
if (nodetree != NULL) {
|
|
|
|
|
nodetree->id.recalc_up_to_undo_push = nodetree->id.recalc_after_undo_push;
|
|
|
|
|
nodetree->id.recalc_after_undo_push = 0;
|
|
|
|
|
}
|
|
|
|
|
if (GS(id->name) == ID_SCE) {
|
|
|
|
|
Scene *scene = (Scene *)id;
|
|
|
|
|
if (scene->master_collection != NULL) {
|
|
|
|
|
scene->master_collection->id.recalc_up_to_undo_push =
|
|
|
|
|
scene->master_collection->id.recalc_after_undo_push;
|
|
|
|
|
scene->master_collection->id.recalc_after_undo_push = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-03 12:07:45 +02:00
|
|
|
mywrite_id_begin(wd, id);
|
|
|
|
|
|
2020-04-01 09:40:11 +02:00
|
|
|
memcpy(id_buffer, id, idtype_struct_size);
|
|
|
|
|
|
|
|
|
|
((ID *)id_buffer)->tag = 0;
|
2020-08-21 13:14:41 +02:00
|
|
|
/* Those listbase data change every time we add/remove an ID, and also often when
|
|
|
|
|
* renaming one (due to re-sorting). This avoids generating a lot of false 'is changed'
|
|
|
|
|
* detections between undo steps. */
|
2020-05-29 14:30:02 +02:00
|
|
|
((ID *)id_buffer)->prev = NULL;
|
|
|
|
|
((ID *)id_buffer)->next = NULL;
|
2020-04-01 09:40:11 +02:00
|
|
|
|
2020-08-28 13:05:48 +02:00
|
|
|
const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
|
|
|
|
|
if (id_type->blend_write != NULL) {
|
|
|
|
|
id_type->blend_write(&writer, (ID *)id_buffer, id);
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
switch ((ID_Type)GS(id->name)) {
|
|
|
|
|
case ID_WM:
|
2020-06-05 12:29:40 +02:00
|
|
|
write_windowmanager(&writer, (wmWindowManager *)id_buffer, id);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case ID_WS:
|
2020-06-05 12:35:03 +02:00
|
|
|
write_workspace(&writer, (WorkSpace *)id_buffer, id);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case ID_SCR:
|
2020-06-05 12:53:39 +02:00
|
|
|
write_screen(&writer, (bScreen *)id_buffer, id);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case ID_SCE:
|
2020-06-05 13:55:33 +02:00
|
|
|
write_scene(&writer, (Scene *)id_buffer, id);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case ID_GR:
|
2020-06-05 14:09:35 +02:00
|
|
|
write_collection(&writer, (Collection *)id_buffer, id);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case ID_OB:
|
2020-06-05 14:41:42 +02:00
|
|
|
write_object(&writer, (Object *)id_buffer, id);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
case ID_PA:
|
2020-06-05 14:41:42 +02:00
|
|
|
write_particlesettings(&writer, (ParticleSettings *)id_buffer, id);
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
2020-08-28 15:45:11 +02:00
|
|
|
case ID_ME:
|
2020-08-28 16:10:17 +02:00
|
|
|
case ID_LT:
|
2020-09-10 11:02:42 +02:00
|
|
|
case ID_AC:
|
2020-09-10 13:33:29 +02:00
|
|
|
case ID_NT:
|
2020-09-10 13:50:03 +02:00
|
|
|
case ID_LS:
|
2020-09-10 13:57:08 +02:00
|
|
|
case ID_TXT:
|
2020-09-10 14:42:39 +02:00
|
|
|
case ID_VF:
|
2020-09-10 14:53:11 +02:00
|
|
|
case ID_MC:
|
2020-09-10 15:40:08 +02:00
|
|
|
case ID_PC:
|
|
|
|
|
case ID_PAL:
|
2020-09-10 15:50:50 +02:00
|
|
|
case ID_BR:
|
2020-09-10 15:59:00 +02:00
|
|
|
case ID_IM:
|
2020-09-10 16:13:18 +02:00
|
|
|
case ID_LA:
|
2020-09-10 16:23:53 +02:00
|
|
|
case ID_MA:
|
2020-09-10 16:37:11 +02:00
|
|
|
case ID_MB:
|
2020-09-10 16:47:12 +02:00
|
|
|
case ID_CU:
|
2020-09-10 16:57:47 +02:00
|
|
|
case ID_CA:
|
2020-09-10 17:06:35 +02:00
|
|
|
case ID_WO:
|
2020-09-10 17:22:35 +02:00
|
|
|
case ID_MSK:
|
2020-09-10 17:31:18 +02:00
|
|
|
case ID_SPK:
|
2020-09-10 17:41:04 +02:00
|
|
|
case ID_AR:
|
2020-09-10 17:47:04 +02:00
|
|
|
case ID_LP:
|
2020-09-10 18:00:44 +02:00
|
|
|
case ID_KE:
|
2020-09-11 10:35:36 +02:00
|
|
|
case ID_TE:
|
2020-09-11 11:06:15 +02:00
|
|
|
case ID_GD:
|
2020-09-11 11:14:17 +02:00
|
|
|
case ID_HA:
|
2020-09-11 11:20:57 +02:00
|
|
|
case ID_PT:
|
2020-09-11 11:39:06 +02:00
|
|
|
case ID_VO:
|
2020-09-11 11:46:26 +02:00
|
|
|
case ID_SIM:
|
2020-09-11 11:52:25 +02:00
|
|
|
case ID_SO:
|
2020-09-11 11:57:54 +02:00
|
|
|
case ID_CF:
|
2020-08-28 15:45:11 +02:00
|
|
|
/* Do nothing, handled in IDTypeInfo callback. */
|
|
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
case ID_LI:
|
|
|
|
|
/* Do nothing, handled below - and should never be reached. */
|
|
|
|
|
BLI_assert(0);
|
|
|
|
|
break;
|
|
|
|
|
case ID_IP:
|
|
|
|
|
/* Do nothing, deprecated. */
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
/* Should never be reached. */
|
|
|
|
|
BLI_assert(0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (do_override) {
|
2020-02-10 18:05:19 +01:00
|
|
|
BKE_lib_override_library_operations_store_end(override_storage, id);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-03-17 12:29:36 +01:00
|
|
|
|
2020-06-03 12:07:45 +02:00
|
|
|
mywrite_id_end(wd, id);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-01 09:40:11 +02:00
|
|
|
if (id_buffer != id_buffer_static) {
|
|
|
|
|
MEM_SAFE_FREE(id_buffer);
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
mywrite_flush(wd);
|
|
|
|
|
}
|
|
|
|
|
} while ((bmain != override_storage) && (bmain = override_storage));
|
|
|
|
|
|
|
|
|
|
if (override_storage) {
|
2020-02-10 18:05:19 +01:00
|
|
|
BKE_lib_override_library_operations_store_finalize(override_storage);
|
2019-04-17 06:17:24 +02:00
|
|
|
override_storage = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Special handling, operating over split Mains... */
|
|
|
|
|
write_libraries(wd, mainvar->next);
|
|
|
|
|
|
|
|
|
|
/* So changes above don't cause a 'DNA1' to be detected as changed on undo. */
|
|
|
|
|
mywrite_flush(wd);
|
|
|
|
|
|
2020-06-19 15:41:07 +10:00
|
|
|
if (use_userdef) {
|
2020-06-05 21:19:03 +02:00
|
|
|
write_userdef(&writer, &U);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Write DNA last, because (to be implemented) test for which structs are written.
|
|
|
|
|
*
|
|
|
|
|
* Note that we *borrow* the pointer to 'DNAstr',
|
|
|
|
|
* so writing each time uses the same address and doesn't cause unnecessary undo overhead. */
|
2020-09-20 18:41:50 +02:00
|
|
|
writedata(wd, DNA1, (size_t)wd->sdna->data_len, wd->sdna->data);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* end of file */
|
|
|
|
|
memset(&bhead, 0, sizeof(BHead));
|
|
|
|
|
bhead.code = ENDB;
|
|
|
|
|
mywrite(wd, &bhead, sizeof(BHead));
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
blo_join_main(&mainlist);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return mywrite_end(wd);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2011-06-02 12:44:59 +00:00
|
|
|
/* do reverse file history: .blend1 -> .blend2, .blend -> .blend1 */
|
|
|
|
|
/* return: success(0), failure(1) */
|
2014-02-03 18:55:59 +11:00
|
|
|
static bool do_history(const char *name, ReportList *reports)
|
2011-06-02 12:44:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
char tempname1[FILE_MAX], tempname2[FILE_MAX];
|
|
|
|
|
int hisnr = U.versions;
|
|
|
|
|
|
|
|
|
|
if (U.versions == 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strlen(name) < 2) {
|
|
|
|
|
BKE_report(reports, RPT_ERROR, "Unable to make version backup: filename too short");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (hisnr > 1) {
|
|
|
|
|
BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr - 1);
|
|
|
|
|
if (BLI_exists(tempname1)) {
|
|
|
|
|
BLI_snprintf(tempname2, sizeof(tempname2), "%s%d", name, hisnr);
|
|
|
|
|
|
|
|
|
|
if (BLI_rename(tempname1, tempname2)) {
|
|
|
|
|
BKE_report(reports, RPT_ERROR, "Unable to make version backup");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
hisnr--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* is needed when hisnr==1 */
|
|
|
|
|
if (BLI_exists(name)) {
|
|
|
|
|
BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr);
|
|
|
|
|
|
|
|
|
|
if (BLI_rename(name, tempname1)) {
|
|
|
|
|
BKE_report(reports, RPT_ERROR, "Unable to make version backup");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
2011-06-02 12:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
2018-04-14 13:17:11 +02:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name File Writing (Public)
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2016-03-03 13:35:21 +11:00
|
|
|
/**
|
|
|
|
|
* \return Success.
|
|
|
|
|
*/
|
2020-06-19 15:41:07 +10:00
|
|
|
bool BLO_write_file(Main *mainvar,
|
|
|
|
|
const char *filepath,
|
|
|
|
|
const int write_flags,
|
|
|
|
|
const struct BlendFileWriteParams *params,
|
|
|
|
|
ReportList *reports)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
char tempname[FILE_MAX + 1];
|
|
|
|
|
eWriteWrapType ww_type;
|
|
|
|
|
WriteWrap ww;
|
|
|
|
|
|
2020-06-19 15:41:07 +10:00
|
|
|
eBLO_WritePathRemap remap_mode = params->remap_mode;
|
|
|
|
|
const bool use_save_versions = params->use_save_versions;
|
|
|
|
|
const bool use_save_as_copy = params->use_save_as_copy;
|
|
|
|
|
const bool use_userdef = params->use_userdef;
|
|
|
|
|
const BlendThumbnail *thumb = params->thumb;
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* path backup/restore */
|
|
|
|
|
void *path_list_backup = NULL;
|
|
|
|
|
const int path_list_flag = (BKE_BPATH_TRAVERSE_SKIP_LIBRARY | BKE_BPATH_TRAVERSE_SKIP_MULTIFILE);
|
|
|
|
|
|
|
|
|
|
if (G.debug & G_DEBUG_IO && mainvar->lock != NULL) {
|
|
|
|
|
BKE_report(reports, RPT_INFO, "Checking sanity of current .blend file *BEFORE* save to disk");
|
|
|
|
|
BLO_main_validate_libraries(mainvar, reports);
|
|
|
|
|
BLO_main_validate_shapekeys(mainvar, reports);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* open temporary file, so we preserve the original in case we crash */
|
|
|
|
|
BLI_snprintf(tempname, sizeof(tempname), "%s@", filepath);
|
|
|
|
|
|
|
|
|
|
if (write_flags & G_FILE_COMPRESS) {
|
|
|
|
|
ww_type = WW_WRAP_ZLIB;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ww_type = WW_WRAP_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ww_handle_init(ww_type, &ww);
|
|
|
|
|
|
|
|
|
|
if (ww.open(&ww, tempname) == false) {
|
|
|
|
|
BKE_reportf(
|
|
|
|
|
reports, RPT_ERROR, "Cannot open file %s for writing: %s", tempname, strerror(errno));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 22:03:07 +11:00
|
|
|
/* Remapping of relative paths to new file location. */
|
2020-06-18 15:25:22 +10:00
|
|
|
if (remap_mode != BLO_WRITE_PATH_REMAP_NONE) {
|
|
|
|
|
|
|
|
|
|
if (remap_mode == BLO_WRITE_PATH_REMAP_RELATIVE) {
|
2020-08-21 13:14:41 +02:00
|
|
|
/* Make all relative as none of the existing paths can be relative in an unsaved document.
|
|
|
|
|
*/
|
2020-06-18 15:25:22 +10:00
|
|
|
if (G.relbase_valid == false) {
|
|
|
|
|
remap_mode = BLO_WRITE_PATH_REMAP_RELATIVE_ALL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 22:03:07 +11:00
|
|
|
char dir_src[FILE_MAX];
|
|
|
|
|
char dir_dst[FILE_MAX];
|
|
|
|
|
BLI_split_dir_part(mainvar->name, dir_src, sizeof(dir_src));
|
|
|
|
|
BLI_split_dir_part(filepath, dir_dst, sizeof(dir_dst));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-07 00:35:55 +11:00
|
|
|
/* Just in case there is some subtle difference. */
|
2020-04-07 12:02:21 +10:00
|
|
|
BLI_path_normalize(mainvar->name, dir_dst);
|
|
|
|
|
BLI_path_normalize(mainvar->name, dir_src);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-18 15:25:22 +10:00
|
|
|
/* Only for relative, not relative-all, as this means making existing paths relative. */
|
|
|
|
|
if (remap_mode == BLO_WRITE_PATH_REMAP_RELATIVE) {
|
|
|
|
|
if (G.relbase_valid && (BLI_path_cmp(dir_dst, dir_src) == 0)) {
|
|
|
|
|
/* Saved to same path. Nothing to do. */
|
|
|
|
|
remap_mode = BLO_WRITE_PATH_REMAP_NONE;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-06-18 15:25:22 +10:00
|
|
|
else if (remap_mode == BLO_WRITE_PATH_REMAP_ABSOLUTE) {
|
|
|
|
|
if (G.relbase_valid == false) {
|
|
|
|
|
/* Unsaved, all paths are absolute.Even if the user manages to set a relative path,
|
|
|
|
|
* there is no base-path that can be used to make it absolute. */
|
|
|
|
|
remap_mode = BLO_WRITE_PATH_REMAP_NONE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (remap_mode != BLO_WRITE_PATH_REMAP_NONE) {
|
2020-02-18 22:03:07 +11:00
|
|
|
/* Check if we need to backup and restore paths. */
|
2020-06-19 15:41:07 +10:00
|
|
|
if (UNLIKELY(use_save_as_copy)) {
|
2020-02-18 22:03:07 +11:00
|
|
|
path_list_backup = BKE_bpath_list_backup(mainvar, path_list_flag);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-18 15:25:22 +10:00
|
|
|
switch (remap_mode) {
|
|
|
|
|
case BLO_WRITE_PATH_REMAP_RELATIVE:
|
|
|
|
|
/* Saved, make relative paths relative to new location (if possible). */
|
|
|
|
|
BKE_bpath_relative_rebase(mainvar, dir_src, dir_dst, NULL);
|
|
|
|
|
break;
|
|
|
|
|
case BLO_WRITE_PATH_REMAP_RELATIVE_ALL:
|
|
|
|
|
/* Make all relative (when requested or unsaved). */
|
|
|
|
|
BKE_bpath_relative_convert(mainvar, dir_dst, NULL);
|
|
|
|
|
break;
|
|
|
|
|
case BLO_WRITE_PATH_REMAP_ABSOLUTE:
|
|
|
|
|
/* Make all absolute (when requested or unsaved). */
|
|
|
|
|
BKE_bpath_absolute_convert(mainvar, dir_src, NULL);
|
|
|
|
|
break;
|
|
|
|
|
case BLO_WRITE_PATH_REMAP_NONE:
|
|
|
|
|
BLI_assert(0); /* Unreachable. */
|
|
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* actual file writing */
|
2020-06-19 15:41:07 +10:00
|
|
|
const bool err = write_file_handle(mainvar, &ww, NULL, NULL, write_flags, use_userdef, thumb);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
ww.close(&ww);
|
|
|
|
|
|
|
|
|
|
if (UNLIKELY(path_list_backup)) {
|
|
|
|
|
BKE_bpath_list_restore(mainvar, path_list_flag, path_list_backup);
|
|
|
|
|
BKE_bpath_list_free(path_list_backup);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
BKE_report(reports, RPT_ERROR, strerror(errno));
|
|
|
|
|
remove(tempname);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* file save to temporary file was successful */
|
|
|
|
|
/* now do reverse file history (move .blend1 -> .blend2, .blend -> .blend1) */
|
2020-06-19 15:41:07 +10:00
|
|
|
if (use_save_versions) {
|
2019-04-17 06:17:24 +02:00
|
|
|
const bool err_hist = do_history(filepath, reports);
|
|
|
|
|
if (err_hist) {
|
|
|
|
|
BKE_report(reports, RPT_ERROR, "Version backup failed (file saved with @)");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BLI_rename(tempname, filepath) != 0) {
|
|
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot change old file (file saved with @)");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (G.debug & G_DEBUG_IO && mainvar->lock != NULL) {
|
|
|
|
|
BKE_report(reports, RPT_INFO, "Checking sanity of current .blend file *AFTER* save to disk");
|
|
|
|
|
BLO_main_validate_libraries(mainvar, reports);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-03 13:35:21 +11:00
|
|
|
/**
|
|
|
|
|
* \return Success.
|
|
|
|
|
*/
|
|
|
|
|
bool BLO_write_file_mem(Main *mainvar, MemFile *compare, MemFile *current, int write_flags)
|
2004-09-05 13:43:51 +00:00
|
|
|
{
|
2020-06-19 15:41:07 +10:00
|
|
|
bool use_userdef = false;
|
2004-09-05 13:43:51 +00:00
|
|
|
|
2020-06-19 15:41:07 +10:00
|
|
|
const bool err = write_file_handle(
|
|
|
|
|
mainvar, NULL, compare, current, write_flags, use_userdef, NULL);
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return (err == 0);
|
2016-03-03 13:35:21 +11:00
|
|
|
}
|
2018-04-14 13:17:11 +02:00
|
|
|
|
2020-09-20 18:41:50 +02:00
|
|
|
void BLO_write_raw(BlendWriter *writer, size_t size_in_bytes, const void *data_ptr)
|
2020-06-05 11:44:36 +02:00
|
|
|
{
|
|
|
|
|
writedata(writer->wd, DATA, size_in_bytes, data_ptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BLO_write_struct_by_name(BlendWriter *writer, const char *struct_name, const void *data_ptr)
|
|
|
|
|
{
|
2020-06-10 16:31:41 +02:00
|
|
|
BLO_write_struct_array_by_name(writer, struct_name, 1, data_ptr);
|
2020-06-05 11:44:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BLO_write_struct_array_by_name(BlendWriter *writer,
|
|
|
|
|
const char *struct_name,
|
|
|
|
|
int array_size,
|
|
|
|
|
const void *data_ptr)
|
|
|
|
|
{
|
|
|
|
|
int struct_id = BLO_get_struct_id_by_name(writer, struct_name);
|
2020-06-10 16:31:41 +02:00
|
|
|
if (UNLIKELY(struct_id == -1)) {
|
|
|
|
|
printf("error: can't find SDNA code <%s>\n", struct_name);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-06-05 11:44:36 +02:00
|
|
|
BLO_write_struct_array_by_id(writer, struct_id, array_size, data_ptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BLO_write_struct_by_id(BlendWriter *writer, int struct_id, const void *data_ptr)
|
|
|
|
|
{
|
|
|
|
|
writestruct_nr(writer->wd, DATA, struct_id, 1, data_ptr);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-05 21:44:14 +02:00
|
|
|
void BLO_write_struct_at_address_by_id(BlendWriter *writer,
|
|
|
|
|
int struct_id,
|
|
|
|
|
const void *address,
|
|
|
|
|
const void *data_ptr)
|
|
|
|
|
{
|
|
|
|
|
writestruct_at_address_nr(writer->wd, DATA, struct_id, 1, address, data_ptr);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-05 11:44:36 +02:00
|
|
|
void BLO_write_struct_array_by_id(BlendWriter *writer,
|
|
|
|
|
int struct_id,
|
|
|
|
|
int array_size,
|
|
|
|
|
const void *data_ptr)
|
|
|
|
|
{
|
|
|
|
|
writestruct_nr(writer->wd, DATA, struct_id, array_size, data_ptr);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-05 21:44:14 +02:00
|
|
|
void BLO_write_struct_array_at_address_by_id(
|
|
|
|
|
BlendWriter *writer, int struct_id, int array_size, const void *address, const void *data_ptr)
|
|
|
|
|
{
|
|
|
|
|
writestruct_at_address_nr(writer->wd, DATA, struct_id, array_size, address, data_ptr);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-05 11:44:36 +02:00
|
|
|
void BLO_write_struct_list_by_id(BlendWriter *writer, int struct_id, ListBase *list)
|
|
|
|
|
{
|
|
|
|
|
writelist_nr(writer->wd, DATA, struct_id, list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BLO_write_struct_list_by_name(BlendWriter *writer, const char *struct_name, ListBase *list)
|
|
|
|
|
{
|
2020-06-10 16:31:41 +02:00
|
|
|
int struct_id = BLO_get_struct_id_by_name(writer, struct_name);
|
|
|
|
|
if (UNLIKELY(struct_id == -1)) {
|
|
|
|
|
printf("error: can't find SDNA code <%s>\n", struct_name);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
BLO_write_struct_list_by_id(writer, struct_id, list);
|
2020-06-05 11:44:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void blo_write_id_struct(BlendWriter *writer, int struct_id, const void *id_address, const ID *id)
|
|
|
|
|
{
|
|
|
|
|
writestruct_at_address_nr(writer->wd, GS(id->name), struct_id, 1, id_address, id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int BLO_get_struct_id_by_name(BlendWriter *writer, const char *struct_name)
|
|
|
|
|
{
|
|
|
|
|
int struct_id = DNA_struct_find_nr(writer->wd->sdna, struct_name);
|
|
|
|
|
return struct_id;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-20 18:41:50 +02:00
|
|
|
void BLO_write_int32_array(BlendWriter *writer, uint num, const int32_t *data_ptr)
|
2020-06-05 11:44:36 +02:00
|
|
|
{
|
2020-09-20 18:41:50 +02:00
|
|
|
BLO_write_raw(writer, sizeof(int32_t) * (size_t)num, data_ptr);
|
2020-06-05 11:44:36 +02:00
|
|
|
}
|
|
|
|
|
|
2020-09-20 18:41:50 +02:00
|
|
|
void BLO_write_uint32_array(BlendWriter *writer, uint num, const uint32_t *data_ptr)
|
2020-06-05 11:44:36 +02:00
|
|
|
{
|
2020-09-20 18:41:50 +02:00
|
|
|
BLO_write_raw(writer, sizeof(uint32_t) * (size_t)num, data_ptr);
|
2020-06-05 11:44:36 +02:00
|
|
|
}
|
|
|
|
|
|
2020-09-20 18:41:50 +02:00
|
|
|
void BLO_write_float_array(BlendWriter *writer, uint num, const float *data_ptr)
|
2020-06-05 11:44:36 +02:00
|
|
|
{
|
2020-09-20 18:41:50 +02:00
|
|
|
BLO_write_raw(writer, sizeof(float) * (size_t)num, data_ptr);
|
2020-06-05 11:44:36 +02:00
|
|
|
}
|
|
|
|
|
|
2020-09-20 18:41:50 +02:00
|
|
|
void BLO_write_pointer_array(BlendWriter *writer, uint num, const void *data_ptr)
|
2020-06-05 13:29:46 +02:00
|
|
|
{
|
2020-09-20 18:41:50 +02:00
|
|
|
BLO_write_raw(writer, sizeof(void *) * (size_t)num, data_ptr);
|
2020-06-05 13:29:46 +02:00
|
|
|
}
|
|
|
|
|
|
2020-09-20 18:41:50 +02:00
|
|
|
void BLO_write_float3_array(BlendWriter *writer, uint num, const float *data_ptr)
|
2020-06-05 11:44:36 +02:00
|
|
|
{
|
2020-09-20 18:41:50 +02:00
|
|
|
BLO_write_raw(writer, sizeof(float[3]) * (size_t)num, data_ptr);
|
2020-06-05 11:44:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Write a null terminated string.
|
|
|
|
|
*/
|
2020-09-20 18:41:50 +02:00
|
|
|
void BLO_write_string(BlendWriter *writer, const char *data_ptr)
|
2020-06-05 11:44:36 +02:00
|
|
|
{
|
2020-09-20 18:41:50 +02:00
|
|
|
if (data_ptr != NULL) {
|
|
|
|
|
BLO_write_raw(writer, strlen(data_ptr) + 1, data_ptr);
|
2020-06-05 11:44:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sometimes different data is written depending on whether the file is saved to disk or used for
|
|
|
|
|
* undo. This function returns true when the current file-writing is done for undo.
|
|
|
|
|
*/
|
|
|
|
|
bool BLO_write_is_undo(BlendWriter *writer)
|
|
|
|
|
{
|
|
|
|
|
return writer->wd->use_memfile;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-14 13:17:11 +02:00
|
|
|
/** \} */
|