This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/blenloader/intern/readfile.c

9320 lines
251 KiB
C
Raw Normal View History

/*
* ***** 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
* 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.
*
*
* Contributor(s): Blender Foundation
2002-10-12 11:37:38 +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/readfile.c
* \ingroup blenloader
*/
#include "zlib.h"
#include <limits.h>
2002-10-12 11:37:38 +00:00
#include <stdio.h> // for printf fopen fwrite fclose sprintf FILE
#include <stdlib.h> // for getenv atoi
#include <stddef.h> // for offsetof
2002-10-12 11:37:38 +00:00
#include <fcntl.h> // for open
#include <string.h> // for strrchr strncmp strstr
#include <math.h> // for fabs
#include <stdarg.h> /* for va_start/end */
2002-10-12 11:37:38 +00:00
#ifndef WIN32
# include <unistd.h> // for read close
2002-10-12 11:37:38 +00:00
#else
# include <io.h> // for open close read
# include "winsock2.h"
# include "BLI_winstuff.h"
2002-10-12 11:37:38 +00:00
#endif
/* allow readfile to use deprecated functionality */
#define DNA_DEPRECATED_ALLOW
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
2002-10-12 11:37:38 +00:00
#include "DNA_actuator_types.h"
#include "DNA_brush_types.h"
#include "DNA_camera_types.h"
#include "DNA_cloth_types.h"
2002-10-12 11:37:38 +00:00
#include "DNA_controller_types.h"
#include "DNA_constraint_types.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_effect_types.h"
#include "DNA_fileglobal_types.h"
#include "DNA_genfile.h"
#include "DNA_group_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_ipo_types.h"
2002-10-12 11:37:38 +00:00
#include "DNA_key_types.h"
#include "DNA_lattice_types.h"
2002-10-12 11:37:38 +00:00
#include "DNA_lamp_types.h"
#include "DNA_meta_types.h"
#include "DNA_material_types.h"
2002-10-12 11:37:38 +00:00
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_nla_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"
#include "DNA_object_fluidsim.h" // NT
#include "DNA_object_types.h"
#include "DNA_packedFile_types.h"
#include "DNA_particle_types.h"
#include "DNA_property_types.h"
2002-10-12 11:37:38 +00:00
#include "DNA_text_types.h"
#include "DNA_view3d_types.h"
#include "DNA_screen_types.h"
#include "DNA_sensor_types.h"
#include "DNA_sdna_types.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "DNA_smoke_types.h"
#include "DNA_speaker_types.h"
2002-10-12 11:37:38 +00:00
#include "DNA_sound_types.h"
#include "DNA_space_types.h"
#include "DNA_vfont_types.h"
#include "DNA_world_types.h"
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
#include "DNA_movieclip_types.h"
#include "DNA_mask_types.h"
2002-10-12 11:37:38 +00:00
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
2002-10-12 11:37:38 +00:00
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_edgehash.h"
2002-10-12 11:37:38 +00:00
#include "BKE_anim.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_action.h"
Result of 2 weeks of quiet coding work in Greece :) Aim was to get a total refresh of the animation system. This is needed because; - we need to upgrade it with 21st century features - current code is spaghetti/hack combo, and hides good design - it should become lag-free with using dependency graphs A full log, with complete code API/structure/design explanation will follow, that's a load of work... so here below the list with hot changes; - The entire object update system (matrices, geometry) is now centralized. Calls to where_is_object and makeDispList are forbidden, instead we tag objects 'changed' and let the depgraph code sort it out - Removed all old "Ika" code - Depgraph is aware of all relationships, including meta balls, constraints, bevelcurve, and so on. - Made depgraph aware of relation types and layers, to do smart flushing of 'changed' events. Nothing gets calculated too often! - Transform uses depgraph to detect changes - On frame-advance, depgraph flushes animated changes Armatures; Almost all armature related code has been fully built from scratch. It now reveils the original design much better, with a very clean implementation, lag free without even calculating each Bone more than once. Result is quite a speedup yes! Important to note is; 1) Armature is data containing the 'rest position' 2) Pose is the changes of rest position, and always on object level. That way more Objects can use same Pose. Also constraints are in Pose 3) Actions only contain the Ipos to change values in Poses. - Bones draw unrotated now - Drawing bones speedup enormously (10-20 times) - Bone selecting in EditMode, selection state is saved for PoseMode, and vice-versa - Undo in editmode - Bone renaming does vertexgroups, constraints, posechannels, actions, for all users of Armature in entire file - Added Bone renaming in NKey panel - Nkey PoseMode shows eulers now - EditMode and PoseMode now have 'active' bone too (last clicked) - Parenting in EditMode' CTRL+P, ALT+P, with nice options! - Pose is added in Outliner now, with showing that constraints are in the Pose, not Armature - Disconnected IK solving from constraints. It's a separate phase now, on top of the full Pose calculations - Pose itself has a dependency graph too, so evaluation order is lag free. TODO NOW; - Rotating in Posemode has incorrect inverse transform (Martin will fix) - Python Bone/Armature/Pose API disabled... needs full recode too (wait for my doc!) - Game engine will need upgrade too - Depgraph code needs revision, cleanup, can be much faster! (But, compliments for Jean-Luc, it works like a charm!) - IK changed, it now doesnt use previous position to advance to next position anymore. That system looks nice (no flips) but is not well suited for NLA and background render. TODO LATER; We now can do loadsa new nifty features as well; like: - Kill PoseMode (can be option for armatures itself) - Make B-Bones (Bezier, Bspline, like for spines) - Move all silly button level edit to 3d window (like CTRL+I = add IK) - Much better & informative drawing - Fix action/nla editors - Put all ipos in Actions (object, mesh key, lamp color) - Add hooks - Null bones - Much more advanced constraints... Bugfixes; - OGL render (view3d header) had wrong first frame on anim render - Ipo 'recording' mode had wrong playback speed - Vertex-key mode now sticks to show 'active key', until frame change -Ton-
2005-07-03 17:35:38 +00:00
#include "BKE_armature.h"
#include "BKE_brush.h"
* 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
#include "BKE_colortools.h"
2002-10-12 11:37:38 +00:00
#include "BKE_constraint.h"
2009-09-16 17:43:09 +00:00
#include "BKE_context.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"
#include "BKE_deform.h"
#include "BKE_effect.h"
#include "BKE_fcurve.h"
2002-10-12 11:37:38 +00:00
#include "BKE_global.h" // for G
#include "BKE_group.h"
#include "BKE_image.h"
#include "BKE_lattice.h"
#include "BKE_library.h" // for which_libbase
#include "BKE_idcode.h"
#include "BKE_material.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_main.h" // for Main
2002-10-12 11:37:38 +00:00
#include "BKE_mesh.h" // for ME_ defines (patching)
#include "BKE_modifier.h"
#include "BKE_multires.h"
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
#include "BKE_node.h" // for tree type defines
#include "BKE_ocean.h"
#include "BKE_object.h"
2009-09-16 17:43:09 +00:00
#include "BKE_paint.h"
#include "BKE_particle.h"
Point Cache Refactoring ======================= Caching and Baking: - The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates. - There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles. - The cloth autoprotect feature was removed. - The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries. - The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions. - PointCache struct was added to DNA and is automatically allocated for each physics type. - Soft body now supports Bake Editing just like cloth. - Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now. Library Linking: - Added some more warnings to prevent editing settings on library linked objects. - Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked. - Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh). Physics UI: - Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth. - Tweaked field panel buttons to not jump around when changing options. - Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable. - I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers. - Fixed modifier error drawing glitch. Particles: - Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() .. - Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading. - Make particle threads work with autothreads. Continue Physics: - The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache. - This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics. Todo: - Point cache can get out of sync with and undo and changing a file without saving it. - Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion. - Menu item and/or buttons for Ctrl+B. - A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested. - The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
#include "BKE_pointcache.h"
#include "BKE_property.h" // for get_ob_property
#include "BKE_report.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_sca.h" // for init_actuator
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_sequencer.h"
#include "BKE_text.h" // for txt_extended_ascii_as_utf8
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
#include "BKE_tracking.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_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND
#include "BKE_sound.h"
#include "IMB_imbuf.h" // for proxy / timecode versioning stuff
#include "NOD_socket.h"
2002-10-12 11:37:38 +00:00
#include "BLO_readfile.h"
#include "BLO_undofile.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 "RE_engine.h"
2002-10-12 11:37:38 +00:00
#include "readfile.h"
#include "PIL_time.h"
2002-10-12 11:37:38 +00:00
#include <errno.h>
2002-10-12 11:37:38 +00:00
/*
Remark: still a weak point is the newaddress() function, that doesnt solve reading from
multiple files at the same time
(added remark: oh, i thought that was solved? will look at that... (ton)
READ
- Existing Library (Main) push or free
- allocate new Main
2002-10-12 11:37:38 +00:00
- load file
- read SDNA
- for each LibBlock
- read LibBlock
- if a Library
2002-10-12 11:37:38 +00:00
- make a new Main
- attach ID's to it
- else
- read associated 'direct data'
- link direct data (internal and to LibBlock)
- read FileGlobal
- read USER data, only when indicated (file is ~/X.XX/startup.blend)
- free file
- per Library (per Main)
- read file
- read SDNA
- find LibBlocks and attach IDs to Main
- if external LibBlock
- search all Main's
- or it's already read,
- or not read yet
- or make new Main
2002-10-12 11:37:38 +00:00
- per LibBlock
- read recursive
- read associated direct data
- link direct data (internal and to LibBlock)
- free file
- per Library with unread LibBlocks
- read file
- read SDNA
2002-10-12 11:37:38 +00:00
- per LibBlock
- read recursive
- read associated direct data
- link direct data (internal and to LibBlock)
- free file
- join all Mains
- link all LibBlocks and indirect pointers to libblocks
- initialize FileGlobal and copy pointers to Global
2002-10-12 11:37:38 +00:00
*/
/* also occurs in library.c */
/* GS reads the memory pointed at in a specific ordering. There are,
* however two definitions for it. I have jotted them down here, both,
* but I think the first one is actually used. The thing is that
* big-endian systems might read this the wrong way round. OTOH, we
* constructed the IDs that are read out with this macro explicitly as
* well. I expect we'll sort it out soon... */
/* from blendef: */
#define GS(a) (*((short *)(a)))
/* from misc_util: flip the bytes from x */
/* #define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1]) */
// only used here in readfile.c
#define SWITCH_LONGINT(a) { \
char s_i, *p_i; \
p_i= (char *)&(a); \
s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \
s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \
s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \
s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; \
} (void)0
2002-10-12 11:37:38 +00:00
/***/
typedef struct OldNew {
void *old, *newp;
int nr;
} OldNew;
typedef struct OldNewMap {
OldNew *entries;
int nentries, entriessize;
int sorted;
2002-10-12 11:37:38 +00:00
int lasthit;
} OldNewMap;
/* local prototypes */
static void *read_struct(FileData *fd, BHead *bh, const char *blockname);
static void direct_link_modifiers(FileData *fd, ListBase *lb);
TexFace to Material Settings big patch Summary: ======== The idea here is to move the texface options into the material panel. For images with the change please visit: http://code.blender.org/index.php/2011/09/bge-material-texface-changes 1 - Some of the legacy problems 2.49 and 2.5x has with the texface system: ========================================================================== 1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can select a face to be more than one mode. 1.2) Sort only works for blend Alpha yet it's an option regardless of the Transparency Blend you pick. 1.3) Shared doesn't affect anything in BGE. 1.4) ObColor only works for Text objects (old bitmap texts) when using Texture Face Materials. (not address yet, I so far ignored obcolor) 2 - Notes: ============ 2.1) Now "Use Face Textures" in material Option panel will work in Multitexture even if there is no texture channel. 2.2) In FaceTexture mode it will use TexFace all the time, even if you don't check the "Use Texture Face" option in the UI. It's a matter of decision, since the code for either way is there. I decided by the solution that makes the creation of a material fast - in this mode the user doesn't need to mess with textures or this "Use Texture Face" option at all. I'm not strong in my opinion here. But I think if we don't have this then what is the point of the Texture Face mode? 2.3) I kept references for tface only when we need the image, UV or the tiling setting. It should help later when/if we split the Image and UV layers from the tface struct (Campbell and Brecht proposal). 3 - Changes in a Nutshell: ========================== 3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set. 3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …). 3.3) New options in the Material Panel * Shadeless option in the Material panel is now supported for all three Shading modes. * Physics is now toggleable, this is the old Collision option. * Two Side (on) is now called Back Culling (off). * Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid). * Shadow, Billboard and Halo are grouped in the “Face Orientation” property. * "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually). * The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties. 4 - Acknowledgment: ================== Mike Pan for the design discussions, and testing along the whole development process. Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that. Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems). Blender artists that gave feedback and helped testing the patch. Patch review and original documentation can be found here: http://wiki.blender.org/index.php/User:Dfelinto/TexFace http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
static void convert_tface_mt(FileData *fd, Main *main);
/* this function ensures that reports are printed,
* in the case of libraray linking errors this is important!
*
* bit kludge but better then doubling up on prints,
* we could alternatively have a versions of a report function which foces printing - campbell
*/
static void BKE_reportf_wrap(ReportList *reports, ReportType type, const char *format, ...)
{
char fixed_buf[1024]; /* should be long enough */
va_list args;
va_start(args, format);
vsnprintf(fixed_buf, sizeof(fixed_buf), format, args);
va_end(args);
fixed_buf[sizeof(fixed_buf) - 1] = '\0';
BKE_report(reports, type, fixed_buf);
if (G.background == 0) {
printf("%s\n", fixed_buf);
}
}
static OldNewMap *oldnewmap_new(void)
{
OldNewMap *onm= MEM_callocN(sizeof(*onm), "OldNewMap");
onm->entriessize = 1024;
onm->entries = MEM_mallocN(sizeof(*onm->entries)*onm->entriessize, "OldNewMap.entries");
2002-10-12 11:37:38 +00:00
return onm;
}
static int verg_oldnewmap(const void *v1, const void *v2)
{
const struct OldNew *x1=v1, *x2=v2;
if (x1->old > x2->old) return 1;
else if (x1->old < x2->old) return -1;
return 0;
}
static void oldnewmap_sort(FileData *fd)
{
qsort(fd->libmap->entries, fd->libmap->nentries, sizeof(OldNew), verg_oldnewmap);
fd->libmap->sorted = 1;
}
/* nr is zero for data, and ID code for libdata */
static void oldnewmap_insert(OldNewMap *onm, void *oldaddr, void *newaddr, int nr)
{
2002-10-12 11:37:38 +00:00
OldNew *entry;
if (oldaddr==NULL || newaddr==NULL) return;
if (onm->nentries == onm->entriessize) {
int osize = onm->entriessize;
OldNew *oentries = onm->entries;
onm->entriessize *= 2;
onm->entries = MEM_mallocN(sizeof(*onm->entries)*onm->entriessize, "OldNewMap.entries");
2002-10-12 11:37:38 +00:00
memcpy(onm->entries, oentries, sizeof(*oentries)*osize);
MEM_freeN(oentries);
}
entry = &onm->entries[onm->nentries++];
entry->old = oldaddr;
entry->newp = newaddr;
entry->nr = nr;
2002-10-12 11:37:38 +00:00
}
void blo_do_versions_oldnewmap_insert(OldNewMap *onm, void *oldaddr, void *newaddr, int nr)
{
oldnewmap_insert(onm, oldaddr, newaddr, nr);
}
static void *oldnewmap_lookup_and_inc(OldNewMap *onm, void *addr)
{
2002-10-12 11:37:38 +00:00
int i;
if (addr == NULL) return NULL;
if (onm->lasthit < onm->nentries-1) {
OldNew *entry = &onm->entries[++onm->lasthit];
if (entry->old == addr) {
2002-10-12 11:37:38 +00:00
entry->nr++;
return entry->newp;
}
}
for (i = 0; i < onm->nentries; i++) {
OldNew *entry = &onm->entries[i];
if (entry->old == addr) {
onm->lasthit = i;
2002-10-12 11:37:38 +00:00
entry->nr++;
return entry->newp;
}
}
2002-10-12 11:37:38 +00:00
return NULL;
}
/* for libdata, nr has ID code, no increment */
static void *oldnewmap_liblookup(OldNewMap *onm, void *addr, void *lib)
{
2002-10-12 11:37:38 +00:00
int i;
if (addr == NULL) return NULL;
/* lasthit works fine for non-libdata, linking there is done in same sequence as writing */
if (onm->sorted) {
OldNew entry_s, *entry;
entry_s.old = addr;
entry = bsearch(&entry_s, onm->entries, onm->nentries, sizeof(OldNew), verg_oldnewmap);
if (entry) {
ID *id = entry->newp;
2002-10-12 11:37:38 +00:00
if (id && (!lib || id->lib)) {
return entry->newp;
}
}
}
for (i = 0; i < onm->nentries; i++) {
OldNew *entry = &onm->entries[i];
if (entry->old == addr) {
ID *id = entry->newp;
2002-10-12 11:37:38 +00:00
if (id && (!lib || id->lib)) {
return entry->newp;
}
}
}
return NULL;
}
static void oldnewmap_free_unused(OldNewMap *onm)
{
2002-10-12 11:37:38 +00:00
int i;
for (i = 0; i < onm->nentries; i++) {
OldNew *entry = &onm->entries[i];
if (entry->nr == 0) {
2002-10-12 11:37:38 +00:00
MEM_freeN(entry->newp);
entry->newp = NULL;
2002-10-12 11:37:38 +00:00
}
}
}
static void oldnewmap_clear(OldNewMap *onm)
{
onm->nentries = 0;
onm->lasthit = 0;
2002-10-12 11:37:38 +00:00
}
static void oldnewmap_free(OldNewMap *onm)
{
2002-10-12 11:37:38 +00:00
MEM_freeN(onm->entries);
MEM_freeN(onm);
}
/***/
static void read_libraries(FileData *basefd, ListBase *mainlist);
/* ************ help functions ***************** */
2002-10-12 11:37:38 +00:00
static void add_main_to_main(Main *mainvar, Main *from)
{
ListBase *lbarray[MAX_LIBARRAY], *fromarray[MAX_LIBARRAY];
2002-10-12 11:37:38 +00:00
int a;
set_listbasepointers(mainvar, lbarray);
a = set_listbasepointers(from, fromarray);
while (a--) {
BLI_movelisttolist(lbarray[a], fromarray[a]);
2002-10-12 11:37:38 +00:00
}
}
void blo_join_main(ListBase *mainlist)
{
Main *tojoin, *mainl;
mainl = mainlist->first;
while ((tojoin = mainl->next)) {
add_main_to_main(mainl, tojoin);
2002-10-12 11:37:38 +00:00
BLI_remlink(mainlist, tojoin);
MEM_freeN(tojoin);
}
2002-10-12 11:37:38 +00:00
}
static void split_libdata(ListBase *lb, Main *first)
{
ListBase *lbn;
ID *id, *idnext;
Main *mainvar;
id = lb->first;
while (id) {
idnext = id->next;
if (id->lib) {
mainvar = first;
while (mainvar) {
if (mainvar->curlib == id->lib) {
lbn= which_libbase(mainvar, GS(id->name));
2002-10-12 11:37:38 +00:00
BLI_remlink(lb, id);
BLI_addtail(lbn, id);
break;
}
mainvar = mainvar->next;
2002-10-12 11:37:38 +00:00
}
if (mainvar == NULL) printf("error split_libdata\n");
2002-10-12 11:37:38 +00:00
}
id = idnext;
2002-10-12 11:37:38 +00:00
}
}
void blo_split_main(ListBase *mainlist, Main *main)
2002-10-12 11:37:38 +00:00
{
ListBase *lbarray[MAX_LIBARRAY];
2002-10-12 11:37:38 +00:00
Library *lib;
int i;
mainlist->first = mainlist->last = main;
main->next = NULL;
if (main->library.first == NULL)
return;
for (lib = main->library.first; lib; lib = lib->id.next) {
Main *libmain = MEM_callocN(sizeof(Main), "libmain");
libmain->curlib = lib;
2002-10-12 11:37:38 +00:00
BLI_addtail(mainlist, libmain);
}
i = set_listbasepointers(main, lbarray);
while (i--)
split_libdata(lbarray[i], main->next);
2002-10-12 11:37:38 +00:00
}
/* removes things like /blah/blah/../../blah/ etc, then writes in *name the full path */
static void cleanup_path(const char *relabase, char *name)
{
char filename[FILE_MAXFILE];
BLI_splitdirstring(name, filename);
BLI_cleanup_dir(relabase, name);
strcat(name, filename);
}
static void read_file_version(FileData *fd, Main *main)
{
BHead *bhead;
for (bhead= blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) {
if (bhead->code == GLOB) {
FileGlobal *fg= read_struct(fd, bhead, "Global");
if (fg) {
main->subversionfile= fg->subversion;
main->minversionfile= fg->minversion;
main->minsubversionfile= fg->minsubversion;
MEM_freeN(fg);
}
else if (bhead->code == ENDB)
break;
}
}
}
static Main *blo_find_main(FileData *fd, const char *filepath, const char *relabase)
2002-10-12 11:37:38 +00:00
{
ListBase *mainlist = fd->mainlist;
2002-10-12 11:37:38 +00:00
Main *m;
Library *lib;
char name1[FILE_MAX];
BLI_strncpy(name1, filepath, sizeof(name1));
cleanup_path(relabase, name1);
// printf("blo_find_main: original in %s\n", name);
// printf("blo_find_main: converted to %s\n", name1);
for (m = mainlist->first; m; m = m->next) {
char *libname = (m->curlib) ? m->curlib->filepath : m->name;
if (BLI_path_cmp(name1, libname) == 0) {
if (G.debug & G_DEBUG) printf("blo_find_main: found library %s\n", libname);
2002-10-12 11:37:38 +00:00
return m;
}
2002-10-12 11:37:38 +00:00
}
m = MEM_callocN(sizeof(Main), "find_main");
2002-10-12 11:37:38 +00:00
BLI_addtail(mainlist, m);
lib = BKE_libblock_alloc(&m->library, ID_LI, "lib");
BLI_strncpy(lib->name, filepath, sizeof(lib->name));
BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath));
m->curlib = lib;
read_file_version(fd, m);
if (G.debug & G_DEBUG) printf("blo_find_main: added new lib %s\n", filepath);
2002-10-12 11:37:38 +00:00
return m;
}
/* ************ FILE PARSING ****************** */
static void switch_endian_bh4(BHead4 *bhead)
{
/* the ID_.. codes */
if ((bhead->code & 0xFFFF)==0) bhead->code >>= 16;
2002-10-12 11:37:38 +00:00
if (bhead->code != ENDB) {
SWITCH_INT(bhead->len);
SWITCH_INT(bhead->SDNAnr);
SWITCH_INT(bhead->nr);
}
}
static void switch_endian_bh8(BHead8 *bhead)
{
/* the ID_.. codes */
if ((bhead->code & 0xFFFF)==0) bhead->code >>= 16;
2002-10-12 11:37:38 +00:00
if (bhead->code != ENDB) {
SWITCH_INT(bhead->len);
SWITCH_INT(bhead->SDNAnr);
SWITCH_INT(bhead->nr);
}
}
static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, int do_endian_swap)
{
BHead4 *bhead4 = (BHead4 *) bhead;
#if defined(WIN32) && !defined(FREE_WINDOWS)
2002-10-12 11:37:38 +00:00
__int64 old;
#else
long long old;
#endif
bhead4->code = bhead8->code;
bhead4->len = bhead8->len;
2002-10-12 11:37:38 +00:00
if (bhead4->code != ENDB) {
/* perform a endian swap on 64bit pointers, otherwise the pointer might map to zero
* 0x0000000000000000000012345678 would become 0x12345678000000000000000000000000
*/
2002-10-12 11:37:38 +00:00
if (do_endian_swap) {
SWITCH_LONGINT(bhead8->old);
}
2002-10-12 11:37:38 +00:00
/* this patch is to avoid a long long being read from not-eight aligned positions
2012-04-22 11:54:53 +00:00
* is necessary on any modern 64bit architecture) */
2002-10-12 11:37:38 +00:00
memcpy(&old, &bhead8->old, 8);
bhead4->old = (int) (old >> 3);
bhead4->SDNAnr = bhead8->SDNAnr;
bhead4->nr = bhead8->nr;
2002-10-12 11:37:38 +00:00
}
}
static void bh8_from_bh4(BHead *bhead, BHead4 *bhead4)
{
BHead8 *bhead8 = (BHead8 *) bhead;
bhead8->code = bhead4->code;
bhead8->len = bhead4->len;
if (bhead8->code != ENDB) {
bhead8->old = bhead4->old;
bhead8->SDNAnr = bhead4->SDNAnr;
2002-10-12 11:37:38 +00:00
bhead8->nr= bhead4->nr;
}
}
static BHeadN *get_bhead(FileData *fd)
{
BHeadN *new_bhead = NULL;
2002-10-12 11:37:38 +00:00
int readsize;
2002-10-12 11:37:38 +00:00
if (fd) {
if (!fd->eof) {
/* initializing to zero isn't strictly needed but shuts valgrind up
* since uninitialized memory gets compared */
BHead8 bhead8 = {0};
BHead4 bhead4 = {0};
BHead bhead = {0};
/* First read the bhead structure.
* Depending on the platform the file was written on this can
* be a big or little endian BHead4 or BHead8 structure.
*
* As usual 'ENDB' (the last *partial* bhead of the file)
* needs some special handling. We don't want to EOF just yet.
*/
2002-10-12 11:37:38 +00:00
if (fd->flags & FD_FLAGS_FILE_POINTSIZE_IS_4) {
bhead4.code = DATA;
readsize = fd->read(fd, &bhead4, sizeof(bhead4));
if (readsize == sizeof(bhead4) || bhead4.code == ENDB) {
2002-10-12 11:37:38 +00:00
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
switch_endian_bh4(&bhead4);
}
2002-10-12 11:37:38 +00:00
if (fd->flags & FD_FLAGS_POINTSIZE_DIFFERS) {
bh8_from_bh4(&bhead, &bhead4);
}
else {
2002-10-12 11:37:38 +00:00
memcpy(&bhead, &bhead4, sizeof(bhead));
}
}
else {
2002-10-12 11:37:38 +00:00
fd->eof = 1;
bhead.len= 0;
2002-10-12 11:37:38 +00:00
}
}
else {
2002-10-12 11:37:38 +00:00
bhead8.code = DATA;
readsize = fd->read(fd, &bhead8, sizeof(bhead8));
2002-10-12 11:37:38 +00:00
if (readsize == sizeof(bhead8) || bhead8.code == ENDB) {
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
switch_endian_bh8(&bhead8);
}
2002-10-12 11:37:38 +00:00
if (fd->flags & FD_FLAGS_POINTSIZE_DIFFERS) {
bh4_from_bh8(&bhead, &bhead8, (fd->flags & FD_FLAGS_SWITCH_ENDIAN));
}
else {
2002-10-12 11:37:38 +00:00
memcpy(&bhead, &bhead8, sizeof(bhead));
}
}
else {
2002-10-12 11:37:38 +00:00
fd->eof = 1;
bhead.len= 0;
2002-10-12 11:37:38 +00:00
}
}
/* make sure people are not trying to pass bad blend files */
if (bhead.len < 0) fd->eof = 1;
/* bhead now contains the (converted) bhead structure. Now read
* the associated data and put everything in a BHeadN (creative naming !)
*/
if (!fd->eof) {
2002-10-12 11:37:38 +00:00
new_bhead = MEM_mallocN(sizeof(BHeadN) + bhead.len, "new_bhead");
if (new_bhead) {
new_bhead->next = new_bhead->prev = NULL;
2002-10-12 11:37:38 +00:00
new_bhead->bhead = bhead;
2002-10-12 11:37:38 +00:00
readsize = fd->read(fd, new_bhead + 1, bhead.len);
2002-10-12 11:37:38 +00:00
if (readsize != bhead.len) {
fd->eof = 1;
MEM_freeN(new_bhead);
new_bhead = NULL;
2002-10-12 11:37:38 +00:00
}
}
else {
2002-10-12 11:37:38 +00:00
fd->eof = 1;
}
}
}
}
/* We've read a new block. Now add it to the list
* of blocks.
*/
2002-10-12 11:37:38 +00:00
if (new_bhead) {
BLI_addtail(&fd->listbase, new_bhead);
}
2002-10-12 11:37:38 +00:00
return(new_bhead);
}
BHead *blo_firstbhead(FileData *fd)
{
BHeadN *new_bhead;
BHead *bhead = NULL;
/* Rewind the file
* Read in a new block if necessary
*/
2002-10-12 11:37:38 +00:00
new_bhead = fd->listbase.first;
if (new_bhead == NULL) {
2002-10-12 11:37:38 +00:00
new_bhead = get_bhead(fd);
}
2002-10-12 11:37:38 +00:00
if (new_bhead) {
bhead = &new_bhead->bhead;
}
2002-10-12 11:37:38 +00:00
return(bhead);
}
BHead *blo_prevbhead(FileData *UNUSED(fd), BHead *thisblock)
2002-10-12 11:37:38 +00:00
{
BHeadN *bheadn = (BHeadN *) (((char *) thisblock) - GET_INT_FROM_POINTER( &((BHeadN*)0)->bhead) );
BHeadN *prev = bheadn->prev;
return (prev) ? &prev->bhead : NULL;
2002-10-12 11:37:38 +00:00
}
BHead *blo_nextbhead(FileData *fd, BHead *thisblock)
{
BHeadN *new_bhead = NULL;
BHead *bhead = NULL;
2002-10-12 11:37:38 +00:00
if (thisblock) {
// bhead is actually a sub part of BHeadN
// We calculate the BHeadN pointer from the BHead pointer below
2008-04-29 08:24:33 +00:00
new_bhead = (BHeadN *) (((char *) thisblock) - GET_INT_FROM_POINTER( &((BHeadN*)0)->bhead) );
2002-10-12 11:37:38 +00:00
// get the next BHeadN. If it doesn't exist we read in the next one
new_bhead = new_bhead->next;
if (new_bhead == NULL) {
2002-10-12 11:37:38 +00:00
new_bhead = get_bhead(fd);
}
}
2002-10-12 11:37:38 +00:00
if (new_bhead) {
// here we do the reverse:
// go from the BHeadN pointer to the BHead pointer
bhead = &new_bhead->bhead;
}
2002-10-12 11:37:38 +00:00
return(bhead);
}
static void decode_blender_header(FileData *fd)
{
char header[SIZEOFBLENDERHEADER], num[4];
int readsize;
/* read in the header data */
2002-10-12 11:37:38 +00:00
readsize = fd->read(fd, header, sizeof(header));
2002-10-12 11:37:38 +00:00
if (readsize == sizeof(header)) {
if (strncmp(header, "BLENDER", 7) == 0) {
int remove_this_endian_test = 1;
2002-10-12 11:37:38 +00:00
fd->flags |= FD_FLAGS_FILE_OK;
/* what size are pointers in the file ? */
if (header[7]=='_') {
2002-10-12 11:37:38 +00:00
fd->flags |= FD_FLAGS_FILE_POINTSIZE_IS_4;
if (sizeof(void *) != 4) {
fd->flags |= FD_FLAGS_POINTSIZE_DIFFERS;
}
}
else {
2002-10-12 11:37:38 +00:00
if (sizeof(void *) != 8) {
fd->flags |= FD_FLAGS_POINTSIZE_DIFFERS;
}
}
/* is the file saved in a different endian
* than we need ?
*/
2002-10-12 11:37:38 +00:00
if (((((char*)&remove_this_endian_test)[0]==1)?L_ENDIAN:B_ENDIAN) != ((header[8]=='v')?L_ENDIAN:B_ENDIAN)) {
fd->flags |= FD_FLAGS_SWITCH_ENDIAN;
}
/* get the version number */
memcpy(num, header + 9, 3);
2002-10-12 11:37:38 +00:00
num[3] = 0;
fd->fileversion = atoi(num);
}
}
}
static int read_file_dna(FileData *fd)
{
BHead *bhead;
for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) {
if (bhead->code == DNA1) {
int do_endian_swap = (fd->flags & FD_FLAGS_SWITCH_ENDIAN) ? 1 : 0;
fd->filesdna = DNA_sdna_from_data(&bhead[1], bhead->len, do_endian_swap);
if (fd->filesdna) {
fd->compflags = DNA_struct_get_compareflags(fd->filesdna, fd->memsdna);
/* used to retrieve ID names from (bhead+1) */
fd->id_name_offs = DNA_elem_offset(fd->filesdna, "ID", "char", "name[]");
}
2002-10-12 11:37:38 +00:00
return 1;
}
else if (bhead->code == ENDB)
2002-10-12 11:37:38 +00:00
break;
}
2002-10-12 11:37:38 +00:00
return 0;
}
static int fd_read_from_file(FileData *filedata, void *buffer, unsigned int size)
2002-10-12 11:37:38 +00:00
{
int readsize = read(filedata->filedes, buffer, size);
2002-10-12 11:37:38 +00:00
if (readsize < 0) {
readsize = EOF;
}
else {
2002-10-12 11:37:38 +00:00
filedata->seek += readsize;
}
return readsize;
2002-10-12 11:37:38 +00:00
}
static int fd_read_gzip_from_file(FileData *filedata, void *buffer, unsigned int size)
{
int readsize = gzread(filedata->gzfiledes, buffer, size);
if (readsize < 0) {
readsize = EOF;
}
else {
filedata->seek += readsize;
}
return (readsize);
}
static int fd_read_from_memory(FileData *filedata, void *buffer, unsigned int size)
2002-10-12 11:37:38 +00:00
{
/* don't read more bytes then there are available in the buffer */
int readsize = (int)MIN2(size, (unsigned int)(filedata->buffersize - filedata->seek));
2002-10-12 11:37:38 +00:00
memcpy(buffer, filedata->buffer + filedata->seek, readsize);
filedata->seek += readsize;
2002-10-12 11:37:38 +00:00
return (readsize);
}
2009-01-02 06:03:53 +00:00
static int fd_read_from_memfile(FileData *filedata, void *buffer, unsigned int size)
{
static unsigned int seek = (1<<30); /* the current position */
static unsigned int offset = 0; /* size of previous chunks */
static MemFileChunk *chunk = NULL;
unsigned int chunkoffset, readsize, totread;
if (size == 0) return 0;
if (seek != (unsigned int)filedata->seek) {
chunk = filedata->memfile->chunks.first;
seek = 0;
while (chunk) {
if (seek + chunk->size > (unsigned) filedata->seek) break;
seek += chunk->size;
chunk = chunk->next;
}
offset = seek;
seek = filedata->seek;
}
if (chunk) {
totread = 0;
do {
/* first check if it's on the end if current chunk */
if (seek-offset == chunk->size) {
offset += chunk->size;
chunk = chunk->next;
}
/* debug, should never happen */
if (chunk == NULL) {
printf("illegal read, chunk zero\n");
return 0;
}
chunkoffset = seek-offset;
readsize = size-totread;
/* data can be spread over multiple chunks, so clamp size
* to within this chunk, and then it will read further in
* the next chunk */
if (chunkoffset+readsize > chunk->size)
readsize= chunk->size-chunkoffset;
memcpy((char*)buffer + totread, chunk->buf + chunkoffset, readsize);
totread += readsize;
filedata->seek += readsize;
seek += readsize;
} while (totread < size);
return totread;
}
return 0;
}
2002-10-12 11:37:38 +00:00
static FileData *filedata_new(void)
{
FileData *fd = MEM_callocN(sizeof(FileData), "FileData");
fd->filedes = -1;
fd->gzfiledes = NULL;
2002-10-12 11:37:38 +00:00
/* XXX, this doesn't need to be done all the time,
* but it keeps us re-entrant, remove once we have
2002-10-12 11:37:38 +00:00
* a lib that provides a nice lock. - zr
*/
fd->memsdna = DNA_sdna_from_data(DNAstr, DNAlen, 0);
2002-10-12 11:37:38 +00:00
fd->datamap = oldnewmap_new();
fd->globmap = oldnewmap_new();
fd->libmap = oldnewmap_new();
2002-10-12 11:37:38 +00:00
return fd;
}
static FileData *blo_decode_and_check(FileData *fd, ReportList *reports)
{
decode_blender_header(fd);
if (fd->flags & FD_FLAGS_FILE_OK) {
if (!read_file_dna(fd)) {
BKE_reportf(reports, RPT_ERROR, "Failed to read blend file: \"%s\", incomplete", fd->relabase);
blo_freefiledata(fd);
fd = NULL;
}
}
else {
BKE_reportf(reports, RPT_ERROR, "Failed to read blend file: \"%s\", not a blend file", fd->relabase);
blo_freefiledata(fd);
fd = NULL;
}
return fd;
}
/* cannot be called with relative paths anymore! */
/* on each new library added, it now checks for the current FileData and expands relativeness */
FileData *blo_openblenderfile(const char *filepath, ReportList *reports)
2002-10-12 11:37:38 +00:00
{
gzFile gzfile;
errno = 0;
gzfile = BLI_gzopen(filepath, "rb");
if (gzfile == (gzFile)Z_NULL) {
BKE_reportf(reports, RPT_ERROR, "Unable to open \"%s\": %s.", filepath, errno ? strerror(errno) : "Unknown error reading file");
2002-10-12 11:37:38 +00:00
return NULL;
}
else {
2002-10-12 11:37:38 +00:00
FileData *fd = filedata_new();
fd->gzfiledes = gzfile;
fd->read = fd_read_gzip_from_file;
/* needed for library_append and read_libraries */
BLI_strncpy(fd->relabase, filepath, sizeof(fd->relabase));
return blo_decode_and_check(fd, reports);
2002-10-12 11:37:38 +00:00
}
}
FileData *blo_openblendermemory(void *mem, int memsize, ReportList *reports)
2002-10-12 11:37:38 +00:00
{
if (!mem || memsize<SIZEOFBLENDERHEADER) {
BKE_report(reports, RPT_ERROR, (mem)? "Unable to read": "Unable to open");
2002-10-12 11:37:38 +00:00
return NULL;
}
else {
FileData *fd = filedata_new();
fd->buffer = mem;
fd->buffersize = memsize;
fd->read = fd_read_from_memory;
fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
return blo_decode_and_check(fd, reports);
2002-10-12 11:37:38 +00:00
}
}
FileData *blo_openblendermemfile(MemFile *memfile, ReportList *reports)
{
if (!memfile) {
BKE_report(reports, RPT_ERROR, "Unable to open blend <memory>");
return NULL;
}
else {
FileData *fd = filedata_new();
fd->memfile = memfile;
fd->read = fd_read_from_memfile;
fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
return blo_decode_and_check(fd, reports);
}
}
2002-10-12 11:37:38 +00:00
void blo_freefiledata(FileData *fd)
{
if (fd) {
if (fd->filedes != -1) {
close(fd->filedes);
}
if (fd->gzfiledes != NULL) {
gzclose(fd->gzfiledes);
}
2002-10-12 11:37:38 +00:00
if (fd->buffer && !(fd->flags & FD_FLAGS_NOT_MY_BUFFER)) {
MEM_freeN(fd->buffer);
fd->buffer = NULL;
2002-10-12 11:37:38 +00:00
}
2002-10-12 11:37:38 +00:00
// Free all BHeadN data blocks
BLI_freelistN(&fd->listbase);
2002-10-12 11:37:38 +00:00
if (fd->memsdna)
DNA_sdna_free(fd->memsdna);
2002-10-12 11:37:38 +00:00
if (fd->filesdna)
DNA_sdna_free(fd->filesdna);
2002-10-12 11:37:38 +00:00
if (fd->compflags)
MEM_freeN(fd->compflags);
2002-10-12 11:37:38 +00:00
if (fd->datamap)
oldnewmap_free(fd->datamap);
if (fd->globmap)
oldnewmap_free(fd->globmap);
if (fd->imamap)
oldnewmap_free(fd->imamap);
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
if (fd->movieclipmap)
oldnewmap_free(fd->movieclipmap);
2002-10-12 11:37:38 +00:00
if (fd->libmap && !(fd->flags & FD_FLAGS_NOT_MY_LIBMAP))
oldnewmap_free(fd->libmap);
if (fd->bheadmap)
MEM_freeN(fd->bheadmap);
2002-10-12 11:37:38 +00:00
MEM_freeN(fd);
}
}
/* ************ DIV ****************** */
int BLO_has_bfile_extension(const char *str)
2002-10-12 11:37:38 +00:00
{
return (BLI_testextensie(str, ".ble") ||
BLI_testextensie(str, ".blend") ||
BLI_testextensie(str, ".blend.gz"));
2002-10-12 11:37:38 +00:00
}
2010-03-20 16:56:52 +00:00
int BLO_is_a_library(const char *path, char *dir, char *group)
2009-09-16 17:43:09 +00:00
{
/* return ok when a blenderfile, in dir is the filename,
* in group the type of libdata
*/
int len;
char *fd;
strcpy(dir, path);
len = strlen(dir);
if (len < 7) return 0;
if ((dir[len - 1] != '/') && (dir[len - 1] != '\\')) return 0;
2009-09-16 17:43:09 +00:00
group[0] = '\0';
dir[len - 1] = '\0';
2009-09-16 17:43:09 +00:00
/* Find the last slash */
fd = BLI_last_slash(dir);
2009-09-16 17:43:09 +00:00
if (fd == NULL) return 0;
*fd = 0;
if (BLO_has_bfile_extension(fd+1)) {
2009-09-16 17:43:09 +00:00
/* the last part of the dir is a .blend file, no group follows */
*fd = '/'; /* put back the removed slash separating the dir and the .blend file name */
2009-09-16 17:43:09 +00:00
}
else {
char *gp = fd + 1; // in case we have a .blend file, gp points to the group
2009-09-16 17:43:09 +00:00
/* Find the last slash */
fd = BLI_last_slash(dir);
2009-09-16 17:43:09 +00:00
if (!fd || !BLO_has_bfile_extension(fd+1)) return 0;
2009-09-16 17:43:09 +00:00
/* now we know that we are in a blend file and it is safe to
2012-04-22 11:54:53 +00:00
* assume that gp actually points to a group */
if (strcmp("Screen", gp) != 0)
2009-09-16 17:43:09 +00:00
BLI_strncpy(group, gp, GROUP_MAX);
}
return 1;
}
2002-10-12 11:37:38 +00:00
/* ************** OLD POINTERS ******************* */
static void *newdataadr(FileData *fd, void *adr) /* only direct databocks */
{
return oldnewmap_lookup_and_inc(fd->datamap, adr);
}
static void *newglobadr(FileData *fd, void *adr) /* direct datablocks with global linking */
{
return oldnewmap_lookup_and_inc(fd->globmap, adr);
}
static void *newimaadr(FileData *fd, void *adr) /* used to restore image data after undo */
{
if (fd->imamap && adr)
return oldnewmap_lookup_and_inc(fd->imamap, adr);
return NULL;
}
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
static void *newmclipadr(FileData *fd, void *adr) /* used to restore movie clip data after undo */
{
if (fd->movieclipmap && adr)
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
return oldnewmap_lookup_and_inc(fd->movieclipmap, adr);
return NULL;
}
2002-10-12 11:37:38 +00:00
static void *newlibadr(FileData *fd, void *lib, void *adr) /* only lib data */
{
return oldnewmap_liblookup(fd->libmap, adr, lib);
2002-10-12 11:37:38 +00:00
}
void *blo_do_versions_newlibadr(FileData *fd, void *lib, void *adr) /* only lib data */
{
return newlibadr(fd, lib, adr);
}
static void *newlibadr_us(FileData *fd, void *lib, void *adr) /* increases user number */
2002-10-12 11:37:38 +00:00
{
ID *id = newlibadr(fd, lib, adr);
if (id)
2002-10-12 11:37:38 +00:00
id->us++;
2002-10-12 11:37:38 +00:00
return id;
}
void *blo_do_versions_newlibadr_us(FileData *fd, void *lib, void *adr) /* increases user number */
{
return newlibadr_us(fd, lib, adr);
}
static void change_idid_adr_fd(FileData *fd, void *old, void *new)
2002-10-12 11:37:38 +00:00
{
int i;
for (i = 0; i < fd->libmap->nentries; i++) {
OldNew *entry = &fd->libmap->entries[i];
if (old==entry->newp && entry->nr==ID_ID) {
entry->newp = new;
if (new) entry->nr = GS( ((ID *)new)->name );
2002-10-12 11:37:38 +00:00
}
}
}
static void change_idid_adr(ListBase *mainlist, FileData *basefd, void *old, void *new)
{
Main *mainptr;
for (mainptr = mainlist->first; mainptr; mainptr = mainptr->next) {
FileData *fd;
if (mainptr->curlib)
fd = mainptr->curlib->filedata;
else
fd = basefd;
if (fd) {
change_idid_adr_fd(fd, old, new);
}
}
}
2002-10-12 11:37:38 +00:00
/* lib linked proxy objects point to our local data, we need
* to clear that pointer before reading the undo memfile since
* the object might be removed, it is set again in reading
* if the local object still exists */
void blo_clear_proxy_pointers_from_lib(Main *oldmain)
{
Object *ob = oldmain->object.first;
for (; ob; ob= ob->id.next) {
if (ob->id.lib)
ob->proxy_from = NULL;
}
}
void blo_make_image_pointer_map(FileData *fd, Main *oldmain)
{
Image *ima = oldmain->image.first;
Scene *sce = oldmain->scene.first;
int a;
fd->imamap = oldnewmap_new();
for (; ima; ima = ima->id.next) {
Link *ibuf = ima->ibufs.first;
for (; ibuf; ibuf = ibuf->next)
oldnewmap_insert(fd->imamap, ibuf, ibuf, 0);
if (ima->gputexture)
oldnewmap_insert(fd->imamap, ima->gputexture, ima->gputexture, 0);
for (a=0; a < IMA_MAX_RENDER_SLOT; a++)
if (ima->renders[a])
oldnewmap_insert(fd->imamap, ima->renders[a], ima->renders[a], 0);
}
for (; sce; sce = sce->id.next) {
if (sce->nodetree) {
bNode *node;
for (node = sce->nodetree->nodes.first; node; node = node->next)
oldnewmap_insert(fd->imamap, node->preview, node->preview, 0);
}
}
}
/* set old main image ibufs to zero if it has been restored */
/* this works because freeing old main only happens after this call */
void blo_end_image_pointer_map(FileData *fd, Main *oldmain)
{
OldNew *entry = fd->imamap->entries;
Image *ima = oldmain->image.first;
Scene *sce = oldmain->scene.first;
int i;
/* used entries were restored, so we put them to zero */
for (i = 0; i < fd->imamap->nentries; i++, entry++) {
if (entry->nr > 0)
entry->newp = NULL;
}
for (; ima; ima = ima->id.next) {
Link *ibuf, *next;
/* this mirrors direct_link_image */
for (ibuf = ima->ibufs.first; ibuf; ibuf = next) {
next = ibuf->next;
if (NULL == newimaadr(fd, ibuf)) { /* so was restored */
BLI_remlink(&ima->ibufs, ibuf);
ima->bindcode = 0;
ima->gputexture = NULL;
}
}
for (i = 0; i < IMA_MAX_RENDER_SLOT; i++)
ima->renders[i] = newimaadr(fd, ima->renders[i]);
ima->gputexture = newimaadr(fd, ima->gputexture);
}
for (; sce; sce = sce->id.next) {
if (sce->nodetree) {
bNode *node;
for (node = sce->nodetree->nodes.first; node; node = node->next)
node->preview = newimaadr(fd, node->preview);
}
}
}
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
void blo_make_movieclip_pointer_map(FileData *fd, Main *oldmain)
{
MovieClip *clip = oldmain->movieclip.first;
Scene *sce = oldmain->scene.first;
fd->movieclipmap = oldnewmap_new();
for (; clip; clip = clip->id.next) {
if (clip->cache)
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
oldnewmap_insert(fd->movieclipmap, clip->cache, clip->cache, 0);
if (clip->tracking.camera.intrinsics)
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
oldnewmap_insert(fd->movieclipmap, clip->tracking.camera.intrinsics, clip->tracking.camera.intrinsics, 0);
}
for (; sce; sce = sce->id.next) {
if (sce->nodetree) {
bNode *node;
for (node = sce->nodetree->nodes.first; node; node= node->next)
if (node->type == CMP_NODE_MOVIEDISTORTION)
oldnewmap_insert(fd->movieclipmap, node->storage, node->storage, 0);
}
}
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
}
/* set old main movie clips caches to zero if it has been restored */
/* this works because freeing old main only happens after this call */
void blo_end_movieclip_pointer_map(FileData *fd, Main *oldmain)
{
OldNew *entry = fd->movieclipmap->entries;
MovieClip *clip = oldmain->movieclip.first;
Scene *sce = oldmain->scene.first;
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
int i;
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
/* used entries were restored, so we put them to zero */
for (i=0; i < fd->movieclipmap->nentries; i++, entry++) {
if (entry->nr > 0)
entry->newp = NULL;
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
}
for (; clip; clip = clip->id.next) {
clip->cache = newmclipadr(fd, clip->cache);
clip->tracking.camera.intrinsics = newmclipadr(fd, clip->tracking.camera.intrinsics);
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
}
for (; sce; sce = sce->id.next) {
if (sce->nodetree) {
bNode *node;
for (node = sce->nodetree->nodes.first; node; node = node->next)
if (node->type == CMP_NODE_MOVIEDISTORTION)
node->storage = newmclipadr(fd, node->storage);
}
}
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
}
/* undo file support: add all library pointers in lookup */
void blo_add_library_pointer_map(ListBase *mainlist, FileData *fd)
{
Main *ptr = mainlist->first;
ListBase *lbarray[MAX_LIBARRAY];
for (ptr = ptr->next; ptr; ptr = ptr->next) {
int i = set_listbasepointers(ptr, lbarray);
while (i--) {
ID *id;
for (id = lbarray[i]->first; id; id = id->next)
oldnewmap_insert(fd->libmap, id, id, GS(id->name));
}
}
}
/* ********** END OLD POINTERS ****************** */
2002-10-12 11:37:38 +00:00
/* ********** READ FILE ****************** */
static void switch_endian_structs(struct SDNA *filesdna, BHead *bhead)
{
int blocksize, nblocks;
char *data;
data = (char *)(bhead+1);
blocksize = filesdna->typelens[ filesdna->structs[bhead->SDNAnr][0] ];
nblocks = bhead->nr;
while (nblocks--) {
DNA_struct_switch_endian(filesdna, bhead->SDNAnr, data);
data += blocksize;
2002-10-12 11:37:38 +00:00
}
}
static void *read_struct(FileData *fd, BHead *bh, const char *blockname)
2002-10-12 11:37:38 +00:00
{
void *temp = NULL;
2002-10-12 11:37:38 +00:00
if (bh->len) {
/* switch is based on file dna */
2002-10-12 11:37:38 +00:00
if (bh->SDNAnr && (fd->flags & FD_FLAGS_SWITCH_ENDIAN))
switch_endian_structs(fd->filesdna, bh);
2002-10-12 11:37:38 +00:00
if (fd->compflags[bh->SDNAnr]) { /* flag==0: doesn't exist anymore */
if (fd->compflags[bh->SDNAnr] == 2) {
temp = DNA_struct_reconstruct(fd->memsdna, fd->filesdna, fd->compflags, bh->SDNAnr, bh->nr, (bh+1));
}
else {
temp = MEM_mallocN(bh->len, blockname);
memcpy(temp, (bh+1), bh->len);
2002-10-12 11:37:38 +00:00
}
}
}
return temp;
2002-10-12 11:37:38 +00:00
}
static void link_list(FileData *fd, ListBase *lb) /* only direct data */
2002-10-12 11:37:38 +00:00
{
Link *ln, *prev;
if (lb->first == NULL) return;
lb->first = newdataadr(fd, lb->first);
ln = lb->first;
prev = NULL;
while (ln) {
ln->next = newdataadr(fd, ln->next);
ln->prev = prev;
prev = ln;
ln = ln->next;
2002-10-12 11:37:38 +00:00
}
lb->last = prev;
2002-10-12 11:37:38 +00:00
}
static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */
{
Link *ln, *prev;
void *poin;
if (lb->first == NULL) return;
poin = newdataadr(fd, lb->first);
if (lb->first) {
2002-10-12 11:37:38 +00:00
oldnewmap_insert(fd->globmap, lb->first, poin, 0);
}
lb->first = poin;
ln = lb->first;
prev = NULL;
while (ln) {
poin = newdataadr(fd, ln->next);
if (ln->next) {
2002-10-12 11:37:38 +00:00
oldnewmap_insert(fd->globmap, ln->next, poin, 0);
}
ln->next = poin;
ln->prev = prev;
prev = ln;
ln = ln->next;
2002-10-12 11:37:38 +00:00
}
lb->last = prev;
2002-10-12 11:37:38 +00:00
}
static void test_pointer_array(FileData *fd, void **mat)
{
#if defined(WIN32) && !defined(FREE_WINDOWS)
2002-10-12 11:37:38 +00:00
__int64 *lpoin, *lmat;
#else
long long *lpoin, *lmat;
#endif
int *ipoin, *imat;
size_t len;
2002-10-12 11:37:38 +00:00
/* manually convert the pointer array in
* the old dna format to a pointer array in
* the new dna format.
*/
if (*mat) {
len = MEM_allocN_len(*mat)/fd->filesdna->pointerlen;
if (fd->filesdna->pointerlen==8 && fd->memsdna->pointerlen==4) {
ipoin=imat= MEM_mallocN(len * 4, "newmatar");
2002-10-12 11:37:38 +00:00
lpoin= *mat;
while (len-- > 0) {
if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN))
2002-10-12 11:37:38 +00:00
SWITCH_LONGINT(*lpoin);
*ipoin = (int)((*lpoin) >> 3);
2002-10-12 11:37:38 +00:00
ipoin++;
lpoin++;
}
MEM_freeN(*mat);
*mat = imat;
2002-10-12 11:37:38 +00:00
}
if (fd->filesdna->pointerlen==4 && fd->memsdna->pointerlen==8) {
lpoin = lmat = MEM_mallocN(len * 8, "newmatar");
ipoin = *mat;
while (len-- > 0) {
*lpoin = *ipoin;
2002-10-12 11:37:38 +00:00
ipoin++;
lpoin++;
}
MEM_freeN(*mat);
*mat= lmat;
}
}
}
/* ************ READ ID Properties *************** */
static void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, FileData *fd);
static void IDP_LibLinkProperty(IDProperty *prop, int switch_endian, FileData *fd);
static void IDP_DirectLinkIDPArray(IDProperty *prop, int switch_endian, FileData *fd)
{
IDProperty *array;
int i;
/* since we didn't save the extra buffer, set totallen to len */
prop->totallen = prop->len;
prop->data.pointer = newdataadr(fd, prop->data.pointer);
array = (IDProperty *)prop->data.pointer;
/* note!, idp-arrays didn't exist in 2.4x, so the pointer will be cleared
2012-03-18 07:38:51 +00:00
* theres not really anything we can do to correct this, at least don't crash */
if (array == NULL) {
prop->len = 0;
prop->totallen = 0;
}
for (i = 0; i < prop->len; i++)
2009-09-16 17:43:09 +00:00
IDP_DirectLinkProperty(&array[i], switch_endian, fd);
}
static void IDP_DirectLinkArray(IDProperty *prop, int switch_endian, FileData *fd)
{
IDProperty **array;
int i;
/* since we didn't save the extra buffer, set totallen to len */
prop->totallen = prop->len;
prop->data.pointer = newdataadr(fd, prop->data.pointer);
if (prop->subtype == IDP_GROUP) {
2009-09-16 17:43:09 +00:00
test_pointer_array(fd, prop->data.pointer);
array = prop->data.pointer;
for (i = 0; i < prop->len; i++)
2009-09-16 17:43:09 +00:00
IDP_DirectLinkProperty(array[i], switch_endian, fd);
}
else if (prop->subtype == IDP_DOUBLE) {
2009-09-16 17:43:09 +00:00
if (switch_endian) {
for (i = 0; i < prop->len; i++) {
SWITCH_LONGINT(((double *)prop->data.pointer)[i]);
}
2009-09-16 17:43:09 +00:00
}
}
else {
if (switch_endian) {
for (i = 0; i < prop->len; i++) {
SWITCH_INT(((int *)prop->data.pointer)[i]);
}
}
}
}
static void IDP_DirectLinkString(IDProperty *prop, FileData *fd)
{
/*since we didn't save the extra string buffer, set totallen to len.*/
prop->totallen = prop->len;
prop->data.pointer = newdataadr(fd, prop->data.pointer);
}
static void IDP_DirectLinkGroup(IDProperty *prop, int switch_endian, FileData *fd)
{
ListBase *lb = &prop->data.group;
IDProperty *loop;
link_list(fd, lb);
/*Link child id properties now*/
for (loop=prop->data.group.first; loop; loop=loop->next) {
IDP_DirectLinkProperty(loop, switch_endian, fd);
}
}
static void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, FileData *fd)
{
switch (prop->type) {
case IDP_GROUP:
IDP_DirectLinkGroup(prop, switch_endian, fd);
break;
case IDP_STRING:
IDP_DirectLinkString(prop, fd);
break;
case IDP_ARRAY:
IDP_DirectLinkArray(prop, switch_endian, fd);
break;
case IDP_IDPARRAY:
IDP_DirectLinkIDPArray(prop, switch_endian, fd);
break;
case IDP_DOUBLE:
/* erg, stupid doubles. since I'm storing them
* in the same field as int val; val2 in the
* IDPropertyData struct, they have to deal with
* endianness specifically
2012-04-22 11:54:53 +00:00
*
* in theory, val and val2 would've already been swapped
* if switch_endian is true, so we have to first unswap
* them then reswap them as a single 64-bit entity.
*/
if (switch_endian) {
SWITCH_INT(prop->data.val);
SWITCH_INT(prop->data.val2);
SWITCH_LONGINT(prop->data.val);
}
break;
}
}
/* stub function */
static void IDP_LibLinkProperty(IDProperty *UNUSED(prop), int UNUSED(switch_endian), FileData *UNUSED(fd))
{
}
/* ************ READ CurveMapping *************** */
/* cuma itself has been read! */
static void direct_link_curvemapping(FileData *fd, CurveMapping *cumap)
{
int a;
/* flag seems to be able to hang? Maybe old files... not bad to clear anyway */
cumap->flag &= ~CUMA_PREMULLED;
for (a = 0; a < CM_TOT; a++) {
cumap->cm[a].curve = newdataadr(fd, cumap->cm[a].curve);
cumap->cm[a].table = NULL;
cumap->cm[a].premultable = NULL;
}
}
/* ************ READ Brush *************** */
/* library brush linking after fileread */
static void lib_link_brush(FileData *fd, Main *main)
{
Brush *brush;
/* only link ID pointers */
for (brush = main->brush.first; brush; brush = brush->id.next) {
if (brush->id.flag & LIB_NEEDLINK) {
brush->id.flag -= LIB_NEEDLINK;
brush->mtex.tex = newlibadr_us(fd, brush->id.lib, brush->mtex.tex);
brush->clone.image = newlibadr_us(fd, brush->id.lib, brush->clone.image);
}
}
}
static void direct_link_brush(FileData *fd, Brush *brush)
{
/* brush itself has been read */
/* fallof curve */
brush->curve = newdataadr(fd, brush->curve);
if (brush->curve)
direct_link_curvemapping(fd, brush->curve);
else
2012-05-05 00:58:22 +00:00
BKE_brush_curve_preset(brush, CURVE_PRESET_SHARP);
brush->preview = NULL;
brush->icon_imbuf = NULL;
}
static void direct_link_script(FileData *UNUSED(fd), Script *script)
{
script->id.us = 1;
SCRIPT_SET_NULL(script);
}
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
2002-10-12 11:37:38 +00:00
/* ************ READ PACKEDFILE *************** */
static PackedFile *direct_link_packedfile(FileData *fd, PackedFile *oldpf)
{
PackedFile *pf = newdataadr(fd, oldpf);
2002-10-12 11:37:38 +00:00
if (pf) {
pf->data = newdataadr(fd, pf->data);
2002-10-12 11:37:38 +00:00
}
2002-10-12 11:37:38 +00:00
return pf;
}
/* ************ READ IMAGE PREVIEW *************** */
static PreviewImage *direct_link_preview_image(FileData *fd, PreviewImage *old_prv)
{
PreviewImage *prv = newdataadr(fd, old_prv);
if (prv) {
int i;
for (i = 0; i < NUM_ICON_SIZES; ++i) {
if (prv->rect[i]) {
prv->rect[i] = newdataadr(fd, prv->rect[i]);
}
}
}
return prv;
}
/* ************ READ ANIMATION STUFF ***************** */
/* Legacy Data Support (for Version Patching) ----------------------------- */
// XXX depreceated - old animation system
static void lib_link_ipo(FileData *fd, Main *main)
{
Ipo *ipo;
for (ipo = main->ipo.first; ipo; ipo = ipo->id.next) {
if (ipo->id.flag & LIB_NEEDLINK) {
IpoCurve *icu;
for (icu = ipo->curve.first; icu; icu = icu->next) {
if (icu->driver)
icu->driver->ob = newlibadr(fd, ipo->id.lib, icu->driver->ob);
}
ipo->id.flag -= LIB_NEEDLINK;
}
}
}
// XXX depreceated - old animation system
static void direct_link_ipo(FileData *fd, Ipo *ipo)
{
IpoCurve *icu;
link_list(fd, &(ipo->curve));
for (icu = ipo->curve.first; icu; icu = icu->next) {
icu->bezt = newdataadr(fd, icu->bezt);
icu->bp = newdataadr(fd, icu->bp);
icu->driver = newdataadr(fd, icu->driver);
}
}
2002-10-12 11:37:38 +00:00
// XXX depreceated - old animation system
2002-10-12 11:37:38 +00:00
static void lib_link_nlastrips(FileData *fd, ID *id, ListBase *striplist)
{
bActionStrip *strip;
Two wonderful new NLA & Armature editing features! - FORWARD CYCLING & MATCHING Up to no now, adding multiple actions in NLA with walkcycles required to animate them standing still, as if walking on a conveyor belt. The stride option then makes the object itself move forward, trying to keep the foot stuck on the floor (with poor results!). This option now allows to make walk cycles moving forward. By indicating a reference Offset Bone, the NLA system will use that bone to detect the correct offset for the Armature Pose to make it seamlessly going forward. Best of all, this option works as for cyclic Action Strips as well as for individual Action Strips. Note that for individual strips, you have to set the strip on "Hold". (Might become automatic detected later). Here's an example edit image for NLA: http://www.blender.org/bf/nla_match-cycle.jpg And the animation for it: http://download.blender.org/demo/test/2.43/0001_0150_match.avi Blender file: http://download.blender.org/demo/test/2.43/mancandy_matching.blend Using this kind of cycling works pretty straightforward, and is a lot easier to setup than Stride Bones. To be further tested: - Blending cycles - matching rotation for the bones as well. - ACTION MODIFIERS (motion deformors) The above option was actually required for this feature. Typically walk cycles are constructed with certain Bones to be the handles, controlling for example the torso or feet. An Action Modifier allows you to use a Curve Path to deform the motion of these controlling bones. This uses the existing Curve Deformation option. Modifiers can be added per Action Strip, each controlling a channel (bone) by choice, and even allows to layer multiple modifiers on top of each other (several paths deforming motion). This option is using the dependency graph, so editing the Curve will give realtime changes in the Armature. The previous walkcycle, controlled by two curves: http://download.blender.org/demo/test/2.43/0001_0150_deform.avi Blender file: http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend Action Modifiers can be added in the NLA Properties Panel. Per Modifier you have to indicate the channel and a Curve Object. You can copy modifiers from one strip to another using CTRL+C (only copies to active Object strips). Setting up a correct Curve Path has to be carefully done: - Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated. - make sure the center point of the Curve Object is at the center of the Armature (or above) - move the first point of the curve to the center point as well. - check if the path starts from this first point, you can change it using (in Curve EditMode) the option Wkey -> "Switch Direction" - Make sure alignment uses the correct axis; if the Armature walks into the negative Y direction, you have to set in Object Buttons, "Anim settings" Panel, the correct Track option. (Note; option will probably move to the Modifier later). This is a good reason to make such paths automatic (on a command). Is on the todo list. Also note this: - the Curve Path extends in beginning and ending, that's (for now) the default, and allows to use multiple paths. Make sure paths begin and end horizontal. - Moving the Curve in Object Mode will change the "mapping" (as if the landscape a character walks over moves). Moving the Curve in Edit Mode will change the actual position of the deformation. - Speed (Ipos) on paths is not supported yet, will be done. - The Curve "Stretch" deform option doesn't work. - Modifiers are executed *after* all actions in NLA are evaluated, there's no support yet for blending multiple strips with Modifiers. - This doesn't work yet for time-mapping... This commit is mostly for review by character animators... some details or working methods might change. This feature can also be used for other modifiers, such as noise (Perlin) or the mythical "Oomph" (frequency control) and of course Python. Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
bActionModifier *amod;
for (strip=striplist->first; strip; strip=strip->next) {
Big commit with work on Groups & Libraries: -> Any Group Duplicate now can get local timing and local NLA override. This enables to control the entire animation system of the Group. Two methods for this have been implemented. 1) The quick way: just give the duplicator a "Startframe" offset. 2) Advanced: in the NLA Editor you can add ActionStrips to the duplicator to override NLA/action of any Grouped Object. For "Group NLA" to work, an ActionStrip needs to know which Object in a group it controls. On adding a strip, the code checks if an Action was already used by an Object in the Group, and assigns it automatic to that Object. You can also set this in the Nkey "Properties" panel for the strip. Change in NLA: the SHIFT+A "Add strip" command now always adds strips to the active Object. (It used to check where mouse was). This allows to add NLA strips to Objects that didn't have actions/nla yet. Important note: In Blender, duplicates are fully procedural and generated on the fly for each redraw. This means that redraw speed equals to stepping through frames, when using animated Duplicated Groups. -> Recoded entire duplicator system The old method was antique and clumsy, using globals and full temporal copies of Object. The new system is nicer in control, faster, and since it doesn't use temporal object copies anymore, it works better with Derived Mesh and DisplayList and rendering. By centralizing the code for duplicating, more options can be easier added. Features to note: - Duplicates now draw selected/unselected based on its Duplicator setting. - Same goes for the drawtype (wire, solid, selection outline, etc) - Duplicated Groups can be normally selected too Bonus goodie: SHIFT+A (Toolbox) now has entry "Add group" too, with a listing of all groups, allowing to add Group instances immediate. -> Library System - SHIFT+F4 data browse now shows the entire path for linked data - Outliner draws Library Icons to denote linked data - Outliner operation added: "Make Local" for library data. - Outliner now also draws Groups in regular view, allowing to unlink too. -> Fixes - depsgraph missed signal update for bone-parented Objects - on reading file, the entire database was tagged to "recalc" fully, causing unnecessary slowdown on reading. Might have missed stuff... :)
2005-12-11 13:23:30 +00:00
strip->object = newlibadr(fd, id->lib, strip->object);
strip->act = newlibadr_us(fd, id->lib, strip->act);
2002-10-12 11:37:38 +00:00
strip->ipo = newlibadr(fd, id->lib, strip->ipo);
for (amod = strip->modifiers.first; amod; amod = amod->next)
amod->ob = newlibadr(fd, id->lib, amod->ob);
Result of 2 weeks of quiet coding work in Greece :) Aim was to get a total refresh of the animation system. This is needed because; - we need to upgrade it with 21st century features - current code is spaghetti/hack combo, and hides good design - it should become lag-free with using dependency graphs A full log, with complete code API/structure/design explanation will follow, that's a load of work... so here below the list with hot changes; - The entire object update system (matrices, geometry) is now centralized. Calls to where_is_object and makeDispList are forbidden, instead we tag objects 'changed' and let the depgraph code sort it out - Removed all old "Ika" code - Depgraph is aware of all relationships, including meta balls, constraints, bevelcurve, and so on. - Made depgraph aware of relation types and layers, to do smart flushing of 'changed' events. Nothing gets calculated too often! - Transform uses depgraph to detect changes - On frame-advance, depgraph flushes animated changes Armatures; Almost all armature related code has been fully built from scratch. It now reveils the original design much better, with a very clean implementation, lag free without even calculating each Bone more than once. Result is quite a speedup yes! Important to note is; 1) Armature is data containing the 'rest position' 2) Pose is the changes of rest position, and always on object level. That way more Objects can use same Pose. Also constraints are in Pose 3) Actions only contain the Ipos to change values in Poses. - Bones draw unrotated now - Drawing bones speedup enormously (10-20 times) - Bone selecting in EditMode, selection state is saved for PoseMode, and vice-versa - Undo in editmode - Bone renaming does vertexgroups, constraints, posechannels, actions, for all users of Armature in entire file - Added Bone renaming in NKey panel - Nkey PoseMode shows eulers now - EditMode and PoseMode now have 'active' bone too (last clicked) - Parenting in EditMode' CTRL+P, ALT+P, with nice options! - Pose is added in Outliner now, with showing that constraints are in the Pose, not Armature - Disconnected IK solving from constraints. It's a separate phase now, on top of the full Pose calculations - Pose itself has a dependency graph too, so evaluation order is lag free. TODO NOW; - Rotating in Posemode has incorrect inverse transform (Martin will fix) - Python Bone/Armature/Pose API disabled... needs full recode too (wait for my doc!) - Game engine will need upgrade too - Depgraph code needs revision, cleanup, can be much faster! (But, compliments for Jean-Luc, it works like a charm!) - IK changed, it now doesnt use previous position to advance to next position anymore. That system looks nice (no flips) but is not well suited for NLA and background render. TODO LATER; We now can do loadsa new nifty features as well; like: - Kill PoseMode (can be option for armatures itself) - Make B-Bones (Bezier, Bspline, like for spines) - Move all silly button level edit to 3d window (like CTRL+I = add IK) - Much better & informative drawing - Fix action/nla editors - Put all ipos in Actions (object, mesh key, lamp color) - Add hooks - Null bones - Much more advanced constraints... Bugfixes; - OGL render (view3d header) had wrong first frame on anim render - Ipo 'recording' mode had wrong playback speed - Vertex-key mode now sticks to show 'active key', until frame change -Ton-
2005-07-03 17:35:38 +00:00
}
2002-10-12 11:37:38 +00:00
}
// XXX depreceated - old animation system
static void direct_link_nlastrips(FileData *fd, ListBase *strips)
{
bActionStrip *strip;
link_list(fd, strips);
for (strip = strips->first; strip; strip = strip->next)
link_list(fd, &strip->modifiers);
}
// XXX depreceated - old animation system
2002-10-12 11:37:38 +00:00
static void lib_link_constraint_channels(FileData *fd, ID *id, ListBase *chanbase)
{
bConstraintChannel *chan;
for (chan=chanbase->first; chan; chan=chan->next) {
2002-10-12 11:37:38 +00:00
chan->ipo = newlibadr_us(fd, id->lib, chan->ipo);
}
}
/* Data Linking ----------------------------- */
2009-05-22 11:19:35 +00:00
static void lib_link_fmodifiers(FileData *fd, ID *id, ListBase *list)
{
FModifier *fcm;
for (fcm = list->first; fcm; fcm = fcm->next) {
2009-05-22 11:19:35 +00:00
/* data for specific modifiers */
switch (fcm->type) {
case FMODIFIER_TYPE_PYTHON:
{
FMod_Python *data = (FMod_Python *)fcm->data;
2009-05-22 11:19:35 +00:00
data->script = newlibadr(fd, id->lib, data->script);
}
break;
}
}
}
static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list)
{
FCurve *fcu;
if (list == NULL)
return;
/* relink ID-block references... */
for (fcu = list->first; fcu; fcu = fcu->next) {
/* driver data */
if (fcu->driver) {
ChannelDriver *driver = fcu->driver;
Durian Request: Drivers Recode Highlights: * Support for Multi-Target Variables This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that. * New Variable Types With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones). * New Driver Types In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to. * Fix for Driver F-Curve colouring bug Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used. Notes: * This commit breaks existing 2.5 files with drivers (in other words, they are lost forever). * Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later. * Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
DriverVar *dvar;
Durian Request: Drivers Recode Highlights: * Support for Multi-Target Variables This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that. * New Variable Types With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones). * New Driver Types In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to. * Fix for Driver F-Curve colouring bug Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used. Notes: * This commit breaks existing 2.5 files with drivers (in other words, they are lost forever). * Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later. * Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
DRIVER_TARGETS_LOOPER(dvar)
{
/* only relink if still used */
if (tarIndex < dvar->num_targets)
dtar->id = newlibadr(fd, id->lib, dtar->id);
Durian Request: Drivers Recode Highlights: * Support for Multi-Target Variables This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that. * New Variable Types With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones). * New Driver Types In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to. * Fix for Driver F-Curve colouring bug Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used. Notes: * This commit breaks existing 2.5 files with drivers (in other words, they are lost forever). * Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later. * Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
else
dtar->id = NULL;
Durian Request: Drivers Recode Highlights: * Support for Multi-Target Variables This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that. * New Variable Types With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones). * New Driver Types In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to. * Fix for Driver F-Curve colouring bug Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used. Notes: * This commit breaks existing 2.5 files with drivers (in other words, they are lost forever). * Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later. * Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
}
DRIVER_TARGETS_LOOPER_END
}
}
/* modifiers */
2009-05-22 11:19:35 +00:00
lib_link_fmodifiers(fd, id, &fcu->modifiers);
}
}
/* NOTE: this assumes that link_list has already been called on the list */
static void direct_link_fmodifiers(FileData *fd, ListBase *list)
{
FModifier *fcm;
for (fcm = list->first; fcm; fcm = fcm->next) {
2009-05-22 11:19:35 +00:00
/* relink general data */
fcm->data = newdataadr(fd, fcm->data);
fcm->edata = NULL;
2009-05-22 11:19:35 +00:00
/* do relinking of data for specific types */
switch (fcm->type) {
case FMODIFIER_TYPE_GENERATOR:
{
FMod_Generator *data = (FMod_Generator *)fcm->data;
data->coefficients = newdataadr(fd, data->coefficients);
2009-05-22 11:19:35 +00:00
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
unsigned int a;
for (a = 0; a < data->arraysize; a++)
SWITCH_INT(data->coefficients[a]);
}
}
2009-05-22 11:19:35 +00:00
break;
case FMODIFIER_TYPE_ENVELOPE:
{
FMod_Envelope *data= (FMod_Envelope *)fcm->data;
2009-05-22 11:19:35 +00:00
data->data= newdataadr(fd, data->data);
}
break;
case FMODIFIER_TYPE_PYTHON:
{
FMod_Python *data = (FMod_Python *)fcm->data;
2009-05-22 11:19:35 +00:00
data->prop = newdataadr(fd, data->prop);
IDP_DirectLinkProperty(data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
}
2009-05-22 11:19:35 +00:00
break;
}
}
}
/* NOTE: this assumes that link_list has already been called on the list */
static void direct_link_fcurves(FileData *fd, ListBase *list)
{
FCurve *fcu;
/* link F-Curve data to F-Curve again (non ID-libs) */
for (fcu = list->first; fcu; fcu = fcu->next) {
/* curve data */
fcu->bezt = newdataadr(fd, fcu->bezt);
fcu->fpt = newdataadr(fd, fcu->fpt);
/* rna path */
fcu->rna_path = newdataadr(fd, fcu->rna_path);
/* group */
fcu->grp = newdataadr(fd, fcu->grp);
/* driver */
fcu->driver= newdataadr(fd, fcu->driver);
if (fcu->driver) {
ChannelDriver *driver= fcu->driver;
Durian Request: Drivers Recode Highlights: * Support for Multi-Target Variables This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that. * New Variable Types With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones). * New Driver Types In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to. * Fix for Driver F-Curve colouring bug Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used. Notes: * This commit breaks existing 2.5 files with drivers (in other words, they are lost forever). * Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later. * Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
DriverVar *dvar;
driver->expr_comp = NULL;
Durian Request: Drivers Recode Highlights: * Support for Multi-Target Variables This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that. * New Variable Types With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones). * New Driver Types In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to. * Fix for Driver F-Curve colouring bug Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used. Notes: * This commit breaks existing 2.5 files with drivers (in other words, they are lost forever). * Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later. * Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
/* relink variables, targets and their paths */
link_list(fd, &driver->variables);
for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
DRIVER_TARGETS_LOOPER(dvar)
{
/* only relink the targets being used */
if (tarIndex < dvar->num_targets)
dtar->rna_path = newdataadr(fd, dtar->rna_path);
Durian Request: Drivers Recode Highlights: * Support for Multi-Target Variables This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that. * New Variable Types With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones). * New Driver Types In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to. * Fix for Driver F-Curve colouring bug Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used. Notes: * This commit breaks existing 2.5 files with drivers (in other words, they are lost forever). * Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later. * Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
else
dtar->rna_path = NULL;
Durian Request: Drivers Recode Highlights: * Support for Multi-Target Variables This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that. * New Variable Types With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones). * New Driver Types In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to. * Fix for Driver F-Curve colouring bug Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used. Notes: * This commit breaks existing 2.5 files with drivers (in other words, they are lost forever). * Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later. * Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
}
DRIVER_TARGETS_LOOPER_END
}
}
/* modifiers */
link_list(fd, &fcu->modifiers);
2009-05-22 11:19:35 +00:00
direct_link_fmodifiers(fd, &fcu->modifiers);
}
}
static void lib_link_action(FileData *fd, Main *main)
{
bAction *act;
bActionChannel *chan;
for (act = main->action.first; act; act = act->id.next) {
if (act->id.flag & LIB_NEEDLINK) {
act->id.flag -= LIB_NEEDLINK;
// XXX depreceated - old animation system <<<
for (chan=act->chanbase.first; chan; chan=chan->next) {
chan->ipo = newlibadr_us(fd, act->id.lib, chan->ipo);
lib_link_constraint_channels(fd, &act->id, &chan->constraintChannels);
}
// >>> XXX depreceated - old animation system
lib_link_fcurves(fd, &act->id, &act->curves);
}
}
}
static void direct_link_action(FileData *fd, bAction *act)
{
bActionChannel *achan; // XXX depreceated - old animation system
bActionGroup *agrp;
link_list(fd, &act->curves);
link_list(fd, &act->chanbase); // XXX depreceated - old animation system
link_list(fd, &act->groups);
link_list(fd, &act->markers);
// XXX depreceated - old animation system <<<
for (achan = act->chanbase.first; achan; achan=achan->next) {
achan->grp = newdataadr(fd, achan->grp);
link_list(fd, &achan->constraintChannels);
}
// >>> XXX depreceated - old animation system
direct_link_fcurves(fd, &act->curves);
for (agrp = act->groups.first; agrp; agrp= agrp->next) {
agrp->channels.first= newdataadr(fd, agrp->channels.first);
agrp->channels.last= newdataadr(fd, agrp->channels.last);
}
}
static void lib_link_nladata_strips(FileData *fd, ID *id, ListBase *list)
{
NlaStrip *strip;
for (strip = list->first; strip; strip = strip->next) {
/* check strip's children */
lib_link_nladata_strips(fd, id, &strip->strips);
/* check strip's F-Curves */
lib_link_fcurves(fd, id, &strip->fcurves);
/* reassign the counted-reference to action */
strip->act = newlibadr_us(fd, id->lib, strip->act);
2011-04-19 13:01:50 +00:00
/* fix action id-root (i.e. if it comes from a pre 2.57 .blend file) */
if ((strip->act) && (strip->act->idroot == 0))
strip->act->idroot = GS(id->name);
}
}
2009-05-22 11:19:35 +00:00
static void lib_link_nladata(FileData *fd, ID *id, ListBase *list)
2009-05-22 11:19:35 +00:00
{
NlaTrack *nlt;
/* we only care about the NLA strips inside the tracks */
for (nlt = list->first; nlt; nlt = nlt->next) {
lib_link_nladata_strips(fd, id, &nlt->strips);
}
}
/* This handles Animato NLA-Strips linking
* NOTE: this assumes that link_list has already been called on the list
*/
static void direct_link_nladata_strips(FileData *fd, ListBase *list)
{
NlaStrip *strip;
for (strip = list->first; strip; strip = strip->next) {
/* strip's child strips */
link_list(fd, &strip->strips);
direct_link_nladata_strips(fd, &strip->strips);
/* strip's F-Curves */
link_list(fd, &strip->fcurves);
direct_link_fcurves(fd, &strip->fcurves);
/* strip's F-Modifiers */
link_list(fd, &strip->modifiers);
direct_link_fmodifiers(fd, &strip->modifiers);
2009-05-22 11:19:35 +00:00
}
}
/* NOTE: this assumes that link_list has already been called on the list */
static void direct_link_nladata(FileData *fd, ListBase *list)
{
NlaTrack *nlt;
for (nlt = list->first; nlt; nlt = nlt->next) {
2009-05-22 11:19:35 +00:00
/* relink list of strips */
link_list(fd, &nlt->strips);
/* relink strip data */
direct_link_nladata_strips(fd, &nlt->strips);
2009-05-22 11:19:35 +00:00
}
}
/* ------- */
static void lib_link_keyingsets(FileData *fd, ID *id, ListBase *list)
{
KeyingSet *ks;
KS_Path *ksp;
/* here, we're only interested in the ID pointer stored in some of the paths */
for (ks = list->first; ks; ks = ks->next) {
for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
ksp->id= newlibadr(fd, id->lib, ksp->id);
}
}
}
/* NOTE: this assumes that link_list has already been called on the list */
static void direct_link_keyingsets(FileData *fd, ListBase *list)
{
KeyingSet *ks;
KS_Path *ksp;
/* link KeyingSet data to KeyingSet again (non ID-libs) */
for (ks = list->first; ks; ks = ks->next) {
/* paths */
link_list(fd, &ks->paths);
for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
/* rna path */
ksp->rna_path= newdataadr(fd, ksp->rna_path);
}
}
}
/* ------- */
static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt)
{
if (adt == NULL)
return;
/* link action data */
adt->action= newlibadr_us(fd, id->lib, adt->action);
adt->tmpact= newlibadr_us(fd, id->lib, adt->tmpact);
2011-04-19 13:01:50 +00:00
/* fix action id-roots (i.e. if they come from a pre 2.57 .blend file) */
if ((adt->action) && (adt->action->idroot == 0))
adt->action->idroot = GS(id->name);
if ((adt->tmpact) && (adt->tmpact->idroot == 0))
adt->tmpact->idroot = GS(id->name);
/* link drivers */
lib_link_fcurves(fd, id, &adt->drivers);
/* overrides don't have lib-link for now, so no need to do anything */
/* link NLA-data */
2009-05-22 11:19:35 +00:00
lib_link_nladata(fd, id, &adt->nla_tracks);
}
static void direct_link_animdata(FileData *fd, AnimData *adt)
{
/* NOTE: must have called newdataadr already before doing this... */
if (adt == NULL)
return;
/* link drivers */
link_list(fd, &adt->drivers);
direct_link_fcurves(fd, &adt->drivers);
/* link overrides */
// TODO...
/* link NLA-data */
2009-05-22 11:19:35 +00:00
link_list(fd, &adt->nla_tracks);
direct_link_nladata(fd, &adt->nla_tracks);
/* relink active strip - even though strictly speaking this should only be used
* if we're in 'tweaking mode', we need to be able to have this loaded back for
* undo, but also since users may not exit tweakmode before saving (#24535)
*/
// TODO: it's not really nice that anyone should be able to save the file in this
// state, but it's going to be too hard to enforce this single case...
adt->actstrip = newdataadr(fd, adt->actstrip);
}
/* ************ READ MOTION PATHS *************** */
/* direct data for cache */
static void direct_link_motionpath(FileData *fd, bMotionPath *mpath)
{
/* sanity check */
if (mpath == NULL)
return;
/* relink points cache */
mpath->points = newdataadr(fd, mpath->points);
}
/* ************ READ NODE TREE *************** */
/* singe node tree (also used for material/scene trees), ntree is not NULL */
static void lib_link_ntree(FileData *fd, ID *id, bNodeTree *ntree)
{
bNode *node;
if (ntree->adt) lib_link_animdata(fd, &ntree->id, ntree->adt);
ntree->gpd = newlibadr_us(fd, id->lib, ntree->gpd);
for (node = ntree->nodes.first; node; node = node->next)
node->id = newlibadr_us(fd, id->lib, node->id);
}
/* library ntree linking after fileread */
static void lib_link_nodetree(FileData *fd, Main *main)
{
bNodeTree *ntree;
/* only link ID pointers */
for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) {
if (ntree->id.flag & LIB_NEEDLINK) {
ntree->id.flag -= LIB_NEEDLINK;
lib_link_ntree(fd, &ntree->id, ntree);
}
}
}
static void do_versions_socket_default_value(bNodeSocket *sock)
{
bNodeSocketValueFloat *valfloat;
bNodeSocketValueVector *valvector;
bNodeSocketValueRGBA *valrgba;
if (sock->default_value)
return;
switch (sock->type) {
case SOCK_FLOAT:
valfloat = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueFloat), "default socket value");
valfloat->value = sock->ns.vec[0];
valfloat->min = sock->ns.min;
valfloat->max = sock->ns.max;
valfloat->subtype = PROP_NONE;
break;
case SOCK_VECTOR:
valvector = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueVector), "default socket value");
copy_v3_v3(valvector->value, sock->ns.vec);
valvector->min = sock->ns.min;
valvector->max = sock->ns.max;
valvector->subtype = PROP_NONE;
break;
case SOCK_RGBA:
valrgba = sock->default_value = MEM_callocN(sizeof(bNodeSocketValueRGBA), "default socket value");
copy_v4_v4(valrgba->value, sock->ns.vec);
break;
}
}
void blo_do_versions_nodetree_default_value(bNodeTree *ntree)
{
bNode *node;
bNodeSocket *sock;
for (node=ntree->nodes.first; node; node=node->next) {
for (sock=node->inputs.first; sock; sock=sock->next)
do_versions_socket_default_value(sock);
for (sock=node->outputs.first; sock; sock=sock->next)
do_versions_socket_default_value(sock);
}
for (sock=ntree->inputs.first; sock; sock=sock->next)
do_versions_socket_default_value(sock);
for (sock=ntree->outputs.first; sock; sock=sock->next)
do_versions_socket_default_value(sock);
}
static void lib_nodetree_init_types_cb(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
{
bNode *node;
ntreeInitTypes(ntree);
/* need to do this here instead of in do_versions, otherwise next function can crash */
blo_do_versions_nodetree_default_value(ntree);
/* XXX could be replaced by do_versions for new nodes */
for (node=ntree->nodes.first; node; node=node->next)
node_verify_socket_templates(ntree, node);
}
/* updates group node socket own_index so that
* external links to/from the group node are preserved.
*/
static void lib_node_do_versions_group_indices(bNode *gnode)
{
bNodeTree *ngroup = (bNodeTree*)gnode->id;
bNode *intnode;
bNodeSocket *sock, *gsock, *intsock;
int found;
for (sock=gnode->outputs.first; sock; sock=sock->next) {
int old_index = sock->to_index;
for (gsock=ngroup->outputs.first; gsock; gsock=gsock->next) {
if (gsock->link && gsock->link->fromsock->own_index == old_index) {
sock->own_index = gsock->own_index;
break;
}
}
}
for (sock=gnode->inputs.first; sock; sock=sock->next) {
int old_index = sock->to_index;
/* can't use break in double loop */
found = 0;
for (intnode=ngroup->nodes.first; intnode && !found; intnode=intnode->next) {
for (intsock=intnode->inputs.first; intsock; intsock=intsock->next) {
if (intsock->own_index == old_index && intsock->link) {
sock->own_index = intsock->link->fromsock->own_index;
found = 1;
break;
}
}
}
}
}
/* updates external links for all group nodes in a tree */
static void lib_nodetree_do_versions_group_indices_cb(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
{
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP) {
bNodeTree *ngroup = (bNodeTree*)node->id;
if (ngroup && (ngroup->flag & NTREE_DO_VERSIONS_GROUP_EXPOSE))
lib_node_do_versions_group_indices(node);
}
}
}
/* make an update call for the tree */
static void lib_nodetree_do_versions_update_cb(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
{
if (ntree->update)
ntreeUpdateTree(ntree);
}
/* verify types for nodes and groups, all data has to be read */
/* open = 0: appending/linking, open = 1: open new file (need to clean out dynamic
2012-04-22 11:54:53 +00:00
* typedefs */
static void lib_verify_nodetree(Main *main, int UNUSED(open))
{
bNodeTree *ntree;
int i;
bNodeTreeType *ntreetype;
2012-04-22 11:54:53 +00:00
/* this crashes blender on undo/redo */
#if 0
if (open == 1) {
reinit_nodesystem();
2012-04-22 11:54:53 +00:00
}
#endif
/* set node->typeinfo pointers */
for (i = 0; i < NUM_NTREE_TYPES; ++i) {
ntreetype = ntreeGetType(i);
if (ntreetype && ntreetype->foreach_nodetree)
ntreetype->foreach_nodetree(main, NULL, lib_nodetree_init_types_cb);
}
for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
lib_nodetree_init_types_cb(NULL, NULL, ntree);
{
int has_old_groups = 0;
/* XXX this should actually be part of do_versions, but since we need
* finished library linking, it is not possible there. Instead in do_versions
* we have set the NTREE_DO_VERSIONS flag, so at this point we can do the
* actual group node updates.
*/
for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) {
if (ntree->flag & NTREE_DO_VERSIONS_GROUP_EXPOSE) {
/* this adds copies and links from all unlinked internal sockets to group inputs/outputs. */
node_group_expose_all_sockets(ntree);
has_old_groups = 1;
}
}
if (has_old_groups) {
for (i = 0; i < NUM_NTREE_TYPES; ++i) {
ntreetype = ntreeGetType(i);
if (ntreetype && ntreetype->foreach_nodetree)
ntreetype->foreach_nodetree(main, NULL, lib_nodetree_do_versions_group_indices_cb);
}
}
for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
ntree->flag &= ~NTREE_DO_VERSIONS_GROUP_EXPOSE;
}
/* verify all group user nodes */
for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) {
ntreeVerifyNodes(main, &ntree->id);
}
/* make update calls where necessary */
{
for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
if (ntree->update)
ntreeUpdateTree(ntree);
for (i = 0; i < NUM_NTREE_TYPES; i++) {
ntreetype = ntreeGetType(i);
if (ntreetype && ntreetype->foreach_nodetree)
ntreetype->foreach_nodetree(main, NULL, lib_nodetree_do_versions_update_cb);
}
}
}
static void direct_link_node_socket(FileData *fd, bNodeSocket *sock)
{
sock->link = newdataadr(fd, sock->link);
sock->storage = newdataadr(fd, sock->storage);
sock->default_value = newdataadr(fd, sock->default_value);
sock->cache = NULL;
}
/* ntree itself has been read! */
static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
{
/* note: writing and reading goes in sync, for speed */
bNode *node;
bNodeSocket *sock;
bNodeLink *link;
ntree->init = 0; /* to set callbacks and force setting types */
ntree->progress = NULL;
ntree->execdata = NULL;
ntree->adt = newdataadr(fd, ntree->adt);
direct_link_animdata(fd, ntree->adt);
link_list(fd, &ntree->nodes);
for (node = ntree->nodes.first; node; node = node->next) {
node->typeinfo = NULL;
link_list(fd, &node->inputs);
link_list(fd, &node->outputs);
if (node->type == CMP_NODE_MOVIEDISTORTION) {
node->storage = newmclipadr(fd, node->storage);
}
else
node->storage = newdataadr(fd, node->storage);
if (node->storage) {
/* could be handlerized at some point */
if (ntree->type==NTREE_SHADER && (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB))
direct_link_curvemapping(fd, node->storage);
else if (ntree->type==NTREE_COMPOSIT) {
if (ELEM4(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT))
direct_link_curvemapping(fd, node->storage);
else if (ELEM3(node->type, CMP_NODE_IMAGE, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
((ImageUser *)node->storage)->ok = 1;
}
else if ( ntree->type==NTREE_TEXTURE) {
if (node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME)
direct_link_curvemapping(fd, node->storage);
else if (node->type==TEX_NODE_IMAGE)
((ImageUser *)node->storage)->ok = 1;
}
}
}
link_list(fd, &ntree->links);
/* external sockets */
link_list(fd, &ntree->inputs);
link_list(fd, &ntree->outputs);
/* and we connect the rest */
for (node = ntree->nodes.first; node; node = node->next) {
node->parent = newdataadr(fd, node->parent);
node->preview = newimaadr(fd, node->preview);
node->lasty = 0;
for (sock = node->inputs.first; sock; sock = sock->next)
direct_link_node_socket(fd, sock);
for (sock = node->outputs.first; sock; sock = sock->next)
direct_link_node_socket(fd, sock);
}
for (sock = ntree->inputs.first; sock; sock = sock->next)
direct_link_node_socket(fd, sock);
for (sock = ntree->outputs.first; sock; sock = sock->next)
direct_link_node_socket(fd, sock);
for (link = ntree->links.first; link; link= link->next) {
link->fromnode = newdataadr(fd, link->fromnode);
link->tonode = newdataadr(fd, link->tonode);
link->fromsock = newdataadr(fd, link->fromsock);
link->tosock = newdataadr(fd, link->tosock);
}
/* type verification is in lib-link */
}
/* ************ READ ARMATURE ***************** */
/* temp struct used to transport needed info to lib_link_constraint_cb() */
typedef struct tConstraintLinkData {
FileData *fd;
ID *id;
} tConstraintLinkData;
/* callback function used to relink constraint ID-links */
static void lib_link_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, short isReference, void *userdata)
{
tConstraintLinkData *cld= (tConstraintLinkData *)userdata;
/* for reference types, we need to increment the usercounts on load... */
if (isReference) {
/* reference type - with usercount */
*idpoin = newlibadr_us(cld->fd, cld->id->lib, *idpoin);
}
else {
/* target type - no usercount needed */
*idpoin = newlibadr(cld->fd, cld->id->lib, *idpoin);
}
}
2002-10-12 11:37:38 +00:00
static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist)
{
tConstraintLinkData cld;
2002-10-12 11:37:38 +00:00
bConstraint *con;
/* legacy fixes */
2002-10-12 11:37:38 +00:00
for (con = conlist->first; con; con=con->next) {
Result of 2 weeks of quiet coding work in Greece :) Aim was to get a total refresh of the animation system. This is needed because; - we need to upgrade it with 21st century features - current code is spaghetti/hack combo, and hides good design - it should become lag-free with using dependency graphs A full log, with complete code API/structure/design explanation will follow, that's a load of work... so here below the list with hot changes; - The entire object update system (matrices, geometry) is now centralized. Calls to where_is_object and makeDispList are forbidden, instead we tag objects 'changed' and let the depgraph code sort it out - Removed all old "Ika" code - Depgraph is aware of all relationships, including meta balls, constraints, bevelcurve, and so on. - Made depgraph aware of relation types and layers, to do smart flushing of 'changed' events. Nothing gets calculated too often! - Transform uses depgraph to detect changes - On frame-advance, depgraph flushes animated changes Armatures; Almost all armature related code has been fully built from scratch. It now reveils the original design much better, with a very clean implementation, lag free without even calculating each Bone more than once. Result is quite a speedup yes! Important to note is; 1) Armature is data containing the 'rest position' 2) Pose is the changes of rest position, and always on object level. That way more Objects can use same Pose. Also constraints are in Pose 3) Actions only contain the Ipos to change values in Poses. - Bones draw unrotated now - Drawing bones speedup enormously (10-20 times) - Bone selecting in EditMode, selection state is saved for PoseMode, and vice-versa - Undo in editmode - Bone renaming does vertexgroups, constraints, posechannels, actions, for all users of Armature in entire file - Added Bone renaming in NKey panel - Nkey PoseMode shows eulers now - EditMode and PoseMode now have 'active' bone too (last clicked) - Parenting in EditMode' CTRL+P, ALT+P, with nice options! - Pose is added in Outliner now, with showing that constraints are in the Pose, not Armature - Disconnected IK solving from constraints. It's a separate phase now, on top of the full Pose calculations - Pose itself has a dependency graph too, so evaluation order is lag free. TODO NOW; - Rotating in Posemode has incorrect inverse transform (Martin will fix) - Python Bone/Armature/Pose API disabled... needs full recode too (wait for my doc!) - Game engine will need upgrade too - Depgraph code needs revision, cleanup, can be much faster! (But, compliments for Jean-Luc, it works like a charm!) - IK changed, it now doesnt use previous position to advance to next position anymore. That system looks nice (no flips) but is not well suited for NLA and background render. TODO LATER; We now can do loadsa new nifty features as well; like: - Kill PoseMode (can be option for armatures itself) - Make B-Bones (Bezier, Bspline, like for spines) - Move all silly button level edit to 3d window (like CTRL+I = add IK) - Much better & informative drawing - Fix action/nla editors - Put all ipos in Actions (object, mesh key, lamp color) - Add hooks - Null bones - Much more advanced constraints... Bugfixes; - OGL render (view3d header) had wrong first frame on anim render - Ipo 'recording' mode had wrong playback speed - Vertex-key mode now sticks to show 'active key', until frame change -Ton-
2005-07-03 17:35:38 +00:00
/* patch for error introduced by changing constraints (dunno how) */
/* if con->data type changes, dna cannot resolve the pointer! (ton) */
if (con->data == NULL) {
con->type = CONSTRAINT_TYPE_NULL;
}
/* own ipo, all constraints have it */
con->ipo = newlibadr_us(fd, id->lib, con->ipo); // XXX depreceated - old animation system
}
/* relink all ID-blocks used by the constraints */
cld.fd = fd;
cld.id = id;
id_loop_constraints(conlist, lib_link_constraint_cb, &cld);
}
static void direct_link_constraints(FileData *fd, ListBase *lb)
{
bConstraint *con;
link_list(fd, lb);
for (con=lb->first; con; con=con->next) {
con->data = newdataadr(fd, con->data);
2002-10-12 11:37:38 +00:00
switch (con->type) {
case CONSTRAINT_TYPE_PYTHON:
{
bPythonConstraint *data= con->data;
link_list(fd, &data->targets);
data->prop = newdataadr(fd, data->prop);
if (data->prop)
IDP_DirectLinkProperty(data->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
== 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
}
break;
case CONSTRAINT_TYPE_SPLINEIK:
{
bSplineIKConstraint *data= con->data;
data->points= newdataadr(fd, data->points);
== 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
}
break;
case CONSTRAINT_TYPE_KINEMATIC:
2002-10-12 11:37:38 +00:00
{
con->lin_error = 0.f;
con->rot_error = 0.f;
}
case CONSTRAINT_TYPE_CHILDOF:
{
/* XXX version patch, in older code this flag wasn't always set, and is inherent to type */
if (con->ownspace == CONSTRAINT_SPACE_POSE)
con->flag |= CONSTRAINT_SPACEONCE;
2002-10-12 11:37:38 +00:00
}
break;
}
2002-10-12 11:37:38 +00:00
}
}
Result of 2 weeks of quiet coding work in Greece :) Aim was to get a total refresh of the animation system. This is needed because; - we need to upgrade it with 21st century features - current code is spaghetti/hack combo, and hides good design - it should become lag-free with using dependency graphs A full log, with complete code API/structure/design explanation will follow, that's a load of work... so here below the list with hot changes; - The entire object update system (matrices, geometry) is now centralized. Calls to where_is_object and makeDispList are forbidden, instead we tag objects 'changed' and let the depgraph code sort it out - Removed all old "Ika" code - Depgraph is aware of all relationships, including meta balls, constraints, bevelcurve, and so on. - Made depgraph aware of relation types and layers, to do smart flushing of 'changed' events. Nothing gets calculated too often! - Transform uses depgraph to detect changes - On frame-advance, depgraph flushes animated changes Armatures; Almost all armature related code has been fully built from scratch. It now reveils the original design much better, with a very clean implementation, lag free without even calculating each Bone more than once. Result is quite a speedup yes! Important to note is; 1) Armature is data containing the 'rest position' 2) Pose is the changes of rest position, and always on object level. That way more Objects can use same Pose. Also constraints are in Pose 3) Actions only contain the Ipos to change values in Poses. - Bones draw unrotated now - Drawing bones speedup enormously (10-20 times) - Bone selecting in EditMode, selection state is saved for PoseMode, and vice-versa - Undo in editmode - Bone renaming does vertexgroups, constraints, posechannels, actions, for all users of Armature in entire file - Added Bone renaming in NKey panel - Nkey PoseMode shows eulers now - EditMode and PoseMode now have 'active' bone too (last clicked) - Parenting in EditMode' CTRL+P, ALT+P, with nice options! - Pose is added in Outliner now, with showing that constraints are in the Pose, not Armature - Disconnected IK solving from constraints. It's a separate phase now, on top of the full Pose calculations - Pose itself has a dependency graph too, so evaluation order is lag free. TODO NOW; - Rotating in Posemode has incorrect inverse transform (Martin will fix) - Python Bone/Armature/Pose API disabled... needs full recode too (wait for my doc!) - Game engine will need upgrade too - Depgraph code needs revision, cleanup, can be much faster! (But, compliments for Jean-Luc, it works like a charm!) - IK changed, it now doesnt use previous position to advance to next position anymore. That system looks nice (no flips) but is not well suited for NLA and background render. TODO LATER; We now can do loadsa new nifty features as well; like: - Kill PoseMode (can be option for armatures itself) - Make B-Bones (Bezier, Bspline, like for spines) - Move all silly button level edit to 3d window (like CTRL+I = add IK) - Much better & informative drawing - Fix action/nla editors - Put all ipos in Actions (object, mesh key, lamp color) - Add hooks - Null bones - Much more advanced constraints... Bugfixes; - OGL render (view3d header) had wrong first frame on anim render - Ipo 'recording' mode had wrong playback speed - Vertex-key mode now sticks to show 'active key', until frame change -Ton-
2005-07-03 17:35:38 +00:00
static void lib_link_pose(FileData *fd, Object *ob, bPose *pose)
2002-10-12 11:37:38 +00:00
{
bPoseChannel *pchan;
bArmature *arm = ob->data;
int rebuild;
if (!pose || !arm)
2002-10-12 11:37:38 +00:00
return;
/* always rebuild to match proxy or lib changes */
rebuild = ob->proxy || (ob->id.lib==NULL && arm->id.lib);
if (ob->proxy) {
/* sync proxy layer */
if (pose->proxy_layer)
arm->layer = pose->proxy_layer;
/* sync proxy active bone */
if (pose->proxy_act_bone[0]) {
Bone *bone = BKE_armature_find_bone_name(arm, pose->proxy_act_bone);
if (bone)
arm->act_bone = bone;
}
}
for (pchan = pose->chanbase.first; pchan; pchan=pchan->next) {
lib_link_constraints(fd, (ID *)ob, &pchan->constraints);
/* hurms... loop in a loop, but yah... later... (ton) */
pchan->bone = BKE_armature_find_bone_name(arm, pchan->name);
pchan->custom = newlibadr_us(fd, arm->id.lib, pchan->custom);
if (pchan->bone == NULL)
rebuild= 1;
else if (ob->id.lib==NULL && arm->id.lib) {
/* local pose selection copied to armature, bit hackish */
pchan->bone->flag &= ~BONE_SELECTED;
pchan->bone->flag |= pchan->selectflag;
}
}
if (rebuild) {
ob->recalc = (OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
pose->flag |= POSE_RECALC;
2002-10-12 11:37:38 +00:00
}
}
static void lib_link_armature(FileData *fd, Main *main)
{
bArmature *arm;
for (arm = main->armature.first; arm; arm = arm->id.next) {
if (arm->id.flag & LIB_NEEDLINK) {
if (arm->adt) lib_link_animdata(fd, &arm->id, arm->adt);
2002-10-12 11:37:38 +00:00
arm->id.flag -= LIB_NEEDLINK;
}
}
}
static void direct_link_bones(FileData *fd, Bone* bone)
{
Bone *child;
bone->parent = newdataadr(fd, bone->parent);
bone->prop = newdataadr(fd, bone->prop);
if (bone->prop)
IDP_DirectLinkProperty(bone->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
bone->flag &= ~BONE_DRAW_ACTIVE;
2002-10-12 11:37:38 +00:00
link_list(fd, &bone->childbase);
for (child=bone->childbase.first; child; child=child->next)
2002-10-12 11:37:38 +00:00
direct_link_bones(fd, child);
}
static void direct_link_armature(FileData *fd, bArmature *arm)
{
Bone *bone;
2002-10-12 11:37:38 +00:00
link_list(fd, &arm->bonebase);
arm->edbo = NULL;
arm->sketch = NULL;
arm->adt = newdataadr(fd, arm->adt);
direct_link_animdata(fd, arm->adt);
for (bone = arm->bonebase.first; bone; bone = bone->next) {
2002-10-12 11:37:38 +00:00
direct_link_bones(fd, bone);
}
arm->act_bone = newdataadr(fd, arm->act_bone);
arm->act_edbone = NULL;
2002-10-12 11:37:38 +00:00
}
/* ************ READ CAMERA ***************** */
static void lib_link_camera(FileData *fd, Main *main)
{
Camera *ca;
for (ca = main->camera.first; ca; ca = ca->id.next) {
if (ca->id.flag & LIB_NEEDLINK) {
if (ca->adt) lib_link_animdata(fd, &ca->id, ca->adt);
ca->ipo = newlibadr_us(fd, ca->id.lib, ca->ipo); // XXX depreceated - old animation system
ca->dof_ob = newlibadr_us(fd, ca->id.lib, ca->dof_ob);
2002-10-12 11:37:38 +00:00
ca->id.flag -= LIB_NEEDLINK;
}
}
}
static void direct_link_camera(FileData *fd, Camera *ca)
{
ca->adt = newdataadr(fd, ca->adt);
direct_link_animdata(fd, ca->adt);
2002-10-12 11:37:38 +00:00
}
2002-10-12 11:37:38 +00:00
/* ************ READ LAMP ***************** */
static void lib_link_lamp(FileData *fd, Main *main)
{
Lamp *la;
MTex *mtex;
int a;
for (la = main->lamp.first; la; la = la->id.next) {
if (la->id.flag & LIB_NEEDLINK) {
if (la->adt) lib_link_animdata(fd, &la->id, la->adt);
for (a = 0; a < MAX_MTEX; a++) {
mtex = la->mtex[a];
if (mtex) {
mtex->tex = newlibadr_us(fd, la->id.lib, mtex->tex);
mtex->object = newlibadr(fd, la->id.lib, mtex->object);
2002-10-12 11:37:38 +00:00
}
}
la->ipo = newlibadr_us(fd, la->id.lib, la->ipo); // XXX depreceated - old animation system
if (la->nodetree)
lib_link_ntree(fd, &la->id, la->nodetree);
2002-10-12 11:37:38 +00:00
la->id.flag -= LIB_NEEDLINK;
}
}
}
static void direct_link_lamp(FileData *fd, Lamp *la)
{
int a;
la->adt = newdataadr(fd, la->adt);
direct_link_animdata(fd, la->adt);
for (a=0; a<MAX_MTEX; a++) {
la->mtex[a] = newdataadr(fd, la->mtex[a]);
2002-10-12 11:37:38 +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
la->curfalloff = newdataadr(fd, la->curfalloff);
if (la->curfalloff)
* 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
direct_link_curvemapping(fd, la->curfalloff);
la->nodetree= newdataadr(fd, la->nodetree);
if (la->nodetree)
direct_link_nodetree(fd, la->nodetree);
* 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
la->preview = direct_link_preview_image(fd, la->preview);
2002-10-12 11:37:38 +00:00
}
/* ************ READ keys ***************** */
static void lib_link_key(FileData *fd, Main *main)
{
Key *key;
for (key = main->key.first; key; key = key->id.next) {
/*check if we need to generate unique ids for the shapekeys*/
if (!key->uidgen) {
KeyBlock *block;
key->uidgen = 1;
for (block=key->block.first; block; block=block->next) {
block->uid = key->uidgen++;
}
}
if (key->id.flag & LIB_NEEDLINK) {
if (key->adt) lib_link_animdata(fd, &key->id, key->adt);
key->ipo = newlibadr_us(fd, key->id.lib, key->ipo); // XXX depreceated - old animation system
key->from = newlibadr(fd, key->id.lib, key->from);
2002-10-12 11:37:38 +00:00
key->id.flag -= LIB_NEEDLINK;
}
}
}
static void switch_endian_keyblock(Key *key, KeyBlock *kb)
{
int elemsize, a, b;
char *data, *poin, *cp;
elemsize = key->elemsize;
data = kb->data;
for (a = 0; a < kb->totelem; a++) {
cp = key->elemstr;
poin = data;
while (cp[0]) { /* cp[0] == amount */
switch (cp[1]) { /* cp[1] = type */
case IPO_FLOAT:
case IPO_BPOINT:
case IPO_BEZTRIPLE:
b = cp[0];
while (b--) {
SWITCH_INT((*poin));
poin += 4;
}
break;
2002-10-12 11:37:38 +00:00
}
cp += 2;
2002-10-12 11:37:38 +00:00
}
data+= elemsize;
}
}
static void direct_link_key(FileData *fd, Key *key)
{
KeyBlock *kb;
2002-10-12 11:37:38 +00:00
link_list(fd, &(key->block));
key->adt = newdataadr(fd, key->adt);
direct_link_animdata(fd, key->adt);
2002-10-12 11:37:38 +00:00
key->refkey= newdataadr(fd, key->refkey);
for (kb = key->block.first; kb; kb = kb->next) {
kb->data = newdataadr(fd, kb->data);
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN)
2002-10-12 11:37:38 +00:00
switch_endian_keyblock(key, kb);
}
}
/* ************ READ mball ***************** */
static void lib_link_mball(FileData *fd, Main *main)
{
MetaBall *mb;
int a;
for (mb = main->mball.first; mb; mb = mb->id.next) {
if (mb->id.flag & LIB_NEEDLINK) {
2009-08-03 13:09:23 +00:00
if (mb->adt) lib_link_animdata(fd, &mb->id, mb->adt);
for (a = 0; a < mb->totcol; a++)
mb->mat[a]= newlibadr_us(fd, mb->id.lib, mb->mat[a]);
mb->ipo = newlibadr_us(fd, mb->id.lib, mb->ipo); // XXX depreceated - old animation system
2002-10-12 11:37:38 +00:00
mb->id.flag -= LIB_NEEDLINK;
}
}
}
static void direct_link_mball(FileData *fd, MetaBall *mb)
{
mb->adt = newdataadr(fd, mb->adt);
2009-08-03 13:09:23 +00:00
direct_link_animdata(fd, mb->adt);
mb->mat = newdataadr(fd, mb->mat);
2002-10-12 11:37:38 +00:00
test_pointer_array(fd, (void **)&mb->mat);
2002-10-12 11:37:38 +00:00
link_list(fd, &(mb->elems));
mb->disp.first = mb->disp.last = NULL;
mb->editelems = NULL;
mb->bb = NULL;
/* mb->edit_elems.first= mb->edit_elems.last= NULL;*/
mb->lastelem = NULL;
2002-10-12 11:37:38 +00:00
}
/* ************ READ WORLD ***************** */
static void lib_link_world(FileData *fd, Main *main)
{
World *wrld;
MTex *mtex;
int a;
for (wrld = main->world.first; wrld; wrld = wrld->id.next) {
if (wrld->id.flag & LIB_NEEDLINK) {
if (wrld->adt) lib_link_animdata(fd, &wrld->id, wrld->adt);
wrld->ipo = newlibadr_us(fd, wrld->id.lib, wrld->ipo); // XXX depreceated - old animation system
for (a=0; a < MAX_MTEX; a++) {
mtex = wrld->mtex[a];
if (mtex) {
mtex->tex = newlibadr_us(fd, wrld->id.lib, mtex->tex);
mtex->object = newlibadr(fd, wrld->id.lib, mtex->object);
2002-10-12 11:37:38 +00:00
}
}
if (wrld->nodetree)
lib_link_ntree(fd, &wrld->id, wrld->nodetree);
2002-10-12 11:37:38 +00:00
wrld->id.flag -= LIB_NEEDLINK;
}
}
}
static void direct_link_world(FileData *fd, World *wrld)
{
int a;
wrld->adt = newdataadr(fd, wrld->adt);
direct_link_animdata(fd, wrld->adt);
for (a = 0; a < MAX_MTEX; a++) {
wrld->mtex[a] = newdataadr(fd, wrld->mtex[a]);
2002-10-12 11:37:38 +00:00
}
wrld->nodetree = newdataadr(fd, wrld->nodetree);
if (wrld->nodetree)
direct_link_nodetree(fd, wrld->nodetree);
wrld->preview = direct_link_preview_image(fd, wrld->preview);
2002-10-12 11:37:38 +00:00
}
/* ************ READ VFONT ***************** */
static void lib_link_vfont(FileData *UNUSED(fd), Main *main)
2002-10-12 11:37:38 +00:00
{
VFont *vf;
for (vf = main->vfont.first; vf; vf = vf->id.next) {
if (vf->id.flag & LIB_NEEDLINK) {
2002-10-12 11:37:38 +00:00
vf->id.flag -= LIB_NEEDLINK;
}
}
2002-10-12 11:37:38 +00:00
}
static void direct_link_vfont(FileData *fd, VFont *vf)
{
vf->data = NULL;
vf->packedfile = direct_link_packedfile(fd, vf->packedfile);
2002-10-12 11:37:38 +00:00
}
/* ************ READ TEXT ****************** */
static void lib_link_text(FileData *UNUSED(fd), Main *main)
2002-10-12 11:37:38 +00:00
{
Text *text;
for (text = main->text.first; text; text = text->id.next) {
if (text->id.flag & LIB_NEEDLINK) {
2002-10-12 11:37:38 +00:00
text->id.flag -= LIB_NEEDLINK;
}
}
2002-10-12 11:37:38 +00:00
}
static void direct_link_text(FileData *fd, Text *text)
{
TextLine *ln;
text->name = newdataadr(fd, text->name);
text->undo_pos = -1;
text->undo_len = TXT_INIT_UNDO;
text->undo_buf = MEM_mallocN(text->undo_len, "undo buf");
text->compiled = NULL;
2012-04-22 11:54:53 +00:00
#if 0
if (text->flags & TXT_ISEXT) {
BKE_text_reload(text);
}
else {
2012-04-22 11:54:53 +00:00
#endif
link_list(fd, &text->lines);
link_list(fd, &text->markers);
text->curl = newdataadr(fd, text->curl);
text->sell = newdataadr(fd, text->sell);
for (ln = text->lines.first; ln; ln = ln->next) {
ln->line = newdataadr(fd, ln->line);
ln->format = NULL;
if (ln->len != (int) strlen(ln->line)) {
printf("Error loading text, line lengths differ\n");
ln->len = strlen(ln->line);
2002-10-12 11:37:38 +00:00
}
}
2.5: Text Editor back. There was very little structure in this code, using many globals and duplicated code. Now it should be better structured. Most things should work, the main parts that are not back yet are the python plugins and markers. Notes: * Blenfont is used for drawing the text, nicely anti-aliased. * A monospace truetype font was added, since that is needed for the text editor. It's Bitstream Vera Sans Mono. This is the default gnome terminal font, but it doesn't fit entirely well with the other font I think, can be changed easily of course. * Clipboard copy/cut/paste now always uses the system clipboard, the code for the own cut buffer was removed. * The interface buttons should support copy/cut/paste again now as well. * WM_clipboard_text_get/WM_clipboard_text_set were added to the windowmanager code. * Find panel is now a kind of second header, instead of a panel. This needs especially a way to start editing the text field immediately on open still. * Operators are independent of the actual space when possible, was a bit of puzzling but got it solved nice with notifiers, and some lazy init for syntax highlight in the drawing code. * RNA was created for the text editor space and used for buttons. * Operators: * New, Open, Reload, Save, Save As, Make Internal * Run Script, Refresh Pyconstraints * Copy, Cut, Paste * Convert Whitespace, Uncomment, Comment, Indent, Unindent * Line Break, Insert * Next Marker, Previous Marker, Clear All Markers, Mark All * Select Line, Select All * Jump, Move, Move Select, Delete, Toggle Overwrite * Scroll, Scroll Bar, Set Cursor, Line Number * Find and Replace, Find, Replace, Find Set Selected, Replace Set Selected * To 3D Object * Resolve Conflict
2009-02-28 23:33:35 +00:00
text->flags = (text->flags) & ~TXT_ISEXT;
text->id.us = 1;
2002-10-12 11:37:38 +00:00
}
/* ************ READ IMAGE ***************** */
static void lib_link_image(FileData *fd, Main *main)
{
Image *ima;
for (ima = main->image.first; ima; ima = ima->id.next) {
if (ima->id.flag & LIB_NEEDLINK) {
if (ima->id.properties) IDP_LibLinkProperty(ima->id.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
2002-10-12 11:37:38 +00:00
ima->id.flag -= LIB_NEEDLINK;
}
}
}
static void link_ibuf_list(FileData *fd, ListBase *lb)
{
Link *ln, *prev;
if (lb->first == NULL) return;
lb->first = newimaadr(fd, lb->first);
ln = lb->first;
prev = NULL;
while (ln) {
ln->next = newimaadr(fd, ln->next);
ln->prev = prev;
prev = ln;
ln = ln->next;
}
lb->last = prev;
}
2002-10-12 11:37:38 +00:00
static void direct_link_image(FileData *fd, Image *ima)
{
/* for undo system, pointers could be restored */
if (fd->imamap)
link_ibuf_list(fd, &ima->ibufs);
else
ima->ibufs.first = ima->ibufs.last = NULL;
/* if not restored, we keep the binded opengl index */
if (ima->ibufs.first == NULL) {
ima->bindcode = 0;
ima->gputexture = NULL;
}
ima->anim = NULL;
ima->rr = NULL;
ima->repbind = NULL;
/* undo system, try to restore render buffers */
if (fd->imamap) {
int a;
for (a = 0; a < IMA_MAX_RENDER_SLOT; a++)
ima->renders[a] = newimaadr(fd, ima->renders[a]);
}
else {
memset(ima->renders, 0, sizeof(ima->renders));
ima->last_render_slot = ima->render_slot;
}
2002-10-12 11:37:38 +00:00
ima->packedfile = direct_link_packedfile(fd, ima->packedfile);
ima->preview = direct_link_preview_image(fd, ima->preview);
ima->ok = 1;
2002-10-12 11:37:38 +00:00
}
/* ************ READ CURVE ***************** */
static void lib_link_curve(FileData *fd, Main *main)
{
Curve *cu;
int a;
for (cu = main->curve.first; cu; cu = cu->id.next) {
if (cu->id.flag & LIB_NEEDLINK) {
if (cu->adt) lib_link_animdata(fd, &cu->id, cu->adt);
for (a = 0; a < cu->totcol; a++)
cu->mat[a] = newlibadr_us(fd, cu->id.lib, cu->mat[a]);
cu->bevobj = newlibadr(fd, cu->id.lib, cu->bevobj);
cu->taperobj = newlibadr(fd, cu->id.lib, cu->taperobj);
cu->textoncurve = newlibadr(fd, cu->id.lib, cu->textoncurve);
cu->vfont = newlibadr_us(fd, cu->id.lib, cu->vfont);
cu->vfontb = newlibadr_us(fd, cu->id.lib, cu->vfontb);
cu->vfonti = newlibadr_us(fd, cu->id.lib, cu->vfonti);
cu->vfontbi = newlibadr_us(fd, cu->id.lib, cu->vfontbi);
cu->ipo = newlibadr_us(fd, cu->id.lib, cu->ipo); // XXX depreceated - old animation system
cu->key = newlibadr_us(fd, cu->id.lib, cu->key);
2002-10-12 11:37:38 +00:00
cu->id.flag -= LIB_NEEDLINK;
}
}
}
static void switch_endian_knots(Nurb *nu)
{
int len;
if (nu->knotsu) {
len = KNOTSU(nu);
while (len--) {
2002-10-12 11:37:38 +00:00
SWITCH_INT(nu->knotsu[len]);
}
}
if (nu->knotsv) {
len = KNOTSV(nu);
while (len--) {
2002-10-12 11:37:38 +00:00
SWITCH_INT(nu->knotsv[len]);
}
}
}
static void direct_link_curve(FileData *fd, Curve *cu)
{
Nurb *nu;
TextBox *tb;
cu->adt= newdataadr(fd, cu->adt);
direct_link_animdata(fd, cu->adt);
cu->mat = newdataadr(fd, cu->mat);
2002-10-12 11:37:38 +00:00
test_pointer_array(fd, (void **)&cu->mat);
cu->str = newdataadr(fd, cu->str);
cu->strinfo= newdataadr(fd, cu->strinfo);
cu->tb = newdataadr(fd, cu->tb);
2002-10-12 11:37:38 +00:00
if (cu->vfont == NULL) link_list(fd, &(cu->nurb));
2002-10-12 11:37:38 +00:00
else {
cu->nurb.first=cu->nurb.last= NULL;
tb = MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "TextBoxread");
if (cu->tb) {
memcpy(tb, cu->tb, cu->totbox*sizeof(TextBox));
MEM_freeN(cu->tb);
cu->tb = tb;
}
else {
cu->totbox = 1;
cu->actbox = 1;
cu->tb = tb;
cu->tb[0].w = cu->linewidth;
}
if (cu->wordspace == 0.0f) cu->wordspace = 1.0f;
2002-10-12 11:37:38 +00:00
}
cu->bev.first = cu->bev.last = NULL;
cu->disp.first = cu->disp.last = NULL;
cu->editnurb = NULL;
cu->lastsel = NULL;
cu->path = NULL;
cu->editfont = NULL;
for (nu = cu->nurb.first; nu; nu = nu->next) {
nu->bezt = newdataadr(fd, nu->bezt);
nu->bp = newdataadr(fd, nu->bp);
nu->knotsu = newdataadr(fd, nu->knotsu);
nu->knotsv = newdataadr(fd, nu->knotsv);
if (cu->vfont == NULL) nu->charidx= nu->mat_nr;
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
2002-10-12 11:37:38 +00:00
switch_endian_knots(nu);
}
}
cu->bb = NULL;
2002-10-12 11:37:38 +00:00
}
/* ************ READ TEX ***************** */
static void lib_link_texture(FileData *fd, Main *main)
{
Tex *tex;
for (tex = main->tex.first; tex; tex = tex->id.next) {
if (tex->id.flag & LIB_NEEDLINK) {
if (tex->adt) lib_link_animdata(fd, &tex->id, tex->adt);
tex->ima = newlibadr_us(fd, tex->id.lib, tex->ima);
tex->ipo = newlibadr_us(fd, tex->id.lib, tex->ipo);
if (tex->env)
tex->env->object = newlibadr(fd, tex->id.lib, tex->env->object);
if (tex->pd)
tex->pd->object = newlibadr(fd, tex->id.lib, tex->pd->object);
if (tex->vd)
tex->vd->object = newlibadr(fd, tex->id.lib, tex->vd->object);
if (tex->ot)
tex->ot->object = newlibadr(fd, tex->id.lib, tex->ot->object);
if (tex->nodetree)
lib_link_ntree(fd, &tex->id, tex->nodetree);
2002-10-12 11:37:38 +00:00
tex->id.flag -= LIB_NEEDLINK;
}
}
}
static void direct_link_texture(FileData *fd, Tex *tex)
{
tex->adt = newdataadr(fd, tex->adt);
direct_link_animdata(fd, tex->adt);
tex->coba = newdataadr(fd, tex->coba);
tex->env = newdataadr(fd, tex->env);
if (tex->env) {
tex->env->ima = NULL;
2002-10-12 11:37:38 +00:00
memset(tex->env->cube, 0, 6*sizeof(void *));
tex->env->ok= 0;
}
tex->pd = newdataadr(fd, tex->pd);
if (tex->pd) {
* Volumetrics Removed all the old particle rendering code and options I had in there before, in order to make way for... A new procedural texture: 'Point Density' Point Density is a 3d texture that find the density of a group of 'points' in space and returns that in the texture as an intensity value. Right now, its at an early stage and it's only enabled for particles, but it would be cool to extend it later for things like object vertices, or point cache files from disk - i.e. to import point cloud data into Blender for rendering volumetrically. Currently there are just options for an Object and its particle system number, this is the particle system that will get cached before rendering, and then used for the texture's density estimation. It works totally consistent with as any other procedural texture, so previously where I've mapped a clouds texture to volume density to make some of those test renders, now I just map a point density texture to volume density. Here's a version of the same particle smoke test file from before, updated to use the point density texture instead: http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend There are a few cool things about implementing this as a texture: - The one texture (and cache) can be instanced across many different materials: http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png This means you can calculate and bake one particle system, but render it multiple times across the scene, with different material settings, at no extra memory cost. Right now, the particles are cached in world space, so you have to map it globally, and if you want it offset, you have to do it in the material (as in the file above). I plan to add an option to bake in local space, so you can just map the texture to local and it just works. - It also works for solid surfaces too, it just gets the density at that particular point on the surface, eg: http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov - You can map it to whatever you want, not only density but the various emissions and colours as well. I'd like to investigate using the other outputs in the texture too (like the RGB or normal outputs), perhaps with options to colour by particle age, generating normals for making particle 'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
tex->pd->point_tree = NULL;
tex->pd->coba = newdataadr(fd, tex->pd->coba);
tex->pd->falloff_curve = newdataadr(fd, tex->pd->falloff_curve);
if (tex->pd->falloff_curve) {
direct_link_curvemapping(fd, tex->pd->falloff_curve);
}
* Volumetrics Removed all the old particle rendering code and options I had in there before, in order to make way for... A new procedural texture: 'Point Density' Point Density is a 3d texture that find the density of a group of 'points' in space and returns that in the texture as an intensity value. Right now, its at an early stage and it's only enabled for particles, but it would be cool to extend it later for things like object vertices, or point cache files from disk - i.e. to import point cloud data into Blender for rendering volumetrically. Currently there are just options for an Object and its particle system number, this is the particle system that will get cached before rendering, and then used for the texture's density estimation. It works totally consistent with as any other procedural texture, so previously where I've mapped a clouds texture to volume density to make some of those test renders, now I just map a point density texture to volume density. Here's a version of the same particle smoke test file from before, updated to use the point density texture instead: http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend There are a few cool things about implementing this as a texture: - The one texture (and cache) can be instanced across many different materials: http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png This means you can calculate and bake one particle system, but render it multiple times across the scene, with different material settings, at no extra memory cost. Right now, the particles are cached in world space, so you have to map it globally, and if you want it offset, you have to do it in the material (as in the file above). I plan to add an option to bake in local space, so you can just map the texture to local and it just works. - It also works for solid surfaces too, it just gets the density at that particular point on the surface, eg: http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov - You can map it to whatever you want, not only density but the various emissions and colours as well. I'd like to investigate using the other outputs in the texture too (like the RGB or normal outputs), perhaps with options to colour by particle age, generating normals for making particle 'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
}
tex->vd = newdataadr(fd, tex->vd);
if (tex->vd) {
* Volume Rendering: Voxel data This commit introduces a new texture ('Voxel Data'), used to load up saved voxel data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández with some additional tweaks. Thanks, Raúl! The texture works similar to the existing point density texture, currently it only provides intensity information, which can then be mapped (for example) to density in a volume material. This is an early version, intended to read the voxel format saved by Raúl's command line simulators, in future revisions there's potential for making a more full-featured 'Blender voxel file format', and also for supporting other formats too. Note: Due to some subtleties in Raúl's existing released simulators, in order to load them correctly the voxel data texture, you'll need to raise the 'resolution' value by 2. So if you baked out the simulation at resolution 50, enter 52 for the resolution in the texture panel. This can possibly be fixed in the simulator later on. Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1 and it can appear rotated 90 degrees incorrectly. This will be tackled, for now, probably the easiest way to map it is with and empty, using Map Input -> Object. Smoke test: http://www.vimeo.com/2449270 One more note, trilinear interpolation seems a bit slow at the moment, we'll look into this. For curiosity, while testing/debugging this, I made a script that exports a mesh to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels, rendered as a volume: http://www.vimeo.com/2512028 The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py * Another smaller thing, brought back early ray termination (was disabled previously for debugging) and made it user configurable. It now appears as a new value in the volume material: 'Depth Cutoff'. For some background info on what this does, check: http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/ * Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
tex->vd->dataset = NULL;
tex->vd->ok = 0;
}
else {
if (tex->type == TEX_VOXELDATA)
tex->vd = MEM_callocN(sizeof(VoxelData), "direct_link_texture VoxelData");
* Volume Rendering: Voxel data This commit introduces a new texture ('Voxel Data'), used to load up saved voxel data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández with some additional tweaks. Thanks, Raúl! The texture works similar to the existing point density texture, currently it only provides intensity information, which can then be mapped (for example) to density in a volume material. This is an early version, intended to read the voxel format saved by Raúl's command line simulators, in future revisions there's potential for making a more full-featured 'Blender voxel file format', and also for supporting other formats too. Note: Due to some subtleties in Raúl's existing released simulators, in order to load them correctly the voxel data texture, you'll need to raise the 'resolution' value by 2. So if you baked out the simulation at resolution 50, enter 52 for the resolution in the texture panel. This can possibly be fixed in the simulator later on. Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1 and it can appear rotated 90 degrees incorrectly. This will be tackled, for now, probably the easiest way to map it is with and empty, using Map Input -> Object. Smoke test: http://www.vimeo.com/2449270 One more note, trilinear interpolation seems a bit slow at the moment, we'll look into this. For curiosity, while testing/debugging this, I made a script that exports a mesh to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels, rendered as a volume: http://www.vimeo.com/2512028 The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py * Another smaller thing, brought back early ray termination (was disabled previously for debugging) and made it user configurable. It now appears as a new value in the volume material: 'Depth Cutoff'. For some background info on what this does, check: http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/ * Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
}
tex->ot = newdataadr(fd, tex->ot);
tex->nodetree = newdataadr(fd, tex->nodetree);
if (tex->nodetree)
direct_link_nodetree(fd, tex->nodetree);
tex->preview = direct_link_preview_image(fd, tex->preview);
tex->iuser.ok = 1;
2002-10-12 11:37:38 +00:00
}
/* ************ READ MATERIAL ***************** */
static void lib_link_material(FileData *fd, Main *main)
{
Material *ma;
MTex *mtex;
int a;
for (ma = main->mat.first; ma; ma = ma->id.next) {
if (ma->id.flag & LIB_NEEDLINK) {
if (ma->adt) lib_link_animdata(fd, &ma->id, ma->adt);
2012-04-22 11:54:53 +00:00
/* Link ID Properties -- and copy this comment EXACTLY for easy finding
* of library blocks that implement this.*/
if (ma->id.properties) IDP_LibLinkProperty(ma->id.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
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
ma->ipo = newlibadr_us(fd, ma->id.lib, ma->ipo);
ma->group = newlibadr_us(fd, ma->id.lib, ma->group);
for (a = 0; a < MAX_MTEX; a++) {
mtex = ma->mtex[a];
if (mtex) {
mtex->tex = newlibadr_us(fd, ma->id.lib, mtex->tex);
mtex->object = newlibadr(fd, ma->id.lib, mtex->object);
2002-10-12 11:37:38 +00:00
}
}
if (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
lib_link_ntree(fd, &ma->id, 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
2002-10-12 11:37:38 +00:00
ma->id.flag -= LIB_NEEDLINK;
}
}
}
static void direct_link_material(FileData *fd, Material *ma)
{
int a;
ma->adt = newdataadr(fd, ma->adt);
direct_link_animdata(fd, ma->adt);
for (a = 0; a < MAX_MTEX; a++) {
ma->mtex[a] = newdataadr(fd, ma->mtex[a]);
2002-10-12 11:37:38 +00:00
}
ma->ramp_col = newdataadr(fd, ma->ramp_col);
ma->ramp_spec = newdataadr(fd, ma->ramp_spec);
ma->nodetree = newdataadr(fd, ma->nodetree);
if (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
direct_link_nodetree(fd, ma->nodetree);
ma->preview = direct_link_preview_image(fd, ma->preview);
ma->gpumaterial.first = ma->gpumaterial.last = NULL;
2002-10-12 11:37:38 +00:00
}
/* ************ READ PARTICLE SETTINGS ***************** */
/* update this also to writefile.c */
static const char *ptcache_data_struct[] = {
"", // 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:
};
Point Cache Refactoring ======================= Caching and Baking: - The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates. - There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles. - The cloth autoprotect feature was removed. - The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries. - The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions. - PointCache struct was added to DNA and is automatically allocated for each physics type. - Soft body now supports Bake Editing just like cloth. - Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now. Library Linking: - Added some more warnings to prevent editing settings on library linked objects. - Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked. - Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh). Physics UI: - Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth. - Tweaked field panel buttons to not jump around when changing options. - Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable. - I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers. - Fixed modifier error drawing glitch. Particles: - Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() .. - Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading. - Make particle threads work with autothreads. Continue Physics: - The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache. - This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics. Todo: - Point cache can get out of sync with and undo and changing a file without saving it. - Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion. - Menu item and/or buttons for Ctrl+B. - A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested. - The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
static void direct_link_pointcache(FileData *fd, PointCache *cache)
{
if ((cache->flag & PTCACHE_DISK_CACHE)==0) {
PTCacheMem *pm;
PTCacheExtra *extra;
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
int i;
link_list(fd, &cache->mem_cache);
pm = cache->mem_cache.first;
for (; pm; pm=pm->next) {
for (i=0; i<BPHYS_TOT_DATA; i++) {
pm->data[i] = newdataadr(fd, pm->data[i]);
/* the cache saves non-struct data without DNA */
if (pm->data[i] && ptcache_data_struct[i][0]=='\0' && (fd->flags & FD_FLAGS_SWITCH_ENDIAN)) {
int j, tot = (BKE_ptcache_data_size (i) * pm->totpoint)/4; /* data_size returns bytes */
int *poin = pm->data[i];
for (j = 0; j < tot; j++)
SWITCH_INT(poin[j]);
}
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
}
link_list(fd, &pm->extradata);
for (extra=pm->extradata.first; extra; extra=extra->next)
extra->data = newdataadr(fd, 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
}
}
else
cache->mem_cache.first = cache->mem_cache.last = NULL;
2009-09-16 17:43:09 +00:00
cache->flag &= ~PTCACHE_SIMULATION_VALID;
cache->simframe = 0;
cache->edit = NULL;
cache->free_edit = NULL;
cache->cached_frames = NULL;
Point Cache Refactoring ======================= Caching and Baking: - The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates. - There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles. - The cloth autoprotect feature was removed. - The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries. - The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions. - PointCache struct was added to DNA and is automatically allocated for each physics type. - Soft body now supports Bake Editing just like cloth. - Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now. Library Linking: - Added some more warnings to prevent editing settings on library linked objects. - Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked. - Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh). Physics UI: - Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth. - Tweaked field panel buttons to not jump around when changing options. - Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable. - I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers. - Fixed modifier error drawing glitch. Particles: - Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() .. - Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading. - Make particle threads work with autothreads. Continue Physics: - The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache. - This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics. Todo: - Point cache can get out of sync with and undo and changing a file without saving it. - Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion. - Menu item and/or buttons for Ctrl+B. - A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested. - The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
}
static void direct_link_pointcache_list(FileData *fd, ListBase *ptcaches, PointCache **ocache, int force_disk)
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 (ptcaches->first) {
PointCache *cache= NULL;
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
link_list(fd, ptcaches);
for (cache=ptcaches->first; cache; cache=cache->next) {
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
direct_link_pointcache(fd, cache);
if (force_disk) {
cache->flag |= PTCACHE_DISK_CACHE;
cache->step = 1;
}
}
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
*ocache = newdataadr(fd, *ocache);
}
else if (*ocache) {
/* old "single" caches need to be linked too */
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
*ocache = newdataadr(fd, *ocache);
direct_link_pointcache(fd, *ocache);
if (force_disk) {
(*ocache)->flag |= PTCACHE_DISK_CACHE;
(*ocache)->step = 1;
}
ptcaches->first = ptcaches->last = *ocache;
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 lib_link_partdeflect(FileData *fd, ID *id, PartDeflect *pd)
{
if (pd && pd->tex)
pd->tex = newlibadr_us(fd, id->lib, pd->tex);
}
static void lib_link_particlesettings(FileData *fd, Main *main)
{
ParticleSettings *part;
ParticleDupliWeight *dw;
MTex *mtex;
int a;
for (part = main->particle.first; part; part = part->id.next) {
if (part->id.flag & LIB_NEEDLINK) {
if (part->adt) lib_link_animdata(fd, &part->id, part->adt);
part->ipo = newlibadr_us(fd, part->id.lib, part->ipo); // XXX depreceated - old animation system
part->dup_ob = newlibadr(fd, part->id.lib, part->dup_ob);
part->dup_group = newlibadr(fd, part->id.lib, part->dup_group);
part->eff_group = newlibadr(fd, part->id.lib, part->eff_group);
part->bb_ob = newlibadr(fd, part->id.lib, part->bb_ob);
lib_link_partdeflect(fd, &part->id, part->pd);
lib_link_partdeflect(fd, &part->id, part->pd2);
if (part->effector_weights)
part->effector_weights->group = newlibadr(fd, part->id.lib, part->effector_weights->group);
if (part->dupliweights.first && part->dup_group) {
int index_ok = 0;
/* check for old files without indices (all indexes 0) */
dw = part->dupliweights.first;
if (part->dupliweights.first == part->dupliweights.last) {
/* special case for only one object in the group */
index_ok = 1;
}
else {
for (; dw; dw=dw->next) {
if (dw->index > 0) {
index_ok = 1;
break;
}
}
}
if (index_ok) {
/* if we have indexes, let's use them */
dw = part->dupliweights.first;
for (; dw; dw=dw->next) {
GroupObject *go = (GroupObject *)BLI_findlink(&part->dup_group->gobject, dw->index);
dw->ob = go ? go->ob : NULL;
}
}
else {
/* otherwise try to get objects from own library (won't work on library linked groups) */
for (; dw; dw=dw->next)
dw->ob = newlibadr(fd, part->id.lib, dw->ob);
}
}
else {
part->dupliweights.first = part->dupliweights.last = NULL;
}
if (part->boids) {
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
BoidState *state = part->boids->states.first;
BoidRule *rule;
for (; state; state=state->next) {
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
rule = state->rules.first;
for (; rule; rule=rule->next)
switch (rule->type) {
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
case eBoidRuleType_Goal:
case eBoidRuleType_Avoid:
{
BoidRuleGoalAvoid *brga = (BoidRuleGoalAvoid*)rule;
brga->ob = newlibadr(fd, part->id.lib, brga->ob);
break;
}
case eBoidRuleType_FollowLeader:
{
BoidRuleFollowLeader *brfl = (BoidRuleFollowLeader*)rule;
brfl->ob = newlibadr(fd, part->id.lib, brfl->ob);
break;
}
}
}
}
for (a = 0; a < MAX_MTEX; a++) {
mtex= part->mtex[a];
if (mtex) {
mtex->tex = newlibadr_us(fd, part->id.lib, mtex->tex);
mtex->object = newlibadr(fd, part->id.lib, mtex->object);
}
}
part->id.flag -= LIB_NEEDLINK;
}
}
}
static void direct_link_partdeflect(PartDeflect *pd)
{
if (pd) pd->rng = NULL;
}
static void direct_link_particlesettings(FileData *fd, ParticleSettings *part)
{
int a;
part->adt = newdataadr(fd, part->adt);
part->pd = newdataadr(fd, part->pd);
part->pd2 = newdataadr(fd, part->pd2);
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
direct_link_animdata(fd, part->adt);
direct_link_partdeflect(part->pd);
direct_link_partdeflect(part->pd2);
part->effector_weights = newdataadr(fd, part->effector_weights);
if (!part->effector_weights)
part->effector_weights = BKE_add_effector_weights(part->eff_group);
link_list(fd, &part->dupliweights);
part->boids = newdataadr(fd, part->boids);
part->fluid = newdataadr(fd, part->fluid);
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
if (part->boids) {
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
BoidState *state;
link_list(fd, &part->boids->states);
for (state=part->boids->states.first; state; state=state->next) {
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
link_list(fd, &state->rules);
link_list(fd, &state->conditions);
link_list(fd, &state->actions);
}
}
for (a = 0; a < MAX_MTEX; a++) {
part->mtex[a] = newdataadr(fd, part->mtex[a]);
}
}
static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase *particles)
{
ParticleSystem *psys, *psysnext;
for (psys=particles->first; psys; psys=psysnext) {
psysnext = psys->next;
psys->part = newlibadr_us(fd, id->lib, psys->part);
if (psys->part) {
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
ParticleTarget *pt = psys->targets.first;
for (; pt; pt=pt->next)
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
pt->ob=newlibadr(fd, id->lib, pt->ob);
psys->parent = newlibadr_us(fd, id->lib, psys->parent);
psys->target_ob = newlibadr(fd, id->lib, psys->target_ob);
if (psys->clmd) {
/* XXX - from reading existing code this seems correct but intended usage of
* pointcache should /w cloth should be added in 'ParticleSystem' - campbell */
psys->clmd->point_cache = psys->pointcache;
psys->clmd->ptcaches.first = psys->clmd->ptcaches.last= NULL;
psys->clmd->coll_parms->group = newlibadr(fd, id->lib, psys->clmd->coll_parms->group);
}
}
else {
/* particle modifier must be removed before particle system */
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
BLI_remlink(&ob->modifiers, psmd);
modifier_free((ModifierData *)psmd);
BLI_remlink(particles, psys);
MEM_freeN(psys);
}
}
}
static void direct_link_particlesystems(FileData *fd, ListBase *particles)
{
ParticleSystem *psys;
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
ParticleData *pa;
int a;
for (psys=particles->first; psys; psys=psys->next) {
2012-04-29 15:47:02 +00:00
psys->particles=newdataadr(fd, psys->particles);
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
if (psys->particles && psys->particles->hair) {
2012-04-29 15:47:02 +00:00
for (a=0, pa=psys->particles; a<psys->totpart; a++, pa++)
pa->hair=newdataadr(fd, pa->hair);
}
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
if (psys->particles && psys->particles->keys) {
2012-04-29 15:47:02 +00:00
for (a=0, pa=psys->particles; a<psys->totpart; a++, pa++) {
Point Cache Refactoring ======================= Caching and Baking: - The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates. - There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles. - The cloth autoprotect feature was removed. - The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries. - The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions. - PointCache struct was added to DNA and is automatically allocated for each physics type. - Soft body now supports Bake Editing just like cloth. - Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now. Library Linking: - Added some more warnings to prevent editing settings on library linked objects. - Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked. - Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh). Physics UI: - Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth. - Tweaked field panel buttons to not jump around when changing options. - Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable. - I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers. - Fixed modifier error drawing glitch. Particles: - Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() .. - Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading. - Make particle threads work with autothreads. Continue Physics: - The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache. - This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics. Todo: - Point cache can get out of sync with and undo and changing a file without saving it. - Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion. - Menu item and/or buttons for Ctrl+B. - A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested. - The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
pa->keys= NULL;
pa->totkey= 0;
}
Point Cache Refactoring ======================= Caching and Baking: - The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates. - There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles. - The cloth autoprotect feature was removed. - The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries. - The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions. - PointCache struct was added to DNA and is automatically allocated for each physics type. - Soft body now supports Bake Editing just like cloth. - Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now. Library Linking: - Added some more warnings to prevent editing settings on library linked objects. - Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked. - Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh). Physics UI: - Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth. - Tweaked field panel buttons to not jump around when changing options. - Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable. - I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers. - Fixed modifier error drawing glitch. Particles: - Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() .. - Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading. - Make particle threads work with autothreads. Continue Physics: - The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache. - This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics. Todo: - Point cache can get out of sync with and undo and changing a file without saving it. - Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion. - Menu item and/or buttons for Ctrl+B. - A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested. - The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
psys->flag &= ~PSYS_KEYED;
}
if (psys->particles && psys->particles->boid) {
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
pa = psys->particles;
pa->boid = newdataadr(fd, pa->boid);
2012-04-29 15:47:02 +00:00
for (a=1, pa++; a<psys->totpart; a++, pa++)
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
pa->boid = (pa-1)->boid + 1;
}
else if (psys->particles) {
2012-04-29 15:47:02 +00:00
for (a=0, pa=psys->particles; a<psys->totpart; a++, pa++)
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
pa->boid = NULL;
}
psys->fluid_springs = newdataadr(fd, psys->fluid_springs);
2012-04-29 15:47:02 +00:00
psys->child = newdataadr(fd, psys->child);
psys->effectors = NULL;
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
link_list(fd, &psys->targets);
2009-09-16 17:43:09 +00:00
psys->edit = NULL;
psys->free_edit = NULL;
psys->pathcache = NULL;
psys->childcache = NULL;
psys->pathcachebufs.first = psys->pathcachebufs.last = NULL;
psys->childcachebufs.first = psys->childcachebufs.last = NULL;
psys->frand = NULL;
psys->pdd = NULL;
psys->renderdata = NULL;
direct_link_pointcache_list(fd, &psys->ptcaches, &psys->pointcache, 0);
if (psys->clmd) {
2009-09-16 17:43:09 +00:00
psys->clmd = newdataadr(fd, psys->clmd);
psys->clmd->clothObject = NULL;
psys->clmd->sim_parms= newdataadr(fd, psys->clmd->sim_parms);
psys->clmd->sim_parms->effector_weights = NULL;
2009-09-16 17:43:09 +00:00
psys->clmd->coll_parms= newdataadr(fd, psys->clmd->coll_parms);
if (psys->clmd->sim_parms) {
if (psys->clmd->sim_parms->presets > 10)
2009-09-16 17:43:09 +00:00
psys->clmd->sim_parms->presets = 0;
}
2009-09-16 17:43:09 +00:00
psys->hair_in_dm = psys->hair_out_dm = NULL;
2009-09-16 17:43:09 +00:00
psys->clmd->point_cache = psys->pointcache;
}
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
psys->tree = NULL;
Completely refactored sph fluid particles. Only the very core of the algorithm remains the same, but big changes have happened both on the outside and on the inside. New UI: * The old parameters were quite true to the underlying algorithm, but were quite obscure from a users point of view. Now there are only a few intuitive basic parameters that define the basic fluid behavior. ** By default particle size is now used to determine the interaction radius, rest density and spring rest lengths so that it's easy to get stable simulations by simply emitting particles for a few frames and adjusting the particle size (easy when the particle size is drawn) so that the fluid appears continuous (particles are touching eachother). ** Stiffness - in reality most fluids are very incompressible, but this is a very hard problem to solve with particle based fluid simulation so some compromises have to be made. So the bigger the stiffness parameter is the less the fluid will compress under stress, but the more substeps are needed for stable simulation. ** Viscosity - how much internal friction there is in the fluid. Large viscosities also smooth out instabilities, so less viscous fluids again need more substeps to remain stable. ** Buoancy - with high buoancy low pressure areas inside the fluid start to rise against gravity, and high pressure areas start to come down. * In addition to these basic parameters there are separate advanced parameters that can either be tweaked relative to the basic parameters (or particle size) or defined independently. ** Repulsion - the stiffness parameter tries to keep the fluid density constant, but this can lead to small clumps of particles, so the repulsion keeps the particles better separated. ** Stiff viscosity - the normal viscosity only applies when particles are moving closer to eachother to allow free flowing fluids. Stiff viscosity also applies smoothing to particles that are moving away from eachother. ** Interaction radius - by default this is 4 * particle size. ** Rest density - by default this is a density that the particles have when they're packed densely next to eachother. ** Spring rest length - by default this is 2 * particle size. * There are also new options for 3d view particle coloring in the display panel to show particle velocity and acceleration. These make it easier to see what's happening in the fluid simulations, but can of course be used with other particles as well. * Viscoelastic springs have some new options too. The plasticity can now be set to much higher values for instant deletion of springs as the elastic limit is exeeded. In addition to that there is an option to only create springs for a certain number of frames when a particle is born. These options give new possibilities for breaking viscoelastic fluids. New in the code: * Most of the fluids code is now thread safe, so when particle dynamics go threaded there will be a nice speed boost to fluids as well. * Fluids now use a bvh-tree instead of a kd-tree for the neighbor lookups. The bvh-tree implementation makes the code quite a bit cleaner and should also give a slight speed boost to the simulation too. * Previously only force fields were calculated with the different integration methods, but now the fluid calculations are also done using the selected integration method, so there are again more choices in effecting simulation accuracy and stability. This change also included a nice cleanup of the whole particle integration code. As the internals are pretty stirred up old particle fluid simulations will probably not work correctly straight away, but with some tweaking the same level of control is still available by not using the "relative versions" of the advanced parameters (by default these are not used when loading old files).
2011-03-12 12:38:11 +00:00
psys->bvhtree = NULL;
}
return;
2002-10-12 11:37:38 +00:00
}
/* ************ READ MESH ***************** */
2006-11-21 16:54:00 +00:00
static void lib_link_mtface(FileData *fd, Mesh *me, MTFace *mtface, int totface)
{
MTFace *tf= mtface;
int i;
/* Add pseudo-references (not fake users!) to images used by texface. A
* little bogus; it would be better if each mesh consistently added one ref
* to each image it used. - z0r */
for (i = 0; i < totface; i++, tf++) {
2006-11-21 16:54:00 +00:00
tf->tpage= newlibadr(fd, me->id.lib, tf->tpage);
if (tf->tpage && tf->tpage->id.us==0)
2006-11-21 16:54:00 +00:00
tf->tpage->id.us= 1;
}
}
static void lib_link_customdata_mtface(FileData *fd, Mesh *me, CustomData *fdata, int totface)
{
int i;
for (i = 0; i < fdata->totlayer; i++) {
CustomDataLayer *layer = &fdata->layers[i];
if (layer->type == CD_MTFACE)
lib_link_mtface(fd, me, layer->data, totface);
}
}
static void lib_link_customdata_mtpoly(FileData *fd, Mesh *me, CustomData *pdata, int totface)
{
int i;
for (i=0; i < pdata->totlayer; i++) {
CustomDataLayer *layer = &pdata->layers[i];
if (layer->type == CD_MTEXPOLY) {
MTexPoly *tf= layer->data;
int i;
for (i = 0; i < totface; i++, tf++) {
tf->tpage = newlibadr(fd, me->id.lib, tf->tpage);
if (tf->tpage && tf->tpage->id.us==0)
tf->tpage->id.us = 1;
}
}
}
}
2002-10-12 11:37:38 +00:00
static void lib_link_mesh(FileData *fd, Main *main)
{
Mesh *me;
for (me = main->mesh.first; me; me = me->id.next) {
if (me->id.flag & LIB_NEEDLINK) {
2002-10-12 11:37:38 +00:00
int i;
2012-04-22 11:54:53 +00:00
/* Link ID Properties -- and copy this comment EXACTLY for easy finding
* of library blocks that implement this.*/
if (me->id.properties) IDP_LibLinkProperty(me->id.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
if (me->adt) lib_link_animdata(fd, &me->id, me->adt);
/* this check added for python created meshes */
if (me->mat) {
for (i = 0; i < me->totcol; i++) {
me->mat[i] = newlibadr_us(fd, me->id.lib, me->mat[i]);
}
}
else me->totcol = 0;
me->ipo = newlibadr_us(fd, me->id.lib, me->ipo); // XXX: deprecated: old anim sys
me->key = newlibadr_us(fd, me->id.lib, me->key);
me->texcomesh = newlibadr_us(fd, me->id.lib, me->texcomesh);
lib_link_customdata_mtface(fd, me, &me->fdata, me->totface);
lib_link_customdata_mtpoly(fd, me, &me->pdata, me->totpoly);
if (me->mr && me->mr->levels.first)
lib_link_customdata_mtface(fd, me, &me->mr->fdata,
((MultiresLevel*)me->mr->levels.first)->totface);
2011-03-31 00:52:12 +00:00
/*check if we need to convert mfaces to mpolys*/
if (me->totface && !me->totpoly) {
/* temporarily switch main so that reading from
2012-04-22 11:54:53 +00:00
* external CustomData works */
Main *gmain = G.main;
G.main = main;
BKE_mesh_do_versions_convert_mfaces_to_mpolys(me);
G.main = gmain;
2011-03-31 00:52:12 +00:00
}
/*
* Re-tessellate, even if the polys were just created from tessfaces, this
* is important because it:
* - fill the CD_POLYINDEX layer
* - gives consistency of tessface between loading from a file and
* converting an edited BMesh back into a mesh (i.e. it replaces
* quad tessfaces in a loaded mesh immediately, instead of lazily
* waiting until edit mode has been entered/exited, making it easier
* to recognize problems that would otherwise only show up after edits).
*/
#ifdef USE_TESSFACE_DEFAULT
BKE_mesh_tessface_calc(me);
#else
BKE_mesh_tessface_clear(me);
#endif
2002-10-12 11:37:38 +00:00
me->id.flag -= LIB_NEEDLINK;
}
}
TexFace to Material Settings big patch Summary: ======== The idea here is to move the texface options into the material panel. For images with the change please visit: http://code.blender.org/index.php/2011/09/bge-material-texface-changes 1 - Some of the legacy problems 2.49 and 2.5x has with the texface system: ========================================================================== 1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can select a face to be more than one mode. 1.2) Sort only works for blend Alpha yet it's an option regardless of the Transparency Blend you pick. 1.3) Shared doesn't affect anything in BGE. 1.4) ObColor only works for Text objects (old bitmap texts) when using Texture Face Materials. (not address yet, I so far ignored obcolor) 2 - Notes: ============ 2.1) Now "Use Face Textures" in material Option panel will work in Multitexture even if there is no texture channel. 2.2) In FaceTexture mode it will use TexFace all the time, even if you don't check the "Use Texture Face" option in the UI. It's a matter of decision, since the code for either way is there. I decided by the solution that makes the creation of a material fast - in this mode the user doesn't need to mess with textures or this "Use Texture Face" option at all. I'm not strong in my opinion here. But I think if we don't have this then what is the point of the Texture Face mode? 2.3) I kept references for tface only when we need the image, UV or the tiling setting. It should help later when/if we split the Image and UV layers from the tface struct (Campbell and Brecht proposal). 3 - Changes in a Nutshell: ========================== 3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set. 3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …). 3.3) New options in the Material Panel * Shadeless option in the Material panel is now supported for all three Shading modes. * Physics is now toggleable, this is the old Collision option. * Two Side (on) is now called Back Culling (off). * Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid). * Shadow, Billboard and Halo are grouped in the “Face Orientation” property. * "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually). * The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties. 4 - Acknowledgment: ================== Mike Pan for the design discussions, and testing along the whole development process. Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that. Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems). Blender artists that gave feedback and helped testing the patch. Patch review and original documentation can be found here: http://wiki.blender.org/index.php/User:Dfelinto/TexFace http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
/* convert texface options to material */
convert_tface_mt(fd, main);
2002-10-12 11:37:38 +00:00
}
static void direct_link_dverts(FileData *fd, int count, MDeformVert *mdverts)
{
int i;
if (mdverts == NULL) {
2002-10-12 11:37:38 +00:00
return;
}
for (i = count; i > 0; i--, mdverts++) {
/*convert to vgroup allocation system*/
2011-05-11 09:31:00 +00:00
MDeformWeight *dw;
if (mdverts->dw && (dw = newdataadr(fd, mdverts->dw))) {
const ssize_t dw_len = mdverts->totweight * sizeof(MDeformWeight);
void *dw_tmp = MEM_mallocN(dw_len, "direct_link_dverts");
2011-05-11 09:31:00 +00:00
memcpy(dw_tmp, dw, dw_len);
mdverts->dw = dw_tmp;
2011-05-11 09:31:00 +00:00
MEM_freeN(dw);
}
else {
mdverts->dw = NULL;
mdverts->totweight = 0;
2011-05-11 09:31:00 +00:00
}
2002-10-12 11:37:38 +00:00
}
}
static void direct_link_mdisps(FileData *fd, int count, MDisps *mdisps, int external)
{
if (mdisps) {
int i;
for (i = 0; i < count; ++i) {
mdisps[i].disps = newdataadr(fd, mdisps[i].disps);
mdisps[i].hidden = newdataadr(fd, mdisps[i].hidden);
if (mdisps[i].totdisp && !mdisps[i].level) {
/* this calculation is only correct for loop mdisps;
2012-04-22 11:54:53 +00:00
* if loading pre-BMesh face mdisps this will be
* overwritten with the correct value in
* bm_corners_to_loops() */
float gridsize = sqrtf(mdisps[i].totdisp);
2012-05-05 21:28:12 +00:00
mdisps[i].level = (int)(logf(gridsize - 1.0f) / (float)M_LN2) + 1;
}
if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN) && (mdisps[i].disps)) {
/* DNA_struct_switch_endian doesn't do endian swap for (*disps)[] */
/* this does swap for data written at write_mdisps() - readfile.c */
int x;
float *tmpdisps = *mdisps[i].disps;
for (x = 0; x < mdisps[i].totdisp * 3; x++) {
SWITCH_INT(*tmpdisps);
tmpdisps++;
}
}
if (!external && !mdisps[i].disps)
mdisps[i].totdisp = 0;
}
}
}
static void direct_link_grid_paint_mask(FileData *fd, int count, GridPaintMask *grid_paint_mask)
{
if (grid_paint_mask) {
int i;
for (i = 0; i < count; ++i) {
GridPaintMask *gpm = &grid_paint_mask[i];
if (gpm->data)
gpm->data = newdataadr(fd, gpm->data);
}
}
}
/*this isn't really a public api function, so prototyped here*/
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
static void direct_link_customdata(FileData *fd, CustomData *data, int count)
{
int i = 0;
data->layers = newdataadr(fd, data->layers);
/* annoying workaround for bug [#31079] loading legacy files with
* no polygons _but_ have stale customdata */
if (UNLIKELY(count == 0 && data->layers == NULL && data->totlayer != 0)) {
memset(data, 0, sizeof(*data));
return;
}
data->external = newdataadr(fd, 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
while (i < data->totlayer) {
CustomDataLayer *layer = &data->layers[i];
if (layer->flag & CD_FLAG_EXTERNAL)
layer->flag &= ~CD_FLAG_IN_MEMORY;
if (CustomData_verify_versions(data, i)) {
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
layer->data = newdataadr(fd, layer->data);
if (layer->type == CD_MDISPS)
direct_link_mdisps(fd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL);
2012-05-22 22:03:41 +00:00
else if (layer->type == CD_GRID_PAINT_MASK)
direct_link_grid_paint_mask(fd, count, layer->data);
Added custom vertex/edge/face data for meshes: All data layers, including MVert/MEdge/MFace, are now managed as custom data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are still used of course, but allocating, copying or freeing these arrays should be done through the CustomData API. Work in progress documentation on this is here: http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData Replaced TFace by MTFace: This is the same struct, except that it does not contain color, that now always stays separated in MCol. This was not a good design decision to begin with, and it is needed for adding multiple color layers later. Note that this does mean older Blender versions will not be able to read UV coordinates from the next release, due to an SDNA limitation. Removed DispListMesh: This now fully replaced by DerivedMesh. To provide access to arrays of vertices, edges and faces, like DispListMesh does. The semantics of the DerivedMesh.getVertArray() and similar functions were changed to return a pointer to an array if one exists, or otherwise allocate a temporary one. On releasing the DerivedMesh, this temporary array will be removed automatically. Removed ssDM and meshDM DerivedMesh backends: The ssDM backend was for DispListMesh, so that became obsolete automatically. The meshDM backend was replaced by the custom data backend, that now figures out which layers need to be modified, and only duplicates those. This changes code in many places, and overall removes 2514 lines of code. So, there's a good chance this might break some stuff, although I've been testing it for a few days now. The good news is, adding multiple color and uv layers should now become easy.
2006-11-20 04:28:02 +00:00
i++;
}
}
CustomData_update_typemap(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
}
2002-10-12 11:37:38 +00:00
static void direct_link_mesh(FileData *fd, Mesh *mesh)
{
mesh->mat= newdataadr(fd, mesh->mat);
test_pointer_array(fd, (void **)&mesh->mat);
mesh->mvert = newdataadr(fd, mesh->mvert);
mesh->medge = newdataadr(fd, mesh->medge);
mesh->mface = newdataadr(fd, mesh->mface);
mesh->mloop = newdataadr(fd, mesh->mloop);
mesh->mpoly = newdataadr(fd, mesh->mpoly);
mesh->tface = newdataadr(fd, mesh->tface);
mesh->mtface = newdataadr(fd, mesh->mtface);
mesh->mcol = newdataadr(fd, mesh->mcol);
mesh->msticky = newdataadr(fd, mesh->msticky);
mesh->dvert = newdataadr(fd, mesh->dvert);
mesh->mloopcol = newdataadr(fd, mesh->mloopcol);
mesh->mloopuv = newdataadr(fd, mesh->mloopuv);
mesh->mtpoly = newdataadr(fd, mesh->mtpoly);
mesh->mselect = newdataadr(fd, mesh->mselect);
/* animdata */
mesh->adt = newdataadr(fd, mesh->adt);
direct_link_animdata(fd, mesh->adt);
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
/* normally direct_link_dverts should be called in direct_link_customdata,
2012-04-22 11:54:53 +00:00
* but for backwards compat in do_versions to work we do it here */
direct_link_dverts(fd, mesh->totvert, mesh->dvert);
direct_link_customdata(fd, &mesh->vdata, mesh->totvert);
direct_link_customdata(fd, &mesh->edata, mesh->totedge);
direct_link_customdata(fd, &mesh->fdata, mesh->totface);
direct_link_customdata(fd, &mesh->ldata, mesh->totloop);
direct_link_customdata(fd, &mesh->pdata, mesh->totpoly);
#ifdef USE_BMESH_FORWARD_COMPAT
/* NEVER ENABLE THIS CODE INTO BMESH!
* THIS IS FOR LOADING BMESH INTO OLDER FILES ONLY */
mesh->mpoly = newdataadr(fd, mesh->mpoly);
mesh->mloop = newdataadr(fd, mesh->mloop);
direct_link_customdata(fd, &mesh->pdata, mesh->totpoly);
direct_link_customdata(fd, &mesh->ldata, mesh->totloop);
if (mesh->mpoly) {
/* be clever and load polygons as mfaces */
2012-05-05 21:28:12 +00:00
mesh->totface= BKE_mesh_mpoly_to_mface(&mesh->fdata, &mesh->ldata, &mesh->pdata,
mesh->totface, mesh->totloop, mesh->totpoly);
CustomData_free(&mesh->pdata, mesh->totpoly);
memset(&mesh->pdata, 0, sizeof(CustomData));
mesh->totpoly = 0;
CustomData_free(&mesh->ldata, mesh->totloop);
memset(&mesh->ldata, 0, sizeof(CustomData));
mesh->totloop = 0;
mesh_update_customdata_pointers(mesh);
}
#endif
mesh->bb = NULL;
mesh->edit_btmesh = NULL;
/* Multires data */
mesh->mr= newdataadr(fd, mesh->mr);
if (mesh->mr) {
MultiresLevel *lvl;
link_list(fd, &mesh->mr->levels);
lvl = mesh->mr->levels.first;
direct_link_customdata(fd, &mesh->mr->vdata, lvl->totvert);
direct_link_dverts(fd, lvl->totvert, CustomData_get(&mesh->mr->vdata, 0, CD_MDEFORMVERT));
direct_link_customdata(fd, &mesh->mr->fdata, lvl->totface);
mesh->mr->edge_flags = newdataadr(fd, mesh->mr->edge_flags);
mesh->mr->edge_creases = newdataadr(fd, mesh->mr->edge_creases);
mesh->mr->verts = newdataadr(fd, mesh->mr->verts);
/* If mesh has the same number of vertices as the
2012-04-22 11:54:53 +00:00
* highest multires level, load the current mesh verts
* into multires and discard the old data. Needed
* because some saved files either do not have a verts
* array, or the verts array contains out-of-date
* data. */
if (mesh->totvert == ((MultiresLevel*)mesh->mr->levels.last)->totvert) {
if (mesh->mr->verts)
MEM_freeN(mesh->mr->verts);
mesh->mr->verts = MEM_dupallocN(mesh->mvert);
}
for (; lvl; lvl = lvl->next) {
lvl->verts = newdataadr(fd, lvl->verts);
lvl->faces = newdataadr(fd, lvl->faces);
lvl->edges = newdataadr(fd, lvl->edges);
lvl->colfaces = newdataadr(fd, lvl->colfaces);
}
}
/* if multires is present but has no valid vertex data,
* there's no way to recover it; silently remove multires */
if (mesh->mr && !mesh->mr->verts) {
multires_free(mesh->mr);
mesh->mr = NULL;
}
if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN) && mesh->tface) {
TFace *tf = mesh->tface;
int i;
for (i = 0; i < (mesh->totface); i++, tf++) {
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
SWITCH_INT(tf->col[0]);
SWITCH_INT(tf->col[1]);
SWITCH_INT(tf->col[2]);
SWITCH_INT(tf->col[3]);
2002-10-12 11:37:38 +00:00
}
}
}
/* ************ READ LATTICE ***************** */
static void lib_link_latt(FileData *fd, Main *main)
{
Lattice *lt;
for (lt = main->latt.first; lt; lt = lt->id.next) {
if (lt->id.flag & LIB_NEEDLINK) {
if (lt->adt) lib_link_animdata(fd, &lt->id, lt->adt);
lt->ipo = newlibadr_us(fd, lt->id.lib, lt->ipo); // XXX depreceated - old animation system
lt->key = newlibadr_us(fd, lt->id.lib, lt->key);
lt->id.flag -= LIB_NEEDLINK;
}
}
}
static void direct_link_latt(FileData *fd, Lattice *lt)
{
lt->def = newdataadr(fd, lt->def);
lt->dvert = newdataadr(fd, lt->dvert);
direct_link_dverts(fd, lt->pntsu*lt->pntsv*lt->pntsw, lt->dvert);
lt->editlatt = NULL;
lt->adt = newdataadr(fd, lt->adt);
direct_link_animdata(fd, lt->adt);
}
2002-10-12 11:37:38 +00:00
/* ************ READ OBJECT ***************** */
static void lib_link_modifiers__linkModifiers(void *userData, Object *ob,
2012-06-06 14:48:39 +00:00
ID **idpoin)
{
FileData *fd = userData;
- shuffled editmesh derived function name/function - added ModifierTypeInfo.freeData function - added modifier_{new,free] utility function - added ccgSubSurf_getUseAgeCounts to query info - removed subsurf modifier faking (ME_SUBSURF flag is no longer valid). subsurf modifier gets converted on file load although there is obscure linked mesh situation where this can go wrong, will fix shortly. this also means that some places in the code that test/copy subsurf settings are broken for the time being. - shuffled modifier calculation to be simpler. note that all modifiers are currently disabled in editmode (including subsurf). don't worry, will return shortly. - bug fix, build modifier didn't randomize meshes with only verts - cleaned up subsurf_ccg and adapted for future editmode modifier work - added editmesh.derived{Cage,Final}, not used yet - added SubsurfModifierData.{mCache,emCache}, will be used to cache subsurf instead of caching in derivedmesh itself - removed old subsurf buttons - added do_modifiers_buttons to handle modifier events - removed count_object counting of modifier (subsurfed) objects... this would be nice to add back at some point but requires care. probably requires rewrite of counting system. New feature: Incremental Subsurf in Object Mode The previous release introduce incremental subsurf calculation during editmode but it was not turned on during object mode. In general it does not make sense to have it always enabled during object mode because it requires caching a fair amount of information about the mesh which is a waste of memory unless the mesh is often recalculated. However, for mesh's that have subsurfed armatures for example, or that have other modifiers so that the mesh is essentially changing on every frame, it makes a lot of sense to keep the subsurf'd object around and that is what the new incremental subsurf modifier toggle is for. The intent is that the user will enable this option for (a) a mesh that is currently under active editing or (b) a mesh that is heavily updated in the scene, such as a character. I will try to write more about this feature for release, because it has advantages and disadvantages that are not immediately obvious (the first user reaction will be to turn it on for ever object, which is probably not correct).
2005-07-21 20:30:33 +00:00
*idpoin = newlibadr(fd, ob->id.lib, *idpoin);
/* hardcoded bad exception; non-object modifier data gets user count (texture, displace) */
if (*idpoin && GS((*idpoin)->name)!=ID_OB)
(*idpoin)->us++;
}
static void lib_link_modifiers(FileData *fd, Object *ob)
{
modifiers_foreachIDLink(ob, lib_link_modifiers__linkModifiers, fd);
}
2002-10-12 11:37:38 +00:00
static void lib_link_object(FileData *fd, Main *main)
{
Object *ob;
Orange branch: Revived hidden treasure, the Groups! Previous experiment (in 2000) didn't satisfy, it had even some primitive NLA option in groups... so, cleaned up the old code (removed most) and integrated it back in a more useful way. Usage: - CTRL+G gives menu to add group, add to existing group, or remove from groups. - In Object buttons, a new (should become first) Panel was added, showing not only Object "ID button" and Parent, but also the Groups the Object Belongs to. These buttons also allow rename, assigning or removing. - To indicate Objects are grouped, they're drawn in a (not theme yet, so temporal?) green wire color. - Use ALT+SHIFT mouse-select to (de)select an entire group But, the real power of groups is in the following features: -> Particle Force field and Guide control In the "Particle Motion" Panel, you can indicate a Group name, this then limits force fields or guides to members of that Group. (Note that layers still work on top of that... not sure about that). -> Light Groups In the Material "Shaders" Panel, you can indicate a Group name to limit lighting for the Material to lamps in this group. The Lights in a Group do need to be 'visible' for the Scene to be rendered (as usual). -> Group Duplicator In the Object "Anim" Panel, you can set any Object (use Empty!) to duplicate an entire Group. It will make copies of all Objects in that Group. Also works for animated Objects, but it will copy the current positions or deforms. Control over 'local timing' (so we can do Massive anims!) will be added later. (Note; this commit won't render Group duplicators yet, a fix in bf-blender will enable that, next commit will sync) -> Library Appending In the SHIFT-F1 or SHIFT+F4 browsers, you can also find the Groups listed. By appending or linking the Group itself, and use the Group Duplicator, you now can animate and position linked Objects. The nice thing is that the local saved file itself will only store the Group name that was linked, so on a next file read, the Group Objects will be re-read as stored (changed) in the Library file. (Note; current implementation also "gives a base" to linked Group Objects, to show them as Objects in the current Scene. Need that now for testing purposes, but probably will be removed later). -> Outliner Outliner now shows Groups as optio too, nice to organize your data a bit too! In General, Groups have a very good potential... for example, it could become default for MetaBall Objects too (jiri, I can help you later on how this works). All current 'layer relationships' in Blender should be dropped in time, I guess...
2005-12-06 10:55:30 +00:00
PartEff *paf;
2002-10-12 11:37:38 +00:00
bSensor *sens;
bController *cont;
bActuator *act;
void *poin;
int warn=0, a;
for (ob = main->object.first; ob; ob = ob->id.next) {
if (ob->id.flag & LIB_NEEDLINK) {
if (ob->id.properties) IDP_LibLinkProperty(ob->id.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
if (ob->adt) lib_link_animdata(fd, &ob->id, ob->adt);
// XXX depreceated - old animation system <<<
ob->ipo = newlibadr_us(fd, ob->id.lib, ob->ipo);
ob->action = newlibadr_us(fd, ob->id.lib, ob->action);
// >>> XXX depreceated - old animation system
ob->parent = newlibadr(fd, ob->id.lib, ob->parent);
ob->track = newlibadr(fd, ob->id.lib, ob->track);
ob->poselib = newlibadr_us(fd, ob->id.lib, ob->poselib);
ob->dup_group = newlibadr_us(fd, ob->id.lib, ob->dup_group);
ob->proxy = newlibadr_us(fd, ob->id.lib, ob->proxy);
if (ob->proxy) {
/* paranoia check, actually a proxy_from pointer should never be written... */
if (ob->proxy->id.lib == NULL) {
ob->proxy->proxy_from = NULL;
ob->proxy = NULL;
if (ob->id.lib)
printf("Proxy lost from object %s lib %s\n", ob->id.name+2, ob->id.lib->name);
else
printf("Proxy lost from object %s lib <NONE>\n", ob->id.name+2);
}
else {
/* this triggers object_update to always use a copy */
ob->proxy->proxy_from = ob;
/* force proxy updates after load/undo, a bit weak */
ob->recalc = ob->proxy->recalc = (OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
}
}
ob->proxy_group = newlibadr(fd, ob->id.lib, ob->proxy_group);
poin = ob->data;
ob->data = newlibadr_us(fd, ob->id.lib, ob->data);
if (ob->data==NULL && poin!=NULL) {
if (ob->id.lib)
printf("Can't find obdata of %s lib %s\n", ob->id.name+2, ob->id.lib->name);
else
printf("Object %s lost data.\n", ob->id.name+2);
ob->type = OB_EMPTY;
warn = 1;
if (ob->pose) {
/* we can't call #BKE_pose_free() here because of library linking
* freeing will recurse down into every pose constraints ID pointers
* which are not always valid, so for now free directly and suffer
* some leaked memory rather then crashing immediately
* while bad this _is_ an exceptional case - campbell */
#if 0
BKE_pose_free(ob->pose);
#else
MEM_freeN(ob->pose);
#endif
ob->pose= NULL;
ob->mode &= ~OB_MODE_POSE;
}
2002-10-12 11:37:38 +00:00
}
for (a=0; a < ob->totcol; a++)
ob->mat[a] = newlibadr_us(fd, ob->id.lib, ob->mat[a]);
/* When the object is local and the data is library its possible
* the material list size gets out of sync. [#22663] */
if (ob->data && ob->id.lib != ((ID *)ob->data)->lib) {
short *totcol_data = give_totcolp(ob);
/* Only expand so as not to loose any object materials that might be set. */
if (totcol_data && (*totcol_data > ob->totcol)) {
/* printf("'%s' %d -> %d\n", ob->id.name, ob->totcol, *totcol_data); */
resize_object_material(ob, *totcol_data);
}
}
ob->gpd = newlibadr_us(fd, ob->id.lib, ob->gpd);
ob->duplilist = NULL;
2002-10-12 11:37:38 +00:00
ob->id.flag -= LIB_NEEDLINK;
/* if id.us==0 a new base will be created later on */
2002-10-12 11:37:38 +00:00
/* WARNING! Also check expand_object(), should reflect the stuff below. */
Result of 2 weeks of quiet coding work in Greece :) Aim was to get a total refresh of the animation system. This is needed because; - we need to upgrade it with 21st century features - current code is spaghetti/hack combo, and hides good design - it should become lag-free with using dependency graphs A full log, with complete code API/structure/design explanation will follow, that's a load of work... so here below the list with hot changes; - The entire object update system (matrices, geometry) is now centralized. Calls to where_is_object and makeDispList are forbidden, instead we tag objects 'changed' and let the depgraph code sort it out - Removed all old "Ika" code - Depgraph is aware of all relationships, including meta balls, constraints, bevelcurve, and so on. - Made depgraph aware of relation types and layers, to do smart flushing of 'changed' events. Nothing gets calculated too often! - Transform uses depgraph to detect changes - On frame-advance, depgraph flushes animated changes Armatures; Almost all armature related code has been fully built from scratch. It now reveils the original design much better, with a very clean implementation, lag free without even calculating each Bone more than once. Result is quite a speedup yes! Important to note is; 1) Armature is data containing the 'rest position' 2) Pose is the changes of rest position, and always on object level. That way more Objects can use same Pose. Also constraints are in Pose 3) Actions only contain the Ipos to change values in Poses. - Bones draw unrotated now - Drawing bones speedup enormously (10-20 times) - Bone selecting in EditMode, selection state is saved for PoseMode, and vice-versa - Undo in editmode - Bone renaming does vertexgroups, constraints, posechannels, actions, for all users of Armature in entire file - Added Bone renaming in NKey panel - Nkey PoseMode shows eulers now - EditMode and PoseMode now have 'active' bone too (last clicked) - Parenting in EditMode' CTRL+P, ALT+P, with nice options! - Pose is added in Outliner now, with showing that constraints are in the Pose, not Armature - Disconnected IK solving from constraints. It's a separate phase now, on top of the full Pose calculations - Pose itself has a dependency graph too, so evaluation order is lag free. TODO NOW; - Rotating in Posemode has incorrect inverse transform (Martin will fix) - Python Bone/Armature/Pose API disabled... needs full recode too (wait for my doc!) - Game engine will need upgrade too - Depgraph code needs revision, cleanup, can be much faster! (But, compliments for Jean-Luc, it works like a charm!) - IK changed, it now doesnt use previous position to advance to next position anymore. That system looks nice (no flips) but is not well suited for NLA and background render. TODO LATER; We now can do loadsa new nifty features as well; like: - Kill PoseMode (can be option for armatures itself) - Make B-Bones (Bezier, Bspline, like for spines) - Move all silly button level edit to 3d window (like CTRL+I = add IK) - Much better & informative drawing - Fix action/nla editors - Put all ipos in Actions (object, mesh key, lamp color) - Add hooks - Null bones - Much more advanced constraints... Bugfixes; - OGL render (view3d header) had wrong first frame on anim render - Ipo 'recording' mode had wrong playback speed - Vertex-key mode now sticks to show 'active key', until frame change -Ton-
2005-07-03 17:35:38 +00:00
lib_link_pose(fd, ob, ob->pose);
2002-10-12 11:37:38 +00:00
lib_link_constraints(fd, &ob->id, &ob->constraints);
// XXX depreceated - old animation system <<<
2002-10-12 11:37:38 +00:00
lib_link_constraint_channels(fd, &ob->id, &ob->constraintChannels);
lib_link_nlastrips(fd, &ob->id, &ob->nlastrips);
// >>> XXX depreceated - old animation system
for (paf = ob->effect.first; paf; paf = paf->next) {
if (paf->type == EFF_PARTICLE) {
paf->group = newlibadr_us(fd, ob->id.lib, paf->group);
Orange branch: Revived hidden treasure, the Groups! Previous experiment (in 2000) didn't satisfy, it had even some primitive NLA option in groups... so, cleaned up the old code (removed most) and integrated it back in a more useful way. Usage: - CTRL+G gives menu to add group, add to existing group, or remove from groups. - In Object buttons, a new (should become first) Panel was added, showing not only Object "ID button" and Parent, but also the Groups the Object Belongs to. These buttons also allow rename, assigning or removing. - To indicate Objects are grouped, they're drawn in a (not theme yet, so temporal?) green wire color. - Use ALT+SHIFT mouse-select to (de)select an entire group But, the real power of groups is in the following features: -> Particle Force field and Guide control In the "Particle Motion" Panel, you can indicate a Group name, this then limits force fields or guides to members of that Group. (Note that layers still work on top of that... not sure about that). -> Light Groups In the Material "Shaders" Panel, you can indicate a Group name to limit lighting for the Material to lamps in this group. The Lights in a Group do need to be 'visible' for the Scene to be rendered (as usual). -> Group Duplicator In the Object "Anim" Panel, you can set any Object (use Empty!) to duplicate an entire Group. It will make copies of all Objects in that Group. Also works for animated Objects, but it will copy the current positions or deforms. Control over 'local timing' (so we can do Massive anims!) will be added later. (Note; this commit won't render Group duplicators yet, a fix in bf-blender will enable that, next commit will sync) -> Library Appending In the SHIFT-F1 or SHIFT+F4 browsers, you can also find the Groups listed. By appending or linking the Group itself, and use the Group Duplicator, you now can animate and position linked Objects. The nice thing is that the local saved file itself will only store the Group name that was linked, so on a next file read, the Group Objects will be re-read as stored (changed) in the Library file. (Note; current implementation also "gives a base" to linked Group Objects, to show them as Objects in the current Scene. Need that now for testing purposes, but probably will be removed later). -> Outliner Outliner now shows Groups as optio too, nice to organize your data a bit too! In General, Groups have a very good potential... for example, it could become default for MetaBall Objects too (jiri, I can help you later on how this works). All current 'layer relationships' in Blender should be dropped in time, I guess...
2005-12-06 10:55:30 +00:00
}
}
for (sens = ob->sensors.first; sens; sens = sens->next) {
for (a = 0; a < sens->totlinks; a++)
sens->links[a] = newglobadr(fd, sens->links[a]);
if (sens->type == SENS_TOUCH) {
bTouchSensor *ts = sens->data;
ts->ma = newlibadr(fd, ob->id.lib, ts->ma);
2002-10-12 11:37:38 +00:00
}
else if (sens->type == SENS_MESSAGE) {
bMessageSensor *ms = sens->data;
ms->fromObject =
newlibadr(fd, ob->id.lib, ms->fromObject);
2002-10-12 11:37:38 +00:00
}
}
for (cont = ob->controllers.first; cont; cont = cont->next) {
for (a=0; a < cont->totlinks; a++)
cont->links[a] = newglobadr(fd, cont->links[a]);
if (cont->type == CONT_PYTHON) {
bPythonCont *pc = cont->data;
pc->text = newlibadr(fd, ob->id.lib, pc->text);
2002-10-12 11:37:38 +00:00
}
cont->slinks = NULL;
cont->totslinks = 0;
2002-10-12 11:37:38 +00:00
}
for (act = ob->actuators.first; act; act = act->next) {
if (act->type == ACT_SOUND) {
bSoundActuator *sa = act->data;
2002-10-12 11:37:38 +00:00
sa->sound= newlibadr_us(fd, ob->id.lib, sa->sound);
}
else if (act->type == ACT_GAME) {
2002-10-12 11:37:38 +00:00
/* bGameActuator *ga= act->data; */
}
else if (act->type == ACT_CAMERA) {
bCameraActuator *ca = act->data;
2002-10-12 11:37:38 +00:00
ca->ob= newlibadr(fd, ob->id.lib, ca->ob);
}
/* leave this one, it's obsolete but necessary to read for conversion */
else if (act->type == ACT_ADD_OBJECT) {
bAddObjectActuator *eoa = act->data;
if (eoa) eoa->ob= newlibadr(fd, ob->id.lib, eoa->ob);
2002-10-12 11:37:38 +00:00
}
else if (act->type == ACT_OBJECT) {
bObjectActuator *oa = act->data;
if (oa == NULL) {
init_actuator(act);
}
else {
oa->reference = newlibadr(fd, ob->id.lib, oa->reference);
}
}
else if (act->type == ACT_EDIT_OBJECT) {
bEditObjectActuator *eoa = act->data;
if (eoa == NULL) {
2002-10-12 11:37:38 +00:00
init_actuator(act);
}
else {
eoa->ob= newlibadr(fd, ob->id.lib, eoa->ob);
eoa->me= newlibadr(fd, ob->id.lib, eoa->me);
}
2002-10-12 11:37:38 +00:00
}
else if (act->type == ACT_SCENE) {
bSceneActuator *sa = act->data;
2002-10-12 11:37:38 +00:00
sa->camera= newlibadr(fd, ob->id.lib, sa->camera);
sa->scene= newlibadr(fd, ob->id.lib, sa->scene);
}
else if (act->type == ACT_ACTION) {
bActionActuator *aa = act->data;
2002-10-12 11:37:38 +00:00
aa->act= newlibadr(fd, ob->id.lib, aa->act);
}
else if (act->type == ACT_SHAPEACTION) {
bActionActuator *aa = act->data;
aa->act= newlibadr(fd, ob->id.lib, aa->act);
}
else if (act->type == ACT_PROPERTY) {
bPropertyActuator *pa = act->data;
2002-10-12 11:37:38 +00:00
pa->ob= newlibadr(fd, ob->id.lib, pa->ob);
}
else if (act->type == ACT_MESSAGE) {
bMessageActuator *ma = act->data;
2002-10-12 11:37:38 +00:00
ma->toObject= newlibadr(fd, ob->id.lib, ma->toObject);
}
else if (act->type == ACT_2DFILTER) {
bTwoDFilterActuator *_2dfa = act->data;
_2dfa->text= newlibadr(fd, ob->id.lib, _2dfa->text);
2007-10-22 20:24:26 +00:00
}
else if (act->type == ACT_PARENT) {
bParentActuator *parenta = act->data;
parenta->ob = newlibadr(fd, ob->id.lib, parenta->ob);
}
else if (act->type == ACT_STATE) {
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
/* bStateActuator *statea = act->data; */
}
else if (act->type == ACT_ARMATURE) {
bArmatureActuator *arma= act->data;
arma->target= newlibadr(fd, ob->id.lib, arma->target);
arma->subtarget= newlibadr(fd, ob->id.lib, arma->subtarget);
}
else if (act->type == ACT_STEERING) {
bSteeringActuator *steeringa = act->data;
steeringa->target = newlibadr(fd, ob->id.lib, steeringa->target);
steeringa->navmesh = newlibadr(fd, ob->id.lib, steeringa->navmesh);
}
2002-10-12 11:37:38 +00:00
}
{
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
if (fluidmd && fluidmd->fss)
fluidmd->fss->ipo = newlibadr_us(fd, ob->id.lib, fluidmd->fss->ipo);
Sorry for the big commit, but I've been fixing many of these issues in parallel... So this commit contains: an update of the solver (e.g. moving objects), integration of blender IPOs, improved rendering (motion blur, smoothed normals) and a first particle test. In more detail: Solver update: - Moving objects using a relatively simple model, and not yet fully optimized - ok for box falling into water, water in a moving glass might cause trouble. Simulation times are influenced by overall no. of triangles of the mesh, scaling meshes up a lot might also cause slowdowns. - Additional obstacle settings: noslip (as before), free slip (move along wall freely) and part slip (mix of both). - Obstacle settings also added for domain boundaries now, the six walls of the domain are obstacles after all as well - Got rid of templates, should make compiling for e.g. macs more convenient, for linux there's not much difference. Finally got rid of parser (and some other code parts), the simulation now uses the internal API to transfer data. - Some unnecessary file were removed, the GUI now needs 3 settings buttons... This should still be changed (maybe by adding a new panel for domain objects). IPOs: - Animated params: viscosity, time and gravity for domains. In contrast to normal time IPO for Blender objects, the fluidsim one scales the time step size - so a constant 1 has no effect, values towards 0 slow it down, larger ones speed the simulation up (-> longer time steps, more compuations). The viscosity IPO is also only a factor for the selected viscosity (again, 1=no effect). - For objects that are enabled for fluidsim, a new IPO type shows up. Inflow objects can use the velocity channels to animate the inflow. Obstacles, in/outflow objects can be switched on (Active IPO>0) and off (<0) during the simulation. - Movement, rotation and scaling of those 3 types is exported from the normal Blender channels (Loc,dLoc,etc.). Particles: - This is still experimental, so it might be deactivated for a release... It should at some point be used to model smaller splashes, depending on the the realworld size and the particle generation settings particles are generated during simulation (stored in _particles_X.gz files). - These are loaded by enabling the particle field for an arbitrary object, which should be given a halo material. For each frame, similar to the mesh loading, the particle system them loads the simulated particle positions. - For rendering, I "abused" the part->rt field - I couldnt find any use for it in the code and it seems to work fine. The fluidsim particles store their size there. Rendering: - The fluidims particles use scaled sizes and alpha values to give a more varied appearance. In convertblender.c fluidsim particle systems use the p->rt field to scale up the size and down the alpha of "smaller particles". Setting the influence fields in the fluidims settings to 0 gives equally sized particles with same alpha everywhere. Higher values cause larger differences. - Smoothed normals: for unmodified fluid meshes (e.g. no subdivision) the normals computed by the solver are used. This is basically done by switching off the normal recalculation in convertblender.c (the function calc_fluidsimnormals handles other mesh inits instead of calc_vertexnormals). This could also be used to e.g. modify mesh normals in a modifier... - Another change is that fluidsim meshes load the velocities computed during the simulation for image based motion blur. This is inited in load_fluidsimspeedvectors for the vector pass (they're loaded during the normal load in DerivedMesh readBobjgz). Generation and loading can be switched off in the settings. Vector pass currently loads the fluidism meshes 3 times, so this should still be optimized. Examples: - smoothed normals versus normals from subdividing once: http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_1smoothnorms.png http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_2subdivnorms.png - fluidsim particles, size/alpha influence 0: http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_3particlesnorm.png size influence 1: http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_4particlessize.png size & alpha influence 1: http://www10.informatik.uni-erlangen.de/~sinithue/temp/v060227_5particlesalpha.png - the standard drop with motion blur and particles: http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t2new.mpg (here's how it looks without http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t1old.mpg) - another inflow animation (moving, switched on/off) with a moving obstacle (and strong mblur :) http://www10.informatik.uni-erlangen.de/~sinithue/temp/elbeemupdate_t3ipos.mpg Things still to fix: - rotating & scaling domains causes wrong speed vectors - get rid of SDL code for threading, use pthreads as well? - update wiki documentation - cool effects for rendering would be photon maps for caustics, and motion blur for particles :)
2006-02-27 11:45:42 +00:00
}
{
SmokeModifierData *smd = (SmokeModifierData *)modifiers_findByType(ob, eModifierType_Smoke);
if (smd && (smd->type == MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
smd->domain->flags |= MOD_SMOKE_FILE_LOAD; /* flag for refreshing the simulation after loading */
}
}
/* texture field */
if (ob->pd)
lib_link_partdeflect(fd, &ob->id, ob->pd);
if (ob->soft)
ob->soft->effector_weights->group = newlibadr(fd, ob->id.lib, ob->soft->effector_weights->group);
lib_link_particlesystems(fd, ob, &ob->id, &ob->particlesystem);
- shuffled editmesh derived function name/function - added ModifierTypeInfo.freeData function - added modifier_{new,free] utility function - added ccgSubSurf_getUseAgeCounts to query info - removed subsurf modifier faking (ME_SUBSURF flag is no longer valid). subsurf modifier gets converted on file load although there is obscure linked mesh situation where this can go wrong, will fix shortly. this also means that some places in the code that test/copy subsurf settings are broken for the time being. - shuffled modifier calculation to be simpler. note that all modifiers are currently disabled in editmode (including subsurf). don't worry, will return shortly. - bug fix, build modifier didn't randomize meshes with only verts - cleaned up subsurf_ccg and adapted for future editmode modifier work - added editmesh.derived{Cage,Final}, not used yet - added SubsurfModifierData.{mCache,emCache}, will be used to cache subsurf instead of caching in derivedmesh itself - removed old subsurf buttons - added do_modifiers_buttons to handle modifier events - removed count_object counting of modifier (subsurfed) objects... this would be nice to add back at some point but requires care. probably requires rewrite of counting system. New feature: Incremental Subsurf in Object Mode The previous release introduce incremental subsurf calculation during editmode but it was not turned on during object mode. In general it does not make sense to have it always enabled during object mode because it requires caching a fair amount of information about the mesh which is a waste of memory unless the mesh is often recalculated. However, for mesh's that have subsurfed armatures for example, or that have other modifiers so that the mesh is essentially changing on every frame, it makes a lot of sense to keep the subsurf'd object around and that is what the new incremental subsurf modifier toggle is for. The intent is that the user will enable this option for (a) a mesh that is currently under active editing or (b) a mesh that is heavily updated in the scene, such as a character. I will try to write more about this feature for release, because it has advantages and disadvantages that are not immediately obvious (the first user reaction will be to turn it on for ever object, which is probably not correct).
2005-07-21 20:30:33 +00:00
lib_link_modifiers(fd, ob);
2002-10-12 11:37:38 +00:00
}
}
if (warn) {
BKE_report(fd->reports, RPT_WARNING, "Warning in console");
}
2002-10-12 11:37:38 +00:00
}
Point Cache Refactoring ======================= Caching and Baking: - The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates. - There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles. - The cloth autoprotect feature was removed. - The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries. - The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions. - PointCache struct was added to DNA and is automatically allocated for each physics type. - Soft body now supports Bake Editing just like cloth. - Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now. Library Linking: - Added some more warnings to prevent editing settings on library linked objects. - Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked. - Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh). Physics UI: - Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth. - Tweaked field panel buttons to not jump around when changing options. - Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable. - I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers. - Fixed modifier error drawing glitch. Particles: - Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() .. - Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading. - Make particle threads work with autothreads. Continue Physics: - The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache. - This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics. Todo: - Point cache can get out of sync with and undo and changing a file without saving it. - Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion. - Menu item and/or buttons for Ctrl+B. - A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested. - The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
static void direct_link_pose(FileData *fd, bPose *pose)
{
bPoseChannel *pchan;
2002-10-12 11:37:38 +00:00
if (!pose)
return;
link_list(fd, &pose->chanbase);
== 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
link_list(fd, &pose->agroups);
2002-10-12 11:37:38 +00:00
pose->chanhash = NULL;
for (pchan = pose->chanbase.first; pchan; pchan=pchan->next) {
pchan->bone = NULL;
pchan->parent = newdataadr(fd, pchan->parent);
pchan->child = newdataadr(fd, pchan->child);
pchan->custom_tx = newdataadr(fd, pchan->custom_tx);
direct_link_constraints(fd, &pchan->constraints);
pchan->prop = newdataadr(fd, pchan->prop);
if (pchan->prop)
IDP_DirectLinkProperty(pchan->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
pchan->mpath = newdataadr(fd, pchan->mpath);
if (pchan->mpath)
direct_link_motionpath(fd, pchan->mpath);
pchan->iktree.first = pchan->iktree.last = NULL;
pchan->siktree.first = pchan->siktree.last = NULL;
/* in case this value changes in future, clamp else we get undefined behavior */
CLAMP(pchan->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
2002-10-12 11:37:38 +00:00
}
pose->ikdata = NULL;
if (pose->ikparam != NULL) {
pose->ikparam = newdataadr(fd, pose->ikparam);
}
2002-10-12 11:37:38 +00:00
}
- shuffled editmesh derived function name/function - added ModifierTypeInfo.freeData function - added modifier_{new,free] utility function - added ccgSubSurf_getUseAgeCounts to query info - removed subsurf modifier faking (ME_SUBSURF flag is no longer valid). subsurf modifier gets converted on file load although there is obscure linked mesh situation where this can go wrong, will fix shortly. this also means that some places in the code that test/copy subsurf settings are broken for the time being. - shuffled modifier calculation to be simpler. note that all modifiers are currently disabled in editmode (including subsurf). don't worry, will return shortly. - bug fix, build modifier didn't randomize meshes with only verts - cleaned up subsurf_ccg and adapted for future editmode modifier work - added editmesh.derived{Cage,Final}, not used yet - added SubsurfModifierData.{mCache,emCache}, will be used to cache subsurf instead of caching in derivedmesh itself - removed old subsurf buttons - added do_modifiers_buttons to handle modifier events - removed count_object counting of modifier (subsurfed) objects... this would be nice to add back at some point but requires care. probably requires rewrite of counting system. New feature: Incremental Subsurf in Object Mode The previous release introduce incremental subsurf calculation during editmode but it was not turned on during object mode. In general it does not make sense to have it always enabled during object mode because it requires caching a fair amount of information about the mesh which is a waste of memory unless the mesh is often recalculated. However, for mesh's that have subsurfed armatures for example, or that have other modifiers so that the mesh is essentially changing on every frame, it makes a lot of sense to keep the subsurf'd object around and that is what the new incremental subsurf modifier toggle is for. The intent is that the user will enable this option for (a) a mesh that is currently under active editing or (b) a mesh that is heavily updated in the scene, such as a character. I will try to write more about this feature for release, because it has advantages and disadvantages that are not immediately obvious (the first user reaction will be to turn it on for ever object, which is probably not correct).
2005-07-21 20:30:33 +00:00
static void direct_link_modifiers(FileData *fd, ListBase *lb)
{
ModifierData *md;
- shuffled editmesh derived function name/function - added ModifierTypeInfo.freeData function - added modifier_{new,free] utility function - added ccgSubSurf_getUseAgeCounts to query info - removed subsurf modifier faking (ME_SUBSURF flag is no longer valid). subsurf modifier gets converted on file load although there is obscure linked mesh situation where this can go wrong, will fix shortly. this also means that some places in the code that test/copy subsurf settings are broken for the time being. - shuffled modifier calculation to be simpler. note that all modifiers are currently disabled in editmode (including subsurf). don't worry, will return shortly. - bug fix, build modifier didn't randomize meshes with only verts - cleaned up subsurf_ccg and adapted for future editmode modifier work - added editmesh.derived{Cage,Final}, not used yet - added SubsurfModifierData.{mCache,emCache}, will be used to cache subsurf instead of caching in derivedmesh itself - removed old subsurf buttons - added do_modifiers_buttons to handle modifier events - removed count_object counting of modifier (subsurfed) objects... this would be nice to add back at some point but requires care. probably requires rewrite of counting system. New feature: Incremental Subsurf in Object Mode The previous release introduce incremental subsurf calculation during editmode but it was not turned on during object mode. In general it does not make sense to have it always enabled during object mode because it requires caching a fair amount of information about the mesh which is a waste of memory unless the mesh is often recalculated. However, for mesh's that have subsurfed armatures for example, or that have other modifiers so that the mesh is essentially changing on every frame, it makes a lot of sense to keep the subsurf'd object around and that is what the new incremental subsurf modifier toggle is for. The intent is that the user will enable this option for (a) a mesh that is currently under active editing or (b) a mesh that is heavily updated in the scene, such as a character. I will try to write more about this feature for release, because it has advantages and disadvantages that are not immediately obvious (the first user reaction will be to turn it on for ever object, which is probably not correct).
2005-07-21 20:30:33 +00:00
link_list(fd, lb);
- shuffled editmesh derived function name/function - added ModifierTypeInfo.freeData function - added modifier_{new,free] utility function - added ccgSubSurf_getUseAgeCounts to query info - removed subsurf modifier faking (ME_SUBSURF flag is no longer valid). subsurf modifier gets converted on file load although there is obscure linked mesh situation where this can go wrong, will fix shortly. this also means that some places in the code that test/copy subsurf settings are broken for the time being. - shuffled modifier calculation to be simpler. note that all modifiers are currently disabled in editmode (including subsurf). don't worry, will return shortly. - bug fix, build modifier didn't randomize meshes with only verts - cleaned up subsurf_ccg and adapted for future editmode modifier work - added editmesh.derived{Cage,Final}, not used yet - added SubsurfModifierData.{mCache,emCache}, will be used to cache subsurf instead of caching in derivedmesh itself - removed old subsurf buttons - added do_modifiers_buttons to handle modifier events - removed count_object counting of modifier (subsurfed) objects... this would be nice to add back at some point but requires care. probably requires rewrite of counting system. New feature: Incremental Subsurf in Object Mode The previous release introduce incremental subsurf calculation during editmode but it was not turned on during object mode. In general it does not make sense to have it always enabled during object mode because it requires caching a fair amount of information about the mesh which is a waste of memory unless the mesh is often recalculated. However, for mesh's that have subsurfed armatures for example, or that have other modifiers so that the mesh is essentially changing on every frame, it makes a lot of sense to keep the subsurf'd object around and that is what the new incremental subsurf modifier toggle is for. The intent is that the user will enable this option for (a) a mesh that is currently under active editing or (b) a mesh that is heavily updated in the scene, such as a character. I will try to write more about this feature for release, because it has advantages and disadvantages that are not immediately obvious (the first user reaction will be to turn it on for ever object, which is probably not correct).
2005-07-21 20:30:33 +00:00
for (md=lb->first; md; md=md->next) {
- modifier UI update (aka, find the modifier buttons!!) - moved back to editing buttons, where life is now cramped... switched to constraint style foldout panes, still a WIP. In particular not sure what buttons should be in header (and if current toggles stay in header if they should also be in an expanded pane). Also need new icons for move up/move down (and drag and drop would of course be nice). Finally current plane is to make it so modifiers will expand out in modifier pane for horizontal orientations instead of just going down down down to goblin town. - added error field to modifiers that is displayed in UI, need to have some way for modifiers to return errors back to interface (esp. important for python) - tweaked cage determination and handling, currently the editmode cage is determined by last modifier with OnCage set that is preceeded completely by modifiers that support mapping or are disabled in editmode. it is kinda confusing, but the interface only lets you toggle OnCage for modifiers that support it - it just might not be clear all the time why you can't toggle a certain modifier OnCage. - update displistmesh_copy to only copy edges if non-NULL There is a display bug that already existed but is more obvious with new modifiers where parts of the pane get drawn in a different area after toggling editmode. It has to do with drawing parts of the interface using GL instead of 100% buttons. I try to keep my grubby little toes out of the interface code so this can wait for Ton to return.
2005-08-04 07:25:43 +00:00
md->error = NULL;
md->scene = NULL;
/* if modifiers disappear, or for upward compatibility */
if (NULL == modifierType_getInfo(md->type))
md->type = eModifierType_None;
if (md->type == eModifierType_Subsurf) {
SubsurfModifierData *smd = (SubsurfModifierData *)md;
smd->emCache = smd->mCache = NULL;
}
else if (md->type == eModifierType_Armature) {
ArmatureModifierData *amd = (ArmatureModifierData *)md;
amd->prevCos = NULL;
}
else if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
clmd->clothObject = NULL;
clmd->sim_parms= newdataadr(fd, clmd->sim_parms);
clmd->coll_parms= newdataadr(fd, clmd->coll_parms);
direct_link_pointcache_list(fd, &clmd->ptcaches, &clmd->point_cache, 0);
if (clmd->sim_parms) {
if (clmd->sim_parms->presets > 10)
clmd->sim_parms->presets = 0;
clmd->sim_parms->reset = 0;
clmd->sim_parms->effector_weights = newdataadr(fd, clmd->sim_parms->effector_weights);
if (!clmd->sim_parms->effector_weights) {
clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL);
}
}
}
else if (md->type == eModifierType_Fluidsim) {
FluidsimModifierData *fluidmd = (FluidsimModifierData *)md;
fluidmd->fss = newdataadr(fd, fluidmd->fss);
if (fluidmd->fss) {
fluidmd->fss->fmd = fluidmd;
fluidmd->fss->meshVelocities = NULL;
}
}
else if (md->type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *)md;
if (smd->type == MOD_SMOKE_TYPE_DOMAIN) {
smd->flow = NULL;
smd->coll = NULL;
smd->domain = newdataadr(fd, smd->domain);
smd->domain->smd = smd;
smd->domain->fluid = NULL;
2009-09-16 17:43:09 +00:00
smd->domain->wt = NULL;
smd->domain->shadow = NULL;
smd->domain->tex = NULL;
2009-09-16 17:43:09 +00:00
smd->domain->tex_shadow = NULL;
smd->domain->tex_wt = NULL;
smd->domain->effector_weights = newdataadr(fd, smd->domain->effector_weights);
if (!smd->domain->effector_weights)
smd->domain->effector_weights = BKE_add_effector_weights(NULL);
direct_link_pointcache_list(fd, &(smd->domain->ptcaches[0]), &(smd->domain->point_cache[0]), 1);
/* Smoke uses only one cache from now on, so store pointer convert */
if (smd->domain->ptcaches[1].first || smd->domain->point_cache[1]) {
if (smd->domain->point_cache[1]) {
PointCache *cache = newdataadr(fd, smd->domain->point_cache[1]);
if (cache->flag & PTCACHE_FAKE_SMOKE)
; /* Smoke was already saved in "new format" and this cache is a fake one. */
else
printf("High resolution smoke cache not available due to pointcache update. Please reset the simulation.\n");
BKE_ptcache_free(cache);
}
smd->domain->ptcaches[1].first = NULL;
smd->domain->ptcaches[1].last = NULL;
smd->domain->point_cache[1] = NULL;
}
}
else if (smd->type == MOD_SMOKE_TYPE_FLOW) {
smd->domain = NULL;
smd->coll = NULL;
smd->flow = newdataadr(fd, smd->flow);
smd->flow->smd = smd;
smd->flow->psys = newdataadr(fd, smd->flow->psys);
}
else if (smd->type == MOD_SMOKE_TYPE_COLL) {
smd->flow = NULL;
smd->domain = NULL;
smd->coll = newdataadr(fd, smd->coll);
if (smd->coll) {
smd->coll->points = NULL;
smd->coll->numpoints = 0;
}
else
smd->type = 0;
}
}
else if (md->type == eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
if (pmd->canvas) {
pmd->canvas = newdataadr(fd, pmd->canvas);
pmd->canvas->pmd = pmd;
pmd->canvas->dm = NULL;
pmd->canvas->flags &= ~MOD_DPAINT_BAKING; /* just in case */
if (pmd->canvas->surfaces.first) {
DynamicPaintSurface *surface;
link_list(fd, &pmd->canvas->surfaces);
for (surface=pmd->canvas->surfaces.first; surface; surface=surface->next) {
surface->canvas = pmd->canvas;
surface->data = NULL;
direct_link_pointcache_list(fd, &(surface->ptcaches), &(surface->pointcache), 1);
if (!(surface->effector_weights = newdataadr(fd, surface->effector_weights)))
surface->effector_weights = BKE_add_effector_weights(NULL);
}
}
}
if (pmd->brush) {
pmd->brush = newdataadr(fd, pmd->brush);
pmd->brush->pmd = pmd;
pmd->brush->psys = newdataadr(fd, pmd->brush->psys);
pmd->brush->paint_ramp = newdataadr(fd, pmd->brush->paint_ramp);
pmd->brush->vel_ramp = newdataadr(fd, pmd->brush->vel_ramp);
pmd->brush->dm = NULL;
}
}
else if (md->type == eModifierType_Collision) {
CollisionModifierData *collmd = (CollisionModifierData *)md;
/*
// TODO: CollisionModifier should use pointcache
// + have proper reset events before enabling this
collmd->x = newdataadr(fd, collmd->x);
collmd->xnew = newdataadr(fd, collmd->xnew);
collmd->mfaces = newdataadr(fd, collmd->mfaces);
2012-04-29 15:47:02 +00:00
collmd->current_x = MEM_callocN(sizeof(MVert)*collmd->numverts, "current_x");
collmd->current_xnew = MEM_callocN(sizeof(MVert)*collmd->numverts, "current_xnew");
collmd->current_v = MEM_callocN(sizeof(MVert)*collmd->numverts, "current_v");
*/
collmd->x = NULL;
collmd->xnew = NULL;
collmd->current_x = NULL;
collmd->current_xnew = NULL;
collmd->current_v = NULL;
collmd->time_x = collmd->time_xnew = -1000;
collmd->numverts = 0;
collmd->bvhtree = NULL;
collmd->mfaces = NULL;
}
else if (md->type == eModifierType_Surface) {
SurfaceModifierData *surmd = (SurfaceModifierData *)md;
surmd->dm = NULL;
surmd->bvhtree = NULL;
Initial code for boids v2 Too many new features to list! But here are the biggies: - Boids can move on air and/or land, or climb a goal object. - Proper interaction with collision objects. * Closest collision object in negative z direction is considered as ground. * Other collision objects are obstacles and boids collide with them. - Boid behavior rules are now added to a dynamic list. * Many new rules and many still not implemented. * Different rule evaluation modes (fuzzy, random, average). - Only particle systems defined by per system "boid relations" are considered for simulation of that system. * This is in addition to the boids own system of course. * Relations define other systems as "neutral", "friend" or "enemy". - All effectors now effect boid physics, not boid brains. * This allows forcing boids somewhere. * Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength). Known issue: - Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly. - Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code. Other new features: - Particle systems can now be named separately from particle settings. * Default name for particle settings is now "ParticleSettings" instead of "PSys" - Per particle system list of particle effector weights. * Enables different effection strengths for particles from different particle systems with without messing around with effector group setting. Other code changes: - KDTree now supports range search as it's needed for new boids. - "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles) Bug fixes: - Object & group visualizations didn't work. - Interpolating pointcache didn't do rotation.
2009-07-20 23:52:53 +00:00
surmd->x = NULL;
surmd->v = NULL;
surmd->numverts = 0;
}
else if (md->type == eModifierType_Hook) {
HookModifierData *hmd = (HookModifierData *)md;
hmd->indexar = newdataadr(fd, hmd->indexar);
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
int a;
for (a = 0; a < hmd->totindex; a++) {
SWITCH_INT(hmd->indexar[a]);
}
}
}
else if (md->type == eModifierType_ParticleSystem) {
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
psmd->dm= NULL;
psmd->psys= newdataadr(fd, psmd->psys);
psmd->flag &= ~eParticleSystemFlag_psys_updated;
psmd->flag |= eParticleSystemFlag_file_loaded;
}
else if (md->type == eModifierType_Explode) {
ExplodeModifierData *psmd = (ExplodeModifierData *)md;
psmd->facepa = NULL;
- shuffled editmesh derived function name/function - added ModifierTypeInfo.freeData function - added modifier_{new,free] utility function - added ccgSubSurf_getUseAgeCounts to query info - removed subsurf modifier faking (ME_SUBSURF flag is no longer valid). subsurf modifier gets converted on file load although there is obscure linked mesh situation where this can go wrong, will fix shortly. this also means that some places in the code that test/copy subsurf settings are broken for the time being. - shuffled modifier calculation to be simpler. note that all modifiers are currently disabled in editmode (including subsurf). don't worry, will return shortly. - bug fix, build modifier didn't randomize meshes with only verts - cleaned up subsurf_ccg and adapted for future editmode modifier work - added editmesh.derived{Cage,Final}, not used yet - added SubsurfModifierData.{mCache,emCache}, will be used to cache subsurf instead of caching in derivedmesh itself - removed old subsurf buttons - added do_modifiers_buttons to handle modifier events - removed count_object counting of modifier (subsurfed) objects... this would be nice to add back at some point but requires care. probably requires rewrite of counting system. New feature: Incremental Subsurf in Object Mode The previous release introduce incremental subsurf calculation during editmode but it was not turned on during object mode. In general it does not make sense to have it always enabled during object mode because it requires caching a fair amount of information about the mesh which is a waste of memory unless the mesh is often recalculated. However, for mesh's that have subsurfed armatures for example, or that have other modifiers so that the mesh is essentially changing on every frame, it makes a lot of sense to keep the subsurf'd object around and that is what the new incremental subsurf modifier toggle is for. The intent is that the user will enable this option for (a) a mesh that is currently under active editing or (b) a mesh that is heavily updated in the scene, such as a character. I will try to write more about this feature for release, because it has advantages and disadvantages that are not immediately obvious (the first user reaction will be to turn it on for ever object, which is probably not correct).
2005-07-21 20:30:33 +00:00
}
else if (md->type == eModifierType_MeshDeform) {
MeshDeformModifierData *mmd = (MeshDeformModifierData *)md;
mmd->bindinfluences = newdataadr(fd, mmd->bindinfluences);
mmd->bindoffsets = newdataadr(fd, mmd->bindoffsets);
mmd->bindcagecos = newdataadr(fd, mmd->bindcagecos);
mmd->dyngrid = newdataadr(fd, mmd->dyngrid);
mmd->dyninfluences = newdataadr(fd, mmd->dyninfluences);
mmd->dynverts = newdataadr(fd, mmd->dynverts);
mmd->bindweights = newdataadr(fd, mmd->bindweights);
mmd->bindcos = newdataadr(fd, mmd->bindcos);
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
int a;
if (mmd->bindoffsets)
for (a=0; a<mmd->totvert+1; a++)
SWITCH_INT(mmd->bindoffsets[a]);
if (mmd->bindcagecos)
for (a=0; a<mmd->totcagevert*3; a++)
SWITCH_INT(mmd->bindcagecos[a]);
if (mmd->dynverts)
for (a=0; a<mmd->totvert; a++)
SWITCH_INT(mmd->dynverts[a]);
if (mmd->bindweights)
for (a=0; a<mmd->totcagevert*mmd->totvert; a++)
SWITCH_INT(mmd->bindweights[a]);
if (mmd->bindcos)
for (a=0; a<mmd->totcagevert*3; a++)
SWITCH_INT(mmd->bindcos[a]);
}
}
else if (md->type == eModifierType_Ocean) {
OceanModifierData *omd = (OceanModifierData *)md;
omd->oceancache = NULL;
omd->ocean = NULL;
omd->refresh = (MOD_OCEAN_REFRESH_ADD|MOD_OCEAN_REFRESH_RESET|MOD_OCEAN_REFRESH_SIM);
}
else if (md->type == eModifierType_Warp) {
WarpModifierData *tmd = (WarpModifierData *)md;
tmd->curfalloff= newdataadr(fd, tmd->curfalloff);
if (tmd->curfalloff)
direct_link_curvemapping(fd, tmd->curfalloff);
}
else if (md->type == eModifierType_WeightVGEdit) {
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
wmd->cmap_curve = newdataadr(fd, wmd->cmap_curve);
if (wmd->cmap_curve)
direct_link_curvemapping(fd, wmd->cmap_curve);
}
- shuffled editmesh derived function name/function - added ModifierTypeInfo.freeData function - added modifier_{new,free] utility function - added ccgSubSurf_getUseAgeCounts to query info - removed subsurf modifier faking (ME_SUBSURF flag is no longer valid). subsurf modifier gets converted on file load although there is obscure linked mesh situation where this can go wrong, will fix shortly. this also means that some places in the code that test/copy subsurf settings are broken for the time being. - shuffled modifier calculation to be simpler. note that all modifiers are currently disabled in editmode (including subsurf). don't worry, will return shortly. - bug fix, build modifier didn't randomize meshes with only verts - cleaned up subsurf_ccg and adapted for future editmode modifier work - added editmesh.derived{Cage,Final}, not used yet - added SubsurfModifierData.{mCache,emCache}, will be used to cache subsurf instead of caching in derivedmesh itself - removed old subsurf buttons - added do_modifiers_buttons to handle modifier events - removed count_object counting of modifier (subsurfed) objects... this would be nice to add back at some point but requires care. probably requires rewrite of counting system. New feature: Incremental Subsurf in Object Mode The previous release introduce incremental subsurf calculation during editmode but it was not turned on during object mode. In general it does not make sense to have it always enabled during object mode because it requires caching a fair amount of information about the mesh which is a waste of memory unless the mesh is often recalculated. However, for mesh's that have subsurfed armatures for example, or that have other modifiers so that the mesh is essentially changing on every frame, it makes a lot of sense to keep the subsurf'd object around and that is what the new incremental subsurf modifier toggle is for. The intent is that the user will enable this option for (a) a mesh that is currently under active editing or (b) a mesh that is heavily updated in the scene, such as a character. I will try to write more about this feature for release, because it has advantages and disadvantages that are not immediately obvious (the first user reaction will be to turn it on for ever object, which is probably not correct).
2005-07-21 20:30:33 +00:00
}
}
2002-10-12 11:37:38 +00:00
static void direct_link_object(FileData *fd, Object *ob)
{
PartEff *paf;
bProperty *prop;
bSensor *sens;
bController *cont;
bActuator *act;
/* weak weak... this was only meant as draw flag, now is used in give_base_to_objects too */
ob->flag &= ~OB_FROMGROUP;
/* loading saved files with editmode enabled works, but for undo we like
2012-04-22 11:54:53 +00:00
* to stay in object mode during undo presses so keep editmode disabled */
if (fd->memfile)
ob->mode &= ~(OB_MODE_EDIT | OB_MODE_PARTICLE_EDIT);
ob->disp.first = ob->disp.last = NULL;
ob->adt = newdataadr(fd, ob->adt);
direct_link_animdata(fd, ob->adt);
ob->pose = newdataadr(fd, ob->pose);
2002-10-12 11:37:38 +00:00
direct_link_pose(fd, ob->pose);
ob->mpath = newdataadr(fd, ob->mpath);
if (ob->mpath)
direct_link_motionpath(fd, ob->mpath);
2002-10-12 11:37:38 +00:00
link_list(fd, &ob->defbase);
// XXX depreceated - old animation system <<<
Two wonderful new NLA & Armature editing features! - FORWARD CYCLING & MATCHING Up to no now, adding multiple actions in NLA with walkcycles required to animate them standing still, as if walking on a conveyor belt. The stride option then makes the object itself move forward, trying to keep the foot stuck on the floor (with poor results!). This option now allows to make walk cycles moving forward. By indicating a reference Offset Bone, the NLA system will use that bone to detect the correct offset for the Armature Pose to make it seamlessly going forward. Best of all, this option works as for cyclic Action Strips as well as for individual Action Strips. Note that for individual strips, you have to set the strip on "Hold". (Might become automatic detected later). Here's an example edit image for NLA: http://www.blender.org/bf/nla_match-cycle.jpg And the animation for it: http://download.blender.org/demo/test/2.43/0001_0150_match.avi Blender file: http://download.blender.org/demo/test/2.43/mancandy_matching.blend Using this kind of cycling works pretty straightforward, and is a lot easier to setup than Stride Bones. To be further tested: - Blending cycles - matching rotation for the bones as well. - ACTION MODIFIERS (motion deformors) The above option was actually required for this feature. Typically walk cycles are constructed with certain Bones to be the handles, controlling for example the torso or feet. An Action Modifier allows you to use a Curve Path to deform the motion of these controlling bones. This uses the existing Curve Deformation option. Modifiers can be added per Action Strip, each controlling a channel (bone) by choice, and even allows to layer multiple modifiers on top of each other (several paths deforming motion). This option is using the dependency graph, so editing the Curve will give realtime changes in the Armature. The previous walkcycle, controlled by two curves: http://download.blender.org/demo/test/2.43/0001_0150_deform.avi Blender file: http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend Action Modifiers can be added in the NLA Properties Panel. Per Modifier you have to indicate the channel and a Curve Object. You can copy modifiers from one strip to another using CTRL+C (only copies to active Object strips). Setting up a correct Curve Path has to be carefully done: - Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated. - make sure the center point of the Curve Object is at the center of the Armature (or above) - move the first point of the curve to the center point as well. - check if the path starts from this first point, you can change it using (in Curve EditMode) the option Wkey -> "Switch Direction" - Make sure alignment uses the correct axis; if the Armature walks into the negative Y direction, you have to set in Object Buttons, "Anim settings" Panel, the correct Track option. (Note; option will probably move to the Modifier later). This is a good reason to make such paths automatic (on a command). Is on the todo list. Also note this: - the Curve Path extends in beginning and ending, that's (for now) the default, and allows to use multiple paths. Make sure paths begin and end horizontal. - Moving the Curve in Object Mode will change the "mapping" (as if the landscape a character walks over moves). Moving the Curve in Edit Mode will change the actual position of the deformation. - Speed (Ipos) on paths is not supported yet, will be done. - The Curve "Stretch" deform option doesn't work. - Modifiers are executed *after* all actions in NLA are evaluated, there's no support yet for blending multiple strips with Modifiers. - This doesn't work yet for time-mapping... This commit is mostly for review by character animators... some details or working methods might change. This feature can also be used for other modifiers, such as noise (Perlin) or the mythical "Oomph" (frequency control) and of course Python. Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
direct_link_nlastrips(fd, &ob->nlastrips);
2002-10-12 11:37:38 +00:00
link_list(fd, &ob->constraintChannels);
// >>> XXX depreceated - old animation system
2002-10-12 11:37:38 +00:00
ob->mat= newdataadr(fd, ob->mat);
test_pointer_array(fd, (void **)&ob->mat);
ob->matbits= newdataadr(fd, ob->matbits);
/* do it here, below old data gets converted */
direct_link_modifiers(fd, &ob->modifiers);
2002-10-12 11:37:38 +00:00
link_list(fd, &ob->effect);
paf= ob->effect.first;
while (paf) {
if (paf->type == EFF_PARTICLE) {
paf->keys = NULL;
2002-10-12 11:37:38 +00:00
}
if (paf->type == EFF_WAVE) {
WaveEff *wav = (WaveEff*) paf;
PartEff *next = paf->next;
WaveModifierData *wmd = (WaveModifierData*) modifier_new(eModifierType_Wave);
wmd->damp = wav->damp;
wmd->flag = wav->flag;
wmd->height = wav->height;
wmd->lifetime = wav->lifetime;
wmd->narrow = wav->narrow;
wmd->speed = wav->speed;
wmd->startx = wav->startx;
wmd->starty = wav->startx;
wmd->timeoffs = wav->timeoffs;
wmd->width = wav->width;
BLI_addtail(&ob->modifiers, wmd);
BLI_remlink(&ob->effect, paf);
MEM_freeN(paf);
paf = next;
continue;
}
if (paf->type == EFF_BUILD) {
BuildEff *baf = (BuildEff*) paf;
PartEff *next = paf->next;
- shuffled editmesh derived function name/function - added ModifierTypeInfo.freeData function - added modifier_{new,free] utility function - added ccgSubSurf_getUseAgeCounts to query info - removed subsurf modifier faking (ME_SUBSURF flag is no longer valid). subsurf modifier gets converted on file load although there is obscure linked mesh situation where this can go wrong, will fix shortly. this also means that some places in the code that test/copy subsurf settings are broken for the time being. - shuffled modifier calculation to be simpler. note that all modifiers are currently disabled in editmode (including subsurf). don't worry, will return shortly. - bug fix, build modifier didn't randomize meshes with only verts - cleaned up subsurf_ccg and adapted for future editmode modifier work - added editmesh.derived{Cage,Final}, not used yet - added SubsurfModifierData.{mCache,emCache}, will be used to cache subsurf instead of caching in derivedmesh itself - removed old subsurf buttons - added do_modifiers_buttons to handle modifier events - removed count_object counting of modifier (subsurfed) objects... this would be nice to add back at some point but requires care. probably requires rewrite of counting system. New feature: Incremental Subsurf in Object Mode The previous release introduce incremental subsurf calculation during editmode but it was not turned on during object mode. In general it does not make sense to have it always enabled during object mode because it requires caching a fair amount of information about the mesh which is a waste of memory unless the mesh is often recalculated. However, for mesh's that have subsurfed armatures for example, or that have other modifiers so that the mesh is essentially changing on every frame, it makes a lot of sense to keep the subsurf'd object around and that is what the new incremental subsurf modifier toggle is for. The intent is that the user will enable this option for (a) a mesh that is currently under active editing or (b) a mesh that is heavily updated in the scene, such as a character. I will try to write more about this feature for release, because it has advantages and disadvantages that are not immediately obvious (the first user reaction will be to turn it on for ever object, which is probably not correct).
2005-07-21 20:30:33 +00:00
BuildModifierData *bmd = (BuildModifierData*) modifier_new(eModifierType_Build);
bmd->start = baf->sfra;
bmd->length = baf->len;
bmd->randomize = 0;
bmd->seed = 1;
BLI_addtail(&ob->modifiers, bmd);
BLI_remlink(&ob->effect, paf);
MEM_freeN(paf);
paf = next;
continue;
2002-10-12 11:37:38 +00:00
}
paf = paf->next;
2002-10-12 11:37:38 +00:00
}
ob->pd= newdataadr(fd, ob->pd);
direct_link_partdeflect(ob->pd);
ob->soft= newdataadr(fd, ob->soft);
if (ob->soft) {
SoftBody *sb = ob->soft;
sb->bpoint = NULL; // init pointers so it gets rebuilt nicely
sb->bspring = NULL;
sb->scratch = NULL;
/* although not used anymore */
/* still have to be loaded to be compatible with old files */
sb->keys = newdataadr(fd, sb->keys);
test_pointer_array(fd, (void **)&sb->keys);
if (sb->keys) {
int a;
for (a = 0; a < sb->totkey; a++) {
sb->keys[a] = newdataadr(fd, sb->keys[a]);
}
}
sb->effector_weights = newdataadr(fd, sb->effector_weights);
if (!sb->effector_weights)
sb->effector_weights = BKE_add_effector_weights(NULL);
direct_link_pointcache_list(fd, &sb->ptcaches, &sb->pointcache, 0);
}
ob->bsoft = newdataadr(fd, ob->bsoft);
ob->fluidsimSettings= newdataadr(fd, ob->fluidsimSettings); /* NT */
link_list(fd, &ob->particlesystem);
2012-04-29 15:47:02 +00:00
direct_link_particlesystems(fd, &ob->particlesystem);
OK. Here's the long awaited first step (V0.01!) of SoftBody. It is called from within mesh_modifiers (kernel deform.c). It copies vertices to a temporal particle system (struct SoftBody with BodyPoint structs) to do physics tricks with it. For each frame change the delta movements (based on standard ipo anim or even other deforms (later) are applied to the physics system. How to apply and calculate satisfying results is not my thing... so here I'll commu- nicate with others for. Since it's in the modifier stack, the SoftBody code can run entirely on original data (no displists!). Right now I've implemented 2 things; - "Goal" which is a per vertex value for how much the current position should take into account (goal=1 is without physics). This is a powerful method for artists to get control over what moves and not. Right now i read the vertex color for it. - And some spring stuff, which now only works based on force moving it to the originial location. This doesnt work with 'goal'... erhm. - You can re-use physics vars from engine, used right now is (in Object) - damping - springf (spring factor) - softflag (to set types, or activate softbody for it - The SoftBody pointer in struct Object is only runtime, nothing saved in file To prevent all users going to complain it doesn't work, I've hidden the functionality. :) The buttons to set softbody 'on' only show now (psst psst) when the object has name "soft" as first 4 characters. You can find the buttons in the F7 Particle Interaction Panel (which should be renamed 'physics properties' later or so. Demo file: http://www.blender.org/bf/softbody.blend
2004-10-01 14:04:17 +00:00
2002-10-12 11:37:38 +00:00
link_list(fd, &ob->prop);
for (prop = ob->prop.first; prop; prop = prop->next) {
prop->poin = newdataadr(fd, prop->poin);
if (prop->poin == NULL)
prop->poin = &prop->data;
2002-10-12 11:37:38 +00:00
}
link_list(fd, &ob->sensors);
for (sens = ob->sensors.first; sens; sens = sens->next) {
sens->data = newdataadr(fd, sens->data);
sens->links = newdataadr(fd, sens->links);
2002-10-12 11:37:38 +00:00
test_pointer_array(fd, (void **)&sens->links);
}
direct_link_constraints(fd, &ob->constraints);
link_glob_list(fd, &ob->controllers);
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
if (ob->init_state) {
/* if a known first state is specified, set it so that the game will start ok */
ob->state = ob->init_state;
}
else if (!ob->state) {
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
ob->state = 1;
}
for (cont = ob->controllers.first; cont; cont = cont->next) {
cont->data = newdataadr(fd, cont->data);
cont->links = newdataadr(fd, cont->links);
2002-10-12 11:37:38 +00:00
test_pointer_array(fd, (void **)&cont->links);
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
if (cont->state_mask == 0)
cont->state_mask = 1;
2002-10-12 11:37:38 +00:00
}
link_glob_list(fd, &ob->actuators);
for (act = ob->actuators.first; act; act = act->next) {
act->data = newdataadr(fd, act->data);
2002-10-12 11:37:38 +00:00
}
link_list(fd, &ob->hooks);
while (ob->hooks.first) {
ObHook *hook = ob->hooks.first;
HookModifierData *hmd = (HookModifierData *)modifier_new(eModifierType_Hook);
hook->indexar= newdataadr(fd, hook->indexar);
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
int a;
for (a = 0; a < hook->totindex; a++) {
SWITCH_INT(hook->indexar[a]);
}
}
/* Do conversion here because if we have loaded
* a hook we need to make sure it gets converted
* and freed, regardless of version.
*/
copy_v3_v3(hmd->cent, hook->cent);
hmd->falloff = hook->falloff;
hmd->force = hook->force;
hmd->indexar = hook->indexar;
hmd->object = hook->parent;
memcpy(hmd->parentinv, hook->parentinv, sizeof(hmd->parentinv));
hmd->totindex = hook->totindex;
BLI_addhead(&ob->modifiers, hmd);
BLI_remlink(&ob->hooks, hook);
modifier_unique_name(&ob->modifiers, (ModifierData*)hmd);
MEM_freeN(hook);
}
ob->customdata_mask = 0;
ob->bb = NULL;
ob->derivedDeform = NULL;
ob->derivedFinal = NULL;
ob->gpulamp.first= ob->gpulamp.last = NULL;
link_list(fd, &ob->pc_ids);
/* in case this value changes in future, clamp else we get undefined behavior */
CLAMP(ob->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
if (ob->sculpt) {
ob->sculpt = MEM_callocN(sizeof(SculptSession), "reload sculpt session");
}
2002-10-12 11:37:38 +00:00
}
/* ************ READ SCENE ***************** */
/* patch for missing scene IDs, can't be in do-versions */
static void composite_patch(bNodeTree *ntree, Scene *scene)
{
bNode *node;
for (node= ntree->nodes.first; node; node= node->next) {
if (node->id==NULL && ELEM4(node->type, CMP_NODE_R_LAYERS, CMP_NODE_COMPOSITE, CMP_NODE_DEFOCUS, CMP_NODE_OUTPUT_FILE))
node->id = &scene->id;
}
}
static void link_paint(FileData *fd, Scene *sce, Paint *p)
{
if (p) {
p->brush = newlibadr_us(fd, sce->id.lib, p->brush);
p->paint_cursor = NULL;
}
}
2002-10-12 11:37:38 +00:00
static void lib_link_scene(FileData *fd, Main *main)
{
Scene *sce;
Base *base, *next;
Sequence *seq;
SceneRenderLayer *srl;
TimeMarker *marker;
for (sce = main->scene.first; sce; sce = sce->id.next) {
if (sce->id.flag & LIB_NEEDLINK) {
2012-04-22 11:54:53 +00:00
/* Link ID Properties -- and copy this comment EXACTLY for easy finding
* of library blocks that implement this.*/
if (sce->id.properties) IDP_LibLinkProperty(sce->id.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
if (sce->adt) lib_link_animdata(fd, &sce->id, sce->adt);
lib_link_keyingsets(fd, &sce->id, &sce->keyingsets);
sce->camera = newlibadr(fd, sce->id.lib, sce->camera);
sce->world = newlibadr_us(fd, sce->id.lib, sce->world);
sce->set = newlibadr(fd, sce->id.lib, sce->set);
sce->gpd = newlibadr_us(fd, sce->id.lib, sce->gpd);
link_paint(fd, sce, &sce->toolsettings->sculpt->paint);
link_paint(fd, sce, &sce->toolsettings->vpaint->paint);
link_paint(fd, sce, &sce->toolsettings->wpaint->paint);
link_paint(fd, sce, &sce->toolsettings->imapaint.paint);
link_paint(fd, sce, &sce->toolsettings->uvsculpt->paint);
sce->toolsettings->skgen_template = newlibadr(fd, sce->id.lib, sce->toolsettings->skgen_template);
for (base = sce->base.first; base; base = next) {
next = base->next;
2002-10-12 11:37:38 +00:00
/* base->object= newlibadr_us(fd, sce->id.lib, base->object); */
base->object = newlibadr_us(fd, sce->id.lib, base->object);
if (base->object == NULL) {
BKE_reportf_wrap(fd->reports, RPT_ERROR,
"LIB ERROR: Object lost from scene:'%s\'",
sce->id.name + 2);
2002-10-12 11:37:38 +00:00
BLI_remlink(&sce->base, base);
if (base == sce->basact) sce->basact = NULL;
2002-10-12 11:37:38 +00:00
MEM_freeN(base);
}
}
SEQ_BEGIN (sce->ed, seq)
{
if (seq->ipo) seq->ipo = newlibadr_us(fd, sce->id.lib, seq->ipo);
seq->scene_sound = NULL;
if (seq->scene) {
seq->scene = newlibadr(fd, sce->id.lib, seq->scene);
if (seq->scene) {
seq->scene_sound = sound_scene_add_scene_sound_defaults(sce, seq);
}
}
if (seq->clip) {
seq->clip = newlibadr(fd, sce->id.lib, seq->clip);
seq->clip->id.us++;
}
2012-06-07 18:24:36 +00:00
if (seq->mask) {
seq->mask = newlibadr(fd, sce->id.lib, seq->mask);
seq->mask->id.us++;
}
if (seq->scene_camera) seq->scene_camera = newlibadr(fd, sce->id.lib, seq->scene_camera);
if (seq->sound) {
seq->scene_sound = NULL;
if (seq->type == SEQ_TYPE_SOUND_HD)
seq->type = SEQ_TYPE_SOUND_RAM;
else
seq->sound = newlibadr(fd, sce->id.lib, seq->sound);
if (seq->sound) {
seq->sound->id.us++;
seq->scene_sound = sound_add_scene_sound_defaults(sce, seq);
Commit message and the brunt of the code courtesy of intrr, apologies for the size of this; Finally, the Sequencer audio support and global audio/animation sync stuff! (See http://intrr.org/blender/audiosequencer.html) Stuff that has been done: ./source/blender/blenloader/intern/writefile.c ./source/blender/blenloader/intern/readfile.c Added code to make it handle sounds used by audio strips, and to convert Scene data from older (<2.28) versions to init Scene global audio settings (Scene->audio) to defaults. ./source/blender/include/BSE_seqaudio.h ./source/blender/src/seqaudio.c The main audio routines that start/stop/scrub the audio stream at a certain frame position, provide the frame reference for the current stream position, mix the audio, convert the audio, mixdown the audio into a file. ./source/blender/makesdna/DNA_sound_types.h Introduced new variables in the bSound struct to accomodate the sample data after converted to the scene's global mixing format (stream, streamlen). Also added a new flag SOUND_FLAGS_SEQUENCE that gets set if the Sound belongs to a sequence strip. ./source/blender/makesdna/DNA_scene_types.h Added AudioData struct, which holds scene-global audio settings. ./source/blender/makesdna/DNA_sequence_types.h Added support for audio strips. Some variables to hold Panning/Attenuation information, position information, reference to the sample, and some flags. ./source/blender/makesdna/DNA_userdef_types.h ./source/blender/src/usiblender.c Added a "Mixing buffer size" userpref. Made the versions stuff initialize it to a default for versions <2.28. ./source/blender/makesdna/DNA_space_types.h ./source/blender/src/filesel.c Added a Cyan dot to .WAV files. Any other suggestions on a better color? :) ./source/blender/src/editsound.c Changes (fixes) to the WAV file loader, re-enabled some gameengine code that is needed for dealing with bSounds and bSamples. ./source/blender/src/editipo.c ./source/blender/src/drawseq.c ./source/blender/src/editnla.c ./source/blender/src/space.c ./source/blender/src/drawview.c ./source/blender/src/renderwin.c ./source/blender/src/headerbuttons.c - Created two different wrappers for update_for_newframe(), one which scrubs the audio, one which doesn't. - Replaced some of the occurences of update_for_newframe() with update_for_newframe_muted(), which doesn't scrub the audio. - In drawview.c: Changed the synchronization scheme to get the current audio position from the audio engine, and use that as a reference for setting CFRA. Implements a/v sync and framedrop. - In editipo.c: Changed handling of Fac IPOs to be usable for audio strips as volume envelopes. - In space.c: Added the mixing buffer size Userpref, enabled audio scrubbing (update_for_newframe()) for moving the sequence editor framebar. ./source/blender/src/editseq.c Added support for audio strips and a default directory for WAV files which gets saved from the last Shift-A operation. ./source/blender/src/buttons.c Added Scene-global audio sequencer settings in Sound buttons. ./source/blender/src/sequence.c Various stuff that deals with handling audio strips differently than usual strips.
2003-07-13 20:16:56 +00:00
}
2002-10-12 11:37:38 +00:00
}
seq->anim = NULL;
2002-10-12 11:37:38 +00:00
}
SEQ_END
#ifdef DURIAN_CAMERA_SWITCH
for (marker = sce->markers.first; marker; marker = marker->next) {
if (marker->camera) {
marker->camera = newlibadr(fd, sce->id.lib, marker->camera);
}
}
#else
(void)marker;
#endif
seq_update_muting(sce->ed);
seq_update_sound_bounds_all(sce);
if (sce->nodetree) {
Giant commit! A full detailed description of this will be done later... is several days of work. Here's a summary: Render: - Full cleanup of render code, removing *all* globals and bad level calls all over blender. Render module is now not called abusive anymore - API-fied calls to rendering - Full recode of internal render pipeline. Is now rendering tiles by default, prepared for much smarter 'bucket' render later. - Each thread now can render a full part - Renders were tested with 4 threads, goes fine, apart from some lookup tables in softshadow and AO still - Rendering is prepared to do multiple layers and passes - No single 32 bits trick in render code anymore, all 100% floats now. Writing images/movies - moved writing images to blender kernel (bye bye 'schrijfplaatje'!) - made a new Movie handle system, also in kernel. This will enable much easier use of movies in Blender PreviewRender: - Using new render API, previewrender (in buttons) now uses regular render code to generate images. - new datafile 'preview.blend.c' has the preview scenes in it - previews get rendered in exact displayed size (1 pixel = 1 pixel) 3D Preview render - new; press Pkey in 3d window, for a panel that continuously renders (pkey is for games, i know... but we dont do that in orange now!) - this render works nearly identical to buttons-preview render, so it stops rendering on any event (mouse, keyboard, etc) - on moving/scaling the panel, the render code doesn't recreate all geometry - same for shifting/panning view - all other operations (now) regenerate the full render database still. - this is WIP... but big fun, especially for simple scenes! Compositor - Using same node system as now in use for shaders, you can composit images - works pretty straightforward... needs much more options/tools and integration with rendering still - is not threaded yet, nor is so smart to only recalculate changes... will be done soon! - the "Render Result" node will get all layers/passes as output sockets - The "Output" node renders to a builtin image, which you can view in the Image window. (yes, output nodes to render-result, and to files, is on the list!) The Bad News - "Unified Render" is removed. It might come back in some stage, but this system should be built from scratch. I can't really understand this code... I expect it is not much needed, especially with advanced layer/passes control - Panorama render, Field render, Motion blur, is not coded yet... (I had to recode every single feature in render, so...!) - Lens Flare is also not back... needs total revision, might become composit effect though (using zbuffer for visibility) - Part render is gone! (well, thats obvious, its default now). - The render window is only restored with limited functionality... I am going to check first the option to render to a Image window, so Blender can become a true single-window application. :) For example, the 'Spare render buffer' (jkey) doesnt work. - Render with border, now default creates a smaller image - No zbuffers are written yet... on the todo! - Scons files and MSVC will need work to get compiling again OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
lib_link_ntree(fd, &sce->id, sce->nodetree);
composite_patch(sce->nodetree, sce);
}
for (srl = sce->r.layers.first; srl; srl = srl->next) {
srl->mat_override = newlibadr_us(fd, sce->id.lib, srl->mat_override);
srl->light_override = newlibadr_us(fd, sce->id.lib, srl->light_override);
}
/*Game Settings: Dome Warp Text*/
sce->gm.dome.warptext = newlibadr(fd, sce->id.lib, sce->gm.dome.warptext);
/* Motion Tracking */
sce->clip = newlibadr_us(fd, sce->id.lib, sce->clip);
2002-10-12 11:37:38 +00:00
sce->id.flag -= LIB_NEEDLINK;
}
}
}
static void link_recurs_seq(FileData *fd, ListBase *lb)
{
Sequence *seq;
2002-10-12 11:37:38 +00:00
link_list(fd, lb);
for (seq = lb->first; seq; seq = seq->next) {
if (seq->seqbase.first)
link_recurs_seq(fd, &seq->seqbase);
}
2002-10-12 11:37:38 +00:00
}
static void direct_link_paint(FileData *fd, Paint **paint)
{
/* TODO. is this needed */
(*paint) = newdataadr(fd, (*paint));
if (*paint && (*paint)->num_input_samples < 1)
(*paint)->num_input_samples = 1;
}
2002-10-12 11:37:38 +00:00
static void direct_link_scene(FileData *fd, Scene *sce)
{
Editing *ed;
Sequence *seq;
MetaStack *ms;
sce->theDag = NULL;
sce->dagisvalid = 0;
sce->obedit = NULL;
sce->stats = NULL;
sce->fps_info = NULL;
sce->customdata_mask_modal = 0;
sce->lay_updated = 0;
sound_create_scene(sce);
/* set users to one by default, not in lib-link, this will increase it for compo nodes */
sce->id.us = 1;
2002-10-12 11:37:38 +00:00
link_list(fd, &(sce->base));
sce->adt = newdataadr(fd, sce->adt);
direct_link_animdata(fd, sce->adt);
link_list(fd, &sce->keyingsets);
direct_link_keyingsets(fd, &sce->keyingsets);
sce->basact = newdataadr(fd, sce->basact);
sce->toolsettings= newdataadr(fd, sce->toolsettings);
if (sce->toolsettings) {
direct_link_paint(fd, (Paint**)&sce->toolsettings->sculpt);
direct_link_paint(fd, (Paint**)&sce->toolsettings->vpaint);
direct_link_paint(fd, (Paint**)&sce->toolsettings->wpaint);
direct_link_paint(fd, (Paint**)&sce->toolsettings->uvsculpt);
sce->toolsettings->imapaint.paintcursor = NULL;
sce->toolsettings->particle.paintcursor = NULL;
}
if (sce->ed) {
ListBase *old_seqbasep = &((Editing *)sce->ed)->seqbase;
ed = sce->ed = newdataadr(fd, sce->ed);
ed->act_seq = newdataadr(fd, ed->act_seq);
/* recursive link sequences, lb will be correctly initialized */
2002-10-12 11:37:38 +00:00
link_recurs_seq(fd, &ed->seqbase);
SEQ_BEGIN (ed, seq)
{
2002-10-12 11:37:38 +00:00
seq->seq1= newdataadr(fd, seq->seq1);
seq->seq2= newdataadr(fd, seq->seq2);
seq->seq3= newdataadr(fd, seq->seq3);
/* a patch: after introduction of effects with 3 input strips */
if (seq->seq3 == NULL) seq->seq3 = seq->seq2;
seq->effectdata = newdataadr(fd, seq->effectdata);
if (seq->type & SEQ_TYPE_EFFECT)
seq->flag |= SEQ_EFFECT_NOT_LOADED;
if (seq->type == SEQ_TYPE_SPEED) {
SpeedControlVars *s = seq->effectdata;
s->frameMap = NULL;
}
seq->strip = newdataadr(fd, seq->strip);
if (seq->strip && seq->strip->done==0) {
seq->strip->done = TRUE;
if (ELEM4(seq->type, SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) {
seq->strip->stripdata = newdataadr(fd, seq->strip->stripdata);
}
else {
seq->strip->stripdata = NULL;
}
if (seq->flag & SEQ_USE_CROP) {
seq->strip->crop = newdataadr(
fd, seq->strip->crop);
}
else {
seq->strip->crop = NULL;
}
if (seq->flag & SEQ_USE_TRANSFORM) {
seq->strip->transform = newdataadr(
fd, seq->strip->transform);
}
else {
seq->strip->transform = NULL;
}
if (seq->flag & SEQ_USE_PROXY) {
seq->strip->proxy = newdataadr(
fd, seq->strip->proxy);
seq->strip->proxy->anim = NULL;
}
else {
seq->strip->proxy = NULL;
}
if (seq->flag & SEQ_USE_COLOR_BALANCE) {
seq->strip->color_balance = newdataadr(
fd, seq->strip->color_balance);
}
else {
seq->strip->color_balance = NULL;
}
if (seq->strip->color_balance) {
// seq->strip->color_balance->gui = 0; // XXX - peter, is this relevant in 2.5?
}
2002-10-12 11:37:38 +00:00
}
}
SEQ_END
/* link metastack, slight abuse of structs here, have to restore pointer to internal part in struct */
{
Sequence temp;
char *poin;
2008-08-30 14:32:16 +00:00
intptr_t offset;
offset = ((intptr_t)&(temp.seqbase)) - ((intptr_t)&temp);
/* root pointer */
if (ed->seqbasep == old_seqbasep) {
ed->seqbasep = &ed->seqbase;
}
else {
poin = (char *)ed->seqbasep;
poin -= offset;
poin = newdataadr(fd, poin);
if (poin)
ed->seqbasep = (ListBase *)(poin+offset);
else
ed->seqbasep = &ed->seqbase;
}
/* stack */
link_list(fd, &(ed->metastack));
for (ms = ed->metastack.first; ms; ms= ms->next) {
ms->parseq = newdataadr(fd, ms->parseq);
if (ms->oldbasep == old_seqbasep)
ms->oldbasep= &ed->seqbase;
else {
poin = (char *)ms->oldbasep;
poin -= offset;
poin = newdataadr(fd, poin);
if (poin)
ms->oldbasep = (ListBase *)(poin+offset);
else
ms->oldbasep = &ed->seqbase;
}
}
}
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
sce->r.avicodecdata = newdataadr(fd, sce->r.avicodecdata);
if (sce->r.avicodecdata) {
sce->r.avicodecdata->lpFormat = newdataadr(fd, sce->r.avicodecdata->lpFormat);
sce->r.avicodecdata->lpParms = newdataadr(fd, sce->r.avicodecdata->lpParms);
}
sce->r.qtcodecdata = newdataadr(fd, sce->r.qtcodecdata);
if (sce->r.qtcodecdata) {
sce->r.qtcodecdata->cdParms = newdataadr(fd, sce->r.qtcodecdata->cdParms);
}
if (sce->r.ffcodecdata.properties) {
sce->r.ffcodecdata.properties = newdataadr(fd, sce->r.ffcodecdata.properties);
if (sce->r.ffcodecdata.properties) {
IDP_DirectLinkProperty(sce->r.ffcodecdata.properties,
(fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
}
}
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
link_list(fd, &(sce->markers));
=== 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
link_list(fd, &(sce->transform_spaces));
2006-01-26 22:18:46 +00:00
link_list(fd, &(sce->r.layers));
sce->nodetree = newdataadr(fd, sce->nodetree);
if (sce->nodetree)
Giant commit! A full detailed description of this will be done later... is several days of work. Here's a summary: Render: - Full cleanup of render code, removing *all* globals and bad level calls all over blender. Render module is now not called abusive anymore - API-fied calls to rendering - Full recode of internal render pipeline. Is now rendering tiles by default, prepared for much smarter 'bucket' render later. - Each thread now can render a full part - Renders were tested with 4 threads, goes fine, apart from some lookup tables in softshadow and AO still - Rendering is prepared to do multiple layers and passes - No single 32 bits trick in render code anymore, all 100% floats now. Writing images/movies - moved writing images to blender kernel (bye bye 'schrijfplaatje'!) - made a new Movie handle system, also in kernel. This will enable much easier use of movies in Blender PreviewRender: - Using new render API, previewrender (in buttons) now uses regular render code to generate images. - new datafile 'preview.blend.c' has the preview scenes in it - previews get rendered in exact displayed size (1 pixel = 1 pixel) 3D Preview render - new; press Pkey in 3d window, for a panel that continuously renders (pkey is for games, i know... but we dont do that in orange now!) - this render works nearly identical to buttons-preview render, so it stops rendering on any event (mouse, keyboard, etc) - on moving/scaling the panel, the render code doesn't recreate all geometry - same for shifting/panning view - all other operations (now) regenerate the full render database still. - this is WIP... but big fun, especially for simple scenes! Compositor - Using same node system as now in use for shaders, you can composit images - works pretty straightforward... needs much more options/tools and integration with rendering still - is not threaded yet, nor is so smart to only recalculate changes... will be done soon! - the "Render Result" node will get all layers/passes as output sockets - The "Output" node renders to a builtin image, which you can view in the Image window. (yes, output nodes to render-result, and to files, is on the list!) The Bad News - "Unified Render" is removed. It might come back in some stage, but this system should be built from scratch. I can't really understand this code... I expect it is not much needed, especially with advanced layer/passes control - Panorama render, Field render, Motion blur, is not coded yet... (I had to recode every single feature in render, so...!) - Lens Flare is also not back... needs total revision, might become composit effect though (using zbuffer for visibility) - Part render is gone! (well, thats obvious, its default now). - The render window is only restored with limited functionality... I am going to check first the option to render to a Image window, so Blender can become a true single-window application. :) For example, the 'Spare render buffer' (jkey) doesnt work. - Render with border, now default creates a smaller image - No zbuffers are written yet... on the todo! - Scons files and MSVC will need work to get compiling again OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
direct_link_nodetree(fd, sce->nodetree);
2002-10-12 11:37:38 +00:00
}
/* ************ READ WM ***************** */
static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
{
wmWindow *win;
wm->id.us = 1;
link_list(fd, &wm->windows);
for (win = wm->windows.first; win; win = win->next) {
win->ghostwin = NULL;
win->eventstate = NULL;
win->curswin = NULL;
win->tweak = NULL;
win->queue.first = win->queue.last = NULL;
win->handlers.first = win->handlers.last = NULL;
win->modalhandlers.first = win->modalhandlers.last = NULL;
win->subwindows.first = win->subwindows.last = NULL;
win->gesture.first = win->gesture.last = NULL;
win->drawdata = NULL;
win->drawmethod = -1;
win->drawfail = 0;
}
wm->timers.first = wm->timers.last = NULL;
wm->operators.first = wm->operators.last = NULL;
wm->paintcursors.first = wm->paintcursors.last = NULL;
wm->queue.first = wm->queue.last = NULL;
BKE_reports_init(&wm->reports, RPT_STORE);
wm->keyconfigs.first = wm->keyconfigs.last = NULL;
wm->defaultconf = NULL;
wm->addonconf = NULL;
wm->userconf = NULL;
wm->jobs.first = wm->jobs.last = NULL;
wm->drags.first = wm->drags.last = NULL;
wm->windrawable = NULL;
wm->winactive = NULL;
wm->initialized = 0;
wm->op_undo_depth = 0;
}
static void lib_link_windowmanager(FileData *fd, Main *main)
{
wmWindowManager *wm;
2009-09-16 17:43:09 +00:00
wmWindow *win;
for (wm = main->wm.first; wm; wm = wm->id.next) {
if (wm->id.flag & LIB_NEEDLINK) {
for (win = wm->windows.first; win; win = win->next)
win->screen = newlibadr(fd, NULL, win->screen);
2009-09-16 17:43:09 +00:00
wm->id.flag -= LIB_NEEDLINK;
}
}
}
/* ****************** READ GREASE PENCIL ***************** */
2002-10-12 11:37:38 +00:00
/* relinks grease-pencil data - used for direct_link and old file linkage */
static void direct_link_gpencil(FileData *fd, bGPdata *gpd)
{
bGPDlayer *gpl;
bGPDframe *gpf;
bGPDstroke *gps;
/* we must firstly have some grease-pencil data to link! */
if (gpd == NULL)
return;
/* relink layers */
link_list(fd, &gpd->layers);
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* relink frames */
link_list(fd, &gpl->frames);
gpl->actframe = newdataadr(fd, gpl->actframe);
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
/* relink strokes (and their points) */
link_list(fd, &gpf->strokes);
for (gps = gpf->strokes.first; gps; gps = gps->next) {
gps->points = newdataadr(fd, gps->points);
}
}
}
}
/* ****************** READ SCREEN ***************** */
static void butspace_version_132(SpaceButs *buts)
{
buts->v2d.tot.xmin = 0.0f;
buts->v2d.tot.ymin = 0.0f;
buts->v2d.tot.xmax = 1279.0f;
buts->v2d.tot.ymax = 228.0f;
buts->v2d.min[0] = 256.0f;
buts->v2d.min[1] = 42.0f;
buts->v2d.max[0] = 2048.0f;
buts->v2d.max[1] = 450.0f;
buts->v2d.minzoom = 0.5f;
buts->v2d.maxzoom = 1.21f;
buts->v2d.scroll = 0;
buts->v2d.keepzoom = 1;
buts->v2d.keeptot = 1;
}
/* note: file read without screens option G_FILE_NO_UI;
2012-04-22 11:54:53 +00:00
* check lib pointers in call below */
2002-10-12 11:37:38 +00:00
static void lib_link_screen(FileData *fd, Main *main)
{
bScreen *sc;
ScrArea *sa;
for (sc = main->screen.first; sc; sc = sc->id.next) {
if (sc->id.flag & LIB_NEEDLINK) {
sc->id.us = 1;
sc->scene = newlibadr(fd, sc->id.lib, sc->scene);
sc->animtimer = NULL; /* saved in rare cases */
for (sa = sc->areabase.first; sa; sa = sa->next) {
2002-10-12 11:37:38 +00:00
SpaceLink *sl;
sa->full = newlibadr(fd, sc->id.lib, sa->full);
for (sl = sa->spacedata.first; sl; sl= sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D*) sl;
BGpic *bgpic = NULL;
2002-10-12 11:37:38 +00:00
v3d->camera= newlibadr(fd, sc->id.lib, v3d->camera);
v3d->ob_centre= newlibadr(fd, sc->id.lib, v3d->ob_centre);
/* should be do_versions but not easy adding into the listbase */
if (v3d->bgpic) {
v3d->bgpic = newlibadr(fd, sc->id.lib, v3d->bgpic);
BLI_addtail(&v3d->bgpicbase, bgpic);
v3d->bgpic = NULL;
}
for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
bgpic->ima = newlibadr_us(fd, sc->id.lib, bgpic->ima);
bgpic->clip = newlibadr_us(fd, sc->id.lib, bgpic->clip);
2002-10-12 11:37:38 +00:00
}
if (v3d->localvd) {
v3d->localvd->camera = newlibadr(fd, sc->id.lib, v3d->localvd->camera);
2002-10-12 11:37:38 +00:00
}
}
else if (sl->spacetype == SPACE_IPO) {
SpaceIpo *sipo = (SpaceIpo *)sl;
bDopeSheet *ads = sipo->ads;
if (ads) {
ads->source = newlibadr(fd, sc->id.lib, ads->source);
ads->filter_grp = newlibadr(fd, sc->id.lib, ads->filter_grp);
}
2002-10-12 11:37:38 +00:00
}
else if (sl->spacetype == SPACE_BUTS) {
SpaceButs *sbuts = (SpaceButs *)sl;
sbuts->pinid = newlibadr(fd, sc->id.lib, sbuts->pinid);
sbuts->mainbo = sbuts->mainb;
sbuts->mainbuser = sbuts->mainb;
if (main->versionfile < 132)
butspace_version_132(sbuts);
2002-10-12 11:37:38 +00:00
}
else if (sl->spacetype == SPACE_FILE) {
SpaceFile *sfile = (SpaceFile *)sl;
sfile->files = NULL;
sfile->op = NULL;
sfile->layout = NULL;
sfile->folders_prev = NULL;
sfile->folders_next = NULL;
2002-10-12 11:37:38 +00:00
}
else if (sl->spacetype == SPACE_ACTION) {
SpaceAction *saction = (SpaceAction *)sl;
bDopeSheet *ads = &saction->ads;
if (ads) {
ads->source = newlibadr(fd, sc->id.lib, ads->source);
ads->filter_grp = newlibadr(fd, sc->id.lib, ads->filter_grp);
}
2002-10-12 11:37:38 +00:00
saction->action = newlibadr(fd, sc->id.lib, saction->action);
}
else if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
sima->image = newlibadr_us(fd, sc->id.lib, sima->image);
/* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
* so fingers crossed this works fine!
*/
sima->gpd = newlibadr_us(fd, sc->id.lib, sima->gpd);
2002-10-12 11:37:38 +00:00
}
else if (sl->spacetype == SPACE_NLA) {
SpaceNla *snla= (SpaceNla *)sl;
bDopeSheet *ads= snla->ads;
if (ads) {
ads->source = newlibadr(fd, sc->id.lib, ads->source);
ads->filter_grp = newlibadr(fd, sc->id.lib, ads->filter_grp);
}
2002-10-12 11:37:38 +00:00
}
else if (sl->spacetype == SPACE_TEXT) {
2002-10-12 11:37:38 +00:00
SpaceText *st= (SpaceText *)sl;
2002-10-12 11:37:38 +00:00
st->text= newlibadr(fd, sc->id.lib, st->text);
st->drawcache= NULL;
}
else if (sl->spacetype == SPACE_SCRIPT) {
SpaceScript *scpt = (SpaceScript *)sl;
2008-03-07 22:39:45 +00:00
/*scpt->script = NULL; - 2.45 set to null, better re-run the script */
if (scpt->script) {
scpt->script = newlibadr(fd, sc->id.lib, scpt->script);
2008-03-07 22:39:45 +00:00
if (scpt->script) {
SCRIPT_SET_NULL(scpt->script);
2008-03-07 22:39:45 +00:00
}
}
2002-10-12 11:37:38 +00:00
}
else if (sl->spacetype == SPACE_OUTLINER) {
2002-10-12 11:37:38 +00:00
SpaceOops *so= (SpaceOops *)sl;
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
TreeStoreElem *tselem;
int a;
so->tree.first = so->tree.last= NULL;
so->search_tse.id = newlibadr(fd, NULL, so->search_tse.id);
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
if (so->treestore) {
tselem = so->treestore->data;
for (a=0; a < so->treestore->usedelem; a++, tselem++) {
tselem->id = newlibadr(fd, NULL, tselem->id);
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
}
}
2002-10-12 11:37:38 +00:00
}
else if (sl->spacetype == SPACE_NODE) {
SpaceNode *snode = (SpaceNode *)sl;
snode->id = newlibadr(fd, sc->id.lib, snode->id);
snode->edittree = NULL;
if (ELEM3(snode->treetype, NTREE_COMPOSIT, NTREE_SHADER, NTREE_TEXTURE)) {
/* internal data, a bit patchy */
snode->nodetree = NULL;
if (snode->id) {
if (GS(snode->id->name)==ID_MA)
snode->nodetree = ((Material *)snode->id)->nodetree;
else if (GS(snode->id->name)==ID_WO)
snode->nodetree = ((World *)snode->id)->nodetree;
else if (GS(snode->id->name)==ID_LA)
snode->nodetree = ((Lamp *)snode->id)->nodetree;
else if (GS(snode->id->name)==ID_SCE)
snode->nodetree = ((Scene *)snode->id)->nodetree;
else if (GS(snode->id->name)==ID_TE)
snode->nodetree = ((Tex *)snode->id)->nodetree;
}
}
else {
snode->nodetree = newlibadr_us(fd, sc->id.lib, snode->nodetree);
}
snode->linkdrag.first = snode->linkdrag.last = NULL;
}
else if (sl->spacetype == SPACE_CLIP) {
SpaceClip *sclip = (SpaceClip *)sl;
sclip->clip = newlibadr_us(fd, sc->id.lib, sclip->clip);
sclip->mask = newlibadr_us(fd, sc->id.lib, sclip->mask);
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
sclip->scopes.track_preview = NULL;
sclip->draw_context = NULL;
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
sclip->scopes.ok = 0;
}
2002-10-12 11:37:38 +00:00
}
}
sc->id.flag -= LIB_NEEDLINK;
}
}
}
/* Only for undo files, or to restore a screen after reading without UI... */
static void *restore_pointer_by_name(Main *mainp, ID *id, int user)
{
if (id) {
ListBase *lb = which_libbase(mainp, GS(id->name));
if (lb) { // there's still risk of checking corrupt mem (freed Ids in oops)
ID *idn = lb->first;
char *name = id->name + 2;
for (; idn; idn = idn->next) {
if (idn->name[2] == name[0] && strcmp(idn->name+2, name) == 0) {
if (idn->lib == id->lib) {
if (user && idn->us == 0) idn->us++;
break;
}
}
}
return idn;
}
}
return NULL;
}
static int lib_link_seq_clipboard_cb(Sequence *seq, void *arg_pt)
{
Main *newmain = (Main *)arg_pt;
if (seq->sound) {
seq->sound = restore_pointer_by_name(newmain, (ID *)seq->sound, 0);
seq->sound->id.us++;
}
if (seq->scene)
seq->scene = restore_pointer_by_name(newmain, (ID *)seq->scene, 1);
if (seq->scene_camera)
seq->scene_camera = restore_pointer_by_name(newmain, (ID *)seq->scene_camera, 1);
return 1;
}
static void lib_link_clipboard_restore(Main *newmain)
{
/* update IDs stored in sequencer clipboard */
seqbase_recursive_apply(&seqbase_clipboard, lib_link_seq_clipboard_cb, newmain);
}
/* called from kernel/blender.c */
/* used to link a file (without UI) to the current UI */
/* note that it assumes the old pointers in UI are still valid, so old Main is not freed */
void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
{
wmWindow *win;
wmWindowManager *wm;
bScreen *sc;
ScrArea *sa;
/* first windowmanager */
for (wm = newmain->wm.first; wm; wm = wm->id.next) {
for (win= wm->windows.first; win; win= win->next) {
win->screen = restore_pointer_by_name(newmain, (ID *)win->screen, 1);
if (win->screen == NULL)
win->screen = curscreen;
win->screen->winid = win->winid;
}
}
for (sc = newmain->screen.first; sc; sc = sc->id.next) {
Scene *oldscene = sc->scene;
sc->scene= restore_pointer_by_name(newmain, (ID *)sc->scene, 1);
if (sc->scene == NULL)
sc->scene = curscene;
/* keep cursor location through undo */
copy_v3_v3(sc->scene->cursor, oldscene->cursor);
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
BGpic *bgpic;
ARegion *ar;
if (v3d->scenelock)
v3d->camera = NULL; /* always get from scene */
else
v3d->camera = restore_pointer_by_name(newmain, (ID *)v3d->camera, 1);
if (v3d->camera == NULL)
v3d->camera = sc->scene->camera;
v3d->ob_centre = restore_pointer_by_name(newmain, (ID *)v3d->ob_centre, 1);
for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) {
bgpic->ima = restore_pointer_by_name(newmain, (ID *)bgpic->ima, 1);
bgpic->clip = restore_pointer_by_name(newmain, (ID *)bgpic->clip, 1);
}
if (v3d->localvd) {
/*Base *base;*/
v3d->localvd->camera = sc->scene->camera;
/* localview can become invalid during undo/redo steps, so we exit it when no could be found */
/* XXX regionlocalview ?
for (base= sc->scene->base.first; base; base= base->next) {
if (base->lay & v3d->lay) break;
}
if (base==NULL) {
v3d->lay= v3d->localvd->lay;
v3d->layact= v3d->localvd->layact;
MEM_freeN(v3d->localvd);
v3d->localvd= NULL;
}
*/
}
else if (v3d->scenelock) v3d->lay = sc->scene->lay;
/* not very nice, but could help */
if ((v3d->layact & v3d->lay) == 0) v3d->layact = v3d->lay;
/* free render engines for now */
for (ar = sa->regionbase.first; ar; ar = ar->next) {
RegionView3D *rv3d= ar->regiondata;
if (rv3d && rv3d->render_engine) {
RE_engine_free(rv3d->render_engine);
rv3d->render_engine = NULL;
}
}
}
else if (sl->spacetype == SPACE_IPO) {
SpaceIpo *sipo = (SpaceIpo *)sl;
bDopeSheet *ads = sipo->ads;
if (ads) {
ads->source = restore_pointer_by_name(newmain, (ID *)ads->source, 1);
if (ads->filter_grp)
ads->filter_grp = restore_pointer_by_name(newmain, (ID *)ads->filter_grp, 0);
}
}
else if (sl->spacetype == SPACE_BUTS) {
SpaceButs *sbuts = (SpaceButs *)sl;
sbuts->pinid = restore_pointer_by_name(newmain, sbuts->pinid, 0);
//XXX if (sbuts->ri) sbuts->ri->curtile = 0;
}
else if (sl->spacetype == SPACE_FILE) {
SpaceFile *sfile = (SpaceFile *)sl;
sfile->op = NULL;
}
else if (sl->spacetype == SPACE_ACTION) {
SpaceAction *saction = (SpaceAction *)sl;
saction->action = restore_pointer_by_name(newmain, (ID *)saction->action, 1);
saction->ads.source= restore_pointer_by_name(newmain, (ID *)saction->ads.source, 1);
if (saction->ads.filter_grp)
saction->ads.filter_grp= restore_pointer_by_name(newmain, (ID *)saction->ads.filter_grp, 0);
}
else if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
sima->image = restore_pointer_by_name(newmain, (ID *)sima->image, 1);
/* this will be freed, not worth attempting to find same scene,
* since it gets initialized later */
sima->iuser.scene = NULL;
sima->scopes.waveform_1 = NULL;
sima->scopes.waveform_2 = NULL;
sima->scopes.waveform_3 = NULL;
sima->scopes.vecscope = NULL;
sima->scopes.ok = 0;
/* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
* so assume that here we're doing for undo only...
*/
sima->gpd = restore_pointer_by_name(newmain, (ID *)sima->gpd, 1);
}
else if (sl->spacetype == SPACE_NLA) {
SpaceNla *snla = (SpaceNla *)sl;
bDopeSheet *ads = snla->ads;
if (ads) {
ads->source = restore_pointer_by_name(newmain, (ID *)ads->source, 1);
if (ads->filter_grp)
ads->filter_grp = restore_pointer_by_name(newmain, (ID *)ads->filter_grp, 0);
}
}
else if (sl->spacetype == SPACE_TEXT) {
SpaceText *st = (SpaceText *)sl;
st->text = restore_pointer_by_name(newmain, (ID *)st->text, 1);
if (st->text == NULL) st->text = newmain->text.first;
}
else if (sl->spacetype == SPACE_SCRIPT) {
SpaceScript *scpt = (SpaceScript *)sl;
scpt->script = restore_pointer_by_name(newmain, (ID *)scpt->script, 1);
/*sc->script = NULL; - 2.45 set to null, better re-run the script */
if (scpt->script) {
SCRIPT_SET_NULL(scpt->script);
}
}
else if (sl->spacetype == SPACE_OUTLINER) {
SpaceOops *so= (SpaceOops *)sl;
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
int a;
so->search_tse.id = restore_pointer_by_name(newmain, so->search_tse.id, 0);
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
if (so->treestore) {
TreeStore *ts = so->treestore;
TreeStoreElem *tselem = ts->data;
for (a = 0; a < ts->usedelem; a++, tselem++) {
tselem->id = restore_pointer_by_name(newmain, tselem->id, 0);
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
}
}
}
else if (sl->spacetype == SPACE_NODE) {
Christmas coding work! ********* Node editor work: - To enable Nodes for Materials, you have to set the "Use Nodes" button, in the new Material buttons "Nodes" Panel or in header of the Node editor. Doing this will disable Material-Layers. - Nodes now execute materials ("shaders"), but still only using the previewrender code. - Nodes have (optional) previews for rendered images. - Node headers allow to hide buttons and/or preview image - Nodes can be dragged larger/smaller (right-bottom corner) - Nodes can be hidden (minimized) with hotkey H - CTRL+click on an Input Socket gives a popup with default values. - Changing Material/Texture or Mix node will adjust Node title. - Click-drag outside of a Node changes cursor to "Knife' and allows to draw a rect where to cut Links. - Added new node types RGBtoBW, Texture, In/Output, ColorRamp - Material Nodes have options to ouput diffuse or specular, or to use a negative normal. The input socket 'Normal' will force the material to use that normal, otherwise it uses the normal from the Material that has the node tree. - When drawing a link between two not-matching sockets, Blender inserts a converting node (now only for value/rgb combos) - When drawing a link to an input socket that's already in use, the old link will either disappear or flip to another unused socket. - A click on a Material Node will activate it, and show all its settings in the Material Buttons. Active Material Nodes draw the material icon in red. - A click on any node will show its options in the Node Panel in the Material buttons. - Multiple Output Nodes can be used, to sample contents of a tree, but only one Output is the real one, which is indicated in a different color and red material icon. - Added ThemeColors for node types - ALT+C will convert existing Material-Layers to Node... this currently only adds the material/mix nodes and connects them. Dunno if this is worth a lot of coding work to make perfect? - Press C to call another "Solve order", which will show all possible cyclic conflicts (if there are). - Technical: nodes now use "Type" structs which define the structure of nodes and in/output sockets. The Type structs store all fixed info, callbacks, and allow to reconstruct saved Nodes to match what is required by Blender. - Defining (new) nodes now is as simple as filling in a fixed Type struct, plus code some callbacks. A doc will be made! - Node preview images are by default float ********* Icon drawing: - Cleanup of how old icons were implemented in new system, making them 16x16 too, correctly centered *and* scaled. - Made drawing Icons use float coordinates - Moved BIF_calcpreview_image() into interface_icons.c, renamed it icon_from_image(). Removed a lot of unneeded Imbuf magic here! :) - Skipped scaling and imbuf copying when icons are OK size ********* Preview render: - Huge cleanup of code.... - renaming BIF_xxx calls that only were used internally - BIF_previewrender() now accepts an argument for rendering method, so it supports icons, buttonwindow previewrender and node editor - Only a single BIF_preview_changed() call now exists, supporting all signals as needed for buttos and node editor ********* More stuff: - glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format argument for GL_FLOAT rects - Made the ColorBand become a built-in button for interface.c Was a load of cleanup work in buttons_shading.c... - removed a load of unneeded glBlendFunc() calls - Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
SpaceNode *snode= (SpaceNode *)sl;
snode->id = restore_pointer_by_name(newmain, snode->id, 1);
snode->edittree = NULL;
if (ELEM3(snode->treetype, NTREE_COMPOSIT, NTREE_SHADER, NTREE_TEXTURE)) {
snode->nodetree = NULL;
if (snode->id) {
if (GS(snode->id->name)==ID_MA)
snode->nodetree = ((Material *)snode->id)->nodetree;
else if (GS(snode->id->name)==ID_SCE)
snode->nodetree = ((Scene *)snode->id)->nodetree;
else if (GS(snode->id->name)==ID_TE)
snode->nodetree = ((Tex *)snode->id)->nodetree;
}
}
else {
snode->nodetree= restore_pointer_by_name(newmain, &snode->nodetree->id, 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
}
else if (sl->spacetype == SPACE_CLIP) {
SpaceClip *sclip = (SpaceClip *)sl;
sclip->clip = restore_pointer_by_name(newmain, (ID *)sclip->clip, 1);
sclip->mask = restore_pointer_by_name(newmain, (ID *)sclip->mask, 1);
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
sclip->scopes.ok = 0;
}
}
}
}
/* update IDs stored in all possible clipboards */
lib_link_clipboard_restore(newmain);
}
static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
{
Panel *pa;
link_list(fd, &ar->panels);
for (pa = ar->panels.first; pa; pa = pa->next) {
pa->paneltab = newdataadr(fd, pa->paneltab);
pa->runtime_flag = 0;
pa->activedata = NULL;
pa->type = NULL;
}
ar->regiondata = newdataadr(fd, ar->regiondata);
if (ar->regiondata) {
if (spacetype == SPACE_VIEW3D) {
RegionView3D *rv3d = ar->regiondata;
rv3d->localvd = newdataadr(fd, rv3d->localvd);
rv3d->clipbb = newdataadr(fd, rv3d->clipbb);
rv3d->depths = NULL;
rv3d->ri = NULL;
rv3d->render_engine = NULL;
rv3d->sms = NULL;
rv3d->smooth_timer = NULL;
}
}
ar->v2d.tab_offset = NULL;
ar->v2d.tab_num = 0;
ar->v2d.tab_cur = 0;
ar->handlers.first = ar->handlers.last = NULL;
ar->uiblocks.first = ar->uiblocks.last = NULL;
ar->headerstr = NULL;
ar->swinid = 0;
ar->type = NULL;
ar->swap = 0;
ar->do_draw = FALSE;
2.5: WM Compositing * Triple Buffer is now more complete: - Proper handling of window resize, duplicate, etc. - It now uses 3x3 textures (or less) if the power of two sizes do not match well. That still has a worst case wast of 23.4%, but better than 300%. - It can also use the ARB/NV/EXT_texture_rectangle extension now, which may be supported on hardware that does not support ARB_texture_non_power_of_two. - Gesture, menu and brushe redraws now require no redraws at all from the area regions. So even on a high poly scene just moving the paint cursor or opening a menu should be fast. * Testing can be done by setting the "Window Draw Method" in the User Preferences in the outliner. "Overlap" is still default, since "Triple Buffer" has not been tested on computers other than mine, would like to avoid crashing Blender on startup in case there is a common bug, but it's ready for testing now. - For reference "Full" draws the full window each time. - "Triple Buffer" should work for both swap copy and swap exchange systems, the latter still need the -E command line option for "Overlap". - Resizing and going fullscreen still gives flicker here but no more than "Full" drawing. * Partial Redraw was added. ED_region_tag_redraw_partial takes a rect in window coordinates to define a subarea of the region. On region draw it will then set glScissor to a smaller area, and ar->drawrct will always be set to either the partial or full window rect. The latter can then be used for clipping in the 3D view or clipping interface drawing. Neither is implemented yet.
2009-01-23 03:52:52 +00:00
memset(&ar->drawrct, 0, sizeof(ar->drawrct));
}
/* for the saved 2.50 files without regiondata */
/* and as patch for 2.48 and older */
void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions)
{
ARegion *ar;
for (ar = regions->first; ar; ar = ar->next) {
if (ar->regiontype==RGN_TYPE_WINDOW && ar->regiondata==NULL) {
RegionView3D *rv3d;
rv3d = ar->regiondata = MEM_callocN(sizeof(RegionView3D), "region v3d patch");
rv3d->persp = (char)v3d->persp;
rv3d->view = (char)v3d->view;
rv3d->dist = v3d->dist;
copy_v3_v3(rv3d->ofs, v3d->ofs);
copy_qt_qt(rv3d->viewquat, v3d->viewquat);
}
}
2009-09-16 17:43:09 +00:00
/* this was not initialized correct always */
if (v3d->twtype == 0)
v3d->twtype = V3D_MANIP_TRANSLATE;
}
2002-10-12 11:37:38 +00:00
static void direct_link_screen(FileData *fd, bScreen *sc)
{
ScrArea *sa;
ScrVert *sv;
ScrEdge *se;
int a;
2002-10-12 11:37:38 +00:00
link_list(fd, &(sc->vertbase));
link_list(fd, &(sc->edgebase));
link_list(fd, &(sc->areabase));
sc->regionbase.first = sc->regionbase.last= NULL;
sc->context = NULL;
sc->mainwin = sc->subwinactive= 0; /* indices */
sc->swap = 0;
/* hacky patch... but people have been saving files with the verse-blender,
2012-04-22 11:54:53 +00:00
* causing the handler to keep running for ever, with no means to disable it */
for (a = 0; a < SCREEN_MAXHANDLER; a+=2) {
if (sc->handler[a] == SCREEN_HANDLER_VERSE) {
sc->handler[a] = 0;
break;
}
}
2002-10-12 11:37:38 +00:00
/* edges */
for (se = sc->edgebase.first; se; se = se->next) {
se->v1 = newdataadr(fd, se->v1);
se->v2 = newdataadr(fd, se->v2);
if ((intptr_t)se->v1 > (intptr_t)se->v2) {
sv = se->v1;
se->v1 = se->v2;
se->v2 = sv;
2002-10-12 11:37:38 +00:00
}
if (se->v1 == NULL) {
2002-10-12 11:37:38 +00:00
printf("error reading screen... file corrupt\n");
se->v1 = se->v2;
2002-10-12 11:37:38 +00:00
}
}
2002-10-12 11:37:38 +00:00
/* areas */
for (sa = sc->areabase.first; sa; sa = sa->next) {
2002-10-12 11:37:38 +00:00
SpaceLink *sl;
ARegion *ar;
2002-10-12 11:37:38 +00:00
link_list(fd, &(sa->spacedata));
link_list(fd, &(sa->regionbase));
sa->handlers.first = sa->handlers.last = NULL;
sa->type = NULL; /* spacetype callbacks */
for (ar = sa->regionbase.first; ar; ar = ar->next)
direct_link_region(fd, ar, sa->spacetype);
/* accident can happen when read/save new file with older version */
/* 2.50: we now always add spacedata for info */
if (sa->spacedata.first==NULL) {
SpaceInfo *sinfo= MEM_callocN(sizeof(SpaceInfo), "spaceinfo");
sa->spacetype= sinfo->spacetype= SPACE_INFO;
BLI_addtail(&sa->spacedata, sinfo);
}
/* add local view3d too */
else if (sa->spacetype == SPACE_VIEW3D)
blo_do_versions_view3d_split_250(sa->spacedata.first, &sa->regionbase);
for (sl = sa->spacedata.first; sl; sl = sl->next) {
link_list(fd, &(sl->regionbase));
for (ar = sl->regionbase.first; ar; ar = ar->next)
direct_link_region(fd, ar, sl->spacetype);
if (sl->spacetype == SPACE_VIEW3D) {
2002-10-12 11:37:38 +00:00
View3D *v3d= (View3D*) sl;
BGpic *bgpic;
v3d->flag |= V3D_INVALID_BACKBUF;
link_list(fd, &v3d->bgpicbase);
/* should be do_versions except this doesnt fit well there */
if (v3d->bgpic) {
bgpic = newdataadr(fd, v3d->bgpic);
BLI_addtail(&v3d->bgpicbase, bgpic);
v3d->bgpic = NULL;
}
for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next)
bgpic->iuser.ok = 1;
if (v3d->gpd) {
v3d->gpd = newdataadr(fd, v3d->gpd);
direct_link_gpencil(fd, v3d->gpd);
}
v3d->localvd = newdataadr(fd, v3d->localvd);
v3d->afterdraw_transp.first = v3d->afterdraw_transp.last = NULL;
v3d->afterdraw_xray.first = v3d->afterdraw_xray.last = NULL;
v3d->afterdraw_xraytransp.first = v3d->afterdraw_xraytransp.last = NULL;
v3d->properties_storage = NULL;
/* render can be quite heavy, set to wire on load */
if (v3d->drawtype == OB_RENDER)
v3d->drawtype = OB_WIRE;
blo_do_versions_view3d_split_250(v3d, &sl->regionbase);
2002-10-12 11:37:38 +00:00
}
else if (sl->spacetype == SPACE_IPO) {
SpaceIpo *sipo = (SpaceIpo *)sl;
sipo->ads = newdataadr(fd, sipo->ads);
sipo->ghostCurves.first = sipo->ghostCurves.last = NULL;
}
else if (sl->spacetype == SPACE_NLA) {
SpaceNla *snla = (SpaceNla *)sl;
snla->ads = newdataadr(fd, snla->ads);
}
else if (sl->spacetype == SPACE_OUTLINER) {
SpaceOops *soops = (SpaceOops *) sl;
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
soops->treestore = newdataadr(fd, soops->treestore);
if (soops->treestore) {
soops->treestore->data = newdataadr(fd, soops->treestore->data);
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
/* we only saved what was used */
soops->treestore->totelem = soops->treestore->usedelem;
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
soops->storeflag |= SO_TREESTORE_CLEANUP; // at first draw
}
2002-10-12 11:37:38 +00:00
}
else if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
sima->cumap = newdataadr(fd, sima->cumap);
if (sima->cumap)
direct_link_curvemapping(fd, sima->cumap);
sima->iuser.scene = NULL;
sima->iuser.ok = 1;
sima->scopes.waveform_1 = NULL;
sima->scopes.waveform_2 = NULL;
sima->scopes.waveform_3 = NULL;
sima->scopes.vecscope = NULL;
sima->scopes.ok = 0;
/* WARNING: gpencil data is no longer stored directly in sima after 2.5
* so sacrifice a few old files for now to avoid crashes with new files!
* committed: r28002 */
#if 0
sima->gpd = newdataadr(fd, sima->gpd);
if (sima->gpd)
direct_link_gpencil(fd, sima->gpd);
#endif
}
else if (sl->spacetype == SPACE_NODE) {
SpaceNode *snode = (SpaceNode *)sl;
if (snode->gpd) {
snode->gpd = newdataadr(fd, snode->gpd);
direct_link_gpencil(fd, snode->gpd);
}
}
else if (sl->spacetype == SPACE_TIME) {
SpaceTime *stime = (SpaceTime *)sl;
stime->caches.first = stime->caches.last = NULL;
}
else if (sl->spacetype == SPACE_LOGIC) {
SpaceLogic *slogic = (SpaceLogic *)sl;
if (slogic->gpd) {
slogic->gpd = newdataadr(fd, slogic->gpd);
direct_link_gpencil(fd, slogic->gpd);
}
}
else if (sl->spacetype == SPACE_SEQ) {
SpaceSeq *sseq = (SpaceSeq *)sl;
if (sseq->gpd) {
sseq->gpd = newdataadr(fd, sseq->gpd);
direct_link_gpencil(fd, sseq->gpd);
}
}
else if (sl->spacetype == SPACE_BUTS) {
SpaceButs *sbuts = (SpaceButs *)sl;
sbuts->path= NULL;
sbuts->texuser= NULL;
}
else if (sl->spacetype == SPACE_CONSOLE) {
SpaceConsole *sconsole = (SpaceConsole *)sl;
2010-04-24 21:14:05 +00:00
ConsoleLine *cl, *cl_next;
link_list(fd, &sconsole->scrollback);
link_list(fd, &sconsole->history);
//for (cl= sconsole->scrollback.first; cl; cl= cl->next)
// cl->line= newdataadr(fd, cl->line);
2012-04-22 11:54:53 +00:00
/* comma expressions, (e.g. expr1, expr2, expr3) evalutate each expression,
* from left to right. the right-most expression sets the result of the comma
* expression as a whole*/
for (cl = sconsole->history.first; cl; cl = cl_next) {
cl_next = cl->next;
cl->line = newdataadr(fd, cl->line);
if (cl->line) {
/* the allocted length is not written, so reset here */
cl->len_alloc = cl->len + 1;
}
else {
BLI_remlink(&sconsole->history, cl);
MEM_freeN(cl);
}
}
}
else if (sl->spacetype == SPACE_FILE) {
SpaceFile *sfile = (SpaceFile *)sl;
/* this sort of info is probably irrelevant for reloading...
* plus, it isn't saved to files yet!
*/
sfile->folders_prev = sfile->folders_next = NULL;
sfile->files = NULL;
sfile->layout = NULL;
sfile->op = NULL;
sfile->params = newdataadr(fd, sfile->params);
}
2002-10-12 11:37:38 +00:00
}
sa->actionzones.first = sa->actionzones.last = NULL;
sa->v1 = newdataadr(fd, sa->v1);
sa->v2 = newdataadr(fd, sa->v2);
sa->v3 = newdataadr(fd, sa->v3);
sa->v4 = newdataadr(fd, sa->v4);
2002-10-12 11:37:38 +00:00
}
}
2002-10-12 11:37:38 +00:00
/* ********** READ LIBRARY *************** */
static void direct_link_library(FileData *fd, Library *lib, Main *main)
2002-10-12 11:37:38 +00:00
{
Main *newmain;
for (newmain = fd->mainlist->first; newmain; newmain = newmain->next) {
if (newmain->curlib) {
if (BLI_path_cmp(newmain->curlib->filepath, lib->filepath) == 0) {
BKE_reportf_wrap(fd->reports, RPT_WARNING,
"Library '%s', '%s' had multiple instances, save and reload!",
lib->name, lib->filepath);
change_idid_adr(fd->mainlist, fd, lib, newmain->curlib);
// change_idid_adr_fd(fd, lib, newmain->curlib);
BLI_remlink(&main->library, lib);
MEM_freeN(lib);
return;
}
}
}
/* make sure we have full path in lib->filename */
BLI_strncpy(lib->filepath, lib->name, sizeof(lib->name));
cleanup_path(fd->relabase, lib->filepath);
// printf("direct_link_library: name %s\n", lib->name);
// printf("direct_link_library: filename %s\n", lib->filename);
/* new main */
2002-10-12 11:37:38 +00:00
newmain= MEM_callocN(sizeof(Main), "directlink");
BLI_addtail(fd->mainlist, newmain);
newmain->curlib = lib;
lib->parent = NULL;
2002-10-12 11:37:38 +00:00
}
static void lib_link_library(FileData *UNUSED(fd), Main *main)
2002-10-12 11:37:38 +00:00
{
Library *lib;
for (lib = main->library.first; lib; lib = lib->id.next) {
lib->id.us = 1;
}
}
/* Always call this once you have loaded new library data to set the relative paths correctly in relation to the blend file */
static void fix_relpaths_library(const char *basepath, Main *main)
{
Library *lib;
/* BLO_read_from_memory uses a blank filename */
if (basepath == NULL || basepath[0] == '\0') {
for (lib = main->library.first; lib; lib= lib->id.next) {
/* when loading a linked lib into a file which has not been saved,
* there is nothing we can be relative to, so instead we need to make
* it absolute. This can happen when appending an object with a relative
* link into an unsaved blend file. See [#27405].
* The remap relative option will make it relative again on save - campbell */
if (strncmp(lib->name, "//", 2) == 0) {
BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name));
}
}
}
else {
for (lib = main->library.first; lib; lib = lib->id.next) {
/* Libraries store both relative and abs paths, recreate relative paths,
* relative to the blend file since indirectly linked libs will be relative to their direct linked library */
if (strncmp(lib->name, "//", 2) == 0) { /* if this is relative to begin with? */
BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name));
BLI_path_rel(lib->name, basepath);
}
}
2002-10-12 11:37:38 +00:00
}
}
/* ************ READ SPEAKER ***************** */
static void lib_link_speaker(FileData *fd, Main *main)
{
Speaker *spk;
for (spk = main->speaker.first; spk; spk = spk->id.next) {
if (spk->id.flag & LIB_NEEDLINK) {
if (spk->adt) lib_link_animdata(fd, &spk->id, spk->adt);
spk->sound= newlibadr(fd, spk->id.lib, spk->sound);
if (spk->sound) {
spk->sound->id.us++;
}
spk->id.flag -= LIB_NEEDLINK;
}
}
}
static void direct_link_speaker(FileData *fd, Speaker *spk)
{
spk->adt = newdataadr(fd, spk->adt);
direct_link_animdata(fd, spk->adt);
2012-04-22 11:54:53 +00:00
#if 0
spk->sound = newdataadr(fd, spk->sound);
2012-04-22 11:54:53 +00:00
direct_link_sound(fd, spk->sound);
#endif
}
2002-10-12 11:37:38 +00:00
/* ************** READ SOUND ******************* */
static void direct_link_sound(FileData *fd, bSound *sound)
{
2009-09-16 17:43:09 +00:00
sound->handle = NULL;
sound->playback_handle = NULL;
sound->waveform = NULL;
2002-10-12 11:37:38 +00:00
// versioning stuff, if there was a cache, then we enable caching:
if (sound->cache) {
sound->flags |= SOUND_FLAGS_CACHING;
sound->cache = NULL;
}
2002-10-12 11:37:38 +00:00
sound->packedfile = direct_link_packedfile(fd, sound->packedfile);
sound->newpackedfile = direct_link_packedfile(fd, sound->newpackedfile);
}
static void lib_link_sound(FileData *fd, Main *main)
{
bSound *sound;
for (sound = main->sound.first; sound; sound = sound->id.next) {
if (sound->id.flag & LIB_NEEDLINK) {
2002-10-12 11:37:38 +00:00
sound->id.flag -= LIB_NEEDLINK;
sound->ipo = newlibadr_us(fd, sound->id.lib, sound->ipo); // XXX depreceated - old animation system
2009-09-16 17:43:09 +00:00
sound_load(main, sound);
2002-10-12 11:37:38 +00:00
}
}
}
/* ***************** READ GROUP *************** */
static void direct_link_group(FileData *fd, Group *group)
{
link_list(fd, &group->gobject);
}
static void lib_link_group(FileData *fd, Main *main)
{
Group *group;
2002-10-12 11:37:38 +00:00
GroupObject *go;
Big commit with work on Groups & Libraries: -> Any Group Duplicate now can get local timing and local NLA override. This enables to control the entire animation system of the Group. Two methods for this have been implemented. 1) The quick way: just give the duplicator a "Startframe" offset. 2) Advanced: in the NLA Editor you can add ActionStrips to the duplicator to override NLA/action of any Grouped Object. For "Group NLA" to work, an ActionStrip needs to know which Object in a group it controls. On adding a strip, the code checks if an Action was already used by an Object in the Group, and assigns it automatic to that Object. You can also set this in the Nkey "Properties" panel for the strip. Change in NLA: the SHIFT+A "Add strip" command now always adds strips to the active Object. (It used to check where mouse was). This allows to add NLA strips to Objects that didn't have actions/nla yet. Important note: In Blender, duplicates are fully procedural and generated on the fly for each redraw. This means that redraw speed equals to stepping through frames, when using animated Duplicated Groups. -> Recoded entire duplicator system The old method was antique and clumsy, using globals and full temporal copies of Object. The new system is nicer in control, faster, and since it doesn't use temporal object copies anymore, it works better with Derived Mesh and DisplayList and rendering. By centralizing the code for duplicating, more options can be easier added. Features to note: - Duplicates now draw selected/unselected based on its Duplicator setting. - Same goes for the drawtype (wire, solid, selection outline, etc) - Duplicated Groups can be normally selected too Bonus goodie: SHIFT+A (Toolbox) now has entry "Add group" too, with a listing of all groups, allowing to add Group instances immediate. -> Library System - SHIFT+F4 data browse now shows the entire path for linked data - Outliner draws Library Icons to denote linked data - Outliner operation added: "Make Local" for library data. - Outliner now also draws Groups in regular view, allowing to unlink too. -> Fixes - depsgraph missed signal update for bone-parented Objects - on reading file, the entire database was tagged to "recalc" fully, causing unnecessary slowdown on reading. Might have missed stuff... :)
2005-12-11 13:23:30 +00:00
int add_us;
for (group = main->group.first; group; group = group->id.next) {
if (group->id.flag & LIB_NEEDLINK) {
2002-10-12 11:37:38 +00:00
group->id.flag -= LIB_NEEDLINK;
Big commit with work on Groups & Libraries: -> Any Group Duplicate now can get local timing and local NLA override. This enables to control the entire animation system of the Group. Two methods for this have been implemented. 1) The quick way: just give the duplicator a "Startframe" offset. 2) Advanced: in the NLA Editor you can add ActionStrips to the duplicator to override NLA/action of any Grouped Object. For "Group NLA" to work, an ActionStrip needs to know which Object in a group it controls. On adding a strip, the code checks if an Action was already used by an Object in the Group, and assigns it automatic to that Object. You can also set this in the Nkey "Properties" panel for the strip. Change in NLA: the SHIFT+A "Add strip" command now always adds strips to the active Object. (It used to check where mouse was). This allows to add NLA strips to Objects that didn't have actions/nla yet. Important note: In Blender, duplicates are fully procedural and generated on the fly for each redraw. This means that redraw speed equals to stepping through frames, when using animated Duplicated Groups. -> Recoded entire duplicator system The old method was antique and clumsy, using globals and full temporal copies of Object. The new system is nicer in control, faster, and since it doesn't use temporal object copies anymore, it works better with Derived Mesh and DisplayList and rendering. By centralizing the code for duplicating, more options can be easier added. Features to note: - Duplicates now draw selected/unselected based on its Duplicator setting. - Same goes for the drawtype (wire, solid, selection outline, etc) - Duplicated Groups can be normally selected too Bonus goodie: SHIFT+A (Toolbox) now has entry "Add group" too, with a listing of all groups, allowing to add Group instances immediate. -> Library System - SHIFT+F4 data browse now shows the entire path for linked data - Outliner draws Library Icons to denote linked data - Outliner operation added: "Make Local" for library data. - Outliner now also draws Groups in regular view, allowing to unlink too. -> Fixes - depsgraph missed signal update for bone-parented Objects - on reading file, the entire database was tagged to "recalc" fully, causing unnecessary slowdown on reading. Might have missed stuff... :)
2005-12-11 13:23:30 +00:00
add_us = 0;
Big commit with work on Groups & Libraries: -> Any Group Duplicate now can get local timing and local NLA override. This enables to control the entire animation system of the Group. Two methods for this have been implemented. 1) The quick way: just give the duplicator a "Startframe" offset. 2) Advanced: in the NLA Editor you can add ActionStrips to the duplicator to override NLA/action of any Grouped Object. For "Group NLA" to work, an ActionStrip needs to know which Object in a group it controls. On adding a strip, the code checks if an Action was already used by an Object in the Group, and assigns it automatic to that Object. You can also set this in the Nkey "Properties" panel for the strip. Change in NLA: the SHIFT+A "Add strip" command now always adds strips to the active Object. (It used to check where mouse was). This allows to add NLA strips to Objects that didn't have actions/nla yet. Important note: In Blender, duplicates are fully procedural and generated on the fly for each redraw. This means that redraw speed equals to stepping through frames, when using animated Duplicated Groups. -> Recoded entire duplicator system The old method was antique and clumsy, using globals and full temporal copies of Object. The new system is nicer in control, faster, and since it doesn't use temporal object copies anymore, it works better with Derived Mesh and DisplayList and rendering. By centralizing the code for duplicating, more options can be easier added. Features to note: - Duplicates now draw selected/unselected based on its Duplicator setting. - Same goes for the drawtype (wire, solid, selection outline, etc) - Duplicated Groups can be normally selected too Bonus goodie: SHIFT+A (Toolbox) now has entry "Add group" too, with a listing of all groups, allowing to add Group instances immediate. -> Library System - SHIFT+F4 data browse now shows the entire path for linked data - Outliner draws Library Icons to denote linked data - Outliner operation added: "Make Local" for library data. - Outliner now also draws Groups in regular view, allowing to unlink too. -> Fixes - depsgraph missed signal update for bone-parented Objects - on reading file, the entire database was tagged to "recalc" fully, causing unnecessary slowdown on reading. Might have missed stuff... :)
2005-12-11 13:23:30 +00:00
for (go = group->gobject.first; go; go = go->next) {
2002-10-12 11:37:38 +00:00
go->ob= newlibadr(fd, group->id.lib, go->ob);
if (go->ob) {
go->ob->flag |= OB_FROMGROUP;
Big commit with work on Groups & Libraries: -> Any Group Duplicate now can get local timing and local NLA override. This enables to control the entire animation system of the Group. Two methods for this have been implemented. 1) The quick way: just give the duplicator a "Startframe" offset. 2) Advanced: in the NLA Editor you can add ActionStrips to the duplicator to override NLA/action of any Grouped Object. For "Group NLA" to work, an ActionStrip needs to know which Object in a group it controls. On adding a strip, the code checks if an Action was already used by an Object in the Group, and assigns it automatic to that Object. You can also set this in the Nkey "Properties" panel for the strip. Change in NLA: the SHIFT+A "Add strip" command now always adds strips to the active Object. (It used to check where mouse was). This allows to add NLA strips to Objects that didn't have actions/nla yet. Important note: In Blender, duplicates are fully procedural and generated on the fly for each redraw. This means that redraw speed equals to stepping through frames, when using animated Duplicated Groups. -> Recoded entire duplicator system The old method was antique and clumsy, using globals and full temporal copies of Object. The new system is nicer in control, faster, and since it doesn't use temporal object copies anymore, it works better with Derived Mesh and DisplayList and rendering. By centralizing the code for duplicating, more options can be easier added. Features to note: - Duplicates now draw selected/unselected based on its Duplicator setting. - Same goes for the drawtype (wire, solid, selection outline, etc) - Duplicated Groups can be normally selected too Bonus goodie: SHIFT+A (Toolbox) now has entry "Add group" too, with a listing of all groups, allowing to add Group instances immediate. -> Library System - SHIFT+F4 data browse now shows the entire path for linked data - Outliner draws Library Icons to denote linked data - Outliner operation added: "Make Local" for library data. - Outliner now also draws Groups in regular view, allowing to unlink too. -> Fixes - depsgraph missed signal update for bone-parented Objects - on reading file, the entire database was tagged to "recalc" fully, causing unnecessary slowdown on reading. Might have missed stuff... :)
2005-12-11 13:23:30 +00:00
/* if group has an object, it increments user... */
add_us = 1;
if (go->ob->id.us == 0)
go->ob->id.us = 1;
}
2002-10-12 11:37:38 +00:00
}
if (add_us) group->id.us++;
rem_from_group(group, NULL, NULL, NULL); /* removes NULL entries */
2002-10-12 11:37:38 +00:00
}
}
}
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
/* ***************** READ MOVIECLIP *************** */
static void direct_link_movieReconstruction(FileData *fd, MovieTrackingReconstruction *reconstruction)
{
reconstruction->cameras = newdataadr(fd, reconstruction->cameras);
}
static void direct_link_movieTracks(FileData *fd, ListBase *tracksbase)
{
MovieTrackingTrack *track;
link_list(fd, tracksbase);
for (track = tracksbase->first; track; track = track->next) {
track->markers = newdataadr(fd, track->markers);
}
}
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
static void direct_link_movieclip(FileData *fd, MovieClip *clip)
{
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *object;
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
clip->adt= newdataadr(fd, clip->adt);
if (fd->movieclipmap) clip->cache = newmclipadr(fd, clip->cache);
else clip->cache = NULL;
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
if (fd->movieclipmap) clip->tracking.camera.intrinsics = newmclipadr(fd, clip->tracking.camera.intrinsics);
else clip->tracking.camera.intrinsics = NULL;
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
direct_link_movieTracks(fd, &tracking->tracks);
direct_link_movieReconstruction(fd, &tracking->reconstruction);
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
clip->tracking.act_track = newdataadr(fd, clip->tracking.act_track);
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
clip->anim = NULL;
clip->tracking_context = NULL;
clip->tracking.stats = NULL;
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
clip->tracking.stabilization.ok = 0;
clip->tracking.stabilization.scaleibuf = NULL;
clip->tracking.stabilization.rot_track = newdataadr(fd, clip->tracking.stabilization.rot_track);
clip->tracking.dopesheet.ok = 0;
clip->tracking.dopesheet.channels.first = clip->tracking.dopesheet.channels.last = NULL;
link_list(fd, &tracking->objects);
for (object = tracking->objects.first; object; object = object->next) {
direct_link_movieTracks(fd, &object->tracks);
direct_link_movieReconstruction(fd, &object->reconstruction);
}
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
}
static void lib_link_movieclip(FileData *fd, Main *main)
{
MovieClip *clip;
for (clip = main->movieclip.first; clip; clip = clip->id.next) {
if (clip->id.flag & LIB_NEEDLINK) {
if (clip->adt)
lib_link_animdata(fd, &clip->id, clip->adt);
clip->gpd = newlibadr_us(fd, clip->id.lib, clip->gpd);
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
clip->id.flag -= LIB_NEEDLINK;
}
}
}
/* ***************** READ MOVIECLIP *************** */
static void direct_link_mask(FileData *fd, Mask *mask)
{
MaskLayer *masklay;
mask->adt = newdataadr(fd, mask->adt);
link_list(fd, &mask->masklayers);
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
MaskSpline *spline;
MaskLayerShape *masklay_shape;
link_list(fd, &masklay->splines);
for (spline = masklay->splines.first; spline; spline = spline->next) {
int i;
spline->points = newdataadr(fd, spline->points);
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
if (point->tot_uw)
point->uw = newdataadr(fd, point->uw);
}
}
link_list(fd, &masklay->splines_shapes);
for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) {
masklay_shape->data = newdataadr(fd, masklay_shape->data);
}
masklay->act_spline = newdataadr(fd, masklay->act_spline);
masklay->act_point = newdataadr(fd, masklay->act_point);
}
}
static void lib_link_mask_parent(FileData *fd, Mask *mask, MaskParent *parent)
{
parent->id = newlibadr_us(fd, mask->id.lib, parent->id);
}
static void lib_link_mask(FileData *fd, Main *main)
{
Mask *mask;
mask = main->mask.first;
while (mask) {
2012-06-04 20:11:09 +00:00
if (mask->id.flag & LIB_NEEDLINK) {
MaskLayer *masklay;
if (mask->adt)
lib_link_animdata(fd, &mask->id, mask->adt);
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
MaskSpline *spline;
spline = masklay->splines.first;
while (spline) {
int i;
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
lib_link_mask_parent(fd, mask, &point->parent);
}
lib_link_mask_parent(fd, mask, &spline->parent);
spline = spline->next;
}
}
mask->id.flag -= LIB_NEEDLINK;
}
mask = mask->id.next;
}
}
/* ************** GENERAL & MAIN ******************** */
2002-10-12 11:37:38 +00:00
Orange: more noodle updates! **** NEW: Group Nodes Node trees usually become messy and confusing quickly, so we need not only a way to collapse Nodes into single 'groups', but also a way to re-use that data to create libraries of effects. This has been done by making a new Library data type, the NodeTree. Everything that has been grouped is stored here, and available for re-use, appending or linking. These NodeTrees are fully generic, i.e. can store shader trees, composit trees, and so on. The 'type' value as stored in the NodeTree will keep track of internal type definitions and execute/drawing callbacks. Needless to say, re-using shader trees in a composit tree is a bit useless, and will be prevented in the browsing code. :) So; any NodeTree can become a "Goup Node" inside in a NodeTree. This Group Node then works just like any Node. To prevent the current code to become too complex, I've disabled the possibility to insert Groups inside of Groups. That might be enabled later, but is a real nasty piece of code to get OK. Since Group Nodes are a dynamic Node type, a lot of work has been done to ensure Node definitions can be dynamic too, but still allow to be stored in files, and allow to be verified for type-definition changes on reloading. This system needs a little bit maturing still, so the Python gurus should better wait a little bit! (Also for me to write the definite API docs for it). What works now: - Press CTRL+G to create a new Group. The grouping code checks for impossible selections (like an unselected node between selected nodes). Everthing that's selected then gets removed from the current tree, and inserted in a new NodeTree library data block. A Group Node then is added which links to this new NodeTree. - Press ALT+G to ungroup. This will not delete the NodeTree library data, but just duplicate the Group into the current tree. - Press TAB, or click on the NodeTree icon to edit Groups. Note that NodeTrees are instances, so editing one Group will also change the other users. This also means that when removing nodes in a Group (or hiding sockets or changing internal links) this is immediately corrected for all users of this Group, also in other Materials. - While editing Groups, only the internal Nodes can be edited. A single click outside of the Group boundary will close this 'edit mode'. What needs to be done: - SHIFT+A menu in toolbox style, also including a list of Groups - Enable the single-user button in the Group Node - Displaying all (visible) internal group UI elements in the Node Panel - Enable Library linking and prevent editing of Groups then. **** NEW: Socket Visibility control Node types will be generated with a lot of possible inputs or outputs, and drawing all sockets all the time isn't very useful then. A new option in the Node header ('plus' icon) allows to either hide all unused sockets (first keypress) or to reveil them (when there are hidden sockets, the icon displays black, otherwise it's blended). Hidden sockets in Nodes also are not exported to a Group, so this way you can control what options (in/outputs) exactly are available. To be done: - a way to hide individual sockets, like with a RMB click on it. **** NEW: Nodes now render! This is still quite primitive, more on a level to replace the (now obsolete and disabled) Material Layers. What needs to be done: - make the "Geometry" node work properly, also for AA textures - make the Texture Node work (does very little at the moment) - give Material Nodes all inputs as needed (like Map-to Panel) - find a way to export more data from a Material Node, like the shadow value, or light intensity only, etc Very important also to separate from the Material Buttons the "global" options, like "Ztransp" or "Wire" or "Halo". These can not be set for each Material-Node individually. Also note that the Preview Render (Buttons window) now renders a bit differently. This was a horrid piece of antique code, using a totally incompatible way of rendering. Target is to fully re-use internal render code for previews. OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
static const char *dataname(short id_code)
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
{
switch (id_code) {
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
case ID_OB: return "Data from OB";
case ID_ME: return "Data from ME";
case ID_IP: return "Data from IP";
case ID_SCE: return "Data from SCE";
case ID_MA: return "Data from MA";
case ID_TE: return "Data from TE";
case ID_CU: return "Data from CU";
case ID_GR: return "Data from GR";
case ID_AR: return "Data from AR";
case ID_AC: return "Data from AC";
case ID_LI: return "Data from LI";
case ID_MB: return "Data from MB";
case ID_IM: return "Data from IM";
case ID_LT: return "Data from LT";
case ID_LA: return "Data from LA";
case ID_CA: return "Data from CA";
case ID_KE: return "Data from KE";
case ID_WO: return "Data from WO";
case ID_SCR: return "Data from SCR";
case ID_VF: return "Data from VF";
case ID_TXT : return "Data from TXT";
case ID_SPK: return "Data from SPK";
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
case ID_SO: return "Data from SO";
case ID_NT: return "Data from NT";
case ID_BR: return "Data from BR";
case ID_PA: return "Data from PA";
case ID_GD: return "Data from GD";
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
case ID_MC: return "Data from MC";
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
}
return "Data from Lib Block";
}
static BHead *read_data_into_oldnewmap(FileData *fd, BHead *bhead, const char *allocname)
{
bhead = blo_nextbhead(fd, bhead);
while (bhead && bhead->code==DATA) {
void *data;
#if 0
/* XXX DUMB DEBUGGING OPTION TO GIVE NAMES for guarded malloc errors */
short *sp = fd->filesdna->structs[bhead->SDNAnr];
char *tmp = malloc(100);
allocname = fd->filesdna->types[ sp[0] ];
strcpy(tmp, allocname);
data = read_struct(fd, bhead, tmp);
#else
data = read_struct(fd, bhead, allocname);
#endif
if (data) {
oldnewmap_insert(fd->datamap, bhead->old, data, 0);
}
bhead = blo_nextbhead(fd, bhead);
}
return bhead;
}
2002-10-12 11:37:38 +00:00
static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID **id_r)
{
/* this routine reads a libblock and its direct data. Use link functions
* to connect it all
2002-10-12 11:37:38 +00:00
*/
ID *id;
ListBase *lb;
const char *allocname;
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
/* read libblock */
id = read_struct(fd, bhead, "lib block");
2002-10-12 11:37:38 +00:00
if (id_r)
*id_r = id;
2002-10-12 11:37:38 +00:00
if (!id)
return blo_nextbhead(fd, bhead);
oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code); /* for ID_ID check */
/* do after read_struct, for dna reconstruct */
if (bhead->code == ID_ID) {
lb = which_libbase(main, GS(id->name));
}
else {
lb = which_libbase(main, bhead->code);
}
2002-10-12 11:37:38 +00:00
BLI_addtail(lb, id);
/* clear first 8 bits */
id->flag = (id->flag & 0xFF00) | flag | LIB_NEEDLINK;
id->lib = main->curlib;
if (id->flag & LIB_FAKEUSER) id->us= 1;
else id->us = 0;
id->icon_id = 0;
id->flag &= ~(LIB_ID_RECALC|LIB_ID_RECALC_DATA);
/* this case cannot be direct_linked: it's just the ID part */
if (bhead->code == ID_ID) {
2002-10-12 11:37:38 +00:00
return blo_nextbhead(fd, bhead);
}
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
/* need a name for the mallocN, just for debugging and sane prints on leaks */
allocname = dataname(GS(id->name));
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
/* read all data into fd->datamap */
bhead = read_data_into_oldnewmap(fd, bhead, allocname);
/* init pointers direct data */
switch (GS(id->name)) {
case ID_WM:
direct_link_windowmanager(fd, (wmWindowManager *)id);
break;
2002-10-12 11:37:38 +00:00
case ID_SCR:
direct_link_screen(fd, (bScreen *)id);
break;
case ID_SCE:
direct_link_scene(fd, (Scene *)id);
break;
case ID_OB:
direct_link_object(fd, (Object *)id);
break;
case ID_ME:
direct_link_mesh(fd, (Mesh *)id);
break;
case ID_CU:
direct_link_curve(fd, (Curve *)id);
break;
case ID_MB:
direct_link_mball(fd, (MetaBall *)id);
break;
case ID_MA:
direct_link_material(fd, (Material *)id);
break;
case ID_TE:
direct_link_texture(fd, (Tex *)id);
break;
case ID_IM:
direct_link_image(fd, (Image *)id);
break;
case ID_LA:
direct_link_lamp(fd, (Lamp *)id);
break;
case ID_VF:
direct_link_vfont(fd, (VFont *)id);
break;
case ID_TXT:
direct_link_text(fd, (Text *)id);
break;
case ID_IP:
direct_link_ipo(fd, (Ipo *)id);
break;
case ID_KE:
direct_link_key(fd, (Key *)id);
break;
case ID_LT:
direct_link_latt(fd, (Lattice *)id);
break;
case ID_WO:
direct_link_world(fd, (World *)id);
break;
case ID_LI:
direct_link_library(fd, (Library *)id, main);
2002-10-12 11:37:38 +00:00
break;
case ID_CA:
direct_link_camera(fd, (Camera *)id);
break;
case ID_SPK:
direct_link_speaker(fd, (Speaker *)id);
break;
2002-10-12 11:37:38 +00:00
case ID_SO:
direct_link_sound(fd, (bSound *)id);
break;
case ID_GR:
direct_link_group(fd, (Group *)id);
break;
case ID_AR:
direct_link_armature(fd, (bArmature*)id);
break;
case ID_AC:
direct_link_action(fd, (bAction*)id);
break;
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
case ID_NT:
direct_link_nodetree(fd, (bNodeTree*)id);
break;
case ID_BR:
direct_link_brush(fd, (Brush*)id);
break;
case ID_PA:
direct_link_particlesettings(fd, (ParticleSettings*)id);
break;
case ID_SCRIPT:
direct_link_script(fd, (Script*)id);
break;
case ID_GD:
direct_link_gpencil(fd, (bGPdata *)id);
break;
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
case ID_MC:
direct_link_movieclip(fd, (MovieClip *)id);
break;
case ID_MSK:
direct_link_mask(fd, (Mask *)id);
break;
2002-10-12 11:37:38 +00:00
}
/*link direct data of ID properties*/
if (id->properties) {
id->properties = newdataadr(fd, id->properties);
if (id->properties) { /* this case means the data was written incorrectly, it should not happen */
IDP_DirectLinkProperty(id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
}
}
2002-10-12 11:37:38 +00:00
oldnewmap_free_unused(fd->datamap);
oldnewmap_clear(fd->datamap);
2002-10-12 11:37:38 +00:00
return (bhead);
}
/* note, this has to be kept for reading older files... */
/* also version info is written here */
static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead)
2002-10-12 11:37:38 +00:00
{
FileGlobal *fg = read_struct(fd, bhead, "Global");
/* copy to bfd handle */
bfd->main->subversionfile = fg->subversion;
bfd->main->minversionfile = fg->minversion;
bfd->main->minsubversionfile = fg->minsubversion;
bfd->main->revision = fg->revision;
bfd->winpos = fg->winpos;
bfd->fileflags = fg->fileflags;
bfd->displaymode = fg->displaymode;
bfd->globalf = fg->globalf;
BLI_strncpy(bfd->filename, fg->filename, sizeof(bfd->filename));
if (G.fileflags & G_FILE_RECOVER)
BLI_strncpy(fd->relabase, fg->filename, sizeof(fd->relabase));
bfd->curscreen = fg->curscreen;
bfd->curscene = fg->curscene;
MEM_freeN(fg);
fd->globalf = bfd->globalf;
fd->fileflags = bfd->fileflags;
return blo_nextbhead(fd, bhead);
}
/* note, this has to be kept for reading older files... */
static void link_global(FileData *fd, BlendFileData *bfd)
{
bfd->curscreen = newlibadr(fd, NULL, bfd->curscreen);
bfd->curscene = newlibadr(fd, NULL, bfd->curscene);
// this happens in files older than 2.35
if (bfd->curscene == NULL) {
if (bfd->curscreen) bfd->curscene = bfd->curscreen->scene;
}
2002-10-12 11:37:38 +00:00
}
/* deprecated, only keep this for readfile.c */
void convert_tface_mt(FileData *fd, Main *main)
2002-10-12 11:37:38 +00:00
{
Main *gmain;
/* this is a delayed do_version (so it can create new materials) */
if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 3)) {
//XXX hack, material.c uses G.main all over the place, instead of main
// temporarily set G.main to the current main
gmain = G.main;
G.main = main;
if (!(do_version_tface(main, 1))) {
BKE_report(fd->reports, RPT_WARNING, "Texface conversion problem. Error in console");
}
//XXX hack, material.c uses G.main allover the place, instead of main
G.main = gmain;
2002-10-12 11:37:38 +00:00
}
}
static void do_versions_nodetree_image_default_alpha_output(bNodeTree *ntree)
{
bNode *node;
bNodeSocket *sock;
for (node = ntree->nodes.first; node; node = node->next) {
if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS)) {
/* default Image output value should have 0 alpha */
sock = node->outputs.first;
((bNodeSocketValueRGBA *)(sock->default_value))->value[3] = 0.0f;
}
}
}
static void do_version_ntree_tex_mapping_260(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
{
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == SH_NODE_MAPPING) {
TexMapping *tex_mapping;
tex_mapping= node->storage;
tex_mapping->projx= PROJ_X;
tex_mapping->projy= PROJ_Y;
tex_mapping->projz= PROJ_Z;
}
}
}
static void do_versions_nodetree_convert_angle(bNodeTree *ntree)
{
bNode *node;
for (node=ntree->nodes.first; node; node=node->next) {
if (node->type == CMP_NODE_ROTATE) {
/* Convert degrees to radians. */
bNodeSocket *sock = ((bNodeSocket*)node->inputs.first)->next;
((bNodeSocketValueFloat*)sock->default_value)->value = DEG2RADF(((bNodeSocketValueFloat*)sock->default_value)->value);
}
else if (node->type == CMP_NODE_DBLUR) {
/* Convert degrees to radians. */
NodeDBlurData *ndbd= node->storage;
ndbd->angle = DEG2RADF(ndbd->angle);
ndbd->spin = DEG2RADF(ndbd->spin);
}
else if (node->type == CMP_NODE_DEFOCUS) {
/* Convert degrees to radians. */
NodeDefocus *nqd = node->storage;
/* XXX DNA char to float conversion seems to map the char value into the [0.0f, 1.0f] range... */
nqd->rotation = DEG2RADF(nqd->rotation*255.0f);
}
else if (node->type == CMP_NODE_CHROMA_MATTE) {
/* Convert degrees to radians. */
NodeChroma *ndc = node->storage;
ndc->t1 = DEG2RADF(ndc->t1);
ndc->t2 = DEG2RADF(ndc->t2);
}
else if (node->type == CMP_NODE_GLARE) {
/* Convert degrees to radians. */
NodeGlare *ndg = node->storage;
/* XXX DNA char to float conversion seems to map the char value into the [0.0f, 1.0f] range... */
ndg->angle_ofs = DEG2RADF(ndg->angle_ofs*255.0f);
}
/* XXX TexMapping struct is used by other nodes too (at least node_composite_mapValue),
* but not the rot part...
*/
else if (node->type == SH_NODE_MAPPING) {
/* Convert degrees to radians. */
TexMapping *tmap = node->storage;
tmap->rot[0] = DEG2RADF(tmap->rot[0]);
tmap->rot[1] = DEG2RADF(tmap->rot[1]);
tmap->rot[2] = DEG2RADF(tmap->rot[2]);
}
}
}
void do_versions_image_settings_2_60(Scene *sce)
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
{
/* note: rd->subimtype is moved into individual settings now and no longer
* exists */
RenderData *rd = &sce->r;
ImageFormatData *imf = &sce->r.im_format;
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
/* we know no data loss happens here, the old values were in char range */
imf->imtype = (char)rd->imtype;
imf->planes = (char)rd->planes;
imf->compress = (char)rd->quality;
imf->quality = (char)rd->quality;
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
/* default, was stored in multiple places, may override later */
imf->depth = R_IMF_CHAN_DEPTH_8;
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
/* openexr */
imf->exr_codec = rd->quality & 7; /* strange but true! 0-4 are valid values, OPENEXR_COMPRESS */
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
switch (imf->imtype) {
case R_IMF_IMTYPE_OPENEXR:
imf->depth = (rd->subimtype & R_OPENEXR_HALF) ? R_IMF_CHAN_DEPTH_16 : R_IMF_CHAN_DEPTH_32;
if (rd->subimtype & R_PREVIEW_JPG) {
imf->flag |= R_IMF_FLAG_PREVIEW_JPG;
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 (rd->subimtype & R_OPENEXR_ZBUF) {
imf->flag |= R_IMF_FLAG_ZBUF;
}
break;
case R_IMF_IMTYPE_TIFF:
if (rd->subimtype & R_TIFF_16BIT) {
imf->depth= R_IMF_CHAN_DEPTH_16;
}
break;
case R_IMF_IMTYPE_JP2:
if (rd->subimtype & R_JPEG2K_16BIT) {
imf->depth= R_IMF_CHAN_DEPTH_16;
}
else if (rd->subimtype & R_JPEG2K_12BIT) {
imf->depth= R_IMF_CHAN_DEPTH_12;
}
if (rd->subimtype & R_JPEG2K_YCC) {
imf->jp2_flag |= R_IMF_JP2_FLAG_YCC;
}
if (rd->subimtype & R_JPEG2K_CINE_PRESET) {
imf->jp2_flag |= R_IMF_JP2_FLAG_CINE_PRESET;
}
if (rd->subimtype & R_JPEG2K_CINE_48FPS) {
imf->jp2_flag |= R_IMF_JP2_FLAG_CINE_48;
}
break;
case R_IMF_IMTYPE_CINEON:
case R_IMF_IMTYPE_DPX:
if (rd->subimtype & R_CINEON_LOG) {
imf->cineon_flag |= R_IMF_CINEON_FLAG_LOG;
}
break;
}
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
}
/* socket use flags were only temporary before */
static void do_versions_nodetree_socket_use_flags_2_62(bNodeTree *ntree)
{
bNode *node;
bNodeSocket *sock;
bNodeLink *link;
for (node = ntree->nodes.first; node; node = node->next) {
for (sock = node->inputs.first; sock; sock = sock->next)
sock->flag &= ~SOCK_IN_USE;
for (sock = node->outputs.first; sock; sock = sock->next)
sock->flag &= ~SOCK_IN_USE;
}
for (sock = ntree->inputs.first; sock; sock = sock->next)
sock->flag &= ~SOCK_IN_USE;
for (sock = ntree->outputs.first; sock; sock = sock->next)
sock->flag &= ~SOCK_IN_USE;
for (link = ntree->links.first; link; link = link->next) {
link->fromsock->flag |= SOCK_IN_USE;
link->tosock->flag |= SOCK_IN_USE;
}
}
static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNodeTree *ntree)
{
bNode *node;
bNodeSocket *sock;
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == CMP_NODE_OUTPUT_FILE) {
/* previous CMP_NODE_OUTPUT_FILE nodes get converted to multi-file outputs */
NodeImageFile *old_data = node->storage;
NodeImageMultiFile *nimf= MEM_callocN(sizeof(NodeImageMultiFile), "node image multi file");
bNodeSocket *old_image = BLI_findlink(&node->inputs, 0);
bNodeSocket *old_z = BLI_findlink(&node->inputs, 1);
bNodeSocket *sock;
char basepath[FILE_MAXDIR];
char filename[FILE_MAXFILE];
/* ugly, need to remove the old inputs list to avoid bad pointer checks when adding new sockets.
* sock->storage is expected to contain path info in ntreeCompositOutputFileAddSocket.
*/
node->inputs.first = node->inputs.last = NULL;
node->storage = nimf;
/* split off filename from the old path, to be used as socket sub-path */
BLI_split_dirfile(old_data->name, basepath, filename, sizeof(basepath), sizeof(filename));
BLI_strncpy(nimf->base_path, basepath, sizeof(nimf->base_path));
nimf->format = old_data->im_format;
/* if z buffer is saved, change the image type to multilayer exr.
* XXX this is slightly messy, Z buffer was ignored before for anything but EXR and IRIS ...
* i'm just assuming here that IRIZ means IRIS with z buffer ...
*/
if (ELEM(old_data->im_format.imtype, R_IMF_IMTYPE_IRIZ, R_IMF_IMTYPE_OPENEXR)) {
char sockpath[FILE_MAX];
nimf->format.imtype = R_IMF_IMTYPE_MULTILAYER;
BLI_snprintf(sockpath, sizeof(sockpath), "%s_Image", filename);
sock = ntreeCompositOutputFileAddSocket(ntree, node, sockpath, &nimf->format);
/* XXX later do_versions copies path from socket name, need to set this explicitely */
BLI_strncpy(sock->name, sockpath, sizeof(sock->name));
if (old_image->link) {
old_image->link->tosock = sock;
sock->link = old_image->link;
}
BLI_snprintf(sockpath, sizeof(sockpath), "%s_Z", filename);
sock = ntreeCompositOutputFileAddSocket(ntree, node, sockpath, &nimf->format);
/* XXX later do_versions copies path from socket name, need to set this explicitely */
BLI_strncpy(sock->name, sockpath, sizeof(sock->name));
if (old_z->link) {
old_z->link->tosock = sock;
sock->link = old_z->link;
}
}
else {
sock = ntreeCompositOutputFileAddSocket(ntree, node, filename, &nimf->format);
/* XXX later do_versions copies path from socket name, need to set this explicitely */
BLI_strncpy(sock->name, filename, sizeof(sock->name));
if (old_image->link) {
old_image->link->tosock = sock;
sock->link = old_image->link;
}
}
nodeRemoveSocket(ntree, node, old_image);
nodeRemoveSocket(ntree, node, old_z);
MEM_freeN(old_data);
}
else if (node->type==CMP_NODE_OUTPUT_MULTI_FILE__DEPRECATED) {
NodeImageMultiFile *nimf = node->storage;
/* CMP_NODE_OUTPUT_MULTI_FILE has been redeclared as CMP_NODE_OUTPUT_FILE */
node->type = CMP_NODE_OUTPUT_FILE;
/* initialize the node-wide image format from render data, if available */
if (sce)
nimf->format = sce->r.im_format;
/* transfer render format toggle to node format toggle */
for (sock=node->inputs.first; sock; sock=sock->next) {
NodeImageMultiFileSocket *simf = sock->storage;
simf->use_node_format = simf->use_render_format;
}
/* we do have preview now */
node->flag |= NODE_PREVIEW;
}
}
}
/* blue and red are swapped pre 2.62.1, be sane (red == red) now! */
static void do_versions_mesh_mloopcol_swap_2_62_1(Mesh *me)
{
CustomDataLayer *layer;
MLoopCol *mloopcol;
int a;
int i;
for (a = 0; a < me->ldata.totlayer; a++) {
layer = &me->ldata.layers[a];
if (layer->type == CD_MLOOPCOL) {
mloopcol = (MLoopCol *)layer->data;
for (i = 0; i < me->totloop; i++, mloopcol++) {
SWAP(char, mloopcol->r, mloopcol->b);
}
}
}
}
static void do_versions_nodetree_multi_file_output_path_2_63_1(bNodeTree *ntree)
{
bNode *node;
for (node=ntree->nodes.first; node; node=node->next) {
if (node->type == CMP_NODE_OUTPUT_FILE) {
bNodeSocket *sock;
for (sock = node->inputs.first; sock; sock = sock->next) {
NodeImageMultiFileSocket *input = sock->storage;
/* input file path is stored in dedicated struct now instead socket name */
BLI_strncpy(input->path, sock->name, sizeof(input->path));
}
}
}
}
A couple more changes to the file and image nodes to improve access to layers that don't follow Blender's rlayer.rpass naming scheme. --- Changes to File Output node --- * Flat layer names in EXR multilayer files. For a socket with name "AAA" the previous resulting EXR layer name would be "AAA.AAA", i.e. the render layer as well as render pass would use the socket name. Now the "render_layer.render_pass" scheme is ignored in multilayer files, socket names are directly written to EXR layers (EXR layer name is "AAA" in this example). If sockets should have a notion of "render layer" this can still be achieved by explicitly adding a separator, e.g. "AAA.BBB". When loading such layers into a Blender Image struct, the name is interpreted as a "render_layer.render_pass" again (although the image node does not care about it, see below). * Socket sub-paths (for singlelayer) or layer names (for multilayer) are stored in dedicated string variables in the socket storage data. This way the RNA can define precise string subtypes (PROP_FILEPATH) and length. The file/layer slots are defined as separate structs with own name properties in the RNA as well, so they can be used nicely with the list template. * Ensure unique socket paths/layer names to prevent overwriting of files and layers respectively. --- Changes to Image node --- * Loading multilayer OpenEXR files has improved layer name splitting into render layer + render pass names now. This properly supports arbitrary EXR layer names now. Example: OpenEXR layer name: AAA.BBB.CCC is split into Render layer name: AAA.BBB Render pass name: CCC If the layer name has no '.' separators the render layer name is empty. * Image node ignores the selected render layer in the image user data. Instead all existing layers are displayed at the same time by combining the render layer names with render pass names again, to reconstruct the original EXR layer name. This avoids the problem that render layers with empty name are not selectetable in the dropdown and allows using all image layers at the same time without duplicating the node.
2012-05-11 08:06:01 +00:00
static void do_versions_nodetree_file_output_layers_2_64_5(bNodeTree *ntree)
{
bNode *node;
for (node=ntree->nodes.first; node; node=node->next) {
if (node->type == CMP_NODE_OUTPUT_FILE) {
A couple more changes to the file and image nodes to improve access to layers that don't follow Blender's rlayer.rpass naming scheme. --- Changes to File Output node --- * Flat layer names in EXR multilayer files. For a socket with name "AAA" the previous resulting EXR layer name would be "AAA.AAA", i.e. the render layer as well as render pass would use the socket name. Now the "render_layer.render_pass" scheme is ignored in multilayer files, socket names are directly written to EXR layers (EXR layer name is "AAA" in this example). If sockets should have a notion of "render layer" this can still be achieved by explicitly adding a separator, e.g. "AAA.BBB". When loading such layers into a Blender Image struct, the name is interpreted as a "render_layer.render_pass" again (although the image node does not care about it, see below). * Socket sub-paths (for singlelayer) or layer names (for multilayer) are stored in dedicated string variables in the socket storage data. This way the RNA can define precise string subtypes (PROP_FILEPATH) and length. The file/layer slots are defined as separate structs with own name properties in the RNA as well, so they can be used nicely with the list template. * Ensure unique socket paths/layer names to prevent overwriting of files and layers respectively. --- Changes to Image node --- * Loading multilayer OpenEXR files has improved layer name splitting into render layer + render pass names now. This properly supports arbitrary EXR layer names now. Example: OpenEXR layer name: AAA.BBB.CCC is split into Render layer name: AAA.BBB Render pass name: CCC If the layer name has no '.' separators the render layer name is empty. * Image node ignores the selected render layer in the image user data. Instead all existing layers are displayed at the same time by combining the render layer names with render pass names again, to reconstruct the original EXR layer name. This avoids the problem that render layers with empty name are not selectetable in the dropdown and allows using all image layers at the same time without duplicating the node.
2012-05-11 08:06:01 +00:00
bNodeSocket *sock;
for (sock=node->inputs.first; sock; sock=sock->next) {
NodeImageMultiFileSocket *input = sock->storage;
/* multilayer names are stored as separate strings now,
* used the path string before, so copy it over.
*/
BLI_strncpy(input->layer, input->path, sizeof(input->layer));
/* paths/layer names also have to be unique now, initial check */
ntreeCompositOutputFileUniquePath(&node->inputs, sock, input->path, '_');
ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, input->layer, '_');
}
}
}
}
static void do_versions_nodetree_image_layer_2_64_5(bNodeTree *ntree)
{
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == CMP_NODE_IMAGE) {
A couple more changes to the file and image nodes to improve access to layers that don't follow Blender's rlayer.rpass naming scheme. --- Changes to File Output node --- * Flat layer names in EXR multilayer files. For a socket with name "AAA" the previous resulting EXR layer name would be "AAA.AAA", i.e. the render layer as well as render pass would use the socket name. Now the "render_layer.render_pass" scheme is ignored in multilayer files, socket names are directly written to EXR layers (EXR layer name is "AAA" in this example). If sockets should have a notion of "render layer" this can still be achieved by explicitly adding a separator, e.g. "AAA.BBB". When loading such layers into a Blender Image struct, the name is interpreted as a "render_layer.render_pass" again (although the image node does not care about it, see below). * Socket sub-paths (for singlelayer) or layer names (for multilayer) are stored in dedicated string variables in the socket storage data. This way the RNA can define precise string subtypes (PROP_FILEPATH) and length. The file/layer slots are defined as separate structs with own name properties in the RNA as well, so they can be used nicely with the list template. * Ensure unique socket paths/layer names to prevent overwriting of files and layers respectively. --- Changes to Image node --- * Loading multilayer OpenEXR files has improved layer name splitting into render layer + render pass names now. This properly supports arbitrary EXR layer names now. Example: OpenEXR layer name: AAA.BBB.CCC is split into Render layer name: AAA.BBB Render pass name: CCC If the layer name has no '.' separators the render layer name is empty. * Image node ignores the selected render layer in the image user data. Instead all existing layers are displayed at the same time by combining the render layer names with render pass names again, to reconstruct the original EXR layer name. This avoids the problem that render layers with empty name are not selectetable in the dropdown and allows using all image layers at the same time without duplicating the node.
2012-05-11 08:06:01 +00:00
bNodeSocket *sock;
for (sock = node->outputs.first; sock; sock = sock->next) {
A couple more changes to the file and image nodes to improve access to layers that don't follow Blender's rlayer.rpass naming scheme. --- Changes to File Output node --- * Flat layer names in EXR multilayer files. For a socket with name "AAA" the previous resulting EXR layer name would be "AAA.AAA", i.e. the render layer as well as render pass would use the socket name. Now the "render_layer.render_pass" scheme is ignored in multilayer files, socket names are directly written to EXR layers (EXR layer name is "AAA" in this example). If sockets should have a notion of "render layer" this can still be achieved by explicitly adding a separator, e.g. "AAA.BBB". When loading such layers into a Blender Image struct, the name is interpreted as a "render_layer.render_pass" again (although the image node does not care about it, see below). * Socket sub-paths (for singlelayer) or layer names (for multilayer) are stored in dedicated string variables in the socket storage data. This way the RNA can define precise string subtypes (PROP_FILEPATH) and length. The file/layer slots are defined as separate structs with own name properties in the RNA as well, so they can be used nicely with the list template. * Ensure unique socket paths/layer names to prevent overwriting of files and layers respectively. --- Changes to Image node --- * Loading multilayer OpenEXR files has improved layer name splitting into render layer + render pass names now. This properly supports arbitrary EXR layer names now. Example: OpenEXR layer name: AAA.BBB.CCC is split into Render layer name: AAA.BBB Render pass name: CCC If the layer name has no '.' separators the render layer name is empty. * Image node ignores the selected render layer in the image user data. Instead all existing layers are displayed at the same time by combining the render layer names with render pass names again, to reconstruct the original EXR layer name. This avoids the problem that render layers with empty name are not selectetable in the dropdown and allows using all image layers at the same time without duplicating the node.
2012-05-11 08:06:01 +00:00
NodeImageLayer *output = MEM_callocN(sizeof(NodeImageLayer), "node image layer");
/* take pass index both from current storage ptr (actually an int) */
output->pass_index = GET_INT_FROM_POINTER(sock->storage);
/* replace socket data pointer */
sock->storage = output;
}
}
}
}
static void do_versions_nodetree_frame_2_64_6(bNodeTree *ntree)
{
bNode *node;
for (node=ntree->nodes.first; node; node=node->next) {
if (node->type==NODE_FRAME) {
/* initialize frame node storage data */
if (node->storage == NULL) {
NodeFrame *data = (NodeFrame *)MEM_callocN(sizeof(NodeFrame), "frame node storage");
node->storage = data;
/* copy current flags */
data->flag = node->custom1;
data->label_size = 20;
}
}
/* initialize custom node color */
node->color[0] = node->color[1] = node->color[2] = 0.608f; /* default theme color */
}
}
static void do_version_ntree_image_user_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree)
{
bNode *node;
for (node = ntree->nodes.first; node; node = node->next) {
if (ELEM(node->type, SH_NODE_TEX_IMAGE, SH_NODE_TEX_ENVIRONMENT)) {
NodeTexImage *tex = node->storage;
tex->iuser.frames= 1;
tex->iuser.sfra= 1;
tex->iuser.fie_ima= 2;
tex->iuser.ok= 1;
}
}
}
static void do_versions(FileData *fd, Library *lib, Main *main)
{
/* WATCH IT!!!: pointers from libdata have not been converted */
if (G.debug & G_DEBUG)
printf("read file %s\n Version %d sub %d svn r%d\n", fd->relabase, main->versionfile, main->subversionfile, main->revision);
blo_do_versions_pre250(fd, lib, main);
blo_do_versions_250(fd, lib, main);
if (main->versionfile < 260) {
{
/* set default alpha value of Image outputs in image and render layer nodes to 0 */
Scene *sce;
bNodeTree *ntree;
for (sce = main->scene.first; sce; sce = sce->id.next) {
/* there are files with invalid audio_channels value, the real cause
2012-04-22 11:54:53 +00:00
* is unknown, but we fix it here anyway to avoid crashes */
if (sce->r.ffcodecdata.audio_channels == 0)
sce->r.ffcodecdata.audio_channels = 2;
if (sce->nodetree)
do_versions_nodetree_image_default_alpha_output(sce->nodetree);
}
for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
do_versions_nodetree_image_default_alpha_output(ntree);
}
Particle dupliobject rotation changes: There has been quite a bit of fuss about particle dupliobject rotation in 2.59, so here are some changes to make things work a bit more consistently and predictably in 2.60. Much of the confusion has been about what the "Initial rotation" for particles actually means. Simply put it's just a vector that that the particles (and the dupliobjects) are aligned to and around which they can be rotated with the phase controls. I've now renamed these controls under a label "Rotation axis". In 2.59 and previous versions the dupliobject's global x-axis was aligned to the particle rotation axis for non-hair particles. This meant that the object's own rotation (in addition to the particle rotation) could effect the dupliobjects' rotations. This old behavior can still be used with the "Rotation" option in the particle render panel when object/group is set as the visualization. This option is also activated automatically for old files to maintain backwards compatibility. Now the default dupliobject rotations ignore the object's own rotation completely and align the object's tracking axis to the particle rotation axis. The tracking axis can be found under the Object tab -> Animation Hacks panel. In 2.58 the way of calculating the rotation for hair didn't work as intended and enabled many non-functional combinations of options. For this reason I removed most of the rotation options for hair in 2.59. Now the options have been reimplemented better and the dupliobject's tracking axis is aligned to the hair direction by default (Rotation axis = Velocity / Hair). All the other axis options work too along with the phase controls.
2011-10-16 16:14:36 +00:00
{
/* support old particle dupliobject rotation settings */
ParticleSettings *part;
Particle dupliobject rotation changes: There has been quite a bit of fuss about particle dupliobject rotation in 2.59, so here are some changes to make things work a bit more consistently and predictably in 2.60. Much of the confusion has been about what the "Initial rotation" for particles actually means. Simply put it's just a vector that that the particles (and the dupliobjects) are aligned to and around which they can be rotated with the phase controls. I've now renamed these controls under a label "Rotation axis". In 2.59 and previous versions the dupliobject's global x-axis was aligned to the particle rotation axis for non-hair particles. This meant that the object's own rotation (in addition to the particle rotation) could effect the dupliobjects' rotations. This old behavior can still be used with the "Rotation" option in the particle render panel when object/group is set as the visualization. This option is also activated automatically for old files to maintain backwards compatibility. Now the default dupliobject rotations ignore the object's own rotation completely and align the object's tracking axis to the particle rotation axis. The tracking axis can be found under the Object tab -> Animation Hacks panel. In 2.58 the way of calculating the rotation for hair didn't work as intended and enabled many non-functional combinations of options. For this reason I removed most of the rotation options for hair in 2.59. Now the options have been reimplemented better and the dupliobject's tracking axis is aligned to the hair direction by default (Rotation axis = Velocity / Hair). All the other axis options work too along with the phase controls.
2011-10-16 16:14:36 +00:00
for (part=main->particle.first; part; part=part->id.next) {
if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
Particle dupliobject rotation changes: There has been quite a bit of fuss about particle dupliobject rotation in 2.59, so here are some changes to make things work a bit more consistently and predictably in 2.60. Much of the confusion has been about what the "Initial rotation" for particles actually means. Simply put it's just a vector that that the particles (and the dupliobjects) are aligned to and around which they can be rotated with the phase controls. I've now renamed these controls under a label "Rotation axis". In 2.59 and previous versions the dupliobject's global x-axis was aligned to the particle rotation axis for non-hair particles. This meant that the object's own rotation (in addition to the particle rotation) could effect the dupliobjects' rotations. This old behavior can still be used with the "Rotation" option in the particle render panel when object/group is set as the visualization. This option is also activated automatically for old files to maintain backwards compatibility. Now the default dupliobject rotations ignore the object's own rotation completely and align the object's tracking axis to the particle rotation axis. The tracking axis can be found under the Object tab -> Animation Hacks panel. In 2.58 the way of calculating the rotation for hair didn't work as intended and enabled many non-functional combinations of options. For this reason I removed most of the rotation options for hair in 2.59. Now the options have been reimplemented better and the dupliobject's tracking axis is aligned to the hair direction by default (Rotation axis = Velocity / Hair). All the other axis options work too along with the phase controls.
2011-10-16 16:14:36 +00:00
part->draw |= PART_DRAW_ROTATE_OB;
if (part->rotmode == 0)
Particle dupliobject rotation changes: There has been quite a bit of fuss about particle dupliobject rotation in 2.59, so here are some changes to make things work a bit more consistently and predictably in 2.60. Much of the confusion has been about what the "Initial rotation" for particles actually means. Simply put it's just a vector that that the particles (and the dupliobjects) are aligned to and around which they can be rotated with the phase controls. I've now renamed these controls under a label "Rotation axis". In 2.59 and previous versions the dupliobject's global x-axis was aligned to the particle rotation axis for non-hair particles. This meant that the object's own rotation (in addition to the particle rotation) could effect the dupliobjects' rotations. This old behavior can still be used with the "Rotation" option in the particle render panel when object/group is set as the visualization. This option is also activated automatically for old files to maintain backwards compatibility. Now the default dupliobject rotations ignore the object's own rotation completely and align the object's tracking axis to the particle rotation axis. The tracking axis can be found under the Object tab -> Animation Hacks panel. In 2.58 the way of calculating the rotation for hair didn't work as intended and enabled many non-functional combinations of options. For this reason I removed most of the rotation options for hair in 2.59. Now the options have been reimplemented better and the dupliobject's tracking axis is aligned to the hair direction by default (Rotation axis = Velocity / Hair). All the other axis options work too along with the phase controls.
2011-10-16 16:14:36 +00:00
part->rotmode = PART_ROT_VEL;
}
}
}
2011-02-16 17:07:18 +00:00
}
if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 1)) {
Object *ob;
for (ob = main->object.first; ob; ob = ob->id.next) {
ob->collision_boundtype= ob->boundtype;
}
{
Camera *cam;
for (cam = main->camera.first; cam; cam = cam->id.next) {
2011-11-11 12:00:08 +00:00
if (cam->sensor_x < 0.01f)
cam->sensor_x = DEFAULT_SENSOR_WIDTH;
2011-11-11 12:00:08 +00:00
if (cam->sensor_y < 0.01f)
cam->sensor_y = DEFAULT_SENSOR_HEIGHT;
}
}
}
if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 2)) {
bNodeTreeType *ntreetype = ntreeGetType(NTREE_SHADER);
if (ntreetype && ntreetype->foreach_nodetree)
ntreetype->foreach_nodetree(main, NULL, do_version_ntree_tex_mapping_260);
}
if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 4)) {
{
/* Convert node angles to radians! */
Scene *sce;
Material *mat;
bNodeTree *ntree;
for (sce = main->scene.first; sce; sce = sce->id.next) {
if (sce->nodetree)
do_versions_nodetree_convert_angle(sce->nodetree);
}
for (mat = main->mat.first; mat; mat = mat->id.next) {
if (mat->nodetree)
do_versions_nodetree_convert_angle(mat->nodetree);
}
for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next)
do_versions_nodetree_convert_angle(ntree);
}
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
{
/* Tomato compatibility code. */
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
bScreen *sc;
MovieClip *clip;
for (sc = main->screen.first; sc; sc = sc->id.next) {
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
View3D *v3d= (View3D *)sl;
if (v3d->bundle_size == 0.0f) {
v3d->bundle_size = 0.2f;
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
v3d->flag2 |= V3D_SHOW_RECONSTRUCTION;
}
if (v3d->bundle_drawtype == 0)
v3d->bundle_drawtype = OB_PLAINAXES;
}
else if (sl->spacetype == SPACE_CLIP) {
SpaceClip *sc = (SpaceClip *)sl;
if (sc->scopes.track_preview_height == 0)
sc->scopes.track_preview_height = 120;
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
}
}
}
}
for (clip = main->movieclip.first; clip; clip = clip->id.next) {
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
MovieTrackingTrack *track;
if (clip->aspx < 1.0f) {
clip->aspx = 1.0f;
clip->aspy = 1.0f;
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
}
clip->proxy.build_tc_flag = IMB_TC_RECORD_RUN |
IMB_TC_FREE_RUN |
IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN;
if (clip->proxy.build_size_flag == 0)
clip->proxy.build_size_flag = IMB_PROXY_25;
if (clip->proxy.quality == 0)
clip->proxy.quality = 90;
if (clip->tracking.camera.pixel_aspect < 0.01f)
clip->tracking.camera.pixel_aspect = 1.0f;
track = clip->tracking.tracks.first;
while (track) {
if (track->pyramid_levels == 0)
track->pyramid_levels = 2;
if (track->minimum_correlation == 0.0f)
track->minimum_correlation = 0.75f;
track = track->next;
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
}
}
}
2011-02-16 17:07:18 +00:00
}
if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 6)) {
Scene *sce;
MovieClip *clip;
bScreen *sc;
for (sce = main->scene.first; sce; sce = sce->id.next) {
do_versions_image_settings_2_60(sce);
}
for (clip= main->movieclip.first; clip; clip= clip->id.next) {
MovieTrackingSettings *settings= &clip->tracking.settings;
if (settings->default_pyramid_levels == 0) {
settings->default_tracker= TRACKER_KLT;
settings->default_pyramid_levels = 2;
settings->default_minimum_correlation = 0.75;
settings->default_pattern_size = 11;
settings->default_search_size = 51;
}
}
for (sc = main->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->flag2 &= ~V3D_RENDER_SHADOW;
}
}
}
}
{
Object *ob;
for (ob = main->object.first; ob; ob = ob->id.next) {
/* convert delta addition into delta scale */
int i;
for (i= 0; i < 3; i++) {
if ( (ob->dsize[i] == 0.0f) || /* simple case, user never touched dsize */
(ob->size[i] == 0.0f)) /* cant scale the dsize to give a non zero result, so fallback to 1.0f */
{
ob->dscale[i]= 1.0f;
}
else {
ob->dscale[i]= (ob->size[i] + ob->dsize[i]) / ob->size[i];
}
}
}
}
}
/* sigh, this dscale vs dsize version patching was not done right, fix for fix,
* this intentionally checks an exact subversion, also note this was never in a release,
* at some point this could be removed. */
2012-03-07 04:53:43 +00:00
else if (main->versionfile == 260 && main->subversionfile == 6) {
Object *ob;
for (ob = main->object.first; ob; ob = ob->id.next) {
if (is_zero_v3(ob->dscale)) {
fill_vn_fl(ob->dscale, 3, 1.0f);
}
}
}
if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 8)) {
Brush *brush;
for (brush = main->brush.first; brush; brush = brush->id.next) {
if (brush->sculpt_tool == SCULPT_TOOL_ROTATE)
brush->alpha= 1.0f;
}
}
if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 1)) {
{
/* update use flags for node sockets (was only temporary before) */
Scene *sce;
Material *mat;
Tex *tex;
Lamp *lamp;
World *world;
bNodeTree *ntree;
for (sce = main->scene.first; sce; sce = sce->id.next) {
if (sce->nodetree)
do_versions_nodetree_socket_use_flags_2_62(sce->nodetree);
}
for (mat = main->mat.first; mat; mat = mat->id.next) {
if (mat->nodetree)
do_versions_nodetree_socket_use_flags_2_62(mat->nodetree);
}
for (tex = main->tex.first; tex; tex = tex->id.next) {
if (tex->nodetree)
do_versions_nodetree_socket_use_flags_2_62(tex->nodetree);
}
for (lamp = main->lamp.first; lamp; lamp = lamp->id.next) {
if (lamp->nodetree)
do_versions_nodetree_socket_use_flags_2_62(lamp->nodetree);
}
for (world = main->world.first; world; world = world->id.next) {
if (world->nodetree)
do_versions_nodetree_socket_use_flags_2_62(world->nodetree);
}
for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) {
do_versions_nodetree_socket_use_flags_2_62(ntree);
}
}
Cucumber, first batch of merge - UI changes and custom exit key --------------------------------------------------------------- This was a test drive to see how painful the merge will be. Next batches are: - use desktop option for fullscreen - multisampling option - bullet collision mask - python - storage (vbo, dl, ...) - lighting [lighting still needs review] [python could use review, although it should be straightforward] [storage should be tested more I think] Merged /branches/soc-2011-cucumber:r 36991,37059,37157,37416,37497-37499,37501,37522,39036,40593 36991: ==UI== * Made some options available in Blender Game that were only available in Blender Render (camera resolution, animation fps) * Created a panel for the embedded player * Renamed the FPS option for the standalone player to Refresh Rate * Moved framing options to display * Made a button to launch the blender player from within blender (only tested on windows for now) 37059: ==UI== * Added the option to change the exit key for the BGE. The UI currently just sets a number, and this feature most likely does not work for blenderplayer yet. More work on this to come. * Removed the physics settings from the scene panel for the BGE. * Added an Add menu in the logic brick header. 37157: Making the bake options available in Blender Game 37416: Making the exit key UI element accept key presses instead of numbers. It still does not work for the Blenderplayer, and it does not limit the input to key presses (other events don't work for exiting) 37497: Some more work on getting the exit key to work in the Blenderplayer. Input is now restricted to keyboard events only for the exit key UI. 37498: Some clean up from the last commit. The exit key setting affects the Blenderplayer now. 37499: Cleaning up some duplicate code. Now the reverseTranslateTable for converting blender key codes to ketsji key codes is only defined in BL_BlenderDataConverter. 37501: Centralizing the exit key methods to the keyboard devices. This should make it easier to get exit key control to the python API. [37517: committed previously] 37522: Moved control of the exit key away from the keyboard devices, and moved it to ketsjiengine. Added setExitKey and getExitKey to the python API 39036: A couple of the doversions were in the wrong spot. This should fix some issues with the exit key not being set. [not committed entirely, see below]] 40552: space_logic.py (* fixed an error in space_logic.py *) 40593: launch blenderplayer from ui not working in OSX fix - by Daniel Stokes and me ######################################################## code left behind (to be included in next commit): ######################################################## { /* Initialize default values for collision masks */ Object *ob; for(ob=main->object.first; ob; ob=ob->id.next) ob->col_group = ob->col_mask = 1; }
2011-12-20 03:11:56 +00:00
{
/* Initialize BGE exit key to esc key */
Scene *scene;
for (scene = main->scene.first; scene; scene = scene->id.next) {
Cucumber, first batch of merge - UI changes and custom exit key --------------------------------------------------------------- This was a test drive to see how painful the merge will be. Next batches are: - use desktop option for fullscreen - multisampling option - bullet collision mask - python - storage (vbo, dl, ...) - lighting [lighting still needs review] [python could use review, although it should be straightforward] [storage should be tested more I think] Merged /branches/soc-2011-cucumber:r 36991,37059,37157,37416,37497-37499,37501,37522,39036,40593 36991: ==UI== * Made some options available in Blender Game that were only available in Blender Render (camera resolution, animation fps) * Created a panel for the embedded player * Renamed the FPS option for the standalone player to Refresh Rate * Moved framing options to display * Made a button to launch the blender player from within blender (only tested on windows for now) 37059: ==UI== * Added the option to change the exit key for the BGE. The UI currently just sets a number, and this feature most likely does not work for blenderplayer yet. More work on this to come. * Removed the physics settings from the scene panel for the BGE. * Added an Add menu in the logic brick header. 37157: Making the bake options available in Blender Game 37416: Making the exit key UI element accept key presses instead of numbers. It still does not work for the Blenderplayer, and it does not limit the input to key presses (other events don't work for exiting) 37497: Some more work on getting the exit key to work in the Blenderplayer. Input is now restricted to keyboard events only for the exit key UI. 37498: Some clean up from the last commit. The exit key setting affects the Blenderplayer now. 37499: Cleaning up some duplicate code. Now the reverseTranslateTable for converting blender key codes to ketsji key codes is only defined in BL_BlenderDataConverter. 37501: Centralizing the exit key methods to the keyboard devices. This should make it easier to get exit key control to the python API. [37517: committed previously] 37522: Moved control of the exit key away from the keyboard devices, and moved it to ketsjiengine. Added setExitKey and getExitKey to the python API 39036: A couple of the doversions were in the wrong spot. This should fix some issues with the exit key not being set. [not committed entirely, see below]] 40552: space_logic.py (* fixed an error in space_logic.py *) 40593: launch blenderplayer from ui not working in OSX fix - by Daniel Stokes and me ######################################################## code left behind (to be included in next commit): ######################################################## { /* Initialize default values for collision masks */ Object *ob; for(ob=main->object.first; ob; ob=ob->id.next) ob->col_group = ob->col_mask = 1; }
2011-12-20 03:11:56 +00:00
if (!scene->gm.exitkey)
scene->gm.exitkey = 218; // Blender key code for ESC
}
}
{
MovieClip *clip;
Object *ob;
for (clip = main->movieclip.first; clip; clip = clip->id.next) {
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *tracking_object = tracking->objects.first;
clip->proxy.build_tc_flag |= IMB_TC_RECORD_RUN_NO_GAPS;
if (!tracking->settings.object_distance)
tracking->settings.object_distance = 1.0f;
if (tracking->objects.first == NULL)
BKE_tracking_new_object(tracking, "Camera");
while (tracking_object) {
if (!tracking_object->scale)
tracking_object->scale = 1.0f;
tracking_object = tracking_object->next;
}
}
for (ob = main->object.first; ob; ob = ob->id.next) {
bConstraint *con;
for (con = ob->constraints.first; con; con = con->next) {
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
if (!cti)
continue;
if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
bObjectSolverConstraint *data = (bObjectSolverConstraint *)con->data;
if (data->invmat[3][3] == 0.0f)
unit_m4(data->invmat);
}
}
}
}
{
/* Warn the user if he is using ["Text"] properties for Font objects */
Object *ob;
bProperty *prop;
for (ob= main->object.first; ob; ob= ob->id.next) {
if (ob->type == OB_FONT) {
prop = get_ob_property(ob, "Text");
if (prop) {
BKE_reportf_wrap(fd->reports, RPT_WARNING,
"Game property name conflict in object: \"%s\".\nText objects reserve the "
"[\"Text\"] game property to change their content through Logic Bricks.",
ob->id.name + 2);
}
}
}
}
}
if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 2)) {
{
/* convert Camera Actuator values to defines */
Object *ob;
bActuator *act;
for (ob = main->object.first; ob; ob= ob->id.next) {
for (act= ob->actuators.first; act; act= act->next) {
if (act->type == ACT_CAMERA) {
bCameraActuator *ba= act->data;
if (ba->axis==(float) 'x') ba->axis=OB_POSX;
else if (ba->axis==(float)'y') ba->axis=OB_POSY;
/* don't do an if/else to avoid imediate subversion bump*/
// ba->axis=((ba->axis == (float) 'x')?OB_POSX_X:OB_POSY);
}
}
}
}
{
/* convert deprecated sculpt_paint_unified_* fields to
2012-04-22 11:54:53 +00:00
* UnifiedPaintSettings */
Scene *scene;
for (scene= main->scene.first; scene; scene= scene->id.next) {
ToolSettings *ts= scene->toolsettings;
UnifiedPaintSettings *ups= &ts->unified_paint_settings;
ups->size= ts->sculpt_paint_unified_size;
ups->unprojected_radius= ts->sculpt_paint_unified_unprojected_radius;
ups->alpha= ts->sculpt_paint_unified_alpha;
ups->flag= ts->sculpt_paint_settings;
}
}
}
if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 3)) {
{
/* convert extended ascii to utf-8 for text editor */
Text *text;
for (text= main->text.first; text; text= text->id.next)
if (!(text->flags & TXT_ISEXT)) {
TextLine *tl;
for (tl= text->lines.first; tl; tl= tl->next) {
int added= txt_extended_ascii_as_utf8(&tl->line);
tl->len+= added;
/* reset cursor position if line was changed */
if (added && tl == text->curl)
text->curc = 0;
}
}
}
{
/* set new dynamic paint values */
Object *ob;
for (ob = main->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md= ob->modifiers.first; md; md= md->next) {
if (md->type == eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
if (pmd->canvas) {
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
for (; surface; surface=surface->next) {
surface->color_dry_threshold = 1.0f;
surface->influence_scale = 1.0f;
surface->radius_scale = 1.0f;
surface->flags |= MOD_DPAINT_USE_DRYING;
}
}
}
}
}
}
}
if (main->versionfile < 262) {
Object *ob;
for (ob=main->object.first; ob; ob= ob->id.next) {
ModifierData *md;
for (md=ob->modifiers.first; md; md=md->next) {
if (md->type==eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData*) md;
if (clmd->sim_parms)
clmd->sim_parms->vel_damping = 1.0f;
}
}
}
}
if (main->versionfile < 263) {
/* set fluidsim rate. the version patch for this in 2.62 was wrong, so
try to correct it, if rate is 0.0 that's likely not intentional */
Object *ob;
for (ob = main->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Fluidsim) {
FluidsimModifierData *fmd = (FluidsimModifierData *)md;
if (fmd->fss->animRate == 0.0f)
fmd->fss->animRate = 1.0f;
}
}
}
}
if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 1)) {
/* update use flags for node sockets (was only temporary before) */
Scene *sce;
bNodeTree *ntree;
for (sce=main->scene.first; sce; sce=sce->id.next) {
if (sce->nodetree)
do_versions_nodetree_multi_file_output_format_2_62_1(sce, sce->nodetree);
}
/* XXX can't associate with scene for group nodes, image format will stay uninitialized */
for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next)
do_versions_nodetree_multi_file_output_format_2_62_1(NULL, ntree);
}
/* only swap for pre-release bmesh merge which had MLoopCol red/blue swap */
if (main->versionfile == 262 && main->subversionfile == 1) {
{
Mesh *me;
for (me = main->mesh.first; me; me = me->id.next) {
do_versions_mesh_mloopcol_swap_2_62_1(me);
}
}
}
if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 2)) {
/* Set new idname of keyingsets from their now "label-only" name. */
Scene *scene;
for (scene = main->scene.first; scene; scene = scene->id.next) {
KeyingSet *ks;
for (ks = scene->keyingsets.first; ks; ks = ks->next) {
if (!ks->idname[0])
BLI_strncpy(ks->idname, ks->name, sizeof(ks->idname));
}
}
}
if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 3)) {
Object *ob;
ModifierData *md;
2012-04-21 12:51:47 +00:00
for (ob = main->object.first; ob; ob = ob->id.next) {
for (md = ob->modifiers.first; md; md = md->next) {
2012-04-21 12:51:47 +00:00
if (md->type == eModifierType_Lattice) {
LatticeModifierData *lmd = (LatticeModifierData *)md;
lmd->strength = 1.0f;
}
}
}
}
if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 4)) {
/* Read Viscosity presets from older files */
Object *ob;
for (ob = main->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Fluidsim) {
FluidsimModifierData *fmd = (FluidsimModifierData *)md;
2012-04-21 12:51:47 +00:00
if (fmd->fss->viscosityMode == 3) {
fmd->fss->viscosityValue = 5.0;
fmd->fss->viscosityExponent = 5;
}
2012-04-21 12:51:47 +00:00
else if (fmd->fss->viscosityMode == 4) {
fmd->fss->viscosityValue = 2.0;
fmd->fss->viscosityExponent = 3;
}
}
}
}
}
if (main->versionfile < 263) {
____ `````|````` | | | ..'''' | | | |______ .'' | | | | ..' | | |_______ |___________ ....'' merge to TRUNK! * The old compositor is still available (Debug Menu: 200) This commit was brought to you by: Developers: * Monique Dewanchand * Jeroen Bakker * Dalai Felinto * Lukas Tönne Review: * Brecht van Lommel Testers: * Nate Wiebe * Wolfgang Faehnle * Carlo Andreacchio * Daniel Salazar * Artur Mag * Christian Krupa * Francesco Siddi * Dan McGrath * Bassam Kurdali But mostly by the community: Gold: Joshua Faulkner Michael Tiemann Francesco Paglia Blender Guru Blender Developers Fund Silver: Pablo Vazquez Joel Heethaar Amrein Olivier Ilias Karasavvidis Thomas Kumlehn Sebastian Koenig Hannu Hoffrén Benjamin Dansie Fred M'ule Michel Vilain Bradley Cathey Gianmichele Mariani Gottfried Hofmann Bjørnar Frøyse Valentijn Bruning Paul Holmes Clemens Rudolph Juris Graphix David Strebel Ronan Zeegers François Tarlier Felipe Andres Esquivel Reed Olaf Beckman Jesus Alberto Olmos Linares Kajimba Maria Figueiredo Alexandr Galperin Francesco Siddi Julio Iglesias Lopez Kjartan Tysdal Thomas Torfs Film Works Teruyuki Nakamura Roger Luethi Benoit Bolsee Stefan Abrahamsen Andreas Mattijat Xavier Bouchoux Blender 3D Graphics and Animation Henk Vostermans Daniel Blanco Delgado BlenderDay/2011 Bradley Cathey Matthieu Dupont de Dinechin Gianmichele Mariani Jérôme Scaillet Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó, Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli, Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein, Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio, Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel, Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey, Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter, Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini, Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch, Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson, Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song, Dylan Urquidi )
2012-05-17 12:49:33 +00:00
/* Default for old files is to save particle rotations to pointcache */
ParticleSettings *part;
for (part = main->particle.first; part; part = part->id.next)
part->flag |= PART_ROTATIONS;
A number of changes to node RNA and the file output node, to simplify socket types and make node code more robust for future nodes with extra socket data. * Removed the struct_type identifier from sockets completely. Any specialization of socket types can be done by using separate collections in RNA and customized socket draw callbacks in node type. Sockets themselves are pure data inputs/outputs now. Possibly the sock->storage data could also be removed, but this will change anyway with id properties in custom nodes. * Replaced the direct socket button draw calls by extra callbacks in node types. This allows nodes to draw sockets in specialized ways without referring to the additional struct_type identifier. Default is simply drawing the socket default_value button, only file output node overrides this atm. * File output node slots now use a separate file sub-path in their storage data, instead of using the socket name. That way the path is an actual PROP_FILEPATH property and it works better with the UI list template (name property is local to the data struct). * Node draw contexts for options on the node itself and detail buttons in the sidebar now have an extra context pointer "node" (uiLayoutSetContextPointer). This can be used to bind operator buttons to a specific node, instead of having to rely on the active/selected node(s) or making weak links via node name. Compare to modifiers and logic bricks, they use the same feature. * Added another operator for reordering custom input slots in the file output node.
2012-05-02 07:18:51 +00:00
{
/* Default for old files is to save particle rotations to pointcache */
ParticleSettings *part;
for (part = main->particle.first; part; part = part->id.next)
part->flag |= PART_ROTATIONS;
}
}
____ `````|````` | | | ..'''' | | | |______ .'' | | | | ..' | | |_______ |___________ ....'' merge to TRUNK! * The old compositor is still available (Debug Menu: 200) This commit was brought to you by: Developers: * Monique Dewanchand * Jeroen Bakker * Dalai Felinto * Lukas Tönne Review: * Brecht van Lommel Testers: * Nate Wiebe * Wolfgang Faehnle * Carlo Andreacchio * Daniel Salazar * Artur Mag * Christian Krupa * Francesco Siddi * Dan McGrath * Bassam Kurdali But mostly by the community: Gold: Joshua Faulkner Michael Tiemann Francesco Paglia Blender Guru Blender Developers Fund Silver: Pablo Vazquez Joel Heethaar Amrein Olivier Ilias Karasavvidis Thomas Kumlehn Sebastian Koenig Hannu Hoffrén Benjamin Dansie Fred M'ule Michel Vilain Bradley Cathey Gianmichele Mariani Gottfried Hofmann Bjørnar Frøyse Valentijn Bruning Paul Holmes Clemens Rudolph Juris Graphix David Strebel Ronan Zeegers François Tarlier Felipe Andres Esquivel Reed Olaf Beckman Jesus Alberto Olmos Linares Kajimba Maria Figueiredo Alexandr Galperin Francesco Siddi Julio Iglesias Lopez Kjartan Tysdal Thomas Torfs Film Works Teruyuki Nakamura Roger Luethi Benoit Bolsee Stefan Abrahamsen Andreas Mattijat Xavier Bouchoux Blender 3D Graphics and Animation Henk Vostermans Daniel Blanco Delgado BlenderDay/2011 Bradley Cathey Matthieu Dupont de Dinechin Gianmichele Mariani Jérôme Scaillet Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó, Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli, Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein, Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio, Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel, Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey, Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter, Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini, Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch, Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson, Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song, Dylan Urquidi )
2012-05-17 12:49:33 +00:00
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 1)) {
/* file output node paths are now stored in the file info struct instead socket name */
Scene *sce;
bNodeTree *ntree;
for (sce = main->scene.first; sce; sce=sce->id.next)
if (sce->nodetree)
do_versions_nodetree_multi_file_output_path_2_63_1(sce->nodetree);
for (ntree = main->nodetree.first; ntree; ntree=ntree->id.next)
do_versions_nodetree_multi_file_output_path_2_63_1(ntree);
}
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 3)) {
Scene *scene;
Brush *brush;
/* For weight paint, each brush now gets its own weight;
2012-05-16 23:37:23 +00:00
* unified paint settings also have weight. Update unified
* paint settings and brushes with a default weight value. */
for (scene = main->scene.first; scene; scene = scene->id.next) {
ToolSettings *ts = scene->toolsettings;
if (ts) {
ts->unified_paint_settings.weight = ts->vgroup_weight;
ts->unified_paint_settings.flag |= UNIFIED_PAINT_WEIGHT;
}
}
for (brush = main->brush.first; brush; brush = brush->id.next) {
brush->weight = 0.5;
}
}
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 2)) {
bScreen *sc;
for (sc = main->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_CLIP) {
SpaceClip *sclip = (SpaceClip *)sl;
ARegion *ar;
int hide = FALSE;
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_PREVIEW) {
if (ar->alignment != RGN_ALIGN_NONE) {
ar->flag |= RGN_FLAG_HIDDEN;
ar->v2d.flag &= ~V2D_IS_INITIALISED;
ar->alignment = RGN_ALIGN_NONE;
hide = TRUE;
}
}
}
if (hide) {
sclip->view = SC_VIEW_CLIP;
}
}
}
}
}
}
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 4))
{
Lamp *la;
Camera *cam;
Curve *cu;
for (la = main->lamp.first; la; la = la->id.next) {
2012-05-05 21:28:12 +00:00
if (la->shadow_frustum_size == 0.0f)
la->shadow_frustum_size= 10.0f;
}
Fisheye Camera for Cycles For sample images see: http://www.dalaifelinto.com/?p=399 (equisolid) http://www.dalaifelinto.com/?p=389 (equidistant) The 'use_panorama' option is now part of a new Camera type: 'Panorama'. Created two other panorama cameras: - Equisolid: most of lens in the market simulate this lens - e.g. Nikon, Canon, ...) this works as a real lens up to an extent. The final result takes the sensor dimensions into account also. .:. to simulate a Nikon DX2S with a 10.5mm lens do: sensor: 23.7 x 15.7 fisheye lens: 10.5 fisheye fov: 180 render dimensions: 4288 x 2848 - Equidistant: this is not a real lens model. Although the old equidistant lens simulate this lens. The result is always as a circular fisheye that takes the whole sensor (in other words, it doesn't take the sensor into consideration). This is perfect for fulldomes ;) For the UI we have 10 to 360 as soft values and 10 to 3600 as hard values (because we can). Reference material: http://www.hdrlabs.com/tutorials/downloads_files/HDRI%20for%20CGI.pdf http://www.bobatkins.com/photography/technical/field_of_view.html Note, this is not a real simulation of the light path through the lens. The ideal solution would be this: https://graphics.stanford.edu/wikis/cs348b-11/Assignment3 http://www.graphics.stanford.edu/papers/camera/ Thanks Brecht for the fix, suggestions and code review. Kudos for the dome community for keeping me stimulated on the topic since 2009 ;) Patch partly implemented during lab time at VisGraf, IMPA - Rio de Janeiro.
2012-05-04 16:20:51 +00:00
for (cam = main->camera.first; cam; cam = cam->id.next) {
if (cam->flag & CAM_PANORAMA) {
cam->type = CAM_PANO;
cam->flag &= ~CAM_PANORAMA;
}
}
2012-05-22 22:03:41 +00:00
for (cu = main->curve.first; cu; cu = cu->id.next) {
if (cu->bevfac2 == 0.0f) {
cu->bevfac1 = 0.0f;
cu->bevfac2 = 1.0f;
}
}
Fisheye Camera for Cycles For sample images see: http://www.dalaifelinto.com/?p=399 (equisolid) http://www.dalaifelinto.com/?p=389 (equidistant) The 'use_panorama' option is now part of a new Camera type: 'Panorama'. Created two other panorama cameras: - Equisolid: most of lens in the market simulate this lens - e.g. Nikon, Canon, ...) this works as a real lens up to an extent. The final result takes the sensor dimensions into account also. .:. to simulate a Nikon DX2S with a 10.5mm lens do: sensor: 23.7 x 15.7 fisheye lens: 10.5 fisheye fov: 180 render dimensions: 4288 x 2848 - Equidistant: this is not a real lens model. Although the old equidistant lens simulate this lens. The result is always as a circular fisheye that takes the whole sensor (in other words, it doesn't take the sensor into consideration). This is perfect for fulldomes ;) For the UI we have 10 to 360 as soft values and 10 to 3600 as hard values (because we can). Reference material: http://www.hdrlabs.com/tutorials/downloads_files/HDRI%20for%20CGI.pdf http://www.bobatkins.com/photography/technical/field_of_view.html Note, this is not a real simulation of the light path through the lens. The ideal solution would be this: https://graphics.stanford.edu/wikis/cs348b-11/Assignment3 http://www.graphics.stanford.edu/papers/camera/ Thanks Brecht for the fix, suggestions and code review. Kudos for the dome community for keeping me stimulated on the topic since 2009 ;) Patch partly implemented during lab time at VisGraf, IMPA - Rio de Janeiro.
2012-05-04 16:20:51 +00:00
}
A couple more changes to the file and image nodes to improve access to layers that don't follow Blender's rlayer.rpass naming scheme. --- Changes to File Output node --- * Flat layer names in EXR multilayer files. For a socket with name "AAA" the previous resulting EXR layer name would be "AAA.AAA", i.e. the render layer as well as render pass would use the socket name. Now the "render_layer.render_pass" scheme is ignored in multilayer files, socket names are directly written to EXR layers (EXR layer name is "AAA" in this example). If sockets should have a notion of "render layer" this can still be achieved by explicitly adding a separator, e.g. "AAA.BBB". When loading such layers into a Blender Image struct, the name is interpreted as a "render_layer.render_pass" again (although the image node does not care about it, see below). * Socket sub-paths (for singlelayer) or layer names (for multilayer) are stored in dedicated string variables in the socket storage data. This way the RNA can define precise string subtypes (PROP_FILEPATH) and length. The file/layer slots are defined as separate structs with own name properties in the RNA as well, so they can be used nicely with the list template. * Ensure unique socket paths/layer names to prevent overwriting of files and layers respectively. --- Changes to Image node --- * Loading multilayer OpenEXR files has improved layer name splitting into render layer + render pass names now. This properly supports arbitrary EXR layer names now. Example: OpenEXR layer name: AAA.BBB.CCC is split into Render layer name: AAA.BBB Render pass name: CCC If the layer name has no '.' separators the render layer name is empty. * Image node ignores the selected render layer in the image user data. Instead all existing layers are displayed at the same time by combining the render layer names with render pass names again, to reconstruct the original EXR layer name. This avoids the problem that render layers with empty name are not selectetable in the dropdown and allows using all image layers at the same time without duplicating the node.
2012-05-11 08:06:01 +00:00
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 5))
{
{
/* file output node paths are now stored in the file info struct instead socket name */
Scene *sce;
bNodeTree *ntree;
for (sce = main->scene.first; sce; sce=sce->id.next) {
if (sce->nodetree) {
do_versions_nodetree_file_output_layers_2_64_5(sce->nodetree);
do_versions_nodetree_image_layer_2_64_5(sce->nodetree);
}
}
for (ntree = main->nodetree.first; ntree; ntree=ntree->id.next) {
do_versions_nodetree_file_output_layers_2_64_5(ntree);
do_versions_nodetree_image_layer_2_64_5(ntree);
}
}
}
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 6))
{
/* update use flags for node sockets (was only temporary before) */
Scene *sce;
Material *mat;
Tex *tex;
Lamp *lamp;
World *world;
bNodeTree *ntree;
for (sce=main->scene.first; sce; sce=sce->id.next)
if (sce->nodetree)
do_versions_nodetree_frame_2_64_6(sce->nodetree);
for (mat=main->mat.first; mat; mat=mat->id.next)
if (mat->nodetree)
do_versions_nodetree_frame_2_64_6(mat->nodetree);
for (tex=main->tex.first; tex; tex=tex->id.next)
if (tex->nodetree)
do_versions_nodetree_frame_2_64_6(tex->nodetree);
for (lamp=main->lamp.first; lamp; lamp=lamp->id.next)
if (lamp->nodetree)
do_versions_nodetree_frame_2_64_6(lamp->nodetree);
for (world=main->world.first; world; world=world->id.next)
if (world->nodetree)
do_versions_nodetree_frame_2_64_6(world->nodetree);
for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next)
do_versions_nodetree_frame_2_64_6(ntree);
}
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 7))
{
Object *ob;
for (ob = main->object.first; ob; ob = ob->id.next) {
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *)md;
2012-05-25 09:51:53 +00:00
if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) {
int maxres = MAX3(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2]);
smd->domain->scale = smd->domain->dx * maxres;
smd->domain->dx = 1.0f / smd->domain->scale;
}
}
}
}
}
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 8))
{
/* set new deactivation values for game settings */
Scene *sce;
for (sce = main->scene.first; sce; sce = sce->id.next) {
/* Game Settings */
sce->gm.lineardeactthreshold = 0.8f;
sce->gm.angulardeactthreshold = 1.0f;
sce->gm.deactivationtime = 2.0f;
}
}
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 9)) {
bNodeTreeType *ntreetype = ntreeGetType(NTREE_SHADER);
if (ntreetype && ntreetype->foreach_nodetree)
ntreetype->foreach_nodetree(main, NULL, do_version_ntree_image_user_264);
}
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 10)) {
{
Scene *scene;
// composite redesign
for (scene=main->scene.first; scene; scene=scene->id.next) {
if (scene->nodetree) {
if (scene->nodetree->chunksize == 0) {
scene->nodetree->chunksize = 256;
}
____ `````|````` | | | ..'''' | | | |______ .'' | | | | ..' | | |_______ |___________ ....'' merge to TRUNK! * The old compositor is still available (Debug Menu: 200) This commit was brought to you by: Developers: * Monique Dewanchand * Jeroen Bakker * Dalai Felinto * Lukas Tönne Review: * Brecht van Lommel Testers: * Nate Wiebe * Wolfgang Faehnle * Carlo Andreacchio * Daniel Salazar * Artur Mag * Christian Krupa * Francesco Siddi * Dan McGrath * Bassam Kurdali But mostly by the community: Gold: Joshua Faulkner Michael Tiemann Francesco Paglia Blender Guru Blender Developers Fund Silver: Pablo Vazquez Joel Heethaar Amrein Olivier Ilias Karasavvidis Thomas Kumlehn Sebastian Koenig Hannu Hoffrén Benjamin Dansie Fred M'ule Michel Vilain Bradley Cathey Gianmichele Mariani Gottfried Hofmann Bjørnar Frøyse Valentijn Bruning Paul Holmes Clemens Rudolph Juris Graphix David Strebel Ronan Zeegers François Tarlier Felipe Andres Esquivel Reed Olaf Beckman Jesus Alberto Olmos Linares Kajimba Maria Figueiredo Alexandr Galperin Francesco Siddi Julio Iglesias Lopez Kjartan Tysdal Thomas Torfs Film Works Teruyuki Nakamura Roger Luethi Benoit Bolsee Stefan Abrahamsen Andreas Mattijat Xavier Bouchoux Blender 3D Graphics and Animation Henk Vostermans Daniel Blanco Delgado BlenderDay/2011 Bradley Cathey Matthieu Dupont de Dinechin Gianmichele Mariani Jérôme Scaillet Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó, Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli, Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein, Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio, Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel, Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey, Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter, Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini, Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch, Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson, Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song, Dylan Urquidi )
2012-05-17 12:49:33 +00:00
}
}
}
{
bScreen *sc;
for (sc = main->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_CLIP) {
SpaceClip *sclip = (SpaceClip *)sl;
if (sclip->around == 0) {
sclip->around = V3D_CENTROID;
}
}
}
}
}
}
{
MovieClip *clip;
for (clip = main->movieclip.first; clip; clip = clip->id.next) {
clip->start_frame = 1;
}
}
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
/* don't forget to set version number in blender.c! */
2002-10-12 11:37:38 +00:00
}
#if 0 // XXX: disabled for now... we still don't have this in the right place in the loading code for it to work
static void do_versions_after_linking(FileData *fd, Library *lib, Main *main)
{
/* old Animation System (using IPO's) needs to be converted to the new Animato system */
if (main->versionfile < 250)
do_versions_ipos_to_animato(main);
}
#endif
2002-10-12 11:37:38 +00:00
static void lib_link_all(FileData *fd, Main *main)
{
oldnewmap_sort(fd);
lib_link_windowmanager(fd, main);
2002-10-12 11:37:38 +00:00
lib_link_screen(fd, main);
lib_link_scene(fd, main);
lib_link_object(fd, main);
lib_link_curve(fd, main);
lib_link_mball(fd, main);
lib_link_material(fd, main);
lib_link_texture(fd, main);
lib_link_image(fd, main);
lib_link_ipo(fd, main); // XXX depreceated... still needs to be maintained for version patches still
2002-10-12 11:37:38 +00:00
lib_link_key(fd, main);
lib_link_world(fd, main);
lib_link_lamp(fd, main);
lib_link_latt(fd, main);
lib_link_text(fd, main);
lib_link_camera(fd, main);
lib_link_speaker(fd, main);
2002-10-12 11:37:38 +00:00
lib_link_sound(fd, main);
lib_link_group(fd, main);
lib_link_armature(fd, main);
lib_link_action(fd, main);
lib_link_vfont(fd, main);
lib_link_nodetree(fd, main); /* has to be done after scene/materials, this will verify group nodes */
lib_link_brush(fd, main);
lib_link_particlesettings(fd, main);
Camera tracking integration =========================== Commiting camera tracking integration gsoc project into trunk. This commit includes: - Bundled version of libmv library (with some changes against official repo, re-sync with libmv repo a bit later) - New datatype ID called MovieClip which is optimized to work with movie clips (both of movie files and image sequences) and doing camera/motion tracking operations. - New editor called Clip Editor which is currently used for motion/tracking stuff only, but which can be easily extended to work with masks too. This editor supports: * Loading movie files/image sequences * Build proxies with different size for loaded movie clip, also supports building undistorted proxies to increase speed of playback in undistorted mode. * Manual lens distortion mode calibration using grid and grease pencil * Supervised 2D tracking using two different algorithms KLT and SAD. * Basic algorithm for feature detection * Camera motion solving. scene orientation - New constraints to "link" scene objects with solved motions from clip: * Follow Track (make object follow 2D motion of track with given name or parent object to reconstructed 3D position of track) * Camera Solver to make camera moving in the same way as reconstructed camera This commit NOT includes changes from tomato branch: - New nodes (they'll be commited as separated patch) - Automatic image offset guessing for image input node and image editor (need to do more tests and gather more feedback) - Code cleanup in libmv-capi. It's not so critical cleanup, just increasing readability and understanadability of code. Better to make this chaneg when Keir will finish his current patch. More details about this project can be found on this page: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2011 Further development of small features would be done in trunk, bigger/experimental features would first be implemented in tomato branch.
2011-11-07 12:55:18 +00:00
lib_link_movieclip(fd, main);
lib_link_mask(fd, main);
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
lib_link_mesh(fd, main); /* as last: tpage images with users at zero */
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
lib_link_library(fd, main); /* only init users */
2002-10-12 11:37:38 +00:00
}
static void direct_link_keymapitem(FileData *fd, wmKeyMapItem *kmi)
{
kmi->properties = newdataadr(fd, kmi->properties);
if (kmi->properties)
IDP_DirectLinkProperty(kmi->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
kmi->ptr = NULL;
kmi->flag &= ~KMI_UPDATE;
}
static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
{
UserDef *user;
wmKeyMap *keymap;
wmKeyMapItem *kmi;
wmKeyMapDiffItem *kmdi;
bfd->user = user= read_struct(fd, bhead, "user def");
/* read all data into fd->datamap */
bhead = read_data_into_oldnewmap(fd, bhead, "user def");
if (user->keymaps.first) {
/* backwards compatibility */
user->user_keymaps= user->keymaps;
user->keymaps.first= user->keymaps.last= NULL;
}
link_list(fd, &user->themes);
link_list(fd, &user->user_keymaps);
link_list(fd, &user->addons);
for (keymap=user->user_keymaps.first; keymap; keymap=keymap->next) {
keymap->modal_items= NULL;
keymap->poll = NULL;
keymap->flag &= ~KEYMAP_UPDATE;
link_list(fd, &keymap->diff_items);
link_list(fd, &keymap->items);
for (kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) {
kmdi->remove_item= newdataadr(fd, kmdi->remove_item);
kmdi->add_item= newdataadr(fd, kmdi->add_item);
if (kmdi->remove_item)
direct_link_keymapitem(fd, kmdi->remove_item);
if (kmdi->add_item)
direct_link_keymapitem(fd, kmdi->add_item);
}
for (kmi=keymap->items.first; kmi; kmi=kmi->next)
direct_link_keymapitem(fd, kmi);
}
// XXX
user->uifonts.first = user->uifonts.last= NULL;
link_list(fd, &user->uistyles);
/* free fd->datamap again */
oldnewmap_free_unused(fd->datamap);
oldnewmap_clear(fd->datamap);
return bhead;
}
BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
2002-10-12 11:37:38 +00:00
{
BHead *bhead = blo_firstbhead(fd);
2002-10-12 11:37:38 +00:00
BlendFileData *bfd;
ListBase mainlist = {NULL, NULL};
bfd = MEM_callocN(sizeof(BlendFileData), "blendfiledata");
bfd->main = MEM_callocN(sizeof(Main), "readfile_Main");
BLI_addtail(&mainlist, bfd->main);
fd->mainlist = &mainlist;
bfd->main->versionfile = fd->fileversion;
bfd->type = BLENFILETYPE_BLEND;
BLI_strncpy(bfd->main->name, filepath, sizeof(bfd->main->name));
2009-09-16 17:43:09 +00:00
while (bhead) {
switch (bhead->code) {
2002-10-12 11:37:38 +00:00
case DATA:
case DNA1:
case TEST: /* used as preview since 2.5x */
2002-10-12 11:37:38 +00:00
case REND:
bhead = blo_nextbhead(fd, bhead);
break;
case GLOB:
bhead = read_global(bfd, fd, bhead);
break;
case USER:
bhead = read_userdef(bfd, fd, bhead);
break;
2002-10-12 11:37:38 +00:00
case ENDB:
bhead = NULL;
break;
2002-10-12 11:37:38 +00:00
case ID_LI:
/* skip library datablocks in undo, this works together with
2012-04-22 11:54:53 +00:00
* BLO_read_from_memfile, where the old main->library is restored
* overwriting the libraries from the memory file. previously
* it did not save ID_LI/ID_ID blocks in this case, but they are
* needed to make quit.blend recover them correctly. */
if (fd->memfile)
bhead = blo_nextbhead(fd, bhead);
else
bhead = read_libblock(fd, bfd->main, bhead, LIB_LOCAL, NULL);
2002-10-12 11:37:38 +00:00
break;
case ID_ID:
/* same as above */
if (fd->memfile)
bhead = blo_nextbhead(fd, bhead);
else
2002-10-12 11:37:38 +00:00
/* always adds to the most recently loaded
* ID_LI block, see direct_link_library.
* this is part of the file format definition. */
bhead = read_libblock(fd, mainlist.last, bhead, LIB_READ+LIB_EXTERN, NULL);
2002-10-12 11:37:38 +00:00
break;
/* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
case ID_SCRN:
bhead->code = ID_SCR;
/* deliberate pass on to default */
2002-10-12 11:37:38 +00:00
default:
bhead = read_libblock(fd, bfd->main, bhead, LIB_LOCAL, NULL);
}
}
/* do before read_libraries, but skip undo case */
// if (fd->memfile==NULL) (the mesh shuffle hacks don't work yet? ton)
do_versions(fd, NULL, bfd->main);
read_libraries(fd, &mainlist);
blo_join_main(&mainlist);
2002-10-12 11:37:38 +00:00
lib_link_all(fd, bfd->main);
//do_versions_after_linking(fd, NULL, bfd->main); // XXX: not here (or even in this function at all)! this causes crashes on many files - Aligorith (July 04, 2010)
lib_verify_nodetree(bfd->main, TRUE);
fix_relpaths_library(fd->relabase, bfd->main); /* make all relative paths, relative to the open blend file */
link_global(fd, bfd); /* as last */
2002-10-12 11:37:38 +00:00
return bfd;
}
/* ************* APPEND LIBRARY ************** */
struct bheadsort {
BHead *bhead;
void *old;
};
static int verg_bheadsort(const void *v1, const void *v2)
{
const struct bheadsort *x1=v1, *x2=v2;
if (x1->old > x2->old) return 1;
else if (x1->old < x2->old) return -1;
return 0;
}
static void sort_bhead_old_map(FileData *fd)
{
BHead *bhead;
struct bheadsort *bhs;
int tot = 0;
for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead))
tot++;
fd->tot_bheadmap = tot;
if (tot == 0) return;
bhs = fd->bheadmap = MEM_mallocN(tot*sizeof(struct bheadsort), "bheadsort");
for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead), bhs++) {
bhs->bhead = bhead;
bhs->old = bhead->old;
}
qsort(fd->bheadmap, tot, sizeof(struct bheadsort), verg_bheadsort);
}
2002-10-12 11:37:38 +00:00
static BHead *find_previous_lib(FileData *fd, BHead *bhead)
{
/* skip library datablocks in undo, see comment in read_libblock */
if (fd->memfile)
return NULL;
for (; bhead; bhead = blo_prevbhead(fd, bhead)) {
if (bhead->code == ID_LI)
2002-10-12 11:37:38 +00:00
break;
}
2002-10-12 11:37:38 +00:00
return bhead;
}
static BHead *find_bhead(FileData *fd, void *old)
{
2008-02-03 18:50:03 +00:00
#if 0
2002-10-12 11:37:38 +00:00
BHead *bhead;
2008-02-03 18:50:03 +00:00
#endif
struct bheadsort *bhs, bhs_s;
2002-10-12 11:37:38 +00:00
if (!old)
return NULL;
if (fd->bheadmap == NULL)
sort_bhead_old_map(fd);
bhs_s.old = old;
bhs = bsearch(&bhs_s, fd->bheadmap, fd->tot_bheadmap, sizeof(struct bheadsort), verg_bheadsort);
if (bhs)
return bhs->bhead;
2008-02-03 18:50:03 +00:00
#if 0
for (bhead = blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) {
if (bhead->old == old)
2002-10-12 11:37:38 +00:00
return bhead;
}
2008-02-03 18:50:03 +00:00
#endif
2002-10-12 11:37:38 +00:00
return NULL;
}
char *bhead_id_name(FileData *fd, BHead *bhead)
{
return ((char *)(bhead+1)) + fd->id_name_offs;
}
static ID *is_yet_read(FileData *fd, Main *mainvar, BHead *bhead)
2002-10-12 11:37:38 +00:00
{
const char *idname= bhead_id_name(fd, bhead);
/* which_libbase can be NULL, intentionally not using idname+2 */
return BLI_findstring(which_libbase(mainvar, GS(idname)), idname, offsetof(ID, name));
2002-10-12 11:37:38 +00:00
}
static void expand_doit(FileData *fd, Main *mainvar, void *old)
{
BHead *bhead;
ID *id;
bhead = find_bhead(fd, old);
if (bhead) {
/* from another library? */
if (bhead->code == ID_ID) {
2002-10-12 11:37:38 +00:00
BHead *bheadlib= find_previous_lib(fd, bhead);
if (bheadlib) {
Library *lib = read_struct(fd, bheadlib, "Library");
Main *ptr = blo_find_main(fd, lib->name, fd->relabase);
id = is_yet_read(fd, ptr, bhead);
if (id == NULL) {
read_libblock(fd, ptr, bhead, LIB_READ+LIB_INDIRECT, NULL);
// commented because this can print way too much
// if (G.debug & G_DEBUG) printf("expand_doit: other lib %s\n", lib->name);
/* for outliner dependency only */
ptr->curlib->parent = mainvar->curlib;
2002-10-12 11:37:38 +00:00
}
else {
/* The line below was commented by Ton (I assume), when Hos did the merge from the orange branch. rev 6568
* This line is NEEDED, the case is that you have 3 blend files...
* user.blend, lib.blend and lib_indirect.blend - if user.blend already references a "tree" from
* lib_indirect.blend but lib.blend does too, linking in a Scene or Group from lib.blend can result in an
* empty without the dupli group referenced. Once you save and reload the group would appier. - Campbell */
/* This crashes files, must look further into it */
/* Update: the issue is that in file reading, the oldnewmap is OK, but for existing data, it has to be
2012-04-22 11:54:53 +00:00
* inserted in the map to be found! */
/* Update: previously it was checking for id->flag & LIB_PRE_EXISTING, however that does not affect file
* reading. For file reading we may need to insert it into the libmap as well, because you might have
* two files indirectly linking the same datablock, and in that case we need this in the libmap for the
* fd of both those files.
*
* The crash that this check avoided earlier was because bhead->code wasn't properly passed in, making
* change_idid_adr not detect the mapping was for an ID_ID datablock. */
oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
change_idid_adr_fd(fd, bhead->old, id);
// commented because this can print way too much
// if (G.debug & G_DEBUG) printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->name);
2002-10-12 11:37:38 +00:00
}
MEM_freeN(lib);
2002-10-12 11:37:38 +00:00
}
}
else {
id = is_yet_read(fd, mainvar, bhead);
if (id == NULL) {
2002-10-12 11:37:38 +00:00
read_libblock(fd, mainvar, bhead, LIB_TESTIND, NULL);
}
else {
/* this is actually only needed on UI call? when ID was already read before, and another append
2012-04-22 11:54:53 +00:00
* happens which invokes same ID... in that case the lookup table needs this entry */
oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
// commented because this can print way too much
// if (G.debug & G_DEBUG) printf("expand: already read %s\n", id->name);
2002-10-12 11:37:38 +00:00
}
}
}
}
// XXX depreceated - old animation system
static void expand_ipo(FileData *fd, Main *mainvar, Ipo *ipo)
{
IpoCurve *icu;
for (icu = ipo->curve.first; icu; icu = icu->next) {
if (icu->driver)
expand_doit(fd, mainvar, icu->driver->ob);
}
}
// XXX depreceated - old animation system
static void expand_constraint_channels(FileData *fd, Main *mainvar, ListBase *chanbase)
{
bConstraintChannel *chan;
for (chan = chanbase->first; chan; chan = chan->next) {
expand_doit(fd, mainvar, chan->ipo);
}
}
static void expand_fmodifiers(FileData *fd, Main *mainvar, ListBase *list)
{
FModifier *fcm;
for (fcm = list->first; fcm; fcm = fcm->next) {
/* library data for specific F-Modifier types */
switch (fcm->type) {
case FMODIFIER_TYPE_PYTHON:
{
FMod_Python *data = (FMod_Python *)fcm->data;
expand_doit(fd, mainvar, data->script);
}
break;
}
}
}
static void expand_fcurves(FileData *fd, Main *mainvar, ListBase *list)
{
FCurve *fcu;
for (fcu = list->first; fcu; fcu = fcu->next) {
/* Driver targets if there is a driver */
if (fcu->driver) {
ChannelDriver *driver = fcu->driver;
Durian Request: Drivers Recode Highlights: * Support for Multi-Target Variables This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that. * New Variable Types With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones). * New Driver Types In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to. * Fix for Driver F-Curve colouring bug Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used. Notes: * This commit breaks existing 2.5 files with drivers (in other words, they are lost forever). * Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later. * Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
DriverVar *dvar;
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
Durian Request: Drivers Recode Highlights: * Support for Multi-Target Variables This was the main reason for this recode. Previously, variables could only be used to give some RNA property used as an input source to the driver a name. However, this meant that effects such as Rotational Difference couldn't be used in conjunction with other effects and/or settings to achieve the powerful results. Now, a variable can take several input targets, perform some interesting operations on them, and spit out a representative value based on that. * New Variable Types With the introduction of multi-target variables, there are now 3 types of variable that can be used: single property (i.e. the only type previously), Rotational Difference (angle between two bones), and Distance (distance between two objects or bones). * New Driver Types In addition to the existing 'Average', 'Sum', and 'Expression' types, there is now the additional options of 'Minimum' and 'Maximum'. These take the smallest/largest value that one of the variables evaluates to. * Fix for Driver F-Curve colouring bug Newly added drivers did not get automatically coloured in the Graph Editor properly. Was caused by inappropriate notifiers being used. Notes: * This commit breaks existing 2.5 files with drivers (in other words, they are lost forever). * Rigify has been corrected to work with the new system. The PyAPI for accessing targets used for the variables could still be made nicer (using subclassing to directly access?), but that is left for later. * Version patching for 2.49 files still needs to be put back in place.
2010-01-04 21:15:45 +00:00
DRIVER_TARGETS_LOOPER(dvar)
{
// TODO: only expand those that are going to get used?
expand_doit(fd, mainvar, dtar->id);
}
DRIVER_TARGETS_LOOPER_END
}
}
/* F-Curve Modifiers */
expand_fmodifiers(fd, mainvar, &fcu->modifiers);
}
}
static void expand_action(FileData *fd, Main *mainvar, bAction *act)
{
bActionChannel *chan;
// XXX depreceated - old animation system --------------
for (chan=act->chanbase.first; chan; chan=chan->next) {
expand_doit(fd, mainvar, chan->ipo);
expand_constraint_channels(fd, mainvar, &chan->constraintChannels);
}
// ---------------------------------------------------
/* F-Curves in Action */
expand_fcurves(fd, mainvar, &act->curves);
}
static void expand_keyingsets(FileData *fd, Main *mainvar, ListBase *list)
{
KeyingSet *ks;
KS_Path *ksp;
/* expand the ID-pointers in KeyingSets's paths */
for (ks = list->first; ks; ks = ks->next) {
for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
expand_doit(fd, mainvar, ksp->id);
}
}
}
static void expand_animdata_nlastrips(FileData *fd, Main *mainvar, ListBase *list)
{
NlaStrip *strip;
for (strip= list->first; strip; strip= strip->next) {
/* check child strips */
expand_animdata_nlastrips(fd, mainvar, &strip->strips);
/* check F-Curves */
expand_fcurves(fd, mainvar, &strip->fcurves);
/* check F-Modifiers */
expand_fmodifiers(fd, mainvar, &strip->modifiers);
/* relink referenced action */
expand_doit(fd, mainvar, strip->act);
}
}
static void expand_animdata(FileData *fd, Main *mainvar, AnimData *adt)
{
2009-05-22 11:19:35 +00:00
NlaTrack *nlt;
/* own action */
expand_doit(fd, mainvar, adt->action);
expand_doit(fd, mainvar, adt->tmpact);
/* drivers - assume that these F-Curves have driver data to be in this list... */
expand_fcurves(fd, mainvar, &adt->drivers);
2009-05-22 11:19:35 +00:00
/* nla-data - referenced actions */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next)
expand_animdata_nlastrips(fd, mainvar, &nlt->strips);
}
static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSettings *part)
{
int a;
expand_doit(fd, mainvar, part->dup_ob);
expand_doit(fd, mainvar, part->dup_group);
expand_doit(fd, mainvar, part->eff_group);
expand_doit(fd, mainvar, part->bb_ob);
if (part->adt)
expand_animdata(fd, mainvar, part->adt);
for (a = 0; a < MAX_MTEX; a++) {
if (part->mtex[a]) {
expand_doit(fd, mainvar, part->mtex[a]->tex);
expand_doit(fd, mainvar, part->mtex[a]->object);
}
}
}
Orange branch: Revived hidden treasure, the Groups! Previous experiment (in 2000) didn't satisfy, it had even some primitive NLA option in groups... so, cleaned up the old code (removed most) and integrated it back in a more useful way. Usage: - CTRL+G gives menu to add group, add to existing group, or remove from groups. - In Object buttons, a new (should become first) Panel was added, showing not only Object "ID button" and Parent, but also the Groups the Object Belongs to. These buttons also allow rename, assigning or removing. - To indicate Objects are grouped, they're drawn in a (not theme yet, so temporal?) green wire color. - Use ALT+SHIFT mouse-select to (de)select an entire group But, the real power of groups is in the following features: -> Particle Force field and Guide control In the "Particle Motion" Panel, you can indicate a Group name, this then limits force fields or guides to members of that Group. (Note that layers still work on top of that... not sure about that). -> Light Groups In the Material "Shaders" Panel, you can indicate a Group name to limit lighting for the Material to lamps in this group. The Lights in a Group do need to be 'visible' for the Scene to be rendered (as usual). -> Group Duplicator In the Object "Anim" Panel, you can set any Object (use Empty!) to duplicate an entire Group. It will make copies of all Objects in that Group. Also works for animated Objects, but it will copy the current positions or deforms. Control over 'local timing' (so we can do Massive anims!) will be added later. (Note; this commit won't render Group duplicators yet, a fix in bf-blender will enable that, next commit will sync) -> Library Appending In the SHIFT-F1 or SHIFT+F4 browsers, you can also find the Groups listed. By appending or linking the Group itself, and use the Group Duplicator, you now can animate and position linked Objects. The nice thing is that the local saved file itself will only store the Group name that was linked, so on a next file read, the Group Objects will be re-read as stored (changed) in the Library file. (Note; current implementation also "gives a base" to linked Group Objects, to show them as Objects in the current Scene. Need that now for testing purposes, but probably will be removed later). -> Outliner Outliner now shows Groups as optio too, nice to organize your data a bit too! In General, Groups have a very good potential... for example, it could become default for MetaBall Objects too (jiri, I can help you later on how this works). All current 'layer relationships' in Blender should be dropped in time, I guess...
2005-12-06 10:55:30 +00:00
static void expand_group(FileData *fd, Main *mainvar, Group *group)
{
GroupObject *go;
for (go = group->gobject.first; go; go = go->next) {
Orange branch: Revived hidden treasure, the Groups! Previous experiment (in 2000) didn't satisfy, it had even some primitive NLA option in groups... so, cleaned up the old code (removed most) and integrated it back in a more useful way. Usage: - CTRL+G gives menu to add group, add to existing group, or remove from groups. - In Object buttons, a new (should become first) Panel was added, showing not only Object "ID button" and Parent, but also the Groups the Object Belongs to. These buttons also allow rename, assigning or removing. - To indicate Objects are grouped, they're drawn in a (not theme yet, so temporal?) green wire color. - Use ALT+SHIFT mouse-select to (de)select an entire group But, the real power of groups is in the following features: -> Particle Force field and Guide control In the "Particle Motion" Panel, you can indicate a Group name, this then limits force fields or guides to members of that Group. (Note that layers still work on top of that... not sure about that). -> Light Groups In the Material "Shaders" Panel, you can indicate a Group name to limit lighting for the Material to lamps in this group. The Lights in a Group do need to be 'visible' for the Scene to be rendered (as usual). -> Group Duplicator In the Object "Anim" Panel, you can set any Object (use Empty!) to duplicate an entire Group. It will make copies of all Objects in that Group. Also works for animated Objects, but it will copy the current positions or deforms. Control over 'local timing' (so we can do Massive anims!) will be added later. (Note; this commit won't render Group duplicators yet, a fix in bf-blender will enable that, next commit will sync) -> Library Appending In the SHIFT-F1 or SHIFT+F4 browsers, you can also find the Groups listed. By appending or linking the Group itself, and use the Group Duplicator, you now can animate and position linked Objects. The nice thing is that the local saved file itself will only store the Group name that was linked, so on a next file read, the Group Objects will be re-read as stored (changed) in the Library file. (Note; current implementation also "gives a base" to linked Group Objects, to show them as Objects in the current Scene. Need that now for testing purposes, but probably will be removed later). -> Outliner Outliner now shows Groups as optio too, nice to organize your data a bit too! In General, Groups have a very good potential... for example, it could become default for MetaBall Objects too (jiri, I can help you later on how this works). All current 'layer relationships' in Blender should be dropped in time, I guess...
2005-12-06 10:55:30 +00:00
expand_doit(fd, mainvar, go->ob);
}
}
2002-10-12 11:37:38 +00:00
static void expand_key(FileData *fd, Main *mainvar, Key *key)
{
expand_doit(fd, mainvar, key->ipo); // XXX depreceated - old animation system
if (key->adt)
expand_animdata(fd, mainvar, key->adt);
2002-10-12 11:37:38 +00:00
}
static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree)
{
bNode *node;
if (ntree->adt)
expand_animdata(fd, mainvar, ntree->adt);
if (ntree->gpd)
expand_doit(fd, mainvar, ntree->gpd);
for (node = ntree->nodes.first; node; node = node->next) {
if (node->id && node->type != CMP_NODE_R_LAYERS)
expand_doit(fd, mainvar, node->id);
}
}
2002-10-12 11:37:38 +00:00
static void expand_texture(FileData *fd, Main *mainvar, Tex *tex)
{
expand_doit(fd, mainvar, tex->ima);
expand_doit(fd, mainvar, tex->ipo); // XXX depreceated - old animation system
if (tex->adt)
expand_animdata(fd, mainvar, tex->adt);
if (tex->nodetree)
expand_nodetree(fd, mainvar, tex->nodetree);
2002-10-12 11:37:38 +00:00
}
static void expand_brush(FileData *fd, Main *mainvar, Brush *brush)
{
expand_doit(fd, mainvar, brush->mtex.tex);
expand_doit(fd, mainvar, brush->clone.image);
}
2002-10-12 11:37:38 +00:00
static void expand_material(FileData *fd, Main *mainvar, Material *ma)
{
int a;
for (a = 0; a < MAX_MTEX; a++) {
if (ma->mtex[a]) {
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, ma->mtex[a]->tex);
expand_doit(fd, mainvar, ma->mtex[a]->object);
}
}
expand_doit(fd, mainvar, ma->ipo); // XXX depreceated - old animation system
if (ma->adt)
expand_animdata(fd, mainvar, ma->adt);
if (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
expand_nodetree(fd, mainvar, ma->nodetree);
if (ma->group)
expand_doit(fd, mainvar, ma->group);
2002-10-12 11:37:38 +00:00
}
static void expand_lamp(FileData *fd, Main *mainvar, Lamp *la)
{
int a;
for (a = 0; a < MAX_MTEX; a++) {
if (la->mtex[a]) {
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, la->mtex[a]->tex);
expand_doit(fd, mainvar, la->mtex[a]->object);
}
}
expand_doit(fd, mainvar, la->ipo); // XXX depreceated - old animation system
if (la->adt)
expand_animdata(fd, mainvar, la->adt);
if (la->nodetree)
expand_nodetree(fd, mainvar, la->nodetree);
2002-10-12 11:37:38 +00:00
}
static void expand_lattice(FileData *fd, Main *mainvar, Lattice *lt)
{
expand_doit(fd, mainvar, lt->ipo); // XXX depreceated - old animation system
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, lt->key);
if (lt->adt)
expand_animdata(fd, mainvar, lt->adt);
2002-10-12 11:37:38 +00:00
}
static void expand_world(FileData *fd, Main *mainvar, World *wrld)
{
int a;
for (a = 0; a < MAX_MTEX; a++) {
if (wrld->mtex[a]) {
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, wrld->mtex[a]->tex);
expand_doit(fd, mainvar, wrld->mtex[a]->object);
}
}
expand_doit(fd, mainvar, wrld->ipo); // XXX depreceated - old animation system
if (wrld->adt)
expand_animdata(fd, mainvar, wrld->adt);
if (wrld->nodetree)
expand_nodetree(fd, mainvar, wrld->nodetree);
2002-10-12 11:37:38 +00:00
}
static void expand_mball(FileData *fd, Main *mainvar, MetaBall *mb)
{
int a;
for (a = 0; a < mb->totcol; a++) {
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, mb->mat[a]);
}
2009-08-03 13:09:23 +00:00
if (mb->adt)
2009-08-03 13:09:23 +00:00
expand_animdata(fd, mainvar, mb->adt);
2002-10-12 11:37:38 +00:00
}
static void expand_curve(FileData *fd, Main *mainvar, Curve *cu)
{
int a;
for (a = 0; a < cu->totcol; a++) {
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, cu->mat[a]);
}
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, cu->vfont);
expand_doit(fd, mainvar, cu->vfontb);
expand_doit(fd, mainvar, cu->vfonti);
expand_doit(fd, mainvar, cu->vfontbi);
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, cu->key);
expand_doit(fd, mainvar, cu->ipo); // XXX depreceated - old animation system
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, cu->bevobj);
expand_doit(fd, mainvar, cu->taperobj);
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, cu->textoncurve);
if (cu->adt)
expand_animdata(fd, mainvar, cu->adt);
2002-10-12 11:37:38 +00:00
}
static void expand_mesh(FileData *fd, Main *mainvar, Mesh *me)
{
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
CustomDataLayer *layer;
2006-11-21 16:54:00 +00:00
MTFace *mtf;
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
TFace *tf;
int a, i;
if (me->adt)
expand_animdata(fd, mainvar, me->adt);
for (a = 0; a < me->totcol; a++) {
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, me->mat[a]);
}
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, me->key);
expand_doit(fd, mainvar, me->texcomesh);
if (me->tface) {
tf = me->tface;
for (i=0; i<me->totface; i++, tf++) {
if (tf->tpage)
2006-11-21 16:54:00 +00:00
expand_doit(fd, mainvar, tf->tpage);
}
2006-11-21 16:54:00 +00:00
}
for (a = 0; a < me->fdata.totlayer; a++) {
layer = &me->fdata.layers[a];
if (layer->type == CD_MTFACE) {
mtf = (MTFace*)layer->data;
for (i = 0; i < me->totface; i++, mtf++) {
if (mtf->tpage)
2006-11-21 16:54:00 +00:00
expand_doit(fd, mainvar, mtf->tpage);
}
2006-11-21 16:54:00 +00:00
}
2002-10-12 11:37:38 +00:00
}
}
/* temp struct used to transport needed info to expand_constraint_cb() */
typedef struct tConstraintExpandData {
FileData *fd;
Main *mainvar;
} tConstraintExpandData;
/* callback function used to expand constraint ID-links */
static void expand_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, short UNUSED(isReference), void *userdata)
{
tConstraintExpandData *ced = (tConstraintExpandData *)userdata;
expand_doit(ced->fd, ced->mainvar, *idpoin);
}
2002-10-12 11:37:38 +00:00
static void expand_constraints(FileData *fd, Main *mainvar, ListBase *lb)
{
tConstraintExpandData ced;
2002-10-12 11:37:38 +00:00
bConstraint *curcon;
/* relink all ID-blocks used by the constraints */
ced.fd = fd;
ced.mainvar = mainvar;
id_loop_constraints(lb, expand_constraint_cb, &ced);
/* depreceated manual expansion stuff */
for (curcon = lb->first; curcon; curcon = curcon->next) {
if (curcon->ipo)
expand_doit(fd, mainvar, curcon->ipo); // XXX depreceated - old animation system
2002-10-12 11:37:38 +00:00
}
}
static void expand_bones(FileData *fd, Main *mainvar, Bone *bone)
{
Bone *curBone;
2002-10-12 11:37:38 +00:00
for (curBone = bone->childbase.first; curBone; curBone=curBone->next) {
expand_bones(fd, mainvar, curBone);
}
}
static void expand_pose(FileData *fd, Main *mainvar, bPose *pose)
{
bPoseChannel *chan;
2002-10-12 11:37:38 +00:00
if (!pose)
return;
for (chan = pose->chanbase.first; chan; chan = chan->next) {
2002-10-12 11:37:38 +00:00
expand_constraints(fd, mainvar, &chan->constraints);
expand_doit(fd, mainvar, chan->custom);
2002-10-12 11:37:38 +00:00
}
}
static void expand_armature(FileData *fd, Main *mainvar, bArmature *arm)
{
Bone *curBone;
if (arm->adt)
expand_animdata(fd, mainvar, arm->adt);
2002-10-12 11:37:38 +00:00
for (curBone = arm->bonebase.first; curBone; curBone=curBone->next) {
expand_bones(fd, mainvar, curBone);
}
}
static void expand_object_expandModifiers(void *userData, Object *UNUSED(ob),
2012-06-06 14:48:39 +00:00
ID **idpoin)
{
struct { FileData *fd; Main *mainvar; } *data= userData;
FileData *fd = data->fd;
Main *mainvar = data->mainvar;
expand_doit(fd, mainvar, *idpoin);
}
2002-10-12 11:37:38 +00:00
static void expand_object(FileData *fd, Main *mainvar, Object *ob)
{
ParticleSystem *psys;
2002-10-12 11:37:38 +00:00
bSensor *sens;
bController *cont;
bActuator *act;
bActionStrip *strip;
PartEff *paf;
2002-10-12 11:37:38 +00:00
int a;
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, ob->data);
/* expand_object_expandModifier() */
if (ob->modifiers.first) {
struct { FileData *fd; Main *mainvar; } data;
data.fd = fd;
data.mainvar = mainvar;
modifiers_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
}
expand_pose(fd, mainvar, ob->pose);
expand_doit(fd, mainvar, ob->poselib);
2002-10-12 11:37:38 +00:00
expand_constraints(fd, mainvar, &ob->constraints);
2009-09-16 17:43:09 +00:00
expand_doit(fd, mainvar, ob->gpd);
// XXX depreceated - old animation system (for version patching only)
expand_doit(fd, mainvar, ob->ipo);
expand_doit(fd, mainvar, ob->action);
2002-10-12 11:37:38 +00:00
expand_constraint_channels(fd, mainvar, &ob->constraintChannels);
for (strip=ob->nlastrips.first; strip; strip=strip->next) {
Big commit with work on Groups & Libraries: -> Any Group Duplicate now can get local timing and local NLA override. This enables to control the entire animation system of the Group. Two methods for this have been implemented. 1) The quick way: just give the duplicator a "Startframe" offset. 2) Advanced: in the NLA Editor you can add ActionStrips to the duplicator to override NLA/action of any Grouped Object. For "Group NLA" to work, an ActionStrip needs to know which Object in a group it controls. On adding a strip, the code checks if an Action was already used by an Object in the Group, and assigns it automatic to that Object. You can also set this in the Nkey "Properties" panel for the strip. Change in NLA: the SHIFT+A "Add strip" command now always adds strips to the active Object. (It used to check where mouse was). This allows to add NLA strips to Objects that didn't have actions/nla yet. Important note: In Blender, duplicates are fully procedural and generated on the fly for each redraw. This means that redraw speed equals to stepping through frames, when using animated Duplicated Groups. -> Recoded entire duplicator system The old method was antique and clumsy, using globals and full temporal copies of Object. The new system is nicer in control, faster, and since it doesn't use temporal object copies anymore, it works better with Derived Mesh and DisplayList and rendering. By centralizing the code for duplicating, more options can be easier added. Features to note: - Duplicates now draw selected/unselected based on its Duplicator setting. - Same goes for the drawtype (wire, solid, selection outline, etc) - Duplicated Groups can be normally selected too Bonus goodie: SHIFT+A (Toolbox) now has entry "Add group" too, with a listing of all groups, allowing to add Group instances immediate. -> Library System - SHIFT+F4 data browse now shows the entire path for linked data - Outliner draws Library Icons to denote linked data - Outliner operation added: "Make Local" for library data. - Outliner now also draws Groups in regular view, allowing to unlink too. -> Fixes - depsgraph missed signal update for bone-parented Objects - on reading file, the entire database was tagged to "recalc" fully, causing unnecessary slowdown on reading. Might have missed stuff... :)
2005-12-11 13:23:30 +00:00
expand_doit(fd, mainvar, strip->object);
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, strip->act);
expand_doit(fd, mainvar, strip->ipo);
}
// XXX depreceated - old animation system (for version patching only)
if (ob->adt)
expand_animdata(fd, mainvar, ob->adt);
for (a = 0; a < ob->totcol; a++) {
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, ob->mat[a]);
}
paf = blo_do_version_give_parteff_245(ob);
if (paf && paf->group)
expand_doit(fd, mainvar, paf->group);
if (ob->dup_group)
expand_doit(fd, mainvar, ob->dup_group);
if (ob->proxy)
expand_doit(fd, mainvar, ob->proxy);
if (ob->proxy_group)
expand_doit(fd, mainvar, ob->proxy_group);
for (psys = ob->particlesystem.first; psys; psys = psys->next)
expand_doit(fd, mainvar, psys->part);
for (sens = ob->sensors.first; sens; sens = sens->next) {
if (sens->type == SENS_TOUCH) {
bTouchSensor *ts = sens->data;
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, ts->ma);
}
else if (sens->type == SENS_MESSAGE) {
bMessageSensor *ms = sens->data;
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, ms->fromObject);
}
}
for (cont = ob->controllers.first; cont; cont = cont->next) {
if (cont->type == CONT_PYTHON) {
bPythonCont *pc = cont->data;
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, pc->text);
}
}
for (act = ob->actuators.first; act; act = act->next) {
if (act->type == ACT_SOUND) {
bSoundActuator *sa = act->data;
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, sa->sound);
}
else if (act->type == ACT_CAMERA) {
bCameraActuator *ca = act->data;
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, ca->ob);
}
else if (act->type == ACT_EDIT_OBJECT) {
bEditObjectActuator *eoa = act->data;
if (eoa) {
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, eoa->ob);
expand_doit(fd, mainvar, eoa->me);
}
}
else if (act->type == ACT_OBJECT) {
bObjectActuator *oa = act->data;
expand_doit(fd, mainvar, oa->reference);
}
else if (act->type == ACT_ADD_OBJECT) {
bAddObjectActuator *aoa = act->data;
expand_doit(fd, mainvar, aoa->ob);
}
else if (act->type == ACT_SCENE) {
bSceneActuator *sa = act->data;
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, sa->camera);
expand_doit(fd, mainvar, sa->scene);
}
else if (act->type == ACT_2DFILTER) {
bTwoDFilterActuator *tdfa = act->data;
expand_doit(fd, mainvar, tdfa->text);
}
else if (act->type == ACT_ACTION) {
bActionActuator *aa = act->data;
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, aa->act);
}
else if (act->type == ACT_SHAPEACTION) {
bActionActuator *aa = act->data;
expand_doit(fd, mainvar, aa->act);
}
else if (act->type == ACT_PROPERTY) {
bPropertyActuator *pa = act->data;
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, pa->ob);
}
else if (act->type == ACT_MESSAGE) {
bMessageActuator *ma = act->data;
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, ma->toObject);
}
else if (act->type==ACT_PARENT) {
bParentActuator *pa = act->data;
expand_doit(fd, mainvar, pa->ob);
}
else if (act->type == ACT_ARMATURE) {
bArmatureActuator *arma = act->data;
expand_doit(fd, mainvar, arma->target);
}
else if (act->type == ACT_STEERING) {
bSteeringActuator *sta = act->data;
expand_doit(fd, mainvar, sta->target);
expand_doit(fd, mainvar, sta->navmesh);
}
2002-10-12 11:37:38 +00:00
}
if (ob->pd && ob->pd->tex)
expand_doit(fd, mainvar, ob->pd->tex);
2002-10-12 11:37:38 +00:00
}
static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
{
Base *base;
SceneRenderLayer *srl;
for (base = sce->base.first; base; base = base->next) {
2002-10-12 11:37:38 +00:00
expand_doit(fd, mainvar, base->object);
}
expand_doit(fd, mainvar, sce->camera);
expand_doit(fd, mainvar, sce->world);
if (sce->adt)
expand_animdata(fd, mainvar, sce->adt);
expand_keyingsets(fd, mainvar, &sce->keyingsets);
if (sce->set)
expand_doit(fd, mainvar, sce->set);
if (sce->nodetree)
expand_nodetree(fd, mainvar, sce->nodetree);
for (srl = sce->r.layers.first; srl; srl = srl->next) {
expand_doit(fd, mainvar, srl->mat_override);
expand_doit(fd, mainvar, srl->light_override);
}
if (sce->r.dometext)
expand_doit(fd, mainvar, sce->gm.dome.warptext);
if (sce->gpd)
2009-09-16 17:43:09 +00:00
expand_doit(fd, mainvar, sce->gpd);
if (sce->ed) {
Sequence *seq;
SEQ_BEGIN (sce->ed, seq)
{
if (seq->scene) expand_doit(fd, mainvar, seq->scene);
if (seq->scene_camera) expand_doit(fd, mainvar, seq->scene_camera);
if (seq->sound) expand_doit(fd, mainvar, seq->sound);
}
SEQ_END
}
#ifdef DURIAN_CAMERA_SWITCH
{
TimeMarker *marker;
for (marker = sce->markers.first; marker; marker = marker->next) {
if (marker->camera) {
expand_doit(fd, mainvar, marker->camera);
}
}
}
#endif
expand_doit(fd, mainvar, sce->clip);
2002-10-12 11:37:38 +00:00
}
static void expand_camera(FileData *fd, Main *mainvar, Camera *ca)
{
expand_doit(fd, mainvar, ca->ipo); // XXX depreceated - old animation system
if (ca->adt)
expand_animdata(fd, mainvar, ca->adt);
2002-10-12 11:37:38 +00:00
}
static void expand_speaker(FileData *fd, Main *mainvar, Speaker *spk)
{
expand_doit(fd, mainvar, spk->sound);
if (spk->adt)
expand_animdata(fd, mainvar, spk->adt);
}
2002-10-12 11:37:38 +00:00
static void expand_sound(FileData *fd, Main *mainvar, bSound *snd)
{
expand_doit(fd, mainvar, snd->ipo); // XXX depreceated - old animation system
2002-10-12 11:37:38 +00:00
}
static void expand_movieclip(FileData *fd, Main *mainvar, MovieClip *clip)
{
if (clip->adt)
expand_animdata(fd, mainvar, clip->adt);
}
2002-10-12 11:37:38 +00:00
static void expand_main(FileData *fd, Main *mainvar)
{
ListBase *lbarray[MAX_LIBARRAY];
2002-10-12 11:37:38 +00:00
ID *id;
int a, do_it = TRUE;
if (fd == NULL) return;
while (do_it) {
do_it = FALSE;
a = set_listbasepointers(mainvar, lbarray);
while (a--) {
2002-10-12 11:37:38 +00:00
id= lbarray[a]->first;
while (id) {
if (id->flag & LIB_TEST) {
switch (GS(id->name)) {
2002-10-12 11:37:38 +00:00
case ID_OB:
expand_object(fd, mainvar, (Object *)id);
break;
case ID_ME:
expand_mesh(fd, mainvar, (Mesh *)id);
break;
case ID_CU:
expand_curve(fd, mainvar, (Curve *)id);
break;
case ID_MB:
expand_mball(fd, mainvar, (MetaBall *)id);
break;
case ID_SCE:
expand_scene(fd, mainvar, (Scene *)id);
break;
case ID_MA:
expand_material(fd, mainvar, (Material *)id);
break;
case ID_TE:
expand_texture(fd, mainvar, (Tex *)id);
break;
case ID_WO:
expand_world(fd, mainvar, (World *)id);
break;
case ID_LT:
expand_lattice(fd, mainvar, (Lattice *)id);
break;
case ID_LA:
2012-04-29 15:47:02 +00:00
expand_lamp(fd, mainvar, (Lamp *)id);
2002-10-12 11:37:38 +00:00
break;
case ID_KE:
expand_key(fd, mainvar, (Key *)id);
break;
case ID_CA:
expand_camera(fd, mainvar, (Camera *)id);
break;
case ID_SPK:
2012-04-29 15:47:02 +00:00
expand_speaker(fd, mainvar, (Speaker *)id);
break;
2002-10-12 11:37:38 +00:00
case ID_SO:
expand_sound(fd, mainvar, (bSound *)id);
break;
case ID_AR:
expand_armature(fd, mainvar, (bArmature *)id);
break;
case ID_AC:
expand_action(fd, mainvar, (bAction *)id); // XXX depreceated - old animation system
2002-10-12 11:37:38 +00:00
break;
Orange branch: Revived hidden treasure, the Groups! Previous experiment (in 2000) didn't satisfy, it had even some primitive NLA option in groups... so, cleaned up the old code (removed most) and integrated it back in a more useful way. Usage: - CTRL+G gives menu to add group, add to existing group, or remove from groups. - In Object buttons, a new (should become first) Panel was added, showing not only Object "ID button" and Parent, but also the Groups the Object Belongs to. These buttons also allow rename, assigning or removing. - To indicate Objects are grouped, they're drawn in a (not theme yet, so temporal?) green wire color. - Use ALT+SHIFT mouse-select to (de)select an entire group But, the real power of groups is in the following features: -> Particle Force field and Guide control In the "Particle Motion" Panel, you can indicate a Group name, this then limits force fields or guides to members of that Group. (Note that layers still work on top of that... not sure about that). -> Light Groups In the Material "Shaders" Panel, you can indicate a Group name to limit lighting for the Material to lamps in this group. The Lights in a Group do need to be 'visible' for the Scene to be rendered (as usual). -> Group Duplicator In the Object "Anim" Panel, you can set any Object (use Empty!) to duplicate an entire Group. It will make copies of all Objects in that Group. Also works for animated Objects, but it will copy the current positions or deforms. Control over 'local timing' (so we can do Massive anims!) will be added later. (Note; this commit won't render Group duplicators yet, a fix in bf-blender will enable that, next commit will sync) -> Library Appending In the SHIFT-F1 or SHIFT+F4 browsers, you can also find the Groups listed. By appending or linking the Group itself, and use the Group Duplicator, you now can animate and position linked Objects. The nice thing is that the local saved file itself will only store the Group name that was linked, so on a next file read, the Group Objects will be re-read as stored (changed) in the Library file. (Note; current implementation also "gives a base" to linked Group Objects, to show them as Objects in the current Scene. Need that now for testing purposes, but probably will be removed later). -> Outliner Outliner now shows Groups as optio too, nice to organize your data a bit too! In General, Groups have a very good potential... for example, it could become default for MetaBall Objects too (jiri, I can help you later on how this works). All current 'layer relationships' in Blender should be dropped in time, I guess...
2005-12-06 10:55:30 +00:00
case ID_GR:
expand_group(fd, mainvar, (Group *)id);
break;
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
case ID_NT:
expand_nodetree(fd, mainvar, (bNodeTree *)id);
break;
case ID_BR:
expand_brush(fd, mainvar, (Brush *)id);
break;
case ID_IP:
expand_ipo(fd, mainvar, (Ipo *)id); // XXX depreceated - old animation system
break;
case ID_PA:
expand_particlesettings(fd, mainvar, (ParticleSettings *)id);
break;
case ID_MC:
expand_movieclip(fd, mainvar, (MovieClip *)id);
break;
2002-10-12 11:37:38 +00:00
}
do_it = TRUE;
2002-10-12 11:37:38 +00:00
id->flag -= LIB_TEST;
2002-10-12 11:37:38 +00:00
}
id = id->next;
2002-10-12 11:37:38 +00:00
}
}
}
}
static int object_in_any_scene(Main *mainvar, Object *ob)
{
Scene *sce;
for (sce= mainvar->scene.first; sce; sce= sce->id.next) {
if (BKE_scene_base_find(sce, ob))
return 1;
}
return 0;
}
static void give_base_to_objects(Main *mainvar, Scene *sce, Library *lib, const short idcode, const short is_link)
2002-10-12 11:37:38 +00:00
{
Object *ob;
Base *base;
const short is_group_append = (is_link==FALSE && idcode==ID_GR);
/* give all objects which are LIB_INDIRECT a base, or for a group when *lib has been set */
for (ob = mainvar->object.first; ob; ob = ob->id.next) {
if (ob->id.flag & LIB_INDIRECT) {
2012-04-22 11:54:53 +00:00
/* IF below is quite confusing!
* if we are appending, but this object wasnt just added along with a group,
* then this is already used indirectly in the scene somewhere else and we didnt just append it.
*
* (ob->id.flag & LIB_PRE_EXISTING)==0 means that this is a newly appended object - Campbell */
if (is_group_append==0 || (ob->id.flag & LIB_PRE_EXISTING)==0) {
int do_it = FALSE;
if (ob->id.us == 0) {
do_it = TRUE;
}
else if (idcode==ID_GR) {
if (ob->id.us==1 && is_link==FALSE && ob->id.lib==lib) {
if ((ob->flag & OB_FROMGROUP) && object_in_any_scene(mainvar, ob)==0) {
do_it = TRUE;
}
}
}
else {
/* when appending, make sure any indirectly loaded objects
* get a base else they cant be accessed at all [#27437] */
if (ob->id.us==1 && is_link==FALSE && ob->id.lib==lib) {
/* we may be appending from a scene where we already
* have a linked object which is not in any scene [#27616] */
if ((ob->id.flag & LIB_PRE_EXISTING)==0) {
if (object_in_any_scene(mainvar, ob)==0) {
do_it = TRUE;
}
}
}
}
if (do_it) {
base = MEM_callocN(sizeof(Base), "add_ext_base");
BLI_addtail(&(sce->base), base);
base->lay = ob->lay;
base->object = ob;
base->flag = ob->flag;
ob->id.us = 1;
ob->id.flag -= LIB_INDIRECT;
ob->id.flag |= LIB_EXTERN;
}
2002-10-12 11:37:38 +00:00
}
}
}
}
static void give_base_to_groups(Main *mainvar, Scene *scene)
{
Group *group;
/* give all objects which are LIB_INDIRECT a base, or for a group when *lib has been set */
for (group = mainvar->group.first; group; group = group->id.next) {
if (((group->id.flag & LIB_INDIRECT)==0 && (group->id.flag & LIB_PRE_EXISTING)==0)) {
Base *base;
/* BKE_object_add(...) messes with the selection */
Object *ob = BKE_object_add_only_object(OB_EMPTY, group->id.name+2);
ob->type = OB_EMPTY;
ob->lay = scene->lay;
/* assign the base */
base = BKE_scene_base_add(scene, ob);
base->flag |= SELECT;
base->object->flag= base->flag;
ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
scene->basact = base;
/* assign the group */
ob->dup_group = group;
ob->transflag |= OB_DUPLIGROUP;
rename_id(&ob->id, group->id.name+2);
copy_v3_v3(ob->loc, scene->cursor);
}
}
}
2002-10-12 11:37:38 +00:00
/* returns true if the item was found
2012-04-22 11:54:53 +00:00
* but it may already have already been appended/linked */
static ID *append_named_part(Main *mainl, FileData *fd, const char *idname, const short idcode)
2002-10-12 11:37:38 +00:00
{
BHead *bhead;
ID *id = NULL;
int found = 0;
2002-10-12 11:37:38 +00:00
for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) {
if (bhead->code == idcode) {
const char *idname_test= bhead_id_name(fd, bhead);
if (strcmp(idname_test + 2, idname) == 0) {
found = 1;
id = is_yet_read(fd, mainl, bhead);
if (id == NULL) {
/* not read yet */
read_libblock(fd, mainl, bhead, LIB_TESTEXT, &id);
if (id) {
/* sort by name in list */
ListBase *lb = which_libbase(mainl, idcode);
id_sort_by_name(lb, id);
}
2002-10-12 11:37:38 +00:00
}
else {
/* already linked */
2002-10-12 11:37:38 +00:00
printf("append: already linked\n");
oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code);
if (id->flag & LIB_INDIRECT) {
2002-10-12 11:37:38 +00:00
id->flag -= LIB_INDIRECT;
id->flag |= LIB_EXTERN;
}
}
break;
2002-10-12 11:37:38 +00:00
}
}
else if (bhead->code == ENDB) {
break;
}
2002-10-12 11:37:38 +00:00
}
/* if we found the id but the id is NULL, this is really bad */
BLI_assert((found != 0) == (id != NULL));
return (found) ? id : NULL;
2002-10-12 11:37:38 +00:00
}
static ID *append_named_part_ex(const bContext *C, Main *mainl, FileData *fd, const char *idname, const int idcode, const int flag)
{
ID *id= append_named_part(mainl, fd, idname, idcode);
if (id && (GS(id->name) == ID_OB)) { /* loose object: give a base */
Scene *scene = CTX_data_scene(C); /* can be NULL */
if (scene) {
Base *base;
Object *ob;
base= MEM_callocN(sizeof(Base), "app_nam_part");
BLI_addtail(&scene->base, base);
ob = (Object *)id;
/* link at active layer (view3d->lay if in context, else scene->lay */
if ((flag & FILE_ACTIVELAY)) {
View3D *v3d = CTX_wm_view3d(C);
ob->lay = v3d ? v3d->layact : scene->lay;
}
ob->mode = 0;
base->lay = ob->lay;
base->object = ob;
ob->id.us++;
if (flag & FILE_AUTOSELECT) {
base->flag |= SELECT;
base->object->flag = base->flag;
/* do NOT make base active here! screws up GUI stuff, if you want it do it on src/ level */
}
}
}
return id;
}
ID *BLO_library_append_named_part(Main *mainl, BlendHandle** bh, const char *idname, const int idcode)
2009-09-16 17:43:09 +00:00
{
FileData *fd = (FileData*)(*bh);
return append_named_part(mainl, fd, idname, idcode);
}
ID *BLO_library_append_named_part_ex(const bContext *C, Main *mainl, BlendHandle** bh, const char *idname, const int idcode, const short flag)
{
FileData *fd = (FileData*)(*bh);
return append_named_part_ex(C, mainl, fd, idname, idcode, flag);
2009-09-16 17:43:09 +00:00
}
2002-10-12 11:37:38 +00:00
static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r)
{
BHead *bhead;
for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) {
2002-10-12 11:37:38 +00:00
if (bhead->code == GS(id->name)) {
if (strcmp(id->name, bhead_id_name(fd, bhead))==0) {
id->flag &= ~LIB_READ;
2002-10-12 11:37:38 +00:00
id->flag |= LIB_TEST;
// printf("read lib block %s\n", id->name);
2002-10-12 11:37:38 +00:00
read_libblock(fd, mainvar, bhead, id->flag, id_r);
2002-10-12 11:37:38 +00:00
break;
}
}
else if (bhead->code==ENDB)
2002-10-12 11:37:38 +00:00
break;
}
}
/* common routine to append/link something from a library */
static Main *library_append_begin(Main *mainvar, FileData **fd, const char *filepath)
2002-10-12 11:37:38 +00:00
{
Main *mainl;
(*fd)->mainlist = MEM_callocN(sizeof(ListBase), "FileData.mainlist");
/* make mains */
blo_split_main((*fd)->mainlist, mainvar);
/* which one do we need? */
mainl = blo_find_main(*fd, filepath, G.main->name);
/* needed for do_version */
mainl->versionfile = (*fd)->fileversion;
read_file_version(*fd, mainl);
2009-09-16 17:43:09 +00:00
return mainl;
}
Main *BLO_library_append_begin(Main *mainvar, BlendHandle** bh, const char *filepath)
2009-09-16 17:43:09 +00:00
{
FileData *fd = (FileData*)(*bh);
return library_append_begin(mainvar, &fd, filepath);
2009-09-16 17:43:09 +00:00
}
/* Context == NULL signifies not to do any scene manipulation */
2009-09-16 17:43:09 +00:00
static void library_append_end(const bContext *C, Main *mainl, FileData **fd, int idcode, short flag)
{
Main *mainvar;
Library *curlib;
/* make main consistent */
expand_main(*fd, mainl);
/* do this when expand found other libs */
read_libraries(*fd, (*fd)->mainlist);
curlib = mainl->curlib;
2009-09-16 17:43:09 +00:00
/* make the lib path relative if required */
if (flag & FILE_RELPATH) {
/* use the full path, this could have been read by other library even */
BLI_strncpy(curlib->name, curlib->filepath, sizeof(curlib->name));
/* uses current .blend file as reference */
BLI_path_rel(curlib->name, G.main->name);
}
blo_join_main((*fd)->mainlist);
mainvar = (*fd)->mainlist->first;
MEM_freeN((*fd)->mainlist);
mainl = NULL; /* blo_join_main free's mainl, cant use anymore */
lib_link_all(*fd, mainvar);
lib_verify_nodetree(mainvar, FALSE);
fix_relpaths_library(G.main->name, mainvar); /* make all relative paths, relative to the open blend file */
if (C) {
Scene *scene = CTX_data_scene(C);
/* give a base to loose objects. If group append, do it for objects too */
if (scene) {
const short is_link = (flag & FILE_LINK) != 0;
if (idcode == ID_SCE) {
2012-03-18 07:38:51 +00:00
/* don't instance anything when linking in scenes, assume the scene its self instances the data */
}
else {
give_base_to_objects(mainvar, scene, curlib, idcode, is_link);
if (flag & FILE_GROUP_INSTANCE) {
give_base_to_groups(mainvar, scene);
}
}
}
else {
printf("library_append_end, scene is NULL (objects wont get bases)\n");
}
}
/* has been removed... erm, why? s..ton) */
/* 20040907: looks like they are give base already in append_named_part(); -Nathan L */
/* 20041208: put back. It only linked direct, not indirect objects (ton) */
/* patch to prevent switch_endian happens twice */
if ((*fd)->flags & FD_FLAGS_SWITCH_ENDIAN) {
blo_freefiledata(*fd);
*fd = NULL;
}
2009-09-16 17:43:09 +00:00
}
void BLO_library_append_end(const bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag)
{
FileData *fd = (FileData*)(*bh);
2009-09-16 17:43:09 +00:00
library_append_end(C, mainl, &fd, idcode, flag);
*bh = (BlendHandle*)fd;
}
void *BLO_library_read_struct(FileData *fd, BHead *bh, const char *blockname)
{
return read_struct(fd, bh, blockname);
}
2002-10-12 11:37:38 +00:00
/* ************* READ LIBRARY ************** */
static int mainvar_count_libread_blocks(Main *mainvar)
{
ListBase *lbarray[MAX_LIBARRAY];
int a, tot = 0;
a = set_listbasepointers(mainvar, lbarray);
while (a--) {
ID *id;
for (id = lbarray[a]->first; id; id = id->next) {
2002-10-12 11:37:38 +00:00
if (id->flag & LIB_READ)
tot++;
}
2002-10-12 11:37:38 +00:00
}
return tot;
}
static void read_libraries(FileData *basefd, ListBase *mainlist)
{
Main *mainl = mainlist->first;
2002-10-12 11:37:38 +00:00
Main *mainptr;
ListBase *lbarray[MAX_LIBARRAY];
int a, do_it = TRUE;
while (do_it) {
do_it = FALSE;
/* test 1: read libdata */
mainptr= mainl->next;
while (mainptr) {
int tot = mainvar_count_libread_blocks(mainptr);
// printf("found LIB_READ %s\n", mainptr->curlib->name);
if (tot) {
FileData *fd = mainptr->curlib->filedata;
if (fd == NULL) {
/* printf and reports for now... its important users know this */
BKE_reportf_wrap(basefd->reports, RPT_INFO,
"read library: '%s', '%s'",
mainptr->curlib->filepath, mainptr->curlib->name);
fd = blo_openblenderfile(mainptr->curlib->filepath, basefd->reports);
/* allow typing in a new lib path */
if (G.rt == -666) {
while (fd == NULL) {
char newlib_path[FILE_MAX] = {0};
printf("Missing library...'\n");
printf(" current file: %s\n", G.main->name);
printf(" absolute lib: %s\n", mainptr->curlib->filepath);
printf(" relative lib: %s\n", mainptr->curlib->name);
printf(" enter a new path:\n");
if (scanf("%s", newlib_path) > 0) {
BLI_strncpy(mainptr->curlib->name, newlib_path, sizeof(mainptr->curlib->name));
BLI_strncpy(mainptr->curlib->filepath, newlib_path, sizeof(mainptr->curlib->filepath));
cleanup_path(G.main->name, mainptr->curlib->filepath);
fd = blo_openblenderfile(mainptr->curlib->filepath, basefd->reports);
fd->mainlist = mainlist;
if (fd) {
printf("found: '%s', party on macuno!\n", mainptr->curlib->filepath);
}
}
}
}
2002-10-12 11:37:38 +00:00
if (fd) {
/* share the mainlist, so all libraries are added immediately in a
* single list. it used to be that all FileData's had their own list,
* but with indirectly linking this meant we didn't catch duplicate
* libraries properly */
fd->mainlist = mainlist;
fd->reports = basefd->reports;
2009-09-16 17:43:09 +00:00
2002-10-12 11:37:38 +00:00
if (fd->libmap)
oldnewmap_free(fd->libmap);
fd->libmap = oldnewmap_new();
mainptr->curlib->filedata = fd;
mainptr->versionfile= fd->fileversion;
/* subversion */
read_file_version(fd, mainptr);
2002-10-12 11:37:38 +00:00
}
else mainptr->curlib->filedata = NULL;
if (fd == NULL) {
BKE_reportf_wrap(basefd->reports, RPT_ERROR,
"Can't find lib '%s'",
mainptr->curlib->filepath);
}
2002-10-12 11:37:38 +00:00
}
if (fd) {
do_it = TRUE;
a = set_listbasepointers(mainptr, lbarray);
while (a--) {
ID *id = lbarray[a]->first;
while (id) {
ID *idn = id->next;
if (id->flag & LIB_READ) {
ID *realid = NULL;
2002-10-12 11:37:38 +00:00
BLI_remlink(lbarray[a], id);
2002-10-12 11:37:38 +00:00
append_id_part(fd, mainptr, id, &realid);
if (!realid) {
BKE_reportf_wrap(fd->reports, RPT_ERROR,
"LIB ERROR: %s:'%s' missing from '%s'",
BKE_idcode_to_name(GS(id->name)),
id->name+2, mainptr->curlib->filepath);
}
change_idid_adr(mainlist, basefd, id, realid);
2002-10-12 11:37:38 +00:00
MEM_freeN(id);
}
id = idn;
2002-10-12 11:37:38 +00:00
}
}
2002-10-12 11:37:38 +00:00
expand_main(fd, mainptr);
}
}
mainptr = mainptr->next;
2002-10-12 11:37:38 +00:00
}
}
/* test if there are unread libblocks */
for (mainptr = mainl->next; mainptr; mainptr = mainptr->next) {
a = set_listbasepointers(mainptr, lbarray);
while (a--) {
ID *id, *idn = NULL;
for (id = lbarray[a]->first; id; id = idn) {
idn = id->next;
if (id->flag & LIB_READ) {
2002-10-12 11:37:38 +00:00
BLI_remlink(lbarray[a], id);
BKE_reportf_wrap(basefd->reports, RPT_ERROR,
"LIB ERROR: %s:'%s' unread libblock missing from '%s'",
BKE_idcode_to_name(GS(id->name)), id->name + 2, mainptr->curlib->filepath);
change_idid_adr(mainlist, basefd, id, NULL);
2002-10-12 11:37:38 +00:00
MEM_freeN(id);
}
}
}
}
/* do versions, link, and free */
for (mainptr = mainl->next; mainptr; mainptr = mainptr->next) {
/* some mains still have to be read, then
* versionfile is still zero! */
if (mainptr->versionfile) {
if (mainptr->curlib->filedata) // can be zero... with shift+f1 append
do_versions(mainptr->curlib->filedata, mainptr->curlib, mainptr);
else
do_versions(basefd, NULL, mainptr);
}
if (mainptr->curlib->filedata)
lib_link_all(mainptr->curlib->filedata, mainptr);
if (mainptr->curlib->filedata) blo_freefiledata(mainptr->curlib->filedata);
mainptr->curlib->filedata = NULL;
2002-10-12 11:37:38 +00:00
}
}
/* reading runtime */
2002-10-12 11:37:38 +00:00
BlendFileData *blo_read_blendafterruntime(int file, const char *name, int actualsize, ReportList *reports)
{
BlendFileData *bfd = NULL;
2002-10-12 11:37:38 +00:00
FileData *fd = filedata_new();
fd->filedes = file;
fd->buffersize = actualsize;
fd->read = fd_read_from_file;
/* needed for library_append and read_libraries */
BLI_strncpy(fd->relabase, name, sizeof(fd->relabase));
fd = blo_decode_and_check(fd, reports);
if (!fd)
return NULL;
fd->reports = reports;
bfd = blo_read_file_internal(fd, "");
2002-10-12 11:37:38 +00:00
blo_freefiledata(fd);
return bfd;
2002-10-12 11:37:38 +00:00
}