2011-10-23 17:52:20 +00:00
|
|
|
/*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2005-12-12 16:29:47 +00:00
|
|
|
|
2011-02-27 20:40:57 +00:00
|
|
|
/** \file blender/blenkernel/intern/library.c
|
|
|
|
|
* \ingroup bke
|
2012-03-24 02:51:46 +00:00
|
|
|
*
|
|
|
|
|
* Contains management of ID's and libraries
|
|
|
|
|
* allocate and free of all library data
|
2011-02-27 20:40:57 +00:00
|
|
|
*/
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
2009-12-29 15:40:26 +00:00
|
|
|
#include <stddef.h>
|
2010-10-07 10:04:07 +00:00
|
|
|
#include <assert.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
/* all types are needed here, in order to do memory operations */
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_anim_types.h"
|
|
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
|
#include "DNA_brush_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_camera_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_group_types.h"
|
2013-01-13 12:25:56 +00:00
|
|
|
#include "DNA_gpencil_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_ipo_types.h"
|
|
|
|
|
#include "DNA_key_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_lamp_types.h"
|
|
|
|
|
#include "DNA_lattice_types.h"
|
2014-05-03 18:51:53 +09:00
|
|
|
#include "DNA_linestyle_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_material_types.h"
|
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_meta_types.h"
|
2013-01-13 12:25:56 +00:00
|
|
|
#include "DNA_movieclip_types.h"
|
|
|
|
|
#include "DNA_mask_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_node_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_screen_types.h"
|
2011-08-01 11:44:20 +00:00
|
|
|
#include "DNA_speaker_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_sound_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_text_types.h"
|
|
|
|
|
#include "DNA_vfont_types.h"
|
2007-12-24 18:38:03 +00:00
|
|
|
#include "DNA_windowmanager_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_world_types.h"
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2013-03-25 08:29:06 +00:00
|
|
|
|
|
|
|
|
#include "BLF_translation.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-01-13 12:25:56 +00:00
|
|
|
#include "BKE_action.h"
|
2009-01-30 14:23:31 +00:00
|
|
|
#include "BKE_animsys.h"
|
2013-01-13 12:25:56 +00:00
|
|
|
#include "BKE_armature.h"
|
2013-03-25 08:29:06 +00:00
|
|
|
#include "BKE_bpath.h"
|
2013-01-13 12:25:56 +00:00
|
|
|
#include "BKE_brush.h"
|
2011-11-05 13:00:39 +00:00
|
|
|
#include "BKE_camera.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_curve.h"
|
2013-12-26 17:24:42 +06:00
|
|
|
#include "BKE_depsgraph.h"
|
2013-01-13 12:25:56 +00:00
|
|
|
#include "BKE_fcurve.h"
|
|
|
|
|
#include "BKE_font.h"
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_group.h"
|
|
|
|
|
#include "BKE_gpencil.h"
|
|
|
|
|
#include "BKE_idprop.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_image.h"
|
|
|
|
|
#include "BKE_ipo.h"
|
|
|
|
|
#include "BKE_key.h"
|
2013-01-13 12:25:56 +00:00
|
|
|
#include "BKE_lamp.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_lattice.h"
|
2013-01-13 12:25:56 +00:00
|
|
|
#include "BKE_library.h"
|
2013-03-23 03:00:37 +00:00
|
|
|
#include "BKE_linestyle.h"
|
2013-01-13 12:25:56 +00:00
|
|
|
#include "BKE_mesh.h"
|
|
|
|
|
#include "BKE_material.h"
|
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "BKE_mball.h"
|
|
|
|
|
#include "BKE_movieclip.h"
|
|
|
|
|
#include "BKE_mask.h"
|
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
|
|
|
#include "BKE_node.h"
|
2013-01-13 12:25:56 +00:00
|
|
|
#include "BKE_object.h"
|
2007-12-24 18:38:03 +00:00
|
|
|
#include "BKE_particle.h"
|
2013-01-13 12:25:56 +00:00
|
|
|
#include "BKE_packedFile.h"
|
2011-08-04 07:12:03 +00:00
|
|
|
#include "BKE_speaker.h"
|
2013-01-13 12:25:56 +00:00
|
|
|
#include "BKE_sound.h"
|
|
|
|
|
#include "BKE_screen.h"
|
|
|
|
|
#include "BKE_scene.h"
|
|
|
|
|
#include "BKE_text.h"
|
|
|
|
|
#include "BKE_texture.h"
|
|
|
|
|
#include "BKE_world.h"
|
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
|
|
|
|
2011-06-29 05:07:12 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
2011-03-01 09:02:54 +00:00
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
|
#include "BPY_extern.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-09-04 21:02:43 +00:00
|
|
|
/* GS reads the memory pointed at in a specific ordering.
|
2012-03-03 20:19:11 +00:00
|
|
|
* only use this definition, makes little and big endian systems
|
|
|
|
|
* work fine, in conjunction with MAKE_ID */
|
2009-09-04 21:02:43 +00:00
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* ************* general ************************ */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-11-01 06:26:55 +00:00
|
|
|
|
|
|
|
|
/* this has to be called from each make_local_* func, we could call
|
|
|
|
|
* from id_make_local() but then the make local functions would not be self
|
|
|
|
|
* contained.
|
|
|
|
|
* also note that the id _must_ have a library - campbell */
|
2011-11-30 00:32:13 +00:00
|
|
|
void BKE_id_lib_local_paths(Main *bmain, Library *lib, ID *id)
|
2011-11-01 06:26:55 +00:00
|
|
|
{
|
2014-04-27 00:20:13 +10:00
|
|
|
const char *bpath_user_data[2] = {bmain->name, lib->filepath};
|
2011-11-01 06:26:55 +00:00
|
|
|
|
2012-12-15 15:31:50 +00:00
|
|
|
BKE_bpath_traverse_id(bmain, id,
|
|
|
|
|
BKE_bpath_relocate_visitor,
|
|
|
|
|
BKE_BPATH_TRAVERSE_SKIP_MULTIFILE,
|
2012-05-06 17:22:54 +00:00
|
|
|
bpath_user_data);
|
2011-11-01 06:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
void id_lib_extern(ID *id)
|
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (id) {
|
|
|
|
|
if (id->flag & LIB_INDIRECT) {
|
2002-10-12 11:37:38 +00:00
|
|
|
id->flag -= LIB_INDIRECT;
|
|
|
|
|
id->flag |= LIB_EXTERN;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-18 08:41:38 +00:00
|
|
|
/* ensure we have a real user */
|
|
|
|
|
void id_us_ensure_real(ID *id)
|
|
|
|
|
{
|
2012-12-19 01:28:00 +00:00
|
|
|
if (id) {
|
|
|
|
|
if (ID_REAL_USERS(id) <= 0) {
|
|
|
|
|
id->us = MAX2(id->us, 0) + 1;
|
|
|
|
|
}
|
2012-12-18 08:41:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
void id_us_plus(ID *id)
|
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (id) {
|
2002-10-12 11:37:38 +00:00
|
|
|
id->us++;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (id->flag & LIB_INDIRECT) {
|
2002-10-12 11:37:38 +00:00
|
|
|
id->flag -= LIB_INDIRECT;
|
|
|
|
|
id->flag |= LIB_EXTERN;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
/* decrements the user count for *id. */
|
2009-05-27 00:03:49 +00:00
|
|
|
void id_us_min(ID *id)
|
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (id) {
|
2012-03-31 00:59:17 +00:00
|
|
|
if (id->us < 2 && (id->flag & LIB_FAKEUSER)) {
|
2012-05-06 17:22:54 +00:00
|
|
|
id->us = 1;
|
2012-03-31 00:59:17 +00:00
|
|
|
}
|
|
|
|
|
else if (id->us <= 0) {
|
|
|
|
|
printf("ID user decrement error: %s\n", id->name);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2010-12-17 14:20:20 +00:00
|
|
|
id->us--;
|
2012-03-31 00:59:17 +00:00
|
|
|
}
|
2010-12-17 14:20:20 +00:00
|
|
|
}
|
2009-05-27 00:03:49 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
/* calls the appropriate make_local method for the block, unless test. Returns true
|
|
|
|
|
* if the block can be made local. */
|
|
|
|
|
bool id_make_local(ID *id, bool test)
|
2009-09-04 21:02:43 +00:00
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (id->flag & LIB_INDIRECT)
|
2013-03-10 05:46:24 +00:00
|
|
|
return false;
|
2009-09-04 21:02:43 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (GS(id->name)) {
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_SCE:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* not implemented */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_LI:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* can't be linked */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_OB:
|
2012-05-05 14:03:12 +00:00
|
|
|
if (!test) BKE_object_make_local((Object *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_ME:
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!test) {
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_mesh_make_local((Mesh *)id);
|
|
|
|
|
BKE_key_make_local(((Mesh *)id)->key);
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_CU:
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!test) {
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_curve_make_local((Curve *)id);
|
|
|
|
|
BKE_key_make_local(((Curve *)id)->key);
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_MB:
|
2012-05-07 06:38:41 +00:00
|
|
|
if (!test) BKE_mball_make_local((MetaBall *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_MA:
|
2012-05-05 16:03:57 +00:00
|
|
|
if (!test) BKE_material_make_local((Material *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_TE:
|
2012-05-05 16:03:57 +00:00
|
|
|
if (!test) BKE_texture_make_local((Tex *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_IM:
|
2012-05-05 14:52:04 +00:00
|
|
|
if (!test) BKE_image_make_local((Image *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_LT:
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!test) {
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_lattice_make_local((Lattice *)id);
|
|
|
|
|
BKE_key_make_local(((Lattice *)id)->key);
|
2.5: Object module
* Split object_edit.c into multiple files:
object_add.c, object_edit.c, object_hook.c, object_relations.c,
object_select.c, object_transform.c.
* Rename files to have consistent object_ and mball_ prefix:
object_shapekey.c, object_lattice.c, object_vgroup.c, mball_edit.c.
* Added operators:
* vertex group menu and set active
* apply location, rotation, scale, visual transform (location is new)
* make local
* make vertex parent
* move to layer
* convert to curve/mesh (not finished yet)
* Many small fixes for marked issues, but still much code to be cleaned
up here...
2009-09-09 11:52:56 +00:00
|
|
|
}
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_LA:
|
2012-05-05 16:03:57 +00:00
|
|
|
if (!test) BKE_lamp_make_local((Lamp *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_CA:
|
2012-05-05 14:03:12 +00:00
|
|
|
if (!test) BKE_camera_make_local((Camera *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2011-08-01 11:44:20 +00:00
|
|
|
case ID_SPK:
|
2012-05-05 16:03:57 +00:00
|
|
|
if (!test) BKE_speaker_make_local((Speaker *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_IP:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* deprecated */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_KE:
|
2012-05-05 14:03:12 +00:00
|
|
|
if (!test) BKE_key_make_local((Key *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_WO:
|
2012-05-05 14:03:12 +00:00
|
|
|
if (!test) BKE_world_make_local((World *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_SCR:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* can't be linked */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_VF:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* not implemented */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_TXT:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* not implemented */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_SCRIPT:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* deprecated */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_SO:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* not implemented */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_GR:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* not implemented */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_AR:
|
2012-05-05 14:03:12 +00:00
|
|
|
if (!test) BKE_armature_make_local((bArmature *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_AC:
|
2012-05-05 14:03:12 +00:00
|
|
|
if (!test) BKE_action_make_local((bAction *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_NT:
|
2013-09-23 08:20:16 +00:00
|
|
|
if (!test) ntreeMakeLocal((bNodeTree *)id);
|
|
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_BR:
|
2012-05-05 14:03:12 +00:00
|
|
|
if (!test) BKE_brush_make_local((Brush *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_PA:
|
2012-05-05 14:03:12 +00:00
|
|
|
if (!test) BKE_particlesettings_make_local((ParticleSettings *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_WM:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* can't be linked */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_GD:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* not implemented */
|
2010-06-25 22:45:42 +00:00
|
|
|
case ID_LS:
|
2014-04-22 09:39:21 +09:00
|
|
|
return false; /* not implemented */
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
return false;
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
/**
|
|
|
|
|
* Invokes the appropriate copy method for the block and returns the result in
|
|
|
|
|
* newid, unless test. Returns true iff the block can be copied.
|
|
|
|
|
*/
|
|
|
|
|
bool id_copy(ID *id, ID **newid, bool test)
|
2009-09-04 21:02:43 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = NULL;
|
2009-09-04 21:02:43 +00:00
|
|
|
|
|
|
|
|
/* conventions:
|
|
|
|
|
* - make shallow copy, only this ID block
|
|
|
|
|
* - id.us of the new ID is set to 1 */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (GS(id->name)) {
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_SCE:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* can't be copied from here */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_LI:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* can't be copied from here */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_OB:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_object_copy((Object *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_ME:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_mesh_copy((Mesh *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_CU:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_curve_copy((Curve *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_MB:
|
2012-05-07 06:38:41 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_mball_copy((MetaBall *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_MA:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_material_copy((Material *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_TE:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_texture_copy((Tex *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_IM:
|
2013-02-08 15:56:14 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_image_copy(G.main, (Image *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_LT:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_lattice_copy((Lattice *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_LA:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_lamp_copy((Lamp *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2011-08-01 11:44:20 +00:00
|
|
|
case ID_SPK:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_speaker_copy((Speaker *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_CA:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_camera_copy((Camera *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_IP:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* deprecated */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_KE:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_key_copy((Key *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_WO:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_world_copy((World *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_SCR:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* can't be copied from here */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_VF:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* not implemented */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_TXT:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_text_copy((Text *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_SCRIPT:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* deprecated */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_SO:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* not implemented */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_GR:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_group_copy((Group *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_AR:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_armature_copy((bArmature *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_AC:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_action_copy((bAction *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_NT:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)ntreeCopyTree((bNodeTree *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_BR:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_brush_copy((Brush *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_PA:
|
2012-05-06 17:22:54 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_particlesettings_copy((ParticleSettings *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_WM:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* can't be copied from here */
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_GD:
|
2013-03-10 05:46:24 +00:00
|
|
|
return false; /* not implemented */
|
2012-07-27 08:18:11 +00:00
|
|
|
case ID_MSK:
|
|
|
|
|
if (!test) *newid = (ID *)BKE_mask_copy((Mask *)id);
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2010-06-25 22:45:42 +00:00
|
|
|
case ID_LS:
|
2013-03-23 03:00:37 +00:00
|
|
|
if (!test) *newid = (ID *)BKE_copy_linestyle((FreestyleLineStyle *)id);
|
2014-04-22 09:39:21 +09:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
return false;
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
bool id_unlink(ID *id, int test)
|
2009-09-04 21:02:43 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
Main *mainlib = G.main;
|
2014-01-15 16:37:03 +01:00
|
|
|
short type = GS(id->name);
|
2009-09-04 21:02:43 +00:00
|
|
|
|
2014-01-15 16:37:03 +01:00
|
|
|
switch (type) {
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_TXT:
|
2013-03-10 05:46:24 +00:00
|
|
|
if (test) return true;
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_text_unlink(mainlib, (Text *)id);
|
2009-09-04 21:02:43 +00:00
|
|
|
break;
|
|
|
|
|
case ID_GR:
|
2013-03-10 05:46:24 +00:00
|
|
|
if (test) return true;
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_group_unlink((Group *)id);
|
2009-09-04 21:02:43 +00:00
|
|
|
break;
|
|
|
|
|
case ID_OB:
|
2013-03-10 05:46:24 +00:00
|
|
|
if (test) return true;
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_unlink((Object *)id);
|
2009-09-04 21:02:43 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (id->us == 0) {
|
2013-03-10 05:46:24 +00:00
|
|
|
if (test) return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
|
2014-01-15 16:37:03 +01:00
|
|
|
BKE_libblock_free(mainlib, id);
|
2009-09-04 21:02:43 +00:00
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
return false;
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
|
2011-06-29 04:34:20 +00:00
|
|
|
{
|
|
|
|
|
ID *newid = NULL;
|
|
|
|
|
PointerRNA idptr;
|
|
|
|
|
|
|
|
|
|
if (id) {
|
|
|
|
|
/* if property isn't editable, we're going to have an extra block hanging around until we save */
|
|
|
|
|
if (RNA_property_editable(ptr, prop)) {
|
2013-03-10 05:46:24 +00:00
|
|
|
if (id_copy(id, &newid, false) && newid) {
|
2011-06-29 04:34:20 +00:00
|
|
|
/* copy animation actions too */
|
|
|
|
|
BKE_copy_animdata_id_action(id);
|
|
|
|
|
/* us is 1 by convention, but RNA_property_pointer_set
|
2012-03-09 00:41:09 +00:00
|
|
|
* will also increment it, so set it to zero */
|
|
|
|
|
newid->us = 0;
|
2011-06-29 04:34:20 +00:00
|
|
|
|
|
|
|
|
/* assign copy */
|
|
|
|
|
RNA_id_pointer_create(newid, &idptr);
|
|
|
|
|
RNA_property_pointer_set(ptr, prop, idptr);
|
|
|
|
|
RNA_property_update(C, ptr, prop);
|
|
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2011-06-29 04:34:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
return false;
|
2011-06-29 04:34:20 +00:00
|
|
|
}
|
|
|
|
|
|
* Multiply for panorama cameras
* Some cases of struct name being set where it shouldnt have been.
* Spelling: wich --> which
* Copy and initialize uv modifier scale, remove unneeded enum.
* Ability to pin any object into the context.
* Update uv window while transforming (useful when used with UVProject modifier)
* Patch by Wahooney, so new template's are internal text and dont get saved over
by mistake.
* Fix for https://bugzilla.redhat.com/show_bug.cgi?id=572186
Bug 572186 - [abrt] crash in blender-2.49b-5.fc12: Process
/usr/bin/blender.bin was killed by signal 6 (SIGABRT). Original fix submitted
by Jochen Schmitt.
* [#21816] bpy.data.add_image has stopped working on Windows. moved to
bpy.data.images.load(), missed this call.
(commits 27726,27825,27828,27831,27832,27833,27834,27836,27837,27838,27839,27858 by Campbell from render25 branch)
2010-03-30 12:15:16 +00:00
|
|
|
ListBase *which_libbase(Main *mainlib, short type)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
switch (type) {
|
2002-10-12 11:37:38 +00:00
|
|
|
case ID_SCE:
|
|
|
|
|
return &(mainlib->scene);
|
|
|
|
|
case ID_LI:
|
|
|
|
|
return &(mainlib->library);
|
|
|
|
|
case ID_OB:
|
|
|
|
|
return &(mainlib->object);
|
|
|
|
|
case ID_ME:
|
|
|
|
|
return &(mainlib->mesh);
|
|
|
|
|
case ID_CU:
|
|
|
|
|
return &(mainlib->curve);
|
|
|
|
|
case ID_MB:
|
|
|
|
|
return &(mainlib->mball);
|
|
|
|
|
case ID_MA:
|
|
|
|
|
return &(mainlib->mat);
|
|
|
|
|
case ID_TE:
|
|
|
|
|
return &(mainlib->tex);
|
|
|
|
|
case ID_IM:
|
|
|
|
|
return &(mainlib->image);
|
|
|
|
|
case ID_LT:
|
|
|
|
|
return &(mainlib->latt);
|
|
|
|
|
case ID_LA:
|
|
|
|
|
return &(mainlib->lamp);
|
|
|
|
|
case ID_CA:
|
|
|
|
|
return &(mainlib->camera);
|
|
|
|
|
case ID_IP:
|
|
|
|
|
return &(mainlib->ipo);
|
|
|
|
|
case ID_KE:
|
|
|
|
|
return &(mainlib->key);
|
|
|
|
|
case ID_WO:
|
|
|
|
|
return &(mainlib->world);
|
|
|
|
|
case ID_SCR:
|
|
|
|
|
return &(mainlib->screen);
|
|
|
|
|
case ID_VF:
|
|
|
|
|
return &(mainlib->vfont);
|
|
|
|
|
case ID_TXT:
|
|
|
|
|
return &(mainlib->text);
|
2003-12-14 01:18:09 +00:00
|
|
|
case ID_SCRIPT:
|
|
|
|
|
return &(mainlib->script);
|
2011-08-01 11:44:20 +00:00
|
|
|
case ID_SPK:
|
|
|
|
|
return &(mainlib->speaker);
|
2002-10-12 11:37:38 +00:00
|
|
|
case ID_SO:
|
|
|
|
|
return &(mainlib->sound);
|
|
|
|
|
case ID_GR:
|
|
|
|
|
return &(mainlib->group);
|
|
|
|
|
case ID_AR:
|
|
|
|
|
return &(mainlib->armature);
|
|
|
|
|
case ID_AC:
|
|
|
|
|
return &(mainlib->action);
|
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:
|
|
|
|
|
return &(mainlib->nodetree);
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
case ID_BR:
|
|
|
|
|
return &(mainlib->brush);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
case ID_PA:
|
|
|
|
|
return &(mainlib->particle);
|
2007-12-24 18:38:03 +00:00
|
|
|
case ID_WM:
|
|
|
|
|
return &(mainlib->wm);
|
2.5
Patch from Joshua, converting Grease Pencil to 2.5.
All GP data now is an ID block, allowing re-use, link and append.
For better contextual control within 2.5, these GP ID's will get
linked to actual data, like NodeTrees, Scenes, Images or Objects.
That will ensure Undo works, and opens up exciting new use cases
as well. :)
Patch note: on reading files, GPencils linked from editors will
get moved to the main library, using standard naming (indicating
where it was used), and with "Fake User" set. That way the user
can manually relink the pencils where appropriate.
We can check on just linking GP to some default, like 3d window
pencils to Scene? Nice to experiment with.
Notes for Joshua:
- for reading old GPencil, it has to use old code as well, meaning
to tread data as "indirect data, within another ID".
- Saving ID data means the chunk in file BHead needs the ID_GD code,
and not "DATA", which indicates 'indirect data'. That's the file
format spec.
- I've added do_versions_gpencil_2_50(), feel free to further tweak
things here, like linking things to scene or so.
- Formerly GPencil saved 2.50 files won't convert gpencil
2009-04-20 10:13:55 +00:00
|
|
|
case ID_GD:
|
|
|
|
|
return &(mainlib->gpencil);
|
2011-11-07 12:55:18 +00:00
|
|
|
case ID_MC:
|
|
|
|
|
return &(mainlib->movieclip);
|
2012-06-04 16:42:58 +00:00
|
|
|
case ID_MSK:
|
|
|
|
|
return &(mainlib->mask);
|
2010-06-25 22:45:42 +00:00
|
|
|
case ID_LS:
|
|
|
|
|
return &(mainlib->linestyle);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2011-02-13 10:52:18 +00:00
|
|
|
return NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2007-04-20 18:48:30 +00:00
|
|
|
/* Flag all ids in listbase */
|
2013-12-30 13:25:27 +11:00
|
|
|
void BKE_main_id_flag_listbase(ListBase *lb, const short flag, const bool value)
|
2007-04-20 18:48:30 +00:00
|
|
|
{
|
|
|
|
|
ID *id;
|
|
|
|
|
if (value) {
|
2012-05-06 17:22:54 +00:00
|
|
|
for (id = lb->first; id; id = id->next) id->flag |= flag;
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2013-12-30 13:25:27 +11:00
|
|
|
const short nflag = ~flag;
|
|
|
|
|
for (id = lb->first; id; id = id->next) id->flag &= nflag;
|
2007-04-20 18:48:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Flag all ids in listbase */
|
2013-12-30 13:25:27 +11:00
|
|
|
void BKE_main_id_flag_all(Main *bmain, const short flag, const bool value)
|
2007-04-20 18:48:30 +00:00
|
|
|
{
|
|
|
|
|
ListBase *lbarray[MAX_LIBARRAY];
|
|
|
|
|
int a;
|
2013-12-30 13:25:27 +11:00
|
|
|
a = set_listbasepointers(bmain, lbarray);
|
|
|
|
|
while (a--) {
|
|
|
|
|
BKE_main_id_flag_listbase(lbarray[a], flag, value);
|
|
|
|
|
}
|
2007-04-20 18:48:30 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-30 13:25:27 +11:00
|
|
|
void BKE_main_lib_objects_recalc_all(Main *bmain)
|
2009-09-12 19:54:39 +00:00
|
|
|
{
|
2009-09-14 12:30:49 +00:00
|
|
|
Object *ob;
|
|
|
|
|
|
|
|
|
|
/* flag for full recalc */
|
2013-12-30 13:25:27 +11:00
|
|
|
for (ob = bmain->object.first; ob; ob = ob->id.next)
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ob->id.lib)
|
2012-05-06 17:22:54 +00:00
|
|
|
ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
|
2014-01-09 19:13:26 +06:00
|
|
|
|
|
|
|
|
DAG_id_type_tag(bmain, ID_OB);
|
2009-09-12 19:54:39 +00:00
|
|
|
}
|
2007-04-20 18:48:30 +00:00
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
/**
|
|
|
|
|
* puts into array *lb pointers to all the ListBase structs in main,
|
|
|
|
|
* and returns the number of them as the function result. This is useful for
|
|
|
|
|
* generic traversal of all the blocks in a Main (by traversing all the
|
|
|
|
|
* lists in turn), without worrying about block types.
|
|
|
|
|
*
|
|
|
|
|
* \note MAX_LIBARRAY define should match this code */
|
2002-10-12 11:37:38 +00:00
|
|
|
int set_listbasepointers(Main *main, ListBase **lb)
|
|
|
|
|
{
|
2008-07-08 17:04:58 +00:00
|
|
|
int a = 0;
|
|
|
|
|
|
2010-10-29 07:11:45 +00:00
|
|
|
/* BACKWARDS! also watch order of free-ing! (mesh<->mat), first items freed last.
|
|
|
|
|
* This is important because freeing data decreases usercounts of other datablocks,
|
|
|
|
|
* if this data is its self freed it can crash. */
|
2012-05-06 17:22:54 +00:00
|
|
|
lb[a++] = &(main->ipo);
|
|
|
|
|
lb[a++] = &(main->action); // xxx moved here to avoid problems when freeing with animato (aligorith)
|
|
|
|
|
lb[a++] = &(main->key);
|
|
|
|
|
lb[a++] = &(main->gpencil); /* referenced by nodes, objects, view, scene etc, before to free after. */
|
|
|
|
|
lb[a++] = &(main->nodetree);
|
|
|
|
|
lb[a++] = &(main->image);
|
|
|
|
|
lb[a++] = &(main->tex);
|
|
|
|
|
lb[a++] = &(main->mat);
|
|
|
|
|
lb[a++] = &(main->vfont);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
/* Important!: When adding a new object type,
|
|
|
|
|
* the specific data should be inserted here
|
|
|
|
|
*/
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
lb[a++] = &(main->armature);
|
|
|
|
|
|
|
|
|
|
lb[a++] = &(main->mesh);
|
|
|
|
|
lb[a++] = &(main->curve);
|
|
|
|
|
lb[a++] = &(main->mball);
|
|
|
|
|
|
|
|
|
|
lb[a++] = &(main->latt);
|
|
|
|
|
lb[a++] = &(main->lamp);
|
|
|
|
|
lb[a++] = &(main->camera);
|
|
|
|
|
|
|
|
|
|
lb[a++] = &(main->text);
|
|
|
|
|
lb[a++] = &(main->sound);
|
|
|
|
|
lb[a++] = &(main->group);
|
|
|
|
|
lb[a++] = &(main->brush);
|
|
|
|
|
lb[a++] = &(main->script);
|
|
|
|
|
lb[a++] = &(main->particle);
|
|
|
|
|
lb[a++] = &(main->speaker);
|
|
|
|
|
|
|
|
|
|
lb[a++] = &(main->world);
|
|
|
|
|
lb[a++] = &(main->screen);
|
|
|
|
|
lb[a++] = &(main->object);
|
2013-04-06 19:42:58 +00:00
|
|
|
lb[a++] = &(main->linestyle); /* referenced by scenes */
|
2012-05-06 17:22:54 +00:00
|
|
|
lb[a++] = &(main->scene);
|
|
|
|
|
lb[a++] = &(main->library);
|
|
|
|
|
lb[a++] = &(main->wm);
|
|
|
|
|
lb[a++] = &(main->movieclip);
|
2012-06-04 16:42:58 +00:00
|
|
|
lb[a++] = &(main->mask);
|
2007-01-18 15:23:28 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
lb[a] = NULL;
|
2003-12-14 01:18:09 +00:00
|
|
|
|
2008-07-08 17:04:58 +00:00
|
|
|
return a;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* *********** ALLOC AND FREE *****************
|
2012-03-03 20:19:11 +00:00
|
|
|
*
|
2012-05-05 14:03:12 +00:00
|
|
|
* BKE_libblock_free(ListBase *lb, ID *id )
|
2012-03-03 20:19:11 +00:00
|
|
|
* provide a list-basis and datablock, but only ID is read
|
|
|
|
|
*
|
2012-05-05 14:03:12 +00:00
|
|
|
* void *BKE_libblock_alloc(ListBase *lb, type, name)
|
2012-03-03 20:19:11 +00:00
|
|
|
* inserts in list and returns a new ID
|
|
|
|
|
*
|
|
|
|
|
* **************************** */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
/**
|
|
|
|
|
* Allocates and returns memory of the right size for the specified block type,
|
|
|
|
|
* initialized to zero.
|
|
|
|
|
*/
|
2002-10-12 11:37:38 +00:00
|
|
|
static ID *alloc_libblock_notest(short type)
|
|
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
ID *id = NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
switch (type) {
|
2002-10-12 11:37:38 +00:00
|
|
|
case ID_SCE:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Scene), "scene");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_LI:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Library), "library");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_OB:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Object), "object");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_ME:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Mesh), "mesh");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_CU:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Curve), "curve");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_MB:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(MetaBall), "mball");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_MA:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Material), "mat");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_TE:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Tex), "tex");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_IM:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Image), "image");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_LT:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Lattice), "latt");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_LA:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Lamp), "lamp");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_CA:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Camera), "camera");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_IP:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Ipo), "ipo");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_KE:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Key), "key");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_WO:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(World), "world");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_SCR:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(bScreen), "screen");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_VF:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(VFont), "vfont");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_TXT:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Text), "text");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
2003-12-14 01:18:09 +00:00
|
|
|
case ID_SCRIPT:
|
2012-05-27 19:40:36 +00:00
|
|
|
//XXX id = MEM_callocN(sizeof(Script), "script");
|
2003-12-14 01:18:09 +00:00
|
|
|
break;
|
2011-08-01 11:44:20 +00:00
|
|
|
case ID_SPK:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Speaker), "speaker");
|
2011-08-01 11:44:20 +00:00
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
case ID_SO:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(bSound), "sound");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_GR:
|
2012-05-06 17:22:54 +00:00
|
|
|
id = MEM_callocN(sizeof(Group), "group");
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_AR:
|
|
|
|
|
id = MEM_callocN(sizeof(bArmature), "armature");
|
|
|
|
|
break;
|
|
|
|
|
case ID_AC:
|
2009-01-18 10:41:45 +00:00
|
|
|
id = MEM_callocN(sizeof(bAction), "action");
|
2002-10-12 11:37:38 +00:00
|
|
|
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:
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
id = MEM_callocN(sizeof(bNodeTree), "nodetree");
|
|
|
|
|
break;
|
|
|
|
|
case ID_BR:
|
|
|
|
|
id = MEM_callocN(sizeof(Brush), "brush");
|
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
|
|
|
break;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
case ID_PA:
|
|
|
|
|
id = MEM_callocN(sizeof(ParticleSettings), "ParticleSettings");
|
2011-11-11 13:09:14 +00:00
|
|
|
break;
|
2007-12-24 18:38:03 +00:00
|
|
|
case ID_WM:
|
|
|
|
|
id = MEM_callocN(sizeof(wmWindowManager), "Window manager");
|
2011-11-11 13:09:14 +00:00
|
|
|
break;
|
2.5
Patch from Joshua, converting Grease Pencil to 2.5.
All GP data now is an ID block, allowing re-use, link and append.
For better contextual control within 2.5, these GP ID's will get
linked to actual data, like NodeTrees, Scenes, Images or Objects.
That will ensure Undo works, and opens up exciting new use cases
as well. :)
Patch note: on reading files, GPencils linked from editors will
get moved to the main library, using standard naming (indicating
where it was used), and with "Fake User" set. That way the user
can manually relink the pencils where appropriate.
We can check on just linking GP to some default, like 3d window
pencils to Scene? Nice to experiment with.
Notes for Joshua:
- for reading old GPencil, it has to use old code as well, meaning
to tread data as "indirect data, within another ID".
- Saving ID data means the chunk in file BHead needs the ID_GD code,
and not "DATA", which indicates 'indirect data'. That's the file
format spec.
- I've added do_versions_gpencil_2_50(), feel free to further tweak
things here, like linking things to scene or so.
- Formerly GPencil saved 2.50 files won't convert gpencil
2009-04-20 10:13:55 +00:00
|
|
|
case ID_GD:
|
|
|
|
|
id = MEM_callocN(sizeof(bGPdata), "Grease Pencil");
|
|
|
|
|
break;
|
2011-11-07 12:55:18 +00:00
|
|
|
case ID_MC:
|
|
|
|
|
id = MEM_callocN(sizeof(MovieClip), "Movie Clip");
|
|
|
|
|
break;
|
2012-06-04 16:42:58 +00:00
|
|
|
case ID_MSK:
|
|
|
|
|
id = MEM_callocN(sizeof(Mask), "Mask");
|
|
|
|
|
break;
|
2010-06-25 22:45:42 +00:00
|
|
|
case ID_LS:
|
|
|
|
|
id = MEM_callocN(sizeof(FreestyleLineStyle), "Freestyle Line Style");
|
|
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
/**
|
|
|
|
|
* Allocates and returns a block of the specified type, with the specified name
|
|
|
|
|
* (adjusted as necessary to ensure uniqueness), and appended to the specified list.
|
|
|
|
|
* The user count is set to 1, all other content (apart from name and links) being
|
|
|
|
|
* initialized to zero.
|
|
|
|
|
*/
|
2014-01-15 16:37:03 +01:00
|
|
|
void *BKE_libblock_alloc(Main *bmain, short type, const char *name)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
ID *id = NULL;
|
2014-01-15 16:37:03 +01:00
|
|
|
ListBase *lb = which_libbase(bmain, type);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
id = alloc_libblock_notest(type);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (id) {
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_addtail(lb, id);
|
2012-05-06 17:22:54 +00:00
|
|
|
id->us = 1;
|
2005-12-21 22:21:43 +00:00
|
|
|
id->icon_id = 0;
|
2012-05-06 17:22:54 +00:00
|
|
|
*( (short *)id->name) = type;
|
2002-10-12 11:37:38 +00:00
|
|
|
new_id(lb, id, name);
|
2013-03-10 05:46:24 +00:00
|
|
|
/* alphabetic insertion: is in new_id */
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2014-01-15 16:37:03 +01:00
|
|
|
DAG_id_type_tag(bmain, type);
|
2002-10-12 11:37:38 +00:00
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-30 14:23:31 +00:00
|
|
|
/* by spec, animdata is first item after ID */
|
2009-09-30 04:59:14 +00:00
|
|
|
/* and, trust that BKE_animdata_from_id() will only find AnimData for valid ID-types */
|
2013-03-10 05:46:24 +00:00
|
|
|
static void id_copy_animdata(ID *id, const bool do_action)
|
2009-01-30 14:23:31 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
AnimData *adt = BKE_animdata_from_id(id);
|
2009-01-30 14:23:31 +00:00
|
|
|
|
2009-09-30 04:59:14 +00:00
|
|
|
if (adt) {
|
|
|
|
|
IdAdtTemplate *iat = (IdAdtTemplate *)id;
|
2013-03-10 05:46:24 +00:00
|
|
|
iat->adt = BKE_copy_animdata(iat->adt, do_action); /* could be set to false, need to investigate */
|
2009-09-30 04:59:14 +00:00
|
|
|
}
|
2009-01-30 14:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
2010-02-15 08:50:04 +00:00
|
|
|
/* material nodes use this since they are not treated as libdata */
|
2013-03-10 05:46:24 +00:00
|
|
|
void BKE_libblock_copy_data(ID *id, const ID *id_from, const bool do_action)
|
2010-02-15 08:50:04 +00:00
|
|
|
{
|
|
|
|
|
if (id_from->properties)
|
|
|
|
|
id->properties = IDP_CopyProperty(id_from->properties);
|
|
|
|
|
|
|
|
|
|
/* the duplicate should get a copy of the animdata */
|
2010-11-09 09:53:17 +00:00
|
|
|
id_copy_animdata(id, do_action);
|
2010-02-15 08:50:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* used everywhere in blenkernel */
|
2013-02-05 12:46:15 +00:00
|
|
|
void *BKE_libblock_copy_ex(Main *bmain, ID *id)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2011-11-07 04:36:37 +00:00
|
|
|
ID *idn;
|
2010-04-29 21:46:25 +00:00
|
|
|
size_t idn_len;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2014-01-15 16:37:03 +01:00
|
|
|
idn = BKE_libblock_alloc(bmain, GS(id->name), id->name + 2);
|
2010-10-07 10:04:07 +00:00
|
|
|
|
|
|
|
|
assert(idn != NULL);
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
idn_len = MEM_allocN_len(idn);
|
2012-03-24 06:18:31 +00:00
|
|
|
if ((int)idn_len - (int)sizeof(ID) > 0) { /* signed to allow neg result */
|
2012-05-06 17:22:54 +00:00
|
|
|
const char *cp = (const char *)id;
|
|
|
|
|
char *cpn = (char *)idn;
|
2011-11-07 04:36:37 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
memcpy(cpn + sizeof(ID), cp + sizeof(ID), idn_len - sizeof(ID));
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
id->newid = idn;
|
2002-10-12 11:37:38 +00:00
|
|
|
idn->flag |= LIB_NEW;
|
2010-02-15 08:50:04 +00:00
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
BKE_libblock_copy_data(idn, id, false);
|
2009-01-30 14:23:31 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return idn;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 14:59:14 +02:00
|
|
|
void *BKE_libblock_copy_nolib(ID *id, const bool do_action)
|
2014-03-21 13:44:38 +01:00
|
|
|
{
|
|
|
|
|
ID *idn;
|
|
|
|
|
size_t idn_len;
|
|
|
|
|
|
|
|
|
|
idn = alloc_libblock_notest(GS(id->name));
|
|
|
|
|
assert(idn != NULL);
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(idn->name, id->name, sizeof(idn->name));
|
|
|
|
|
|
|
|
|
|
idn_len = MEM_allocN_len(idn);
|
|
|
|
|
if ((int)idn_len - (int)sizeof(ID) > 0) { /* signed to allow neg result */
|
|
|
|
|
const char *cp = (const char *)id;
|
|
|
|
|
char *cpn = (char *)idn;
|
|
|
|
|
|
|
|
|
|
memcpy(cpn + sizeof(ID), cp + sizeof(ID), idn_len - sizeof(ID));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
id->newid = idn;
|
|
|
|
|
idn->flag |= LIB_NEW;
|
|
|
|
|
|
2014-05-09 14:59:14 +02:00
|
|
|
BKE_libblock_copy_data(idn, id, do_action);
|
2014-03-21 13:44:38 +01:00
|
|
|
|
|
|
|
|
return idn;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-05 12:46:15 +00:00
|
|
|
void *BKE_libblock_copy(ID *id)
|
|
|
|
|
{
|
|
|
|
|
return BKE_libblock_copy_ex(G.main, id);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-13 12:25:56 +00:00
|
|
|
static void BKE_library_free(Library *lib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2013-01-13 12:25:56 +00:00
|
|
|
if (lib->packedfile)
|
|
|
|
|
freePackedFile(lib->packedfile);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
static void (*free_windowmanager_cb)(bContext *, wmWindowManager *) = NULL;
|
2007-12-24 18:38:03 +00:00
|
|
|
|
|
|
|
|
void set_free_windowmanager_cb(void (*func)(bContext *C, wmWindowManager *) )
|
|
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
free_windowmanager_cb = func;
|
2007-12-24 18:38:03 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 13:03:04 +00:00
|
|
|
static void (*free_notifier_reference_cb)(const void *) = NULL;
|
|
|
|
|
|
|
|
|
|
void set_free_notifier_reference_cb(void (*func)(const void *) )
|
|
|
|
|
{
|
|
|
|
|
free_notifier_reference_cb = func;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
static void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata)
|
2010-01-29 21:16:21 +00:00
|
|
|
{
|
|
|
|
|
ChannelDriver *driver;
|
|
|
|
|
FCurve *fcu;
|
|
|
|
|
|
|
|
|
|
/* find the driver this belongs to and update it */
|
2012-05-06 17:22:54 +00:00
|
|
|
for (fcu = adt->drivers.first; fcu; fcu = fcu->next) {
|
|
|
|
|
driver = fcu->driver;
|
2010-01-30 05:08:42 +00:00
|
|
|
|
2010-01-29 21:16:21 +00:00
|
|
|
if (driver) {
|
|
|
|
|
DriverVar *dvar;
|
2012-05-06 17:22:54 +00:00
|
|
|
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
|
2010-01-30 05:08:42 +00:00
|
|
|
DRIVER_TARGETS_USED_LOOPER(dvar)
|
|
|
|
|
{
|
|
|
|
|
if (dtar->id == userdata)
|
2012-05-06 17:22:54 +00:00
|
|
|
dtar->id = NULL;
|
2010-01-29 21:16:21 +00:00
|
|
|
}
|
2010-01-30 05:08:42 +00:00
|
|
|
DRIVER_TARGETS_LOOPER_END
|
2010-01-29 21:16:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-28 17:09:50 +00:00
|
|
|
void BKE_libblock_free_data(ID *id)
|
|
|
|
|
{
|
|
|
|
|
Main *bmain = G.main; /* should eventually be an arg */
|
|
|
|
|
|
|
|
|
|
if (id->properties) {
|
|
|
|
|
IDP_FreeProperty(id->properties);
|
|
|
|
|
MEM_freeN(id->properties);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* this ID may be a driver target! */
|
|
|
|
|
BKE_animdata_main_cb(bmain, animdata_dtar_clear_cb, (void *)id);
|
|
|
|
|
}
|
2010-01-29 21:16:21 +00:00
|
|
|
|
2007-04-06 10:08:48 +00:00
|
|
|
/* used in headerbuttons.c image.c mesh.c screen.c sound.c and library.c */
|
2014-01-15 16:37:03 +01:00
|
|
|
void BKE_libblock_free_ex(Main *bmain, void *idv, bool do_id_user)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
ID *id = idv;
|
2014-01-15 16:37:03 +01:00
|
|
|
short type = GS(id->name);
|
|
|
|
|
ListBase *lb = which_libbase(bmain, type);
|
|
|
|
|
|
|
|
|
|
DAG_id_type_tag(bmain, type);
|
2011-03-01 09:02:54 +00:00
|
|
|
|
|
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
|
BPY_id_release(id);
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-01-15 16:37:03 +01:00
|
|
|
switch (type) { /* GetShort from util.h */
|
2002-10-12 11:37:38 +00:00
|
|
|
case ID_SCE:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_scene_free((Scene *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_LI:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_library_free((Library *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_OB:
|
2013-12-25 16:43:26 +06:00
|
|
|
BKE_object_free_ex((Object *)id, do_id_user);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_ME:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_mesh_free((Mesh *)id, 1);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_CU:
|
2012-04-28 16:49:00 +00:00
|
|
|
BKE_curve_free((Curve *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_MB:
|
2012-05-07 06:38:41 +00:00
|
|
|
BKE_mball_free((MetaBall *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_MA:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_material_free((Material *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_TE:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_texture_free((Tex *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_IM:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_image_free((Image *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_LT:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_lattice_free((Lattice *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_LA:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_lamp_free((Lamp *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_CA:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_camera_free((Camera *) id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_IP:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_ipo_free((Ipo *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_KE:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_key_free((Key *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_WO:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_world_free((World *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_SCR:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_screen_free((bScreen *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_VF:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_vfont_free((VFont *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_TXT:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_text_free((Text *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
2003-12-14 01:18:09 +00:00
|
|
|
case ID_SCRIPT:
|
2012-09-06 00:33:59 +00:00
|
|
|
/* deprecated */
|
2003-12-14 01:18:09 +00:00
|
|
|
break;
|
2011-08-01 11:44:20 +00:00
|
|
|
case ID_SPK:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_speaker_free((Speaker *)id);
|
2011-08-01 11:44:20 +00:00
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
case ID_SO:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_sound_free((bSound *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_GR:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_group_free((Group *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_AR:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_armature_free((bArmature *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
|
case ID_AC:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_action_free((bAction *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
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:
|
2013-12-26 08:57:44 +11:00
|
|
|
ntreeFreeTree_ex((bNodeTree *)id, do_id_user);
|
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
|
|
|
break;
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
case ID_BR:
|
2012-05-05 00:58:22 +00:00
|
|
|
BKE_brush_free((Brush *)id);
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
break;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
case ID_PA:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_particlesettings_free((ParticleSettings *)id);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
break;
|
2007-12-24 18:38:03 +00:00
|
|
|
case ID_WM:
|
2012-03-24 06:18:31 +00:00
|
|
|
if (free_windowmanager_cb)
|
2007-12-24 18:38:03 +00:00
|
|
|
free_windowmanager_cb(NULL, (wmWindowManager *)id);
|
|
|
|
|
break;
|
2.5
Patch from Joshua, converting Grease Pencil to 2.5.
All GP data now is an ID block, allowing re-use, link and append.
For better contextual control within 2.5, these GP ID's will get
linked to actual data, like NodeTrees, Scenes, Images or Objects.
That will ensure Undo works, and opens up exciting new use cases
as well. :)
Patch note: on reading files, GPencils linked from editors will
get moved to the main library, using standard naming (indicating
where it was used), and with "Fake User" set. That way the user
can manually relink the pencils where appropriate.
We can check on just linking GP to some default, like 3d window
pencils to Scene? Nice to experiment with.
Notes for Joshua:
- for reading old GPencil, it has to use old code as well, meaning
to tread data as "indirect data, within another ID".
- Saving ID data means the chunk in file BHead needs the ID_GD code,
and not "DATA", which indicates 'indirect data'. That's the file
format spec.
- I've added do_versions_gpencil_2_50(), feel free to further tweak
things here, like linking things to scene or so.
- Formerly GPencil saved 2.50 files won't convert gpencil
2009-04-20 10:13:55 +00:00
|
|
|
case ID_GD:
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_gpencil_free((bGPdata *)id);
|
2.5
Patch from Joshua, converting Grease Pencil to 2.5.
All GP data now is an ID block, allowing re-use, link and append.
For better contextual control within 2.5, these GP ID's will get
linked to actual data, like NodeTrees, Scenes, Images or Objects.
That will ensure Undo works, and opens up exciting new use cases
as well. :)
Patch note: on reading files, GPencils linked from editors will
get moved to the main library, using standard naming (indicating
where it was used), and with "Fake User" set. That way the user
can manually relink the pencils where appropriate.
We can check on just linking GP to some default, like 3d window
pencils to Scene? Nice to experiment with.
Notes for Joshua:
- for reading old GPencil, it has to use old code as well, meaning
to tread data as "indirect data, within another ID".
- Saving ID data means the chunk in file BHead needs the ID_GD code,
and not "DATA", which indicates 'indirect data'. That's the file
format spec.
- I've added do_versions_gpencil_2_50(), feel free to further tweak
things here, like linking things to scene or so.
- Formerly GPencil saved 2.50 files won't convert gpencil
2009-04-20 10:13:55 +00:00
|
|
|
break;
|
2011-11-07 12:55:18 +00:00
|
|
|
case ID_MC:
|
2012-04-28 16:49:00 +00:00
|
|
|
BKE_movieclip_free((MovieClip *)id);
|
2011-11-07 12:55:18 +00:00
|
|
|
break;
|
2012-06-04 16:42:58 +00:00
|
|
|
case ID_MSK:
|
2012-09-14 01:15:08 +00:00
|
|
|
BKE_mask_free(bmain, (Mask *)id);
|
2012-06-04 16:42:58 +00:00
|
|
|
break;
|
2010-06-25 22:45:42 +00:00
|
|
|
case ID_LS:
|
2013-03-23 03:00:37 +00:00
|
|
|
BKE_free_linestyle((FreestyleLineStyle *)id);
|
2010-06-25 22:45:42 +00:00
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 13:03:04 +00:00
|
|
|
/* avoid notifying on removed data */
|
|
|
|
|
if (free_notifier_reference_cb)
|
|
|
|
|
free_notifier_reference_cb(id);
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_remlink(lb, id);
|
|
|
|
|
|
2012-10-28 17:09:50 +00:00
|
|
|
BKE_libblock_free_data(id);
|
2010-01-29 21:16:21 +00:00
|
|
|
|
|
|
|
|
MEM_freeN(id);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2014-01-15 16:37:03 +01:00
|
|
|
void BKE_libblock_free(Main *bmain, void *idv)
|
2013-12-25 16:43:26 +06:00
|
|
|
{
|
2014-01-15 16:37:03 +01:00
|
|
|
BKE_libblock_free_ex(bmain, idv, true);
|
2013-12-25 16:43:26 +06:00
|
|
|
}
|
|
|
|
|
|
2014-01-15 16:37:03 +01:00
|
|
|
void BKE_libblock_free_us(Main *bmain, void *idv) /* test users */
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
ID *id = idv;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
id->us--;
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
if (id->us < 0) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (id->lib) printf("ERROR block %s %s users %d\n", id->lib->name, id->name, id->us);
|
2002-10-12 11:37:38 +00:00
|
|
|
else printf("ERROR block %s users %d\n", id->name, id->us);
|
|
|
|
|
}
|
2012-05-06 17:22:54 +00:00
|
|
|
if (id->us == 0) {
|
|
|
|
|
if (GS(id->name) == ID_OB) BKE_object_unlink((Object *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2014-01-15 16:37:03 +01:00
|
|
|
BKE_libblock_free(bmain, id);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-26 17:24:42 +06:00
|
|
|
Main *BKE_main_new(void)
|
|
|
|
|
{
|
|
|
|
|
Main *bmain = MEM_callocN(sizeof(Main), "new main");
|
2014-01-05 17:13:18 +06:00
|
|
|
bmain->eval_ctx = MEM_callocN(sizeof(EvaluationContext), "EvaluationContext");
|
2013-12-26 17:24:42 +06:00
|
|
|
return bmain;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-12-30 13:25:27 +11:00
|
|
|
void BKE_main_free(Main *mainvar)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2003-04-26 11:56:44 +00:00
|
|
|
/* also call when reading a file, erase all, etc */
|
2002-10-12 11:37:38 +00:00
|
|
|
ListBase *lbarray[MAX_LIBARRAY];
|
|
|
|
|
int a;
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
a = set_listbasepointers(mainvar, lbarray);
|
2012-03-24 06:18:31 +00:00
|
|
|
while (a--) {
|
2012-05-06 17:22:54 +00:00
|
|
|
ListBase *lb = lbarray[a];
|
2002-10-12 11:37:38 +00:00
|
|
|
ID *id;
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
while ( (id = lb->first) ) {
|
2012-09-14 01:15:08 +00:00
|
|
|
#if 1
|
2014-01-15 16:37:03 +01:00
|
|
|
BKE_libblock_free_ex(mainvar, id, false);
|
2012-09-14 01:15:08 +00:00
|
|
|
#else
|
|
|
|
|
/* errors freeing ID's can be hard to track down,
|
|
|
|
|
* enable this so valgrind will give the line number in its error log */
|
|
|
|
|
switch (a) {
|
2014-01-15 16:37:03 +01:00
|
|
|
case 0: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 1: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 2: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 3: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 4: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 5: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 6: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 7: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 8: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 9: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 10: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 11: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 12: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 13: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 14: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 15: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 16: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 17: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 18: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 19: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 20: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 21: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 22: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 23: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 24: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 25: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 26: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 27: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 28: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 29: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 30: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 31: BKE_libblock_free_ex(mainvar, id, false); break;
|
|
|
|
|
case 32: BKE_libblock_free_ex(mainvar, id, false); break;
|
2012-09-14 01:15:08 +00:00
|
|
|
default:
|
|
|
|
|
BLI_assert(0);
|
2013-07-21 08:16:37 +00:00
|
|
|
break;
|
2012-09-14 01:15:08 +00:00
|
|
|
}
|
|
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-26 17:24:42 +06:00
|
|
|
MEM_freeN(mainvar->eval_ctx);
|
2002-10-12 11:37:38 +00:00
|
|
|
MEM_freeN(mainvar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ***************** ID ************************ */
|
|
|
|
|
|
2006-07-07 17:08:04 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
ID *BKE_libblock_find_name(const short type, const char *name) /* type: "OB" or "MA" etc */
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2012-05-06 12:13:45 +00:00
|
|
|
ListBase *lb = which_libbase(G.main, type);
|
|
|
|
|
BLI_assert(lb != NULL);
|
2009-12-29 15:40:26 +00:00
|
|
|
return BLI_findstring(lb, name, offsetof(ID, name) + 2);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2012-04-06 16:19:30 +00:00
|
|
|
void id_sort_by_name(ListBase *lb, ID *id)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
ID *idtest;
|
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* insert alphabetically */
|
2012-05-06 17:22:54 +00:00
|
|
|
if (lb->first != lb->last) {
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_remlink(lb, id);
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
idtest = lb->first;
|
2012-03-24 06:18:31 +00:00
|
|
|
while (idtest) {
|
2012-05-06 17:22:54 +00:00
|
|
|
if (BLI_strcasecmp(idtest->name, id->name) > 0 || (idtest->lib && !id->lib)) {
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_insertlinkbefore(lb, idtest, id);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2012-05-06 17:22:54 +00:00
|
|
|
idtest = idtest->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2003-04-26 11:56:44 +00:00
|
|
|
/* as last */
|
2012-05-06 17:22:54 +00:00
|
|
|
if (idtest == NULL) {
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_addtail(lb, id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-10 05:58:09 +00:00
|
|
|
/**
|
2009-12-28 01:31:47 +00:00
|
|
|
* Check to see if there is an ID with the same name as 'name'.
|
|
|
|
|
* Returns the ID if so, if not, returns NULL
|
|
|
|
|
*/
|
2010-11-17 09:45:45 +00:00
|
|
|
static ID *is_dupid(ListBase *lb, ID *id, const char *name)
|
2009-12-28 01:31:47 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
ID *idtest = NULL;
|
2009-12-28 01:31:47 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
for (idtest = lb->first; idtest; idtest = idtest->next) {
|
2009-12-28 01:31:47 +00:00
|
|
|
/* if idtest is not a lib */
|
2012-05-06 17:22:54 +00:00
|
|
|
if (id != idtest && idtest->lib == NULL) {
|
2009-12-28 01:31:47 +00:00
|
|
|
/* do not test alphabetic! */
|
|
|
|
|
/* optimized */
|
2012-05-06 17:22:54 +00:00
|
|
|
if (idtest->name[2] == name[0]) {
|
|
|
|
|
if (strcmp(name, idtest->name + 2) == 0) break;
|
2009-12-28 01:31:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return idtest;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-10 05:58:09 +00:00
|
|
|
/**
|
2007-03-29 04:55:29 +00:00
|
|
|
* Check to see if an ID name is already used, and find a new one if so.
|
2013-03-10 05:46:24 +00:00
|
|
|
* Return true if created a new name (returned in name).
|
2007-03-29 04:55:29 +00:00
|
|
|
*
|
|
|
|
|
* Normally the ID that's being check is already in the ListBase, so ID *id
|
|
|
|
|
* points at the new entry. The Python Library module needs to know what
|
|
|
|
|
* the name of a datablock will be before it is appended; in this case ID *id
|
2012-06-05 22:12:17 +00:00
|
|
|
* id is NULL
|
2007-03-29 04:55:29 +00:00
|
|
|
*/
|
|
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
static bool check_for_dupid(ListBase *lb, ID *id, char *name)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
ID *idtest;
|
2013-08-07 08:20:37 +00:00
|
|
|
int nr = 0, a, left_len;
|
2013-03-10 05:46:24 +00:00
|
|
|
#define MAX_IN_USE 64
|
|
|
|
|
bool in_use[MAX_IN_USE];
|
2013-03-10 05:58:09 +00:00
|
|
|
/* to speed up finding unused numbers within [1 .. MAX_IN_USE - 1] */
|
2012-01-11 08:51:06 +00:00
|
|
|
|
|
|
|
|
char left[MAX_ID_NAME + 8], leftest[MAX_ID_NAME + 8];
|
2010-03-06 18:21:57 +00:00
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
while (true) {
|
2007-03-29 04:55:29 +00:00
|
|
|
|
|
|
|
|
/* phase 1: id already exists? */
|
2009-12-28 01:31:47 +00:00
|
|
|
idtest = is_dupid(lb, id, name);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2007-03-29 04:55:29 +00:00
|
|
|
/* if there is no double, done */
|
2013-03-10 05:46:24 +00:00
|
|
|
if (idtest == NULL) return false;
|
2007-03-29 04:55:29 +00:00
|
|
|
|
|
|
|
|
/* we have a dup; need to make a new name */
|
2013-03-10 05:46:24 +00:00
|
|
|
/* quick check so we can reuse one of first MAX_IN_USE - 1 ids if vacant */
|
|
|
|
|
memset(in_use, false, sizeof(in_use));
|
2007-03-29 04:55:29 +00:00
|
|
|
|
|
|
|
|
/* get name portion, number portion ("name.number") */
|
2012-05-06 17:22:54 +00:00
|
|
|
left_len = BLI_split_name_num(left, &nr, name, '.');
|
2007-03-29 04:55:29 +00:00
|
|
|
|
|
|
|
|
/* if new name will be too long, truncate it */
|
2013-03-10 05:46:24 +00:00
|
|
|
if (nr > 999 && left_len > (MAX_ID_NAME - 8)) { /* assumption: won't go beyond 9999 */
|
2012-05-06 17:22:54 +00:00
|
|
|
left[MAX_ID_NAME - 8] = 0;
|
|
|
|
|
left_len = MAX_ID_NAME - 8;
|
2010-08-22 07:11:40 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (left_len > (MAX_ID_NAME - 7)) {
|
2012-05-06 17:22:54 +00:00
|
|
|
left[MAX_ID_NAME - 7] = 0;
|
|
|
|
|
left_len = MAX_ID_NAME - 7;
|
2010-08-22 07:11:40 +00:00
|
|
|
}
|
2007-03-29 04:55:29 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
for (idtest = lb->first; idtest; idtest = idtest->next) {
|
2013-08-07 08:20:37 +00:00
|
|
|
int nrtest;
|
2012-05-06 17:22:54 +00:00
|
|
|
if ( (id != idtest) &&
|
|
|
|
|
(idtest->lib == NULL) &&
|
|
|
|
|
(*name == *(idtest->name + 2)) &&
|
|
|
|
|
(strncmp(name, idtest->name + 2, left_len) == 0) &&
|
|
|
|
|
(BLI_split_name_num(leftest, &nrtest, idtest->name + 2, '.') == left_len)
|
|
|
|
|
)
|
|
|
|
|
{
|
2013-03-10 05:58:09 +00:00
|
|
|
/* will get here at least once, otherwise is_dupid call above would have returned NULL */
|
2013-03-10 05:46:24 +00:00
|
|
|
if (nrtest < MAX_IN_USE)
|
|
|
|
|
in_use[nrtest] = true; /* mark as used */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (nr <= nrtest)
|
2012-05-06 17:22:54 +00:00
|
|
|
nr = nrtest + 1; /* track largest unused */
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2013-08-07 08:20:37 +00:00
|
|
|
/* At this point, 'nr' will typically be at least 1. (but not always) */
|
|
|
|
|
// BLI_assert(nr >= 1);
|
2007-03-29 04:55:29 +00:00
|
|
|
|
|
|
|
|
/* decide which value of nr to use */
|
2013-03-10 05:46:24 +00:00
|
|
|
for (a = 0; a < MAX_IN_USE; a++) {
|
|
|
|
|
if (a >= nr) break; /* stop when we've checked up to biggest */ /* redundant check */
|
|
|
|
|
if (!in_use[a]) { /* found an unused value */
|
2007-03-29 04:55:29 +00:00
|
|
|
nr = a;
|
2013-03-10 05:58:09 +00:00
|
|
|
/* can only be zero if all potential duplicate names had
|
|
|
|
|
* nonzero numeric suffixes, which means name itself has
|
|
|
|
|
* nonzero numeric suffix (else no name conflict and wouldn't
|
|
|
|
|
* have got here), which means name[left_len] is not a null */
|
2007-03-29 04:55:29 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2013-03-10 05:58:09 +00:00
|
|
|
/* At this point, nr is either the lowest unused number within [0 .. MAX_IN_USE - 1],
|
|
|
|
|
* or 1 greater than the largest used number if all those low ones are taken.
|
|
|
|
|
* We can't be bothered to look for the lowest unused number beyond (MAX_IN_USE - 1). */
|
2007-03-29 04:55:29 +00:00
|
|
|
|
2009-12-28 01:31:47 +00:00
|
|
|
/* If the original name has no numeric suffix,
|
|
|
|
|
* rather than just chopping and adding numbers,
|
2010-07-23 04:41:27 +00:00
|
|
|
* shave off the end chars until we have a unique name.
|
2012-03-18 07:38:51 +00:00
|
|
|
* Check the null terminators match as well so we don't get Cube.000 -> Cube.00 */
|
2012-05-06 17:22:54 +00:00
|
|
|
if (nr == 0 && name[left_len] == '\0') {
|
2013-03-10 05:58:09 +00:00
|
|
|
int len;
|
|
|
|
|
/* FIXME: this code will never be executed, because either nr will be
|
|
|
|
|
* at least 1, or name will not end at left_len! */
|
|
|
|
|
BLI_assert(0);
|
|
|
|
|
|
|
|
|
|
len = left_len - 1;
|
2012-05-06 17:22:54 +00:00
|
|
|
idtest = is_dupid(lb, id, name);
|
2009-12-28 01:31:47 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
while (idtest && len > 1) {
|
2009-12-28 01:31:47 +00:00
|
|
|
name[len--] = '\0';
|
2012-05-06 17:22:54 +00:00
|
|
|
idtest = is_dupid(lb, id, name);
|
2007-03-29 04:55:29 +00:00
|
|
|
}
|
2013-03-10 05:46:24 +00:00
|
|
|
if (idtest == NULL) return true;
|
2009-12-28 01:31:47 +00:00
|
|
|
/* otherwise just continue and use a number suffix */
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2009-12-28 01:31:47 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (nr > 999 && left_len > (MAX_ID_NAME - 8)) {
|
2009-12-28 01:31:47 +00:00
|
|
|
/* this would overflow name buffer */
|
2012-01-11 08:51:06 +00:00
|
|
|
left[MAX_ID_NAME - 8] = 0;
|
2012-03-18 07:38:51 +00:00
|
|
|
/* left_len = MAX_ID_NAME - 8; */ /* for now this isn't used again */
|
2012-01-11 08:51:06 +00:00
|
|
|
memcpy(name, left, sizeof(char) * (MAX_ID_NAME - 7));
|
2009-12-28 01:31:47 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
/* this format specifier is from hell... */
|
2012-04-29 15:47:02 +00:00
|
|
|
BLI_snprintf(name, sizeof(id->name) - 2, "%s.%.3d", left, nr);
|
2009-12-28 01:31:47 +00:00
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
return true;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2013-03-10 05:46:24 +00:00
|
|
|
|
|
|
|
|
#undef MAX_IN_USE
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-29 04:55:29 +00:00
|
|
|
/*
|
|
|
|
|
* Only for local blocks: external en indirect blocks already have a
|
|
|
|
|
* unique ID.
|
|
|
|
|
*
|
2013-03-10 05:46:24 +00:00
|
|
|
* return true: created a new name
|
2007-03-29 04:55:29 +00:00
|
|
|
*/
|
|
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
bool new_id(ListBase *lb, ID *id, const char *tname)
|
2007-03-21 02:23:28 +00:00
|
|
|
{
|
2013-03-10 05:46:24 +00:00
|
|
|
bool result;
|
2012-05-06 17:22:54 +00:00
|
|
|
char name[MAX_ID_NAME - 2];
|
2010-03-06 18:21:57 +00:00
|
|
|
|
2007-03-29 04:55:29 +00:00
|
|
|
/* if library, don't rename */
|
2013-03-25 08:29:06 +00:00
|
|
|
if (id->lib)
|
|
|
|
|
return false;
|
2007-03-29 04:55:29 +00:00
|
|
|
|
|
|
|
|
/* if no libdata given, look up based on ID */
|
2013-03-25 08:29:06 +00:00
|
|
|
if (lb == NULL)
|
|
|
|
|
lb = which_libbase(G.main, GS(id->name));
|
2007-03-29 04:55:29 +00:00
|
|
|
|
2010-03-06 18:21:57 +00:00
|
|
|
/* if no name given, use name of current ID
|
|
|
|
|
* else make a copy (tname args can be const) */
|
2012-05-06 17:22:54 +00:00
|
|
|
if (tname == NULL)
|
|
|
|
|
tname = id->name + 2;
|
2010-03-06 18:21:57 +00:00
|
|
|
|
2013-03-25 08:29:06 +00:00
|
|
|
BLI_strncpy(name, tname, sizeof(name));
|
2007-03-29 04:55:29 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (name[0] == '\0') {
|
2010-08-30 08:28:48 +00:00
|
|
|
/* disallow empty names */
|
2013-03-25 08:29:06 +00:00
|
|
|
BLI_strncpy(name, DATA_(ID_FALLBACK_NAME), sizeof(name));
|
2010-08-30 08:28:48 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* disallow non utf8 chars,
|
2012-03-18 07:38:51 +00:00
|
|
|
* the interface checks for this but new ID's based on file names don't */
|
2010-08-30 08:28:48 +00:00
|
|
|
BLI_utf8_invalid_strip(name, strlen(name));
|
|
|
|
|
}
|
2007-03-29 04:55:29 +00:00
|
|
|
|
2010-03-06 18:21:57 +00:00
|
|
|
result = check_for_dupid(lb, id, name);
|
2012-05-06 17:22:54 +00:00
|
|
|
strcpy(id->name + 2, name);
|
2007-03-29 04:55:29 +00:00
|
|
|
|
2007-04-06 10:08:48 +00:00
|
|
|
/* This was in 2.43 and previous releases
|
|
|
|
|
* however all data in blender should be sorted, not just duplicate names
|
2013-10-05 14:19:39 +00:00
|
|
|
* sorting should not hurt, but noting just incase it alters the way other
|
2007-04-06 10:08:48 +00:00
|
|
|
* functions work, so sort every time */
|
2012-03-03 20:19:11 +00:00
|
|
|
#if 0
|
2012-05-06 17:22:54 +00:00
|
|
|
if (result)
|
2012-04-06 16:19:30 +00:00
|
|
|
id_sort_by_name(lb, id);
|
2012-03-03 20:19:11 +00:00
|
|
|
#endif
|
|
|
|
|
|
2012-04-06 16:19:30 +00:00
|
|
|
id_sort_by_name(lb, id);
|
2007-04-06 10:08:48 +00:00
|
|
|
|
2007-03-21 02:23:28 +00:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-30 13:25:27 +11:00
|
|
|
/**
|
|
|
|
|
* Pull an ID out of a library (make it local). Only call this for IDs that
|
|
|
|
|
* don't have other library users.
|
|
|
|
|
*/
|
2011-10-26 21:22:35 +00:00
|
|
|
void id_clear_lib_data(Main *bmain, ID *id)
|
2011-10-26 10:49:21 +00:00
|
|
|
{
|
2013-06-12 07:02:52 +00:00
|
|
|
bNodeTree *ntree = NULL;
|
|
|
|
|
|
2011-11-30 00:32:13 +00:00
|
|
|
BKE_id_lib_local_paths(bmain, id->lib, id);
|
2011-11-01 06:26:55 +00:00
|
|
|
|
2014-04-20 14:33:27 +02:00
|
|
|
if (id->flag & LIB_FAKEUSER) {
|
|
|
|
|
id->us--;
|
|
|
|
|
id->flag &= ~LIB_FAKEUSER;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
id->lib = NULL;
|
|
|
|
|
id->flag = LIB_LOCAL;
|
2011-10-26 21:22:35 +00:00
|
|
|
new_id(which_libbase(bmain, GS(id->name)), id, NULL);
|
2013-06-12 07:02:52 +00:00
|
|
|
|
|
|
|
|
/* internal bNodeTree blocks inside ID types below
|
|
|
|
|
* also stores id->lib, make sure this stays in sync.
|
|
|
|
|
*/
|
|
|
|
|
switch (GS(id->name)) {
|
|
|
|
|
case ID_SCE: ntree = ((Scene *)id)->nodetree; break;
|
|
|
|
|
case ID_MA: ntree = ((Material *)id)->nodetree; break;
|
|
|
|
|
case ID_LA: ntree = ((Lamp *)id)->nodetree; break;
|
|
|
|
|
case ID_WO: ntree = ((World *)id)->nodetree; break;
|
|
|
|
|
case ID_TE: ntree = ((Tex *)id)->nodetree; break;
|
2014-05-03 18:51:53 +09:00
|
|
|
case ID_LS: ntree = ((FreestyleLineStyle *)id)->nodetree; break;
|
2013-06-12 07:02:52 +00:00
|
|
|
}
|
|
|
|
|
if (ntree)
|
|
|
|
|
ntree->id.lib = NULL;
|
2011-10-26 10:49:21 +00:00
|
|
|
}
|
|
|
|
|
|
2007-04-06 10:08:48 +00:00
|
|
|
/* next to indirect usage in read/writefile also in editobject.c scene.c */
|
2013-12-30 13:25:27 +11:00
|
|
|
void BKE_main_id_clear_newpoins(Main *bmain)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
ListBase *lbarray[MAX_LIBARRAY];
|
|
|
|
|
ID *id;
|
|
|
|
|
int a;
|
|
|
|
|
|
2013-12-30 13:25:27 +11:00
|
|
|
a = set_listbasepointers(bmain, lbarray);
|
2012-03-24 06:18:31 +00:00
|
|
|
while (a--) {
|
2012-05-06 17:22:54 +00:00
|
|
|
id = lbarray[a]->first;
|
2012-03-24 06:18:31 +00:00
|
|
|
while (id) {
|
2012-05-06 17:22:54 +00:00
|
|
|
id->newid = NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
id->flag &= ~LIB_NEW;
|
2012-05-06 17:22:54 +00:00
|
|
|
id = id->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-31 07:22:18 +00:00
|
|
|
static void lib_indirect_test_id(ID *id, Library *lib)
|
2006-03-05 17:35:06 +00:00
|
|
|
{
|
2013-03-10 05:46:24 +00:00
|
|
|
#define LIBTAG(a) if (a && a->id.lib) { a->id.flag &= ~LIB_INDIRECT; a->id.flag |= LIB_EXTERN; } (void)0
|
2006-03-05 17:35:06 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (id->lib) {
|
2010-03-31 07:22:18 +00:00
|
|
|
/* datablocks that were indirectly related are now direct links
|
|
|
|
|
* without this, appending data that has a link to other data will fail to write */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (lib && id->lib->parent == lib) {
|
2010-03-31 07:22:18 +00:00
|
|
|
id_lib_extern(id);
|
|
|
|
|
}
|
2006-03-05 17:35:06 +00:00
|
|
|
return;
|
2010-03-31 07:22:18 +00:00
|
|
|
}
|
2.5
Patch from Joshua, converting Grease Pencil to 2.5.
All GP data now is an ID block, allowing re-use, link and append.
For better contextual control within 2.5, these GP ID's will get
linked to actual data, like NodeTrees, Scenes, Images or Objects.
That will ensure Undo works, and opens up exciting new use cases
as well. :)
Patch note: on reading files, GPencils linked from editors will
get moved to the main library, using standard naming (indicating
where it was used), and with "Fake User" set. That way the user
can manually relink the pencils where appropriate.
We can check on just linking GP to some default, like 3d window
pencils to Scene? Nice to experiment with.
Notes for Joshua:
- for reading old GPencil, it has to use old code as well, meaning
to tread data as "indirect data, within another ID".
- Saving ID data means the chunk in file BHead needs the ID_GD code,
and not "DATA", which indicates 'indirect data'. That's the file
format spec.
- I've added do_versions_gpencil_2_50(), feel free to further tweak
things here, like linking things to scene or so.
- Formerly GPencil saved 2.50 files won't convert gpencil
2009-04-20 10:13:55 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
if (GS(id->name) == ID_OB) {
|
|
|
|
|
Object *ob = (Object *)id;
|
2006-03-05 17:35:06 +00:00
|
|
|
Mesh *me;
|
2008-04-27 18:26:20 +00:00
|
|
|
|
2006-03-05 17:35:06 +00:00
|
|
|
int a;
|
2011-12-04 17:24:34 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */
|
2012-07-07 22:51:57 +00:00
|
|
|
/* XXX old animation system! -------------------------------------- */
|
2011-12-04 17:24:34 +00:00
|
|
|
{
|
|
|
|
|
bActionStrip *strip;
|
2012-05-06 17:22:54 +00:00
|
|
|
for (strip = ob->nlastrips.first; strip; strip = strip->next) {
|
2011-12-04 17:24:34 +00:00
|
|
|
LIBTAG(strip->object);
|
|
|
|
|
LIBTAG(strip->act);
|
|
|
|
|
LIBTAG(strip->ipo);
|
|
|
|
|
}
|
2006-03-05 17:35:06 +00:00
|
|
|
}
|
2012-07-07 22:51:57 +00:00
|
|
|
/* XXX: new animation system needs something like this? */
|
2011-12-04 17:24:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
for (a = 0; a < ob->totcol; a++) {
|
2006-03-05 17:35:06 +00:00
|
|
|
LIBTAG(ob->mat[a]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBTAG(ob->dup_group);
|
2007-01-25 11:59:29 +00:00
|
|
|
LIBTAG(ob->proxy);
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
me = ob->data;
|
2006-03-05 17:35:06 +00:00
|
|
|
LIBTAG(me);
|
|
|
|
|
}
|
2013-03-10 05:46:24 +00:00
|
|
|
|
|
|
|
|
#undef LIBTAG
|
2006-03-05 17:35:06 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-30 13:25:27 +11:00
|
|
|
void BKE_main_id_tag_listbase(ListBase *lb, const bool tag)
|
2009-08-07 03:51:28 +00:00
|
|
|
{
|
|
|
|
|
ID *id;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tag) {
|
2012-05-06 17:22:54 +00:00
|
|
|
for (id = lb->first; id; id = id->next) {
|
2011-01-05 05:33:27 +00:00
|
|
|
id->flag |= LIB_DOIT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-05-06 17:22:54 +00:00
|
|
|
for (id = lb->first; id; id = id->next) {
|
2011-01-05 05:33:27 +00:00
|
|
|
id->flag &= ~LIB_DOIT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-30 13:25:27 +11:00
|
|
|
void BKE_main_id_tag_idcode(struct Main *mainvar, const short type, const bool tag)
|
2011-01-05 05:33:27 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
ListBase *lb = which_libbase(mainvar, type);
|
2011-01-05 05:33:27 +00:00
|
|
|
|
2013-12-30 13:25:27 +11:00
|
|
|
BKE_main_id_tag_listbase(lb, tag);
|
2011-01-05 05:33:27 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-30 13:25:27 +11:00
|
|
|
void BKE_main_id_tag_all(struct Main *mainvar, const bool tag)
|
2011-01-05 05:33:27 +00:00
|
|
|
{
|
|
|
|
|
ListBase *lbarray[MAX_LIBARRAY];
|
2009-08-07 03:51:28 +00:00
|
|
|
int a;
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
a = set_listbasepointers(mainvar, lbarray);
|
2012-03-24 06:18:31 +00:00
|
|
|
while (a--) {
|
2013-12-30 13:25:27 +11:00
|
|
|
BKE_main_id_tag_listbase(lbarray[a], tag);
|
2009-08-07 03:51:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
2006-03-05 17:35:06 +00:00
|
|
|
|
2011-10-28 04:44:59 +00:00
|
|
|
/* if lib!=NULL, only all from lib local
|
|
|
|
|
* bmain is almost certainly G.main */
|
2013-03-10 05:46:24 +00:00
|
|
|
void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2013-03-10 06:40:19 +00:00
|
|
|
ListBase *lbarray[MAX_LIBARRAY];
|
2002-10-12 11:37:38 +00:00
|
|
|
ID *id, *idn;
|
|
|
|
|
int a;
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
a = set_listbasepointers(bmain, lbarray);
|
2012-03-24 06:18:31 +00:00
|
|
|
while (a--) {
|
2012-05-06 17:22:54 +00:00
|
|
|
id = lbarray[a]->first;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
while (id) {
|
2012-05-06 17:22:54 +00:00
|
|
|
id->newid = NULL;
|
|
|
|
|
idn = id->next; /* id is possibly being inserted again */
|
2004-04-22 19:58:54 +00:00
|
|
|
|
2010-01-07 16:19:38 +00:00
|
|
|
/* The check on the second line (LIB_PRE_EXISTING) is done so its
|
2012-03-18 07:38:51 +00:00
|
|
|
* possible to tag data you don't want to be made local, used for
|
2010-07-20 19:39:07 +00:00
|
|
|
* appending data, so any libdata already linked wont become local
|
2007-04-07 17:35:47 +00:00
|
|
|
* (very nasty to discover all your links are lost after appending)
|
|
|
|
|
* */
|
2012-05-06 17:22:54 +00:00
|
|
|
if (id->flag & (LIB_EXTERN | LIB_INDIRECT | LIB_NEW) &&
|
2013-03-10 05:46:24 +00:00
|
|
|
((untagged_only == false) || !(id->flag & LIB_PRE_EXISTING)))
|
2007-04-07 17:35:47 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
if (lib == NULL || id->lib == lib) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (id->lib) {
|
2013-07-04 14:11:42 +00:00
|
|
|
/* for Make Local > All we should be calling id_make_local,
|
|
|
|
|
* but doing that breaks append (see #36003 and #36006), we
|
|
|
|
|
* we should make it work with all datablocks and id.us==0 */
|
|
|
|
|
id_clear_lib_data(bmain, id); /* sets 'id->flag' */
|
2011-10-28 04:44:59 +00:00
|
|
|
|
|
|
|
|
/* why sort alphabetically here but not in
|
|
|
|
|
* id_clear_lib_data() ? - campbell */
|
2012-04-06 16:19:30 +00:00
|
|
|
id_sort_by_name(lbarray[a], id);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2011-10-28 04:44:59 +00:00
|
|
|
else {
|
2012-05-06 17:22:54 +00:00
|
|
|
id->flag &= ~(LIB_EXTERN | LIB_INDIRECT | LIB_NEW);
|
2011-10-28 04:44:59 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-05-06 17:22:54 +00:00
|
|
|
id = idn;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2006-03-05 17:35:06 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
a = set_listbasepointers(bmain, lbarray);
|
2012-03-24 06:18:31 +00:00
|
|
|
while (a--) {
|
2012-05-06 17:22:54 +00:00
|
|
|
for (id = lbarray[a]->first; id; id = id->next)
|
2010-03-31 07:22:18 +00:00
|
|
|
lib_indirect_test_id(id, lib);
|
2006-03-05 17:35:06 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_idbutton(char *name)
|
|
|
|
|
{
|
2003-04-26 11:56:44 +00:00
|
|
|
/* called from buttons: when name already exists: call new_id */
|
2002-10-12 11:37:38 +00:00
|
|
|
ListBase *lb;
|
|
|
|
|
ID *idtest;
|
|
|
|
|
|
|
|
|
|
|
2013-03-10 06:40:19 +00:00
|
|
|
lb = which_libbase(G.main, GS(name) );
|
2012-05-06 17:22:54 +00:00
|
|
|
if (lb == NULL) return;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* search for id */
|
2013-03-10 06:40:19 +00:00
|
|
|
idtest = BLI_findstring(lb, name + 2, offsetof(ID, name) + 2);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-03-10 06:40:19 +00:00
|
|
|
if (idtest && !new_id(lb, idtest, name + 2)) {
|
2012-11-18 02:41:55 +00:00
|
|
|
id_sort_by_name(lb, idtest);
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
/**
|
|
|
|
|
* Sets the name of a block to name, suitably adjusted for uniqueness.
|
|
|
|
|
*/
|
2010-12-03 17:05:21 +00:00
|
|
|
void rename_id(ID *id, const char *name)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
ListBase *lb;
|
2010-03-06 18:21:57 +00:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
BLI_strncpy(id->name + 2, name, sizeof(id->name) - 2);
|
|
|
|
|
lb = which_libbase(G.main, GS(id->name) );
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
new_id(lb, id, name);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2010-07-31 01:06:08 +00:00
|
|
|
|
2013-03-10 05:46:24 +00:00
|
|
|
/**
|
|
|
|
|
* Returns in name the name of the block, with a 3-character prefix prepended
|
|
|
|
|
* indicating whether it comes from a library, has a fake user, or no users.
|
|
|
|
|
*/
|
|
|
|
|
void name_uiprefix_id(char *name, const ID *id)
|
2010-07-31 01:06:08 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
name[0] = id->lib ? 'L' : ' ';
|
|
|
|
|
name[1] = id->flag & LIB_FAKEUSER ? 'F' : (id->us == 0) ? '0' : ' ';
|
2010-07-31 01:06:08 +00:00
|
|
|
name[2] = ' ';
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
strcpy(name + 3, id->name + 2);
|
2010-07-31 01:06:08 +00:00
|
|
|
}
|
2011-10-23 17:52:20 +00:00
|
|
|
|
|
|
|
|
void BKE_library_filepath_set(Library *lib, const char *filepath)
|
|
|
|
|
{
|
2011-10-26 22:46:06 +00:00
|
|
|
/* in some cases this is used to update the absolute path from the
|
|
|
|
|
* relative */
|
|
|
|
|
if (lib->name != filepath) {
|
|
|
|
|
BLI_strncpy(lib->name, filepath, sizeof(lib->name));
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-23 17:52:20 +00:00
|
|
|
BLI_strncpy(lib->filepath, filepath, sizeof(lib->filepath));
|
|
|
|
|
|
|
|
|
|
/* not essential but set filepath is an absolute copy of value which
|
|
|
|
|
* is more useful if its kept in sync */
|
2012-08-29 10:32:38 +00:00
|
|
|
if (BLI_path_is_rel(lib->filepath)) {
|
2011-10-23 17:52:20 +00:00
|
|
|
/* note that the file may be unsaved, in this case, setting the
|
|
|
|
|
* filepath on an indirectly linked path is not allowed from the
|
|
|
|
|
* outliner, and its not really supported but allow from here for now
|
|
|
|
|
* since making local could cause this to be directly linked - campbell
|
|
|
|
|
*/
|
2012-05-06 17:22:54 +00:00
|
|
|
const char *basepath = lib->parent ? lib->parent->filepath : G.main->name;
|
2011-10-23 17:52:20 +00:00
|
|
|
BLI_path_abs(lib->filepath, basepath);
|
|
|
|
|
}
|
|
|
|
|
}
|