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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/*
|
2003-04-26 18:01:01 +00:00
|
|
|
FILEFORMAT: IFF-style structure (but not IFF compatible!)
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
start file:
|
|
|
|
BLENDER_V100 12 bytes (versie 1.00)
|
|
|
|
V = big endian, v = little endian
|
|
|
|
_ = 4 byte pointer, - = 8 byte pointer
|
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
datablocks: also see struct BHead
|
2002-10-12 11:37:38 +00:00
|
|
|
<bh.code> 4 chars
|
2003-04-26 18:01:01 +00:00
|
|
|
<bh.len> int, len data after BHead
|
|
|
|
<bh.old> void, old pointer
|
2002-10-12 11:37:38 +00:00
|
|
|
<bh.SDNAnr> int
|
2003-04-26 18:01:01 +00:00
|
|
|
<bh.nr> int, in case of array: amount of structs
|
2004-06-23 18:22:51 +00:00
|
|
|
data
|
2002-10-12 11:37:38 +00:00
|
|
|
...
|
|
|
|
...
|
|
|
|
|
2003-04-26 18:01:01 +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 .
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
WRITE
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-26 18:01:01 +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
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
(Local file data)
|
|
|
|
- for each LibBlock
|
|
|
|
- write LibBlock
|
|
|
|
- write associated direct data
|
|
|
|
(External file data)
|
2002-10-12 11:37:38 +00:00
|
|
|
- per library
|
2003-04-26 18:01:01 +00:00
|
|
|
- write library block
|
2002-10-12 11:37:38 +00:00
|
|
|
- per LibBlock
|
2003-04-26 18:01:01 +00:00
|
|
|
- write the ID of LibBlock
|
2010-05-24 21:52:18 +00:00
|
|
|
- write TEST (128x128, blend file preview, optional)
|
2003-04-26 18:01:01 +00:00
|
|
|
- write FileGlobal (some global vars)
|
|
|
|
- write SDNA
|
2010-07-15 11:51:43 +00:00
|
|
|
- write USER if filename is ~/X.XX/config/startup.blend
|
2003-04-26 18:01:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2005-07-27 21:31:44 +00:00
|
|
|
#include "zlib.h"
|
|
|
|
|
2004-06-23 18:22:51 +00:00
|
|
|
#ifndef WIN32
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#else
|
|
|
|
#include "winsock2.h"
|
|
|
|
#include <io.h>
|
|
|
|
#include <process.h> // for getpid
|
2009-09-16 17:43:09 +00:00
|
|
|
#include "BLI_winstuff.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif
|
|
|
|
|
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"
|
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"
|
|
|
|
#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"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-06-23 18:22:51 +00:00
|
|
|
#include "MEM_guardedalloc.h" // MEM_freeN
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_linklist.h"
|
2010-01-08 17:50:55 +00:00
|
|
|
#include "BLI_bpath.h"
|
2011-09-06 16:51:10 +00:00
|
|
|
#include "BLI_math.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include "BKE_action.h"
|
2006-11-26 21:17:15 +00:00
|
|
|
#include "BKE_blender.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
|
|
|
|
#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"
|
2011-01-07 19:18:31 +00:00
|
|
|
#include "BKE_utildefines.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
|
|
|
|
|
|
|
#include "BLO_writefile.h"
|
|
|
|
#include "BLO_readfile.h"
|
2004-09-05 13:43:51 +00:00
|
|
|
#include "BLO_undofile.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include "readfile.h"
|
|
|
|
|
Patch provided by Shaul Kedem: Compressed files are back!
He even made a nice doc in wiki:
http://wiki.blender.org/bin/view.pl/Blenderdev/Blendgz
Usage: set the option "Compress File" in the main "File" pulldown menu.
This setting is a user-def, meaning it is not changed on reading files.
If you want it default, save it with CTRL+U.
The longest debate went over the file naming convention. Shaul started
with .blend.gz files, which gave issues in Blender because of the code
hanging out everywhere that detects blender files, and that appends the
.blend extension if needed.
Daniel Dunbar proposed to just save it as .blend, and not bother users
with such details. This is indeed the most elegant solution, with as
only drawback that old Blender executables cannot read it.
This drawback isn't very relevant at the moment, since we're heading
towards a release that isn't upward compatible anyway... the recode
going on on Meshes, Modfiers, Armatures, Poses, Actions, NLA already
have upward compatibility issues.
We might check - during the next month(s) - on a builtin system to
warn users in the future when we change things that make a file risky
to read in an older release.
2005-07-27 19:46:06 +00:00
|
|
|
#include <errno.h>
|
2004-09-05 13:43:51 +00:00
|
|
|
|
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
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
typedef struct {
|
|
|
|
struct SDNA *sdna;
|
|
|
|
|
|
|
|
int file;
|
|
|
|
unsigned char *buf;
|
2004-09-05 13:43:51 +00:00
|
|
|
MemFile *compare, *current;
|
|
|
|
|
|
|
|
int tot, count, error, memsize;
|
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
|
|
|
char use_mesh_compat; /* option to save with older mesh format */
|
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
} WriteData;
|
|
|
|
|
This commit removes the glue from Blender, and with it
the directories decrypt, deflate, encrypt, inflate, readstreamglue,
sign, writeblenfile and writestreamglue.
Sirdude was so kind to modify the makefiles, so SCons and
Make are ready to build with the new Blender.
Visual Studio workspaces, solutions and projectfiles still need
to be updated (I'll do the .vcprojs and .sln myself after this commit).
Runtimes created with the Blender Publisher are not anymore
recognised - if you want these available, you'll have to convert
them first to .blends with the Publisher.
2004-04-16 15:55:16 +00:00
|
|
|
static WriteData *writedata_new(int file)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
WriteData *wd= MEM_callocN(sizeof(*wd), "writedata");
|
|
|
|
|
|
|
|
/* XXX, see note about this in readfile.c, remove
|
|
|
|
* once we have an xp lock - zr
|
|
|
|
*/
|
2006-10-27 18:24:10 +00:00
|
|
|
|
|
|
|
if (wd == NULL) return NULL;
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
wd->sdna= DNA_sdna_from_data(DNAstr, DNAlen, 0);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
wd->file= file;
|
|
|
|
|
2008-03-05 15:13:41 +00: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void writedata_do_write(WriteData *wd, void *mem, int memlen)
|
|
|
|
{
|
2006-10-27 18:24:10 +00:00
|
|
|
if ((wd == NULL) || wd->error || (mem == NULL) || memlen < 1) return;
|
2002-10-12 11:37:38 +00:00
|
|
|
if (wd->error) return;
|
2004-09-05 13:43:51 +00:00
|
|
|
|
|
|
|
/* memory based save */
|
|
|
|
if(wd->current) {
|
|
|
|
add_memfilechunk(NULL, wd->current, mem, memlen);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (write(wd->file, mem, memlen) != memlen)
|
|
|
|
wd->error= 1;
|
|
|
|
|
|
|
|
}
|
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
|
|
|
|
* @param adr Pointer to new chunk of data
|
|
|
|
* @param len Length of new chunk of data
|
|
|
|
* @warning Talks to other functions with global parameters
|
|
|
|
*/
|
2004-09-05 13:43:51 +00:00
|
|
|
|
2008-03-05 15:13:41 +00:00
|
|
|
#define MYWRITE_FLUSH NULL
|
2004-09-05 13:43:51 +00:00
|
|
|
|
|
|
|
static void mywrite( WriteData *wd, void *adr, int len)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
if (wd->error) return;
|
|
|
|
|
2008-03-05 15:13:41 +00:00
|
|
|
/* flush helps compression for undo-save */
|
2004-09-05 13:43:51 +00:00
|
|
|
if(adr==MYWRITE_FLUSH) {
|
|
|
|
if(wd->count) {
|
|
|
|
writedata_do_write(wd, wd->buf, wd->count);
|
|
|
|
wd->count= 0;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-09-05 13:43:51 +00: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 */
|
|
|
|
if(len>MYWRITE_MAX_CHUNK) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(wd->count) {
|
|
|
|
writedata_do_write(wd, wd->buf, wd->count);
|
|
|
|
wd->count= 0;
|
|
|
|
}
|
2008-03-05 15:13:41 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
int writelen= MIN2(len, MYWRITE_MAX_CHUNK);
|
|
|
|
writedata_do_write(wd, adr, writelen);
|
|
|
|
adr = (char*)adr + writelen;
|
|
|
|
len -= writelen;
|
|
|
|
} while(len > 0);
|
|
|
|
|
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 */
|
|
|
|
if(len+wd->count>MYWRITE_BUFFER_SIZE-1) {
|
2002-10-12 11:37:38 +00:00
|
|
|
writedata_do_write(wd, wd->buf, wd->count);
|
2004-06-23 18:22:51 +00: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);
|
|
|
|
wd->count+= len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* BeGiN initializer for mywrite
|
|
|
|
* @param file File descriptor
|
|
|
|
* @param write_flags Write parameters
|
|
|
|
* @warning Talks to other functions with global parameters
|
|
|
|
*/
|
2010-09-06 12:54:54 +00:00
|
|
|
static WriteData *bgnwrite(int file, MemFile *compare, MemFile *current)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
This commit removes the glue from Blender, and with it
the directories decrypt, deflate, encrypt, inflate, readstreamglue,
sign, writeblenfile and writestreamglue.
Sirdude was so kind to modify the makefiles, so SCons and
Make are ready to build with the new Blender.
Visual Studio workspaces, solutions and projectfiles still need
to be updated (I'll do the .vcprojs and .sln myself after this commit).
Runtimes created with the Blender Publisher are not anymore
recognised - if you want these available, you'll have to convert
them first to .blends with the Publisher.
2004-04-16 15:55:16 +00:00
|
|
|
WriteData *wd= writedata_new(file);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2006-10-27 18:24:10 +00:00
|
|
|
if (wd == NULL) return NULL;
|
|
|
|
|
2004-09-05 13:43:51 +00:00
|
|
|
wd->compare= compare;
|
|
|
|
wd->current= current;
|
|
|
|
/* this inits comparing */
|
|
|
|
add_memfilechunk(compare, NULL, NULL, 0);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return wd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* END the mywrite wrapper
|
|
|
|
* @return 1 if write failed
|
|
|
|
* @return unknown global variable otherwise
|
|
|
|
* @warning Talks to other functions with global parameters
|
|
|
|
*/
|
2004-09-05 13:43:51 +00:00
|
|
|
static int endwrite(WriteData *wd)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
int err;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if (wd->count) {
|
|
|
|
writedata_do_write(wd, wd->buf, wd->count);
|
2004-06-23 18:22:51 +00:00
|
|
|
wd->count= 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-09-05 13:43:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
err= wd->error;
|
|
|
|
writedata_free(wd);
|
2007-02-14 11:00:05 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ********** WRITE FILE ****************** */
|
|
|
|
|
2010-12-03 17:05:21 +00:00
|
|
|
static void writestruct(WriteData *wd, int filecode, const char *structname, int nr, void *adr)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
BHead bh;
|
|
|
|
short *sp;
|
2004-06-23 18:22:51 +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
|
|
|
if(adr==NULL || nr==0) return;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* init BHead */
|
2002-10-12 11:37:38 +00:00
|
|
|
bh.code= filecode;
|
|
|
|
bh.old= adr;
|
|
|
|
bh.nr= nr;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
bh.SDNAnr= DNA_struct_find_nr(wd->sdna, structname);
|
2002-10-12 11:37:38 +00:00
|
|
|
if(bh.SDNAnr== -1) {
|
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
|
|
|
printf("error: can't find SDNA code <%s>\n", structname);
|
2002-10-12 11:37:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
sp= wd->sdna->structs[bh.SDNAnr];
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
bh.len= nr*wd->sdna->typelens[sp[0]];
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00: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));
|
|
|
|
mywrite(wd, adr, bh.len);
|
|
|
|
}
|
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
static void writedata(WriteData *wd, int filecode, int len, 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
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
if(adr==NULL) return;
|
2002-10-12 11:37:38 +00:00
|
|
|
if(len==0) return;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
len+= 3;
|
|
|
|
len-= ( len % 4);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* init BHead */
|
2002-10-12 11:37:38 +00:00
|
|
|
bh.code= filecode;
|
|
|
|
bh.old= adr;
|
|
|
|
bh.nr= 1;
|
2004-06-23 18:22:51 +00:00
|
|
|
bh.SDNAnr= 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
bh.len= len;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
mywrite(wd, &bh, sizeof(BHead));
|
|
|
|
if(len) mywrite(wd, adr, len);
|
|
|
|
}
|
|
|
|
|
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.*/
|
|
|
|
void IDP_WriteProperty_OnlyData(IDProperty *prop, void *wd);
|
|
|
|
void IDP_WriteProperty(IDProperty *prop, void *wd);
|
|
|
|
|
2008-09-29 17:08:11 +00:00
|
|
|
static void IDP_WriteArray(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
|
|
|
|
2008-12-31 13:16:37 +00:00
|
|
|
if(prop->subtype == IDP_GROUP) {
|
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
|
|
|
IDProperty **array= prop->data.pointer;
|
|
|
|
int a;
|
|
|
|
|
|
|
|
for(a=0; a<prop->len; a++)
|
|
|
|
IDP_WriteProperty(array[a], wd);
|
|
|
|
}
|
2006-11-17 04:46:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-31 13:16:37 +00:00
|
|
|
static void IDP_WriteIDPArray(IDProperty *prop, void *wd)
|
|
|
|
{
|
|
|
|
/*REMEMBER to set totalen to len in the linking code!!*/
|
|
|
|
if (prop->data.pointer) {
|
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
|
|
|
IDProperty *array = prop->data.pointer;
|
2008-12-31 13:16:37 +00:00
|
|
|
int 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
|
|
|
writestruct(wd, DATA, "IDProperty", prop->len, array);
|
2008-12-31 13:16:37 +00: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);
|
2008-12-31 13:16:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-29 17:08:11 +00:00
|
|
|
static void IDP_WriteString(IDProperty *prop, void *wd)
|
2006-11-17 04:46:48 +00:00
|
|
|
{
|
|
|
|
/*REMEMBER to set totalen to len in the linking code!!*/
|
|
|
|
writedata(wd, DATA, prop->len+1, prop->data.pointer);
|
|
|
|
}
|
|
|
|
|
2008-09-29 17:08:11 +00:00
|
|
|
static void IDP_WriteGroup(IDProperty *prop, void *wd)
|
2006-11-17 04:46:48 +00:00
|
|
|
{
|
|
|
|
IDProperty *loop;
|
|
|
|
|
|
|
|
for (loop=prop->data.group.first; loop; loop=loop->next) {
|
|
|
|
IDP_WriteProperty(loop, wd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Functions to read/write ID Properties */
|
|
|
|
void IDP_WriteProperty_OnlyData(IDProperty *prop, void *wd)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void IDP_WriteProperty(IDProperty *prop, void *wd)
|
|
|
|
{
|
|
|
|
writestruct(wd, DATA, "IDProperty", 1, prop);
|
|
|
|
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
|
|
|
|
2010-12-13 08:08:09 +00:00
|
|
|
static void write_fmodifiers(WriteData *wd, ListBase *fmodifiers)
|
|
|
|
{
|
|
|
|
FModifier *fcm;
|
|
|
|
|
|
|
|
/* Modifiers */
|
|
|
|
for (fcm= fmodifiers->first; fcm; fcm= fcm->next) {
|
|
|
|
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
|
|
|
|
|
|
|
|
/* Write the specific data */
|
|
|
|
if (fmi && fcm->data) {
|
|
|
|
/* firstly, just write the plain fmi->data struct */
|
|
|
|
writestruct(wd, DATA, fmi->structName, 1, fcm->data);
|
|
|
|
|
|
|
|
/* do any modifier specific stuff */
|
|
|
|
switch (fcm->type) {
|
|
|
|
case FMODIFIER_TYPE_GENERATOR:
|
|
|
|
{
|
|
|
|
FMod_Generator *data= (FMod_Generator *)fcm->data;
|
|
|
|
|
|
|
|
/* write coefficients array */
|
|
|
|
if (data->coefficients)
|
|
|
|
writedata(wd, DATA, sizeof(float)*(data->arraysize), data->coefficients);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FMODIFIER_TYPE_ENVELOPE:
|
|
|
|
{
|
|
|
|
FMod_Envelope *data= (FMod_Envelope *)fcm->data;
|
|
|
|
|
|
|
|
/* write envelope data */
|
|
|
|
if (data->data)
|
2011-03-24 09:53:39 +00:00
|
|
|
writestruct(wd, DATA, "FCM_EnvelopeData", data->totvert, data->data);
|
2010-12-13 08:08:09 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FMODIFIER_TYPE_PYTHON:
|
|
|
|
{
|
|
|
|
FMod_Python *data = (FMod_Python *)fcm->data;
|
|
|
|
|
|
|
|
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
|
|
|
|
of library blocks that implement this.*/
|
|
|
|
IDP_WriteProperty(data->prop, wd);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write the modifier */
|
|
|
|
writestruct(wd, DATA, "FModifier", 1, fcm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_fcurves(WriteData *wd, ListBase *fcurves)
|
|
|
|
{
|
|
|
|
FCurve *fcu;
|
|
|
|
|
|
|
|
for (fcu=fcurves->first; fcu; fcu=fcu->next) {
|
|
|
|
/* F-Curve */
|
|
|
|
writestruct(wd, DATA, "FCurve", 1, fcu);
|
|
|
|
|
|
|
|
/* curve data */
|
|
|
|
if (fcu->bezt)
|
|
|
|
writestruct(wd, DATA, "BezTriple", fcu->totvert, fcu->bezt);
|
|
|
|
if (fcu->fpt)
|
|
|
|
writestruct(wd, DATA, "FPoint", fcu->totvert, fcu->fpt);
|
|
|
|
|
|
|
|
if (fcu->rna_path)
|
|
|
|
writedata(wd, DATA, strlen(fcu->rna_path)+1, fcu->rna_path);
|
|
|
|
|
|
|
|
/* driver data */
|
|
|
|
if (fcu->driver) {
|
|
|
|
ChannelDriver *driver= fcu->driver;
|
|
|
|
DriverVar *dvar;
|
|
|
|
|
|
|
|
writestruct(wd, DATA, "ChannelDriver", 1, driver);
|
|
|
|
|
|
|
|
/* variables */
|
|
|
|
for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
|
|
|
|
writestruct(wd, DATA, "DriverVar", 1, dvar);
|
|
|
|
|
|
|
|
DRIVER_TARGETS_USED_LOOPER(dvar)
|
|
|
|
{
|
|
|
|
if (dtar->rna_path)
|
|
|
|
writedata(wd, DATA, strlen(dtar->rna_path)+1, dtar->rna_path);
|
|
|
|
}
|
|
|
|
DRIVER_TARGETS_LOOPER_END
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write F-Modifiers */
|
|
|
|
write_fmodifiers(wd, &fcu->modifiers);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_actions(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
bAction *act;
|
|
|
|
bActionGroup *grp;
|
|
|
|
TimeMarker *marker;
|
|
|
|
|
|
|
|
for(act=idbase->first; act; act= act->id.next) {
|
|
|
|
if (act->id.us>0 || wd->current) {
|
|
|
|
writestruct(wd, ID_AC, "bAction", 1, act);
|
|
|
|
if (act->id.properties) IDP_WriteProperty(act->id.properties, wd);
|
|
|
|
|
|
|
|
write_fcurves(wd, &act->curves);
|
|
|
|
|
|
|
|
for (grp=act->groups.first; grp; grp=grp->next) {
|
|
|
|
writestruct(wd, DATA, "bActionGroup", 1, grp);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (marker=act->markers.first; marker; marker=marker->next) {
|
|
|
|
writestruct(wd, DATA, "TimeMarker", 1, marker);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
for (ks= list->first; ks; ks= ks->next) {
|
|
|
|
/* KeyingSet */
|
|
|
|
writestruct(wd, DATA, "KeyingSet", 1, ks);
|
|
|
|
|
|
|
|
/* Paths */
|
|
|
|
for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
|
|
|
|
/* Path */
|
|
|
|
writestruct(wd, DATA, "KS_Path", 1, ksp);
|
|
|
|
|
|
|
|
if (ksp->rna_path)
|
|
|
|
writedata(wd, DATA, strlen(ksp->rna_path)+1, ksp->rna_path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_nlastrips(WriteData *wd, ListBase *strips)
|
|
|
|
{
|
|
|
|
NlaStrip *strip;
|
|
|
|
|
|
|
|
for (strip= strips->first; strip; strip= strip->next) {
|
|
|
|
/* write the strip first */
|
|
|
|
writestruct(wd, DATA, "NlaStrip", 1, strip);
|
|
|
|
|
|
|
|
/* write the strip's F-Curves and modifiers */
|
|
|
|
write_fcurves(wd, &strip->fcurves);
|
|
|
|
write_fmodifiers(wd, &strip->modifiers);
|
|
|
|
|
|
|
|
/* write the strip's children */
|
|
|
|
write_nlastrips(wd, &strip->strips);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_nladata(WriteData *wd, ListBase *nlabase)
|
|
|
|
{
|
|
|
|
NlaTrack *nlt;
|
|
|
|
|
|
|
|
/* write all the tracks */
|
|
|
|
for (nlt= nlabase->first; nlt; nlt= nlt->next) {
|
|
|
|
/* write the track first */
|
|
|
|
writestruct(wd, DATA, "NlaTrack", 1, nlt);
|
|
|
|
|
|
|
|
/* write the track's strips */
|
|
|
|
write_nlastrips(wd, &nlt->strips);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_animdata(WriteData *wd, AnimData *adt)
|
|
|
|
{
|
|
|
|
AnimOverride *aor;
|
|
|
|
|
|
|
|
/* firstly, just write the AnimData block */
|
|
|
|
writestruct(wd, DATA, "AnimData", 1, adt);
|
|
|
|
|
|
|
|
/* write drivers */
|
|
|
|
write_fcurves(wd, &adt->drivers);
|
|
|
|
|
|
|
|
/* write overrides */
|
|
|
|
// FIXME: are these needed?
|
|
|
|
for (aor= adt->overrides.first; aor; aor= aor->next) {
|
|
|
|
/* overrides consist of base data + rna_path */
|
|
|
|
writestruct(wd, DATA, "AnimOverride", 1, aor);
|
|
|
|
writedata(wd, DATA, strlen(aor->rna_path)+1, aor->rna_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO write the remaps (if they are needed)
|
|
|
|
|
|
|
|
/* write NLA data */
|
|
|
|
write_nladata(wd, &adt->nla_tracks);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static void write_curvemapping(WriteData *wd, CurveMapping *cumap)
|
|
|
|
{
|
|
|
|
int a;
|
|
|
|
|
|
|
|
writestruct(wd, DATA, "CurveMapping", 1, cumap);
|
|
|
|
for(a=0; a<CM_TOT; a++)
|
|
|
|
writestruct(wd, DATA, "CurveMapPoint", cumap->cm[a].totpoint, cumap->cm[a].curve);
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
static void write_node_socket(WriteData *wd, bNodeSocket *sock)
|
|
|
|
{
|
|
|
|
bNodeSocketType *stype= ntreeGetSocketType(sock->type);
|
2011-09-06 16:51:10 +00:00
|
|
|
|
|
|
|
/* forward compatibility code, so older blenders still open */
|
|
|
|
sock->stack_type = 1;
|
2012-01-21 11:15:01 +00:00
|
|
|
|
2011-09-06 16:51:10 +00:00
|
|
|
if(sock->default_value) {
|
|
|
|
bNodeSocketValueFloat *valfloat;
|
|
|
|
bNodeSocketValueVector *valvector;
|
|
|
|
bNodeSocketValueRGBA *valrgba;
|
|
|
|
|
|
|
|
switch (sock->type) {
|
|
|
|
case SOCK_FLOAT:
|
|
|
|
valfloat = sock->default_value;
|
|
|
|
sock->ns.vec[0] = valfloat->value;
|
|
|
|
sock->ns.min = valfloat->min;
|
|
|
|
sock->ns.max = valfloat->max;
|
|
|
|
break;
|
|
|
|
case SOCK_VECTOR:
|
|
|
|
valvector = sock->default_value;
|
|
|
|
copy_v3_v3(sock->ns.vec, valvector->value);
|
|
|
|
sock->ns.min = valvector->min;
|
|
|
|
sock->ns.max = valvector->max;
|
|
|
|
break;
|
|
|
|
case SOCK_RGBA:
|
|
|
|
valrgba = sock->default_value;
|
|
|
|
copy_v4_v4(sock->ns.vec, valrgba->value);
|
|
|
|
sock->ns.min = 0.0f;
|
|
|
|
sock->ns.max = 1.0f;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* actual socket writing */
|
2011-09-05 21:01:50 +00:00
|
|
|
writestruct(wd, DATA, "bNodeSocket", 1, sock);
|
|
|
|
if (sock->default_value)
|
|
|
|
writestruct(wd, DATA, stype->value_structname, 1, sock->default_value);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* for link_list() speed, we write per list */
|
|
|
|
|
2009-12-03 10:23:38 +00:00
|
|
|
if(ntree->adt) write_animdata(wd, ntree->adt);
|
|
|
|
|
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(node= ntree->nodes.first; node; node= node->next)
|
|
|
|
writestruct(wd, DATA, "bNode", 1, node);
|
|
|
|
|
|
|
|
for(node= ntree->nodes.first; node; node= node->next) {
|
2011-09-05 21:01:50 +00:00
|
|
|
for(sock= node->inputs.first; sock; sock= sock->next)
|
|
|
|
write_node_socket(wd, sock);
|
|
|
|
for(sock= node->outputs.first; sock; sock= sock->next)
|
|
|
|
write_node_socket(wd, sock);
|
|
|
|
|
|
|
|
|
2008-02-09 23:17:15 +00:00
|
|
|
if(node->storage && node->type!=NODE_DYNAMIC) {
|
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 */
|
|
|
|
if(ntree->type==NTREE_SHADER && (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB))
|
|
|
|
write_curvemapping(wd, node->storage);
|
2010-01-21 00:00:45 +00:00
|
|
|
else if(ntree->type==NTREE_COMPOSIT && ELEM4(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);
|
2008-11-12 22:03:11 +00:00
|
|
|
else if(ntree->type==NTREE_TEXTURE && (node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME) )
|
|
|
|
write_curvemapping(wd, node->storage);
|
2011-11-07 12:56:05 +00:00
|
|
|
else if(ntree->type==NTREE_COMPOSIT && node->type==CMP_NODE_MOVIEDISTORTION)
|
|
|
|
/* pass */ ;
|
2011-09-05 21:01:50 +00:00
|
|
|
else
|
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
|
|
|
writestruct(wd, DATA, node->typeinfo->storagename, 1, node->storage);
|
|
|
|
}
|
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= ntree->links.first; link; link= link->next)
|
|
|
|
writestruct(wd, DATA, "bNodeLink", 1, link);
|
2011-02-21 13:47:49 +00:00
|
|
|
|
|
|
|
/* external sockets */
|
|
|
|
for(sock= ntree->inputs.first; sock; sock= sock->next)
|
2011-09-05 21:01:50 +00:00
|
|
|
write_node_socket(wd, sock);
|
2011-02-21 13:47:49 +00:00
|
|
|
for(sock= ntree->outputs.first; sock; sock= sock->next)
|
2011-09-05 21:01:50 +00:00
|
|
|
write_node_socket(wd, sock);
|
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
|
|
|
}
|
|
|
|
|
2008-12-19 16:36:15 +00:00
|
|
|
static void current_screen_compat(Main *mainvar, bScreen **screen)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2008-12-19 16:36:15 +00:00
|
|
|
wmWindowManager *wm;
|
|
|
|
wmWindow *window;
|
|
|
|
|
|
|
|
/* find a global current screen in the first open window, to have
|
|
|
|
* a reasonable default for reading in older versions */
|
|
|
|
wm= mainvar->wm.first;
|
|
|
|
window= (wm)? wm->windows.first: NULL;
|
|
|
|
*screen= (window)? window->screen: NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_renderinfo(WriteData *wd, Main *mainvar) /* for renderdeamon */
|
|
|
|
{
|
|
|
|
bScreen *curscreen;
|
2002-10-12 11:37:38 +00:00
|
|
|
Scene *sce;
|
|
|
|
int data[8];
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
/* XXX in future, handle multiple windows with multiple screnes? */
|
2008-12-19 16:36:15 +00:00
|
|
|
current_screen_compat(mainvar, &curscreen);
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
for(sce= mainvar->scene.first; sce; sce= sce->id.next) {
|
|
|
|
if(sce->id.lib==NULL && ( sce==curscreen->scene || (sce->r.scemode & R_BG_RENDER)) ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
data[0]= sce->r.sfra;
|
|
|
|
data[1]= sce->r.efra;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2006-12-01 19:52:04 +00:00
|
|
|
memset(data+2, 0, sizeof(int)*6);
|
2010-11-05 07:35:21 +00:00
|
|
|
BLI_strncpy((char *)(data+2), sce->id.name+2, sizeof(sce->id.name)-2);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
writedata(wd, REND, 32, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
writestruct(wd, DATA, "wmKeyMapItem", 1, kmi);
|
|
|
|
if(kmi->properties)
|
|
|
|
IDP_WriteProperty(kmi->properties, wd);
|
|
|
|
}
|
|
|
|
|
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;
|
2009-10-22 23:22:05 +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;
|
2011-06-24 14:00:15 +00:00
|
|
|
uiStyle *style;
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, USER, "UserDef", 1, &U);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
for(btheme= U.themes.first; btheme; btheme=btheme->next)
|
- 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
|
|
|
writestruct(wd, DATA, "bTheme", 1, btheme);
|
2009-10-22 23:22:05 +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
|
|
|
for(keymap= U.user_keymaps.first; keymap; keymap=keymap->next) {
|
2009-10-22 23:22:05 +00:00
|
|
|
writestruct(wd, DATA, "wmKeyMap", 1, keymap);
|
|
|
|
|
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
|
|
|
for(kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) {
|
|
|
|
writestruct(wd, DATA, "wmKeyMapDiffItem", 1, kmdi);
|
|
|
|
if(kmdi->remove_item)
|
|
|
|
write_keymapitem(wd, kmdi->remove_item);
|
|
|
|
if(kmdi->add_item)
|
|
|
|
write_keymapitem(wd, kmdi->add_item);
|
2009-10-22 23:22:05 +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
|
|
|
|
|
|
|
for(kmi=keymap->items.first; kmi; kmi=kmi->next)
|
|
|
|
write_keymapitem(wd, kmi);
|
- 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
|
|
|
|
2010-02-26 14:28:29 +00:00
|
|
|
for(bext= U.addons.first; bext; bext=bext->next)
|
|
|
|
writestruct(wd, DATA, "bAddon", 1, bext);
|
2011-06-24 14:00:15 +00:00
|
|
|
|
|
|
|
for(style= U.uistyles.first; style; style= style->next) {
|
|
|
|
writestruct(wd, DATA, "uiStyle", 1, style);
|
|
|
|
}
|
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;
|
|
|
|
//BoidCondition *cond = state->conditions.first;
|
|
|
|
|
|
|
|
writestruct(wd, DATA, "BoidState", 1, state);
|
|
|
|
|
|
|
|
for(; rule; rule=rule->next) {
|
|
|
|
switch(rule->type) {
|
|
|
|
case eBoidRuleType_Goal:
|
|
|
|
case eBoidRuleType_Avoid:
|
|
|
|
writestruct(wd, DATA, "BoidRuleGoalAvoid", 1, rule);
|
|
|
|
break;
|
|
|
|
case eBoidRuleType_AvoidCollision:
|
|
|
|
writestruct(wd, DATA, "BoidRuleAvoidCollision", 1, rule);
|
|
|
|
break;
|
|
|
|
case eBoidRuleType_FollowLeader:
|
|
|
|
writestruct(wd, DATA, "BoidRuleFollowLeader", 1, rule);
|
|
|
|
break;
|
|
|
|
case eBoidRuleType_AverageSpeed:
|
|
|
|
writestruct(wd, DATA, "BoidRuleAverageSpeed", 1, rule);
|
|
|
|
break;
|
|
|
|
case eBoidRuleType_Fight:
|
|
|
|
writestruct(wd, DATA, "BoidRuleFight", 1, rule);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
writestruct(wd, DATA, "BoidRule", 1, rule);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//for(; cond; cond=cond->next)
|
|
|
|
// writestruct(wd, DATA, "BoidCondition", 1, cond);
|
|
|
|
}
|
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:
|
|
|
|
"", // BPHYS_DATA_TIMES:
|
|
|
|
"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
|
|
|
|
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
|
|
|
for(; cache; cache=cache->next) {
|
|
|
|
writestruct(wd, DATA, "PointCache", 1, cache);
|
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
|
|
|
if((cache->flag & PTCACHE_DISK_CACHE)==0) {
|
|
|
|
PTCacheMem *pm = cache->mem_cache.first;
|
|
|
|
|
|
|
|
for(; pm; pm=pm->next) {
|
2011-01-09 19:09:41 +00:00
|
|
|
PTCacheExtra *extra = pm->extradata.first;
|
|
|
|
|
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
|
|
|
writestruct(wd, DATA, "PTCacheMem", 1, pm);
|
|
|
|
|
|
|
|
for(i=0; i<BPHYS_TOT_DATA; i++) {
|
2011-01-09 18:23:41 +00:00
|
|
|
if(pm->data[i] && pm->data_types & (1<<i)) {
|
2011-10-21 08:16:15 +00:00
|
|
|
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]);
|
|
|
|
else
|
2011-01-10 02:40:24 +00:00
|
|
|
writestruct(wd, DATA, ptcache_data_struct[i], pm->totpoint, pm->data[i]);
|
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
|
|
|
|
|
|
|
for(; extra; extra=extra->next) {
|
2011-10-21 08:16:15 +00:00
|
|
|
if(ptcache_extra_struct[extra->type][0]=='\0')
|
2011-01-09 19:09:41 +00:00
|
|
|
continue;
|
|
|
|
writestruct(wd, DATA, "PTCacheExtra", 1, extra);
|
2011-01-10 02:40:24 +00:00
|
|
|
writestruct(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-22 23:22:05 +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
|
|
|
|
|
|
|
part= idbase->first;
|
|
|
|
while(part) {
|
|
|
|
if(part->id.us>0 || wd->current) {
|
|
|
|
/* write LibData */
|
|
|
|
writestruct(wd, ID_PA, "ParticleSettings", 1, part);
|
2008-07-24 19:22:17 +00:00
|
|
|
if (part->id.properties) IDP_WriteProperty(part->id.properties, wd);
|
2009-06-24 02:11:36 +00:00
|
|
|
if (part->adt) write_animdata(wd, part->adt);
|
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
|
|
|
writestruct(wd, DATA, "PartDeflect", 1, part->pd);
|
2008-08-21 21:12:27 +00:00
|
|
|
writestruct(wd, DATA, "PartDeflect", 1, part->pd2);
|
2009-10-22 23:22:05 +00:00
|
|
|
writestruct(wd, DATA, "EffectorWeights", 1, part->effector_weights);
|
|
|
|
|
|
|
|
dw = part->dupliweights.first;
|
2011-07-15 13:32:02 +00:00
|
|
|
for(; dw; dw=dw->next) {
|
|
|
|
/* update indices */
|
|
|
|
dw->index = 0;
|
2011-08-23 20:49:06 +00:00
|
|
|
if(part->dup_group) { /* can be NULL if lining fails or set to None */
|
|
|
|
go = part->dup_group->gobject.first;
|
|
|
|
while(go && go->ob != dw->ob) {
|
|
|
|
go=go->next;
|
|
|
|
dw->index++;
|
|
|
|
}
|
2011-07-15 13:32:02 +00:00
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
writestruct(wd, DATA, "ParticleDupliWeight", 1, dw);
|
2011-07-15 13:32:02 +00:00
|
|
|
}
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
if(part->boids && part->phystype == PART_PHYS_BOIDS) {
|
|
|
|
BoidState *state = part->boids->states.first;
|
|
|
|
|
|
|
|
writestruct(wd, DATA, "BoidSettings", 1, part->boids);
|
|
|
|
|
|
|
|
for(; state; state=state->next)
|
|
|
|
write_boid_state(wd, state);
|
|
|
|
}
|
2010-04-04 12:29:06 +00:00
|
|
|
if(part->fluid && part->phystype == PART_PHYS_FLUID){
|
|
|
|
writestruct(wd, DATA, "SPHFluidSettings", 1, part->fluid);
|
|
|
|
}
|
2011-02-12 14:38:34 +00:00
|
|
|
|
|
|
|
for(a=0; a<MAX_MTEX; a++) {
|
|
|
|
if(part->mtex[a]) writestruct(wd, DATA, "MTex", 1, part->mtex[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
|
|
|
}
|
|
|
|
part= part->id.next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void write_particlesystems(WriteData *wd, ListBase *particles)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
for(; psys; psys=psys->next) {
|
|
|
|
writestruct(wd, DATA, "ParticleSystem", 1, psys);
|
|
|
|
|
|
|
|
if(psys->particles) {
|
|
|
|
writestruct(wd, DATA, "ParticleData", psys->totpart ,psys->particles);
|
|
|
|
|
|
|
|
if(psys->particles->hair) {
|
|
|
|
ParticleData *pa = psys->particles;
|
|
|
|
|
|
|
|
for(a=0; a<psys->totpart; a++, pa++)
|
2007-12-26 15:25:30 +00:00
|
|
|
writestruct(wd, DATA, "HairKey", pa->totkey, pa->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
|
|
|
}
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
if(psys->particles->boid && psys->part->phystype == PART_PHYS_BOIDS)
|
2009-09-16 17:43:09 +00:00
|
|
|
writestruct(wd, DATA, "BoidParticle", psys->totpart, psys->particles->boid);
|
2011-01-09 19:09:41 +00:00
|
|
|
|
|
|
|
if(psys->part->fluid && psys->part->phystype == PART_PHYS_FLUID && (psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS))
|
|
|
|
writestruct(wd, DATA, "ParticleSpring", psys->tot_fluidsprings, psys->fluid_springs);
|
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;
|
|
|
|
for(; pt; pt=pt->next)
|
|
|
|
writestruct(wd, DATA, "ParticleTarget", 1, pt);
|
2009-07-12 23:38:47 +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
|
|
|
if(psys->child) writestruct(wd, DATA, "ChildParticle", psys->totchild ,psys->child);
|
2009-09-16 17:43:09 +00:00
|
|
|
|
|
|
|
if(psys->clmd) {
|
|
|
|
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);
|
|
|
|
}
|
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
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
prop= lb->first;
|
|
|
|
while(prop) {
|
|
|
|
writestruct(wd, DATA, "bProperty", 1, prop);
|
2004-06-23 18:22:51 +00: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);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
prop= prop->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_sensors(WriteData *wd, ListBase *lb)
|
|
|
|
{
|
|
|
|
bSensor *sens;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
sens= lb->first;
|
|
|
|
while(sens) {
|
|
|
|
writestruct(wd, DATA, "bSensor", 1, sens);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
writedata(wd, DATA, sizeof(void *)*sens->totlinks, sens->links);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
switch(sens->type) {
|
|
|
|
case SENS_NEAR:
|
|
|
|
writestruct(wd, DATA, "bNearSensor", 1, sens->data);
|
|
|
|
break;
|
|
|
|
case SENS_MOUSE:
|
|
|
|
writestruct(wd, DATA, "bMouseSensor", 1, sens->data);
|
|
|
|
break;
|
|
|
|
case SENS_TOUCH:
|
|
|
|
writestruct(wd, DATA, "bTouchSensor", 1, sens->data);
|
|
|
|
break;
|
|
|
|
case SENS_KEYBOARD:
|
|
|
|
writestruct(wd, DATA, "bKeyboardSensor", 1, sens->data);
|
|
|
|
break;
|
|
|
|
case SENS_PROPERTY:
|
|
|
|
writestruct(wd, DATA, "bPropertySensor", 1, sens->data);
|
|
|
|
break;
|
2009-10-22 23:22:05 +00:00
|
|
|
case SENS_ARMATURE:
|
|
|
|
writestruct(wd, DATA, "bArmatureSensor", 1, sens->data);
|
|
|
|
break;
|
BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an
event at the start of the game or when entering a state or at
object creation. The event will be positive or negative
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed
with force. The control if of type "PID" (Propotional, Integral,
Derivate): the force is automatically adapted to achieve the
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style:
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world
coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
coordinates of LinV). No limitation means that the force
will grow as large as necessary to achieve the target
speed along that axis. Set a max value to limit the
accelaration along an axis (slow start) and set a min
value (negative) to limit the brake force.
P: Proportional coefficient of servo controller, don't set
directly unless you know what you're doing.
I: Integral coefficient of servo controller. Use low value
(<0.1) for slow reaction (sliding), high values (>0.5)
for hard control. The P coefficient will be automatically
set to 60 times the I coefficient (a reasonable value).
D: Derivate coefficient. Leave to 0 unless you know what
you're doing. High values create instability.
Notes: - This actuator works perfectly in zero friction
environment: the PID controller will simulate friction
by applying force as needed.
- This actuator is compatible with simple Drot motion
actuator but not with LinV and Dloc motion.
- (0,0,0) is a valid target speed.
- All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp: Time constant (in nb of frames) of distance and
orientation control.
Dist: Select to enable distance control and set target
distance. The object will be position at the given
distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be
detected.
N : Select to enable orientation control. The actuator will
change the orientation and the location of the object
so that it is parallel to the surface at the vertical
of the point of contact of the ray.
M/P : Select to enable material detection. Default is property
detection.
Property/Material: name of property/material that the target of
ray must have to be detected. If not set, property/
material filter is disabled and any collisioning object
within range will be detected.
PER : Select to enable persistent operation. Normally the
actuator disables itself automatically if the ray does
not reach a valid target.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
rotDamp: Time constant (in nb of frame) of orientation control.
0 : use Damp parameter.
>0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
does not change the position and orientation of the
object; it works as a ray sensor.
- The ray has no "X-ray" capability: if the first object
hit does not have the required property/material, it
returns no hit and the actuator disables itself unless
PER option is enabled.
- This actuator changes the position and orientation but
not the speed of the object. This has an important
implication in a gravity environment: the gravity will
cause the speed to increase although the object seems
to stay still (it is repositioned at each frame).
The gravity must be compensated in one way or another.
the new servo control motion actuator is the simplest
way: set the target speed along the ray axis to 0
and the servo control will automatically compensate
the gravity.
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is
placed BEFORE the Drot motion actuator (the order of
actuator is important)
- All parameters are accessible through Python.
Orientation constraint
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction.
time : Maximum activation time of actuator.
0 : unlimited.
>0: number of frames before automatic deactivation.
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
- This actuator changes the orientation of the object
and will conflict with Drot motion unless it is placed
BEFORE the Drot motion actuator (the order of
actuator is important).
- This actuator doesn't change the location and speed.
It is compatible with gravity.
- All parameters are accessible through Python.
Actuator sensor
===============
This sensor detects the activation and deactivation of actuators
of the same object. The sensor generates a positive pulse when
the corresponding sensor is activated and a negative pulse when
it is deactivated (the contrary if the Inv option is selected).
This is mostly useful to chain actions and to detect the loss of
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
want to detect the On-Off transition of an actuator
after it has been activated at least once, unselect the
Lvl and Inv options and use a NAND controller.
- Some actuators deactivates themselves immediately after
being activated. The sensor detects this situation as
an On-Off transition.
- The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
|
|
|
case SENS_ACTUATOR:
|
|
|
|
writestruct(wd, DATA, "bActuatorSensor", 1, sens->data);
|
|
|
|
break;
|
2008-08-16 20:45:37 +00:00
|
|
|
case SENS_DELAY:
|
|
|
|
writestruct(wd, DATA, "bDelaySensor", 1, sens->data);
|
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
case SENS_COLLISION:
|
|
|
|
writestruct(wd, DATA, "bCollisionSensor", 1, sens->data);
|
|
|
|
break;
|
|
|
|
case SENS_RADAR:
|
|
|
|
writestruct(wd, DATA, "bRadarSensor", 1, sens->data);
|
|
|
|
break;
|
|
|
|
case SENS_RANDOM:
|
|
|
|
writestruct(wd, DATA, "bRandomSensor", 1, sens->data);
|
|
|
|
break;
|
|
|
|
case SENS_RAY:
|
|
|
|
writestruct(wd, DATA, "bRaySensor", 1, sens->data);
|
|
|
|
break;
|
|
|
|
case SENS_MESSAGE:
|
|
|
|
writestruct(wd, DATA, "bMessageSensor", 1, sens->data);
|
|
|
|
break;
|
2005-01-23 01:36:29 +00:00
|
|
|
case SENS_JOYSTICK:
|
|
|
|
writestruct(wd, DATA, "bJoystickSensor", 1, sens->data);
|
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
default:
|
|
|
|
; /* error: don't know how to write this file */
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
sens= sens->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_controllers(WriteData *wd, ListBase *lb)
|
|
|
|
{
|
|
|
|
bController *cont;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
cont= lb->first;
|
|
|
|
while(cont) {
|
|
|
|
writestruct(wd, DATA, "bController", 1, cont);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
writedata(wd, DATA, sizeof(void *)*cont->totlinks, cont->links);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
switch(cont->type) {
|
|
|
|
case CONT_EXPRESSION:
|
|
|
|
writestruct(wd, DATA, "bExpressionCont", 1, cont->data);
|
|
|
|
break;
|
|
|
|
case CONT_PYTHON:
|
|
|
|
writestruct(wd, DATA, "bPythonCont", 1, cont->data);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
; /* error: don't know how to write this file */
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
cont= cont->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_actuators(WriteData *wd, ListBase *lb)
|
|
|
|
{
|
|
|
|
bActuator *act;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
act= lb->first;
|
|
|
|
while(act) {
|
|
|
|
writestruct(wd, DATA, "bActuator", 1, act);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
switch(act->type) {
|
|
|
|
case ACT_ACTION:
|
2008-06-18 06:46:49 +00:00
|
|
|
case ACT_SHAPEACTION:
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, DATA, "bActionActuator", 1, act->data);
|
|
|
|
break;
|
|
|
|
case ACT_SOUND:
|
|
|
|
writestruct(wd, DATA, "bSoundActuator", 1, act->data);
|
|
|
|
break;
|
|
|
|
case ACT_OBJECT:
|
|
|
|
writestruct(wd, DATA, "bObjectActuator", 1, act->data);
|
|
|
|
break;
|
|
|
|
case ACT_IPO:
|
|
|
|
writestruct(wd, DATA, "bIpoActuator", 1, act->data);
|
|
|
|
break;
|
|
|
|
case ACT_PROPERTY:
|
|
|
|
writestruct(wd, DATA, "bPropertyActuator", 1, act->data);
|
|
|
|
break;
|
|
|
|
case ACT_CAMERA:
|
|
|
|
writestruct(wd, DATA, "bCameraActuator", 1, act->data);
|
|
|
|
break;
|
|
|
|
case ACT_CONSTRAINT:
|
|
|
|
writestruct(wd, DATA, "bConstraintActuator", 1, act->data);
|
|
|
|
break;
|
|
|
|
case ACT_EDIT_OBJECT:
|
|
|
|
writestruct(wd, DATA, "bEditObjectActuator", 1, act->data);
|
|
|
|
break;
|
|
|
|
case ACT_SCENE:
|
|
|
|
writestruct(wd, DATA, "bSceneActuator", 1, act->data);
|
|
|
|
break;
|
|
|
|
case ACT_GROUP:
|
|
|
|
writestruct(wd, DATA, "bGroupActuator", 1, act->data);
|
|
|
|
break;
|
|
|
|
case ACT_RANDOM:
|
|
|
|
writestruct(wd, DATA, "bRandomActuator", 1, act->data);
|
|
|
|
break;
|
|
|
|
case ACT_MESSAGE:
|
|
|
|
writestruct(wd, DATA, "bMessageActuator", 1, act->data);
|
|
|
|
break;
|
|
|
|
case ACT_GAME:
|
|
|
|
writestruct(wd, DATA, "bGameActuator", 1, act->data);
|
|
|
|
break;
|
|
|
|
case ACT_VISIBILITY:
|
|
|
|
writestruct(wd, DATA, "bVisibilityActuator", 1, act->data);
|
|
|
|
break;
|
2007-10-22 20:24:26 +00:00
|
|
|
case ACT_2DFILTER:
|
|
|
|
writestruct(wd, DATA, "bTwoDFilterActuator", 1, act->data);
|
|
|
|
break;
|
2008-04-06 18:30:52 +00:00
|
|
|
case ACT_PARENT:
|
|
|
|
writestruct(wd, DATA, "bParentActuator", 1, act->data);
|
|
|
|
break;
|
BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of
sensor and actuators, full GUI support and selective display of sensors and actuators.
Note: Python API is available but not documented yet. It will be added asap.
State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value;
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers
that belong to active states. Sensors and actuators don't have a state mask but are effectively
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated,
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated,
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more
controllers of a single state) will generate a pulse each time the state becomes active. This feature is
not available on all sensors, see the notes below.
GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object.
The Ini button sets the state mask back to the object default state. You can change the default state
of object by first selecting the desired state mask and storing using the menu under the State button.
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender,
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.
The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility.
The new Sta button in the sensor and actuator column header allows you to display only the sensors and
actuators that are linked to visible controllers.
A new state actuator is available to modify the state during the game. It defines a bit mask and
the operation to apply on the current object state mask:
Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.
Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller
of the state as the state name. The GUI will support that convention by displaying as a hint the name
of the first controller of the state when you move the mouse over a state bit of the object state mask
or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are
part of a logical group, it is recommended to put the state engine only in the main object and to
link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1
so that all the controllers belong to this single state. This ensures backward compatibility with
existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are
guaranteed to execute before being eventually disabled due to the state change. This is useful for
example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
are acticated again, they will behave as follow:
* keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive
to new key press.
* collision sensor: objects already colliding won't be detected. Only new collisions are
detected.
* near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
|
|
|
case ACT_STATE:
|
|
|
|
writestruct(wd, DATA, "bStateActuator", 1, act->data);
|
|
|
|
break;
|
2009-10-22 23:22:05 +00:00
|
|
|
case ACT_ARMATURE:
|
|
|
|
writestruct(wd, DATA, "bArmatureActuator", 1, act->data);
|
|
|
|
break;
|
2010-05-31 22:35:22 +00:00
|
|
|
case ACT_STEERING:
|
|
|
|
writestruct(wd, DATA, "bSteeringActuator", 1, act->data);
|
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
default:
|
|
|
|
; /* error: don't know how to write this file */
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
act= act->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 */
|
|
|
|
if (mpath == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* firstly, just write the motionpath struct */
|
|
|
|
writestruct(wd, DATA, "bMotionPath", 1, mpath);
|
|
|
|
|
|
|
|
/* now write the array of data */
|
|
|
|
writestruct(wd, DATA, "bMotionPathVert", mpath->length, mpath->points);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
for (con=conlist->first; con; con=con->next) {
|
== 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
|
|
|
bConstraintTypeInfo *cti= constraint_get_typeinfo(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 */
|
|
|
|
writestruct(wd, DATA, cti->structName, 1, con->data);
|
|
|
|
|
|
|
|
/* do any constraint specific stuff */
|
|
|
|
switch (con->type) {
|
|
|
|
case CONSTRAINT_TYPE_PYTHON:
|
|
|
|
{
|
2007-10-24 10:03:19 +00:00
|
|
|
bPythonConstraint *data = (bPythonConstraint *)con->data;
|
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
/* write targets */
|
|
|
|
for (ct= data->targets.first; ct; ct= ct->next)
|
|
|
|
writestruct(wd, DATA, "bConstraintTarget", 1, ct);
|
== 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
|
|
|
|
of library blocks that implement this.*/
|
|
|
|
IDP_WriteProperty(data->prop, wd);
|
|
|
|
}
|
2011-05-11 09:31:00 +00:00
|
|
|
break;
|
2009-11-01 11:29:40 +00:00
|
|
|
case CONSTRAINT_TYPE_SPLINEIK:
|
|
|
|
{
|
|
|
|
bSplineIKConstraint *data= (bSplineIKConstraint*)con->data;
|
|
|
|
|
|
|
|
/* write points array */
|
|
|
|
writedata(wd, DATA, sizeof(float)*(data->numpoints), data->points);
|
2011-05-11 09:31:00 +00:00
|
|
|
}
|
2009-11-07 23:10:18 +00:00
|
|
|
break;
|
2011-05-11 09:31:00 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00: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
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* Write the constraint */
|
|
|
|
writestruct(wd, DATA, "bConstraint", 1, con);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 */
|
|
|
|
if (!pose)
|
|
|
|
return;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2007-07-04 07:07:12 +00:00
|
|
|
/* Write channels */
|
2002-10-12 11:37:38 +00:00
|
|
|
for (chan=pose->chanbase.first; chan; chan=chan->next) {
|
2009-05-23 03:24:15 +00:00
|
|
|
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
|
|
|
|
of library blocks that implement this.*/
|
|
|
|
if (chan->prop)
|
|
|
|
IDP_WriteProperty(chan->prop, wd);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
write_constraints(wd, &chan->constraints);
|
2007-07-04 07:07:12 +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
|
|
|
write_motionpath(wd, chan->mpath);
|
|
|
|
|
2007-07-04 07:07:12 +00:00
|
|
|
/* prevent crashes with autosave, when a bone duplicated in editmode has not yet been assigned to its posechannel */
|
|
|
|
if (chan->bone)
|
2009-11-09 21:03:54 +00:00
|
|
|
chan->selectflag= chan->bone->flag & BONE_SELECTED; /* gets restored on read, for library armatures */
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, DATA, "bPoseChannel", 1, 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
|
|
|
|
|
|
|
/* Write groups */
|
|
|
|
for (grp=pose->agroups.first; grp; grp=grp->next)
|
|
|
|
writestruct(wd, DATA, "bActionGroup", 1, grp);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
/* write IK param */
|
|
|
|
if (pose->ikparam) {
|
|
|
|
char *structname = (char *)get_ikparam_name(pose);
|
|
|
|
if (structname)
|
|
|
|
writestruct(wd, DATA, structname, 1, pose->ikparam);
|
|
|
|
}
|
|
|
|
|
2007-07-04 07:07:12 +00:00
|
|
|
/* Write this pose */
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, DATA, "bPose", 1, pose);
|
2009-10-22 23:22:05 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void write_defgroups(WriteData *wd, ListBase *defbase)
|
|
|
|
{
|
|
|
|
bDeformGroup *defgroup;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
for (defgroup=defbase->first; defgroup; defgroup=defgroup->next)
|
|
|
|
writestruct(wd, DATA, "bDeformGroup", 1, defgroup);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2006-10-27 18:24:10 +00:00
|
|
|
if (modbase == NULL) return;
|
2005-07-19 20:14:17 +00:00
|
|
|
for (md=modbase->first; md; md= md->next) {
|
2005-08-03 04:04:05 +00:00
|
|
|
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
2006-10-27 18:24:10 +00:00
|
|
|
if (mti == NULL) return;
|
== 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
|
|
|
|
2005-07-19 20:14:17 +00:00
|
|
|
writestruct(wd, DATA, mti->structName, 1, md);
|
== 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
|
|
|
|
- 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
|
|
|
if (md->type==eModifierType_Hook) {
|
|
|
|
HookModifierData *hmd = (HookModifierData*) md;
|
== 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
|
|
|
|
- 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
|
|
|
writedata(wd, DATA, sizeof(int)*hmd->totindex, hmd->indexar);
|
|
|
|
}
|
2008-01-29 21:01:12 +00:00
|
|
|
else if(md->type==eModifierType_Cloth) {
|
|
|
|
ClothModifierData *clmd = (ClothModifierData*) md;
|
|
|
|
|
2008-03-20 18:28:40 +00:00
|
|
|
writestruct(wd, DATA, "ClothSimSettings", 1, clmd->sim_parms);
|
|
|
|
writestruct(wd, DATA, "ClothCollSettings", 1, clmd->coll_parms);
|
2009-10-22 23:22:05 +00:00
|
|
|
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);
|
2008-01-29 21:01:12 +00:00
|
|
|
}
|
2009-07-30 15:00:26 +00:00
|
|
|
else if(md->type==eModifierType_Smoke) {
|
|
|
|
SmokeModifierData *smd = (SmokeModifierData*) md;
|
|
|
|
|
2009-08-20 00:33:59 +00:00
|
|
|
if(smd->type & MOD_SMOKE_TYPE_DOMAIN)
|
2009-10-22 23:22:05 +00:00
|
|
|
{
|
2010-12-16 16:09:23 +00:00
|
|
|
if(smd->domain)
|
|
|
|
{
|
|
|
|
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]);
|
2011-02-24 13:37:53 +00: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]));
|
|
|
|
}
|
|
|
|
|
2009-07-30 15:00:26 +00:00
|
|
|
writestruct(wd, DATA, "SmokeDomainSettings", 1, smd->domain);
|
2010-12-16 16:09:23 +00:00
|
|
|
|
|
|
|
if(smd->domain) {
|
|
|
|
/* cleanup the fake pointcache */
|
|
|
|
BKE_ptcache_free_list(&smd->domain->ptcaches[1]);
|
|
|
|
smd->domain->point_cache[1] = NULL;
|
|
|
|
|
|
|
|
writestruct(wd, DATA, "EffectorWeights", 1, smd->domain->effector_weights);
|
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
2009-08-20 00:33:59 +00:00
|
|
|
else if(smd->type & MOD_SMOKE_TYPE_FLOW)
|
2009-07-30 15:00:26 +00:00
|
|
|
writestruct(wd, DATA, "SmokeFlowSettings", 1, smd->flow);
|
2009-08-20 00:33:59 +00:00
|
|
|
else if(smd->type & MOD_SMOKE_TYPE_COLL)
|
2009-07-30 15:00:26 +00:00
|
|
|
writestruct(wd, DATA, "SmokeCollSettings", 1, smd->coll);
|
|
|
|
}
|
2008-07-25 18:57:16 +00:00
|
|
|
else if(md->type==eModifierType_Fluidsim) {
|
|
|
|
FluidsimModifierData *fluidmd = (FluidsimModifierData*) md;
|
|
|
|
|
|
|
|
writestruct(wd, DATA, "FluidsimSettings", 1, fluidmd->fss);
|
2011-05-24 07:08:58 +00:00
|
|
|
}
|
|
|
|
else if(md->type==eModifierType_DynamicPaint) {
|
|
|
|
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
|
|
|
|
|
2011-07-08 11:03:37 +00:00
|
|
|
if(pmd->canvas)
|
2011-05-24 07:08:58 +00:00
|
|
|
{
|
2011-06-16 10:41:00 +00:00
|
|
|
DynamicPaintSurface *surface;
|
2011-05-24 07:08:58 +00:00
|
|
|
writestruct(wd, DATA, "DynamicPaintCanvasSettings", 1, pmd->canvas);
|
2011-06-16 10:41:00 +00:00
|
|
|
|
|
|
|
/* write surfaces */
|
|
|
|
for (surface=pmd->canvas->surfaces.first; surface; surface=surface->next)
|
|
|
|
writestruct(wd, DATA, "DynamicPaintSurface", 1, surface);
|
2011-06-27 07:30:58 +00:00
|
|
|
/* write caches and effector weights */
|
|
|
|
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
|
|
|
|
|
|
|
writestruct(wd, DATA, "EffectorWeights", 1, surface->effector_weights);
|
|
|
|
}
|
2011-05-24 07:08:58 +00:00
|
|
|
}
|
2011-07-08 11:03:37 +00:00
|
|
|
if(pmd->brush)
|
2011-05-24 07:08:58 +00:00
|
|
|
{
|
2011-06-16 10:41:00 +00:00
|
|
|
writestruct(wd, DATA, "DynamicPaintBrushSettings", 1, pmd->brush);
|
|
|
|
writestruct(wd, DATA, "ColorBand", 1, pmd->brush->paint_ramp);
|
2011-08-03 18:31:48 +00:00
|
|
|
writestruct(wd, DATA, "ColorBand", 1, pmd->brush->vel_ramp);
|
2011-05-24 07:08:58 +00:00
|
|
|
}
|
2008-07-25 18:57:16 +00:00
|
|
|
}
|
2008-01-29 21:01:12 +00:00
|
|
|
else if (md->type==eModifierType_Collision) {
|
|
|
|
|
|
|
|
/*
|
2008-02-03 01:33:35 +00:00
|
|
|
CollisionModifierData *collmd = (CollisionModifierData*) md;
|
2008-01-29 21:01:12 +00:00
|
|
|
// TODO: CollisionModifier should use pointcache
|
|
|
|
// + have proper reset events before enabling this
|
|
|
|
writestruct(wd, DATA, "MVert", collmd->numverts, collmd->x);
|
|
|
|
writestruct(wd, DATA, "MVert", collmd->numverts, collmd->xnew);
|
|
|
|
writestruct(wd, DATA, "MFace", collmd->numfaces, collmd->mfaces);
|
|
|
|
*/
|
|
|
|
}
|
2007-11-04 22:00:24 +00: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
|
|
|
|
2010-04-25 10:27:45 +00:00
|
|
|
writestruct(wd, DATA, "MDefInfluence", mmd->totinfluence, mmd->bindinfluences);
|
|
|
|
writedata(wd, DATA, sizeof(int)*(mmd->totvert+1), mmd->bindoffsets);
|
2007-11-04 22:00:24 +00:00
|
|
|
writedata(wd, DATA, sizeof(float)*3*mmd->totcagevert,
|
2010-04-23 18:02:50 +00:00
|
|
|
mmd->bindcagecos);
|
2007-11-13 18:50:57 +00:00
|
|
|
writestruct(wd, DATA, "MDefCell", size*size*size, mmd->dyngrid);
|
|
|
|
writestruct(wd, DATA, "MDefInfluence", mmd->totinfluence, mmd->dyninfluences);
|
2007-11-11 22:54:14 +00:00
|
|
|
writedata(wd, DATA, sizeof(int)*mmd->totvert, mmd->dynverts);
|
2007-11-04 22:00:24 +00:00
|
|
|
}
|
2011-05-01 15:16:59 +00:00
|
|
|
else if (md->type==eModifierType_Warp) {
|
|
|
|
WarpModifierData *tmd = (WarpModifierData*) md;
|
|
|
|
if(tmd->curfalloff) {
|
|
|
|
write_curvemapping(wd, tmd->curfalloff);
|
|
|
|
}
|
|
|
|
}
|
2011-07-25 15:27:01 +00:00
|
|
|
else if (md->type==eModifierType_WeightVGEdit) {
|
|
|
|
WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md;
|
|
|
|
|
|
|
|
if (wmd->cmap_curve)
|
|
|
|
write_curvemapping(wd, wmd->cmap_curve);
|
|
|
|
}
|
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;
|
2004-09-14 19:03:11 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
ob= idbase->first;
|
|
|
|
while(ob) {
|
2004-11-07 10:15:06 +00:00
|
|
|
if(ob->id.us>0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, ID_OB, "Object", 1, ob);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2006-11-17 04:46:48 +00:00
|
|
|
/*Write ID Properties -- and copy this comment EXACTLY for easy finding
|
|
|
|
of library blocks that implement this.*/
|
|
|
|
if (ob->id.properties) IDP_WriteProperty(ob->id.properties, wd);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
|
|
|
if (ob->adt) write_animdata(wd, ob->adt);
|
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2002-10-12 11:37:38 +00:00
|
|
|
writedata(wd, DATA, sizeof(void *)*ob->totcol, ob->mat);
|
2009-07-13 00:40:20 +00:00
|
|
|
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);
|
2004-06-26 18:18:11 +00:00
|
|
|
|
|
|
|
writestruct(wd, DATA, "PartDeflect", 1, ob->pd);
|
2005-04-02 13:57:23 +00:00
|
|
|
writestruct(wd, DATA, "SoftBody", 1, ob->soft);
|
2009-10-22 23:22:05 +00:00
|
|
|
if(ob->soft) {
|
|
|
|
write_pointcaches(wd, &ob->soft->ptcaches);
|
|
|
|
writestruct(wd, DATA, "EffectorWeights", 1, ob->soft->effector_weights);
|
|
|
|
}
|
2008-09-27 21:52:20 +00:00
|
|
|
writestruct(wd, DATA, "BulletSoftBody", 1, ob->bsoft);
|
2004-09-14 19:03:11 +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
|
|
|
write_particlesystems(wd, &ob->particlesystem);
|
2009-08-19 16:49:21 +00:00
|
|
|
write_modifiers(wd, &ob->modifiers);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
ob= ob->id.next;
|
|
|
|
}
|
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;
|
|
|
|
PackedFile * pf;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
vf= idbase->first;
|
|
|
|
while(vf) {
|
2004-11-07 10:15:06 +00:00
|
|
|
if(vf->id.us>0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, ID_VF, "VFont", 1, vf);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (vf->id.properties) IDP_WriteProperty(vf->id.properties, wd);
|
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
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if (vf->packedfile) {
|
|
|
|
pf = vf->packedfile;
|
|
|
|
writestruct(wd, DATA, "PackedFile", 1, pf);
|
|
|
|
writedata(wd, DATA, pf->size, pf->data);
|
|
|
|
}
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
vf= vf->id.next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void write_keys(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Key *key;
|
|
|
|
KeyBlock *kb;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
key= idbase->first;
|
|
|
|
while(key) {
|
2004-11-07 10:15:06 +00:00
|
|
|
if(key->id.us>0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, ID_KE, "Key", 1, key);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (key->id.properties) IDP_WriteProperty(key->id.properties, wd);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
|
|
|
if (key->adt) write_animdata(wd, key->adt);
|
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2002-10-12 11:37:38 +00:00
|
|
|
kb= key->block.first;
|
|
|
|
while(kb) {
|
|
|
|
writestruct(wd, DATA, "KeyBlock", 1, kb);
|
|
|
|
if(kb->data) writedata(wd, DATA, kb->totelem*key->elemsize, kb->data);
|
|
|
|
kb= kb->next;
|
|
|
|
}
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
key= key->id.next;
|
|
|
|
}
|
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
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
cam= idbase->first;
|
|
|
|
while(cam) {
|
2004-11-07 10:15:06 +00:00
|
|
|
if(cam->id.us>0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, ID_CA, "Camera", 1, cam);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (cam->id.properties) IDP_WriteProperty(cam->id.properties, wd);
|
2009-01-19 02:26:46 +00: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
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
cam= cam->id.next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_mballs(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
MetaBall *mb;
|
|
|
|
MetaElem *ml;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
mb= idbase->first;
|
|
|
|
while(mb) {
|
2004-11-07 10:15:06 +00:00
|
|
|
if(mb->id.us>0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, ID_MB, "MetaBall", 1, mb);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (mb->id.properties) IDP_WriteProperty(mb->id.properties, wd);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2002-10-12 11:37:38 +00:00
|
|
|
writedata(wd, DATA, sizeof(void *)*mb->totcol, mb->mat);
|
2009-08-03 13:09:23 +00:00
|
|
|
if (mb->adt) write_animdata(wd, mb->adt);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
ml= mb->elems.first;
|
|
|
|
while(ml) {
|
|
|
|
writestruct(wd, DATA, "MetaElem", 1, ml);
|
|
|
|
ml= ml->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mb= mb->id.next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-29 17:08:11 +00:00
|
|
|
static int amount_of_chars(char *str)
|
2005-09-14 14:02:21 +00:00
|
|
|
{
|
|
|
|
// Since the data is saved as UTF-8 to the cu->str
|
|
|
|
// The cu->len is not same as the strlen(cu->str)
|
|
|
|
return strlen(str);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
cu= idbase->first;
|
|
|
|
while(cu) {
|
2004-11-07 10:15:06 +00:00
|
|
|
if(cu->id.us>0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, ID_CU, "Curve", 1, cu);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2002-10-12 11:37:38 +00:00
|
|
|
writedata(wd, DATA, sizeof(void *)*cu->totcol, cu->mat);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (cu->id.properties) IDP_WriteProperty(cu->id.properties, wd);
|
2009-01-18 10:41:45 +00:00
|
|
|
if (cu->adt) write_animdata(wd, cu->adt);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if(cu->vfont) {
|
2005-09-14 14:02:21 +00:00
|
|
|
writedata(wd, DATA, amount_of_chars(cu->str)+1, cu->str);
|
2010-07-23 05:31:11 +00:00
|
|
|
writestruct(wd, DATA, "CharInfo", cu->len+1, cu->strinfo);
|
2005-06-17 21:04:27 +00:00
|
|
|
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 */
|
2002-10-12 11:37:38 +00:00
|
|
|
nu= cu->nurb.first;
|
|
|
|
while(nu) {
|
|
|
|
writestruct(wd, DATA, "Nurb", 1, nu);
|
|
|
|
nu= nu->next;
|
|
|
|
}
|
|
|
|
nu= cu->nurb.first;
|
|
|
|
while(nu) {
|
2009-09-16 17:43:09 +00:00
|
|
|
if(nu->type == CU_BEZIER)
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, DATA, "BezTriple", nu->pntsu, nu->bezt);
|
|
|
|
else {
|
|
|
|
writestruct(wd, DATA, "BPoint", nu->pntsu*nu->pntsv, nu->bp);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cu= cu->id.next;
|
|
|
|
}
|
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) {
|
2009-01-06 18:59:03 +00:00
|
|
|
int i;
|
2006-09-03 12:16:14 +00:00
|
|
|
|
|
|
|
/* Write the dvert list */
|
|
|
|
writestruct(wd, DATA, "MDeformVert", count, dvlist);
|
|
|
|
|
|
|
|
/* Write deformation data for each dvert */
|
2002-10-12 11:37:38 +00:00
|
|
|
for (i=0; i<count; i++) {
|
|
|
|
if (dvlist[i].dw)
|
2004-06-23 18:22:51 +00:00
|
|
|
writestruct(wd, DATA, "MDeformWeight", dvlist[i].totweight, dvlist[i].dw);
|
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
|
|
|
{
|
|
|
|
if(mdlist) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
writestruct(wd, DATA, "MDisps", count, mdlist);
|
2009-11-25 14:27:50 +00:00
|
|
|
if(!external) {
|
|
|
|
for(i = 0; i < count; ++i) {
|
|
|
|
if(mdlist[i].disps)
|
|
|
|
writedata(wd, DATA, sizeof(float)*3*mdlist[i].totdisp, mdlist[i].disps);
|
|
|
|
}
|
2009-01-06 18:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-10 14:26:06 +00:00
|
|
|
static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data, 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) */
|
2009-11-25 14:27:50 +00:00
|
|
|
if(data->external && !wd->current)
|
2009-12-10 14:26:06 +00:00
|
|
|
CustomData_external_write(data, id, CD_MASK_MESH, count, 0);
|
2009-11-25 14:27:50 +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
|
|
|
writestruct(wd, DATA, "CustomDataLayer", data->maxlayer, data->layers);
|
|
|
|
|
|
|
|
for (i=0; i<data->totlayer; i++) {
|
|
|
|
CustomDataLayer *layer= &data->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
|
|
|
}
|
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
|
|
|
|
are smaller than the original, so their type and count is
|
|
|
|
passed to make this work */
|
|
|
|
if (layer->type != partial_type) datasize= structnum*count;
|
|
|
|
else datasize= structnum*partial_count;
|
|
|
|
|
|
|
|
writestruct(wd, DATA, structname, datasize, 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
|
2011-11-24 19:36:12 +00:00
|
|
|
printf("%s error: layer '%s':%d - can't be written to file\n",
|
|
|
|
__func__, structname, layer->type);
|
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
|
|
|
|
|
|
|
if(data->external)
|
|
|
|
writestruct(wd, DATA, "CustomDataExternal", 1, data->external);
|
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
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
static void write_meshs(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Mesh *mesh;
|
2011-12-27 08:39:55 +00:00
|
|
|
int save_for_old_blender= 0;
|
|
|
|
|
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
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
mesh= idbase->first;
|
|
|
|
while(mesh) {
|
2004-11-07 10:15:06 +00: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) {
|
2012-01-02 12:37:58 +00:00
|
|
|
|
|
|
|
#ifdef USE_BMESH_SAVE_WITHOUT_MFACE
|
|
|
|
Mesh backup_mesh = {{0}};
|
|
|
|
/* cache only - dont write */
|
|
|
|
backup_mesh.mface = mesh->mface;
|
|
|
|
mesh->mface = NULL;
|
|
|
|
/* -- */
|
|
|
|
backup_mesh.totface = mesh->totface;
|
|
|
|
mesh->totface = 0;
|
|
|
|
/* -- */
|
|
|
|
#endif /* USE_BMESH_SAVE_WITHOUT_MFACE */
|
|
|
|
|
2011-12-27 08:39:55 +00:00
|
|
|
writestruct(wd, ID_ME, "Mesh", 1, mesh);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2011-12-27 08:39:55 +00:00
|
|
|
/* direct data */
|
|
|
|
if (mesh->id.properties) IDP_WriteProperty(mesh->id.properties, wd);
|
|
|
|
if (mesh->adt) write_animdata(wd, mesh->adt);
|
2006-11-17 06:14:15 +00:00
|
|
|
|
2011-12-27 08:39:55 +00:00
|
|
|
writedata(wd, DATA, sizeof(void *)*mesh->totcol, mesh->mat);
|
2004-07-08 20:38:27 +00:00
|
|
|
|
2011-12-27 08:39:55 +00:00
|
|
|
write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, -1, 0);
|
|
|
|
write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, -1, 0);
|
2012-01-02 12:37:58 +00:00
|
|
|
/* fdata is really a dummy - written so slots align */
|
2011-12-27 08:39:55 +00:00
|
|
|
write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, -1, 0);
|
|
|
|
write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, -1, 0);
|
|
|
|
write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, -1, 0);
|
2012-01-02 12:37:58 +00:00
|
|
|
|
|
|
|
#ifdef USE_BMESH_SAVE_WITHOUT_MFACE
|
|
|
|
/* cache only - dont write */
|
|
|
|
mesh->mface = backup_mesh.mface;
|
|
|
|
/* -- */
|
|
|
|
mesh->totface = backup_mesh.totface;
|
|
|
|
#endif /* USE_BMESH_SAVE_WITHOUT_MFACE */
|
|
|
|
|
2011-12-27 08:39:55 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
2011-12-28 15:07:00 +00:00
|
|
|
#ifdef USE_BMESH_SAVE_AS_COMPAT
|
2011-12-27 08:39:55 +00:00
|
|
|
|
|
|
|
Mesh backup_mesh = {{0}};
|
|
|
|
|
|
|
|
/* backup */
|
|
|
|
backup_mesh.mpoly = mesh->mpoly;
|
|
|
|
mesh->mpoly = NULL;
|
|
|
|
/* -- */
|
|
|
|
backup_mesh.mface = mesh->mface;
|
|
|
|
mesh->mface = NULL;
|
|
|
|
/* -- */
|
|
|
|
backup_mesh.totface = mesh->totface;
|
|
|
|
mesh->totface = 0;
|
|
|
|
/* -- */
|
|
|
|
backup_mesh.totpoly = mesh->totpoly;
|
|
|
|
mesh->totpoly = 0;
|
|
|
|
/* -- */
|
|
|
|
backup_mesh.totloop = mesh->totloop;
|
|
|
|
mesh->totloop = 0;
|
|
|
|
/* -- */
|
|
|
|
backup_mesh.fdata = mesh->fdata;
|
|
|
|
memset(&mesh->fdata, 0, sizeof(CustomData));
|
|
|
|
/* -- */
|
|
|
|
backup_mesh.pdata = mesh->pdata;
|
|
|
|
memset(&mesh->pdata, 0, sizeof(CustomData));
|
|
|
|
/* -- */
|
|
|
|
backup_mesh.ldata = mesh->ldata;
|
|
|
|
memset(&mesh->ldata, 0, sizeof(CustomData));
|
|
|
|
/* -- */
|
|
|
|
backup_mesh.edit_btmesh = mesh->edit_btmesh;
|
|
|
|
mesh->edit_btmesh = NULL;
|
|
|
|
/* backup */
|
|
|
|
|
|
|
|
|
|
|
|
/* now fill in polys to mfaces*/
|
|
|
|
mesh->totface= mesh_mpoly_to_mface(&mesh->fdata, &backup_mesh.ldata, &backup_mesh.pdata,
|
|
|
|
mesh->totface, backup_mesh.totloop, backup_mesh.totpoly);
|
|
|
|
|
|
|
|
mesh_update_customdata_pointers(mesh, FALSE);
|
|
|
|
|
|
|
|
writestruct(wd, ID_ME, "Mesh", 1, mesh);
|
|
|
|
|
|
|
|
/* direct data */
|
|
|
|
if (mesh->id.properties) IDP_WriteProperty(mesh->id.properties, wd);
|
|
|
|
if (mesh->adt) write_animdata(wd, mesh->adt);
|
|
|
|
|
|
|
|
writedata(wd, DATA, sizeof(void *)*mesh->totcol, mesh->mat);
|
|
|
|
|
|
|
|
write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, -1, 0);
|
|
|
|
write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, -1, 0);
|
|
|
|
write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, -1, 0);
|
|
|
|
/* harmless for older blender versioins but _not_ writing these keeps file size down */
|
|
|
|
/*
|
|
|
|
write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, -1, 0);
|
|
|
|
write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, -1, 0);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* restore */
|
|
|
|
mesh->mpoly = backup_mesh.mpoly;
|
|
|
|
/* -- */
|
|
|
|
mesh->mface = backup_mesh.mface;
|
|
|
|
/* -- */
|
|
|
|
CustomData_free(&mesh->fdata, mesh->totface);
|
|
|
|
/* -- */
|
|
|
|
mesh->fdata= backup_mesh.fdata;
|
|
|
|
/* -- */
|
|
|
|
mesh->pdata= backup_mesh.pdata;
|
|
|
|
/* -- */
|
|
|
|
mesh->ldata= backup_mesh.ldata;
|
|
|
|
/* -- */
|
2012-01-17 04:57:51 +00:00
|
|
|
mesh->totface = backup_mesh.totface;
|
|
|
|
mesh->totpoly = backup_mesh.totpoly;
|
|
|
|
mesh->totloop = backup_mesh.totloop;
|
|
|
|
/* -- */
|
2011-12-27 08:39:55 +00:00
|
|
|
mesh_update_customdata_pointers(mesh, FALSE);
|
|
|
|
/* --*/
|
|
|
|
mesh->edit_btmesh = backup_mesh.edit_btmesh; /* keep this after updating custom pointers */
|
|
|
|
/* restore */
|
|
|
|
|
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
|
|
|
}
|
|
|
|
mesh= mesh->id.next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-03 12:16:14 +00:00
|
|
|
static void write_lattices(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Lattice *lt;
|
|
|
|
|
|
|
|
lt= idbase->first;
|
|
|
|
while(lt) {
|
|
|
|
if(lt->id.us>0 || wd->current) {
|
|
|
|
/* write LibData */
|
|
|
|
writestruct(wd, ID_LT, "Lattice", 1, lt);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (lt->id.properties) IDP_WriteProperty(lt->id.properties, wd);
|
2010-12-13 06:31:49 +00:00
|
|
|
|
|
|
|
/* write animdata */
|
|
|
|
if (lt->adt) write_animdata(wd, lt->adt);
|
|
|
|
|
2006-09-03 12:16:14 +00:00
|
|
|
/* direct data */
|
|
|
|
writestruct(wd, DATA, "BPoint", lt->pntsu*lt->pntsv*lt->pntsw, lt->def);
|
|
|
|
|
|
|
|
write_dverts(wd, lt->pntsu*lt->pntsv*lt->pntsw, lt->dvert);
|
|
|
|
|
|
|
|
}
|
|
|
|
lt= lt->id.next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
static void write_previews(WriteData *wd, PreviewImage *prv)
|
|
|
|
{
|
|
|
|
if (prv) {
|
|
|
|
short w = prv->w[1];
|
|
|
|
short h = prv->h[1];
|
|
|
|
unsigned int *rect = prv->rect[1];
|
|
|
|
/* don't write out large previews if not requested */
|
|
|
|
if (!(U.flag & USER_SAVE_PREVIEWS) ) {
|
|
|
|
prv->w[1] = 0;
|
|
|
|
prv->h[1] = 0;
|
|
|
|
prv->rect[1] = NULL;
|
|
|
|
}
|
|
|
|
writestruct(wd, DATA, "PreviewImage", 1, prv);
|
|
|
|
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]);
|
|
|
|
|
|
|
|
/* restore preview, we still want to keep it in memory even if not saved to file */
|
|
|
|
if (!(U.flag & USER_SAVE_PREVIEWS) ) {
|
|
|
|
prv->w[1] = w;
|
|
|
|
prv->h[1] = h;
|
|
|
|
prv->rect[1] = rect;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
static void write_images(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Image *ima;
|
|
|
|
PackedFile * pf;
|
2007-08-19 11:15:33 +00:00
|
|
|
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
ima= idbase->first;
|
|
|
|
while(ima) {
|
2004-11-07 10:15:06 +00:00
|
|
|
if(ima->id.us>0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, ID_IM, "Image", 1, ima);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (ima->id.properties) IDP_WriteProperty(ima->id.properties, wd);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if (ima->packedfile) {
|
|
|
|
pf = ima->packedfile;
|
|
|
|
writestruct(wd, DATA, "PackedFile", 1, pf);
|
|
|
|
writedata(wd, DATA, pf->size, pf->data);
|
|
|
|
}
|
2006-06-05 11:07:15 +00:00
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
write_previews(wd, ima->preview);
|
2009-07-10 16:55:49 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
ima= ima->id.next;
|
|
|
|
}
|
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
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
tex= idbase->first;
|
|
|
|
while(tex) {
|
2004-11-07 10:15:06 +00:00
|
|
|
if(tex->id.us>0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, ID_TE, "Tex", 1, tex);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (tex->id.properties) IDP_WriteProperty(tex->id.properties, wd);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2009-02-20 16:39:39 +00:00
|
|
|
if (tex->adt) write_animdata(wd, tex->adt);
|
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2009-05-23 03:24:15 +00:00
|
|
|
if(tex->type == TEX_PLUGIN && tex->plugin) writestruct(wd, DATA, "PluginTex", 1, tex->plugin);
|
2002-10-12 11:37:38 +00:00
|
|
|
if(tex->coba) writestruct(wd, DATA, "ColorBand", 1, tex->coba);
|
2009-05-23 03:24:15 +00:00
|
|
|
if(tex->type == TEX_ENVMAP && tex->env) writestruct(wd, DATA, "EnvMap", 1, tex->env);
|
2009-08-13 05:21:25 +00:00
|
|
|
if(tex->type == TEX_POINTDENSITY && tex->pd) {
|
2008-11-09 01:16:12 +00:00
|
|
|
writestruct(wd, DATA, "PointDensity", 1, tex->pd);
|
|
|
|
if(tex->pd->coba) writestruct(wd, DATA, "ColorBand", 1, tex->pd->coba);
|
2011-05-01 03:57:53 +00:00
|
|
|
if(tex->pd->falloff_curve) write_curvemapping(wd, tex->pd->falloff_curve);
|
2008-11-09 01:16:12 +00:00
|
|
|
}
|
2011-09-22 17:52:27 +00:00
|
|
|
if(tex->type == TEX_VOXELDATA) writestruct(wd, DATA, "VoxelData", 1, tex->vd);
|
2011-11-13 12:17:27 +00:00
|
|
|
if(tex->type == TEX_OCEAN && tex->ot) writestruct(wd, DATA, "OceanTex", 1, tex->ot);
|
2007-09-02 17:25:03 +00:00
|
|
|
|
2008-11-12 22:03:11 +00:00
|
|
|
/* nodetree is integral part of texture, no libdata */
|
|
|
|
if(tex->nodetree) {
|
|
|
|
writestruct(wd, DATA, "bNodeTree", 1, tex->nodetree);
|
|
|
|
write_nodetree(wd, tex->nodetree);
|
|
|
|
}
|
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
write_previews(wd, tex->preview);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
tex= tex->id.next;
|
|
|
|
}
|
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
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
ma= idbase->first;
|
|
|
|
while(ma) {
|
2004-11-07 10:15:06 +00:00
|
|
|
if(ma->id.us>0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, ID_MA, "Material", 1, ma);
|
2006-11-17 04:46:48 +00:00
|
|
|
|
|
|
|
/*Write ID Properties -- and copy this comment EXACTLY for easy finding
|
|
|
|
of library blocks that implement this.*/
|
|
|
|
/*manually set head group property to IDP_GROUP, just in case it hadn't been
|
|
|
|
set yet :) */
|
|
|
|
if (ma->id.properties) IDP_WriteProperty(ma->id.properties, wd);
|
2009-02-20 16:39:39 +00:00
|
|
|
|
|
|
|
if (ma->adt) write_animdata(wd, ma->adt);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2004-12-04 21:49:02 +00:00
|
|
|
for(a=0; a<MAX_MTEX; a++) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(ma->mtex[a]) writestruct(wd, DATA, "MTex", 1, ma->mtex[a]);
|
|
|
|
}
|
2004-06-30 18:54:09 +00:00
|
|
|
|
|
|
|
if(ma->ramp_col) writestruct(wd, DATA, "ColorBand", 1, ma->ramp_col);
|
|
|
|
if(ma->ramp_spec) writestruct(wd, DATA, "ColorBand", 1, ma->ramp_spec);
|
|
|
|
|
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 */
|
|
|
|
if(ma->nodetree) {
|
|
|
|
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
|
|
|
|
|
|
|
write_previews(wd, ma->preview);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
ma= ma->id.next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_worlds(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
World *wrld;
|
|
|
|
int a;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
wrld= idbase->first;
|
|
|
|
while(wrld) {
|
2004-11-07 10:15:06 +00:00
|
|
|
if(wrld->id.us>0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, ID_WO, "World", 1, wrld);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (wrld->id.properties) IDP_WriteProperty(wrld->id.properties, wd);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
|
|
|
if (wrld->adt) write_animdata(wd, wrld->adt);
|
|
|
|
|
2004-12-04 21:49:02 +00:00
|
|
|
for(a=0; a<MAX_MTEX; a++) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(wrld->mtex[a]) writestruct(wd, DATA, "MTex", 1, wrld->mtex[a]);
|
|
|
|
}
|
2011-11-02 18:55:32 +00:00
|
|
|
|
|
|
|
/* nodetree is integral part of lamps, no libdata */
|
|
|
|
if(wrld->nodetree) {
|
|
|
|
writestruct(wd, DATA, "bNodeTree", 1, wrld->nodetree);
|
|
|
|
write_nodetree(wd, wrld->nodetree);
|
|
|
|
}
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
write_previews(wd, wrld->preview);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
wrld= wrld->id.next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_lamps(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Lamp *la;
|
|
|
|
int a;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
la= idbase->first;
|
|
|
|
while(la) {
|
2004-11-07 10:15:06 +00:00
|
|
|
if(la->id.us>0 || wd->current) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, ID_LA, "Lamp", 1, la);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (la->id.properties) IDP_WriteProperty(la->id.properties, wd);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
|
|
|
if (la->adt) write_animdata(wd, la->adt);
|
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2004-12-04 21:49:02 +00:00
|
|
|
for(a=0; a<MAX_MTEX; a++) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(la->mtex[a]) writestruct(wd, DATA, "MTex", 1, la->mtex[a]);
|
|
|
|
}
|
2009-01-19 02:26:46 +00:00
|
|
|
|
* Extra lamp falloff options, including custom curve!
This adds some new lamp attenuation options to the Lamp panel, replacing the old 'Quad' button. Yes, the panel layout is still nasty here, but I've ignored it for now to address properly in the panels cleanup work.
* Constant
http://mke3.net/blender/devel/rendering/falloff-constant.jpg
Lamp doesn't decay with distance
* Inverse Linear
http://mke3.net/blender/devel/rendering/falloff-invlinear.jpg
Default, and same as in older Blender without 'Quad' on. Decays linearly, with 'Dist' value as the lamp's half-energy-distance
* Inverse Square
http://mke3.net/blender/devel/rendering/falloff-invsquare.jpg
A sharper, more realistic decay, good for most electric lights (i.e. not sunlight). This is similar to the old Quad option with slight changes.
* Lin/Quad weighted
Exactly the same as in older Blenders with the old 'Quad' button enabled. When this setting is chosen, two sliders are shown, 'Linear' and 'Quad' (previously Quad1 and Quad2), which controls the 'linearness' or 'quadraticness' of the falloff curve. Lamps in old files with the 'Quad' button on will be initialised to this setting.
But much better for precise control over the lamp falloff now is:
* Custom Curve
This shows an extra 'Falloff Curve' panel, where you can use the standard Blender curve UI control to precisely control how the light falls off. The Y axis is intensity, and the X axis is distance, stretched over the length of the 'Dist' value.
Some example curves and renders:
http://mke3.net/blender/devel/rendering/falloff-curve1-curve.png
http://mke3.net/blender/devel/rendering/falloff-curve1.jpg
http://mke3.net/blender/devel/rendering/falloff-curve2-curve.png
http://mke3.net/blender/devel/rendering/falloff-curve2.jpg
http://mke3.net/blender/devel/rendering/falloff-curve3-curve.png
http://mke3.net/blender/devel/rendering/falloff-curve3.jpg (whee)
2007-09-16 13:50:34 +00:00
|
|
|
if(la->curfalloff)
|
|
|
|
write_curvemapping(wd, la->curfalloff);
|
|
|
|
|
2011-11-02 18:55:32 +00:00
|
|
|
/* nodetree is integral part of lamps, no libdata */
|
|
|
|
if(la->nodetree) {
|
|
|
|
writestruct(wd, DATA, "bNodeTree", 1, la->nodetree);
|
|
|
|
write_nodetree(wd, la->nodetree);
|
|
|
|
}
|
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
write_previews(wd, la->preview);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
la= la->id.next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
2009-08-17 00:39:00 +00:00
|
|
|
ToolSettings *tos;
|
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
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
sce= scebase->first;
|
|
|
|
while(sce) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write LibData */
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, ID_SCE, "Scene", 1, sce);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (sce->id.properties) IDP_WriteProperty(sce->id.properties, wd);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
|
|
|
if (sce->adt) write_animdata(wd, sce->adt);
|
2009-02-11 12:19:42 +00:00
|
|
|
write_keyingsets(wd, &sce->keyingsets);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2002-10-12 11:37:38 +00:00
|
|
|
base= sce->base.first;
|
|
|
|
while(base) {
|
|
|
|
writestruct(wd, DATA, "Base", 1, base);
|
|
|
|
base= base->next;
|
|
|
|
}
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2009-08-17 00:39:00 +00:00
|
|
|
tos = sce->toolsettings;
|
|
|
|
writestruct(wd, DATA, "ToolSettings", 1, tos);
|
2009-08-17 02:49:31 +00:00
|
|
|
if(tos->vpaint) {
|
2009-08-17 00:39:00 +00:00
|
|
|
writestruct(wd, DATA, "VPaint", 1, tos->vpaint);
|
2009-08-17 02:49:31 +00:00
|
|
|
}
|
|
|
|
if(tos->wpaint) {
|
2009-08-17 00:39:00 +00:00
|
|
|
writestruct(wd, DATA, "VPaint", 1, tos->wpaint);
|
2009-08-17 02:49:31 +00:00
|
|
|
}
|
2009-08-17 00:39:00 +00:00
|
|
|
if(tos->sculpt) {
|
|
|
|
writestruct(wd, DATA, "Sculpt", 1, tos->sculpt);
|
2009-08-16 19:50:00 +00:00
|
|
|
}
|
2012-01-17 16:31:13 +00:00
|
|
|
if(tos->uvsculpt) {
|
|
|
|
writestruct(wd, DATA, "UvSculpt", 1, tos->uvsculpt);
|
|
|
|
}
|
2006-11-06 01:08:26 +00:00
|
|
|
|
2010-08-04 12:18:07 +00:00
|
|
|
// write_paint(wd, &tos->imapaint.paint);
|
2006-11-06 01:08:26 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
ed= sce->ed;
|
|
|
|
if(ed) {
|
|
|
|
writestruct(wd, DATA, "Editing", 1, ed);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* reset write flags too */
|
2008-01-01 18:16:10 +00:00
|
|
|
|
2008-12-15 05:21:44 +00:00
|
|
|
SEQ_BEGIN(ed, seq) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(seq->strip) seq->strip->done= 0;
|
|
|
|
writestruct(wd, DATA, "Sequence", 1, seq);
|
|
|
|
}
|
2008-12-15 05:21:44 +00:00
|
|
|
SEQ_END
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2008-12-15 05:21:44 +00:00
|
|
|
SEQ_BEGIN(ed, seq) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(seq->strip && seq->strip->done==0) {
|
2003-04-26 18:01:01 +00:00
|
|
|
/* write strip with 'done' at 0 because readfile */
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if(seq->plugin) writestruct(wd, DATA, "PluginSeq", 1, seq->plugin);
|
2004-06-23 18:22:51 +00:00
|
|
|
if(seq->effectdata) {
|
|
|
|
switch(seq->type){
|
2006-11-09 22:23:09 +00:00
|
|
|
case SEQ_COLOR:
|
|
|
|
writestruct(wd, DATA, "SolidColorVars", 1, seq->effectdata);
|
|
|
|
break;
|
2006-11-11 22:35:40 +00:00
|
|
|
case SEQ_SPEED:
|
|
|
|
writestruct(wd, DATA, "SpeedControlVars", 1, seq->effectdata);
|
|
|
|
break;
|
2006-11-09 22:23:09 +00:00
|
|
|
case SEQ_WIPE:
|
|
|
|
writestruct(wd, DATA, "WipeVars", 1, seq->effectdata);
|
|
|
|
break;
|
|
|
|
case SEQ_GLOW:
|
|
|
|
writestruct(wd, DATA, "GlowVars", 1, seq->effectdata);
|
|
|
|
break;
|
|
|
|
case SEQ_TRANSFORM:
|
|
|
|
writestruct(wd, DATA, "TransformVars", 1, seq->effectdata);
|
|
|
|
break;
|
2004-06-23 18:22:51 +00:00
|
|
|
}
|
|
|
|
}
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
strip= seq->strip;
|
|
|
|
writestruct(wd, DATA, "Strip", 1, strip);
|
2007-12-25 15:31:36 +00:00
|
|
|
if(seq->flag & SEQ_USE_CROP && strip->crop) {
|
|
|
|
writestruct(wd, DATA, "StripCrop", 1, strip->crop);
|
|
|
|
}
|
|
|
|
if(seq->flag & SEQ_USE_TRANSFORM && strip->transform) {
|
|
|
|
writestruct(wd, DATA, "StripTransform", 1, strip->transform);
|
|
|
|
}
|
|
|
|
if(seq->flag & SEQ_USE_PROXY && strip->proxy) {
|
|
|
|
writestruct(wd, DATA, "StripProxy", 1, strip->proxy);
|
|
|
|
}
|
2008-02-02 23:28:50 +00:00
|
|
|
if(seq->flag & SEQ_USE_COLOR_BALANCE && strip->color_balance) {
|
|
|
|
writestruct(wd, DATA, "StripColorBalance", 1, strip->color_balance);
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
if(seq->type==SEQ_IMAGE)
|
2008-03-24 17:35:01 +00:00
|
|
|
writestruct(wd, DATA, "StripElem", MEM_allocN_len(strip->stripdata) / sizeof(struct StripElem), strip->stripdata);
|
2006-02-05 19:36:32 +00:00
|
|
|
else if(seq->type==SEQ_MOVIE || seq->type==SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND)
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, DATA, "StripElem", 1, strip->stripdata);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
strip->done= 1;
|
|
|
|
}
|
|
|
|
}
|
2008-12-15 05:21:44 +00:00
|
|
|
SEQ_END
|
2004-11-13 12:55:59 +00:00
|
|
|
|
|
|
|
/* new; meta stack too, even when its nasty restore code */
|
|
|
|
for(ms= ed->metastack.first; ms; ms= ms->next) {
|
|
|
|
writestruct(wd, DATA, "MetaStack", 1, ms);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2009-02-11 12:19:42 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if (sce->r.avicodecdata) {
|
|
|
|
writestruct(wd, DATA, "AviCodecData", 1, sce->r.avicodecdata);
|
|
|
|
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);
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2003-05-21 01:21:07 +00:00
|
|
|
if (sce->r.qtcodecdata) {
|
|
|
|
writestruct(wd, DATA, "QuicktimeCodecData", 1, sce->r.qtcodecdata);
|
|
|
|
if (sce->r.qtcodecdata->cdParms) writedata(wd, DATA, sce->r.qtcodecdata->cdSize, sce->r.qtcodecdata->cdParms);
|
|
|
|
}
|
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 */
|
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
|
|
|
for(marker= sce->markers.first; marker; marker= marker->next)
|
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
|
|
|
writestruct(wd, DATA, "TimeMarker", 1, marker);
|
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
|
|
|
|
=== 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 */
|
|
|
|
for(ts = sce->transform_spaces.first; ts; ts = ts->next)
|
|
|
|
writestruct(wd, DATA, "TransformOrientation", 1, 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
|
|
|
for(srl= sce->r.layers.first; srl; srl= srl->next)
|
|
|
|
writestruct(wd, DATA, "SceneRenderLayer", 1, srl);
|
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
|
|
|
|
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
|
|
|
if(sce->nodetree) {
|
|
|
|
writestruct(wd, DATA, "bNodeTree", 1, sce->nodetree);
|
|
|
|
write_nodetree(wd, sce->nodetree);
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
sce= sce->id.next;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
static void write_gpencils(WriteData *wd, ListBase *lb)
|
2008-07-22 09:53:25 +00:00
|
|
|
{
|
2009-05-23 03:24:15 +00:00
|
|
|
bGPdata *gpd;
|
2008-07-22 09:53:25 +00:00
|
|
|
bGPDlayer *gpl;
|
|
|
|
bGPDframe *gpf;
|
|
|
|
bGPDstroke *gps;
|
|
|
|
|
2009-05-23 03:24:15 +00:00
|
|
|
for (gpd= lb->first; gpd; gpd= gpd->id.next) {
|
2011-01-19 22:49:09 +00:00
|
|
|
if (gpd->id.us>0 || wd->current) {
|
|
|
|
/* write gpd data block to file */
|
|
|
|
writestruct(wd, ID_GD, "bGPdata", 1, gpd);
|
2008-07-22 09:53:25 +00:00
|
|
|
|
2011-01-19 22:49:09 +00:00
|
|
|
/* write grease-pencil layers to file */
|
|
|
|
for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
|
|
|
|
writestruct(wd, DATA, "bGPDlayer", 1, gpl);
|
2009-05-23 03:24:15 +00:00
|
|
|
|
2011-01-19 22:49:09 +00:00
|
|
|
/* write this layer's frames to file */
|
|
|
|
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
|
|
|
|
writestruct(wd, DATA, "bGPDframe", 1, gpf);
|
|
|
|
|
|
|
|
/* write strokes */
|
|
|
|
for (gps= gpf->strokes.first; gps; gps= gps->next) {
|
|
|
|
writestruct(wd, DATA, "bGPDstroke", 1, gps);
|
|
|
|
writestruct(wd, DATA, "bGPDspoint", gps->totpoints, gps->points);
|
|
|
|
}
|
2009-05-23 03:24:15 +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;
|
|
|
|
|
|
|
|
for(wm= lb->first; wm; wm= wm->id.next) {
|
|
|
|
writestruct(wd, ID_WM, "wmWindowManager", 1, wm);
|
|
|
|
|
|
|
|
for(win= wm->windows.first; win; win= win->next)
|
|
|
|
writestruct(wd, DATA, "wmWindow", 1, win);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
writestruct(wd, DATA, "ARegion", 1, ar);
|
|
|
|
|
|
|
|
if(ar->regiondata) {
|
|
|
|
switch(spacetype) {
|
|
|
|
case SPACE_VIEW3D:
|
|
|
|
if(ar->regiontype==RGN_TYPE_WINDOW) {
|
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
|
|
|
writestruct(wd, DATA, "RegionView3D", 1, rv3d);
|
|
|
|
|
|
|
|
if(rv3d->localvd)
|
|
|
|
writestruct(wd, DATA, "RegionView3D", 1, rv3d->localvd);
|
|
|
|
if(rv3d->clipbb)
|
|
|
|
writestruct(wd, DATA, "BoundBox", 1, rv3d->clipbb);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf("regiondata write missing!\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("regiondata write missing!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
static void write_screens(WriteData *wd, ListBase *scrbase)
|
|
|
|
{
|
|
|
|
bScreen *sc;
|
|
|
|
ScrArea *sa;
|
|
|
|
ScrVert *sv;
|
|
|
|
ScrEdge *se;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
sc= scrbase->first;
|
|
|
|
while(sc) {
|
2008-01-01 15:53:38 +00: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 */
|
|
|
|
writestruct(wd, ID_SCRN, "Screen", 1, sc);
|
2008-01-01 15:53:38 +00:00
|
|
|
if (sc->id.properties)
|
|
|
|
IDP_WriteProperty(sc->id.properties, wd);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* direct data */
|
2008-01-01 15:53:38 +00:00
|
|
|
for(sv= sc->vertbase.first; sv; sv= sv->next)
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, DATA, "ScrVert", 1, sv);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2008-01-01 15:53:38 +00:00
|
|
|
for(se= sc->edgebase.first; se; se= se->next)
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, DATA, "ScrEdge", 1, se);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2008-01-01 15:53:38 +00: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;
|
2008-01-01 15:53:38 +00:00
|
|
|
ARegion *ar;
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, DATA, "ScrArea", 1, sa);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2008-12-26 13:11:04 +00: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);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2008-12-26 13:11:04 +00:00
|
|
|
for(pa= ar->panels.first; pa; pa= pa->next)
|
|
|
|
writestruct(wd, DATA, "Panel", 1, pa);
|
|
|
|
}
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
sl= sa->spacedata.first;
|
|
|
|
while(sl) {
|
2008-12-19 00:18:16 +00: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);
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if(sl->spacetype==SPACE_VIEW3D) {
|
2008-07-22 09:53:25 +00:00
|
|
|
View3D *v3d= (View3D *) sl;
|
2010-01-19 22:44:43 +00:00
|
|
|
BGpic *bgpic;
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, DATA, "View3D", 1, v3d);
|
2010-01-19 22:44:43 +00:00
|
|
|
for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next)
|
2010-01-25 23:12:02 +00:00
|
|
|
writestruct(wd, DATA, "BGpic", 1, bgpic);
|
2002-10-12 11:37:38 +00:00
|
|
|
if(v3d->localvd) writestruct(wd, DATA, "View3D", 1, v3d->localvd);
|
|
|
|
}
|
|
|
|
else if(sl->spacetype==SPACE_IPO) {
|
2009-05-23 03:24:15 +00:00
|
|
|
SpaceIpo *sipo= (SpaceIpo *)sl;
|
|
|
|
ListBase tmpGhosts = sipo->ghostCurves;
|
|
|
|
|
|
|
|
/* temporarily disable ghost curves when saving */
|
|
|
|
sipo->ghostCurves.first= sipo->ghostCurves.last= NULL;
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, DATA, "SpaceIpo", 1, sl);
|
2009-05-23 03:24:15 +00:00
|
|
|
if(sipo->ads) writestruct(wd, DATA, "bDopeSheet", 1, sipo->ads);
|
|
|
|
|
|
|
|
/* reenable ghost curves */
|
|
|
|
sipo->ghostCurves= tmpGhosts;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
else if(sl->spacetype==SPACE_BUTS) {
|
|
|
|
writestruct(wd, DATA, "SpaceButs", 1, sl);
|
|
|
|
}
|
|
|
|
else if(sl->spacetype==SPACE_FILE) {
|
2011-07-08 12:22:48 +00:00
|
|
|
SpaceFile *sfile= (SpaceFile *)sl;
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, DATA, "SpaceFile", 1, sl);
|
2011-07-08 12:22:48 +00:00
|
|
|
if(sfile->params)
|
|
|
|
writestruct(wd, DATA, "FileSelectParams", 1, sfile->params);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
else if(sl->spacetype==SPACE_SEQ) {
|
|
|
|
writestruct(wd, DATA, "SpaceSeq", 1, sl);
|
|
|
|
}
|
2009-03-26 14:05:33 +00:00
|
|
|
else if(sl->spacetype==SPACE_OUTLINER) {
|
2002-10-12 11:37:38 +00:00
|
|
|
SpaceOops *so= (SpaceOops *)sl;
|
2009-01-19 02:26:46 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, DATA, "SpaceOops", 1, so);
|
2009-03-26 14:05:33 +00:00
|
|
|
|
Version 1.0 of the new Outliner
The outliner is a hierarchical diagram displaying a list of data in Blender
and its dependencies. The 'databrowse' doesn't really show it, and Oops is
too chaotic still. And most of all, the former two don't offer much tools.
After discussions on irc, Matt came with this design proposal;
http://mke3.net/blender/interface/layout/outliner/
Which is closely followed for the implementation.
The current version only shows all 'library data' in Blender (objects,
meshes, ipos, etc) and not the 'direct data' such as vertex groups or NLA.
I decided to make it inside the Oopw window, as an option. You can find the
option in the "View" pulldown, or directly invoke it with ALT+SHIFT+F9
Here's a quick overview of the Outliner GUI:
- Header pulldown has options what it can show (Visible = in current layers)
- click on triangle arrow to open/close
- press AKEY to open/close all
- Leftmouse click on an item activates; and does based on type a couple of
extra things:
- activates a scene
- selects/activates the Object
- enters editmode (if clicked on Mesh, Curve, etc)
- shows the appropriate Shading buttons (Lamp, Material, Texture)
- sets the IpoWindow to the current IPO
- activates the Ipo-channel in an Action
- Selected and Active objects are drawn in its Theme selection color
- SHIFT+click on Object does extend-select
- Press DOTkey to get the current active data in center of view
TODO;
- rightmouse selection; for indicating operations like delete or duplicate
- showing more data types
- icon (re)design...
- lotsof options as described in Matts paper still...
2004-10-06 18:55:00 +00:00
|
|
|
/* outliner */
|
|
|
|
if(so->treestore) {
|
|
|
|
writestruct(wd, DATA, "TreeStore", 1, so->treestore);
|
|
|
|
if(so->treestore->data)
|
|
|
|
writestruct(wd, DATA, "TreeStoreElem", so->treestore->usedelem, so->treestore->data);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
else if(sl->spacetype==SPACE_IMAGE) {
|
2006-01-09 23:52:51 +00:00
|
|
|
SpaceImage *sima= (SpaceImage *)sl;
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, DATA, "SpaceImage", 1, sl);
|
2006-01-09 23:52:51 +00:00
|
|
|
if(sima->cumap)
|
2008-09-05 07:12:04 +00:00
|
|
|
write_curvemapping(wd, sima->cumap);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
else if(sl->spacetype==SPACE_TEXT) {
|
|
|
|
writestruct(wd, DATA, "SpaceText", 1, sl);
|
|
|
|
}
|
2003-12-14 01:18:09 +00:00
|
|
|
else if(sl->spacetype==SPACE_SCRIPT) {
|
2011-05-23 08:14:29 +00:00
|
|
|
SpaceScript *scr = (SpaceScript*)sl;
|
|
|
|
scr->but_refs = NULL;
|
2003-12-14 01:18:09 +00:00
|
|
|
writestruct(wd, DATA, "SpaceScript", 1, sl);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
else if(sl->spacetype==SPACE_ACTION) {
|
|
|
|
writestruct(wd, DATA, "SpaceAction", 1, sl);
|
|
|
|
}
|
|
|
|
else if(sl->spacetype==SPACE_NLA){
|
2009-05-25 13:07:54 +00:00
|
|
|
SpaceNla *snla= (SpaceNla *)sl;
|
|
|
|
|
|
|
|
writestruct(wd, DATA, "SpaceNla", 1, snla);
|
|
|
|
if(snla->ads) writestruct(wd, DATA, "bDopeSheet", 1, snla->ads);
|
2002-10-12 11:37:38 +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
|
|
|
else if(sl->spacetype==SPACE_TIME){
|
|
|
|
writestruct(wd, DATA, "SpaceTime", 1, sl);
|
|
|
|
}
|
2005-12-18 13:46:01 +00:00
|
|
|
else if(sl->spacetype==SPACE_NODE){
|
|
|
|
writestruct(wd, DATA, "SpaceNode", 1, sl);
|
|
|
|
}
|
2009-06-16 13:09:36 +00:00
|
|
|
else if(sl->spacetype==SPACE_LOGIC){
|
|
|
|
writestruct(wd, DATA, "SpaceLogic", 1, sl);
|
|
|
|
}
|
2009-07-16 00:50:27 +00:00
|
|
|
else if(sl->spacetype==SPACE_CONSOLE) {
|
2010-04-23 09:24:22 +00:00
|
|
|
SpaceConsole *con = (SpaceConsole*)sl;
|
|
|
|
ConsoleLine *cl;
|
|
|
|
|
|
|
|
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 */
|
2010-04-23 09:24:22 +00:00
|
|
|
writestruct(wd, DATA, "ConsoleLine", 1, cl);
|
|
|
|
writedata(wd, DATA, cl->len+1, cl->line);
|
|
|
|
}
|
2009-07-16 00:50:27 +00:00
|
|
|
writestruct(wd, DATA, "SpaceConsole", 1, sl);
|
2010-04-23 09:24:22 +00:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
2009-08-18 12:58:51 +00:00
|
|
|
else if(sl->spacetype==SPACE_USERPREF) {
|
|
|
|
writestruct(wd, DATA, "SpaceUserPref", 1, sl);
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
else if(sl->spacetype==SPACE_CLIP) {
|
|
|
|
writestruct(wd, DATA, "SpaceClip", 1, sl);
|
|
|
|
}
|
2009-08-18 12:58:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
sl= sl->next;
|
|
|
|
}
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
sc= sc->id.next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_libraries(WriteData *wd, Main *main)
|
|
|
|
{
|
2011-10-29 11:15:12 +00:00
|
|
|
ListBase *lbarray[MAX_LIBARRAY];
|
2002-10-12 11:37:38 +00:00
|
|
|
ID *id;
|
|
|
|
int a, tot, foundone;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2006-11-25 13:07:28 +00:00
|
|
|
for(; main; main= main->next) {
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
a=tot= set_listbasepointers(main, lbarray);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2003-04-26 18:01:01 +00:00
|
|
|
/* test: is lib being used */
|
2002-10-12 11:37:38 +00:00
|
|
|
foundone= 0;
|
|
|
|
while(tot--) {
|
2006-11-25 13:07:28 +00:00
|
|
|
for(id= lbarray[tot]->first; id; id= id->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(id->us>0 && (id->flag & LIB_EXTERN)) {
|
|
|
|
foundone= 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(foundone) break;
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
|
|
|
if(foundone) {
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, ID_LI, "Library", 1, main->curlib);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
while(a--) {
|
2006-11-25 13:07:28 +00:00
|
|
|
for(id= lbarray[a]->first; id; id= id->next) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(id->us>0 && (id->flag & LIB_EXTERN)) {
|
|
|
|
writestruct(wd, ID_ID, "ID", 1, id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_bone(WriteData *wd, Bone* bone)
|
|
|
|
{
|
|
|
|
Bone* cbone;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2005-07-09 13:41:01 +00:00
|
|
|
// PATCH for upward compatibility after 2.37+ armature recode
|
|
|
|
bone->size[0]= bone->size[1]= bone->size[2]= 1.0f;
|
|
|
|
|
2004-06-23 18:22:51 +00:00
|
|
|
// Write this bone
|
2002-10-12 11:37:38 +00: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
|
|
|
|
of library blocks that implement this.*/
|
|
|
|
if (bone->prop)
|
|
|
|
IDP_WriteProperty(bone->prop, wd);
|
2005-07-09 13:41:01 +00:00
|
|
|
|
2004-06-23 18:22:51 +00:00
|
|
|
// Write Children
|
2002-10-12 11:37:38 +00:00
|
|
|
cbone= bone->childbase.first;
|
|
|
|
while(cbone) {
|
|
|
|
write_bone(wd, cbone);
|
|
|
|
cbone= cbone->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_armatures(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
bArmature *arm;
|
|
|
|
Bone *bone;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
arm=idbase->first;
|
|
|
|
while (arm) {
|
2004-11-07 10:15:06 +00:00
|
|
|
if (arm->id.us>0 || wd->current) {
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, ID_AR, "bArmature", 1, arm);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (arm->id.properties) IDP_WriteProperty(arm->id.properties, wd);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
if (arm->adt) write_animdata(wd, arm->adt);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* Direct data */
|
|
|
|
bone= arm->bonebase.first;
|
|
|
|
while(bone) {
|
|
|
|
write_bone(wd, bone);
|
|
|
|
bone=bone->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
arm=arm->id.next;
|
|
|
|
}
|
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;
|
2008-08-04 23:01:47 +00:00
|
|
|
TextMarker *mrk;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
text= idbase->first;
|
|
|
|
while(text) {
|
|
|
|
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 */
|
|
|
|
writestruct(wd, ID_TXT, "Text", 1, text);
|
|
|
|
if(text->name) writedata(wd, DATA, strlen(text->name)+1, text->name);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (text->id.properties) IDP_WriteProperty(text->id.properties, wd);
|
2004-06-23 18:22:51 +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 */
|
|
|
|
tmp= text->lines.first;
|
|
|
|
while (tmp) {
|
|
|
|
writestruct(wd, DATA, "TextLine", 1, tmp);
|
|
|
|
tmp= tmp->next;
|
|
|
|
}
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
tmp= text->lines.first;
|
|
|
|
while (tmp) {
|
|
|
|
writedata(wd, DATA, tmp->len+1, tmp->line);
|
|
|
|
tmp= tmp->next;
|
|
|
|
}
|
2008-08-04 23:01:47 +00:00
|
|
|
|
|
|
|
/* write markers */
|
|
|
|
mrk= text->markers.first;
|
|
|
|
while (mrk) {
|
|
|
|
writestruct(wd, DATA, "TextMarker", 1, mrk);
|
|
|
|
mrk= mrk->next;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-08-04 23:01:47 +00:00
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
text= text->id.next;
|
|
|
|
}
|
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;
|
|
|
|
|
|
|
|
spk= idbase->first;
|
|
|
|
while(spk) {
|
|
|
|
if(spk->id.us>0 || wd->current) {
|
|
|
|
/* write LibData */
|
|
|
|
writestruct(wd, ID_SPK, "Speaker", 1, spk);
|
|
|
|
if (spk->id.properties) IDP_WriteProperty(spk->id.properties, wd);
|
|
|
|
|
|
|
|
if (spk->adt) write_animdata(wd, spk->adt);
|
|
|
|
}
|
|
|
|
spk= spk->id.next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
PackedFile * pf;
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
sound= idbase->first;
|
|
|
|
while(sound) {
|
2004-11-07 10:15:06 +00:00
|
|
|
if(sound->id.us>0 || wd->current) {
|
2002-10-12 11:37:38 +00:00
|
|
|
/* write LibData */
|
|
|
|
writestruct(wd, ID_SO, "bSound", 1, sound);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (sound->id.properties) IDP_WriteProperty(sound->id.properties, wd);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2009-08-09 21:16:39 +00:00
|
|
|
if (sound->packedfile) {
|
|
|
|
pf = sound->packedfile;
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, DATA, "PackedFile", 1, pf);
|
|
|
|
writedata(wd, DATA, pf->size, pf->data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sound= sound->id.next;
|
|
|
|
}
|
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
|
|
|
|
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
|
|
|
for(group= idbase->first; group; group= group->id.next) {
|
2004-11-07 10:15:06 +00:00
|
|
|
if(group->id.us>0 || wd->current) {
|
2002-10-12 11:37:38 +00:00
|
|
|
/* write LibData */
|
|
|
|
writestruct(wd, ID_GR, "Group", 1, group);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (group->id.properties) IDP_WriteProperty(group->id.properties, wd);
|
2004-06-23 18:22:51 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
go= group->gobject.first;
|
|
|
|
while(go) {
|
|
|
|
writestruct(wd, DATA, "GroupObject", 1, go);
|
|
|
|
go= go->next;
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
|
|
|
|
for(ntree=idbase->first; ntree; ntree= ntree->id.next) {
|
|
|
|
if (ntree->id.us>0 || wd->current) {
|
|
|
|
writestruct(wd, ID_NT, "bNodeTree", 1, ntree);
|
|
|
|
write_nodetree(wd, ntree);
|
2009-02-20 16:39:39 +00:00
|
|
|
|
2006-11-17 06:14:15 +00:00
|
|
|
if (ntree->id.properties) IDP_WriteProperty(ntree->id.properties, wd);
|
2009-02-20 16:39:39 +00:00
|
|
|
|
|
|
|
if (ntree->adt) write_animdata(wd, ntree->adt);
|
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
|
|
|
}
|
2002-10-12 11:37:38 +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
|
|
|
static void write_brushes(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Brush *brush;
|
|
|
|
|
2006-07-31 15:53:03 +00:00
|
|
|
for(brush=idbase->first; brush; brush= brush->id.next) {
|
|
|
|
if(brush->id.us>0 || wd->current) {
|
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
|
|
|
writestruct(wd, ID_BR, "Brush", 1, brush);
|
2006-11-17 06:14:15 +00:00
|
|
|
if (brush->id.properties) IDP_WriteProperty(brush->id.properties, wd);
|
2010-01-03 08:37:18 +00:00
|
|
|
|
2010-01-22 04:21:46 +00:00
|
|
|
writestruct(wd, DATA, "MTex", 1, &brush->mtex);
|
|
|
|
|
2009-01-07 04:38:30 +00:00
|
|
|
if(brush->curve)
|
|
|
|
write_curvemapping(wd, brush->curve);
|
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
|
|
|
}
|
|
|
|
|
2008-03-06 21:25:15 +00:00
|
|
|
static void write_scripts(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
Script *script;
|
|
|
|
|
|
|
|
for(script=idbase->first; script; script= script->id.next) {
|
|
|
|
if(script->id.us>0 || wd->current) {
|
|
|
|
writestruct(wd, ID_SCRIPT, "Script", 1, script);
|
|
|
|
if (script->id.properties) IDP_WriteProperty(script->id.properties, wd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-05 18:57:17 +00:00
|
|
|
static void write_movieTracks(WriteData *wd, ListBase *tracks)
|
|
|
|
{
|
|
|
|
MovieTrackingTrack *track;
|
|
|
|
|
|
|
|
track= tracks->first;
|
|
|
|
while(track) {
|
|
|
|
writestruct(wd, DATA, "MovieTrackingTrack", 1, track);
|
|
|
|
|
|
|
|
if(track->markers)
|
|
|
|
writestruct(wd, DATA, "MovieTrackingMarker", track->markersnr, track->markers);
|
|
|
|
|
|
|
|
track= track->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_movieReconstruction(WriteData *wd, MovieTrackingReconstruction *reconstruction)
|
|
|
|
{
|
|
|
|
if(reconstruction->camnr)
|
|
|
|
writestruct(wd, DATA, "MovieReconstructedCamera", reconstruction->camnr, reconstruction->cameras);
|
|
|
|
}
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
static void write_movieclips(WriteData *wd, ListBase *idbase)
|
|
|
|
{
|
|
|
|
MovieClip *clip;
|
|
|
|
|
|
|
|
clip= idbase->first;
|
|
|
|
while(clip) {
|
|
|
|
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
|
|
|
writestruct(wd, ID_MC, "MovieClip", 1, clip);
|
|
|
|
|
2012-02-17 08:13:45 +00:00
|
|
|
if(clip->adt)
|
|
|
|
write_animdata(wd, clip->adt);
|
|
|
|
|
2011-12-05 18:57:17 +00:00
|
|
|
write_movieTracks(wd, &tracking->tracks);
|
|
|
|
write_movieReconstruction(wd, &tracking->reconstruction);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2011-12-05 18:57:17 +00:00
|
|
|
object= tracking->objects.first;
|
|
|
|
while(object) {
|
|
|
|
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);
|
|
|
|
write_movieReconstruction(wd, &object->reconstruction);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2011-12-05 18:57:17 +00:00
|
|
|
object= object->next;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
clip= clip->id.next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* flush helps the compression for undo-save */
|
|
|
|
mywrite(wd, MYWRITE_FLUSH, 0);
|
|
|
|
}
|
|
|
|
|
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-11-01 00:06:53 +00:00
|
|
|
static void write_global(WriteData *wd, int fileflags, Main *mainvar)
|
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];
|
2006-11-27 10:43:00 +00:00
|
|
|
|
2011-01-16 21:12:38 +00:00
|
|
|
/* prevent mem checkers from complaining */
|
|
|
|
fg.pads= fg.pad= 0;
|
|
|
|
memset(fg.filename, 0, sizeof(fg.filename));
|
|
|
|
|
2008-12-19 16:36:15 +00:00
|
|
|
current_screen_compat(mainvar, &screen);
|
|
|
|
|
|
|
|
/* XXX still remap G */
|
|
|
|
fg.curscreen= screen;
|
2009-01-04 14:14:06 +00:00
|
|
|
fg.curscene= screen->scene;
|
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
|
|
|
fg.displaymode= G.displaymode;
|
|
|
|
fg.winpos= G.winpos;
|
2011-12-27 13:17:58 +00:00
|
|
|
|
|
|
|
/* prevent to save this, is not good convention, and feature with concerns... */
|
|
|
|
fg.fileflags= (fileflags & ~(G_FILE_NO_UI|G_FILE_RELATIVE_REMAP|G_FILE_MESH_COMPAT));
|
|
|
|
|
2003-07-21 19:41:07 +00:00
|
|
|
fg.globalf= G.f;
|
2009-11-01 00:06: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);
|
|
|
|
|
2006-11-26 21:17:15 +00: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
|
|
|
{
|
|
|
|
extern char build_rev[];
|
|
|
|
fg.revision= atoi(build_rev);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
fg.revision= 0;
|
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
writestruct(wd, GLOB, "FileGlobal", 1, &fg);
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
static void write_thumb(WriteData *wd, int *img)
|
|
|
|
{
|
|
|
|
if(img)
|
|
|
|
writedata(wd, TEST, (2 + img[0] * img[1]) * sizeof(int), img);
|
|
|
|
}
|
|
|
|
|
2006-11-25 13:07:28 +00:00
|
|
|
/* if MemFile * there's filesave to memory */
|
2008-12-19 16:36:15 +00:00
|
|
|
static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFile *current,
|
2010-05-24 21:52:18 +00:00
|
|
|
int write_user_block, int write_flags, int *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
|
|
|
|
2010-09-06 12:54:54 +00:00
|
|
|
wd= bgnwrite(handle, 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
|
|
|
|
|
2008-12-19 19:11:02 +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-11-01 00:06:53 +00:00
|
|
|
write_global(wd, write_flags, mainvar);
|
2006-11-26 21:17:15 +00:00
|
|
|
|
2007-12-24 18:53:37 +00:00
|
|
|
/* no UI save in undo */
|
|
|
|
if(current==NULL) {
|
2008-12-19 16:36:15 +00:00
|
|
|
write_windowmanagers(wd, &mainvar->wm);
|
|
|
|
write_screens (wd, &mainvar->screen);
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
write_movieclips (wd, &mainvar->movieclip);
|
2008-12-19 16:36:15 +00:00
|
|
|
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);
|
2011-08-01 11:44:20 +00:00
|
|
|
write_speakers (wd, &mainvar->speaker);
|
2008-12-19 16:36:15 +00:00
|
|
|
write_sounds (wd, &mainvar->sound);
|
|
|
|
write_groups (wd, &mainvar->group);
|
|
|
|
write_armatures(wd, &mainvar->armature);
|
|
|
|
write_actions (wd, &mainvar->action);
|
2009-08-19 16:49:21 +00:00
|
|
|
write_objects (wd, &mainvar->object);
|
2008-12-19 16:36:15 +00:00
|
|
|
write_materials(wd, &mainvar->mat);
|
|
|
|
write_textures (wd, &mainvar->tex);
|
|
|
|
write_meshs (wd, &mainvar->mesh);
|
|
|
|
write_particlesettings(wd, &mainvar->particle);
|
|
|
|
write_nodetrees(wd, &mainvar->nodetree);
|
|
|
|
write_brushes (wd, &mainvar->brush);
|
|
|
|
write_scripts (wd, &mainvar->script);
|
2009-05-23 03:24:15 +00:00
|
|
|
write_gpencils (wd, &mainvar->gpencil);
|
2009-11-01 00:06:53 +00:00
|
|
|
write_libraries(wd, mainvar->next);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
if (write_user_block) {
|
|
|
|
write_userdef(wd);
|
|
|
|
}
|
2007-12-24 18:53:37 +00: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
|
|
|
|
2004-09-05 13:43:51 +00:00
|
|
|
/* end of file */
|
|
|
|
memset(&bhead, 0, sizeof(BHead));
|
|
|
|
bhead.code= ENDB;
|
|
|
|
mywrite(wd, &bhead, sizeof(BHead));
|
2004-06-23 18:22:51 +00:00
|
|
|
|
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) */
|
|
|
|
static int do_history(const char *name, ReportList *reports)
|
|
|
|
{
|
2011-11-26 04:07:38 +00:00
|
|
|
char tempname1[FILE_MAX], tempname2[FILE_MAX];
|
2011-06-02 12:44:59 +00:00
|
|
|
int hisnr= U.versions;
|
|
|
|
|
|
|
|
if(U.versions==0) return 0;
|
|
|
|
if(strlen(name)<2) {
|
|
|
|
BKE_report(reports, RPT_ERROR, "Unable to make version backup: filename too short");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(hisnr > 1) {
|
|
|
|
BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr-1);
|
|
|
|
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 1;
|
|
|
|
}
|
|
|
|
hisnr--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* is needed when hisnr==1 */
|
|
|
|
BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr);
|
|
|
|
|
|
|
|
if(BLI_rename(name, tempname1)) {
|
|
|
|
BKE_report(reports, RPT_ERROR, "Unable to make version backup");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-09-05 13:43:51 +00:00
|
|
|
/* return: success (1) */
|
2011-05-18 06:27:32 +00:00
|
|
|
int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportList *reports, int *thumb)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2011-11-26 04:07:38 +00:00
|
|
|
char userfilename[FILE_MAX];
|
|
|
|
char tempname[FILE_MAX+1];
|
2006-11-25 13:07:28 +00:00
|
|
|
int file, err, write_user_block;
|
2004-06-23 18:22:51 +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
|
|
|
|
|
|
|
file = open(tempname,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
|
|
|
|
if(file == -1) {
|
2010-07-14 20:52:23 +00:00
|
|
|
BKE_reportf(reports, RPT_ERROR, "Can't 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
|
|
|
|
2010-01-29 11:26:17 +00:00
|
|
|
/* remapping of relative paths to new file location */
|
2010-01-08 17:50:55 +00:00
|
|
|
if(write_flags & G_FILE_RELATIVE_REMAP) {
|
2011-11-26 04:07:38 +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
|
|
|
|
|
|
|
/* just incase 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
|
|
|
|
2011-05-18 06:48:52 +00:00
|
|
|
if(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 {
|
|
|
|
if(G.relbase_valid) {
|
|
|
|
/* 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
|
|
|
|
* print an error, dont try make the absolute in this case. */
|
|
|
|
makeFilesAbsolute(mainvar, G.main->name, NULL);
|
|
|
|
}
|
|
|
|
}
|
2010-01-08 17:50:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-18 06:41:16 +00:00
|
|
|
BLI_make_file_string(G.main->name, userfilename, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
|
2011-05-18 06:27:32 +00:00
|
|
|
write_user_block= (BLI_path_cmp(filepath, userfilename) == 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-01-08 17:50:55 +00:00
|
|
|
if(write_flags & G_FILE_RELATIVE_REMAP)
|
2011-05-18 06:27:32 +00:00
|
|
|
makeFilesRelative(mainvar, filepath, NULL); /* note, making relative to something OTHER then G.main->name */
|
2010-01-08 17:50:55 +00:00
|
|
|
|
2010-01-29 11:26:17 +00:00
|
|
|
/* actual file writing */
|
2010-05-24 21:52:18 +00:00
|
|
|
err= write_file_handle(mainvar, file, NULL,NULL, write_user_block, write_flags, thumb);
|
2002-10-12 11:37:38 +00:00
|
|
|
close(file);
|
2004-06-23 18:22:51 +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) */
|
|
|
|
if (write_flags & G_FILE_HISTORY) {
|
|
|
|
int err_hist = do_history(filepath, reports);
|
|
|
|
if (err_hist) {
|
|
|
|
BKE_report(reports, RPT_ERROR, "Version backup failed. File saved with @");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(write_flags & G_FILE_COMPRESS) {
|
|
|
|
/* compressed files have the same ending as regular files... only from 2.4!!! */
|
2011-11-26 04:07:38 +00:00
|
|
|
char gzname[FILE_MAX+4];
|
2011-06-02 12:44:59 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* first write compressed to separate @.gz */
|
|
|
|
BLI_snprintf(gzname, sizeof(gzname), "%s@.gz", filepath);
|
2011-10-22 15:35:49 +00:00
|
|
|
ret = BLI_file_gzip(tempname, gzname);
|
2011-06-02 12:44:59 +00:00
|
|
|
|
|
|
|
if(0==ret) {
|
|
|
|
/* now rename to real file name, and delete temp @ file too */
|
|
|
|
if(BLI_rename(gzname, filepath) != 0) {
|
|
|
|
BKE_report(reports, RPT_ERROR, "Can't change old file. File saved with @.");
|
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
|
|
|
return 0;
|
|
|
|
}
|
2011-06-02 12:44:59 +00:00
|
|
|
|
|
|
|
BLI_delete(tempname, 0, 0);
|
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
|
|
|
}
|
2011-06-02 12:44:59 +00:00
|
|
|
else if(-1==ret) {
|
|
|
|
BKE_report(reports, RPT_ERROR, "Failed opening .gz file.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if(-2==ret) {
|
|
|
|
BKE_report(reports, RPT_ERROR, "Failed opening .blend file for compression.");
|
2002-10-12 11:37:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2010-01-29 11:26:17 +00:00
|
|
|
}
|
2011-06-02 12:44:59 +00:00
|
|
|
else if(BLI_rename(tempname, filepath) != 0) {
|
|
|
|
BKE_report(reports, RPT_ERROR, "Can't 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;
|
|
|
|
}
|
|
|
|
|
2004-09-05 13:43:51 +00:00
|
|
|
/* return: success (1) */
|
2010-10-16 02:40:31 +00:00
|
|
|
int BLO_write_file_mem(Main *mainvar, MemFile *compare, MemFile *current, int write_flags)
|
2004-09-05 13:43:51 +00:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
2010-05-24 21:52:18 +00:00
|
|
|
err= write_file_handle(mainvar, 0, compare, current, 0, write_flags, NULL);
|
2004-09-05 13:43:51 +00:00
|
|
|
|
|
|
|
if(err==0) return 1;
|
|
|
|
return 0;
|
|
|
|
}
|