2008-01-01 15:53:38 +00:00
|
|
|
/*
|
2007-12-24 18:53:37 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
2007-12-24 18:53:37 +00:00
|
|
|
* Contributor(s): Blender Foundation
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-27 20:35:41 +00:00
|
|
|
/** \file blender/blenloader/intern/writefile.c
|
|
|
|
* \ingroup blenloader
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2016-06-27 11:21:03 +10:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* FILE FORMAT
|
|
|
|
* ===========
|
|
|
|
*
|
|
|
|
* IFF-style structure (but not IFF compatible!)
|
2012-10-04 13:26:15 +00:00
|
|
|
*
|
|
|
|
* start file:
|
2016-06-27 11:21:03 +10:00
|
|
|
* <pre>
|
2012-10-04 13:26:15 +00:00
|
|
|
* BLENDER_V100 12 bytes (versie 1.00)
|
|
|
|
* 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
|
|
|
*
|
2016-06-27 11:21:03 +10:00
|
|
|
* datablocks: (also see struct #BHead).
|
|
|
|
* <pre>
|
2012-10-04 13:26:15 +00:00
|
|
|
* <bh.code> 4 chars
|
|
|
|
* <bh.len> int, len data after BHead
|
|
|
|
* <bh.old> void, old pointer
|
|
|
|
* <bh.SDNAnr> int
|
|
|
|
* <bh.nr> int, in case of array: amount 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
|
|
|
|
* and compared with StructDNA .
|
|
|
|
*
|
2016-06-27 11:21:03 +10:00
|
|
|
*
|
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?)
|
|
|
|
* Any case: direct data is ALWAYS after the lib block
|
|
|
|
*
|
|
|
|
* (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)
|
|
|
|
* - write #USER (#UserDef struct) if filename is ``~/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 <math.h>
|
|
|
|
#include <fcntl.h>
|
2013-03-18 16:34:57 +00:00
|
|
|
#include <limits.h>
|
2009-09-06 13:20:05 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2014-04-02 11:43:54 +02:00
|
|
|
#ifdef WIN32
|
2014-11-29 19:12:33 +01:00
|
|
|
# include <zlib.h> /* odd include order-issue */
|
2012-04-15 07:54:07 +00:00
|
|
|
# include "winsock2.h"
|
|
|
|
# include <io.h>
|
|
|
|
# include "BLI_winstuff.h"
|
2014-04-03 09:20:04 +02:00
|
|
|
#else
|
|
|
|
# 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"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_actuator_types.h"
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
#include "DNA_brush_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_camera_types.h"
|
2008-01-29 21:01:12 +00:00
|
|
|
#include "DNA_cloth_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"
|
|
|
|
#include "DNA_controller_types.h"
|
2011-05-24 07:08:58 +00:00
|
|
|
#include "DNA_dynamicpaint_types.h"
|
2008-10-31 23:50:02 +00:00
|
|
|
#include "DNA_genfile.h"
|
2005-05-02 13:28:13 +00:00
|
|
|
#include "DNA_group_types.h"
|
2008-07-22 09:53:25 +00:00
|
|
|
#include "DNA_gpencil_types.h"
|
2005-05-02 13:28:13 +00:00
|
|
|
#include "DNA_fileglobal_types.h"
|
|
|
|
#include "DNA_key_types.h"
|
|
|
|
#include "DNA_lattice_types.h"
|
|
|
|
#include "DNA_lamp_types.h"
|
2013-03-23 03:00:37 +00:00
|
|
|
#include "DNA_linestyle_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_meta_types.h"
|
|
|
|
#include "DNA_mesh_types.h"
|
2004-03-20 22:55:42 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_material_types.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 "DNA_node_types.h"
|
2005-05-02 13:28:13 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_object_force.h"
|
|
|
|
#include "DNA_packedFile_types.h"
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
#include "DNA_particle_types.h"
|
2005-05-02 13:28:13 +00:00
|
|
|
#include "DNA_property_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"
|
|
|
|
#include "DNA_sdna_types.h"
|
|
|
|
#include "DNA_sequence_types.h"
|
|
|
|
#include "DNA_sensor_types.h"
|
2009-07-30 15:00:26 +00:00
|
|
|
#include "DNA_smoke_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_space_types.h"
|
|
|
|
#include "DNA_screen_types.h"
|
2011-08-01 11:44:20 +00:00
|
|
|
#include "DNA_speaker_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_sound_types.h"
|
|
|
|
#include "DNA_text_types.h"
|
2005-05-02 13:28:13 +00:00
|
|
|
#include "DNA_view3d_types.h"
|
|
|
|
#include "DNA_vfont_types.h"
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
#include "DNA_world_types.h"
|
2007-12-24 18:53:37 +00:00
|
|
|
#include "DNA_windowmanager_types.h"
|
2011-11-07 12:55:18 +00:00
|
|
|
#include "DNA_movieclip_types.h"
|
2012-06-04 16:42:58 +00:00
|
|
|
#include "DNA_mask_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-06-23 18:22:51 +00:00
|
|
|
#include "MEM_guardedalloc.h" // MEM_freeN
|
2012-03-14 06:31:38 +00:00
|
|
|
#include "BLI_bitmap.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_linklist.h"
|
2013-08-03 11:35:09 +00:00
|
|
|
#include "BLI_mempool.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include "BKE_action.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"
|
Biiig commit! Thanks to 2-3 weeks of cvs freeze...
Render:
- New; support for dual CPU render (SDL thread)
Currently only works with alternating scanlines, but gives excellent
performance. For both normal render as unified implemented.
Note the "mutex" locks on z-transp buffer render and imbuf loads.
- This has been made possible by major cleanups in render code, especially
getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct
OSA or using Materials or Texture data to write to.
- Made normal render fully 4x32 floats too, and removed all old optimizes
with chars or shorts.
- Made normal render and unified render use same code for sky and halo
render, giving equal (and better) results for halo render. Old render
now also uses PostProcess options (brightness, mul, gamma)
- Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer
after render. Using PostProcess menu you will note an immediate re-
display of image too (32 bits RGBA)
- Added "Hue" and "Saturation" sliders to PostProcess options
- Render module is still not having a "nice" API, but amount of dependencies
went down a lot. Next todo: remove abusive "previewrender" code.
The last main global in Render (struct Render) now can be re-used for fully
controlling a render, to allow multiple "instances" of render to open.
- Renderwindow now displays a smal bar on top with the stats, and keeps the
stats after render too. Including "spare" page support.
Not only easier visible that way, but also to remove the awkward code that
was drawing stats in the Info header (extreme slow on some ATIs too)
- Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping
defines.
- I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
|
|
|
#include "BKE_curve.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_constraint.h"
|
|
|
|
#include "BKE_global.h" // for G
|
2015-11-13 15:34:07 +01:00
|
|
|
#include "BKE_idcode.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_library.h" // for set_listbasepointers
|
2008-12-19 16:36:15 +00:00
|
|
|
#include "BKE_main.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"
|
2008-12-19 00:50:21 +00:00
|
|
|
#include "BKE_report.h"
|
2009-12-13 14:56:45 +00:00
|
|
|
#include "BKE_sequencer.h"
|
2012-05-10 20:33:24 +00:00
|
|
|
#include "BKE_subsurf.h"
|
2005-07-19 20:14:17 +00:00
|
|
|
#include "BKE_modifier.h"
|
2009-01-18 10:41:45 +00:00
|
|
|
#include "BKE_fcurve.h"
|
2010-12-16 16:09:23 +00:00
|
|
|
#include "BKE_pointcache.h"
|
2011-12-27 08:39:55 +00:00
|
|
|
#include "BKE_mesh.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
#ifdef USE_NODE_COMPAT_CUSTOMNODES
|
2016-06-28 17:35:35 +10:00
|
|
|
#include "NOD_socket.h" /* for sock->default_value data */
|
2013-03-18 16:34:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BLO_writefile.h"
|
|
|
|
#include "BLO_readfile.h"
|
2004-09-05 13:43:51 +00:00
|
|
|
#include "BLO_undofile.h"
|
2012-09-03 10:12:25 +00:00
|
|
|
#include "BLO_blend_defs.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include "readfile.h"
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
/* for SDNA_TYPE_FROM_STRUCT() macro */
|
|
|
|
#include "dna_type_offsets.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
|
|
|
|
2008-03-05 15:13:41 +00:00
|
|
|
/* ********* my write, buffered writing with minimum size chunks ************ */
|
|
|
|
|
|
|
|
#define MYWRITE_BUFFER_SIZE 100000
|
|
|
|
#define MYWRITE_MAX_CHUNK 32768
|
2004-09-05 13:43:51 +00:00
|
|
|
|
2014-09-04 21:48:36 +10:00
|
|
|
|
|
|
|
|
|
|
|
/** \name Small API to handle compression.
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
WW_WRAP_NONE = 1,
|
|
|
|
WW_WRAP_ZLIB,
|
|
|
|
} eWriteWrapType;
|
|
|
|
|
|
|
|
typedef struct WriteWrap WriteWrap;
|
|
|
|
struct WriteWrap {
|
|
|
|
/* callbacks */
|
|
|
|
bool (*open)(WriteWrap *ww, const char *filepath);
|
|
|
|
bool (*close)(WriteWrap *ww);
|
|
|
|
size_t (*write)(WriteWrap *ww, const char *data, size_t data_len);
|
|
|
|
|
|
|
|
/* internal */
|
|
|
|
union {
|
|
|
|
int file_handle;
|
|
|
|
gzFile gz_handle;
|
|
|
|
} _user_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* none */
|
|
|
|
#define FILE_HANDLE(ww) \
|
|
|
|
(ww)->_user_data.file_handle
|
|
|
|
|
|
|
|
static bool ww_open_none(WriteWrap *ww, const char *filepath)
|
|
|
|
{
|
|
|
|
int file;
|
|
|
|
|
|
|
|
file = BLI_open(filepath, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666);
|
|
|
|
|
|
|
|
if (file != -1) {
|
|
|
|
FILE_HANDLE(ww) = file;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static bool ww_close_none(WriteWrap *ww)
|
|
|
|
{
|
|
|
|
return (close(FILE_HANDLE(ww)) != -1);
|
|
|
|
}
|
|
|
|
static size_t ww_write_none(WriteWrap *ww, const char *buf, size_t buf_len)
|
|
|
|
{
|
|
|
|
return write(FILE_HANDLE(ww), buf, buf_len);
|
|
|
|
}
|
|
|
|
#undef FILE_HANDLE
|
|
|
|
|
|
|
|
/* zlib */
|
|
|
|
#define FILE_HANDLE(ww) \
|
|
|
|
(ww)->_user_data.gz_handle
|
|
|
|
|
|
|
|
static bool ww_open_zlib(WriteWrap *ww, const char *filepath)
|
|
|
|
{
|
|
|
|
gzFile file;
|
|
|
|
|
|
|
|
file = BLI_gzopen(filepath, "wb1");
|
|
|
|
|
|
|
|
if (file != Z_NULL) {
|
|
|
|
FILE_HANDLE(ww) = file;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static bool ww_close_zlib(WriteWrap *ww)
|
|
|
|
{
|
|
|
|
return (gzclose(FILE_HANDLE(ww)) == Z_OK);
|
|
|
|
}
|
|
|
|
static size_t ww_write_zlib(WriteWrap *ww, const char *buf, size_t buf_len)
|
|
|
|
{
|
|
|
|
return gzwrite(FILE_HANDLE(ww), buf, buf_len);
|
|
|
|
}
|
|
|
|
#undef FILE_HANDLE
|
|
|
|
|
|
|
|
/* --- end compression types --- */
|
|
|
|
|
|
|
|
static void ww_handle_init(eWriteWrapType ww_type, WriteWrap *r_ww)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
r_ww->open = ww_open_none;
|
|
|
|
r_ww->close = ww_close_none;
|
|
|
|
r_ww->write = ww_write_none;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
typedef struct {
|
|
|
|
struct SDNA *sdna;
|
|
|
|
|
|
|
|
unsigned char *buf;
|
2004-09-05 13:43:51 +00:00
|
|
|
MemFile *compare, *current;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2016-06-28 21:00:00 +10:00
|
|
|
int tot, count;
|
|
|
|
bool error;
|
2011-12-27 13:17:58 +00:00
|
|
|
|
2014-09-04 21:48:36 +10:00
|
|
|
/* Wrap writing, so we can use zlib or
|
|
|
|
* other compression types later, see: G_FILE_COMPRESS
|
|
|
|
* Will be NULL for UNDO. */
|
|
|
|
WriteWrap *ww;
|
|
|
|
|
2011-12-28 13:50:33 +00:00
|
|
|
#ifdef USE_BMESH_SAVE_AS_COMPAT
|
2016-06-28 21:00:00 +10:00
|
|
|
bool use_mesh_compat; /* option to save with older mesh format */
|
2011-12-27 13:17:58 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
} WriteData;
|
|
|
|
|
2014-09-04 21:48:36 +10:00
|
|
|
static WriteData *writedata_new(WriteWrap *ww)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
WriteData *wd = MEM_callocN(sizeof(*wd), "writedata");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-02-22 13:35:32 +00:00
|
|
|
wd->sdna = DNA_sdna_from_data(DNAstr, DNAlen, false);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2014-09-04 21:48:36 +10:00
|
|
|
wd->ww = ww;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
wd->buf = MEM_mallocN(MYWRITE_BUFFER_SIZE, "wd->buf");
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return wd;
|
|
|
|
}
|
|
|
|
|
2012-04-17 19:51:40 +00:00
|
|
|
static void writedata_do_write(WriteData *wd, const void *mem, int memlen)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
if ((wd == NULL) || wd->error || (mem == NULL) || memlen < 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UNLIKELY(wd->error)) {
|
|
|
|
return;
|
|
|
|
}
|
2004-09-05 13:43:51 +00:00
|
|
|
|
|
|
|
/* memory based save */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (wd->current) {
|
2015-04-18 17:33:04 +02:00
|
|
|
memfile_chunk_add(NULL, wd->current, mem, memlen);
|
2004-09-05 13:43:51 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-09-04 21:48:36 +10:00
|
|
|
if (wd->ww->write(wd->ww, mem, memlen) != memlen) {
|
2016-06-28 21:00:00 +10:00
|
|
|
wd->error = true;
|
2014-09-04 21:48:36 +10:00
|
|
|
}
|
2004-09-05 13:43:51 +00:00
|
|
|
}
|
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
|
|
|
{
|
2008-10-31 23:50:02 +00:00
|
|
|
DNA_sdna_free(wd->sdna);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
MEM_freeN(wd->buf);
|
|
|
|
MEM_freeN(wd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Low level WRITE(2) wrapper that buffers data
|
2012-03-02 16:05:54 +00:00
|
|
|
* \param adr Pointer to new chunk of data
|
|
|
|
* \param len Length of new chunk of data
|
|
|
|
* \warning Talks to other functions with global parameters
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2016-06-28 20:05:42 +10:00
|
|
|
|
2008-03-05 15:13:41 +00:00
|
|
|
#define MYWRITE_FLUSH NULL
|
2004-09-05 13:43:51 +00:00
|
|
|
|
2012-04-29 17:11:40 +00:00
|
|
|
static void mywrite(WriteData *wd, const void *adr, int len)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
if (UNLIKELY(wd->error)) {
|
|
|
|
return;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-03-05 15:13:41 +00:00
|
|
|
/* flush helps compression for undo-save */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (adr == MYWRITE_FLUSH) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (wd->count) {
|
2004-09-05 13:43:51 +00:00
|
|
|
writedata_do_write(wd, wd->buf, wd->count);
|
2016-06-28 17:35:35 +10:00
|
|
|
wd->count = 0;
|
2004-09-05 13:43:51 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
wd->tot += len;
|
|
|
|
|
2008-03-05 15:13:41 +00:00
|
|
|
/* if we have a single big chunk, write existing data in
|
|
|
|
* buffer and write out big chunk in smaller pieces */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (len > MYWRITE_MAX_CHUNK) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (wd->count) {
|
2002-10-12 11:37:38 +00:00
|
|
|
writedata_do_write(wd, wd->buf, wd->count);
|
2016-06-28 17:35:35 +10:00
|
|
|
wd->count = 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-03-05 15:13:41 +00:00
|
|
|
|
|
|
|
do {
|
2016-06-28 17:35:35 +10:00
|
|
|
int writelen = MIN2(len, MYWRITE_MAX_CHUNK);
|
2008-03-05 15:13:41 +00:00
|
|
|
writedata_do_write(wd, adr, writelen);
|
2012-04-17 19:51:40 +00:00
|
|
|
adr = (const char *)adr + writelen;
|
2008-03-05 15:13:41 +00:00
|
|
|
len -= writelen;
|
2012-03-24 07:52:14 +00:00
|
|
|
} while (len > 0);
|
2008-03-05 15:13:41 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-03-05 15:13:41 +00:00
|
|
|
|
|
|
|
/* if data would overflow buffer, write out the buffer */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (len + wd->count > MYWRITE_BUFFER_SIZE - 1) {
|
2002-10-12 11:37:38 +00:00
|
|
|
writedata_do_write(wd, wd->buf, wd->count);
|
2016-06-28 17:35:35 +10:00
|
|
|
wd->count = 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-03-05 15:13:41 +00:00
|
|
|
|
|
|
|
/* append data at end of buffer */
|
2002-10-12 11:37:38 +00:00
|
|
|
memcpy(&wd->buf[wd->count], adr, len);
|
2016-06-28 17:35:35 +10:00
|
|
|
wd->count += 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.
|
2012-03-02 16:05:54 +00:00
|
|
|
* \param compare Previous memory file (can be NULL).
|
|
|
|
* \param current The current memory file (can be NULL).
|
|
|
|
* \warning Talks to other functions with global parameters
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2014-09-04 21:48:36 +10:00
|
|
|
static WriteData *bgnwrite(WriteWrap *ww, MemFile *compare, MemFile *current)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
WriteData *wd = writedata_new(ww);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (wd == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-10-27 18:24:10 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
wd->compare = compare;
|
|
|
|
wd->current = current;
|
2004-09-05 13:43:51 +00:00
|
|
|
/* this inits comparing */
|
2015-04-18 17:33:04 +02:00
|
|
|
memfile_chunk_add(compare, NULL, NULL, 0);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return wd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*/
|
2016-06-28 21:00:00 +10:00
|
|
|
static bool endwrite(WriteData *wd)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
if (wd->count) {
|
|
|
|
writedata_do_write(wd, wd->buf, wd->count);
|
2016-06-28 17:35:35 +10:00
|
|
|
wd->count = 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2016-06-28 21:00:00 +10:00
|
|
|
const bool err = wd->error;
|
2002-10-12 11:37:38 +00:00
|
|
|
writedata_free(wd);
|
2007-02-14 11:00:05 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ********** WRITE FILE ****************** */
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
static void writestruct_at_address_nr(
|
|
|
|
WriteData *wd, int filecode, const int struct_nr, int nr,
|
2016-06-22 08:44:26 +10:00
|
|
|
const void *adr, const void *data)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
BHead bh;
|
2014-04-27 00:24:11 +10:00
|
|
|
const short *sp;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
BLI_assert(struct_nr > 0 && struct_nr < SDNA_TYPE_MAX);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (adr == NULL || data == NULL || nr == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* init BHead */
|
2016-06-28 17:35:35 +10:00
|
|
|
bh.code = filecode;
|
|
|
|
bh.old = adr;
|
|
|
|
bh.nr = nr;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
bh.SDNAnr = struct_nr;
|
2016-06-28 17:35:35 +10:00
|
|
|
sp = wd->sdna->structs[bh.SDNAnr];
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
bh.len = nr * wd->sdna->typelens[sp[0]];
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (bh.len == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
mywrite(wd, &bh, sizeof(BHead));
|
2013-04-12 15:33:09 +00:00
|
|
|
mywrite(wd, data, bh.len);
|
|
|
|
}
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
static void writestruct_at_address_id(
|
|
|
|
WriteData *wd, int filecode, const char *structname, int nr,
|
|
|
|
const void *adr, const void *data)
|
|
|
|
{
|
|
|
|
if (adr == NULL || data == NULL || nr == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int SDNAnr = DNA_struct_find_nr(wd->sdna, structname);
|
|
|
|
if (UNLIKELY(SDNAnr == -1)) {
|
|
|
|
printf("error: can't find SDNA code <%s>\n", structname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
writestruct_at_address_nr(wd, filecode, SDNAnr, nr, adr, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void writestruct_nr(
|
|
|
|
WriteData *wd, int filecode, const int struct_nr, int nr,
|
|
|
|
const void *adr)
|
|
|
|
{
|
|
|
|
writestruct_at_address_nr(wd, filecode, struct_nr, nr, adr, adr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void writestruct_id(
|
2016-06-22 08:44:26 +10:00
|
|
|
WriteData *wd, int filecode, const char *structname, int nr,
|
|
|
|
const void *adr)
|
2013-04-12 15:33:09 +00:00
|
|
|
{
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_at_address_id(wd, filecode, structname, nr, adr, adr);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2012-04-17 19:51:40 +00:00
|
|
|
static void writedata(WriteData *wd, int filecode, int len, const void *adr) /* do not use for structs */
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
BHead bh;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (adr == NULL || len == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2013-05-08 13:00:06 +00:00
|
|
|
/* align to 4 (writes uninitialized bytes in some cases) */
|
|
|
|
len = (len + 3) & ~3;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* init BHead */
|
2012-04-17 19:51:40 +00:00
|
|
|
bh.code = filecode;
|
2016-06-22 08:44:26 +10:00
|
|
|
bh.old = adr;
|
2012-04-17 19:51:40 +00:00
|
|
|
bh.nr = 1;
|
|
|
|
bh.SDNAnr = 0;
|
|
|
|
bh.len = len;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
mywrite(wd, &bh, sizeof(BHead));
|
2013-05-08 13:00:06 +00:00
|
|
|
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
|
|
|
{
|
2016-06-22 08:44:26 +10:00
|
|
|
const Link *link = lb->first;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2013-03-07 16:57:53 +00:00
|
|
|
while (link) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_nr(wd, filecode, struct_nr, 1, link);
|
2013-03-07 16:57:53 +00:00
|
|
|
link = link->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
#if 0
|
|
|
|
static void writelist_id(WriteData *wd, int filecode, const char *structname, const ListBase *lb)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define writestruct_at_address(wd, filecode, struct_id, nr, adr, data) \
|
|
|
|
writestruct_at_address_nr(wd, filecode, SDNA_TYPE_FROM_STRUCT(struct_id), nr, adr, data)
|
|
|
|
|
|
|
|
#define writestruct(wd, filecode, struct_id, nr, adr) \
|
|
|
|
writestruct_nr(wd, filecode, SDNA_TYPE_FROM_STRUCT(struct_id), nr, adr)
|
|
|
|
|
|
|
|
#define writelist(wd, filecode, struct_id, lb) \
|
|
|
|
writelist_nr(wd, filecode, SDNA_TYPE_FROM_STRUCT(struct_id), lb)
|
|
|
|
|
Orange:
- New UI element: the "Curve Button".
For mapping ranges (like 0 - 1) to another range, the curve button can be
used for proportional falloff, bone influences, painting density, etc.
Most evident use is of course to map RGB color with curves.
To be able to use it, you have to allocate a CurveMapping struct and pass
this on to the button. The CurveMapping API is in the new C file
blenkernel/intern/colortools.c
It's as simple as calling:
curvemap= curvemapping_add(3, 0, 0, 1, 1)
Which will create 3 curves, and sets a default 0-1 range. The current code
only supports up to 4 curves maximum per mapping struct.
The CurveMap button in Blender than handles allmost all editing.
Evaluating a single channel:
float newvalue= curvemapping_evaluateF(curvemap, 0, oldval);
Where the second argument is the channel index, here 0-1-2 are possible.
Or mapping a vector:
curvemapping_evaluate3F(curvemap, newvec, oldvec);
Optimized versions for byte or short mapping is possible too, not done yet.
In butspace.c I've added a template wrapper for buttons around the curve, to
reveil settings or show tools; check this screenie:
http://www.blender.org/bf/curves.jpg
- Buttons R, G, B: select channel
- icons + and -: zoom in, out
- icon 'wrench': menu with tools, like clear curve, set handle type
- icon 'clipping': menu with clip values, and to dis/enable clipping
- icon 'x': delete selection
In the curve button itself, only LMB clicks are handled (like all UI elements
in Blender).
- click on point: select
- shift+click on point: swap select
- click on point + drag: select point (if not selected) and move it
- click outside point + drag: translate view
- CTRL+click: add new point
- hold SHIFT while dragging to snap to grid
(Yes I know... either one of these can be Blender compliant, not both!)
- if you drag a point exactly on top of another, it merges them
Other fixes:
- Icons now draw using "Safe RasterPos", so they align with pixel boundary.
the old code made ints from the raster pos coordinate, which doesn't work
well for zoom in/out situations
- bug in Node editing: buttons could not get freed, causing in memory error
prints at end of a Blender session. That one was a very simple, but nasty
error causing me all evening last night to find!
(Hint; check diff of editnode.c, where uiDoButtons is called)
Last note: this adds 3 new files in our tree, I did scons, but not MSVC!
2006-01-08 11:41:06 +00:00
|
|
|
/* *************** writing some direct data structs used in more code parts **************** */
|
2006-11-17 04:46:48 +00:00
|
|
|
/*These functions are used by blender's .blend system for file saving/loading.*/
|
2016-06-22 08:44:26 +10:00
|
|
|
void IDP_WriteProperty_OnlyData(const IDProperty *prop, void *wd);
|
|
|
|
void IDP_WriteProperty(const IDProperty *prop, void *wd);
|
2006-11-17 04:46:48 +00:00
|
|
|
|
2016-06-22 08:44:26 +10:00
|
|
|
static void IDP_WriteArray(const IDProperty *prop, void *wd)
|
2006-11-17 04:46:48 +00:00
|
|
|
{
|
|
|
|
/*REMEMBER to set totalen to len in the linking code!!*/
|
|
|
|
if (prop->data.pointer) {
|
|
|
|
writedata(wd, DATA, MEM_allocN_len(prop->data.pointer), prop->data.pointer);
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 20:38:52 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (prop->subtype == IDP_GROUP) {
|
2016-06-28 17:35:35 +10:00
|
|
|
IDProperty **array = prop->data.pointer;
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 20:38:52 +00:00
|
|
|
int a;
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (a = 0; a < prop->len; a++) {
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 20:38:52 +00:00
|
|
|
IDP_WriteProperty(array[a], wd);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
2008-12-26 20:38:52 +00:00
|
|
|
}
|
2006-11-17 04:46:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-22 08:44:26 +10:00
|
|
|
static void IDP_WriteIDPArray(const IDProperty *prop, void *wd)
|
2008-12-31 13:16:37 +00:00
|
|
|
{
|
|
|
|
/*REMEMBER to set totalen to len in the linking code!!*/
|
|
|
|
if (prop->data.pointer) {
|
2016-06-22 08:44:26 +10:00
|
|
|
const IDProperty *array = prop->data.pointer;
|
2008-12-31 13:16:37 +00:00
|
|
|
int a;
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, IDProperty, prop->len, array);
|
2008-12-31 13:16:37 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (a = 0; a < prop->len; a++) {
|
2.5: RNA, defining enums, pointers and collections properties is now
possible from python, but it's still work in progress.
Pointers and collections are restricted to types derived from
IDPropertyGroup (same as for operators), because RNA knows how to
allocate/deallocate those.
Collections have .add() and .remove(number) functions that can be
used. The remove function should be fixed to take an other argument
than a number.
With the IDPropertyGroup restriction, pointers are more like nested
structs. They don't have add(), remove() yet, not sure where to put
them. Currently the pointer / nested struct is automatically allocated
in the get() function, this needs to be fixed, rule is that RNA get()
will not change any data for thread safety.
Also, it is only possible to add properties to structs after they have
been registered, which needs to be improved as well.
Example code:
http://www.pasteall.org/7201/python
2009-08-18 01:29:25 +00:00
|
|
|
IDP_WriteProperty_OnlyData(&array[a], wd);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2008-12-31 13:16:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-22 08:44:26 +10:00
|
|
|
static void IDP_WriteString(const IDProperty *prop, void *wd)
|
2006-11-17 04:46:48 +00:00
|
|
|
{
|
|
|
|
/*REMEMBER to set totalen to len in the linking code!!*/
|
2014-02-15 12:27:23 +11:00
|
|
|
writedata(wd, DATA, prop->len, prop->data.pointer);
|
2006-11-17 04:46:48 +00:00
|
|
|
}
|
|
|
|
|
2016-06-22 08:44:26 +10:00
|
|
|
static void IDP_WriteGroup(const IDProperty *prop, void *wd)
|
2006-11-17 04:46:48 +00:00
|
|
|
{
|
|
|
|
IDProperty *loop;
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (loop = prop->data.group.first; loop; loop = loop->next) {
|
2006-11-17 04:46:48 +00:00
|
|
|
IDP_WriteProperty(loop, wd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Functions to read/write ID Properties */
|
2016-06-22 08:44:26 +10:00
|
|
|
void IDP_WriteProperty_OnlyData(const IDProperty *prop, void *wd)
|
2006-11-17 04:46:48 +00:00
|
|
|
{
|
|
|
|
switch (prop->type) {
|
|
|
|
case IDP_GROUP:
|
|
|
|
IDP_WriteGroup(prop, wd);
|
|
|
|
break;
|
|
|
|
case IDP_STRING:
|
|
|
|
IDP_WriteString(prop, wd);
|
|
|
|
break;
|
|
|
|
case IDP_ARRAY:
|
|
|
|
IDP_WriteArray(prop, wd);
|
|
|
|
break;
|
2008-12-31 13:16:37 +00:00
|
|
|
case IDP_IDPARRAY:
|
|
|
|
IDP_WriteIDPArray(prop, wd);
|
|
|
|
break;
|
2006-11-17 04:46:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-22 08:44:26 +10:00
|
|
|
void IDP_WriteProperty(const IDProperty *prop, void *wd)
|
2006-11-17 04:46:48 +00:00
|
|
|
{
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, IDProperty, 1, prop);
|
2006-11-17 04:46:48 +00:00
|
|
|
IDP_WriteProperty_OnlyData(prop, wd);
|
|
|
|
}
|
Orange:
- New UI element: the "Curve Button".
For mapping ranges (like 0 - 1) to another range, the curve button can be
used for proportional falloff, bone influences, painting density, etc.
Most evident use is of course to map RGB color with curves.
To be able to use it, you have to allocate a CurveMapping struct and pass
this on to the button. The CurveMapping API is in the new C file
blenkernel/intern/colortools.c
It's as simple as calling:
curvemap= curvemapping_add(3, 0, 0, 1, 1)
Which will create 3 curves, and sets a default 0-1 range. The current code
only supports up to 4 curves maximum per mapping struct.
The CurveMap button in Blender than handles allmost all editing.
Evaluating a single channel:
float newvalue= curvemapping_evaluateF(curvemap, 0, oldval);
Where the second argument is the channel index, here 0-1-2 are possible.
Or mapping a vector:
curvemapping_evaluate3F(curvemap, newvec, oldvec);
Optimized versions for byte or short mapping is possible too, not done yet.
In butspace.c I've added a template wrapper for buttons around the curve, to
reveil settings or show tools; check this screenie:
http://www.blender.org/bf/curves.jpg
- Buttons R, G, B: select channel
- icons + and -: zoom in, out
- icon 'wrench': menu with tools, like clear curve, set handle type
- icon 'clipping': menu with clip values, and to dis/enable clipping
- icon 'x': delete selection
In the curve button itself, only LMB clicks are handled (like all UI elements
in Blender).
- click on point: select
- shift+click on point: swap select
- click on point + drag: select point (if not selected) and move it
- click outside point + drag: translate view
- CTRL+click: add new point
- hold SHIFT while dragging to snap to grid
(Yes I know... either one of these can be Blender compliant, not both!)
- if you drag a point exactly on top of another, it merges them
Other fixes:
- Icons now draw using "Safe RasterPos", so they align with pixel boundary.
the old code made ints from the raster pos coordinate, which doesn't work
well for zoom in/out situations
- bug in Node editing: buttons could not get freed, causing in memory error
prints at end of a Blender session. That one was a very simple, but nasty
error causing me all evening last night to find!
(Hint; check diff of editnode.c, where uiDoButtons is called)
Last note: this adds 3 new files in our tree, I did scons, but not MSVC!
2006-01-08 11:41:06 +00:00
|
|
|
|
2016-06-22 08:44:26 +10:00
|
|
|
static void write_iddata(void *wd, const ID *id)
|
2016-06-14 14:53:39 +02:00
|
|
|
{
|
|
|
|
/* ID_WM's id->properties are considered runtime only, and never written in .blend file. */
|
|
|
|
if (id->properties && !ELEM(GS(id->name), ID_WM)) {
|
|
|
|
IDP_WriteProperty(id->properties, wd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-22 08:44:26 +10:00
|
|
|
static void write_previews(WriteData *wd, const PreviewImage *prv_orig)
|
2015-08-10 15:41:28 +02:00
|
|
|
{
|
|
|
|
/* Never write previews when doing memsave (i.e. undo/redo)! */
|
2016-06-22 08:44:26 +10:00
|
|
|
if (prv_orig && !wd->current) {
|
|
|
|
PreviewImage prv = *prv_orig;
|
2015-08-10 15:41:28 +02:00
|
|
|
|
|
|
|
/* don't write out large previews if not requested */
|
|
|
|
if (!(U.flag & USER_SAVE_PREVIEWS)) {
|
2016-06-22 08:44:26 +10:00
|
|
|
prv.w[1] = 0;
|
|
|
|
prv.h[1] = 0;
|
|
|
|
prv.rect[1] = NULL;
|
2015-08-10 15:41:28 +02:00
|
|
|
}
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_at_address(wd, DATA, PreviewImage, 1, prv_orig, &prv);
|
2016-06-22 08:44:26 +10:00
|
|
|
if (prv.rect[0]) {
|
|
|
|
writedata(wd, DATA, prv.w[0] * prv.h[0] * sizeof(unsigned int), prv.rect[0]);
|
|
|
|
}
|
|
|
|
if (prv.rect[1]) {
|
|
|
|
writedata(wd, DATA, prv.w[1] * prv.h[1] * sizeof(unsigned int), prv.rect[1]);
|
2015-08-10 15:41:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
static void write_fmodifiers(WriteData *wd, ListBase *fmodifiers)
|
|
|
|
{
|
|
|
|
FModifier *fcm;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2013-03-08 10:59:43 +00:00
|
|
|
/* Write all modifiers first (for faster reloading) */
|
2016-06-28 20:05:42 +10:00
|
|
|
writelist(wd, DATA, FModifier, fmodifiers);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* Modifiers */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (fcm = fmodifiers->first; fcm; fcm = fcm->next) {
|
|
|
|
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
|
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* Write the specific data */
|
|
|
|
if (fmi && fcm->data) {
|
|
|
|
/* firstly, just write the plain fmi->data struct */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_id(wd, DATA, fmi->structName, 1, fcm->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* do any modifier specific stuff */
|
|
|
|
switch (fcm->type) {
|
|
|
|
case FMODIFIER_TYPE_GENERATOR:
|
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
FMod_Generator *data = fcm->data;
|
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* write coefficients array */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (data->coefficients) {
|
|
|
|
writedata(wd, DATA, sizeof(float) * (data->arraysize), data->coefficients);
|
|
|
|
}
|
2015-07-18 19:02:39 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
break;
|
2015-07-18 19:02:39 +10:00
|
|
|
}
|
2010-12-13 08:08:09 +00:00
|
|
|
case FMODIFIER_TYPE_ENVELOPE:
|
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
FMod_Envelope *data = fcm->data;
|
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* write envelope data */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (data->data) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, FCM_EnvelopeData, data->totvert, data->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2015-07-18 19:02:39 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
break;
|
2015-07-18 19:02:39 +10:00
|
|
|
}
|
2010-12-13 08:08:09 +00:00
|
|
|
case FMODIFIER_TYPE_PYTHON:
|
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
FMod_Python *data = fcm->data;
|
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
|
2012-04-22 11:54:53 +00:00
|
|
|
* of library blocks that implement this.*/
|
2010-12-13 08:08:09 +00:00
|
|
|
IDP_WriteProperty(data->prop, wd);
|
2015-07-18 19:02:39 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
break;
|
2015-07-18 19:02:39 +10:00
|
|
|
}
|
2010-12-13 08:08:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_fcurves(WriteData *wd, ListBase *fcurves)
|
|
|
|
{
|
|
|
|
FCurve *fcu;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writelist(wd, DATA, FCurve, fcurves);
|
2016-06-28 17:35:35 +10:00
|
|
|
for (fcu = fcurves->first; fcu; fcu = fcu->next) {
|
2010-12-13 08:08:09 +00:00
|
|
|
/* curve data */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (fcu->bezt) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BezTriple, fcu->totvert, fcu->bezt);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
if (fcu->fpt) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, FPoint, fcu->totvert, fcu->fpt);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fcu->rna_path) {
|
|
|
|
writedata(wd, DATA, strlen(fcu->rna_path) + 1, fcu->rna_path);
|
|
|
|
}
|
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* driver data */
|
|
|
|
if (fcu->driver) {
|
2016-06-28 17:35:35 +10:00
|
|
|
ChannelDriver *driver = fcu->driver;
|
2010-12-13 08:08:09 +00:00
|
|
|
DriverVar *dvar;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ChannelDriver, 1, driver);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* variables */
|
2016-06-28 20:05:42 +10:00
|
|
|
writelist(wd, DATA, DriverVar, &driver->variables);
|
2016-06-28 17:35:35 +10:00
|
|
|
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
|
2010-12-13 08:08:09 +00:00
|
|
|
DRIVER_TARGETS_USED_LOOPER(dvar)
|
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
if (dtar->rna_path) {
|
|
|
|
writedata(wd, DATA, strlen(dtar->rna_path) + 1, dtar->rna_path);
|
|
|
|
}
|
2010-12-13 08:08:09 +00:00
|
|
|
}
|
|
|
|
DRIVER_TARGETS_LOOPER_END
|
|
|
|
}
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* write F-Modifiers */
|
|
|
|
write_fmodifiers(wd, &fcu->modifiers);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_actions(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
bAction *act;
|
2010-12-13 08:08:09 +00:00
|
|
|
bActionGroup *grp;
|
|
|
|
TimeMarker *marker;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
for (act = idbase->first; act; act = act->id.next) {
|
|
|
|
if (act->id.us > 0 || wd->current) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_AC, bAction, 1, act);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &act->id);
|
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
write_fcurves(wd, &act->curves);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
for (grp = act->groups.first; grp; grp = grp->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bActionGroup, 1, grp);
|
2010-12-13 08:08:09 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
for (marker = act->markers.first; marker; marker = marker->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, TimeMarker, 1, marker);
|
2010-12-13 08:08:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* flush helps the compression for undo-save */
|
|
|
|
mywrite(wd, MYWRITE_FLUSH, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_keyingsets(WriteData *wd, ListBase *list)
|
|
|
|
{
|
|
|
|
KeyingSet *ks;
|
|
|
|
KS_Path *ksp;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
for (ks = list->first; ks; ks = ks->next) {
|
2010-12-13 08:08:09 +00:00
|
|
|
/* KeyingSet */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, KeyingSet, 1, ks);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* Paths */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
|
2010-12-13 08:08:09 +00:00
|
|
|
/* Path */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, KS_Path, 1, ksp);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
if (ksp->rna_path) {
|
|
|
|
writedata(wd, DATA, strlen(ksp->rna_path) + 1, ksp->rna_path);
|
|
|
|
}
|
2010-12-13 08:08:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_nlastrips(WriteData *wd, ListBase *strips)
|
|
|
|
{
|
|
|
|
NlaStrip *strip;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writelist(wd, DATA, NlaStrip, strips);
|
2016-06-28 17:35:35 +10:00
|
|
|
for (strip = strips->first; strip; strip = strip->next) {
|
2010-12-13 08:08:09 +00:00
|
|
|
/* write the strip's F-Curves and modifiers */
|
|
|
|
write_fcurves(wd, &strip->fcurves);
|
|
|
|
write_fmodifiers(wd, &strip->modifiers);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* write the strip's children */
|
|
|
|
write_nlastrips(wd, &strip->strips);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_nladata(WriteData *wd, ListBase *nlabase)
|
|
|
|
{
|
|
|
|
NlaTrack *nlt;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* write all the tracks */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (nlt = nlabase->first; nlt; nlt = nlt->next) {
|
2010-12-13 08:08:09 +00:00
|
|
|
/* write the track first */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, NlaTrack, 1, nlt);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* write the track's strips */
|
|
|
|
write_nlastrips(wd, &nlt->strips);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_animdata(WriteData *wd, AnimData *adt)
|
|
|
|
{
|
|
|
|
AnimOverride *aor;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* firstly, just write the AnimData block */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, AnimData, 1, adt);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* write drivers */
|
|
|
|
write_fcurves(wd, &adt->drivers);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* write overrides */
|
|
|
|
// FIXME: are these needed?
|
2016-06-28 17:35:35 +10:00
|
|
|
for (aor = adt->overrides.first; aor; aor = aor->next) {
|
2010-12-13 08:08:09 +00:00
|
|
|
/* overrides consist of base data + rna_path */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, AnimOverride, 1, aor);
|
2016-06-28 17:35:35 +10:00
|
|
|
writedata(wd, DATA, strlen(aor->rna_path) + 1, aor->rna_path);
|
2010-12-13 08:08:09 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
// TODO write the remaps (if they are needed)
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
/* write NLA data */
|
|
|
|
write_nladata(wd, &adt->nla_tracks);
|
|
|
|
}
|
|
|
|
|
2012-08-19 15:41:56 +00:00
|
|
|
static void write_curvemapping_curves(WriteData *wd, CurveMapping *cumap)
|
Orange:
- New UI element: the "Curve Button".
For mapping ranges (like 0 - 1) to another range, the curve button can be
used for proportional falloff, bone influences, painting density, etc.
Most evident use is of course to map RGB color with curves.
To be able to use it, you have to allocate a CurveMapping struct and pass
this on to the button. The CurveMapping API is in the new C file
blenkernel/intern/colortools.c
It's as simple as calling:
curvemap= curvemapping_add(3, 0, 0, 1, 1)
Which will create 3 curves, and sets a default 0-1 range. The current code
only supports up to 4 curves maximum per mapping struct.
The CurveMap button in Blender than handles allmost all editing.
Evaluating a single channel:
float newvalue= curvemapping_evaluateF(curvemap, 0, oldval);
Where the second argument is the channel index, here 0-1-2 are possible.
Or mapping a vector:
curvemapping_evaluate3F(curvemap, newvec, oldvec);
Optimized versions for byte or short mapping is possible too, not done yet.
In butspace.c I've added a template wrapper for buttons around the curve, to
reveil settings or show tools; check this screenie:
http://www.blender.org/bf/curves.jpg
- Buttons R, G, B: select channel
- icons + and -: zoom in, out
- icon 'wrench': menu with tools, like clear curve, set handle type
- icon 'clipping': menu with clip values, and to dis/enable clipping
- icon 'x': delete selection
In the curve button itself, only LMB clicks are handled (like all UI elements
in Blender).
- click on point: select
- shift+click on point: swap select
- click on point + drag: select point (if not selected) and move it
- click outside point + drag: translate view
- CTRL+click: add new point
- hold SHIFT while dragging to snap to grid
(Yes I know... either one of these can be Blender compliant, not both!)
- if you drag a point exactly on top of another, it merges them
Other fixes:
- Icons now draw using "Safe RasterPos", so they align with pixel boundary.
the old code made ints from the raster pos coordinate, which doesn't work
well for zoom in/out situations
- bug in Node editing: buttons could not get freed, causing in memory error
prints at end of a Blender session. That one was a very simple, but nasty
error causing me all evening last night to find!
(Hint; check diff of editnode.c, where uiDoButtons is called)
Last note: this adds 3 new files in our tree, I did scons, but not MSVC!
2006-01-08 11:41:06 +00:00
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
for (int a = 0; a < CM_TOT; a++) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, CurveMapPoint, cumap->cm[a].totpoint, cumap->cm[a].curve);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
Orange:
- New UI element: the "Curve Button".
For mapping ranges (like 0 - 1) to another range, the curve button can be
used for proportional falloff, bone influences, painting density, etc.
Most evident use is of course to map RGB color with curves.
To be able to use it, you have to allocate a CurveMapping struct and pass
this on to the button. The CurveMapping API is in the new C file
blenkernel/intern/colortools.c
It's as simple as calling:
curvemap= curvemapping_add(3, 0, 0, 1, 1)
Which will create 3 curves, and sets a default 0-1 range. The current code
only supports up to 4 curves maximum per mapping struct.
The CurveMap button in Blender than handles allmost all editing.
Evaluating a single channel:
float newvalue= curvemapping_evaluateF(curvemap, 0, oldval);
Where the second argument is the channel index, here 0-1-2 are possible.
Or mapping a vector:
curvemapping_evaluate3F(curvemap, newvec, oldvec);
Optimized versions for byte or short mapping is possible too, not done yet.
In butspace.c I've added a template wrapper for buttons around the curve, to
reveil settings or show tools; check this screenie:
http://www.blender.org/bf/curves.jpg
- Buttons R, G, B: select channel
- icons + and -: zoom in, out
- icon 'wrench': menu with tools, like clear curve, set handle type
- icon 'clipping': menu with clip values, and to dis/enable clipping
- icon 'x': delete selection
In the curve button itself, only LMB clicks are handled (like all UI elements
in Blender).
- click on point: select
- shift+click on point: swap select
- click on point + drag: select point (if not selected) and move it
- click outside point + drag: translate view
- CTRL+click: add new point
- hold SHIFT while dragging to snap to grid
(Yes I know... either one of these can be Blender compliant, not both!)
- if you drag a point exactly on top of another, it merges them
Other fixes:
- Icons now draw using "Safe RasterPos", so they align with pixel boundary.
the old code made ints from the raster pos coordinate, which doesn't work
well for zoom in/out situations
- bug in Node editing: buttons could not get freed, causing in memory error
prints at end of a Blender session. That one was a very simple, but nasty
error causing me all evening last night to find!
(Hint; check diff of editnode.c, where uiDoButtons is called)
Last note: this adds 3 new files in our tree, I did scons, but not MSVC!
2006-01-08 11:41:06 +00:00
|
|
|
}
|
|
|
|
|
2012-08-19 15:41:56 +00:00
|
|
|
static void write_curvemapping(WriteData *wd, CurveMapping *cumap)
|
|
|
|
{
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, CurveMapping, 1, cumap);
|
2012-08-19 15:41:56 +00:00
|
|
|
|
|
|
|
write_curvemapping_curves(wd, cumap);
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
static void write_node_socket(WriteData *wd, bNodeTree *UNUSED(ntree), bNode *node, bNodeSocket *sock)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
#ifdef USE_NODE_COMPAT_CUSTOMNODES
|
2011-09-06 16:51:10 +00:00
|
|
|
/* forward compatibility code, so older blenders still open */
|
|
|
|
sock->stack_type = 1;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (node->type == NODE_GROUP) {
|
|
|
|
bNodeTree *ngroup = (bNodeTree *)node->id;
|
|
|
|
if (ngroup) {
|
|
|
|
/* for node groups: look up the deprecated groupsock pointer */
|
|
|
|
sock->groupsock = ntreeFindSocketInterface(ngroup, sock->in_out, sock->identifier);
|
|
|
|
BLI_assert(sock->groupsock != NULL);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* node group sockets now use the generic identifier string to verify group nodes,
|
|
|
|
* old blender uses the own_index.
|
|
|
|
*/
|
|
|
|
sock->own_index = sock->groupsock->own_index;
|
2011-09-06 16:51:10 +00:00
|
|
|
}
|
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
#endif
|
2011-09-06 16:51:10 +00:00
|
|
|
|
|
|
|
/* actual socket writing */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bNodeSocket, 1, sock);
|
2013-03-18 16:34:57 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (sock->prop) {
|
2013-03-18 16:34:57 +00:00
|
|
|
IDP_WriteProperty(sock->prop, wd);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sock->default_value) {
|
2013-03-18 16:34:57 +00:00
|
|
|
writedata(wd, DATA, MEM_allocN_len(sock->default_value), sock->default_value);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
static void write_node_socket_interface(WriteData *wd, bNodeTree *UNUSED(ntree), bNodeSocket *sock)
|
|
|
|
{
|
|
|
|
#ifdef USE_NODE_COMPAT_CUSTOMNODES
|
|
|
|
/* forward compatibility code, so older blenders still open */
|
|
|
|
sock->stack_type = 1;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* Reconstruct the deprecated default_value structs in socket interface DNA. */
|
|
|
|
if (sock->default_value == NULL && sock->typeinfo) {
|
|
|
|
node_socket_init_default_value(sock);
|
|
|
|
}
|
|
|
|
#endif
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* actual socket writing */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bNodeSocket, 1, sock);
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (sock->prop) {
|
2013-03-18 16:34:57 +00:00
|
|
|
IDP_WriteProperty(sock->prop, wd);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sock->default_value) {
|
2013-04-05 11:16:06 +00:00
|
|
|
writedata(wd, DATA, MEM_allocN_len(sock->default_value), sock->default_value);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
/* this is only direct data, tree itself should have been written */
|
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
|
|
|
static void write_nodetree(WriteData *wd, bNodeTree *ntree)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
bNodeSocket *sock;
|
|
|
|
bNodeLink *link;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
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
|
|
|
/* for link_list() speed, we write per list */
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
if (ntree->adt) {
|
|
|
|
write_animdata(wd, ntree->adt);
|
|
|
|
}
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bNode, 1, node);
|
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
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (node->prop) {
|
2013-03-18 16:34:57 +00:00
|
|
|
IDP_WriteProperty(node->prop, wd);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (sock = node->inputs.first; sock; sock = sock->next) {
|
2013-03-18 16:34:57 +00:00
|
|
|
write_node_socket(wd, ntree, node, sock);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
for (sock = node->outputs.first; sock; sock = sock->next) {
|
2013-03-18 16:34:57 +00:00
|
|
|
write_node_socket(wd, ntree, node, sock);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
for (link = node->internal_links.first; link; link = link->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bNodeLink, 1, link);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
2012-05-29 09:37:23 +00:00
|
|
|
if (node->storage) {
|
Orange:
- New UI element: the "Curve Button".
For mapping ranges (like 0 - 1) to another range, the curve button can be
used for proportional falloff, bone influences, painting density, etc.
Most evident use is of course to map RGB color with curves.
To be able to use it, you have to allocate a CurveMapping struct and pass
this on to the button. The CurveMapping API is in the new C file
blenkernel/intern/colortools.c
It's as simple as calling:
curvemap= curvemapping_add(3, 0, 0, 1, 1)
Which will create 3 curves, and sets a default 0-1 range. The current code
only supports up to 4 curves maximum per mapping struct.
The CurveMap button in Blender than handles allmost all editing.
Evaluating a single channel:
float newvalue= curvemapping_evaluateF(curvemap, 0, oldval);
Where the second argument is the channel index, here 0-1-2 are possible.
Or mapping a vector:
curvemapping_evaluate3F(curvemap, newvec, oldvec);
Optimized versions for byte or short mapping is possible too, not done yet.
In butspace.c I've added a template wrapper for buttons around the curve, to
reveil settings or show tools; check this screenie:
http://www.blender.org/bf/curves.jpg
- Buttons R, G, B: select channel
- icons + and -: zoom in, out
- icon 'wrench': menu with tools, like clear curve, set handle type
- icon 'clipping': menu with clip values, and to dis/enable clipping
- icon 'x': delete selection
In the curve button itself, only LMB clicks are handled (like all UI elements
in Blender).
- click on point: select
- shift+click on point: swap select
- click on point + drag: select point (if not selected) and move it
- click outside point + drag: translate view
- CTRL+click: add new point
- hold SHIFT while dragging to snap to grid
(Yes I know... either one of these can be Blender compliant, not both!)
- if you drag a point exactly on top of another, it merges them
Other fixes:
- Icons now draw using "Safe RasterPos", so they align with pixel boundary.
the old code made ints from the raster pos coordinate, which doesn't work
well for zoom in/out situations
- bug in Node editing: buttons could not get freed, causing in memory error
prints at end of a Blender session. That one was a very simple, but nasty
error causing me all evening last night to find!
(Hint; check diff of editnode.c, where uiDoButtons is called)
Last note: this adds 3 new files in our tree, I did scons, but not MSVC!
2006-01-08 11:41:06 +00:00
|
|
|
/* could be handlerized at some point, now only 1 exception still */
|
2016-06-28 17:35:35 +10:00
|
|
|
if ((ntree->type == NTREE_SHADER) &&
|
|
|
|
ELEM(node->type, SH_NODE_CURVE_VEC, SH_NODE_CURVE_RGB))
|
|
|
|
{
|
Orange:
- New UI element: the "Curve Button".
For mapping ranges (like 0 - 1) to another range, the curve button can be
used for proportional falloff, bone influences, painting density, etc.
Most evident use is of course to map RGB color with curves.
To be able to use it, you have to allocate a CurveMapping struct and pass
this on to the button. The CurveMapping API is in the new C file
blenkernel/intern/colortools.c
It's as simple as calling:
curvemap= curvemapping_add(3, 0, 0, 1, 1)
Which will create 3 curves, and sets a default 0-1 range. The current code
only supports up to 4 curves maximum per mapping struct.
The CurveMap button in Blender than handles allmost all editing.
Evaluating a single channel:
float newvalue= curvemapping_evaluateF(curvemap, 0, oldval);
Where the second argument is the channel index, here 0-1-2 are possible.
Or mapping a vector:
curvemapping_evaluate3F(curvemap, newvec, oldvec);
Optimized versions for byte or short mapping is possible too, not done yet.
In butspace.c I've added a template wrapper for buttons around the curve, to
reveil settings or show tools; check this screenie:
http://www.blender.org/bf/curves.jpg
- Buttons R, G, B: select channel
- icons + and -: zoom in, out
- icon 'wrench': menu with tools, like clear curve, set handle type
- icon 'clipping': menu with clip values, and to dis/enable clipping
- icon 'x': delete selection
In the curve button itself, only LMB clicks are handled (like all UI elements
in Blender).
- click on point: select
- shift+click on point: swap select
- click on point + drag: select point (if not selected) and move it
- click outside point + drag: translate view
- CTRL+click: add new point
- hold SHIFT while dragging to snap to grid
(Yes I know... either one of these can be Blender compliant, not both!)
- if you drag a point exactly on top of another, it merges them
Other fixes:
- Icons now draw using "Safe RasterPos", so they align with pixel boundary.
the old code made ints from the raster pos coordinate, which doesn't work
well for zoom in/out situations
- bug in Node editing: buttons could not get freed, causing in memory error
prints at end of a Blender session. That one was a very simple, but nasty
error causing me all evening last night to find!
(Hint; check diff of editnode.c, where uiDoButtons is called)
Last note: this adds 3 new files in our tree, I did scons, but not MSVC!
2006-01-08 11:41:06 +00:00
|
|
|
write_curvemapping(wd, node->storage);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
else if (ntree->type == NTREE_SHADER &&
|
|
|
|
(node->type == SH_NODE_SCRIPT))
|
|
|
|
{
|
2012-11-03 14:32:26 +00:00
|
|
|
NodeShaderScript *nss = (NodeShaderScript *)node->storage;
|
2016-06-28 17:35:35 +10:00
|
|
|
if (nss->bytecode) {
|
|
|
|
writedata(wd, DATA, strlen(nss->bytecode) + 1, nss->bytecode);
|
|
|
|
}
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
|
2012-11-03 14:32:26 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if ((ntree->type == NTREE_COMPOSIT) &&
|
|
|
|
ELEM(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT))
|
|
|
|
{
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
write_curvemapping(wd, node->storage);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
else if ((ntree->type == NTREE_TEXTURE) &&
|
|
|
|
(node->type == TEX_NODE_CURVE_RGB || node->type == TEX_NODE_CURVE_TIME))
|
|
|
|
{
|
2008-11-12 22:03:11 +00:00
|
|
|
write_curvemapping(wd, node->storage);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
else if ((ntree->type == NTREE_COMPOSIT) &&
|
|
|
|
(node->type == CMP_NODE_MOVIEDISTORTION))
|
|
|
|
{
|
2012-10-14 13:08:19 +00:00
|
|
|
/* pass */
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_id(wd, DATA, node->typeinfo->storagename, 1, node->storage);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
Orange:
- New UI element: the "Curve Button".
For mapping ranges (like 0 - 1) to another range, the curve button can be
used for proportional falloff, bone influences, painting density, etc.
Most evident use is of course to map RGB color with curves.
To be able to use it, you have to allocate a CurveMapping struct and pass
this on to the button. The CurveMapping API is in the new C file
blenkernel/intern/colortools.c
It's as simple as calling:
curvemap= curvemapping_add(3, 0, 0, 1, 1)
Which will create 3 curves, and sets a default 0-1 range. The current code
only supports up to 4 curves maximum per mapping struct.
The CurveMap button in Blender than handles allmost all editing.
Evaluating a single channel:
float newvalue= curvemapping_evaluateF(curvemap, 0, oldval);
Where the second argument is the channel index, here 0-1-2 are possible.
Or mapping a vector:
curvemapping_evaluate3F(curvemap, newvec, oldvec);
Optimized versions for byte or short mapping is possible too, not done yet.
In butspace.c I've added a template wrapper for buttons around the curve, to
reveil settings or show tools; check this screenie:
http://www.blender.org/bf/curves.jpg
- Buttons R, G, B: select channel
- icons + and -: zoom in, out
- icon 'wrench': menu with tools, like clear curve, set handle type
- icon 'clipping': menu with clip values, and to dis/enable clipping
- icon 'x': delete selection
In the curve button itself, only LMB clicks are handled (like all UI elements
in Blender).
- click on point: select
- shift+click on point: swap select
- click on point + drag: select point (if not selected) and move it
- click outside point + drag: translate view
- CTRL+click: add new point
- hold SHIFT while dragging to snap to grid
(Yes I know... either one of these can be Blender compliant, not both!)
- if you drag a point exactly on top of another, it merges them
Other fixes:
- Icons now draw using "Safe RasterPos", so they align with pixel boundary.
the old code made ints from the raster pos coordinate, which doesn't work
well for zoom in/out situations
- bug in Node editing: buttons could not get freed, causing in memory error
prints at end of a Blender session. That one was a very simple, but nasty
error causing me all evening last night to find!
(Hint; check diff of editnode.c, where uiDoButtons is called)
Last note: this adds 3 new files in our tree, I did scons, but not MSVC!
2006-01-08 11:41:06 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
if (node->type == CMP_NODE_OUTPUT_FILE) {
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
/* inputs have own storage data */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (sock = node->inputs.first; sock; sock = sock->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, NodeImageMultiFileSocket, 1, sock->storage);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
if (node->type == CMP_NODE_IMAGE) {
|
2012-05-11 08:06:01 +00:00
|
|
|
/* write extra socket info */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (sock = node->outputs.first; sock; sock = sock->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, NodeImageLayer, 1, sock->storage);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2012-05-11 08:06:01 +00:00
|
|
|
}
|
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
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
for (link = ntree->links.first; link; link = link->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bNodeLink, 1, link);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
for (sock = ntree->inputs.first; sock; sock = sock->next) {
|
2013-03-18 16:34:57 +00:00
|
|
|
write_node_socket_interface(wd, ntree, sock);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
for (sock = ntree->outputs.first; sock; sock = sock->next) {
|
2013-03-18 16:34:57 +00:00
|
|
|
write_node_socket_interface(wd, ntree, sock);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
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).
|
|
|
|
*/
|
|
|
|
static void current_screen_compat(Main *mainvar, bScreen **r_screen, bool use_active_win)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2008-12-19 16:36:15 +00:00
|
|
|
wmWindowManager *wm;
|
2015-02-10 05:45:57 +11:00
|
|
|
wmWindow *window = NULL;
|
2008-12-19 16:36:15 +00:00
|
|
|
|
|
|
|
/* find a global current screen in the first open window, to have
|
|
|
|
* a reasonable default for reading in older versions */
|
2013-03-31 03:28:46 +00:00
|
|
|
wm = mainvar->wm.first;
|
2015-02-10 05:45:57 +11:00
|
|
|
|
|
|
|
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) ? window->screen : NULL;
|
2008-12-19 16:36:15 +00:00
|
|
|
}
|
|
|
|
|
2012-04-26 04:03:25 +00:00
|
|
|
typedef struct RenderInfo {
|
|
|
|
int sfra;
|
|
|
|
int efra;
|
|
|
|
char scene_name[MAX_ID_NAME - 2];
|
|
|
|
} RenderInfo;
|
|
|
|
|
2012-10-15 02:15:07 +00:00
|
|
|
/* was for historic render-deamon feature,
|
|
|
|
* now write because it can be easily extracted without
|
|
|
|
* reading the whole blend file */
|
|
|
|
static void write_renderinfo(WriteData *wd, Main *mainvar)
|
2008-12-19 16:36:15 +00:00
|
|
|
{
|
|
|
|
bScreen *curscreen;
|
2013-03-05 11:19:21 +00:00
|
|
|
Scene *sce, *curscene = NULL;
|
2012-04-26 04:03:25 +00:00
|
|
|
RenderInfo data;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2012-10-15 02:15:07 +00:00
|
|
|
/* XXX in future, handle multiple windows with multiple screens? */
|
2015-02-10 05:45:57 +11:00
|
|
|
current_screen_compat(mainvar, &curscreen, false);
|
2016-06-28 17:35:35 +10:00
|
|
|
if (curscreen) {
|
|
|
|
curscene = curscreen->scene;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (sce = mainvar->scene.first; sce; sce = sce->id.next) {
|
2013-03-05 11:19:21 +00:00
|
|
|
if (sce->id.lib == NULL && (sce == curscene || (sce->r.scemode & R_BG_RENDER))) {
|
2012-04-26 04:03:25 +00: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
|
|
|
|
2012-04-26 04:03:25 +00:00
|
|
|
BLI_strncpy(data.scene_name, sce->id.name + 2, sizeof(data.scene_name));
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2012-04-26 04:03:25 +00:00
|
|
|
writedata(wd, REND, sizeof(data), &data);
|
2002-10-12 11:37:38 +00: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
|
|
|
static void write_keymapitem(WriteData *wd, wmKeyMapItem *kmi)
|
|
|
|
{
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, wmKeyMapItem, 1, kmi);
|
2016-06-28 17:35:35 +10:00
|
|
|
if (kmi->properties) {
|
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
|
|
|
IDP_WriteProperty(kmi->properties, wd);
|
2016-06-28 17:35:35 +10: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
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
static void write_userdef(WriteData *wd)
|
|
|
|
{
|
- The basic layer for Themes in place!
- currently only implemented for 3d window
- create as many themes you like, and name them
- default theme is not editable, and always will be defined at startup
(initTheme)
- saves in .B.blend
- themes for spaces can become local too, so you can set individual
3d windows at theme 'Maya' or so. (to be implemented)
- it uses alpha as well...!
API:
This doesnt use the old method with BFCOLORID blahblah. The API is copied
from OpenGL conventions (naming) as much as possible:
- void BIF_ThemeColor(ScrArea *sa, int colorid)
sets a color... id's are in BIF_resources.h (TH_GRID, TH_WIRE, etc)
- void BIF_ThemeColorShade(ScrArea *sa, int colorid, int offset)
sets a color with offset, no more weird COLORSHADE_LGREY stuff
- void BIF_GetThemeColor3fv(ScrArea *sa, int colorid, float *col)
like opengl, this gives you in *col the three rgb values
- void BIF_GetThemeColor4ubv(ScrArea *sa, int colorid, char *col)
or the one to get 4 bytes
ThemeColor calls for globals (UI etc) can also call NULL for *sa... this
is to be implemented still.
Next step: cleaning up interface.c for all weird colorcalls.
2003-10-17 14:02:08 +00:00
|
|
|
bTheme *btheme;
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmKeyMap *keymap;
|
|
|
|
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
|
|
|
wmKeyMapDiffItem *kmdi;
|
2010-02-26 14:28:29 +00:00
|
|
|
bAddon *bext;
|
2013-06-18 18:11:52 +00:00
|
|
|
bPathCompare *path_cmp;
|
2011-06-24 14:00:15 +00:00
|
|
|
uiStyle *style;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, USER, UserDef, 1, &U);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bTheme, 1, btheme);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (keymap = U.user_keymaps.first; keymap; keymap = keymap->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, wmKeyMap, 1, keymap);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, wmKeyMapDiffItem, 1, kmdi);
|
2016-06-28 17:35:35 +10:00
|
|
|
if (kmdi->remove_item) {
|
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
|
|
|
write_keymapitem(wd, kmdi->remove_item);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
if (kmdi->add_item) {
|
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
|
|
|
write_keymapitem(wd, kmdi->add_item);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00: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
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
|
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
|
|
|
write_keymapitem(wd, kmi);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
- The basic layer for Themes in place!
- currently only implemented for 3d window
- create as many themes you like, and name them
- default theme is not editable, and always will be defined at startup
(initTheme)
- saves in .B.blend
- themes for spaces can become local too, so you can set individual
3d windows at theme 'Maya' or so. (to be implemented)
- it uses alpha as well...!
API:
This doesnt use the old method with BFCOLORID blahblah. The API is copied
from OpenGL conventions (naming) as much as possible:
- void BIF_ThemeColor(ScrArea *sa, int colorid)
sets a color... id's are in BIF_resources.h (TH_GRID, TH_WIRE, etc)
- void BIF_ThemeColorShade(ScrArea *sa, int colorid, int offset)
sets a color with offset, no more weird COLORSHADE_LGREY stuff
- void BIF_GetThemeColor3fv(ScrArea *sa, int colorid, float *col)
like opengl, this gives you in *col the three rgb values
- void BIF_GetThemeColor4ubv(ScrArea *sa, int colorid, char *col)
or the one to get 4 bytes
ThemeColor calls for globals (UI etc) can also call NULL for *sa... this
is to be implemented still.
Next step: cleaning up interface.c for all weird colorcalls.
2003-10-17 14:02:08 +00:00
|
|
|
}
|
2010-02-14 23:33:18 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (bext = U.addons.first; bext; bext = bext->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bAddon, 1, bext);
|
2012-12-29 10:24:42 +00:00
|
|
|
if (bext->prop) {
|
|
|
|
IDP_WriteProperty(bext->prop, wd);
|
|
|
|
}
|
|
|
|
}
|
2013-06-18 18:11:52 +00:00
|
|
|
|
|
|
|
for (path_cmp = U.autoexec_paths.first; path_cmp; path_cmp = path_cmp->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bPathCompare, 1, path_cmp);
|
2013-06-18 18:11:52 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
for (style = U.uistyles.first; style; style = style->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, uiStyle, 1, style);
|
2011-06-24 14:00:15 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
static void write_boid_state(WriteData *wd, BoidState *state)
|
|
|
|
{
|
|
|
|
BoidRule *rule = state->rules.first;
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BoidState, 1, state);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (; rule; rule = rule->next) {
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (rule->type) {
|
2009-07-20 23:52:53 +00:00
|
|
|
case eBoidRuleType_Goal:
|
|
|
|
case eBoidRuleType_Avoid:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BoidRuleGoalAvoid, 1, rule);
|
2009-07-20 23:52:53 +00:00
|
|
|
break;
|
|
|
|
case eBoidRuleType_AvoidCollision:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BoidRuleAvoidCollision, 1, rule);
|
2009-07-20 23:52:53 +00:00
|
|
|
break;
|
|
|
|
case eBoidRuleType_FollowLeader:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BoidRuleFollowLeader, 1, rule);
|
2009-07-20 23:52:53 +00:00
|
|
|
break;
|
|
|
|
case eBoidRuleType_AverageSpeed:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BoidRuleAverageSpeed, 1, rule);
|
2009-07-20 23:52:53 +00:00
|
|
|
break;
|
|
|
|
case eBoidRuleType_Fight:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BoidRuleFight, 1, rule);
|
2009-07-20 23:52:53 +00:00
|
|
|
break;
|
|
|
|
default:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BoidRule, 1, rule);
|
2009-07-20 23:52:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
#if 0
|
|
|
|
BoidCondition *cond = state->conditions.first;
|
|
|
|
for (; cond; cond = cond->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BoidCondition, 1, cond);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
#endif
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
2011-01-10 02:40:24 +00:00
|
|
|
|
|
|
|
/* update this also to readfile.c */
|
2011-01-10 05:17:53 +00:00
|
|
|
static const char *ptcache_data_struct[] = {
|
2011-01-10 02:40:24 +00:00
|
|
|
"", // BPHYS_DATA_INDEX
|
|
|
|
"", // BPHYS_DATA_LOCATION
|
|
|
|
"", // BPHYS_DATA_VELOCITY
|
|
|
|
"", // BPHYS_DATA_ROTATION
|
|
|
|
"", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */
|
|
|
|
"", // BPHYS_DATA_SIZE:
|
2012-10-21 05:46:41 +00:00
|
|
|
"", // BPHYS_DATA_TIMES:
|
2011-01-10 02:40:24 +00:00
|
|
|
"BoidData" // case BPHYS_DATA_BOIDS:
|
|
|
|
};
|
2011-01-10 05:17:53 +00:00
|
|
|
static const char *ptcache_extra_struct[] = {
|
2011-01-10 02:40:24 +00:00
|
|
|
"",
|
|
|
|
"ParticleSpring"
|
|
|
|
};
|
New point cache file format:
- HEADER (beginning of each file)
* general header:
+ 8 char: "BPHYSICS"
+ 1 int: simulation type (same as PTCacheID->type)
* custom header (same for sb, particles and cloth, but can be different for new dynamics)
+ 1 int: totpoint (number of points)
+ 1 int: data_types (bit flags for what the stored data is)
- DATA (directly after header)
*totpoint times the data as specified in data_types flags
- simulation type
soft body = 0, particles = 1, cloth = 2
- data types (more can be added easily when needed)
data flag contains
----------------------------------------
index (1<<0) 1 int (index of current point)
location (1<<1) 3 float
velocity (1<<2) 3 float
rotation (1<<3) 4 float (quaternion)
avelocity (1<<4) 3 float (used for particles)
xconst (1<<4) 3 float (used for cloth)
size (1<<5) 1 float
times (1<<6) 3 float (birth, die & lifetime of particle)
boids (1<<7) 1 BoidData
Notes:
- Every frame is not nescessary since data is interpolated for the inbetween frames.
- For now every point is needed for every cached frame, the "index" data type is reserved for future usage.
- For loading external particle caches only "location" data is necessary, other needed values are determined from the given data.
- Non-dynamic data should be written into an info file if external usage is desired.
* Info file is named as normal cache files, but with frame number 0;
* "Non-dynamic" means data such as particle times.
* Written automatically when baking to disk so basically a library of particle simulations should be possible.
- Old disk cache format is supported for reading, so pre 2.5 files shouldn't break. However old style memory cache (added during 2.5 development) is not supported. To keep memory cached simulations convert the cache to disk cache before svn update and save the blend.
- External sb and cloth caches should be perfectly possible, but due to lack of testing these are not yet enabled in ui.
Other changes:
- Multiple point caches per dynamics system.
* In the future these will hopefully be nla editable etc, but for now things are simple and the current (selected) point cache is used.
* Changing the amount of cached points (for example particle count) is allowed, but might not give correct results if multiple caches are present.
- Generalization of point cache baking etc operator & rna code.
- Comb brushing particle hair didn't work smoothly.
2009-08-12 09:54:29 +00:00
|
|
|
static void write_pointcaches(WriteData *wd, ListBase *ptcaches)
|
2009-06-21 10:16:52 +00:00
|
|
|
{
|
New point cache file format:
- HEADER (beginning of each file)
* general header:
+ 8 char: "BPHYSICS"
+ 1 int: simulation type (same as PTCacheID->type)
* custom header (same for sb, particles and cloth, but can be different for new dynamics)
+ 1 int: totpoint (number of points)
+ 1 int: data_types (bit flags for what the stored data is)
- DATA (directly after header)
*totpoint times the data as specified in data_types flags
- simulation type
soft body = 0, particles = 1, cloth = 2
- data types (more can be added easily when needed)
data flag contains
----------------------------------------
index (1<<0) 1 int (index of current point)
location (1<<1) 3 float
velocity (1<<2) 3 float
rotation (1<<3) 4 float (quaternion)
avelocity (1<<4) 3 float (used for particles)
xconst (1<<4) 3 float (used for cloth)
size (1<<5) 1 float
times (1<<6) 3 float (birth, die & lifetime of particle)
boids (1<<7) 1 BoidData
Notes:
- Every frame is not nescessary since data is interpolated for the inbetween frames.
- For now every point is needed for every cached frame, the "index" data type is reserved for future usage.
- For loading external particle caches only "location" data is necessary, other needed values are determined from the given data.
- Non-dynamic data should be written into an info file if external usage is desired.
* Info file is named as normal cache files, but with frame number 0;
* "Non-dynamic" means data such as particle times.
* Written automatically when baking to disk so basically a library of particle simulations should be possible.
- Old disk cache format is supported for reading, so pre 2.5 files shouldn't break. However old style memory cache (added during 2.5 development) is not supported. To keep memory cached simulations convert the cache to disk cache before svn update and save the blend.
- External sb and cloth caches should be perfectly possible, but due to lack of testing these are not yet enabled in ui.
Other changes:
- Multiple point caches per dynamics system.
* In the future these will hopefully be nla editable etc, but for now things are simple and the current (selected) point cache is used.
* Changing the amount of cached points (for example particle count) is allowed, but might not give correct results if multiple caches are present.
- Generalization of point cache baking etc operator & rna code.
- Comb brushing particle hair didn't work smoothly.
2009-08-12 09:54:29 +00:00
|
|
|
PointCache *cache = ptcaches->first;
|
|
|
|
int i;
|
2009-06-21 10:16:52 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (; cache; cache = cache->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, PointCache, 1, cache);
|
2009-06-21 10:16:52 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if ((cache->flag & PTCACHE_DISK_CACHE) == 0) {
|
New point cache file format:
- HEADER (beginning of each file)
* general header:
+ 8 char: "BPHYSICS"
+ 1 int: simulation type (same as PTCacheID->type)
* custom header (same for sb, particles and cloth, but can be different for new dynamics)
+ 1 int: totpoint (number of points)
+ 1 int: data_types (bit flags for what the stored data is)
- DATA (directly after header)
*totpoint times the data as specified in data_types flags
- simulation type
soft body = 0, particles = 1, cloth = 2
- data types (more can be added easily when needed)
data flag contains
----------------------------------------
index (1<<0) 1 int (index of current point)
location (1<<1) 3 float
velocity (1<<2) 3 float
rotation (1<<3) 4 float (quaternion)
avelocity (1<<4) 3 float (used for particles)
xconst (1<<4) 3 float (used for cloth)
size (1<<5) 1 float
times (1<<6) 3 float (birth, die & lifetime of particle)
boids (1<<7) 1 BoidData
Notes:
- Every frame is not nescessary since data is interpolated for the inbetween frames.
- For now every point is needed for every cached frame, the "index" data type is reserved for future usage.
- For loading external particle caches only "location" data is necessary, other needed values are determined from the given data.
- Non-dynamic data should be written into an info file if external usage is desired.
* Info file is named as normal cache files, but with frame number 0;
* "Non-dynamic" means data such as particle times.
* Written automatically when baking to disk so basically a library of particle simulations should be possible.
- Old disk cache format is supported for reading, so pre 2.5 files shouldn't break. However old style memory cache (added during 2.5 development) is not supported. To keep memory cached simulations convert the cache to disk cache before svn update and save the blend.
- External sb and cloth caches should be perfectly possible, but due to lack of testing these are not yet enabled in ui.
Other changes:
- Multiple point caches per dynamics system.
* In the future these will hopefully be nla editable etc, but for now things are simple and the current (selected) point cache is used.
* Changing the amount of cached points (for example particle count) is allowed, but might not give correct results if multiple caches are present.
- Generalization of point cache baking etc operator & rna code.
- Comb brushing particle hair didn't work smoothly.
2009-08-12 09:54:29 +00:00
|
|
|
PTCacheMem *pm = cache->mem_cache.first;
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (; pm; pm = pm->next) {
|
2011-01-09 19:09:41 +00:00
|
|
|
PTCacheExtra *extra = pm->extradata.first;
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, PTCacheMem, 1, pm);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
for (i = 0; i < BPHYS_TOT_DATA; i++) {
|
|
|
|
if (pm->data[i] && pm->data_types & (1 << i)) {
|
|
|
|
if (ptcache_data_struct[i][0] == '\0') {
|
2011-01-09 18:23:41 +00:00
|
|
|
writedata(wd, DATA, MEM_allocN_len(pm->data[i]), pm->data[i]);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_id(wd, DATA, ptcache_data_struct[i], pm->totpoint, pm->data[i]);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2011-01-09 18:23:41 +00:00
|
|
|
}
|
New point cache file format:
- HEADER (beginning of each file)
* general header:
+ 8 char: "BPHYSICS"
+ 1 int: simulation type (same as PTCacheID->type)
* custom header (same for sb, particles and cloth, but can be different for new dynamics)
+ 1 int: totpoint (number of points)
+ 1 int: data_types (bit flags for what the stored data is)
- DATA (directly after header)
*totpoint times the data as specified in data_types flags
- simulation type
soft body = 0, particles = 1, cloth = 2
- data types (more can be added easily when needed)
data flag contains
----------------------------------------
index (1<<0) 1 int (index of current point)
location (1<<1) 3 float
velocity (1<<2) 3 float
rotation (1<<3) 4 float (quaternion)
avelocity (1<<4) 3 float (used for particles)
xconst (1<<4) 3 float (used for cloth)
size (1<<5) 1 float
times (1<<6) 3 float (birth, die & lifetime of particle)
boids (1<<7) 1 BoidData
Notes:
- Every frame is not nescessary since data is interpolated for the inbetween frames.
- For now every point is needed for every cached frame, the "index" data type is reserved for future usage.
- For loading external particle caches only "location" data is necessary, other needed values are determined from the given data.
- Non-dynamic data should be written into an info file if external usage is desired.
* Info file is named as normal cache files, but with frame number 0;
* "Non-dynamic" means data such as particle times.
* Written automatically when baking to disk so basically a library of particle simulations should be possible.
- Old disk cache format is supported for reading, so pre 2.5 files shouldn't break. However old style memory cache (added during 2.5 development) is not supported. To keep memory cached simulations convert the cache to disk cache before svn update and save the blend.
- External sb and cloth caches should be perfectly possible, but due to lack of testing these are not yet enabled in ui.
Other changes:
- Multiple point caches per dynamics system.
* In the future these will hopefully be nla editable etc, but for now things are simple and the current (selected) point cache is used.
* Changing the amount of cached points (for example particle count) is allowed, but might not give correct results if multiple caches are present.
- Generalization of point cache baking etc operator & rna code.
- Comb brushing particle hair didn't work smoothly.
2009-08-12 09:54:29 +00:00
|
|
|
}
|
2011-01-09 19:09:41 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (; extra; extra = extra->next) {
|
|
|
|
if (ptcache_extra_struct[extra->type][0] == '\0') {
|
2011-01-09 19:09:41 +00:00
|
|
|
continue;
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, PTCacheExtra, 1, extra);
|
|
|
|
writestruct_id(wd, DATA, ptcache_extra_struct[extra->type], extra->totdata, extra->data);
|
New point cache file format:
- HEADER (beginning of each file)
* general header:
+ 8 char: "BPHYSICS"
+ 1 int: simulation type (same as PTCacheID->type)
* custom header (same for sb, particles and cloth, but can be different for new dynamics)
+ 1 int: totpoint (number of points)
+ 1 int: data_types (bit flags for what the stored data is)
- DATA (directly after header)
*totpoint times the data as specified in data_types flags
- simulation type
soft body = 0, particles = 1, cloth = 2
- data types (more can be added easily when needed)
data flag contains
----------------------------------------
index (1<<0) 1 int (index of current point)
location (1<<1) 3 float
velocity (1<<2) 3 float
rotation (1<<3) 4 float (quaternion)
avelocity (1<<4) 3 float (used for particles)
xconst (1<<4) 3 float (used for cloth)
size (1<<5) 1 float
times (1<<6) 3 float (birth, die & lifetime of particle)
boids (1<<7) 1 BoidData
Notes:
- Every frame is not nescessary since data is interpolated for the inbetween frames.
- For now every point is needed for every cached frame, the "index" data type is reserved for future usage.
- For loading external particle caches only "location" data is necessary, other needed values are determined from the given data.
- Non-dynamic data should be written into an info file if external usage is desired.
* Info file is named as normal cache files, but with frame number 0;
* "Non-dynamic" means data such as particle times.
* Written automatically when baking to disk so basically a library of particle simulations should be possible.
- Old disk cache format is supported for reading, so pre 2.5 files shouldn't break. However old style memory cache (added during 2.5 development) is not supported. To keep memory cached simulations convert the cache to disk cache before svn update and save the blend.
- External sb and cloth caches should be perfectly possible, but due to lack of testing these are not yet enabled in ui.
Other changes:
- Multiple point caches per dynamics system.
* In the future these will hopefully be nla editable etc, but for now things are simple and the current (selected) point cache is used.
* Changing the amount of cached points (for example particle count) is allowed, but might not give correct results if multiple caches are present.
- Generalization of point cache baking etc operator & rna code.
- Comb brushing particle hair didn't work smoothly.
2009-08-12 09:54:29 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-21 10:16:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
static void write_particlesettings(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
ParticleSettings *part;
|
2009-10-05 13:25:56 +00:00
|
|
|
ParticleDupliWeight *dw;
|
2011-07-15 13:32:02 +00:00
|
|
|
GroupObject *go;
|
2011-02-12 14:38:34 +00:00
|
|
|
int a;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
part = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (part) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (part->id.us > 0 || wd->current) {
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_PA, ParticleSettings, 1, part);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &part->id);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (part->adt) {
|
|
|
|
write_animdata(wd, part->adt);
|
|
|
|
}
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, PartDeflect, 1, part->pd);
|
|
|
|
writestruct(wd, DATA, PartDeflect, 1, part->pd2);
|
|
|
|
writestruct(wd, DATA, EffectorWeights, 1, part->effector_weights);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (part->clumpcurve) {
|
2015-01-09 14:24:19 +01:00
|
|
|
write_curvemapping(wd, part->clumpcurve);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
if (part->roughcurve) {
|
2015-01-09 15:58:18 +01:00
|
|
|
write_curvemapping(wd, part->roughcurve);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
2009-10-05 13:25:56 +00:00
|
|
|
dw = part->dupliweights.first;
|
2016-06-28 17:35:35 +10:00
|
|
|
for (; dw; dw = dw->next) {
|
2011-07-15 13:32:02 +00:00
|
|
|
/* update indices */
|
|
|
|
dw->index = 0;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->dup_group) { /* can be NULL if lining fails or set to None */
|
2011-08-23 20:49:06 +00:00
|
|
|
go = part->dup_group->gobject.first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (go && go->ob != dw->ob) {
|
2016-06-28 17:35:35 +10:00
|
|
|
go = go->next;
|
2011-08-23 20:49:06 +00:00
|
|
|
dw->index++;
|
|
|
|
}
|
2011-07-15 13:32:02 +00:00
|
|
|
}
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ParticleDupliWeight, 1, dw);
|
2011-07-15 13:32:02 +00:00
|
|
|
}
|
2009-10-05 13:25:56 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->boids && part->phystype == PART_PHYS_BOIDS) {
|
2009-07-20 23:52:53 +00:00
|
|
|
BoidState *state = part->boids->states.first;
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BoidSettings, 1, part->boids);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (; state; state = state->next) {
|
2009-07-20 23:52:53 +00:00
|
|
|
write_boid_state(wd, state);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->fluid && part->phystype == PART_PHYS_FLUID) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SPHFluidSettings, 1, part->fluid);
|
2010-04-04 12:29:06 +00:00
|
|
|
}
|
2011-02-12 14:38:34 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (a = 0; a < MAX_MTEX; a++) {
|
|
|
|
if (part->mtex[a]) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MTex, 1, part->mtex[a]);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2011-02-12 14:38:34 +00:00
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
part = part->id.next;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
static void write_particlesystems(WriteData *wd, ListBase *particles)
|
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
ParticleSystem *psys = particles->first;
|
2009-07-20 23:52:53 +00:00
|
|
|
ParticleTarget *pt;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
int a;
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (; psys; psys = psys->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ParticleSystem, 1, psys);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->particles) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ParticleData, psys->totpart, psys->particles);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->particles->hair) {
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
ParticleData *pa = psys->particles;
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (a = 0; a < psys->totpart; a++, pa++) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, HairKey, pa->totkey, pa->hair);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (psys->particles->boid &&
|
|
|
|
(psys->part->phystype == PART_PHYS_BOIDS))
|
|
|
|
{
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BoidParticle, psys->totpart, psys->particles->boid);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2011-01-09 19:09:41 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (psys->part->fluid &&
|
|
|
|
(psys->part->phystype == PART_PHYS_FLUID) &&
|
|
|
|
(psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS))
|
|
|
|
{
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ParticleSpring, psys->tot_fluidsprings, psys->fluid_springs);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
2009-07-20 23:52:53 +00:00
|
|
|
pt = psys->targets.first;
|
2016-06-28 17:35:35 +10:00
|
|
|
for (; pt; pt = pt->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ParticleTarget, 1, pt);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2009-07-12 23:38:47 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (psys->child) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ChildParticle, psys->totchild, psys->child);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2009-09-10 22:32:33 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (psys->clmd) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ClothModifierData, 1, psys->clmd);
|
|
|
|
writestruct(wd, DATA, ClothSimSettings, 1, psys->clmd->sim_parms);
|
|
|
|
writestruct(wd, DATA, ClothCollSettings, 1, psys->clmd->coll_parms);
|
2009-09-10 22:32:33 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
New point cache file format:
- HEADER (beginning of each file)
* general header:
+ 8 char: "BPHYSICS"
+ 1 int: simulation type (same as PTCacheID->type)
* custom header (same for sb, particles and cloth, but can be different for new dynamics)
+ 1 int: totpoint (number of points)
+ 1 int: data_types (bit flags for what the stored data is)
- DATA (directly after header)
*totpoint times the data as specified in data_types flags
- simulation type
soft body = 0, particles = 1, cloth = 2
- data types (more can be added easily when needed)
data flag contains
----------------------------------------
index (1<<0) 1 int (index of current point)
location (1<<1) 3 float
velocity (1<<2) 3 float
rotation (1<<3) 4 float (quaternion)
avelocity (1<<4) 3 float (used for particles)
xconst (1<<4) 3 float (used for cloth)
size (1<<5) 1 float
times (1<<6) 3 float (birth, die & lifetime of particle)
boids (1<<7) 1 BoidData
Notes:
- Every frame is not nescessary since data is interpolated for the inbetween frames.
- For now every point is needed for every cached frame, the "index" data type is reserved for future usage.
- For loading external particle caches only "location" data is necessary, other needed values are determined from the given data.
- Non-dynamic data should be written into an info file if external usage is desired.
* Info file is named as normal cache files, but with frame number 0;
* "Non-dynamic" means data such as particle times.
* Written automatically when baking to disk so basically a library of particle simulations should be possible.
- Old disk cache format is supported for reading, so pre 2.5 files shouldn't break. However old style memory cache (added during 2.5 development) is not supported. To keep memory cached simulations convert the cache to disk cache before svn update and save the blend.
- External sb and cloth caches should be perfectly possible, but due to lack of testing these are not yet enabled in ui.
Other changes:
- Multiple point caches per dynamics system.
* In the future these will hopefully be nla editable etc, but for now things are simple and the current (selected) point cache is used.
* Changing the amount of cached points (for example particle count) is allowed, but might not give correct results if multiple caches are present.
- Generalization of point cache baking etc operator & rna code.
- Comb brushing particle hair didn't work smoothly.
2009-08-12 09:54:29 +00:00
|
|
|
write_pointcaches(wd, &psys->ptcaches);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
static void write_properties(WriteData *wd, ListBase *lb)
|
|
|
|
{
|
|
|
|
bProperty *prop;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
prop = lb->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (prop) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bProperty, 1, prop);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (prop->poin && prop->poin != &prop->data) {
|
2002-10-12 11:37:38 +00:00
|
|
|
writedata(wd, DATA, MEM_allocN_len(prop->poin), prop->poin);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
prop = prop->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_sensors(WriteData *wd, ListBase *lb)
|
|
|
|
{
|
|
|
|
bSensor *sens;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
sens = lb->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (sens) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bSensor, 1, sens);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
writedata(wd, DATA, sizeof(void *) * sens->totlinks, sens->links);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (sens->type) {
|
2016-06-28 17:35:35 +10:00
|
|
|
case SENS_NEAR:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bNearSensor, 1, sens->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SENS_MOUSE:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bMouseSensor, 1, sens->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SENS_KEYBOARD:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bKeyboardSensor, 1, sens->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SENS_PROPERTY:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bPropertySensor, 1, sens->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SENS_ARMATURE:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bArmatureSensor, 1, sens->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SENS_ACTUATOR:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bActuatorSensor, 1, sens->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SENS_DELAY:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bDelaySensor, 1, sens->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SENS_COLLISION:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bCollisionSensor, 1, sens->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SENS_RADAR:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bRadarSensor, 1, sens->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SENS_RANDOM:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bRandomSensor, 1, sens->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SENS_RAY:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bRaySensor, 1, sens->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SENS_MESSAGE:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bMessageSensor, 1, sens->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SENS_JOYSTICK:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bJoystickSensor, 1, sens->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
; /* error: don't know how to write this file */
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
sens = sens->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_controllers(WriteData *wd, ListBase *lb)
|
|
|
|
{
|
|
|
|
bController *cont;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
cont = lb->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (cont) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bController, 1, cont);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
writedata(wd, DATA, sizeof(void *) * cont->totlinks, cont->links);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (cont->type) {
|
2016-06-28 17:35:35 +10:00
|
|
|
case CONT_EXPRESSION:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bExpressionCont, 1, cont->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case CONT_PYTHON:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bPythonCont, 1, cont->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
; /* error: don't know how to write this file */
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
cont = cont->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_actuators(WriteData *wd, ListBase *lb)
|
|
|
|
{
|
|
|
|
bActuator *act;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
act = lb->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (act) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bActuator, 1, act);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (act->type) {
|
2016-06-28 17:35:35 +10:00
|
|
|
case ACT_ACTION:
|
|
|
|
case ACT_SHAPEACTION:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bActionActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_SOUND:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bSoundActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_OBJECT:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bObjectActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_PROPERTY:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bPropertyActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_CAMERA:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bCameraActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_CONSTRAINT:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bConstraintActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_EDIT_OBJECT:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bEditObjectActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_SCENE:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bSceneActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_GROUP:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bGroupActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_RANDOM:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bRandomActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_MESSAGE:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bMessageActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_GAME:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bGameActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_VISIBILITY:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bVisibilityActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_2DFILTER:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bTwoDFilterActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_PARENT:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bParentActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_STATE:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bStateActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_ARMATURE:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bArmatureActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_STEERING:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bSteeringActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case ACT_MOUSE:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bMouseActuator, 1, act->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
; /* error: don't know how to write this file */
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
act = act->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static void write_motionpath(WriteData *wd, bMotionPath *mpath)
|
|
|
|
{
|
|
|
|
/* sanity checks */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (mpath == NULL) {
|
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
|
|
|
return;
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
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
|
|
|
/* firstly, just write the motionpath struct */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bMotionPath, 1, mpath);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
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
|
|
|
/* now write the array of data */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, 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
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
static void write_constraints(WriteData *wd, ListBase *conlist)
|
|
|
|
{
|
|
|
|
bConstraint *con;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (con = conlist->first; con; con = con->next) {
|
|
|
|
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* Write the specific data */
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
if (cti && con->data) {
|
|
|
|
/* firstly, just write the plain con->data struct */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_id(wd, DATA, cti->structName, 1, con->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* do any constraint specific stuff */
|
|
|
|
switch (con->type) {
|
|
|
|
case CONSTRAINT_TYPE_PYTHON:
|
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
bPythonConstraint *data = con->data;
|
2007-10-24 10:03:19 +00:00
|
|
|
bConstraintTarget *ct;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2007-10-24 10:03:19 +00:00
|
|
|
/* write targets */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (ct = data->targets.first; ct; ct = ct->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bConstraintTarget, 1, ct);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
|
2012-04-22 11:54:53 +00:00
|
|
|
* of library blocks that implement this.*/
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
IDP_WriteProperty(data->prop, wd);
|
2015-07-18 19:02:39 +10:00
|
|
|
|
2009-11-01 11:29:40 +00:00
|
|
|
break;
|
2015-07-18 19:02:39 +10:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
case CONSTRAINT_TYPE_SPLINEIK:
|
2009-11-01 11:29:40 +00:00
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
bSplineIKConstraint *data = con->data;
|
|
|
|
|
2009-11-01 11:29:40 +00:00
|
|
|
/* write points array */
|
2016-06-28 17:35:35 +10:00
|
|
|
writedata(wd, DATA, sizeof(float) * (data->numpoints), data->points);
|
2015-07-18 19:02:39 +10:00
|
|
|
|
2009-11-01 11:29:40 +00:00
|
|
|
break;
|
2015-07-18 19:02:39 +10:00
|
|
|
}
|
2007-06-18 07:41:21 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* Write the constraint */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bConstraint, 1, con);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_pose(WriteData *wd, bPose *pose)
|
|
|
|
{
|
2007-07-04 07:07:12 +00:00
|
|
|
bPoseChannel *chan;
|
== Bone Groups ==
I'm committing some work-in-progress code for "bone groups" now, as I there have been are some major bugs caused by the timeoffset stuff (some of my test files were not loading, and other files were showing all sorts of weird problems).
Anyway, in this commit, the following things for "bone groups" have been done:
* Bone groups are stored per armature (internally, this is per bPose block)
* Added controls for editing bone-groups per armature - "add", "remove", "rename". These can be found in the "Links and Materials" panel in PoseMode, beside the settings for PoseLib.
* Reorganised buttons for editing selected bones in PoseMode. I've replaced the "dist" and "weight" buttons (they existed in EditMode anyway) with a menu to choose the bone-group and the custom-shape-ob field. In the place of the old custom-shape-ob field, I've restored the "Hide" button. This might break muscle-memory a bit, but there isn't a lot of space to play with there.
Some stuff I'd been originally planning to do before committing:
* When adding keyframes for bones, an action-group with the same name as the bone's group will be added to the action, and the action-channel will be made a member of that.
* New action/bone groups have unique names (renaming/adding new should check if name exists before assigning it)
* There's a setting under Bone-Groups stuff which sets which custom-colour set is used to colour that group's bones. Currently, this is non-functional, as the necessary drawing code for armatures is not in place yet.
2008-01-20 02:55:35 +00:00
|
|
|
bActionGroup *grp;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* Write each channel */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (pose == NULL) {
|
2002-10-12 11:37:38 +00:00
|
|
|
return;
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2007-07-04 07:07:12 +00:00
|
|
|
/* Write channels */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (chan = pose->chanbase.first; chan; chan = chan->next) {
|
2009-05-18 02:25:33 +00:00
|
|
|
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
|
2012-04-22 11:54:53 +00:00
|
|
|
* of library blocks that implement this.*/
|
2016-06-28 17:35:35 +10:00
|
|
|
if (chan->prop) {
|
2009-05-18 02:25:33 +00:00
|
|
|
IDP_WriteProperty(chan->prop, wd);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
write_constraints(wd, &chan->constraints);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
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
|
|
|
write_motionpath(wd, chan->mpath);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
/* prevent crashes with autosave,
|
|
|
|
* when a bone duplicated in editmode has not yet been assigned to its posechannel */
|
|
|
|
if (chan->bone) {
|
|
|
|
/* gets restored on read, for library armatures */
|
|
|
|
chan->selectflag = chan->bone->flag & BONE_SELECTED;
|
|
|
|
}
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bPoseChannel, 1, chan);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
== Bone Groups ==
I'm committing some work-in-progress code for "bone groups" now, as I there have been are some major bugs caused by the timeoffset stuff (some of my test files were not loading, and other files were showing all sorts of weird problems).
Anyway, in this commit, the following things for "bone groups" have been done:
* Bone groups are stored per armature (internally, this is per bPose block)
* Added controls for editing bone-groups per armature - "add", "remove", "rename". These can be found in the "Links and Materials" panel in PoseMode, beside the settings for PoseLib.
* Reorganised buttons for editing selected bones in PoseMode. I've replaced the "dist" and "weight" buttons (they existed in EditMode anyway) with a menu to choose the bone-group and the custom-shape-ob field. In the place of the old custom-shape-ob field, I've restored the "Hide" button. This might break muscle-memory a bit, but there isn't a lot of space to play with there.
Some stuff I'd been originally planning to do before committing:
* When adding keyframes for bones, an action-group with the same name as the bone's group will be added to the action, and the action-channel will be made a member of that.
* New action/bone groups have unique names (renaming/adding new should check if name exists before assigning it)
* There's a setting under Bone-Groups stuff which sets which custom-colour set is used to colour that group's bones. Currently, this is non-functional, as the necessary drawing code for armatures is not in place yet.
2008-01-20 02:55:35 +00:00
|
|
|
/* Write groups */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (grp = pose->agroups.first; grp; grp = grp->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bActionGroup, 1, grp);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
/* write IK param */
|
|
|
|
if (pose->ikparam) {
|
2015-01-01 23:26:03 +11:00
|
|
|
const char *structname = BKE_pose_ikparam_get_name(pose);
|
2016-06-28 17:35:35 +10:00
|
|
|
if (structname) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_id(wd, DATA, structname, 1, pose->ikparam);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2009-09-24 21:22:24 +00:00
|
|
|
}
|
|
|
|
|
2007-07-04 07:07:12 +00:00
|
|
|
/* Write this pose */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bPose, 1, pose);
|
2009-09-24 21:22:24 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void write_defgroups(WriteData *wd, ListBase *defbase)
|
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
for (bDeformGroup *defgroup = defbase->first; defgroup; defgroup = defgroup->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bDeformGroup, 1, defgroup);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-08-19 16:49:21 +00:00
|
|
|
static void write_modifiers(WriteData *wd, ListBase *modbase)
|
2005-07-19 20:14:17 +00:00
|
|
|
{
|
|
|
|
ModifierData *md;
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (modbase == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (md = modbase->first; md; md = md->next) {
|
2015-03-30 21:17:07 +11:00
|
|
|
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
2016-06-28 17:35:35 +10:00
|
|
|
if (mti == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_id(wd, DATA, mti->structName, 1, md);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
if (md->type == eModifierType_Hook) {
|
|
|
|
HookModifierData *hmd = (HookModifierData *)md;
|
|
|
|
|
2015-02-04 07:04:21 +11:00
|
|
|
if (hmd->curfalloff) {
|
|
|
|
write_curvemapping(wd, hmd->curfalloff);
|
|
|
|
}
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
writedata(wd, DATA, sizeof(int) * hmd->totindex, hmd->indexar);
|
- added eModifierTypeFlag_RequiresOriginalData for modifiers that
can only follow deform (for example, they store mesh vertex
indices)
- added ModifierType.foreachObjectLink for iterating over Object
links inside modifier data (used for file load, relinking, etc)
- switched various modifiers_ functions to take object argument
instead of ListBase
- added user editable name field to modifiers
- bug fix, duplicate and make single user didn't relink object
pointers in modifier data
- added modifiers to outliner, needs icon
- added armature, hook, and softbody modifiers (softbody doesn't
do anything atm). added conversion of old hooks to modifiers.
NOTE-THE-FIRST: User name field is not initialized on loading 2.38 files
so if you have saved stuff with a cvs blender you will see blank names.
NOTE-THE-SECOND: Since modifiers aren't evaluated yet for non-Mesh
objects, hooks for lattices and curves are broken. Don't updated if
you actually, say, *use* Blender.
NOTE-THE-THIRD: Old hooks used a quirky weighting system during
deformation which can't be extended to modifiers. On the upside,
I doubt anyone relied on the old quirky system and the new system
makes much more sense. (Although the way falloff works is still
quite stupid I think).
2005-08-10 22:05:52 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (md->type == eModifierType_Cloth) {
|
|
|
|
ClothModifierData *clmd = (ClothModifierData *)md;
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ClothSimSettings, 1, clmd->sim_parms);
|
|
|
|
writestruct(wd, DATA, ClothCollSettings, 1, clmd->coll_parms);
|
|
|
|
writestruct(wd, DATA, EffectorWeights, 1, clmd->sim_parms->effector_weights);
|
New point cache file format:
- HEADER (beginning of each file)
* general header:
+ 8 char: "BPHYSICS"
+ 1 int: simulation type (same as PTCacheID->type)
* custom header (same for sb, particles and cloth, but can be different for new dynamics)
+ 1 int: totpoint (number of points)
+ 1 int: data_types (bit flags for what the stored data is)
- DATA (directly after header)
*totpoint times the data as specified in data_types flags
- simulation type
soft body = 0, particles = 1, cloth = 2
- data types (more can be added easily when needed)
data flag contains
----------------------------------------
index (1<<0) 1 int (index of current point)
location (1<<1) 3 float
velocity (1<<2) 3 float
rotation (1<<3) 4 float (quaternion)
avelocity (1<<4) 3 float (used for particles)
xconst (1<<4) 3 float (used for cloth)
size (1<<5) 1 float
times (1<<6) 3 float (birth, die & lifetime of particle)
boids (1<<7) 1 BoidData
Notes:
- Every frame is not nescessary since data is interpolated for the inbetween frames.
- For now every point is needed for every cached frame, the "index" data type is reserved for future usage.
- For loading external particle caches only "location" data is necessary, other needed values are determined from the given data.
- Non-dynamic data should be written into an info file if external usage is desired.
* Info file is named as normal cache files, but with frame number 0;
* "Non-dynamic" means data such as particle times.
* Written automatically when baking to disk so basically a library of particle simulations should be possible.
- Old disk cache format is supported for reading, so pre 2.5 files shouldn't break. However old style memory cache (added during 2.5 development) is not supported. To keep memory cached simulations convert the cache to disk cache before svn update and save the blend.
- External sb and cloth caches should be perfectly possible, but due to lack of testing these are not yet enabled in ui.
Other changes:
- Multiple point caches per dynamics system.
* In the future these will hopefully be nla editable etc, but for now things are simple and the current (selected) point cache is used.
* Changing the amount of cached points (for example particle count) is allowed, but might not give correct results if multiple caches are present.
- Generalization of point cache baking etc operator & rna code.
- Comb brushing particle hair didn't work smoothly.
2009-08-12 09:54:29 +00:00
|
|
|
write_pointcaches(wd, &clmd->ptcaches);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (md->type == eModifierType_Smoke) {
|
|
|
|
SmokeModifierData *smd = (SmokeModifierData *)md;
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
|
|
|
|
if (smd->domain) {
|
2010-12-16 16:09:23 +00:00
|
|
|
write_pointcaches(wd, &(smd->domain->ptcaches[0]));
|
|
|
|
|
|
|
|
/* create fake pointcache so that old blender versions can read it */
|
|
|
|
smd->domain->point_cache[1] = BKE_ptcache_add(&smd->domain->ptcaches[1]);
|
2016-06-28 17:35:35 +10:00
|
|
|
smd->domain->point_cache[1]->flag |= PTCACHE_DISK_CACHE | PTCACHE_FAKE_SMOKE;
|
2010-12-16 16:09:23 +00:00
|
|
|
smd->domain->point_cache[1]->step = 1;
|
|
|
|
|
|
|
|
write_pointcaches(wd, &(smd->domain->ptcaches[1]));
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SmokeDomainSettings, 1, smd->domain);
|
2010-12-16 16:09:23 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (smd->domain) {
|
2010-12-16 16:09:23 +00:00
|
|
|
/* cleanup the fake pointcache */
|
|
|
|
BKE_ptcache_free_list(&smd->domain->ptcaches[1]);
|
|
|
|
smd->domain->point_cache[1] = NULL;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, EffectorWeights, 1, smd->domain->effector_weights);
|
2010-12-16 16:09:23 +00:00
|
|
|
}
|
2009-10-08 10:18:14 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (smd->type & MOD_SMOKE_TYPE_FLOW) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SmokeFlowSettings, 1, smd->flow);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
else if (smd->type & MOD_SMOKE_TYPE_COLL) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SmokeCollSettings, 1, smd->coll);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (md->type == eModifierType_Fluidsim) {
|
|
|
|
FluidsimModifierData *fluidmd = (FluidsimModifierData *)md;
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, FluidsimSettings, 1, fluidmd->fss);
|
2011-05-24 07:08:58 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (md->type == eModifierType_DynamicPaint) {
|
|
|
|
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (pmd->canvas) {
|
2011-06-16 10:41:00 +00:00
|
|
|
DynamicPaintSurface *surface;
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, DynamicPaintCanvasSettings, 1, pmd->canvas);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2011-06-16 10:41:00 +00:00
|
|
|
/* write surfaces */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, DynamicPaintSurface, 1, surface);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2011-06-27 07:30:58 +00:00
|
|
|
/* write caches and effector weights */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
|
2011-06-16 10:41:00 +00:00
|
|
|
write_pointcaches(wd, &(surface->ptcaches));
|
2011-06-27 07:30:58 +00:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, EffectorWeights, 1, surface->effector_weights);
|
2011-06-27 07:30:58 +00:00
|
|
|
}
|
2011-05-24 07:08:58 +00:00
|
|
|
}
|
2012-04-28 06:31:57 +00:00
|
|
|
if (pmd->brush) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, DynamicPaintBrushSettings, 1, pmd->brush);
|
|
|
|
writestruct(wd, DATA, ColorBand, 1, pmd->brush->paint_ramp);
|
|
|
|
writestruct(wd, DATA, ColorBand, 1, pmd->brush->vel_ramp);
|
2011-05-24 07:08:58 +00:00
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (md->type == eModifierType_Collision) {
|
|
|
|
|
2012-06-30 22:49:33 +00:00
|
|
|
#if 0
|
2016-06-28 17:35:35 +10:00
|
|
|
CollisionModifierData *collmd = (CollisionModifierData *)md;
|
|
|
|
// TODO: CollisionModifier should use pointcache
|
2008-01-29 21:01:12 +00:00
|
|
|
// + have proper reset events before enabling this
|
2016-06-28 20:05:42 +10:00
|
|
|
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
|
2008-01-29 21:01:12 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (md->type == eModifierType_MeshDeform) {
|
|
|
|
MeshDeformModifierData *mmd = (MeshDeformModifierData *)md;
|
2007-11-11 22:54:14 +00:00
|
|
|
int size = mmd->dyngridsize;
|
2007-11-04 22:00:24 +00:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MDefInfluence, mmd->totinfluence, mmd->bindinfluences);
|
2013-01-08 02:06:16 +00:00
|
|
|
writedata(wd, DATA, sizeof(int) * (mmd->totvert + 1), mmd->bindoffsets);
|
|
|
|
writedata(wd, DATA, sizeof(float) * 3 * mmd->totcagevert,
|
2016-06-28 17:35:35 +10:00
|
|
|
mmd->bindcagecos);
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MDefCell, size * size * size, mmd->dyngrid);
|
|
|
|
writestruct(wd, DATA, MDefInfluence, mmd->totinfluence, mmd->dyninfluences);
|
2016-06-28 17:35:35 +10:00
|
|
|
writedata(wd, DATA, sizeof(int) * mmd->totvert, mmd->dynverts);
|
2007-11-04 22:00:24 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (md->type == eModifierType_Warp) {
|
|
|
|
WarpModifierData *tmd = (WarpModifierData *)md;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tmd->curfalloff) {
|
2011-05-01 15:16:59 +00:00
|
|
|
write_curvemapping(wd, tmd->curfalloff);
|
|
|
|
}
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (md->type == eModifierType_WeightVGEdit) {
|
|
|
|
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
|
2011-07-25 15:27:01 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (wmd->cmap_curve) {
|
2011-07-25 15:27:01 +00:00
|
|
|
write_curvemapping(wd, wmd->cmap_curve);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2011-07-25 15:27:01 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (md->type == eModifierType_LaplacianDeform) {
|
|
|
|
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
|
2013-11-24 07:00:49 +11:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
writedata(wd, DATA, sizeof(float) * lmd->total_verts * 3, lmd->vertexco);
|
2013-11-24 07:00:49 +11:00
|
|
|
}
|
2015-03-29 04:44:05 +11:00
|
|
|
else if (md->type == eModifierType_CorrectiveSmooth) {
|
|
|
|
CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
|
|
|
|
|
|
|
|
if (csmd->bind_coords) {
|
|
|
|
writedata(wd, DATA, sizeof(float[3]) * csmd->bind_coords_num, csmd->bind_coords);
|
|
|
|
}
|
|
|
|
}
|
2005-07-19 20:14:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-19 16:49:21 +00:00
|
|
|
static void write_objects(WriteData *wd, ListBase *idbase)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
Object *ob;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
ob = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (ob) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (ob->id.us > 0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_OB, Object, 1, ob);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &ob->id);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (ob->adt) {
|
|
|
|
write_animdata(wd, ob->adt);
|
|
|
|
}
|
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2016-06-28 17:35:35 +10:00
|
|
|
writedata(wd, DATA, sizeof(void *) * ob->totcol, ob->mat);
|
|
|
|
writedata(wd, DATA, sizeof(char) * ob->totcol, ob->matbits);
|
2008-04-27 18:26:20 +00:00
|
|
|
/* write_effects(wd, &ob->effect); */ /* not used anymore */
|
2002-10-12 11:37:38 +00:00
|
|
|
write_properties(wd, &ob->prop);
|
|
|
|
write_sensors(wd, &ob->sensors);
|
|
|
|
write_controllers(wd, &ob->controllers);
|
|
|
|
write_actuators(wd, &ob->actuators);
|
2010-05-04 12:31:24 +00:00
|
|
|
|
|
|
|
if (ob->type == OB_ARMATURE) {
|
|
|
|
bArmature *arm = ob->data;
|
|
|
|
if (arm && ob->pose && arm->act_bone) {
|
2011-02-13 03:21:27 +00:00
|
|
|
BLI_strncpy(ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone));
|
2010-05-04 12:31:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
write_pose(wd, ob->pose);
|
|
|
|
write_defgroups(wd, &ob->defbase);
|
|
|
|
write_constraints(wd, &ob->constraints);
|
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
|
|
|
write_motionpath(wd, ob->mpath);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, PartDeflect, 1, ob->pd);
|
|
|
|
writestruct(wd, DATA, SoftBody, 1, ob->soft);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ob->soft) {
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
write_pointcaches(wd, &ob->soft->ptcaches);
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, EffectorWeights, 1, ob->soft->effector_weights);
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
}
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BulletSoftBody, 1, ob->bsoft);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2013-01-23 05:56:22 +00:00
|
|
|
if (ob->rigidbody_object) {
|
2016-06-28 17:35:35 +10:00
|
|
|
/* TODO: if any extra data is added to handle duplis, will need separate function then */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, RigidBodyOb, 1, ob->rigidbody_object);
|
2013-01-23 05:56:22 +00:00
|
|
|
}
|
2013-01-23 05:56:56 +00:00
|
|
|
if (ob->rigidbody_constraint) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, RigidBodyCon, 1, ob->rigidbody_constraint);
|
2013-01-23 05:56:56 +00:00
|
|
|
}
|
|
|
|
|
2014-01-13 21:57:05 +01:00
|
|
|
if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ImageUser, 1, ob->iuser);
|
2014-01-13 21:57:05 +01:00
|
|
|
}
|
|
|
|
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
write_particlesystems(wd, &ob->particlesystem);
|
2009-08-19 16:49:21 +00:00
|
|
|
write_modifiers(wd, &ob->modifiers);
|
2013-12-17 14:42:47 -08:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writelist(wd, DATA, LinkData, &ob->pc_ids);
|
|
|
|
writelist(wd, DATA, LodLevel, &ob->lodlevels);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2015-08-10 15:41:28 +02:00
|
|
|
|
|
|
|
write_previews(wd, ob->preview);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
ob = ob->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-09-05 13:43:51 +00:00
|
|
|
|
|
|
|
/* flush helps the compression for undo-save */
|
|
|
|
mywrite(wd, MYWRITE_FLUSH, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void write_vfonts(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
VFont *vf;
|
2016-06-28 17:35:35 +10:00
|
|
|
PackedFile *pf;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
vf = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (vf) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (vf->id.us > 0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_VF, VFont, 1, vf);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &vf->id);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2013-01-13 12:25:56 +00:00
|
|
|
if (vf->packedfile) {
|
2002-10-12 11:37:38 +00:00
|
|
|
pf = vf->packedfile;
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, PackedFile, 1, pf);
|
2002-10-12 11:37:38 +00:00
|
|
|
writedata(wd, DATA, pf->size, pf->data);
|
|
|
|
}
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
vf = vf->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void write_keys(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Key *key;
|
|
|
|
KeyBlock *kb;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
key = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (key) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (key->id.us > 0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_KE, Key, 1, key);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &key->id);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (key->adt) {
|
|
|
|
write_animdata(wd, key->adt);
|
|
|
|
}
|
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2016-06-28 17:35:35 +10:00
|
|
|
kb = key->block.first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (kb) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, KeyBlock, 1, kb);
|
2016-06-28 17:35:35 +10:00
|
|
|
if (kb->data) {
|
|
|
|
writedata(wd, DATA, kb->totelem * key->elemsize, kb->data);
|
|
|
|
}
|
|
|
|
kb = kb->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
key = key->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-09-05 13:43:51 +00:00
|
|
|
/* flush helps the compression for undo-save */
|
|
|
|
mywrite(wd, MYWRITE_FLUSH, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void write_cameras(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Camera *cam;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
cam = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (cam) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (cam->id.us > 0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_CA, Camera, 1, cam);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &cam->id);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (cam->adt) {
|
|
|
|
write_animdata(wd, cam->adt);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
cam = cam->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_mballs(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
MetaBall *mb;
|
|
|
|
MetaElem *ml;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
mb = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (mb) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (mb->id.us > 0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_MB, MetaBall, 1, mb);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &mb->id);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2016-06-28 17:35:35 +10:00
|
|
|
writedata(wd, DATA, sizeof(void *) * mb->totcol, mb->mat);
|
|
|
|
if (mb->adt) {
|
|
|
|
write_animdata(wd, mb->adt);
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
ml = mb->elems.first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (ml) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MetaElem, 1, ml);
|
2016-06-28 17:35:35 +10:00
|
|
|
ml = ml->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
mb = mb->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_curves(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Curve *cu;
|
|
|
|
Nurb *nu;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
cu = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (cu) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (cu->id.us > 0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_CU, Curve, 1, cu);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &cu->id);
|
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2016-06-28 17:35:35 +10:00
|
|
|
writedata(wd, DATA, sizeof(void *) * cu->totcol, cu->mat);
|
|
|
|
if (cu->adt) {
|
|
|
|
write_animdata(wd, cu->adt);
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (cu->vfont) {
|
2014-01-03 17:04:42 +11:00
|
|
|
writedata(wd, DATA, cu->len + 1, cu->str);
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, CharInfo, cu->len_wchar + 1, cu->strinfo);
|
|
|
|
writestruct(wd, DATA, TextBox, cu->totbox, cu->tb);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
else {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* is also the order of reading */
|
2016-06-28 17:35:35 +10:00
|
|
|
nu = cu->nurb.first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (nu) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, Nurb, 1, nu);
|
2016-06-28 17:35:35 +10:00
|
|
|
nu = nu->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
nu = cu->nurb.first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (nu) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (nu->type == CU_BEZIER) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BezTriple, nu->pntsu, nu->bezt);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BPoint, nu->pntsu * nu->pntsv, nu->bp);
|
2016-06-28 17:35:35 +10:00
|
|
|
if (nu->knotsu) {
|
|
|
|
writedata(wd, DATA, KNOTSU(nu) * sizeof(float), nu->knotsu);
|
|
|
|
}
|
|
|
|
if (nu->knotsv) {
|
|
|
|
writedata(wd, DATA, KNOTSV(nu) * sizeof(float), nu->knotsv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nu = nu->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
cu = cu->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-09-05 13:43:51 +00:00
|
|
|
|
|
|
|
/* flush helps the compression for undo-save */
|
|
|
|
mywrite(wd, MYWRITE_FLUSH, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void write_dverts(WriteData *wd, int count, MDeformVert *dvlist)
|
|
|
|
{
|
|
|
|
if (dvlist) {
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2006-09-03 12:16:14 +00:00
|
|
|
/* Write the dvert list */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MDeformVert, count, dvlist);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2006-09-03 12:16:14 +00:00
|
|
|
/* Write deformation data for each dvert */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
if (dvlist[i].dw) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MDeformWeight, dvlist[i].totweight, dvlist[i].dw);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-25 14:27:50 +00:00
|
|
|
static void write_mdisps(WriteData *wd, int count, MDisps *mdlist, int external)
|
2009-01-06 18:59:03 +00:00
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (mdlist) {
|
2009-01-06 18:59:03 +00:00
|
|
|
int i;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MDisps, count, mdlist);
|
2012-03-24 06:18:31 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2012-03-14 06:31:38 +00:00
|
|
|
MDisps *md = &mdlist[i];
|
2012-03-24 06:18:31 +00:00
|
|
|
if (md->disps) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (!external) {
|
2013-01-08 02:06:16 +00:00
|
|
|
writedata(wd, DATA, sizeof(float) * 3 * md->totdisp, md->disps);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2009-11-25 14:27:50 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
if (md->hidden) {
|
2012-03-14 06:31:38 +00:00
|
|
|
writedata(wd, DATA, BLI_BITMAP_SIZE(md->totdisp), md->hidden);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2009-01-06 18:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-10 20:33:24 +00:00
|
|
|
static void write_grid_paint_mask(WriteData *wd, int count, GridPaintMask *grid_paint_mask)
|
|
|
|
{
|
2012-05-22 22:03:41 +00:00
|
|
|
if (grid_paint_mask) {
|
2012-05-10 20:33:24 +00:00
|
|
|
int i;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, GridPaintMask, count, grid_paint_mask);
|
2012-05-22 22:03:41 +00:00
|
|
|
for (i = 0; i < count; ++i) {
|
2012-05-10 20:33:24 +00:00
|
|
|
GridPaintMask *gpm = &grid_paint_mask[i];
|
2012-05-22 22:03:41 +00:00
|
|
|
if (gpm->data) {
|
2013-10-01 09:17:35 +00:00
|
|
|
const int gridsize = BKE_ccg_gridsize(gpm->level);
|
2012-05-10 20:33:24 +00:00
|
|
|
writedata(wd, DATA,
|
2012-05-22 22:03:41 +00:00
|
|
|
sizeof(*gpm->data) * gridsize * gridsize,
|
|
|
|
gpm->data);
|
2012-05-10 20:33:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-21 12:02:11 +02:00
|
|
|
static void write_customdata(
|
|
|
|
WriteData *wd, ID *id, int count, CustomData *data, CustomDataLayer *layers,
|
|
|
|
int partial_type, int partial_count)
|
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
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2009-12-10 14:26:06 +00:00
|
|
|
/* write external customdata (not for undo) */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (data->external && !wd->current) {
|
2015-04-23 20:43:29 +02:00
|
|
|
CustomData_external_write(data, id, CD_MASK_MESH, count, 0);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2009-11-25 14:27:50 +00:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_at_address(wd, DATA, CustomDataLayer, data->totlayer, data->layers, layers);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2015-04-23 20:43:29 +02:00
|
|
|
for (i = 0; i < data->totlayer; i++) {
|
2015-07-21 12:02:11 +02:00
|
|
|
CustomDataLayer *layer = &layers[i];
|
2010-12-03 17:05:21 +00:00
|
|
|
const char *structname;
|
2007-02-10 23:47:31 +00:00
|
|
|
int structnum, datasize;
|
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
|
|
|
|
|
|
|
if (layer->type == CD_MDEFORMVERT) {
|
|
|
|
/* layer types that allocate own memory need special handling */
|
|
|
|
write_dverts(wd, count, layer->data);
|
|
|
|
}
|
2009-01-06 18:59:03 +00:00
|
|
|
else if (layer->type == CD_MDISPS) {
|
2009-11-25 14:27:50 +00:00
|
|
|
write_mdisps(wd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL);
|
2009-01-06 18:59:03 +00:00
|
|
|
}
|
2012-05-10 20:33:24 +00:00
|
|
|
else if (layer->type == CD_PAINT_MASK) {
|
2014-04-27 00:24:11 +10:00
|
|
|
const float *layer_data = layer->data;
|
2012-05-10 20:33:24 +00:00
|
|
|
writedata(wd, DATA, sizeof(*layer_data) * count, layer_data);
|
|
|
|
}
|
|
|
|
else if (layer->type == CD_GRID_PAINT_MASK) {
|
|
|
|
write_grid_paint_mask(wd, count, layer->data);
|
|
|
|
}
|
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
|
|
|
else {
|
|
|
|
CustomData_file_write_info(layer->type, &structname, &structnum);
|
2007-02-10 23:47:31 +00:00
|
|
|
if (structnum) {
|
|
|
|
/* when using partial visibility, the MEdge and MFace layers
|
2012-04-22 11:54:53 +00:00
|
|
|
* are smaller than the original, so their type and count is
|
|
|
|
* passed to make this work */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (layer->type != partial_type) {
|
|
|
|
datasize = structnum * count;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
datasize = structnum * partial_count;
|
|
|
|
}
|
2007-02-10 23:47:31 +00:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_id(wd, DATA, structname, datasize, layer->data);
|
2007-02-10 23:47:31 +00:00
|
|
|
}
|
2012-10-31 05:39:10 +00:00
|
|
|
else {
|
2011-11-26 13:11:55 +00:00
|
|
|
printf("%s error: layer '%s':%d - can't be written to file\n",
|
|
|
|
__func__, structname, layer->type);
|
2012-10-31 05:39:10 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
2009-11-25 14:27:50 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (data->external) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, CustomDataExternal, 1, data->external);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2013-10-05 14:19:39 +00:00
|
|
|
static void write_meshes(WriteData *wd, ListBase *idbase)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
Mesh *mesh;
|
2016-06-28 21:00:00 +10:00
|
|
|
bool save_for_old_blender = false;
|
2011-12-27 08:39:55 +00:00
|
|
|
|
2011-12-28 15:07:00 +00:00
|
|
|
#ifdef USE_BMESH_SAVE_AS_COMPAT
|
2011-12-27 13:44:15 +00:00
|
|
|
save_for_old_blender = wd->use_mesh_compat; /* option to save with older mesh format */
|
2011-12-27 08:39:55 +00:00
|
|
|
#endif
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
mesh = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (mesh) {
|
2015-07-21 12:02:11 +02:00
|
|
|
CustomDataLayer *vlayers = NULL, vlayers_buff[CD_TEMP_CHUNK_SIZE];
|
|
|
|
CustomDataLayer *elayers = NULL, elayers_buff[CD_TEMP_CHUNK_SIZE];
|
|
|
|
CustomDataLayer *flayers = NULL, flayers_buff[CD_TEMP_CHUNK_SIZE];
|
|
|
|
CustomDataLayer *llayers = NULL, llayers_buff[CD_TEMP_CHUNK_SIZE];
|
|
|
|
CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE];
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (mesh->id.us > 0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2011-12-27 08:39:55 +00:00
|
|
|
if (!save_for_old_blender) {
|
2013-04-12 15:33:09 +00:00
|
|
|
/* write a copy of the mesh, don't modify in place because it is
|
|
|
|
* not thread safe for threaded renders that are reading this */
|
|
|
|
Mesh *old_mesh = mesh;
|
|
|
|
Mesh copy_mesh = *mesh;
|
|
|
|
mesh = ©_mesh;
|
|
|
|
|
2015-04-23 20:43:29 +02:00
|
|
|
#ifdef USE_BMESH_SAVE_WITHOUT_MFACE
|
2012-03-18 07:38:51 +00:00
|
|
|
/* cache only - don't write */
|
2012-01-02 12:37:58 +00:00
|
|
|
mesh->mface = NULL;
|
|
|
|
mesh->totface = 0;
|
2012-10-31 05:39:10 +00:00
|
|
|
memset(&mesh->fdata, 0, sizeof(mesh->fdata));
|
2015-04-23 20:43:29 +02:00
|
|
|
#endif /* USE_BMESH_SAVE_WITHOUT_MFACE */
|
|
|
|
|
2015-07-21 12:02:11 +02:00
|
|
|
/**
|
|
|
|
* Those calls:
|
|
|
|
* - Reduce mesh->xdata.totlayer to number of layers to write.
|
|
|
|
* - Fill xlayers with those layers to be written.
|
|
|
|
* Note that mesh->xdata is from now on invalid for Blender, but this is why the whole mesh is
|
|
|
|
* a temp local copy!
|
|
|
|
*/
|
|
|
|
CustomData_file_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff));
|
|
|
|
CustomData_file_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff));
|
2015-05-01 16:11:55 +02:00
|
|
|
#ifndef USE_BMESH_SAVE_WITHOUT_MFACE /* Do not copy org fdata in this case!!! */
|
2015-07-21 12:02:11 +02:00
|
|
|
CustomData_file_write_prepare(&mesh->fdata, &flayers, flayers_buff, ARRAY_SIZE(flayers_buff));
|
|
|
|
#else
|
|
|
|
flayers = flayers_buff;
|
2015-05-01 16:11:55 +02:00
|
|
|
#endif
|
2015-07-21 12:02:11 +02:00
|
|
|
CustomData_file_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff));
|
|
|
|
CustomData_file_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
|
2012-01-02 12:37:58 +00:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_at_address(wd, ID_ME, Mesh, 1, old_mesh, mesh);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &mesh->id);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2011-12-27 08:39:55 +00:00
|
|
|
/* direct data */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (mesh->adt) {
|
|
|
|
write_animdata(wd, mesh->adt);
|
|
|
|
}
|
2006-11-17 06:14:15 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
writedata(wd, DATA, sizeof(void *) * mesh->totcol, mesh->mat);
|
2012-04-11 11:52:21 +00:00
|
|
|
writedata(wd, DATA, sizeof(MSelect) * mesh->totselect, mesh->mselect);
|
2004-07-08 20:38:27 +00:00
|
|
|
|
2015-07-21 12:02:11 +02:00
|
|
|
write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, vlayers, -1, 0);
|
|
|
|
write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, elayers, -1, 0);
|
2012-01-02 12:37:58 +00:00
|
|
|
/* fdata is really a dummy - written so slots align */
|
2015-07-21 12:02:11 +02:00
|
|
|
write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, flayers, -1, 0);
|
|
|
|
write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, -1, 0);
|
|
|
|
write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, -1, 0);
|
2015-04-23 20:43:29 +02:00
|
|
|
|
2013-04-12 15:33:09 +00:00
|
|
|
/* restore pointer */
|
|
|
|
mesh = old_mesh;
|
2011-12-27 08:39:55 +00:00
|
|
|
}
|
|
|
|
else {
|
2006-11-17 06:14:15 +00:00
|
|
|
|
2011-12-28 15:07:00 +00:00
|
|
|
#ifdef USE_BMESH_SAVE_AS_COMPAT
|
2013-04-12 15:33:09 +00:00
|
|
|
/* write a copy of the mesh, don't modify in place because it is
|
|
|
|
* not thread safe for threaded renders that are reading this */
|
|
|
|
Mesh *old_mesh = mesh;
|
|
|
|
Mesh copy_mesh = *mesh;
|
|
|
|
mesh = ©_mesh;
|
2004-07-08 20:38:27 +00:00
|
|
|
|
2011-12-27 08:39:55 +00:00
|
|
|
mesh->mpoly = NULL;
|
|
|
|
mesh->mface = NULL;
|
|
|
|
mesh->totface = 0;
|
|
|
|
mesh->totpoly = 0;
|
|
|
|
mesh->totloop = 0;
|
2012-11-05 05:52:21 +00:00
|
|
|
CustomData_reset(&mesh->fdata);
|
|
|
|
CustomData_reset(&mesh->pdata);
|
|
|
|
CustomData_reset(&mesh->ldata);
|
2011-12-27 08:39:55 +00:00
|
|
|
mesh->edit_btmesh = NULL;
|
|
|
|
|
2012-08-17 14:43:20 +00:00
|
|
|
/* now fill in polys to mfaces */
|
2015-07-21 12:02:11 +02:00
|
|
|
/* XXX This breaks writing desing, by using temp allocated memory, which will likely generate
|
2015-09-14 02:21:15 +10:00
|
|
|
* duplicates in stored 'old' addresses.
|
2015-07-21 12:02:11 +02:00
|
|
|
* This is very bad, but do not see easy way to avoid this, aside from generating those data
|
|
|
|
* outside of save process itself.
|
|
|
|
* Maybe we can live with this, though?
|
|
|
|
*/
|
2013-04-12 15:33:09 +00:00
|
|
|
mesh->totface = BKE_mesh_mpoly_to_mface(&mesh->fdata, &old_mesh->ldata, &old_mesh->pdata,
|
|
|
|
mesh->totface, old_mesh->totloop, old_mesh->totpoly);
|
2011-12-27 08:39:55 +00:00
|
|
|
|
2013-03-17 19:55:10 +00:00
|
|
|
BKE_mesh_update_customdata_pointers(mesh, false);
|
2011-12-27 08:39:55 +00:00
|
|
|
|
2015-07-21 12:02:11 +02:00
|
|
|
CustomData_file_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff));
|
|
|
|
CustomData_file_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff));
|
|
|
|
CustomData_file_write_prepare(&mesh->fdata, &flayers, flayers_buff, ARRAY_SIZE(flayers_buff));
|
|
|
|
#if 0
|
|
|
|
CustomData_file_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff));
|
|
|
|
CustomData_file_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
|
|
|
|
#endif
|
2015-04-23 20:43:29 +02:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_at_address(wd, ID_ME, Mesh, 1, old_mesh, mesh);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &mesh->id);
|
2011-12-27 08:39:55 +00:00
|
|
|
|
|
|
|
/* direct data */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (mesh->adt) {
|
|
|
|
write_animdata(wd, mesh->adt);
|
|
|
|
}
|
2011-12-27 08:39:55 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
writedata(wd, DATA, sizeof(void *) * mesh->totcol, mesh->mat);
|
2012-04-11 11:52:21 +00:00
|
|
|
/* writedata(wd, DATA, sizeof(MSelect) * mesh->totselect, mesh->mselect); */ /* pre-bmesh NULL's */
|
2011-12-27 08:39:55 +00:00
|
|
|
|
2015-07-21 12:02:11 +02:00
|
|
|
write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, vlayers, -1, 0);
|
|
|
|
write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, elayers, -1, 0);
|
|
|
|
write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, flayers, -1, 0);
|
2011-12-27 08:39:55 +00:00
|
|
|
/* harmless for older blender versioins but _not_ writing these keeps file size down */
|
2012-04-22 11:54:53 +00:00
|
|
|
#if 0
|
2015-07-21 12:02:11 +02:00
|
|
|
write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, -1, 0);
|
|
|
|
write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, -1, 0);
|
2012-04-22 11:54:53 +00:00
|
|
|
#endif
|
2011-12-27 08:39:55 +00:00
|
|
|
|
|
|
|
CustomData_free(&mesh->fdata, mesh->totface);
|
2015-07-21 12:02:11 +02:00
|
|
|
flayers = NULL;
|
2011-12-27 08:39:55 +00:00
|
|
|
|
2013-04-12 15:33:09 +00:00
|
|
|
/* restore pointer */
|
|
|
|
mesh = old_mesh;
|
2011-12-28 15:07:00 +00:00
|
|
|
#endif /* USE_BMESH_SAVE_AS_COMPAT */
|
2011-12-27 08:39:55 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2015-07-21 12:02:11 +02:00
|
|
|
|
|
|
|
if (vlayers && vlayers != vlayers_buff) {
|
|
|
|
MEM_freeN(vlayers);
|
|
|
|
}
|
|
|
|
if (elayers && elayers != elayers_buff) {
|
|
|
|
MEM_freeN(elayers);
|
|
|
|
}
|
|
|
|
if (flayers && flayers != flayers_buff) {
|
|
|
|
MEM_freeN(flayers);
|
|
|
|
}
|
|
|
|
if (llayers && llayers != llayers_buff) {
|
|
|
|
MEM_freeN(llayers);
|
|
|
|
}
|
|
|
|
if (players && players != players_buff) {
|
|
|
|
MEM_freeN(players);
|
|
|
|
}
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
mesh = mesh->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-03 12:16:14 +00:00
|
|
|
static void write_lattices(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Lattice *lt;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
lt = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (lt) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (lt->id.us > 0 || wd->current) {
|
2006-09-03 12:16:14 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_LT, Lattice, 1, lt);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, <->id);
|
|
|
|
|
2010-12-13 06:31:49 +00:00
|
|
|
/* write animdata */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (lt->adt) {
|
|
|
|
write_animdata(wd, lt->adt);
|
|
|
|
}
|
|
|
|
|
2006-09-03 12:16:14 +00:00
|
|
|
/* direct data */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BPoint, lt->pntsu * lt->pntsv * lt->pntsw, lt->def);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
write_dverts(wd, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
|
|
|
|
|
2006-09-03 12:16:14 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
lt = lt->id.next;
|
2006-09-03 12:16:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
static void write_images(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Image *ima;
|
2016-06-28 17:35:35 +10:00
|
|
|
PackedFile *pf;
|
2015-04-06 10:40:12 -03:00
|
|
|
ImageView *iv;
|
|
|
|
ImagePackedFile *imapf;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
ima = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (ima) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (ima->id.us > 0 || wd->current) {
|
2015-05-26 14:43:50 +05:00
|
|
|
/* Some trickery to keep forward compatibility of packed images. */
|
|
|
|
BLI_assert(ima->packedfile == NULL);
|
|
|
|
if (ima->packedfiles.first != NULL) {
|
|
|
|
imapf = ima->packedfiles.first;
|
|
|
|
ima->packedfile = imapf->packedfile;
|
|
|
|
}
|
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_IM, Image, 1, ima);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &ima->id);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ImagePackedFile, 1, imapf);
|
2015-04-06 10:40:12 -03:00
|
|
|
if (imapf->packedfile) {
|
|
|
|
pf = imapf->packedfile;
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, PackedFile, 1, pf);
|
2015-04-06 10:40:12 -03:00
|
|
|
writedata(wd, DATA, pf->size, pf->data);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2006-06-05 11:07:15 +00:00
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
write_previews(wd, ima->preview);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (iv = ima->views.first; iv; iv = iv->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ImageView, 1, iv);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, Stereo3dFormat, 1, ima->stereo3d_format);
|
2015-05-26 14:43:50 +05:00
|
|
|
|
|
|
|
ima->packedfile = NULL;
|
2009-07-10 16:55:49 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
ima = ima->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-09-05 13:43:51 +00:00
|
|
|
/* flush helps the compression for undo-save */
|
|
|
|
mywrite(wd, MYWRITE_FLUSH, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void write_textures(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Tex *tex;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
tex = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (tex) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (tex->id.us > 0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_TE, Tex, 1, tex);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &tex->id);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (tex->adt) {
|
|
|
|
write_animdata(wd, tex->adt);
|
|
|
|
}
|
2009-02-20 16:39:39 +00:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (tex->coba) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ColorBand, 1, tex->coba);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
if (tex->type == TEX_ENVMAP && tex->env) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, EnvMap, 1, tex->env);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tex->type == TEX_POINTDENSITY && tex->pd) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, PointDensity, 1, tex->pd);
|
2016-06-28 17:35:35 +10:00
|
|
|
if (tex->pd->coba) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ColorBand, 1, tex->pd->coba);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
if (tex->pd->falloff_curve) {
|
|
|
|
write_curvemapping(wd, tex->pd->falloff_curve);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tex->type == TEX_VOXELDATA) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, VoxelData, 1, tex->vd);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
if (tex->type == TEX_OCEAN && tex->ot) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, OceanTex, 1, tex->ot);
|
2008-11-09 01:16:12 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2008-11-12 22:03:11 +00:00
|
|
|
/* nodetree is integral part of texture, no libdata */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tex->nodetree) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bNodeTree, 1, tex->nodetree);
|
2008-11-12 22:03:11 +00:00
|
|
|
write_nodetree(wd, tex->nodetree);
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
write_previews(wd, tex->preview);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
tex = tex->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-09-05 13:43:51 +00:00
|
|
|
|
|
|
|
/* flush helps the compression for undo-save */
|
|
|
|
mywrite(wd, MYWRITE_FLUSH, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void write_materials(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Material *ma;
|
|
|
|
int a;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
ma = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (ma) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (ma->id.us > 0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_MA, Material, 1, ma);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &ma->id);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (ma->adt) {
|
|
|
|
write_animdata(wd, ma->adt);
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (a = 0; a < MAX_MTEX; a++) {
|
|
|
|
if (ma->mtex[a]) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MTex, 1, ma->mtex[a]);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
if (ma->ramp_col) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ColorBand, 1, ma->ramp_col);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
if (ma->ramp_spec) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ColorBand, 1, ma->ramp_spec);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
/* nodetree is integral part of material, no libdata */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ma->nodetree) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bNodeTree, 1, ma->nodetree);
|
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
|
|
|
write_nodetree(wd, ma->nodetree);
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
}
|
2007-09-02 17:25:03 +00:00
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
write_previews(wd, ma->preview);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
ma = ma->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_worlds(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
World *wrld;
|
|
|
|
int a;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
wrld = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (wrld) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (wrld->id.us > 0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_WO, World, 1, wrld);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &wrld->id);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (wrld->adt) {
|
|
|
|
write_animdata(wd, wrld->adt);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (a = 0; a < MAX_MTEX; a++) {
|
|
|
|
if (wrld->mtex[a]) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MTex, 1, wrld->mtex[a]);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2011-11-02 18:55:32 +00:00
|
|
|
|
2014-05-01 22:57:02 +09:00
|
|
|
/* nodetree is integral part of world, no libdata */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (wrld->nodetree) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bNodeTree, 1, wrld->nodetree);
|
2011-11-02 18:55:32 +00:00
|
|
|
write_nodetree(wd, wrld->nodetree);
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
write_previews(wd, wrld->preview);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
wrld = wrld->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_lamps(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Lamp *la;
|
|
|
|
int a;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
la = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (la) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (la->id.us > 0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_LA, Lamp, 1, la);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &la->id);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (la->adt) {
|
|
|
|
write_animdata(wd, la->adt);
|
|
|
|
}
|
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (a = 0; a < MAX_MTEX; a++) {
|
|
|
|
if (la->mtex[a]) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MTex, 1, la->mtex[a]);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
if (la->curfalloff) {
|
2012-10-21 05:46:41 +00:00
|
|
|
write_curvemapping(wd, la->curfalloff);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
2011-11-02 18:55:32 +00:00
|
|
|
/* nodetree is integral part of lamps, no libdata */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (la->nodetree) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bNodeTree, 1, la->nodetree);
|
2011-11-02 18:55:32 +00:00
|
|
|
write_nodetree(wd, la->nodetree);
|
|
|
|
}
|
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
write_previews(wd, la->preview);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
la = la->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-19 15:41:56 +00:00
|
|
|
static void write_sequence_modifiers(WriteData *wd, ListBase *modbase)
|
|
|
|
{
|
|
|
|
SequenceModifierData *smd;
|
|
|
|
|
|
|
|
for (smd = modbase->first; smd; smd = smd->next) {
|
2015-03-30 21:17:07 +11:00
|
|
|
const SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type);
|
2012-08-19 15:41:56 +00:00
|
|
|
|
|
|
|
if (smti) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_id(wd, DATA, smti->struct_name, 1, smd);
|
2012-08-19 15:41:56 +00:00
|
|
|
|
|
|
|
if (smd->type == seqModifierType_Curves) {
|
2016-06-28 17:35:35 +10:00
|
|
|
CurvesModifierData *cmd = (CurvesModifierData *)smd;
|
2012-08-19 15:41:56 +00:00
|
|
|
|
|
|
|
write_curvemapping(wd, &cmd->curve_mapping);
|
|
|
|
}
|
|
|
|
else if (smd->type == seqModifierType_HueCorrect) {
|
2016-06-28 17:35:35 +10:00
|
|
|
HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
|
2012-08-19 15:41:56 +00:00
|
|
|
|
|
|
|
write_curvemapping(wd, &hcmd->curve_mapping);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SequenceModifierData, 1, smd);
|
2012-08-19 15:41:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-10-12 11:37:38 +00: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
|
|
|
static void write_view_settings(WriteData *wd, ColorManagedViewSettings *view_settings)
|
|
|
|
{
|
|
|
|
if (view_settings->curve_mapping) {
|
|
|
|
write_curvemapping(wd, view_settings->curve_mapping);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-11 15:07:04 +01:00
|
|
|
static void write_paint(WriteData *wd, Paint *p)
|
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
if (p->cavity_curve) {
|
2015-02-11 15:07:04 +01:00
|
|
|
write_curvemapping(wd, p->cavity_curve);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2015-02-11 15:07:04 +01:00
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
static void write_scenes(WriteData *wd, ListBase *scebase)
|
|
|
|
{
|
|
|
|
Scene *sce;
|
|
|
|
Base *base;
|
|
|
|
Editing *ed;
|
|
|
|
Sequence *seq;
|
2004-11-13 12:55:59 +00:00
|
|
|
MetaStack *ms;
|
2002-10-12 11:37:38 +00:00
|
|
|
Strip *strip;
|
Added the new Timeline Window, copied from Tuhopuu, coded by Matt Ebb.
Main change is that it's an own Space type now, not part of the Audio
window... the audio window should restrict to own options. This way
functionality is nicely separated.
Since it's the first time I added a new space (since long!) I've made an
extensive tutorial as well. You can find that here:
http://www.blender3d.org/cms/Adding_new_Space_Window.557.0.html
Notes for using timewindow;
- Add time markers with MKey
- CTRL+M gives option to name Marker
- Markers cannot be moved yet...
- Pageup-Pagedown keys moves current frame to next-prev Marker
- Xkey removes Markers
- If an object has Ipos or an Action, it draws key lines
- CTRL+Pageup-Pagedown moves current frame to next-prev Key
- Press S or E to set start/end frame for playback
Notes about the implementation in Tuhopuu:
- Add new Marker now selects new, deselects others
- Selecting Marker didn't work like elsewhere in Blender, on click it
should deselect all, except the indicated Marker. Not when holding SHIFT
of course
- Not exported functions are static now
- Removed unused defines (MARKER_NONE NEXT_AVAIL)
- Drawing order was confusing, doing too many matrix calls
- Removed not needed scrollbar, added new function to draw time values.
(Has advantage the MMB scroll works not confusing on a scrollbar)
- Added proper support for 'frame mapping'
- The string button (name Marker) had a bug (checked str[64] while str
was only 64 long)
- String button itself didn't allow "OK on enter"
- Made frame buttons in header larger, the arrows overlapped
- Removed support for negative frame values, that won't work so simple!
2005-05-05 17:19:21 +00:00
|
|
|
TimeMarker *marker;
|
=== Custom Transform Orientation ===
Custom Orientations can be added with Ctrl-Shift-C (hotkey suggestions are welcomed), this adds and select the new alignment. Custom Orientations can also be added, deleted, selected from the Transform Orientations panel (View -> Transform Orientations). Standard orientations (global, local, normal, view) can also be selected from this panel.
If you plan on using only a single custom orientation and don't really need a list, I suggest you use the hotkey as it adds and selects at the same time.
Custom Orientations are save in the scene and are selected per 3D view (like normal orientation).
Adding from an object, the orientation is a normalized version of the object's orientation.
Adding from mesh data, a single element (vertex, edge, face) must be selected in its respective selection mode. Vertex orientation Z-axis is based on the normal, edge Z-axis on the edge itself (X-axis is on the XoY plane when possible, Y-axis is perpendicular to the rest). Face orientation Z-axis is the face normal, X-axis is perpendicular to the first edge, Y-axis is perpendicular to the rest.
(More logical orientations can be suggested).
I plan to add: 2 vertice (connected or not) => edge orientation , 3 vertice = face orientation
Differences from the patch:
- orientations no longer link back to the object they came from, everything is copy on creation.
- orientations are overwritten based on name (if you add an orientation with the same name as one that already exists, it overwrites the old one)
2008-01-13 18:24:09 +00:00
|
|
|
TransformOrientation *ts;
|
Orange; more render & compo stuff!
-> Rendering in RenderLayers
It's important to distinguish a 'render layer' from a 'pass'. The first is
control over the main pipeline itself, to indicate what geometry is being
is rendered. The 'pass' (not in this commit!) is related to internal
shading code, like shadow/spec/AO/normals/etc.
Options for RenderLayers now are:
- Indicate which 3d 'view layers' have to be included (so you can render
front and back separately)
- "Solid", all solid faces, includes sky at the moment too
- "ZTransp", all transparent faces
- "Halo", the halos
- "Strand", the particle strands (not coded yet...)
Currently only 2 'passes' are exported for render, which is the "Combined"
buffer and the "Z. The latter now works, and can be turned on/off.
Note that all layers are still fully kept in memory now, saving the tiles
and layers to disk (in exr) is also todo.
-> New Blur options
The existing Blur Node (compositor) now has an optional input image. This
has to be a 'value buffer', which can be a Zbuffer, or any mask you can
think of. The input values have to be in the 0-1 range, so another new
node was added too "Map Value".
The value input can also be used to tweak blur size with the (todo)
Time Node.
Temporal screenies:
http://www.blender.org/bf/rt.jpg
http://www.blender.org/bf/rt1.jpg
http://www.blender.org/bf/rt2.jpg
BTW: The compositor is very slow still, it recalulates all nodes on each
change still. Persistant memory and dependency checks is coming!
2006-01-26 22:18:46 +00:00
|
|
|
SceneRenderLayer *srl;
|
2015-04-06 10:40:12 -03:00
|
|
|
SceneRenderView *srv;
|
2009-08-17 00:39:00 +00:00
|
|
|
ToolSettings *tos;
|
2013-03-23 03:00:37 +00:00
|
|
|
FreestyleModuleConfig *fmc;
|
|
|
|
FreestyleLineSet *fls;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
sce = scebase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (sce) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_SCE, Scene, 1, sce);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &sce->id);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (sce->adt) {
|
|
|
|
write_animdata(wd, sce->adt);
|
|
|
|
}
|
2009-02-11 12:19:42 +00:00
|
|
|
write_keyingsets(wd, &sce->keyingsets);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2016-06-28 17:35:35 +10:00
|
|
|
base = sce->base.first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (base) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, Base, 1, base);
|
2016-06-28 17:35:35 +10:00
|
|
|
base = base->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2009-08-17 00:39:00 +00:00
|
|
|
tos = sce->toolsettings;
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ToolSettings, 1, tos);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tos->vpaint) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, VPaint, 1, tos->vpaint);
|
2016-06-22 14:02:51 +10:00
|
|
|
write_paint(wd, &tos->vpaint->paint);
|
2009-08-17 02:49:31 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tos->wpaint) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, VPaint, 1, tos->wpaint);
|
2016-06-22 14:02:51 +10:00
|
|
|
write_paint(wd, &tos->wpaint->paint);
|
2009-08-17 02:49:31 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tos->sculpt) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, Sculpt, 1, tos->sculpt);
|
2016-06-22 14:02:51 +10:00
|
|
|
write_paint(wd, &tos->sculpt->paint);
|
2009-08-16 19:50:00 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tos->uvsculpt) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, UvSculpt, 1, tos->uvsculpt);
|
2016-06-22 14:02:51 +10:00
|
|
|
write_paint(wd, &tos->uvsculpt->paint);
|
2012-01-17 16:31:13 +00:00
|
|
|
}
|
2006-11-06 01:08:26 +00:00
|
|
|
|
2015-02-11 15:07:04 +01:00
|
|
|
write_paint(wd, &tos->imapaint.paint);
|
2006-11-06 01:08:26 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
ed = sce->ed;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ed) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, Editing, 1, ed);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* reset write flags too */
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
SEQ_BEGIN(ed, seq)
|
2012-04-30 16:22:40 +00:00
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
if (seq->strip) {
|
|
|
|
seq->strip->done = false;
|
|
|
|
}
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, Sequence, 1, seq);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-12-15 05:21:44 +00:00
|
|
|
SEQ_END
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
SEQ_BEGIN(ed, seq)
|
2012-04-30 16:22:40 +00:00
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
if (seq->strip && seq->strip->done == 0) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write strip with 'done' at 0 because readfile */
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (seq->effectdata) {
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (seq->type) {
|
2016-06-28 17:35:35 +10:00
|
|
|
case SEQ_TYPE_COLOR:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SolidColorVars, 1, seq->effectdata);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SEQ_TYPE_SPEED:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpeedControlVars, 1, seq->effectdata);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SEQ_TYPE_WIPE:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, WipeVars, 1, seq->effectdata);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SEQ_TYPE_GLOW:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, GlowVars, 1, seq->effectdata);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SEQ_TYPE_TRANSFORM:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, TransformVars, 1, seq->effectdata);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SEQ_TYPE_GAUSSIAN_BLUR:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, GaussianBlurVars, 1, seq->effectdata);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case SEQ_TYPE_TEXT:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, TextVars, 1, seq->effectdata);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
2004-06-23 18:22:51 +00:00
|
|
|
}
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, Stereo3dFormat, 1, seq->stereo3d_format);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
strip = seq->strip;
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, Strip, 1, strip);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (seq->flag & SEQ_USE_CROP && strip->crop) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, StripCrop, 1, strip->crop);
|
2007-12-25 15:31:36 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (seq->flag & SEQ_USE_TRANSFORM && strip->transform) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, StripTransform, 1, strip->transform);
|
2007-12-25 15:31:36 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (seq->flag & SEQ_USE_PROXY && strip->proxy) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, StripProxy, 1, strip->proxy);
|
2007-12-25 15:31:36 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
if (seq->type == SEQ_TYPE_IMAGE) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, StripElem,
|
2016-06-28 17:35:35 +10:00
|
|
|
MEM_allocN_len(strip->stripdata) / sizeof(struct StripElem),
|
|
|
|
strip->stripdata);
|
|
|
|
}
|
|
|
|
else if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, StripElem, 1, strip->stripdata);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
strip->done = true;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2012-08-19 15:41:56 +00:00
|
|
|
|
2015-04-02 21:05:12 +11:00
|
|
|
if (seq->prop) {
|
|
|
|
IDP_WriteProperty(seq->prop, wd);
|
|
|
|
}
|
|
|
|
|
2012-08-19 15:41:56 +00:00
|
|
|
write_sequence_modifiers(wd, &seq->modifiers);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-12-15 05:21:44 +00:00
|
|
|
SEQ_END
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2004-11-13 12:55:59 +00:00
|
|
|
/* new; meta stack too, even when its nasty restore code */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (ms = ed->metastack.first; ms; ms = ms->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MetaStack, 1, ms);
|
2004-11-13 12:55:59 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if (sce->r.avicodecdata) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, AviCodecData, 1, sce->r.avicodecdata);
|
2016-06-28 17:35:35 +10:00
|
|
|
if (sce->r.avicodecdata->lpFormat) {
|
|
|
|
writedata(wd, DATA, sce->r.avicodecdata->cbFormat, sce->r.avicodecdata->lpFormat);
|
|
|
|
}
|
|
|
|
if (sce->r.avicodecdata->lpParms) {
|
|
|
|
writedata(wd, DATA, sce->r.avicodecdata->cbParms, sce->r.avicodecdata->lpParms);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2003-05-21 01:21:07 +00:00
|
|
|
if (sce->r.qtcodecdata) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, QuicktimeCodecData, 1, sce->r.qtcodecdata);
|
2016-06-28 17:35:35 +10:00
|
|
|
if (sce->r.qtcodecdata->cdParms) {
|
|
|
|
writedata(wd, DATA, sce->r.qtcodecdata->cdSize, sce->r.qtcodecdata->cdParms);
|
|
|
|
}
|
2003-05-21 01:21:07 +00:00
|
|
|
}
|
2008-05-11 20:40:55 +00:00
|
|
|
if (sce->r.ffcodecdata.properties) {
|
|
|
|
IDP_WriteProperty(sce->r.ffcodecdata.properties, wd);
|
|
|
|
}
|
2003-05-21 01:21:07 +00:00
|
|
|
|
Added the new Timeline Window, copied from Tuhopuu, coded by Matt Ebb.
Main change is that it's an own Space type now, not part of the Audio
window... the audio window should restrict to own options. This way
functionality is nicely separated.
Since it's the first time I added a new space (since long!) I've made an
extensive tutorial as well. You can find that here:
http://www.blender3d.org/cms/Adding_new_Space_Window.557.0.html
Notes for using timewindow;
- Add time markers with MKey
- CTRL+M gives option to name Marker
- Markers cannot be moved yet...
- Pageup-Pagedown keys moves current frame to next-prev Marker
- Xkey removes Markers
- If an object has Ipos or an Action, it draws key lines
- CTRL+Pageup-Pagedown moves current frame to next-prev Key
- Press S or E to set start/end frame for playback
Notes about the implementation in Tuhopuu:
- Add new Marker now selects new, deselects others
- Selecting Marker didn't work like elsewhere in Blender, on click it
should deselect all, except the indicated Marker. Not when holding SHIFT
of course
- Not exported functions are static now
- Removed unused defines (MARKER_NONE NEXT_AVAIL)
- Drawing order was confusing, doing too many matrix calls
- Removed not needed scrollbar, added new function to draw time values.
(Has advantage the MMB scroll works not confusing on a scrollbar)
- Added proper support for 'frame mapping'
- The string button (name Marker) had a bug (checked str[64] while str
was only 64 long)
- String button itself didn't allow "OK on enter"
- Made frame buttons in header larger, the arrows overlapped
- Removed support for negative frame values, that won't work so simple!
2005-05-05 17:19:21 +00:00
|
|
|
/* writing dynamic list of TimeMarkers to the blend file */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (marker = sce->markers.first; marker; marker = marker->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, TimeMarker, 1, marker);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
=== Custom Transform Orientation ===
Custom Orientations can be added with Ctrl-Shift-C (hotkey suggestions are welcomed), this adds and select the new alignment. Custom Orientations can also be added, deleted, selected from the Transform Orientations panel (View -> Transform Orientations). Standard orientations (global, local, normal, view) can also be selected from this panel.
If you plan on using only a single custom orientation and don't really need a list, I suggest you use the hotkey as it adds and selects at the same time.
Custom Orientations are save in the scene and are selected per 3D view (like normal orientation).
Adding from an object, the orientation is a normalized version of the object's orientation.
Adding from mesh data, a single element (vertex, edge, face) must be selected in its respective selection mode. Vertex orientation Z-axis is based on the normal, edge Z-axis on the edge itself (X-axis is on the XoY plane when possible, Y-axis is perpendicular to the rest). Face orientation Z-axis is the face normal, X-axis is perpendicular to the first edge, Y-axis is perpendicular to the rest.
(More logical orientations can be suggested).
I plan to add: 2 vertice (connected or not) => edge orientation , 3 vertice = face orientation
Differences from the patch:
- orientations no longer link back to the object they came from, everything is copy on creation.
- orientations are overwritten based on name (if you add an orientation with the same name as one that already exists, it overwrites the old one)
2008-01-13 18:24:09 +00:00
|
|
|
/* writing dynamic list of TransformOrientations to the blend file */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (ts = sce->transform_spaces.first; ts; ts = ts->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, TransformOrientation, 1, ts);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
2012-12-11 22:00:22 +00:00
|
|
|
for (srl = sce->r.layers.first; srl; srl = srl->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SceneRenderLayer, 1, srl);
|
2013-04-08 04:39:09 +00:00
|
|
|
for (fmc = srl->freestyleConfig.modules.first; fmc; fmc = fmc->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, FreestyleModuleConfig, 1, fmc);
|
2013-03-23 03:00:37 +00:00
|
|
|
}
|
2013-04-08 04:39:09 +00:00
|
|
|
for (fls = srl->freestyleConfig.linesets.first; fls; fls = fls->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, FreestyleLineSet, 1, fls);
|
2012-12-20 07:57:26 +00:00
|
|
|
}
|
2009-10-07 07:18:50 +00:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
/* writing MultiView to the blend file */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (srv = sce->r.views.first; srv; srv = srv->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SceneRenderView, 1, srv);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (sce->nodetree) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bNodeTree, 1, sce->nodetree);
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
write_nodetree(wd, sce->nodetree);
|
|
|
|
}
|
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
|
|
|
|
|
|
|
write_view_settings(wd, &sce->view_settings);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2013-01-23 05:56:22 +00:00
|
|
|
/* writing RigidBodyWorld data to the blend file */
|
|
|
|
if (sce->rigidbody_world) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, RigidBodyWorld, 1, sce->rigidbody_world);
|
|
|
|
writestruct(wd, DATA, EffectorWeights, 1, sce->rigidbody_world->effector_weights);
|
2013-01-23 05:56:34 +00:00
|
|
|
write_pointcaches(wd, &(sce->rigidbody_world->ptcaches));
|
2013-01-23 05:56:22 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2015-08-10 15:41:28 +02:00
|
|
|
write_previews(wd, sce->preview);
|
2015-10-27 19:00:51 +05:00
|
|
|
write_curvemapping_curves(wd, &sce->r.mblur_shutter_curve);
|
2015-08-10 15:41:28 +02:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
sce = sce->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-09-05 13:43:51 +00:00
|
|
|
/* flush helps the compression for undo-save */
|
|
|
|
mywrite(wd, MYWRITE_FLUSH, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2.5
Patch from Joshua, converting Grease Pencil to 2.5.
All GP data now is an ID block, allowing re-use, link and append.
For better contextual control within 2.5, these GP ID's will get
linked to actual data, like NodeTrees, Scenes, Images or Objects.
That will ensure Undo works, and opens up exciting new use cases
as well. :)
Patch note: on reading files, GPencils linked from editors will
get moved to the main library, using standard naming (indicating
where it was used), and with "Fake User" set. That way the user
can manually relink the pencils where appropriate.
We can check on just linking GP to some default, like 3d window
pencils to Scene? Nice to experiment with.
Notes for Joshua:
- for reading old GPencil, it has to use old code as well, meaning
to tread data as "indirect data, within another ID".
- Saving ID data means the chunk in file BHead needs the ID_GD code,
and not "DATA", which indicates 'indirect data'. That's the file
format spec.
- I've added do_versions_gpencil_2_50(), feel free to further tweak
things here, like linking things to scene or so.
- Formerly GPencil saved 2.50 files won't convert gpencil
2009-04-20 10:13:55 +00:00
|
|
|
static void write_gpencils(WriteData *wd, ListBase *lb)
|
2008-07-22 09:53:25 +00:00
|
|
|
{
|
2.5
Patch from Joshua, converting Grease Pencil to 2.5.
All GP data now is an ID block, allowing re-use, link and append.
For better contextual control within 2.5, these GP ID's will get
linked to actual data, like NodeTrees, Scenes, Images or Objects.
That will ensure Undo works, and opens up exciting new use cases
as well. :)
Patch note: on reading files, GPencils linked from editors will
get moved to the main library, using standard naming (indicating
where it was used), and with "Fake User" set. That way the user
can manually relink the pencils where appropriate.
We can check on just linking GP to some default, like 3d window
pencils to Scene? Nice to experiment with.
Notes for Joshua:
- for reading old GPencil, it has to use old code as well, meaning
to tread data as "indirect data, within another ID".
- Saving ID data means the chunk in file BHead needs the ID_GD code,
and not "DATA", which indicates 'indirect data'. That's the file
format spec.
- I've added do_versions_gpencil_2_50(), feel free to further tweak
things here, like linking things to scene or so.
- Formerly GPencil saved 2.50 files won't convert gpencil
2009-04-20 10:13:55 +00:00
|
|
|
bGPdata *gpd;
|
2008-07-22 09:53:25 +00:00
|
|
|
bGPDlayer *gpl;
|
|
|
|
bGPDframe *gpf;
|
|
|
|
bGPDstroke *gps;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
for (gpd = lb->first; gpd; gpd = gpd->id.next) {
|
|
|
|
if (gpd->id.us > 0 || wd->current) {
|
2011-01-19 22:49:09 +00:00
|
|
|
/* write gpd data block to file */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_GD, bGPdata, 1, gpd);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &gpd->id);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (gpd->adt) {
|
|
|
|
write_animdata(wd, gpd->adt);
|
|
|
|
}
|
|
|
|
|
2011-01-19 22:49:09 +00:00
|
|
|
/* write grease-pencil layers to file */
|
2016-06-28 20:05:42 +10:00
|
|
|
writelist(wd, DATA, bGPDlayer, &gpd->layers);
|
2016-06-28 17:35:35 +10:00
|
|
|
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
|
|
|
|
|
2011-01-19 22:49:09 +00:00
|
|
|
/* write this layer's frames to file */
|
2016-06-28 20:05:42 +10:00
|
|
|
writelist(wd, DATA, bGPDframe, &gpl->frames);
|
2016-06-28 17:35:35 +10:00
|
|
|
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
|
|
|
|
|
2011-01-19 22:49:09 +00:00
|
|
|
/* write strokes */
|
2016-06-28 20:05:42 +10:00
|
|
|
writelist(wd, DATA, bGPDstroke, &gpf->strokes);
|
2016-06-28 17:35:35 +10:00
|
|
|
for (gps = gpf->strokes.first; gps; gps = gps->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bGPDspoint, gps->totpoints, gps->points);
|
2011-01-19 22:49:09 +00:00
|
|
|
}
|
2.5
Patch from Joshua, converting Grease Pencil to 2.5.
All GP data now is an ID block, allowing re-use, link and append.
For better contextual control within 2.5, these GP ID's will get
linked to actual data, like NodeTrees, Scenes, Images or Objects.
That will ensure Undo works, and opens up exciting new use cases
as well. :)
Patch note: on reading files, GPencils linked from editors will
get moved to the main library, using standard naming (indicating
where it was used), and with "Fake User" set. That way the user
can manually relink the pencils where appropriate.
We can check on just linking GP to some default, like 3d window
pencils to Scene? Nice to experiment with.
Notes for Joshua:
- for reading old GPencil, it has to use old code as well, meaning
to tread data as "indirect data, within another ID".
- Saving ID data means the chunk in file BHead needs the ID_GD code,
and not "DATA", which indicates 'indirect data'. That's the file
format spec.
- I've added do_versions_gpencil_2_50(), feel free to further tweak
things here, like linking things to scene or so.
- Formerly GPencil saved 2.50 files won't convert gpencil
2009-04-20 10:13:55 +00:00
|
|
|
}
|
2008-07-22 09:53:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-24 18:53:37 +00:00
|
|
|
static void write_windowmanagers(WriteData *wd, ListBase *lb)
|
|
|
|
{
|
|
|
|
wmWindowManager *wm;
|
|
|
|
wmWindow *win;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
for (wm = lb->first; wm; wm = wm->id.next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_WM, wmWindowManager, 1, wm);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &wm->id);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (win = wm->windows.first; win; win = win->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, wmWindow, 1, win);
|
|
|
|
writestruct(wd, DATA, Stereo3dFormat, 1, win->stereo3d_format);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
2007-12-24 18:53:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static void write_region(WriteData *wd, ARegion *ar, int spacetype)
|
2016-06-28 17:35:35 +10:00
|
|
|
{
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ARegion, 1, ar);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ar->regiondata) {
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (spacetype) {
|
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
|
|
|
case SPACE_VIEW3D:
|
2016-06-28 17:35:35 +10:00
|
|
|
if (ar->regiontype == RGN_TYPE_WINDOW) {
|
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, RegionView3D, 1, rv3d);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
if (rv3d->localvd) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, RegionView3D, 1, rv3d->localvd);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
if (rv3d->clipbb) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BoundBox, 1, rv3d->clipbb);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
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
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf("regiondata write missing!\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("regiondata write missing!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-29 12:55:31 +00:00
|
|
|
static void write_uilist(WriteData *wd, uiList *ui_list)
|
|
|
|
{
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, uiList, 1, ui_list);
|
2013-08-29 12:55:31 +00:00
|
|
|
|
|
|
|
if (ui_list->properties) {
|
|
|
|
IDP_WriteProperty(ui_list->properties, wd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-06 05:35:54 +00:00
|
|
|
static void write_soops(WriteData *wd, SpaceOops *so, LinkNode **tmp_mem_list)
|
2013-08-03 11:35:09 +00:00
|
|
|
{
|
|
|
|
BLI_mempool *ts = so->treestore;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2013-08-03 11:35:09 +00:00
|
|
|
if (ts) {
|
|
|
|
int elems = BLI_mempool_count(ts);
|
|
|
|
/* linearize mempool to array */
|
|
|
|
TreeStoreElem *data = elems ? BLI_mempool_as_arrayN(ts, "TreeStoreElem") : NULL;
|
2013-08-06 05:35:54 +00:00
|
|
|
|
2013-08-03 11:35:09 +00:00
|
|
|
if (data) {
|
2013-08-06 05:35:54 +00:00
|
|
|
TreeStore *ts_flat = MEM_callocN(sizeof(TreeStore), "TreeStore");
|
|
|
|
|
|
|
|
ts_flat->usedelem = elems;
|
|
|
|
ts_flat->totelem = elems;
|
|
|
|
ts_flat->data = data;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2013-08-06 05:35:54 +00:00
|
|
|
/* temporarily replace mempool-treestore by flat-treestore */
|
|
|
|
so->treestore = (BLI_mempool *)ts_flat;
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceOops, 1, so);
|
2013-08-06 05:35:54 +00:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, TreeStore, 1, ts_flat);
|
|
|
|
writestruct(wd, DATA, TreeStoreElem, elems, data);
|
2013-08-06 05:35:54 +00:00
|
|
|
|
|
|
|
/* we do not free the pointers immediately, because if we have multiple
|
|
|
|
* outliners in a screen we might get the same address on the next
|
|
|
|
* malloc, which makes the address no longer unique and so invalid for
|
|
|
|
* lookups on file read, causing crashes or double frees */
|
2013-08-16 13:06:40 +00:00
|
|
|
BLI_linklist_prepend(tmp_mem_list, ts_flat);
|
|
|
|
BLI_linklist_prepend(tmp_mem_list, data);
|
2013-08-06 05:35:54 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
so->treestore = NULL;
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceOops, 1, so);
|
2013-08-03 11:35:09 +00:00
|
|
|
}
|
2013-08-06 05:35:54 +00:00
|
|
|
|
|
|
|
/* restore old treestore */
|
|
|
|
so->treestore = ts;
|
2013-09-21 10:46:58 +00:00
|
|
|
}
|
|
|
|
else {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceOops, 1, so);
|
2013-08-03 11:35:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
static void write_screens(WriteData *wd, ListBase *scrbase)
|
|
|
|
{
|
|
|
|
bScreen *sc;
|
|
|
|
ScrArea *sa;
|
|
|
|
ScrVert *sv;
|
|
|
|
ScrEdge *se;
|
2013-08-06 05:35:54 +00:00
|
|
|
LinkNode *tmp_mem_list = NULL;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
sc = scrbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (sc) {
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2008-11-27 16:00:59 +00:00
|
|
|
/* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_SCRN, bScreen, 1, sc);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &sc->id);
|
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2016-06-28 17:35:35 +10:00
|
|
|
for (sv = sc->vertbase.first; sv; sv = sv->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ScrVert, 1, sv);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
for (se = sc->edgebase.first; se; se = se->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ScrEdge, 1, se);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
SpaceLink *sl;
|
2003-10-04 20:35:50 +00:00
|
|
|
Panel *pa;
|
2012-12-28 10:32:49 +00:00
|
|
|
uiList *ui_list;
|
Add drag-resize to uiTemplatePreview (mat/tex/etc. preview widget).
This is done by adding a new button type, GRIP, similar to other numbuttons
(scroll, slider, ...), which here controls the preview height.
Then, we add a new DNA struct to be able to save that height in Blend files
(note I choose not to use Panel struct for this, because we would then have the
same limitation we used to have with uiLists, only one preview per panel
and no preview outside panel).
This implies a change to template_preview UI RNA/py API (each preview needs an ID),
but this is backward compatible, as by default datablock type will be used if no ID is
given (which means e.g. all material previews with no ID will have same height).
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D342
2014-04-02 12:59:48 +02:00
|
|
|
uiPreview *ui_preview;
|
2013-12-17 03:21:55 +11:00
|
|
|
PanelCategoryStack *pc_act;
|
2008-01-01 15:53:38 +00:00
|
|
|
ARegion *ar;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ScrArea, 1, sa);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
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
|
|
|
write_region(wd, ar, sa->spacetype);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
for (pa = ar->panels.first; pa; pa = pa->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, Panel, 1, pa);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
for (pc_act = ar->panels_category_active.first; pc_act; pc_act = pc_act->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, PanelCategoryStack, 1, pc_act);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2013-12-17 03:21:55 +11:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (ui_list = ar->ui_lists.first; ui_list; ui_list = ui_list->next) {
|
2013-08-29 12:55:31 +00:00
|
|
|
write_uilist(wd, ui_list);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
Add drag-resize to uiTemplatePreview (mat/tex/etc. preview widget).
This is done by adding a new button type, GRIP, similar to other numbuttons
(scroll, slider, ...), which here controls the preview height.
Then, we add a new DNA struct to be able to save that height in Blend files
(note I choose not to use Panel struct for this, because we would then have the
same limitation we used to have with uiLists, only one preview per panel
and no preview outside panel).
This implies a change to template_preview UI RNA/py API (each preview needs an ID),
but this is backward compatible, as by default datablock type will be used if no ID is
given (which means e.g. all material previews with no ID will have same height).
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D342
2014-04-02 12:59:48 +02:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (ui_preview = ar->ui_previews.first; ui_preview; ui_preview = ui_preview->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, uiPreview, 1, ui_preview);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2008-12-26 13:11:04 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
sl = sa->spacedata.first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (sl) {
|
2016-06-28 17:35:35 +10:00
|
|
|
for (ar = sl->regionbase.first; ar; ar = ar->next) {
|
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
|
|
|
write_region(wd, ar, sl->spacetype);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sl->spacetype == SPACE_VIEW3D) {
|
|
|
|
View3D *v3d = (View3D *)sl;
|
2010-01-19 22:44:43 +00:00
|
|
|
BGpic *bgpic;
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, View3D, 1, v3d);
|
2016-06-28 17:35:35 +10:00
|
|
|
for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, BGpic, 1, bgpic);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
if (v3d->localvd) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, View3D, 1, v3d->localvd);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2015-02-12 18:54:41 +01:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (v3d->fx_settings.ssao) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, GPUSSAOSettings, 1, v3d->fx_settings.ssao);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
if (v3d->fx_settings.dof) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, GPUDOFSettings, 1, v3d->fx_settings.dof);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_IPO) {
|
|
|
|
SpaceIpo *sipo = (SpaceIpo *)sl;
|
2009-04-08 01:07:46 +00:00
|
|
|
ListBase tmpGhosts = sipo->ghostCurves;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2009-04-08 01:07:46 +00:00
|
|
|
/* temporarily disable ghost curves when saving */
|
2016-06-28 17:35:35 +10:00
|
|
|
sipo->ghostCurves.first = sipo->ghostCurves.last = NULL;
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceIpo, 1, sl);
|
2016-06-28 17:35:35 +10:00
|
|
|
if (sipo->ads) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bDopeSheet, 1, sipo->ads);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
2009-04-08 01:07:46 +00:00
|
|
|
/* reenable ghost curves */
|
2016-06-28 17:35:35 +10:00
|
|
|
sipo->ghostCurves = tmpGhosts;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_BUTS) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceButs, 1, sl);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_FILE) {
|
|
|
|
SpaceFile *sfile = (SpaceFile *)sl;
|
2011-07-08 12:22:48 +00:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceFile, 1, sl);
|
2016-06-28 17:35:35 +10:00
|
|
|
if (sfile->params) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, FileSelectParams, 1, sfile->params);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_SEQ) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceSeq, 1, sl);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_OUTLINER) {
|
|
|
|
SpaceOops *so = (SpaceOops *)sl;
|
2013-08-06 05:35:54 +00:00
|
|
|
write_soops(wd, so, &tmp_mem_list);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_IMAGE) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceImage, 1, sl);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_TEXT) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceText, 1, sl);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_SCRIPT) {
|
|
|
|
SpaceScript *scr = (SpaceScript *)sl;
|
2011-05-23 08:14:29 +00:00
|
|
|
scr->but_refs = NULL;
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceScript, 1, sl);
|
2003-12-14 01:18:09 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_ACTION) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceAction, 1, sl);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_NLA) {
|
|
|
|
SpaceNla *snla = (SpaceNla *)sl;
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceNla, 1, snla);
|
2016-06-28 17:35:35 +10:00
|
|
|
if (snla->ads) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bDopeSheet, 1, snla->ads);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_TIME) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceTime, 1, sl);
|
Added the new Timeline Window, copied from Tuhopuu, coded by Matt Ebb.
Main change is that it's an own Space type now, not part of the Audio
window... the audio window should restrict to own options. This way
functionality is nicely separated.
Since it's the first time I added a new space (since long!) I've made an
extensive tutorial as well. You can find that here:
http://www.blender3d.org/cms/Adding_new_Space_Window.557.0.html
Notes for using timewindow;
- Add time markers with MKey
- CTRL+M gives option to name Marker
- Markers cannot be moved yet...
- Pageup-Pagedown keys moves current frame to next-prev Marker
- Xkey removes Markers
- If an object has Ipos or an Action, it draws key lines
- CTRL+Pageup-Pagedown moves current frame to next-prev Key
- Press S or E to set start/end frame for playback
Notes about the implementation in Tuhopuu:
- Add new Marker now selects new, deselects others
- Selecting Marker didn't work like elsewhere in Blender, on click it
should deselect all, except the indicated Marker. Not when holding SHIFT
of course
- Not exported functions are static now
- Removed unused defines (MARKER_NONE NEXT_AVAIL)
- Drawing order was confusing, doing too many matrix calls
- Removed not needed scrollbar, added new function to draw time values.
(Has advantage the MMB scroll works not confusing on a scrollbar)
- Added proper support for 'frame mapping'
- The string button (name Marker) had a bug (checked str[64] while str
was only 64 long)
- String button itself didn't allow "OK on enter"
- Made frame buttons in header larger, the arrows overlapped
- Removed support for negative frame values, that won't work so simple!
2005-05-05 17:19:21 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_NODE) {
|
2013-03-18 16:34:57 +00:00
|
|
|
SpaceNode *snode = (SpaceNode *)sl;
|
|
|
|
bNodeTreePath *path;
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceNode, 1, snode);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
for (path = snode->treepath.first; path; path = path->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bNodeTreePath, 1, path);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2005-12-18 13:46:01 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_LOGIC) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceLogic, 1, sl);
|
2009-06-16 13:09:36 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_CONSOLE) {
|
|
|
|
SpaceConsole *con = (SpaceConsole *)sl;
|
2010-04-23 09:24:22 +00:00
|
|
|
ConsoleLine *cl;
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (cl = con->history.first; cl; cl = cl->next) {
|
2011-01-25 01:51:28 +00:00
|
|
|
/* 'len_alloc' is invalid on write, set from 'len' on read */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ConsoleLine, 1, cl);
|
2016-06-28 17:35:35 +10:00
|
|
|
writedata(wd, DATA, cl->len + 1, cl->line);
|
2010-04-23 09:24:22 +00:00
|
|
|
}
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceConsole, 1, sl);
|
2010-04-23 09:24:22 +00:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_USERPREF) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceUserPref, 1, sl);
|
2009-08-18 12:58:51 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
else if (sl->spacetype == SPACE_CLIP) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceClip, 1, sl);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2015-02-23 21:33:14 +11:00
|
|
|
else if (sl->spacetype == SPACE_INFO) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, SpaceInfo, 1, sl);
|
2015-02-23 21:33:14 +11:00
|
|
|
}
|
2009-08-18 12:58:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
sl = sl->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
sc = sc->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2013-08-06 05:35:54 +00:00
|
|
|
|
|
|
|
BLI_linklist_freeN(tmp_mem_list);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
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
|
|
|
/* flush helps the compression for undo-save */
|
|
|
|
mywrite(wd, MYWRITE_FLUSH, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2012-08-26 11:35:43 +00:00
|
|
|
static void write_bone(WriteData *wd, Bone *bone)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
/* PATCH for upward compatibility after 2.37+ armature recode */
|
2012-10-22 08:15:51 +00:00
|
|
|
bone->size[0] = bone->size[1] = bone->size[2] = 1.0f;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
/* Write this bone */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, Bone, 1, bone);
|
2009-10-28 15:33:45 +00:00
|
|
|
|
|
|
|
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
|
2012-04-22 11:54:53 +00:00
|
|
|
* of library blocks that implement this.*/
|
2016-06-28 17:35:35 +10:00
|
|
|
if (bone->prop) {
|
2009-10-28 15:33:45 +00:00
|
|
|
IDP_WriteProperty(bone->prop, wd);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write Children */
|
|
|
|
for (Bone *cbone = bone->childbase.first; cbone; cbone = cbone->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
write_bone(wd, cbone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_armatures(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
bArmature *arm;
|
|
|
|
Bone *bone;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
arm = idbase->first;
|
2002-10-12 11:37:38 +00:00
|
|
|
while (arm) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (arm->id.us > 0 || wd->current) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_AR, bArmature, 1, arm);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &arm->id);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (arm->adt) {
|
|
|
|
write_animdata(wd, arm->adt);
|
|
|
|
}
|
2009-09-21 06:43:20 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* Direct data */
|
2016-06-28 17:35:35 +10:00
|
|
|
bone = arm->bonebase.first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (bone) {
|
2002-10-12 11:37:38 +00:00
|
|
|
write_bone(wd, bone);
|
2016-06-28 17:35:35 +10:00
|
|
|
bone = bone->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
arm = arm->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-09-05 13:43:51 +00:00
|
|
|
|
|
|
|
/* flush helps the compression for undo-save */
|
|
|
|
mywrite(wd, MYWRITE_FLUSH, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void write_texts(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Text *text;
|
|
|
|
TextLine *tmp;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
text = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (text) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if ( (text->flags & TXT_ISMEM) && (text->flags & TXT_ISEXT)) {
|
|
|
|
text->flags &= ~TXT_ISEXT;
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_TXT, Text, 1, text);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &text->id);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (text->name) {
|
|
|
|
writedata(wd, DATA, strlen(text->name) + 1, text->name);
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!(text->flags & TXT_ISEXT)) {
|
2002-10-12 11:37:38 +00:00
|
|
|
/* now write the text data, in two steps for optimization in the readfunction */
|
2016-06-28 17:35:35 +10:00
|
|
|
tmp = text->lines.first;
|
2002-10-12 11:37:38 +00:00
|
|
|
while (tmp) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, TextLine, 1, tmp);
|
2016-06-28 17:35:35 +10:00
|
|
|
tmp = tmp->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
tmp = text->lines.first;
|
2002-10-12 11:37:38 +00:00
|
|
|
while (tmp) {
|
2016-06-28 17:35:35 +10:00
|
|
|
writedata(wd, DATA, tmp->len + 1, tmp->line);
|
|
|
|
tmp = tmp->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
2008-08-04 23:01:47 +00:00
|
|
|
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
text = text->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-09-05 13:43:51 +00:00
|
|
|
|
|
|
|
/* flush helps the compression for undo-save */
|
|
|
|
mywrite(wd, MYWRITE_FLUSH, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2011-08-01 11:44:20 +00:00
|
|
|
static void write_speakers(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Speaker *spk;
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
spk = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (spk) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (spk->id.us > 0 || wd->current) {
|
2011-08-01 11:44:20 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_SPK, Speaker, 1, spk);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &spk->id);
|
2011-08-01 11:44:20 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (spk->adt) {
|
|
|
|
write_animdata(wd, spk->adt);
|
|
|
|
}
|
2011-08-01 11:44:20 +00:00
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
spk = spk->id.next;
|
2011-08-01 11:44:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
static void write_sounds(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
bSound *sound;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
PackedFile *pf;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
sound = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (sound) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (sound->id.us > 0 || wd->current) {
|
2002-10-12 11:37:38 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_SO, bSound, 1, sound);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &sound->id);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2013-01-13 12:25:56 +00:00
|
|
|
if (sound->packedfile) {
|
2009-08-09 21:16:39 +00:00
|
|
|
pf = sound->packedfile;
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, PackedFile, 1, pf);
|
2002-10-12 11:37:38 +00:00
|
|
|
writedata(wd, DATA, pf->size, pf->data);
|
|
|
|
}
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
sound = sound->id.next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-09-05 13:43:51 +00:00
|
|
|
|
|
|
|
/* flush helps the compression for undo-save */
|
|
|
|
mywrite(wd, MYWRITE_FLUSH, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void write_groups(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Group *group;
|
|
|
|
GroupObject *go;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (group = idbase->first; group; group = group->id.next) {
|
|
|
|
if (group->id.us > 0 || wd->current) {
|
2002-10-12 11:37:38 +00:00
|
|
|
/* write LibData */
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_GR, Group, 1, group);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &group->id);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2015-08-10 15:41:28 +02:00
|
|
|
write_previews(wd, group->preview);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
go = group->gobject.first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (go) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, GroupObject, 1, go);
|
2016-06-28 17:35:35 +10:00
|
|
|
go = go->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_nodetrees(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
bNodeTree *ntree;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
for (ntree = idbase->first; ntree; ntree = ntree->id.next) {
|
|
|
|
if (ntree->id.us > 0 || wd->current) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_NT, bNodeTree, 1, ntree);
|
2016-06-14 14:53:39 +02:00
|
|
|
/* Note that trees directly used by other IDs (materials etc.) are not 'real' ID, they cannot
|
|
|
|
* be linked, etc., so we write actual id data here only, for 'real' ID trees. */
|
|
|
|
write_iddata(wd, &ntree->id);
|
|
|
|
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
write_nodetree(wd, ntree);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
#ifdef USE_NODE_COMPAT_CUSTOMNODES
|
2013-03-24 12:13:13 +00:00
|
|
|
static void customnodes_add_deprecated_data(Main *mainvar)
|
|
|
|
{
|
|
|
|
FOREACH_NODETREE(mainvar, ntree, id) {
|
|
|
|
bNodeLink *link, *last_link = ntree->links.last;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
/* only do this for node groups */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (id != &ntree->id) {
|
2013-03-24 12:13:13 +00:00
|
|
|
continue;
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
/* Forward compatibility for group nodes: add links to node tree interface sockets.
|
|
|
|
* These links are invalid by new rules (missing node pointer)!
|
|
|
|
* They will be removed again in customnodes_free_deprecated_data,
|
|
|
|
* cannot do this directly lest bNodeLink pointer mapping becomes ambiguous.
|
|
|
|
* When loading files with such links in a new Blender version
|
|
|
|
* they will be removed as well.
|
|
|
|
*/
|
|
|
|
for (link = ntree->links.first; link; link = link->next) {
|
|
|
|
bNode *fromnode = link->fromnode, *tonode = link->tonode;
|
|
|
|
bNodeSocket *fromsock = link->fromsock, *tosock = link->tosock;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
/* check both sides of the link, to handle direct input-to-output links */
|
|
|
|
if (fromnode->type == NODE_GROUP_INPUT) {
|
|
|
|
fromnode = NULL;
|
|
|
|
fromsock = ntreeFindSocketInterface(ntree, SOCK_IN, fromsock->identifier);
|
|
|
|
}
|
|
|
|
/* only the active output node defines links */
|
|
|
|
if (tonode->type == NODE_GROUP_OUTPUT && (tonode->flag & NODE_DO_OUTPUT)) {
|
|
|
|
tonode = NULL;
|
|
|
|
tosock = ntreeFindSocketInterface(ntree, SOCK_OUT, tosock->identifier);
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
if (!fromnode || !tonode) {
|
|
|
|
/* Note: not using nodeAddLink here, it asserts existing node pointers */
|
|
|
|
bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "group node link");
|
|
|
|
tlink->fromnode = fromnode;
|
|
|
|
tlink->fromsock = fromsock;
|
|
|
|
tlink->tonode = tonode;
|
2016-06-28 17:35:35 +10:00
|
|
|
tlink->tosock = tosock;
|
2013-03-24 12:13:13 +00:00
|
|
|
tosock->link = tlink;
|
|
|
|
tlink->flag |= NODE_LINK_VALID;
|
|
|
|
BLI_addtail(&ntree->links, tlink);
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
/* don't check newly created compatibility links */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (link == last_link) {
|
2013-03-24 12:13:13 +00:00
|
|
|
break;
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
}
|
2013-03-24 12:13:13 +00:00
|
|
|
FOREACH_NODETREE_END
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void customnodes_free_deprecated_data(Main *mainvar)
|
|
|
|
{
|
2013-03-24 12:13:13 +00:00
|
|
|
FOREACH_NODETREE(mainvar, ntree, id) {
|
|
|
|
bNodeLink *link, *next_link;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
for (link = ntree->links.first; link; link = next_link) {
|
|
|
|
next_link = link->next;
|
2016-06-28 17:35:35 +10:00
|
|
|
if (link->fromnode == NULL || link->tonode == NULL) {
|
2013-03-24 12:13:13 +00:00
|
|
|
nodeRemLink(ntree, link);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2013-03-24 12:13:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
FOREACH_NODETREE_END
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
static void write_brushes(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Brush *brush;
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
for (brush = idbase->first; brush; brush = brush->id.next) {
|
|
|
|
if (brush->id.us > 0 || wd->current) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_BR, Brush, 1, brush);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &brush->id);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (brush->curve) {
|
2009-01-07 04:38:30 +00:00
|
|
|
write_curvemapping(wd, brush->curve);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
if (brush->gradient) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ColorBand, 1, brush->gradient);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2014-07-21 12:02:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_palettes(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Palette *palette;
|
|
|
|
|
|
|
|
for (palette = idbase->first; palette; palette = palette->id.next) {
|
|
|
|
if (palette->id.us > 0 || wd->current) {
|
|
|
|
PaletteColor *color;
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_PAL, Palette, 1, palette);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &palette->id);
|
2014-07-21 12:02:05 +02:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (color = palette->colors.first; color; color = color->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, PaletteColor, 1, color);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2014-07-21 12:02:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_paintcurves(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
PaintCurve *pc;
|
|
|
|
|
|
|
|
for (pc = idbase->first; pc; pc = pc->id.next) {
|
|
|
|
if (pc->id.us > 0 || wd->current) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_PC, PaintCurve, 1, pc);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &pc->id);
|
2014-07-21 12:02:05 +02:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, PaintCurvePoint, pc->tot_points, pc->points);
|
2006-07-31 15:53:03 +00:00
|
|
|
}
|
|
|
|
}
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
}
|
|
|
|
|
2011-12-05 18:57:17 +00:00
|
|
|
static void write_movieTracks(WriteData *wd, ListBase *tracks)
|
|
|
|
{
|
|
|
|
MovieTrackingTrack *track;
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
track = tracks->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (track) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MovieTrackingTrack, 1, track);
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (track->markers) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MovieTrackingMarker, track->markersnr, track->markers);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2011-12-05 18:57:17 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
track = track->next;
|
2011-12-05 18:57:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
static void write_moviePlaneTracks(WriteData *wd, ListBase *plane_tracks_base)
|
|
|
|
{
|
|
|
|
MovieTrackingPlaneTrack *plane_track;
|
|
|
|
|
|
|
|
for (plane_track = plane_tracks_base->first;
|
|
|
|
plane_track;
|
|
|
|
plane_track = plane_track->next)
|
|
|
|
{
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MovieTrackingPlaneTrack, 1, plane_track);
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
|
|
|
|
writedata(wd, DATA, sizeof(MovieTrackingTrack *) * plane_track->point_tracksnr, plane_track->point_tracks);
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MovieTrackingPlaneMarker, plane_track->markersnr, plane_track->markers);
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-05 18:57:17 +00:00
|
|
|
static void write_movieReconstruction(WriteData *wd, MovieTrackingReconstruction *reconstruction)
|
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
if (reconstruction->camnr) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MovieReconstructedCamera, reconstruction->camnr, reconstruction->cameras);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2011-12-05 18:57:17 +00:00
|
|
|
}
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
static void write_movieclips(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
MovieClip *clip;
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
clip = idbase->first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (clip) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (clip->id.us > 0 || wd->current) {
|
|
|
|
MovieTracking *tracking = &clip->tracking;
|
2011-12-05 18:57:17 +00:00
|
|
|
MovieTrackingObject *object;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_MC, MovieClip, 1, clip);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &clip->id);
|
2012-05-08 07:31:02 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (clip->adt) {
|
2012-02-17 08:13:45 +00:00
|
|
|
write_animdata(wd, clip->adt);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2012-02-17 08:13:45 +00:00
|
|
|
|
2011-12-05 18:57:17 +00:00
|
|
|
write_movieTracks(wd, &tracking->tracks);
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
write_moviePlaneTracks(wd, &tracking->plane_tracks);
|
2011-12-05 18:57:17 +00:00
|
|
|
write_movieReconstruction(wd, &tracking->reconstruction);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
object = tracking->objects.first;
|
2012-03-24 07:52:14 +00:00
|
|
|
while (object) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MovieTrackingObject, 1, object);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2011-12-05 18:57:17 +00:00
|
|
|
write_movieTracks(wd, &object->tracks);
|
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
|
|
|
write_moviePlaneTracks(wd, &object->plane_tracks);
|
2011-12-05 18:57:17 +00:00
|
|
|
write_movieReconstruction(wd, &object->reconstruction);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
object = object->next;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
clip = clip->id.next;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* flush helps the compression for undo-save */
|
|
|
|
mywrite(wd, MYWRITE_FLUSH, 0);
|
|
|
|
}
|
|
|
|
|
2012-06-04 16:42:58 +00:00
|
|
|
static void write_masks(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Mask *mask;
|
|
|
|
|
|
|
|
mask = idbase->first;
|
|
|
|
while (mask) {
|
|
|
|
if (mask->id.us > 0 || wd->current) {
|
|
|
|
MaskLayer *masklay;
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_MSK, Mask, 1, mask);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &mask->id);
|
2012-06-04 16:42:58 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (mask->adt) {
|
2012-06-04 16:42:58 +00:00
|
|
|
write_animdata(wd, mask->adt);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2012-06-04 16:42:58 +00:00
|
|
|
|
|
|
|
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
|
|
|
|
MaskSpline *spline;
|
|
|
|
MaskLayerShape *masklay_shape;
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MaskLayer, 1, masklay);
|
2012-06-04 16:42:58 +00:00
|
|
|
|
|
|
|
for (spline = masklay->splines.first; spline; spline = spline->next) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
void *points_deform = spline->points_deform;
|
|
|
|
spline->points_deform = NULL;
|
|
|
|
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MaskSpline, 1, spline);
|
|
|
|
writestruct(wd, DATA, MaskSplinePoint, spline->tot_point, spline->points);
|
2012-06-04 16:42:58 +00:00
|
|
|
|
|
|
|
spline->points_deform = points_deform;
|
|
|
|
|
|
|
|
for (i = 0; i < spline->tot_point; i++) {
|
|
|
|
MaskSplinePoint *point = &spline->points[i];
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (point->tot_uw) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MaskSplinePointUW, point->tot_uw, point->uw);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2012-06-04 16:42:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (masklay_shape = masklay->splines_shapes.first;
|
|
|
|
masklay_shape;
|
|
|
|
masklay_shape = masklay_shape->next)
|
|
|
|
{
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MaskLayerShape, 1, masklay_shape);
|
2016-06-28 17:35:35 +10:00
|
|
|
writedata(wd, DATA,
|
|
|
|
masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE,
|
|
|
|
masklay_shape->data);
|
2012-06-04 16:42:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mask = mask->id.next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* flush helps the compression for undo-save */
|
|
|
|
mywrite(wd, MYWRITE_FLUSH, 0);
|
|
|
|
}
|
|
|
|
|
2010-07-24 20:37:54 +00:00
|
|
|
static void write_linestyle_color_modifiers(WriteData *wd, ListBase *modifiers)
|
|
|
|
{
|
|
|
|
LineStyleModifier *m;
|
|
|
|
|
|
|
|
for (m = modifiers->first; m; m = m->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
int struct_nr;
|
2010-07-24 20:37:54 +00:00
|
|
|
switch (m->type) {
|
2016-06-28 17:35:35 +10:00
|
|
|
case LS_MODIFIER_ALONG_STROKE:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_AlongStroke);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_DISTANCE_FROM_CAMERA:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_DistanceFromCamera);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_DISTANCE_FROM_OBJECT:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_DistanceFromObject);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_MATERIAL:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_Material);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TANGENT:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_Tangent);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_NOISE:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_Noise);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_CREASE_ANGLE:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_CreaseAngle);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_CURVATURE_3D:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleColorModifier_Curvature_3D);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
default:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleModifier); /* this should not happen */
|
2010-07-24 20:37:54 +00:00
|
|
|
}
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_nr(wd, DATA, struct_nr, 1, m);
|
2010-07-24 20:37:54 +00:00
|
|
|
}
|
|
|
|
for (m = modifiers->first; m; m = m->next) {
|
|
|
|
switch (m->type) {
|
2016-06-28 17:35:35 +10:00
|
|
|
case LS_MODIFIER_ALONG_STROKE:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_AlongStroke *)m)->color_ramp);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_DISTANCE_FROM_CAMERA:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_DISTANCE_FROM_OBJECT:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_MATERIAL:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_Material *)m)->color_ramp);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TANGENT:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_Tangent *)m)->color_ramp);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_NOISE:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_Noise *)m)->color_ramp);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_CREASE_ANGLE:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_CreaseAngle *)m)->color_ramp);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_CURVATURE_3D:
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, ColorBand, 1, ((LineStyleColorModifier_Curvature_3D *)m)->color_ramp);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
2010-07-24 20:37:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_linestyle_alpha_modifiers(WriteData *wd, ListBase *modifiers)
|
|
|
|
{
|
|
|
|
LineStyleModifier *m;
|
|
|
|
|
|
|
|
for (m = modifiers->first; m; m = m->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
int struct_nr;
|
2010-07-24 20:37:54 +00:00
|
|
|
switch (m->type) {
|
2016-06-28 17:35:35 +10:00
|
|
|
case LS_MODIFIER_ALONG_STROKE:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_AlongStroke);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_DISTANCE_FROM_CAMERA:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_DistanceFromCamera);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_DISTANCE_FROM_OBJECT:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_DistanceFromObject);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_MATERIAL:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_Material);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TANGENT:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_Tangent);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_NOISE:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_Noise);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_CREASE_ANGLE:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_CreaseAngle);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_CURVATURE_3D:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleAlphaModifier_Curvature_3D);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
default:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleModifier); /* this should not happen */
|
2010-07-24 20:37:54 +00:00
|
|
|
}
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_nr(wd, DATA, struct_nr, 1, m);
|
2010-07-24 20:37:54 +00:00
|
|
|
}
|
|
|
|
for (m = modifiers->first; m; m = m->next) {
|
|
|
|
switch (m->type) {
|
2016-06-28 17:35:35 +10:00
|
|
|
case LS_MODIFIER_ALONG_STROKE:
|
|
|
|
write_curvemapping(wd, ((LineStyleAlphaModifier_AlongStroke *)m)->curve);
|
|
|
|
break;
|
|
|
|
case LS_MODIFIER_DISTANCE_FROM_CAMERA:
|
|
|
|
write_curvemapping(wd, ((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve);
|
|
|
|
break;
|
|
|
|
case LS_MODIFIER_DISTANCE_FROM_OBJECT:
|
|
|
|
write_curvemapping(wd, ((LineStyleAlphaModifier_DistanceFromObject *)m)->curve);
|
|
|
|
break;
|
|
|
|
case LS_MODIFIER_MATERIAL:
|
|
|
|
write_curvemapping(wd, ((LineStyleAlphaModifier_Material *)m)->curve);
|
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TANGENT:
|
|
|
|
write_curvemapping(wd, ((LineStyleAlphaModifier_Tangent *)m)->curve);
|
|
|
|
break;
|
|
|
|
case LS_MODIFIER_NOISE:
|
|
|
|
write_curvemapping(wd, ((LineStyleAlphaModifier_Noise *)m)->curve);
|
|
|
|
break;
|
|
|
|
case LS_MODIFIER_CREASE_ANGLE:
|
|
|
|
write_curvemapping(wd, ((LineStyleAlphaModifier_CreaseAngle *)m)->curve);
|
|
|
|
break;
|
|
|
|
case LS_MODIFIER_CURVATURE_3D:
|
|
|
|
write_curvemapping(wd, ((LineStyleAlphaModifier_Curvature_3D *)m)->curve);
|
|
|
|
break;
|
2010-07-24 20:37:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_linestyle_thickness_modifiers(WriteData *wd, ListBase *modifiers)
|
|
|
|
{
|
|
|
|
LineStyleModifier *m;
|
|
|
|
|
|
|
|
for (m = modifiers->first; m; m = m->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
int struct_nr;
|
2010-07-24 20:37:54 +00:00
|
|
|
switch (m->type) {
|
2016-06-28 17:35:35 +10:00
|
|
|
case LS_MODIFIER_ALONG_STROKE:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_AlongStroke);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_DISTANCE_FROM_CAMERA:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_DistanceFromCamera);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_DISTANCE_FROM_OBJECT:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_DistanceFromObject);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_MATERIAL:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_Material);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_CALLIGRAPHY:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_Calligraphy);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TANGENT:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_Tangent);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_NOISE:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_Noise);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_CREASE_ANGLE:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_CreaseAngle);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_CURVATURE_3D:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleThicknessModifier_Curvature_3D);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
default:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleModifier); /* this should not happen */
|
2010-07-24 20:37:54 +00:00
|
|
|
}
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_nr(wd, DATA, struct_nr, 1, m);
|
2010-07-24 20:37:54 +00:00
|
|
|
}
|
|
|
|
for (m = modifiers->first; m; m = m->next) {
|
|
|
|
switch (m->type) {
|
2016-06-28 17:35:35 +10:00
|
|
|
case LS_MODIFIER_ALONG_STROKE:
|
|
|
|
write_curvemapping(wd, ((LineStyleThicknessModifier_AlongStroke *)m)->curve);
|
|
|
|
break;
|
|
|
|
case LS_MODIFIER_DISTANCE_FROM_CAMERA:
|
|
|
|
write_curvemapping(wd, ((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve);
|
|
|
|
break;
|
|
|
|
case LS_MODIFIER_DISTANCE_FROM_OBJECT:
|
|
|
|
write_curvemapping(wd, ((LineStyleThicknessModifier_DistanceFromObject *)m)->curve);
|
|
|
|
break;
|
|
|
|
case LS_MODIFIER_MATERIAL:
|
|
|
|
write_curvemapping(wd, ((LineStyleThicknessModifier_Material *)m)->curve);
|
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TANGENT:
|
|
|
|
write_curvemapping(wd, ((LineStyleThicknessModifier_Tangent *)m)->curve);
|
|
|
|
break;
|
|
|
|
case LS_MODIFIER_CREASE_ANGLE:
|
|
|
|
write_curvemapping(wd, ((LineStyleThicknessModifier_CreaseAngle *)m)->curve);
|
|
|
|
break;
|
|
|
|
case LS_MODIFIER_CURVATURE_3D:
|
|
|
|
write_curvemapping(wd, ((LineStyleThicknessModifier_Curvature_3D *)m)->curve);
|
|
|
|
break;
|
2010-07-24 20:37:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-19 14:05:11 +00:00
|
|
|
static void write_linestyle_geometry_modifiers(WriteData *wd, ListBase *modifiers)
|
|
|
|
{
|
|
|
|
LineStyleModifier *m;
|
|
|
|
|
|
|
|
for (m = modifiers->first; m; m = m->next) {
|
2016-06-28 20:05:42 +10:00
|
|
|
int struct_nr;
|
2011-08-19 14:05:11 +00:00
|
|
|
switch (m->type) {
|
2016-06-28 17:35:35 +10:00
|
|
|
case LS_MODIFIER_SAMPLING:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_Sampling);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_BEZIER_CURVE:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_BezierCurve);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_SINUS_DISPLACEMENT:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_SinusDisplacement);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_SPATIAL_NOISE:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_SpatialNoise);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_PERLIN_NOISE_1D:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_PerlinNoise1D);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_PERLIN_NOISE_2D:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_PerlinNoise2D);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_BACKBONE_STRETCHER:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_BackboneStretcher);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TIP_REMOVER:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_TipRemover);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_POLYGONIZATION:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_Polygonalization);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_GUIDING_LINES:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_GuidingLines);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_BLUEPRINT:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_Blueprint);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_2D_OFFSET:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_2DOffset);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_2D_TRANSFORM:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_2DTransform);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_SIMPLIFICATION:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleGeometryModifier_Simplification);
|
2016-06-28 17:35:35 +10:00
|
|
|
break;
|
|
|
|
default:
|
2016-06-28 20:05:42 +10:00
|
|
|
struct_nr = SDNA_TYPE_FROM_STRUCT(LineStyleModifier); /* this should not happen */
|
2011-08-19 14:05:11 +00:00
|
|
|
}
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct_nr(wd, DATA, struct_nr, 1, m);
|
2011-08-19 14:05:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-25 22:45:42 +00:00
|
|
|
static void write_linestyles(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
FreestyleLineStyle *linestyle;
|
2014-05-03 18:51:53 +09:00
|
|
|
int a;
|
2010-07-24 20:37:54 +00:00
|
|
|
|
2012-12-11 22:00:22 +00:00
|
|
|
for (linestyle = idbase->first; linestyle; linestyle = linestyle->id.next) {
|
2016-06-28 17:35:35 +10:00
|
|
|
if (linestyle->id.us > 0 || wd->current) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_LS, FreestyleLineStyle, 1, linestyle);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &linestyle->id);
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (linestyle->adt) {
|
2012-12-11 22:00:22 +00:00
|
|
|
write_animdata(wd, linestyle->adt);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
|
|
|
|
2010-07-24 20:37:54 +00:00
|
|
|
write_linestyle_color_modifiers(wd, &linestyle->color_modifiers);
|
|
|
|
write_linestyle_alpha_modifiers(wd, &linestyle->alpha_modifiers);
|
|
|
|
write_linestyle_thickness_modifiers(wd, &linestyle->thickness_modifiers);
|
2011-08-19 14:05:11 +00:00
|
|
|
write_linestyle_geometry_modifiers(wd, &linestyle->geometry_modifiers);
|
2016-06-28 17:35:35 +10:00
|
|
|
for (a = 0; a < MAX_MTEX; a++) {
|
|
|
|
if (linestyle->mtex[a]) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, MTex, 1, linestyle->mtex[a]);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2014-05-03 18:51:53 +09:00
|
|
|
}
|
|
|
|
if (linestyle->nodetree) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, bNodeTree, 1, linestyle->nodetree);
|
2014-05-03 18:51:53 +09:00
|
|
|
write_nodetree(wd, linestyle->nodetree);
|
|
|
|
}
|
2010-06-25 22:45:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-14 14:53:39 +02:00
|
|
|
/* Keep it last of write_foodata functions. */
|
|
|
|
static void write_libraries(WriteData *wd, Main *main)
|
|
|
|
{
|
|
|
|
ListBase *lbarray[MAX_LIBARRAY];
|
|
|
|
ID *id;
|
|
|
|
int a, tot;
|
|
|
|
bool found_one;
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
for (; main; main = main->next) {
|
2016-06-14 14:53:39 +02:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
a = tot = set_listbasepointers(main, lbarray);
|
2016-06-14 14:53:39 +02:00
|
|
|
|
|
|
|
/* test: is lib being used */
|
2016-06-28 17:35:35 +10:00
|
|
|
if (main->curlib && main->curlib->packedfile) {
|
2016-06-14 14:53:39 +02:00
|
|
|
found_one = true;
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2016-06-14 14:53:39 +02:00
|
|
|
else {
|
|
|
|
found_one = false;
|
|
|
|
while (tot--) {
|
2016-06-28 17:35:35 +10:00
|
|
|
for (id = lbarray[tot]->first; id; id = id->next) {
|
2016-06-14 14:53:39 +02:00
|
|
|
if (id->us > 0 && (id->tag & LIB_TAG_EXTERN)) {
|
|
|
|
found_one = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
if (found_one) {
|
|
|
|
break;
|
|
|
|
}
|
2016-06-14 14:53:39 +02: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 */
|
|
|
|
if (found_one) {
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_LI, Library, 1, main->curlib);
|
2016-06-14 14:53:39 +02:00
|
|
|
write_iddata(wd, &main->curlib->id);
|
|
|
|
|
|
|
|
if (main->curlib->packedfile) {
|
|
|
|
PackedFile *pf = main->curlib->packedfile;
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, DATA, PackedFile, 1, pf);
|
2016-06-14 14:53:39 +02:00
|
|
|
writedata(wd, DATA, pf->size, pf->data);
|
2016-06-28 17:35:35 +10:00
|
|
|
if (wd->current == NULL) {
|
2016-06-14 14:53:39 +02:00
|
|
|
printf("write packed .blend: %s\n", main->curlib->name);
|
2016-06-28 17:35:35 +10:00
|
|
|
}
|
2016-06-14 14:53:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
while (a--) {
|
2016-06-28 17:35:35 +10:00
|
|
|
for (id = lbarray[a]->first; id; id = id->next) {
|
2016-06-14 14:53:39 +02:00
|
|
|
if (id->us > 0 && (id->tag & LIB_TAG_EXTERN)) {
|
|
|
|
if (!BKE_idcode_is_linkable(GS(id->name))) {
|
|
|
|
printf("ERROR: write file: datablock '%s' from lib '%s' is not linkable "
|
|
|
|
"but is flagged as directly linked", id->name, main->curlib->filepath);
|
|
|
|
BLI_assert(0);
|
|
|
|
}
|
2016-06-28 20:05:42 +10:00
|
|
|
writestruct(wd, ID_ID, ID, 1, id);
|
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
|
|
|
{
|
2015-02-10 05:45:57 +11:00
|
|
|
const bool is_undo = (wd->current != NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
FileGlobal fg;
|
2008-12-19 16:36:15 +00:00
|
|
|
bScreen *screen;
|
2007-01-08 12:31:53 +00:00
|
|
|
char subvstr[8];
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2011-01-16 21:12:38 +00:00
|
|
|
/* prevent mem checkers from complaining */
|
2015-01-20 01:07:12 +11:00
|
|
|
memset(fg.pad, 0, sizeof(fg.pad));
|
2011-01-16 21:12:38 +00:00
|
|
|
memset(fg.filename, 0, sizeof(fg.filename));
|
2014-01-22 16:23:55 +06:00
|
|
|
memset(fg.build_hash, 0, sizeof(fg.build_hash));
|
2011-01-16 21:12:38 +00:00
|
|
|
|
2015-02-10 05:45:57 +11:00
|
|
|
current_screen_compat(mainvar, &screen, is_undo);
|
2008-12-19 16:36:15 +00:00
|
|
|
|
|
|
|
/* XXX still remap G */
|
2016-06-28 17:35:35 +10:00
|
|
|
fg.curscreen = screen;
|
|
|
|
fg.curscene = screen ? screen->scene : NULL;
|
2011-12-27 13:17:58 +00:00
|
|
|
|
|
|
|
/* prevent to save this, is not good convention, and feature with concerns... */
|
2016-06-28 17:35:35 +10:00
|
|
|
fg.fileflags = (fileflags & ~G_FILE_FLAGS_RUNTIME);
|
2011-12-27 13:17:58 +00:00
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
fg.globalf = G.f;
|
2009-10-20 13:58:53 +00:00
|
|
|
BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename));
|
2007-01-08 12:31:53 +00:00
|
|
|
sprintf(subvstr, "%4d", BLENDER_SUBVERSION);
|
|
|
|
memcpy(fg.subvstr, subvstr, 4);
|
2016-06-28 17:35:35 +10:00
|
|
|
|
|
|
|
fg.subversion = BLENDER_SUBVERSION;
|
|
|
|
fg.minversion = BLENDER_MINVERSION;
|
|
|
|
fg.minsubversion = BLENDER_MINSUBVERSION;
|
2011-08-22 16:54:26 +00:00
|
|
|
#ifdef WITH_BUILDINFO
|
2011-01-02 13:33:32 +00:00
|
|
|
{
|
2013-11-15 17:11:59 +06:00
|
|
|
extern unsigned long build_commit_timestamp;
|
|
|
|
extern char build_hash[];
|
2013-11-04 13:21:39 +00:00
|
|
|
/* TODO(sergey): Add branch name to file as well? */
|
2013-11-15 17:11:59 +06:00
|
|
|
fg.build_commit_timestamp = build_commit_timestamp;
|
2013-11-04 13:21:39 +00:00
|
|
|
BLI_strncpy(fg.build_hash, build_hash, sizeof(fg.build_hash));
|
2011-01-02 13:33:32 +00:00
|
|
|
}
|
|
|
|
#else
|
2013-11-15 17:11:59 +06:00
|
|
|
fg.build_commit_timestamp = 0;
|
2013-11-04 13:21:39 +00:00
|
|
|
BLI_strncpy(fg.build_hash, "unknown", sizeof(fg.build_hash));
|
2011-01-02 13:33:32 +00:00
|
|
|
#endif
|
2016-06-28 20:05:42 +10: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
|
|
|
|
* second are an RGBA image (unsigned char)
|
|
|
|
* 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
|
|
|
{
|
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
|
|
|
if (thumb) {
|
2015-09-01 01:52:27 +10:00
|
|
|
writedata(wd, TEST, BLEN_THUMB_MEMSIZE_FILE(thumb->width, thumb->height), thumb);
|
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
|
|
|
}
|
2010-05-24 21:52:18 +00:00
|
|
|
}
|
|
|
|
|
2006-11-25 13:07:28 +00:00
|
|
|
/* if MemFile * there's filesave to memory */
|
2016-06-28 21:00:00 +10:00
|
|
|
static bool write_file_handle(
|
2014-09-04 21:48:36 +10:00
|
|
|
Main *mainvar,
|
|
|
|
WriteWrap *ww,
|
|
|
|
MemFile *compare, MemFile *current,
|
2016-06-28 21:00:00 +10:00
|
|
|
int write_flags, const BlendThumbnail *thumb)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2004-09-05 13:43:51 +00:00
|
|
|
BHead bhead;
|
2002-10-12 11:37:38 +00:00
|
|
|
ListBase mainlist;
|
2006-12-01 19:52:04 +00:00
|
|
|
char buf[16];
|
2002-10-12 11:37:38 +00:00
|
|
|
WriteData *wd;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2008-12-19 16:36:15 +00:00
|
|
|
blo_split_main(&mainlist, mainvar);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2014-09-04 21:48:36 +10:00
|
|
|
wd = bgnwrite(ww, compare, current);
|
2011-12-27 13:17:58 +00:00
|
|
|
|
2011-12-28 13:50:33 +00:00
|
|
|
#ifdef USE_BMESH_SAVE_AS_COMPAT
|
2011-12-27 13:17:58 +00:00
|
|
|
wd->use_mesh_compat = (write_flags & G_FILE_MESH_COMPAT) != 0;
|
|
|
|
#endif
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
#ifdef USE_NODE_COMPAT_CUSTOMNODES
|
2013-03-24 12:13:13 +00:00
|
|
|
/* don't write compatibility data on undo */
|
|
|
|
if (!current) {
|
|
|
|
/* deprecated forward compat data is freed again below */
|
|
|
|
customnodes_add_deprecated_data(mainvar);
|
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
#endif
|
|
|
|
|
2013-03-31 03:28:46 +00:00
|
|
|
sprintf(buf, "BLENDER%c%c%.3d",
|
|
|
|
(sizeof(void *) == 8) ? '-' : '_',
|
|
|
|
(ENDIAN_ORDER == B_ENDIAN) ? 'V' : 'v',
|
|
|
|
BLENDER_VERSION);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
mywrite(wd, buf, 12);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2008-12-19 16:36:15 +00:00
|
|
|
write_renderinfo(wd, mainvar);
|
2010-05-24 21:52:18 +00:00
|
|
|
write_thumb(wd, thumb);
|
2009-10-20 13:58:53 +00:00
|
|
|
write_global(wd, write_flags, mainvar);
|
2006-11-26 21:17:15 +00:00
|
|
|
|
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
|
|
|
write_windowmanagers(wd, &mainvar->wm);
|
2016-06-28 17:35:35 +10:00
|
|
|
write_screens(wd, &mainvar->screen);
|
|
|
|
write_movieclips(wd, &mainvar->movieclip);
|
|
|
|
write_masks(wd, &mainvar->mask);
|
|
|
|
write_scenes(wd, &mainvar->scene);
|
|
|
|
write_curves(wd, &mainvar->curve);
|
|
|
|
write_mballs(wd, &mainvar->mball);
|
|
|
|
write_images(wd, &mainvar->image);
|
|
|
|
write_cameras(wd, &mainvar->camera);
|
|
|
|
write_lamps(wd, &mainvar->lamp);
|
|
|
|
write_lattices(wd, &mainvar->latt);
|
|
|
|
write_vfonts(wd, &mainvar->vfont);
|
|
|
|
write_keys(wd, &mainvar->key);
|
|
|
|
write_worlds(wd, &mainvar->world);
|
|
|
|
write_texts(wd, &mainvar->text);
|
|
|
|
write_speakers(wd, &mainvar->speaker);
|
|
|
|
write_sounds(wd, &mainvar->sound);
|
|
|
|
write_groups(wd, &mainvar->group);
|
2008-12-19 16:36:15 +00:00
|
|
|
write_armatures(wd, &mainvar->armature);
|
2016-06-28 17:35:35 +10:00
|
|
|
write_actions(wd, &mainvar->action);
|
|
|
|
write_objects(wd, &mainvar->object);
|
2008-12-19 16:36:15 +00:00
|
|
|
write_materials(wd, &mainvar->mat);
|
2016-06-28 17:35:35 +10:00
|
|
|
write_textures(wd, &mainvar->tex);
|
|
|
|
write_meshes(wd, &mainvar->mesh);
|
2008-12-19 16:36:15 +00:00
|
|
|
write_particlesettings(wd, &mainvar->particle);
|
|
|
|
write_nodetrees(wd, &mainvar->nodetree);
|
2016-06-28 17:35:35 +10:00
|
|
|
write_brushes(wd, &mainvar->brush);
|
|
|
|
write_palettes(wd, &mainvar->palettes);
|
|
|
|
write_paintcurves(wd, &mainvar->paintcurves);
|
|
|
|
write_gpencils(wd, &mainvar->gpencil);
|
2010-06-25 22:45:42 +00:00
|
|
|
write_linestyles(wd, &mainvar->linestyle);
|
2009-10-20 16:43:25 +00:00
|
|
|
write_libraries(wd, mainvar->next);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2016-06-28 21:00:00 +10:00
|
|
|
if (write_flags & G_FILE_USERPREFS) {
|
2002-10-12 11:37:38 +00:00
|
|
|
write_userdef(wd);
|
|
|
|
}
|
2016-06-28 17:35:35 +10:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* dna as last, because (to be implemented) test for which structs are written */
|
2002-10-12 11:37:38 +00:00
|
|
|
writedata(wd, DNA1, wd->sdna->datalen, wd->sdna->data);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
#ifdef USE_NODE_COMPAT_CUSTOMNODES
|
2013-03-24 12:13:13 +00:00
|
|
|
/* compatibility data not created on undo */
|
|
|
|
if (!current) {
|
|
|
|
/* Ugly, forward compatibility code generates deprecated data during writing,
|
|
|
|
* this has to be freed again. Can not be done directly after writing, otherwise
|
|
|
|
* the data pointers could be reused and not be mapped correctly.
|
|
|
|
*/
|
|
|
|
customnodes_free_deprecated_data(mainvar);
|
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
#endif
|
|
|
|
|
2004-09-05 13:43:51 +00:00
|
|
|
/* end of file */
|
|
|
|
memset(&bhead, 0, sizeof(BHead));
|
2016-06-28 17:35:35 +10:00
|
|
|
bhead.code = ENDB;
|
2004-09-05 13:43:51 +00:00
|
|
|
mywrite(wd, &bhead, sizeof(BHead));
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
blo_join_main(&mainlist);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return endwrite(wd);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2011-11-26 13:11:55 +00:00
|
|
|
char tempname1[FILE_MAX], tempname2[FILE_MAX];
|
2016-06-28 17:35:35 +10:00
|
|
|
int hisnr = U.versions;
|
|
|
|
|
|
|
|
if (U.versions == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen(name) < 2) {
|
2011-06-02 12:44:59 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Unable to make version backup: filename too short");
|
|
|
|
return 1;
|
|
|
|
}
|
2016-02-03 17:06:42 +11:00
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
while (hisnr > 1) {
|
2016-06-28 17:35:35 +10:00
|
|
|
BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr - 1);
|
2016-02-03 17:06:42 +11:00
|
|
|
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;
|
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2011-06-02 12:44:59 +00:00
|
|
|
hisnr--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* is needed when hisnr==1 */
|
2016-02-03 17:06:42 +11:00
|
|
|
if (BLI_exists(name)) {
|
|
|
|
BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr);
|
2011-06-02 12:44:59 +00:00
|
|
|
|
2016-02-03 17:06:42 +11:00
|
|
|
if (BLI_rename(name, tempname1)) {
|
|
|
|
BKE_report(reports, RPT_ERROR, "Unable to make version backup");
|
|
|
|
return true;
|
|
|
|
}
|
2011-06-02 12:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-03-03 13:35:21 +11:00
|
|
|
/**
|
|
|
|
* \return Success.
|
|
|
|
*/
|
|
|
|
bool BLO_write_file(
|
|
|
|
Main *mainvar, const char *filepath, int write_flags,
|
|
|
|
ReportList *reports, const BlendThumbnail *thumb)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2016-06-28 17:35:35 +10:00
|
|
|
char tempname[FILE_MAX + 1];
|
2014-09-04 21:48:36 +10:00
|
|
|
eWriteWrapType ww_type;
|
|
|
|
WriteWrap ww;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2012-11-07 04:13:03 +00:00
|
|
|
/* path backup/restore */
|
|
|
|
void *path_list_backup = NULL;
|
2012-12-15 15:31:50 +00:00
|
|
|
const int path_list_flag = (BKE_BPATH_TRAVERSE_SKIP_LIBRARY | BKE_BPATH_TRAVERSE_SKIP_MULTIFILE);
|
2012-11-07 04:13:03 +00:00
|
|
|
|
2010-01-29 11:26:17 +00:00
|
|
|
/* open temporary file, so we preserve the original in case we crash */
|
2011-05-18 06:27:32 +00:00
|
|
|
BLI_snprintf(tempname, sizeof(tempname), "%s@", filepath);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2014-09-04 21:48:36 +10:00
|
|
|
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) {
|
2012-10-19 16:43:10 +00:00
|
|
|
BKE_reportf(reports, RPT_ERROR, "Cannot open file %s for writing: %s", tempname, strerror(errno));
|
2002-10-12 11:37:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2012-11-07 04:13:03 +00:00
|
|
|
/* check if we need to backup and restore paths */
|
|
|
|
if (UNLIKELY((write_flags & G_FILE_RELATIVE_REMAP) && (G_FILE_SAVE_COPY & write_flags))) {
|
2012-12-15 15:31:50 +00:00
|
|
|
path_list_backup = BKE_bpath_list_backup(mainvar, path_list_flag);
|
2012-11-07 04:13:03 +00:00
|
|
|
}
|
|
|
|
|
2010-01-29 11:26:17 +00:00
|
|
|
/* remapping of relative paths to new file location */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (write_flags & G_FILE_RELATIVE_REMAP) {
|
2011-11-26 13:11:55 +00:00
|
|
|
char dir1[FILE_MAX];
|
|
|
|
char dir2[FILE_MAX];
|
2011-10-21 02:13:36 +00:00
|
|
|
BLI_split_dir_part(filepath, dir1, sizeof(dir1));
|
|
|
|
BLI_split_dir_part(mainvar->name, dir2, sizeof(dir2));
|
2010-01-08 17:50:55 +00:00
|
|
|
|
2012-03-09 00:41:09 +00:00
|
|
|
/* just in case there is some subtle difference */
|
2010-01-08 20:55:13 +00:00
|
|
|
BLI_cleanup_dir(mainvar->name, dir1);
|
|
|
|
BLI_cleanup_dir(mainvar->name, dir2);
|
2010-01-08 17:50:55 +00:00
|
|
|
|
2013-11-27 21:25:15 +11:00
|
|
|
if (G.relbase_valid && (BLI_path_cmp(dir1, dir2) == 0)) {
|
2010-01-08 17:50:55 +00:00
|
|
|
write_flags &= ~G_FILE_RELATIVE_REMAP;
|
2011-05-18 06:48:52 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (G.relbase_valid) {
|
2011-05-18 06:48:52 +00:00
|
|
|
/* blend may not have been saved before. Tn this case
|
|
|
|
* we should not have any relative paths, but if there
|
|
|
|
* is somehow, an invalid or empty G.main->name it will
|
2012-03-18 07:38:51 +00:00
|
|
|
* print an error, don't try make the absolute in this case. */
|
2012-12-15 15:31:50 +00:00
|
|
|
BKE_bpath_absolute_convert(mainvar, G.main->name, NULL);
|
2011-05-18 06:48:52 +00:00
|
|
|
}
|
|
|
|
}
|
2010-01-08 17:50:55 +00:00
|
|
|
}
|
|
|
|
|
2016-06-28 17:35:35 +10:00
|
|
|
if (write_flags & G_FILE_RELATIVE_REMAP) {
|
|
|
|
/* note, making relative to something OTHER then G.main->name */
|
|
|
|
BKE_bpath_relative_convert(mainvar, filepath, NULL);
|
|
|
|
}
|
2010-01-08 17:50:55 +00:00
|
|
|
|
2010-01-29 11:26:17 +00:00
|
|
|
/* actual file writing */
|
2016-06-28 21:00:00 +10:00
|
|
|
const bool err = write_file_handle(mainvar, &ww, NULL, NULL, write_flags, thumb);
|
2014-09-04 21:48:36 +10:00
|
|
|
|
|
|
|
ww.close(&ww);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2012-11-07 04:13:03 +00:00
|
|
|
if (UNLIKELY(path_list_backup)) {
|
2012-12-15 15:31:50 +00:00
|
|
|
BKE_bpath_list_restore(mainvar, path_list_flag, path_list_backup);
|
|
|
|
BKE_bpath_list_free(path_list_backup);
|
2012-11-07 04:13:03 +00:00
|
|
|
}
|
|
|
|
|
2011-06-02 12:44:59 +00:00
|
|
|
if (err) {
|
|
|
|
BKE_report(reports, RPT_ERROR, strerror(errno));
|
|
|
|
remove(tempname);
|
2010-01-29 11:26:17 +00:00
|
|
|
|
2011-06-02 12:44:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2010-01-29 11:26:17 +00:00
|
|
|
|
2011-06-02 12:44:59 +00:00
|
|
|
/* file save to temporary file was successful */
|
|
|
|
/* now do reverse file history (move .blend1 -> .blend2, .blend -> .blend1) */
|
2012-10-21 05:46:41 +00:00
|
|
|
if (write_flags & G_FILE_HISTORY) {
|
2014-02-03 18:55:59 +11:00
|
|
|
const bool err_hist = do_history(filepath, reports);
|
2011-06-02 12:44:59 +00:00
|
|
|
if (err_hist) {
|
2012-10-13 15:44:50 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Version backup failed (file saved with @)");
|
2011-06-02 12:44:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-04 21:48:36 +10:00
|
|
|
if (BLI_rename(tempname, filepath) != 0) {
|
2012-10-19 16:43:10 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Cannot change old file (file saved with @)");
|
2002-10-12 11:37:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2016-06-28 21:00:00 +10:00
|
|
|
write_flags &= ~G_FILE_USERPREFS;
|
2004-09-05 13:43:51 +00:00
|
|
|
|
2016-06-28 21:00:00 +10:00
|
|
|
const bool err = write_file_handle(mainvar, NULL, compare, current, write_flags, 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
|
|
|
|
2016-03-03 13:35:21 +11:00
|
|
|
return (err == 0);
|
|
|
|
}
|