2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2002-10-12 11:37:38 +00:00
|
|
|
* $Id$
|
2005-12-12 16:29:47 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2005-12-12 16:29:47 +00:00
|
|
|
/*
|
|
|
|
* Contains management of ID's and libraries
|
|
|
|
* allocate and free of all library data
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
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"
|
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"
|
|
|
|
#include "DNA_material_types.h"
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_meta_types.h"
|
|
|
|
#include "DNA_nla_types.h"
|
|
|
|
#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"
|
|
|
|
#include "DNA_gpencil_types.h"
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_dynstr.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2009-01-30 14:23:31 +00:00
|
|
|
#include "BKE_animsys.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
2009-01-30 14:23:31 +00:00
|
|
|
#include "BKE_library.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_main.h"
|
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_sound.h"
|
|
|
|
#include "BKE_object.h"
|
|
|
|
#include "BKE_screen.h"
|
|
|
|
#include "BKE_mesh.h"
|
|
|
|
#include "BKE_material.h"
|
|
|
|
#include "BKE_curve.h"
|
|
|
|
#include "BKE_mball.h"
|
2003-12-14 01:18:09 +00:00
|
|
|
#include "BKE_text.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_texture.h"
|
|
|
|
#include "BKE_scene.h"
|
2005-12-21 22:21:43 +00:00
|
|
|
#include "BKE_icons.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_image.h"
|
|
|
|
#include "BKE_ipo.h"
|
|
|
|
#include "BKE_key.h"
|
|
|
|
#include "BKE_world.h"
|
|
|
|
#include "BKE_font.h"
|
|
|
|
#include "BKE_group.h"
|
|
|
|
#include "BKE_lattice.h"
|
|
|
|
#include "BKE_armature.h"
|
|
|
|
#include "BKE_action.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"
|
Brush Datablock:
- Added a new Brush datablock, only used by image paint, but intended
to be used in texture paint, vertex paint, weight paint and sculpt
mode also.
- Being a datablock, these brushes can be saved, appended and linked.
They have a fake user by default, to make sure they are saved even if
not selected.
Image Painting:
- Replaced the img module with C code in imagepaint.c
- Airbrush is no longer a separate tool, but rather an option that can
be used for soften, smear and clone also.
- Blend modes mix, add, subtract, multiply, darken and lighten have been
added, code taken directly from vertex paint.
Note to project files maintainers:
- The img module was removed from SCons and Makefiles, and this should
be done in other build systems also. I'll wait to remove the module
from cvs, to not break compilation.
2006-07-26 22:29:23 +00:00
|
|
|
#include "BKE_brush.h"
|
2006-11-17 04:46:48 +00:00
|
|
|
#include "BKE_idprop.h"
|
2007-12-24 18:38:03 +00:00
|
|
|
#include "BKE_particle.h"
|
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
|
|
|
#include "BKE_gpencil.h"
|
2010-01-30 05:08:42 +00:00
|
|
|
#include "BKE_fcurve.h"
|
2011-08-04 07:12:03 +00:00
|
|
|
#include "BKE_speaker.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
|
|
|
|
|
2005-12-12 16:29:47 +00:00
|
|
|
#define MAX_IDPUP 60 /* was 24 */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-09-04 21:02:43 +00:00
|
|
|
/* GS reads the memory pointed at in a specific ordering.
|
|
|
|
only use this definition, makes little and big endian systems
|
|
|
|
work fine, in conjunction with MAKE_ID */
|
|
|
|
|
|
|
|
/* from blendef: */
|
|
|
|
#define GS(a) (*((short *)(a)))
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* ************* general ************************ */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
void id_lib_extern(ID *id)
|
|
|
|
{
|
|
|
|
if(id) {
|
|
|
|
if(id->flag & LIB_INDIRECT) {
|
|
|
|
id->flag -= LIB_INDIRECT;
|
|
|
|
id->flag |= LIB_EXTERN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void id_us_plus(ID *id)
|
|
|
|
{
|
|
|
|
if(id) {
|
|
|
|
id->us++;
|
|
|
|
if(id->flag & LIB_INDIRECT) {
|
|
|
|
id->flag -= LIB_INDIRECT;
|
|
|
|
id->flag |= LIB_EXTERN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-27 00:03:49 +00:00
|
|
|
void id_us_min(ID *id)
|
|
|
|
{
|
2010-12-17 14:20:20 +00:00
|
|
|
if(id) {
|
|
|
|
if(id->us<2 && (id->flag & LIB_FAKEUSER))
|
|
|
|
id->us= 1;
|
|
|
|
else if(id->us<=0)
|
|
|
|
printf("ID user decrement error: %s \n", id->name);
|
|
|
|
else
|
|
|
|
id->us--;
|
|
|
|
}
|
2009-05-27 00:03:49 +00:00
|
|
|
}
|
|
|
|
|
2009-09-04 21:02:43 +00:00
|
|
|
int id_make_local(ID *id, int test)
|
|
|
|
{
|
|
|
|
if(id->flag & LIB_INDIRECT)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
switch(GS(id->name)) {
|
|
|
|
case ID_SCE:
|
|
|
|
return 0; /* not implemented */
|
|
|
|
case ID_LI:
|
|
|
|
return 0; /* can't be linked */
|
|
|
|
case ID_OB:
|
|
|
|
if(!test) make_local_object((Object*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_ME:
|
|
|
|
if(!test) {
|
|
|
|
make_local_mesh((Mesh*)id);
|
|
|
|
make_local_key(((Mesh*)id)->key);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
case ID_CU:
|
|
|
|
if(!test) {
|
|
|
|
make_local_curve((Curve*)id);
|
|
|
|
make_local_key(((Curve*)id)->key);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
case ID_MB:
|
|
|
|
if(!test) make_local_mball((MetaBall*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_MA:
|
|
|
|
if(!test) make_local_material((Material*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_TE:
|
|
|
|
if(!test) make_local_texture((Tex*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_IM:
|
|
|
|
return 0; /* not implemented */
|
|
|
|
case ID_LT:
|
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
|
|
|
if(!test) {
|
|
|
|
make_local_lattice((Lattice*)id);
|
|
|
|
make_local_key(((Lattice*)id)->key);
|
|
|
|
}
|
2009-09-04 21:02:43 +00:00
|
|
|
return 1;
|
|
|
|
case ID_LA:
|
|
|
|
if(!test) make_local_lamp((Lamp*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_CA:
|
|
|
|
if(!test) make_local_camera((Camera*)id);
|
|
|
|
return 1;
|
2011-08-01 11:44:20 +00:00
|
|
|
case ID_SPK:
|
|
|
|
if(!test) make_local_speaker((Speaker*)id);
|
|
|
|
return 1;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_IP:
|
|
|
|
return 0; /* deprecated */
|
|
|
|
case ID_KE:
|
|
|
|
if(!test) make_local_key((Key*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_WO:
|
|
|
|
if(!test) make_local_world((World*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_SCR:
|
|
|
|
return 0; /* can't be linked */
|
|
|
|
case ID_VF:
|
|
|
|
return 0; /* not implemented */
|
|
|
|
case ID_TXT:
|
|
|
|
return 0; /* not implemented */
|
|
|
|
case ID_SCRIPT:
|
|
|
|
return 0; /* deprecated */
|
|
|
|
case ID_SO:
|
|
|
|
return 0; /* not implemented */
|
|
|
|
case ID_GR:
|
|
|
|
return 0; /* not implemented */
|
|
|
|
case ID_AR:
|
|
|
|
if(!test) make_local_armature((bArmature*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_AC:
|
|
|
|
if(!test) make_local_action((bAction*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_NT:
|
|
|
|
return 0; /* not implemented */
|
|
|
|
case ID_BR:
|
|
|
|
if(!test) make_local_brush((Brush*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_PA:
|
|
|
|
if(!test) make_local_particlesettings((ParticleSettings*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_WM:
|
|
|
|
return 0; /* can't be linked */
|
|
|
|
case ID_GD:
|
|
|
|
return 0; /* not implemented */
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int id_copy(ID *id, ID **newid, int test)
|
|
|
|
{
|
|
|
|
if(!test) *newid= NULL;
|
|
|
|
|
|
|
|
/* conventions:
|
|
|
|
* - make shallow copy, only this ID block
|
|
|
|
* - id.us of the new ID is set to 1 */
|
|
|
|
switch(GS(id->name)) {
|
|
|
|
case ID_SCE:
|
|
|
|
return 0; /* can't be copied from here */
|
|
|
|
case ID_LI:
|
|
|
|
return 0; /* can't be copied from here */
|
|
|
|
case ID_OB:
|
|
|
|
if(!test) *newid= (ID*)copy_object((Object*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_ME:
|
|
|
|
if(!test) *newid= (ID*)copy_mesh((Mesh*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_CU:
|
|
|
|
if(!test) *newid= (ID*)copy_curve((Curve*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_MB:
|
|
|
|
if(!test) *newid= (ID*)copy_mball((MetaBall*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_MA:
|
|
|
|
if(!test) *newid= (ID*)copy_material((Material*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_TE:
|
|
|
|
if(!test) *newid= (ID*)copy_texture((Tex*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_IM:
|
2010-07-30 06:09:23 +00:00
|
|
|
if(!test) *newid= (ID*)copy_image((Image*)id);
|
|
|
|
return 1;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_LT:
|
|
|
|
if(!test) *newid= (ID*)copy_lattice((Lattice*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_LA:
|
|
|
|
if(!test) *newid= (ID*)copy_lamp((Lamp*)id);
|
|
|
|
return 1;
|
2011-08-01 11:44:20 +00:00
|
|
|
case ID_SPK:
|
|
|
|
if(!test) *newid= (ID*)copy_speaker((Speaker*)id);
|
|
|
|
return 1;
|
2009-09-04 21:02:43 +00:00
|
|
|
case ID_CA:
|
|
|
|
if(!test) *newid= (ID*)copy_camera((Camera*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_IP:
|
|
|
|
return 0; /* deprecated */
|
|
|
|
case ID_KE:
|
|
|
|
if(!test) *newid= (ID*)copy_key((Key*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_WO:
|
|
|
|
if(!test) *newid= (ID*)copy_world((World*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_SCR:
|
|
|
|
return 0; /* can't be copied from here */
|
|
|
|
case ID_VF:
|
|
|
|
return 0; /* not implemented */
|
|
|
|
case ID_TXT:
|
|
|
|
if(!test) *newid= (ID*)copy_text((Text*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_SCRIPT:
|
|
|
|
return 0; /* deprecated */
|
|
|
|
case ID_SO:
|
|
|
|
return 0; /* not implemented */
|
|
|
|
case ID_GR:
|
|
|
|
if(!test) *newid= (ID*)copy_group((Group*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_AR:
|
|
|
|
if(!test) *newid= (ID*)copy_armature((bArmature*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_AC:
|
|
|
|
if(!test) *newid= (ID*)copy_action((bAction*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_NT:
|
2011-02-11 09:37:58 +00:00
|
|
|
if(!test) *newid= (ID*)ntreeCopyTree((bNodeTree*)id);
|
2009-09-04 21:02:43 +00:00
|
|
|
return 1;
|
|
|
|
case ID_BR:
|
|
|
|
if(!test) *newid= (ID*)copy_brush((Brush*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_PA:
|
|
|
|
if(!test) *newid= (ID*)psys_copy_settings((ParticleSettings*)id);
|
|
|
|
return 1;
|
|
|
|
case ID_WM:
|
|
|
|
return 0; /* can't be copied from here */
|
|
|
|
case ID_GD:
|
|
|
|
return 0; /* not implemented */
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int id_unlink(ID *id, int test)
|
|
|
|
{
|
|
|
|
Main *mainlib= G.main;
|
|
|
|
ListBase *lb;
|
|
|
|
|
|
|
|
switch(GS(id->name)) {
|
|
|
|
case ID_TXT:
|
|
|
|
if(test) return 1;
|
|
|
|
unlink_text(mainlib, (Text*)id);
|
|
|
|
break;
|
|
|
|
case ID_GR:
|
|
|
|
if(test) return 1;
|
|
|
|
unlink_group((Group*)id);
|
|
|
|
break;
|
|
|
|
case ID_OB:
|
|
|
|
if(test) return 1;
|
2010-10-16 14:32:17 +00:00
|
|
|
unlink_object((Object*)id);
|
2009-09-04 21:02:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(id->us == 0) {
|
|
|
|
if(test) return 1;
|
|
|
|
|
* 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
|
|
|
lb= which_libbase(mainlib, GS(id->name));
|
2009-09-04 21:02:43 +00:00
|
|
|
free_libblock(lb, id);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-06-29 04:34:20 +00:00
|
|
|
int id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
|
|
|
|
{
|
|
|
|
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)) {
|
|
|
|
if (id_copy(id, &newid, 0) && newid) {
|
|
|
|
/* copy animation actions too */
|
|
|
|
BKE_copy_animdata_id_action(id);
|
|
|
|
/* us is 1 by convention, but RNA_property_pointer_set
|
|
|
|
will also incremement it, so set it to zero */
|
|
|
|
newid->us= 0;
|
|
|
|
|
|
|
|
/* assign copy */
|
|
|
|
RNA_id_pointer_create(newid, &idptr);
|
|
|
|
RNA_property_pointer_set(ptr, prop, idptr);
|
|
|
|
RNA_property_update(C, ptr, prop);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
* 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
|
|
|
{
|
|
|
|
switch( type ) {
|
|
|
|
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);
|
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 */
|
|
|
|
void flag_listbase_ids(ListBase *lb, short flag, short value)
|
|
|
|
{
|
|
|
|
ID *id;
|
|
|
|
if (value) {
|
|
|
|
for(id= lb->first; id; id= id->next) id->flag |= flag;
|
|
|
|
} else {
|
|
|
|
flag = ~flag;
|
|
|
|
for(id= lb->first; id; id= id->next) id->flag &= flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Flag all ids in listbase */
|
|
|
|
void flag_all_listbases_ids(short flag, short value)
|
|
|
|
{
|
|
|
|
ListBase *lbarray[MAX_LIBARRAY];
|
|
|
|
int a;
|
|
|
|
a= set_listbasepointers(G.main, lbarray);
|
|
|
|
while(a--) flag_listbase_ids(lbarray[a], flag, value);
|
|
|
|
}
|
|
|
|
|
2009-09-14 12:30:49 +00:00
|
|
|
void recalc_all_library_objects(Main *main)
|
2009-09-12 19:54:39 +00:00
|
|
|
{
|
2009-09-14 12:30:49 +00:00
|
|
|
Object *ob;
|
|
|
|
|
|
|
|
/* flag for full recalc */
|
|
|
|
for(ob=main->object.first; ob; ob=ob->id.next)
|
|
|
|
if(ob->id.lib)
|
2010-12-17 15:51:42 +00:00
|
|
|
ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
|
2009-09-12 19:54:39 +00:00
|
|
|
}
|
2007-04-20 18:48:30 +00:00
|
|
|
|
2006-09-06 09:51:30 +00:00
|
|
|
/* 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. */
|
2008-07-08 17:04:58 +00:00
|
|
|
lb[a++]= &(main->ipo);
|
2009-01-22 10:53:22 +00:00
|
|
|
lb[a++]= &(main->action); // xxx moved here to avoid problems when freeing with animato (aligorith)
|
2008-07-08 17:04:58 +00:00
|
|
|
lb[a++]= &(main->key);
|
2010-10-29 07:11:45 +00:00
|
|
|
lb[a++]= &(main->gpencil); /* referenced by nodes, objects, view, scene etc, before to free after. */
|
2008-07-08 17:04:58 +00:00
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
2008-07-08 17:04:58 +00:00
|
|
|
lb[a++]= &(main->armature);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-07-08 17:04:58 +00:00
|
|
|
lb[a++]= &(main->mesh);
|
|
|
|
lb[a++]= &(main->curve);
|
|
|
|
lb[a++]= &(main->mball);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-07-08 17:04:58 +00:00
|
|
|
lb[a++]= &(main->latt);
|
|
|
|
lb[a++]= &(main->lamp);
|
|
|
|
lb[a++]= &(main->camera);
|
2011-08-01 11:44:20 +00:00
|
|
|
lb[a++]= &(main->speaker);
|
|
|
|
|
2008-07-08 17:04:58 +00:00
|
|
|
lb[a++]= &(main->text);
|
|
|
|
lb[a++]= &(main->sound);
|
|
|
|
lb[a++]= &(main->group);
|
|
|
|
lb[a++]= &(main->brush);
|
|
|
|
lb[a++]= &(main->script);
|
|
|
|
lb[a++]= &(main->particle);
|
2010-10-29 07:11:45 +00:00
|
|
|
|
2008-07-08 17:04:58 +00:00
|
|
|
lb[a++]= &(main->world);
|
|
|
|
lb[a++]= &(main->screen);
|
|
|
|
lb[a++]= &(main->object);
|
|
|
|
lb[a++]= &(main->scene);
|
|
|
|
lb[a++]= &(main->library);
|
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
later added in trunk also, but reverted partially, specifically revision
16683. I have left out this reversion in the 2.5 branch since I think it is
needed there.
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
-W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
differently. Since this is changed so much, and I don't think those fixes
would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
initialized when running with -P. The code that initializes the screen there
I had to disable, that can't work in 2.5 anymore but left it commented as a
reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
still use changes that were done in trunk.
2008-11-12 21:16:53 +00:00
|
|
|
lb[a++]= &(main->wm);
|
2007-01-18 15:23:28 +00:00
|
|
|
|
2008-07-08 17:04:58 +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 *****************
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
free_libblock(ListBase *lb, ID *id )
|
2003-04-26 11:56:44 +00:00
|
|
|
provide a list-basis and datablock, but only ID is read
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
void *alloc_libblock(ListBase *lb, type, name)
|
2003-04-26 11:56:44 +00:00
|
|
|
inserts in list and returns a new ID
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
***************************** */
|
|
|
|
|
|
|
|
static ID *alloc_libblock_notest(short type)
|
|
|
|
{
|
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
|
|
|
ID *id= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
switch( type ) {
|
|
|
|
case ID_SCE:
|
|
|
|
id= MEM_callocN(sizeof(Scene), "scene");
|
|
|
|
break;
|
|
|
|
case ID_LI:
|
|
|
|
id= MEM_callocN(sizeof(Library), "library");
|
|
|
|
break;
|
|
|
|
case ID_OB:
|
|
|
|
id= MEM_callocN(sizeof(Object), "object");
|
|
|
|
break;
|
|
|
|
case ID_ME:
|
|
|
|
id= MEM_callocN(sizeof(Mesh), "mesh");
|
|
|
|
break;
|
|
|
|
case ID_CU:
|
|
|
|
id= MEM_callocN(sizeof(Curve), "curve");
|
|
|
|
break;
|
|
|
|
case ID_MB:
|
|
|
|
id= MEM_callocN(sizeof(MetaBall), "mball");
|
|
|
|
break;
|
|
|
|
case ID_MA:
|
|
|
|
id= MEM_callocN(sizeof(Material), "mat");
|
|
|
|
break;
|
|
|
|
case ID_TE:
|
|
|
|
id= MEM_callocN(sizeof(Tex), "tex");
|
|
|
|
break;
|
|
|
|
case ID_IM:
|
|
|
|
id= MEM_callocN(sizeof(Image), "image");
|
|
|
|
break;
|
|
|
|
case ID_LT:
|
|
|
|
id= MEM_callocN(sizeof(Lattice), "latt");
|
|
|
|
break;
|
|
|
|
case ID_LA:
|
|
|
|
id= MEM_callocN(sizeof(Lamp), "lamp");
|
|
|
|
break;
|
|
|
|
case ID_CA:
|
|
|
|
id= MEM_callocN(sizeof(Camera), "camera");
|
|
|
|
break;
|
|
|
|
case ID_IP:
|
|
|
|
id= MEM_callocN(sizeof(Ipo), "ipo");
|
|
|
|
break;
|
|
|
|
case ID_KE:
|
|
|
|
id= MEM_callocN(sizeof(Key), "key");
|
|
|
|
break;
|
|
|
|
case ID_WO:
|
|
|
|
id= MEM_callocN(sizeof(World), "world");
|
|
|
|
break;
|
|
|
|
case ID_SCR:
|
|
|
|
id= MEM_callocN(sizeof(bScreen), "screen");
|
|
|
|
break;
|
|
|
|
case ID_VF:
|
|
|
|
id= MEM_callocN(sizeof(VFont), "vfont");
|
|
|
|
break;
|
|
|
|
case ID_TXT:
|
|
|
|
id= MEM_callocN(sizeof(Text), "text");
|
|
|
|
break;
|
2003-12-14 01:18:09 +00:00
|
|
|
case ID_SCRIPT:
|
2008-01-01 19:20:49 +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:
|
|
|
|
id= MEM_callocN(sizeof(Speaker), "speaker");
|
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
case ID_SO:
|
|
|
|
id= MEM_callocN(sizeof(bSound), "sound");
|
|
|
|
break;
|
|
|
|
case ID_GR:
|
2006-11-25 13:07:28 +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");
|
2010-03-22 09:30:00 +00:00
|
|
|
break;
|
2007-12-24 18:38:03 +00:00
|
|
|
case ID_WM:
|
|
|
|
id = MEM_callocN(sizeof(wmWindowManager), "Window manager");
|
2010-03-22 09:30:00 +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;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2007-04-06 10:08:48 +00:00
|
|
|
/* used everywhere in blenkernel and text.c */
|
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
|
|
|
void *alloc_libblock(ListBase *lb, short type, const char *name)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
Orange: more noodle updates!
**** NEW: Group Nodes
Node trees usually become messy and confusing quickly, so we need
not only a way to collapse Nodes into single 'groups', but also a
way to re-use that data to create libraries of effects.
This has been done by making a new Library data type, the NodeTree.
Everything that has been grouped is stored here, and available for
re-use, appending or linking. These NodeTrees are fully generic,
i.e. can store shader trees, composit trees, and so on. The 'type'
value as stored in the NodeTree will keep track of internal type
definitions and execute/drawing callbacks. Needless to say, re-using
shader trees in a composit tree is a bit useless, and will be
prevented in the browsing code. :)
So; any NodeTree can become a "Goup Node" inside in a NodeTree. This
Group Node then works just like any Node.
To prevent the current code to become too complex, I've disabled
the possibility to insert Groups inside of Groups. That might be
enabled later, but is a real nasty piece of code to get OK.
Since Group Nodes are a dynamic Node type, a lot of work has been
done to ensure Node definitions can be dynamic too, but still allow
to be stored in files, and allow to be verified for type-definition
changes on reloading. This system needs a little bit maturing still,
so the Python gurus should better wait a little bit! (Also for me to
write the definite API docs for it).
What works now:
- Press CTRL+G to create a new Group. The grouping code checks for
impossible selections (like an unselected node between selected nodes).
Everthing that's selected then gets removed from the current tree, and
inserted in a new NodeTree library data block. A Group Node then is
added which links to this new NodeTree.
- Press ALT+G to ungroup. This will not delete the NodeTree library
data, but just duplicate the Group into the current tree.
- Press TAB, or click on the NodeTree icon to edit Groups. Note that
NodeTrees are instances, so editing one Group will also change the
other users.
This also means that when removing nodes in a Group (or hiding sockets
or changing internal links) this is immediately corrected for all users
of this Group, also in other Materials.
- While editing Groups, only the internal Nodes can be edited. A single
click outside of the Group boundary will close this 'edit mode'.
What needs to be done:
- SHIFT+A menu in toolbox style, also including a list of Groups
- Enable the single-user button in the Group Node
- Displaying all (visible) internal group UI elements in the Node Panel
- Enable Library linking and prevent editing of Groups then.
**** NEW: Socket Visibility control
Node types will be generated with a lot of possible inputs or outputs,
and drawing all sockets all the time isn't very useful then.
A new option in the Node header ('plus' icon) allows to either hide all
unused sockets (first keypress) or to reveil them (when there are hidden
sockets, the icon displays black, otherwise it's blended).
Hidden sockets in Nodes also are not exported to a Group, so this way
you can control what options (in/outputs) exactly are available.
To be done:
- a way to hide individual sockets, like with a RMB click on it.
**** NEW: Nodes now render!
This is still quite primitive, more on a level to replace the (now
obsolete and disabled) Material Layers.
What needs to be done:
- make the "Geometry" node work properly, also for AA textures
- make the Texture Node work (does very little at the moment)
- give Material Nodes all inputs as needed (like Map-to Panel)
- find a way to export more data from a Material Node, like the
shadow value, or light intensity only, etc
Very important also to separate from the Material Buttons the
"global" options, like "Ztransp" or "Wire" or "Halo". These can not
be set for each Material-Node individually.
Also note that the Preview Render (Buttons window) now renders a bit
differently. This was a horrid piece of antique code, using a totally
incompatible way of rendering. Target is to fully re-use internal
render code for previews.
OK... that's it mostly. Now test!
2006-01-02 13:06:05 +00:00
|
|
|
ID *id= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
id= alloc_libblock_notest(type);
|
|
|
|
if(id) {
|
|
|
|
BLI_addtail(lb, id);
|
|
|
|
id->us= 1;
|
2005-12-21 22:21:43 +00:00
|
|
|
id->icon_id = 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
*( (short *)id->name )= type;
|
|
|
|
new_id(lb, id, name);
|
2003-04-26 11:56:44 +00:00
|
|
|
/* alphabetic insterion: is in new_id */
|
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 */
|
2010-11-09 09:53:17 +00:00
|
|
|
static void id_copy_animdata(ID *id, const short do_action)
|
2009-01-30 14:23:31 +00:00
|
|
|
{
|
2009-09-30 04:59:14 +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;
|
2010-11-09 09:53:17 +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 */
|
2010-11-09 09:53:17 +00:00
|
|
|
void copy_libblock_data(ID *id, const ID *id_from, const short 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 */
|
2002-10-12 11:37:38 +00:00
|
|
|
void *copy_libblock(void *rt)
|
|
|
|
{
|
|
|
|
ID *idn, *id;
|
|
|
|
ListBase *lb;
|
|
|
|
char *cp, *cpn;
|
2010-04-29 21:46:25 +00:00
|
|
|
size_t idn_len;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
id= rt;
|
|
|
|
|
* 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
|
|
|
lb= which_libbase(G.main, GS(id->name));
|
2002-10-12 11:37:38 +00:00
|
|
|
idn= alloc_libblock(lb, GS(id->name), id->name+2);
|
2010-10-07 10:04:07 +00:00
|
|
|
|
|
|
|
assert(idn != NULL);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
idn_len= MEM_allocN_len(idn);
|
|
|
|
if(idn_len - sizeof(ID) > 0) {
|
|
|
|
cp= (char *)id;
|
|
|
|
cpn= (char *)idn;
|
|
|
|
memcpy(cpn+sizeof(ID), cp+sizeof(ID), idn_len - sizeof(ID));
|
|
|
|
}
|
|
|
|
|
|
|
|
id->newid= idn;
|
|
|
|
idn->flag |= LIB_NEW;
|
2010-02-15 08:50:04 +00:00
|
|
|
|
2010-11-09 09:53:17 +00:00
|
|
|
copy_libblock_data(idn, id, FALSE);
|
2009-01-30 14:23:31 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return idn;
|
|
|
|
}
|
|
|
|
|
2010-10-15 05:18:45 +00:00
|
|
|
static void free_library(Library *UNUSED(lib))
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2010-03-22 09:30:00 +00:00
|
|
|
/* no freeing needed for libraries yet */
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2007-12-24 18:38:03 +00:00
|
|
|
static void (*free_windowmanager_cb)(bContext *, wmWindowManager *)= NULL;
|
|
|
|
|
|
|
|
void set_free_windowmanager_cb(void (*func)(bContext *C, wmWindowManager *) )
|
|
|
|
{
|
|
|
|
free_windowmanager_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 */
|
|
|
|
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;
|
|
|
|
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)
|
2010-01-29 21:16:21 +00:00
|
|
|
dtar->id= NULL;
|
|
|
|
}
|
2010-01-30 05:08:42 +00:00
|
|
|
DRIVER_TARGETS_LOOPER_END
|
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 */
|
2002-10-12 11:37:38 +00:00
|
|
|
void free_libblock(ListBase *lb, void *idv)
|
|
|
|
{
|
|
|
|
ID *id= idv;
|
2011-03-01 09:02:54 +00:00
|
|
|
|
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
BPY_id_release(id);
|
|
|
|
#endif
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
switch( GS(id->name) ) { /* GetShort from util.h */
|
2002-10-12 11:37:38 +00:00
|
|
|
case ID_SCE:
|
|
|
|
free_scene((Scene *)id);
|
|
|
|
break;
|
|
|
|
case ID_LI:
|
|
|
|
free_library((Library *)id);
|
|
|
|
break;
|
|
|
|
case ID_OB:
|
|
|
|
free_object((Object *)id);
|
|
|
|
break;
|
|
|
|
case ID_ME:
|
|
|
|
free_mesh((Mesh *)id);
|
|
|
|
break;
|
|
|
|
case ID_CU:
|
|
|
|
free_curve((Curve *)id);
|
|
|
|
break;
|
|
|
|
case ID_MB:
|
|
|
|
free_mball((MetaBall *)id);
|
|
|
|
break;
|
|
|
|
case ID_MA:
|
|
|
|
free_material((Material *)id);
|
|
|
|
break;
|
|
|
|
case ID_TE:
|
|
|
|
free_texture((Tex *)id);
|
|
|
|
break;
|
|
|
|
case ID_IM:
|
|
|
|
free_image((Image *)id);
|
|
|
|
break;
|
|
|
|
case ID_LT:
|
|
|
|
free_lattice((Lattice *)id);
|
|
|
|
break;
|
|
|
|
case ID_LA:
|
|
|
|
free_lamp((Lamp *)id);
|
|
|
|
break;
|
|
|
|
case ID_CA:
|
|
|
|
free_camera((Camera*) id);
|
|
|
|
break;
|
|
|
|
case ID_IP:
|
2009-01-22 10:53:22 +00:00
|
|
|
free_ipo((Ipo *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
case ID_KE:
|
|
|
|
free_key((Key *)id);
|
|
|
|
break;
|
|
|
|
case ID_WO:
|
|
|
|
free_world((World *)id);
|
|
|
|
break;
|
|
|
|
case ID_SCR:
|
|
|
|
free_screen((bScreen *)id);
|
|
|
|
break;
|
|
|
|
case ID_VF:
|
|
|
|
free_vfont((VFont *)id);
|
|
|
|
break;
|
|
|
|
case ID_TXT:
|
|
|
|
free_text((Text *)id);
|
|
|
|
break;
|
2003-12-14 01:18:09 +00:00
|
|
|
case ID_SCRIPT:
|
2008-01-01 19:20:49 +00:00
|
|
|
//XXX free_script((Script *)id);
|
2003-12-14 01:18:09 +00:00
|
|
|
break;
|
2011-08-01 11:44:20 +00:00
|
|
|
case ID_SPK:
|
|
|
|
free_speaker((Speaker *)id);
|
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
case ID_SO:
|
2009-08-09 21:16:39 +00:00
|
|
|
sound_free((bSound*)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
case ID_GR:
|
2010-01-12 13:42:13 +00:00
|
|
|
free_group_objects((Group *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
break;
|
|
|
|
case ID_AR:
|
|
|
|
free_armature((bArmature *)id);
|
|
|
|
break;
|
|
|
|
case ID_AC:
|
2009-01-18 10:41:45 +00:00
|
|
|
free_action((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:
|
|
|
|
ntreeFreeTree((bNodeTree *)id);
|
|
|
|
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:
|
|
|
|
free_brush((Brush *)id);
|
|
|
|
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:
|
|
|
|
psys_free_settings((ParticleSettings *)id);
|
|
|
|
break;
|
2007-12-24 18:38:03 +00:00
|
|
|
case ID_WM:
|
|
|
|
if(free_windowmanager_cb)
|
|
|
|
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:
|
|
|
|
free_gpencil_data((bGPdata *)id);
|
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2006-11-17 04:46:48 +00:00
|
|
|
if (id->properties) {
|
|
|
|
IDP_FreeProperty(id->properties);
|
|
|
|
MEM_freeN(id->properties);
|
|
|
|
}
|
2010-01-29 21:16:21 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_remlink(lb, id);
|
|
|
|
|
2010-01-29 21:16:21 +00:00
|
|
|
/* this ID may be a driver target! */
|
|
|
|
BKE_animdata_main_cb(G.main, animdata_dtar_clear_cb, (void *)id);
|
|
|
|
|
|
|
|
MEM_freeN(id);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void free_libblock_us(ListBase *lb, void *idv) /* test users */
|
|
|
|
{
|
|
|
|
ID *id= idv;
|
|
|
|
|
|
|
|
id->us--;
|
|
|
|
|
|
|
|
if(id->us<0) {
|
|
|
|
if(id->lib) printf("ERROR block %s %s users %d\n", id->lib->name, id->name, id->us);
|
|
|
|
else printf("ERROR block %s users %d\n", id->name, id->us);
|
|
|
|
}
|
|
|
|
if(id->us==0) {
|
2010-10-16 14:32:17 +00:00
|
|
|
if( GS(id->name)==ID_OB ) unlink_object((Object *)id);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
free_libblock(lb, id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void free_main(Main *mainvar)
|
|
|
|
{
|
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;
|
|
|
|
|
|
|
|
a= set_listbasepointers(mainvar, lbarray);
|
|
|
|
while(a--) {
|
|
|
|
ListBase *lb= lbarray[a];
|
|
|
|
ID *id;
|
|
|
|
|
Phew, a lot of work, and no new features...
Main target was to make the inner rendering loop using no globals anymore.
This is essential for proper usage while raytracing, it caused a lot of
hacks in the raycode as well, which even didn't work correctly for all
situations (textures especially).
Done this by creating a new local struct RenderInput, which replaces usage
of the global struct Render R. The latter now only is used to denote
image size, viewmatrix, and the like.
Making the inner render loops using no globals caused 1000s of vars to
be changed... but the result definitely is much nicer code, which enables
making 'real' shaders in a next stage.
It also enabled me to remove the hacks from ray.c
Then i went to the task of removing redundant code. Especially the calculus
of texture coords took place (identical) in three locations.
Most obvious is the change in the unified render part, which is much less
code now; it uses the same rendering routines as normal render now.
(Note; not for halos yet!)
I also removed 6 files called 'shadowbuffer' something. This was experimen-
tal stuff from NaN days. And again saved a lot of double used code.
Finally I went over the blenkernel and blender/src calls to render stuff.
Here the same local data is used now, resulting in less dependency.
I also moved render-texture to the render module, this was still in Kernel.
(new file: texture.c)
So! After this commit I will check on the autofiles, to try to fix that.
MSVC people have to do it themselves.
This commit will need quite some testing help, but I'm around!
2003-12-21 21:52:51 +00:00
|
|
|
while ( (id= lb->first) ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
free_libblock(lb, id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MEM_freeN(mainvar);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ***************** ID ************************ */
|
|
|
|
|
2006-07-07 17:08:04 +00:00
|
|
|
|
2010-12-03 17:05:21 +00:00
|
|
|
ID *find_id(const char *type, const char *name) /* type: "OB" or "MA" etc */
|
2002-10-12 11:37:38 +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 *lb= which_libbase(G.main, GS(type));
|
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
|
|
|
}
|
|
|
|
|
More node goodies!
First note; this is a WIP project, some commits might change things that
make formerly saved situations not to work identically... like now!
------ New Material integration ------
Until now, the Node system worked on top of the 'current' Material, just
like how the Material Layers worked. That's quite confusing in practice,
especially to see what Material is a Node, or what is the "base material"
Best solution is to completely separate the two. This has been implemented
as follows now;
- The confusing "Input" node has been removed.
- When choosing a Material in Blender, you can define this Material to be
either 'normal' (default) or be the root of a Node tree.
- If a Material is a Node tree, you have to add Nodes in the tree to see
something happen. An empty Node tree doesn't do anything (black).
- If a Material is a Node Tree, the 'data browse' menus show it with an
'N' mark before the name. The 'data block' buttons display it with the
suffix 'NT' (instead of 'MA').
- In a Node Tree, any Material can be inserted, including itself. Only in
that case the Material is being used itself for shading.
UI changes:
Added a new Panel "Links", which shows:
- where the Material is linked to (Object, Mesh, etc)
- if the Material is a NodeTree or not
- the actual active Material in the Tree
The "Node" Panel itself now only shows buttons from the other nodes, when
they are active.
Further the Material Nodes themselves allow browsing and renaming or adding
new Materials now too.
Second half of today's work was cleaning up selection when the Nodes
overlap... it was possible to drag links from invisible sockets, or click
headers for invisible nodes, etc. This because the mouse input code was
not checking for visibility yet.
Works now even for buttons. :)
2005-12-29 18:08:01 +00:00
|
|
|
static void get_flags_for_id(ID *id, char *buf)
|
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
int isfake= id->flag & LIB_FAKEUSER;
|
More node goodies!
First note; this is a WIP project, some commits might change things that
make formerly saved situations not to work identically... like now!
------ New Material integration ------
Until now, the Node system worked on top of the 'current' Material, just
like how the Material Layers worked. That's quite confusing in practice,
especially to see what Material is a Node, or what is the "base material"
Best solution is to completely separate the two. This has been implemented
as follows now;
- The confusing "Input" node has been removed.
- When choosing a Material in Blender, you can define this Material to be
either 'normal' (default) or be the root of a Node tree.
- If a Material is a Node tree, you have to add Nodes in the tree to see
something happen. An empty Node tree doesn't do anything (black).
- If a Material is a Node Tree, the 'data browse' menus show it with an
'N' mark before the name. The 'data block' buttons display it with the
suffix 'NT' (instead of 'MA').
- In a Node Tree, any Material can be inserted, including itself. Only in
that case the Material is being used itself for shading.
UI changes:
Added a new Panel "Links", which shows:
- where the Material is linked to (Object, Mesh, etc)
- if the Material is a NodeTree or not
- the actual active Material in the Tree
The "Node" Panel itself now only shows buttons from the other nodes, when
they are active.
Further the Material Nodes themselves allow browsing and renaming or adding
new Materials now too.
Second half of today's work was cleaning up selection when the Nodes
overlap... it was possible to drag links from invisible sockets, or click
headers for invisible nodes, etc. This because the mouse input code was
not checking for visibility yet.
Works now even for buttons. :)
2005-12-29 18:08:01 +00:00
|
|
|
int isnode=0;
|
2002-10-12 11:37:38 +00:00
|
|
|
/* Writeout the flags for the entry, note there
|
|
|
|
* is a small hack that writes 5 spaces instead
|
|
|
|
* of 4 if no flags are displayed... this makes
|
|
|
|
* things usually line up ok - better would be
|
|
|
|
* to have that explicit, oh well - zr
|
|
|
|
*/
|
|
|
|
|
More node goodies!
First note; this is a WIP project, some commits might change things that
make formerly saved situations not to work identically... like now!
------ New Material integration ------
Until now, the Node system worked on top of the 'current' Material, just
like how the Material Layers worked. That's quite confusing in practice,
especially to see what Material is a Node, or what is the "base material"
Best solution is to completely separate the two. This has been implemented
as follows now;
- The confusing "Input" node has been removed.
- When choosing a Material in Blender, you can define this Material to be
either 'normal' (default) or be the root of a Node tree.
- If a Material is a Node tree, you have to add Nodes in the tree to see
something happen. An empty Node tree doesn't do anything (black).
- If a Material is a Node Tree, the 'data browse' menus show it with an
'N' mark before the name. The 'data block' buttons display it with the
suffix 'NT' (instead of 'MA').
- In a Node Tree, any Material can be inserted, including itself. Only in
that case the Material is being used itself for shading.
UI changes:
Added a new Panel "Links", which shows:
- where the Material is linked to (Object, Mesh, etc)
- if the Material is a NodeTree or not
- the actual active Material in the Tree
The "Node" Panel itself now only shows buttons from the other nodes, when
they are active.
Further the Material Nodes themselves allow browsing and renaming or adding
new Materials now too.
Second half of today's work was cleaning up selection when the Nodes
overlap... it was possible to drag links from invisible sockets, or click
headers for invisible nodes, etc. This because the mouse input code was
not checking for visibility yet.
Works now even for buttons. :)
2005-12-29 18:08:01 +00:00
|
|
|
if(GS(id->name)==ID_MA)
|
|
|
|
isnode= ((Material *)id)->use_nodes;
|
2008-11-12 22:03:11 +00:00
|
|
|
if(GS(id->name)==ID_TE)
|
|
|
|
isnode= ((Tex *)id)->use_nodes;
|
More node goodies!
First note; this is a WIP project, some commits might change things that
make formerly saved situations not to work identically... like now!
------ New Material integration ------
Until now, the Node system worked on top of the 'current' Material, just
like how the Material Layers worked. That's quite confusing in practice,
especially to see what Material is a Node, or what is the "base material"
Best solution is to completely separate the two. This has been implemented
as follows now;
- The confusing "Input" node has been removed.
- When choosing a Material in Blender, you can define this Material to be
either 'normal' (default) or be the root of a Node tree.
- If a Material is a Node tree, you have to add Nodes in the tree to see
something happen. An empty Node tree doesn't do anything (black).
- If a Material is a Node Tree, the 'data browse' menus show it with an
'N' mark before the name. The 'data block' buttons display it with the
suffix 'NT' (instead of 'MA').
- In a Node Tree, any Material can be inserted, including itself. Only in
that case the Material is being used itself for shading.
UI changes:
Added a new Panel "Links", which shows:
- where the Material is linked to (Object, Mesh, etc)
- if the Material is a NodeTree or not
- the actual active Material in the Tree
The "Node" Panel itself now only shows buttons from the other nodes, when
they are active.
Further the Material Nodes themselves allow browsing and renaming or adding
new Materials now too.
Second half of today's work was cleaning up selection when the Nodes
overlap... it was possible to drag links from invisible sockets, or click
headers for invisible nodes, etc. This because the mouse input code was
not checking for visibility yet.
Works now even for buttons. :)
2005-12-29 18:08:01 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if (id->us<0)
|
|
|
|
sprintf(buf, "-1W ");
|
More node goodies!
First note; this is a WIP project, some commits might change things that
make formerly saved situations not to work identically... like now!
------ New Material integration ------
Until now, the Node system worked on top of the 'current' Material, just
like how the Material Layers worked. That's quite confusing in practice,
especially to see what Material is a Node, or what is the "base material"
Best solution is to completely separate the two. This has been implemented
as follows now;
- The confusing "Input" node has been removed.
- When choosing a Material in Blender, you can define this Material to be
either 'normal' (default) or be the root of a Node tree.
- If a Material is a Node tree, you have to add Nodes in the tree to see
something happen. An empty Node tree doesn't do anything (black).
- If a Material is a Node Tree, the 'data browse' menus show it with an
'N' mark before the name. The 'data block' buttons display it with the
suffix 'NT' (instead of 'MA').
- In a Node Tree, any Material can be inserted, including itself. Only in
that case the Material is being used itself for shading.
UI changes:
Added a new Panel "Links", which shows:
- where the Material is linked to (Object, Mesh, etc)
- if the Material is a NodeTree or not
- the actual active Material in the Tree
The "Node" Panel itself now only shows buttons from the other nodes, when
they are active.
Further the Material Nodes themselves allow browsing and renaming or adding
new Materials now too.
Second half of today's work was cleaning up selection when the Nodes
overlap... it was possible to drag links from invisible sockets, or click
headers for invisible nodes, etc. This because the mouse input code was
not checking for visibility yet.
Works now even for buttons. :)
2005-12-29 18:08:01 +00:00
|
|
|
else if (!id->lib && !isfake && id->us && !isnode)
|
2002-10-12 11:37:38 +00:00
|
|
|
sprintf(buf, " ");
|
More node goodies!
First note; this is a WIP project, some commits might change things that
make formerly saved situations not to work identically... like now!
------ New Material integration ------
Until now, the Node system worked on top of the 'current' Material, just
like how the Material Layers worked. That's quite confusing in practice,
especially to see what Material is a Node, or what is the "base material"
Best solution is to completely separate the two. This has been implemented
as follows now;
- The confusing "Input" node has been removed.
- When choosing a Material in Blender, you can define this Material to be
either 'normal' (default) or be the root of a Node tree.
- If a Material is a Node tree, you have to add Nodes in the tree to see
something happen. An empty Node tree doesn't do anything (black).
- If a Material is a Node Tree, the 'data browse' menus show it with an
'N' mark before the name. The 'data block' buttons display it with the
suffix 'NT' (instead of 'MA').
- In a Node Tree, any Material can be inserted, including itself. Only in
that case the Material is being used itself for shading.
UI changes:
Added a new Panel "Links", which shows:
- where the Material is linked to (Object, Mesh, etc)
- if the Material is a NodeTree or not
- the actual active Material in the Tree
The "Node" Panel itself now only shows buttons from the other nodes, when
they are active.
Further the Material Nodes themselves allow browsing and renaming or adding
new Materials now too.
Second half of today's work was cleaning up selection when the Nodes
overlap... it was possible to drag links from invisible sockets, or click
headers for invisible nodes, etc. This because the mouse input code was
not checking for visibility yet.
Works now even for buttons. :)
2005-12-29 18:08:01 +00:00
|
|
|
else if(isnode)
|
|
|
|
sprintf(buf, "%c%cN%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' ');
|
2002-10-12 11:37:38 +00:00
|
|
|
else
|
|
|
|
sprintf(buf, "%c%c%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' ');
|
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
#define IDPUP_NO_VIEWER 1
|
|
|
|
|
|
|
|
static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, short *nr, int hideflag)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
int i, nids= BLI_countlist(lb);
|
|
|
|
|
2004-04-10 15:13:28 +00:00
|
|
|
if (nr) *nr= -1;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-04-10 15:13:28 +00:00
|
|
|
if (nr && nids>MAX_IDPUP) {
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_dynstr_append(pupds, "DataBrowse %x-2");
|
2005-12-12 16:29:47 +00:00
|
|
|
*nr= -2;
|
2002-10-12 11:37:38 +00:00
|
|
|
} else {
|
|
|
|
ID *id;
|
|
|
|
|
|
|
|
for (i=0, id= lb->first; id; id= id->next, i++) {
|
|
|
|
char buf[32];
|
|
|
|
|
2004-04-10 15:13:28 +00:00
|
|
|
if (nr && id==link) *nr= i+1;
|
2005-07-11 23:49:06 +00:00
|
|
|
|
|
|
|
if (U.uiflag & USER_HIDE_DOT && id->name[2]=='.')
|
|
|
|
continue;
|
2006-12-20 17:57:56 +00:00
|
|
|
if (hideflag & IDPUP_NO_VIEWER)
|
|
|
|
if (GS(id->name)==ID_IM)
|
|
|
|
if ( ((Image *)id)->source==IMA_SRC_VIEWER )
|
|
|
|
continue;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
get_flags_for_id(id, buf);
|
|
|
|
|
|
|
|
BLI_dynstr_append(pupds, buf);
|
|
|
|
BLI_dynstr_append(pupds, id->name+2);
|
2011-02-12 16:54:24 +00:00
|
|
|
BLI_snprintf(buf, sizeof(buf), "%%x%d", i+1);
|
First commit of a new toolbox system.
Aim was to find a simple & easy system, script alike, to add and configure
a toolbox system, so that others can experiment, but also of course Python.
Summary:
- spacebar calls it up. SHIFT+A still does old toolbox
- hold left or rightmouse for 0.4 second, and it pops up as well
this is experimental! Can be tweaked with Userdef var "ThresA"
- it is a little bit complete for Object mode only. Needs still work
at information desing/structure level
- the code works like an engine, interpreting structs like this:
static TBitem addmenu_curve[]= {
{ 0, "Bezier Curve", 0, NULL},
{ 0, "Bezier Circle", 1, NULL},
{ 0, "NURBS Curve", 2, NULL},
{ 0, "NURBS Circle", 3, NULL},
{ 0, "Path", 4, NULL},
{ -1, "", 0, do_info_add_curvemenu}};
- first value is ICON code,
- then name
- return value
- pointer to optional child
last row has -1 to indicate its the last...
plus a callback to event function.
I also built an old toolbox style callback for this:
static TBitem tb_object_select[]= {
{ 0, "Border Select|B", 'b', NULL},
{ 0, "(De)select All|A", 'a', NULL},
{ 0, "Linked...|Shift L", 'L', NULL},
{ 0, "Grouped...|Shift G", 'G', NULL},
{ -1, "", 0, tb_do_hotkey}};
here the return values are put back as hotkeys in mainqueue.
A mainloop can do all context switching, and build menus on the fly.
Meaning, it also allows other designs such as radials...
2003-10-25 00:08:12 +00:00
|
|
|
BLI_dynstr_append(pupds, buf);
|
|
|
|
|
More node goodies!
First note; this is a WIP project, some commits might change things that
make formerly saved situations not to work identically... like now!
------ New Material integration ------
Until now, the Node system worked on top of the 'current' Material, just
like how the Material Layers worked. That's quite confusing in practice,
especially to see what Material is a Node, or what is the "base material"
Best solution is to completely separate the two. This has been implemented
as follows now;
- The confusing "Input" node has been removed.
- When choosing a Material in Blender, you can define this Material to be
either 'normal' (default) or be the root of a Node tree.
- If a Material is a Node tree, you have to add Nodes in the tree to see
something happen. An empty Node tree doesn't do anything (black).
- If a Material is a Node Tree, the 'data browse' menus show it with an
'N' mark before the name. The 'data block' buttons display it with the
suffix 'NT' (instead of 'MA').
- In a Node Tree, any Material can be inserted, including itself. Only in
that case the Material is being used itself for shading.
UI changes:
Added a new Panel "Links", which shows:
- where the Material is linked to (Object, Mesh, etc)
- if the Material is a NodeTree or not
- the actual active Material in the Tree
The "Node" Panel itself now only shows buttons from the other nodes, when
they are active.
Further the Material Nodes themselves allow browsing and renaming or adding
new Materials now too.
Second half of today's work was cleaning up selection when the Nodes
overlap... it was possible to drag links from invisible sockets, or click
headers for invisible nodes, etc. This because the mouse input code was
not checking for visibility yet.
Works now even for buttons. :)
2005-12-29 18:08:01 +00:00
|
|
|
/* icon */
|
2005-12-21 22:21:43 +00:00
|
|
|
switch(GS(id->name))
|
|
|
|
{
|
|
|
|
case ID_MA: /* fall through */
|
|
|
|
case ID_TE: /* fall through */
|
|
|
|
case ID_IM: /* fall through */
|
|
|
|
case ID_WO: /* fall through */
|
|
|
|
case ID_LA: /* fall through */
|
2011-02-12 16:54:24 +00:00
|
|
|
BLI_snprintf(buf, sizeof(buf), "%%i%d", BKE_icon_getid(id) );
|
2005-12-21 22:21:43 +00:00
|
|
|
BLI_dynstr_append(pupds, buf);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if(id->next)
|
|
|
|
BLI_dynstr_append(pupds, "|");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-06 10:08:48 +00:00
|
|
|
/* used by headerbuttons.c buttons.c editobject.c editseq.c */
|
|
|
|
/* if nr==NULL no MAX_IDPUP, this for non-header browsing */
|
2010-12-03 17:05:21 +00:00
|
|
|
void IDnames_to_pupstring(const char **str, const char *title, const char *extraops, ListBase *lb, ID *link, short *nr)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
DynStr *pupds= BLI_dynstr_new();
|
|
|
|
|
|
|
|
if (title) {
|
|
|
|
BLI_dynstr_append(pupds, title);
|
|
|
|
BLI_dynstr_append(pupds, "%t|");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (extraops) {
|
First commit of a new toolbox system.
Aim was to find a simple & easy system, script alike, to add and configure
a toolbox system, so that others can experiment, but also of course Python.
Summary:
- spacebar calls it up. SHIFT+A still does old toolbox
- hold left or rightmouse for 0.4 second, and it pops up as well
this is experimental! Can be tweaked with Userdef var "ThresA"
- it is a little bit complete for Object mode only. Needs still work
at information desing/structure level
- the code works like an engine, interpreting structs like this:
static TBitem addmenu_curve[]= {
{ 0, "Bezier Curve", 0, NULL},
{ 0, "Bezier Circle", 1, NULL},
{ 0, "NURBS Curve", 2, NULL},
{ 0, "NURBS Circle", 3, NULL},
{ 0, "Path", 4, NULL},
{ -1, "", 0, do_info_add_curvemenu}};
- first value is ICON code,
- then name
- return value
- pointer to optional child
last row has -1 to indicate its the last...
plus a callback to event function.
I also built an old toolbox style callback for this:
static TBitem tb_object_select[]= {
{ 0, "Border Select|B", 'b', NULL},
{ 0, "(De)select All|A", 'a', NULL},
{ 0, "Linked...|Shift L", 'L', NULL},
{ 0, "Grouped...|Shift G", 'G', NULL},
{ -1, "", 0, tb_do_hotkey}};
here the return values are put back as hotkeys in mainqueue.
A mainloop can do all context switching, and build menus on the fly.
Meaning, it also allows other designs such as radials...
2003-10-25 00:08:12 +00:00
|
|
|
BLI_dynstr_append(pupds, extraops);
|
2002-10-12 11:37:38 +00:00
|
|
|
if (BLI_dynstr_get_len(pupds))
|
|
|
|
BLI_dynstr_append(pupds, "|");
|
|
|
|
}
|
First commit of a new toolbox system.
Aim was to find a simple & easy system, script alike, to add and configure
a toolbox system, so that others can experiment, but also of course Python.
Summary:
- spacebar calls it up. SHIFT+A still does old toolbox
- hold left or rightmouse for 0.4 second, and it pops up as well
this is experimental! Can be tweaked with Userdef var "ThresA"
- it is a little bit complete for Object mode only. Needs still work
at information desing/structure level
- the code works like an engine, interpreting structs like this:
static TBitem addmenu_curve[]= {
{ 0, "Bezier Curve", 0, NULL},
{ 0, "Bezier Circle", 1, NULL},
{ 0, "NURBS Curve", 2, NULL},
{ 0, "NURBS Circle", 3, NULL},
{ 0, "Path", 4, NULL},
{ -1, "", 0, do_info_add_curvemenu}};
- first value is ICON code,
- then name
- return value
- pointer to optional child
last row has -1 to indicate its the last...
plus a callback to event function.
I also built an old toolbox style callback for this:
static TBitem tb_object_select[]= {
{ 0, "Border Select|B", 'b', NULL},
{ 0, "(De)select All|A", 'a', NULL},
{ 0, "Linked...|Shift L", 'L', NULL},
{ 0, "Grouped...|Shift G", 'G', NULL},
{ -1, "", 0, tb_do_hotkey}};
here the return values are put back as hotkeys in mainqueue.
A mainloop can do all context switching, and build menus on the fly.
Meaning, it also allows other designs such as radials...
2003-10-25 00:08:12 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
IDnames_to_dyn_pupstring(pupds, lb, link, nr, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
*str= BLI_dynstr_get_cstring(pupds);
|
|
|
|
BLI_dynstr_free(pupds);
|
|
|
|
}
|
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* skips viewer images */
|
2010-12-03 17:05:21 +00:00
|
|
|
void IMAnames_to_pupstring(const char **str, const char *title, const char *extraops, ListBase *lb, ID *link, short *nr)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
|
|
|
DynStr *pupds= BLI_dynstr_new();
|
|
|
|
|
|
|
|
if (title) {
|
|
|
|
BLI_dynstr_append(pupds, title);
|
|
|
|
BLI_dynstr_append(pupds, "%t|");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (extraops) {
|
|
|
|
BLI_dynstr_append(pupds, extraops);
|
|
|
|
if (BLI_dynstr_get_len(pupds))
|
|
|
|
BLI_dynstr_append(pupds, "|");
|
|
|
|
}
|
|
|
|
|
|
|
|
IDnames_to_dyn_pupstring(pupds, lb, link, nr, IDPUP_NO_VIEWER);
|
|
|
|
|
|
|
|
*str= BLI_dynstr_get_cstring(pupds);
|
|
|
|
BLI_dynstr_free(pupds);
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
static void sort_alpha_id(ListBase *lb, ID *id)
|
|
|
|
{
|
|
|
|
ID *idtest;
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* insert alphabetically */
|
2002-10-12 11:37:38 +00:00
|
|
|
if(lb->first!=lb->last) {
|
|
|
|
BLI_remlink(lb, id);
|
|
|
|
|
|
|
|
idtest= lb->first;
|
|
|
|
while(idtest) {
|
2005-04-02 15:36:57 +00:00
|
|
|
if(BLI_strcasecmp(idtest->name, id->name)>0 || idtest->lib) {
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_insertlinkbefore(lb, idtest, id);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
idtest= idtest->next;
|
|
|
|
}
|
2003-04-26 11:56:44 +00:00
|
|
|
/* as last */
|
2011-02-13 10:52:18 +00:00
|
|
|
if(idtest==NULL) {
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_addtail(lb, id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
ID *idtest=NULL;
|
|
|
|
|
|
|
|
for( idtest = lb->first; idtest; idtest = idtest->next ) {
|
|
|
|
/* if idtest is not a lib */
|
|
|
|
if( id != idtest && idtest->lib == NULL ) {
|
|
|
|
/* do not test alphabetic! */
|
|
|
|
/* optimized */
|
|
|
|
if( idtest->name[2] == name[0] ) {
|
|
|
|
if(strcmp(name, idtest->name+2)==0) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return idtest;
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
* Return 1 if created a new name (returned in name).
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* id is NULL;
|
|
|
|
*/
|
|
|
|
|
2010-03-06 18:21:57 +00:00
|
|
|
static int check_for_dupid(ListBase *lb, ID *id, char *name)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
ID *idtest;
|
2010-07-23 04:41:27 +00:00
|
|
|
int nr= 0, nrtest, a, left_len;
|
2007-03-29 04:55:29 +00:00
|
|
|
char left[32], leftest[32], in_use[32];
|
2010-03-06 18:21:57 +00:00
|
|
|
|
2007-03-29 04:55:29 +00:00
|
|
|
/* make sure input name is terminated properly */
|
2010-03-06 18:21:57 +00:00
|
|
|
/* if( strlen(name) > 21 ) name[21]= 0; */
|
|
|
|
/* removed since this is only ever called from one place - campbell */
|
2007-03-29 04:55:29 +00:00
|
|
|
|
|
|
|
while (1) {
|
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
if( idtest == NULL ) return 0;
|
|
|
|
|
|
|
|
/* we have a dup; need to make a new name */
|
|
|
|
/* quick check so we can reuse one of first 32 ids if vacant */
|
2010-07-23 04:41:27 +00:00
|
|
|
memset(in_use, 0, sizeof(in_use));
|
2007-03-29 04:55:29 +00:00
|
|
|
|
|
|
|
/* get name portion, number portion ("name.number") */
|
2010-11-07 08:49:07 +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 */
|
2010-08-22 07:11:40 +00:00
|
|
|
if(nr > 999 && left_len > 16) {
|
|
|
|
left[16]= 0;
|
|
|
|
left_len= 16;
|
|
|
|
}
|
|
|
|
else if(left_len > 17) {
|
|
|
|
left[17]= 0;
|
|
|
|
left_len= 17;
|
|
|
|
}
|
2007-03-29 04:55:29 +00:00
|
|
|
|
2010-07-23 04:41:27 +00:00
|
|
|
for(idtest= lb->first; idtest; idtest= idtest->next) {
|
|
|
|
if( (id != idtest) &&
|
|
|
|
(idtest->lib == NULL) &&
|
|
|
|
(*name == *(idtest->name+2)) &&
|
|
|
|
(strncmp(name, idtest->name+2, left_len)==0) &&
|
2010-11-07 08:49:07 +00:00
|
|
|
(BLI_split_name_num(leftest, &nrtest, idtest->name+2, '.') == left_len)
|
2010-07-23 04:41:27 +00:00
|
|
|
) {
|
|
|
|
if(nrtest < sizeof(in_use))
|
|
|
|
in_use[nrtest]= 1; /* mark as used */
|
|
|
|
if(nr <= nrtest)
|
|
|
|
nr= nrtest+1; /* track largest unused */
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
2007-03-29 04:55:29 +00:00
|
|
|
|
|
|
|
/* decide which value of nr to use */
|
2010-07-23 04:41:27 +00:00
|
|
|
for(a=0; a < sizeof(in_use); a++) {
|
2007-03-29 04:55:29 +00:00
|
|
|
if(a>=nr) break; /* stop when we've check up to biggest */
|
|
|
|
if( in_use[a]==0 ) { /* found an unused value */
|
|
|
|
nr = a;
|
|
|
|
break;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
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.
|
|
|
|
* Check the null terminators match as well so we dont get Cube.000 -> Cube.00 */
|
2010-08-22 10:52:30 +00:00
|
|
|
if (nr==0 && name[left_len]== '\0') {
|
|
|
|
int len = left_len-1;
|
2009-12-28 01:31:47 +00:00
|
|
|
idtest= is_dupid(lb, id, name);
|
|
|
|
|
|
|
|
while (idtest && len> 1) {
|
|
|
|
name[len--] = '\0';
|
|
|
|
idtest= is_dupid(lb, id, name);
|
2007-03-29 04:55:29 +00:00
|
|
|
}
|
2009-12-28 01:31:47 +00:00
|
|
|
if (idtest == NULL) return 1;
|
|
|
|
/* otherwise just continue and use a number suffix */
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2009-12-28 01:31:47 +00:00
|
|
|
|
2010-08-22 07:11:40 +00:00
|
|
|
if(nr > 999 && left_len > 16) {
|
2009-12-28 01:31:47 +00:00
|
|
|
/* this would overflow name buffer */
|
|
|
|
left[16] = 0;
|
2010-08-22 07:11:40 +00:00
|
|
|
/* left_len = 16; */ /* for now this isnt used again */
|
2010-09-06 11:29:23 +00:00
|
|
|
memcpy(name, left, sizeof(char) * 17);
|
2009-12-28 01:31:47 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* this format specifier is from hell... */
|
2011-02-12 16:54:24 +00:00
|
|
|
BLI_snprintf(name, sizeof(id->name) - 2,"%s.%.3d", left, nr);
|
2009-12-28 01:31:47 +00:00
|
|
|
|
2007-03-29 04:55:29 +00:00
|
|
|
return 1;
|
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.
|
|
|
|
*
|
|
|
|
* return 1: created a new name
|
|
|
|
*/
|
|
|
|
|
2007-03-21 02:23:28 +00:00
|
|
|
int new_id(ListBase *lb, ID *id, const char *tname)
|
|
|
|
{
|
2007-03-26 13:02:43 +00:00
|
|
|
int result;
|
2011-04-19 06:59:49 +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 */
|
|
|
|
if(id->lib) return 0;
|
|
|
|
|
|
|
|
/* if no libdata given, look up based on ID */
|
* 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
|
|
|
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) */
|
|
|
|
if(tname==NULL)
|
|
|
|
tname= id->name+2;
|
|
|
|
|
|
|
|
strncpy(name, tname, sizeof(name)-1);
|
|
|
|
|
|
|
|
/* if result > 21, strncpy don't put the final '\0' to name.
|
|
|
|
* easier to assign each time then to check if its needed */
|
|
|
|
name[sizeof(name)-1]= 0;
|
2007-03-29 04:55:29 +00:00
|
|
|
|
2010-08-30 08:28:48 +00:00
|
|
|
if(name[0] == '\0') {
|
|
|
|
/* disallow empty names */
|
2010-03-06 18:21:57 +00:00
|
|
|
strcpy(name, ID_FALLBACK_NAME);
|
2010-08-30 08:28:48 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* disallow non utf8 chars,
|
|
|
|
* the interface checks for this but new ID's based on file names dont */
|
|
|
|
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);
|
|
|
|
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
|
|
|
|
* sorting should not hurt, but noting just incause it alters the way other
|
|
|
|
* functions work, so sort every time */
|
|
|
|
/* if( result )
|
|
|
|
sort_alpha_id(lb, id);*/
|
|
|
|
|
|
|
|
sort_alpha_id(lb, id);
|
|
|
|
|
2007-03-21 02:23:28 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-04-06 10:08:48 +00:00
|
|
|
/* next to indirect usage in read/writefile also in editobject.c scene.c */
|
2011-02-13 10:52:18 +00:00
|
|
|
void clear_id_newpoins(void)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
ListBase *lbarray[MAX_LIBARRAY];
|
|
|
|
ID *id;
|
|
|
|
int a;
|
|
|
|
|
|
|
|
a= set_listbasepointers(G.main, lbarray);
|
|
|
|
while(a--) {
|
|
|
|
id= lbarray[a]->first;
|
|
|
|
while(id) {
|
2011-02-13 10:52:18 +00:00
|
|
|
id->newid= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
id->flag &= ~LIB_NEW;
|
|
|
|
id= id->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-09 19:47:53 +00:00
|
|
|
/* only for library fixes */
|
|
|
|
static void image_fix_relative_path(Image *ima)
|
|
|
|
{
|
|
|
|
if(ima->id.lib==NULL) return;
|
|
|
|
if(strncmp(ima->name, "//", 2)==0) {
|
2010-06-02 17:58:28 +00:00
|
|
|
BLI_path_abs(ima->name, ima->id.lib->filepath);
|
2010-10-18 06:41:16 +00:00
|
|
|
BLI_path_rel(ima->name, G.main->name);
|
2006-02-09 19:47:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-05 17:35:06 +00:00
|
|
|
#define LIBTAG(a) if(a && a->id.lib) {a->id.flag &=~LIB_INDIRECT; a->id.flag |= LIB_EXTERN;}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
2010-03-31 07:22:18 +00:00
|
|
|
if(id->lib) {
|
|
|
|
/* datablocks that were indirectly related are now direct links
|
|
|
|
* without this, appending data that has a link to other data will fail to write */
|
|
|
|
if(lib && id->lib->parent == lib) {
|
|
|
|
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
|
|
|
|
2006-03-05 17:35:06 +00:00
|
|
|
if(GS(id->name)==ID_OB) {
|
|
|
|
Object *ob= (Object *)id;
|
|
|
|
bActionStrip *strip;
|
|
|
|
Mesh *me;
|
2008-04-27 18:26:20 +00:00
|
|
|
|
2006-03-05 17:35:06 +00:00
|
|
|
int a;
|
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
|
|
|
|
2009-10-09 12:16:58 +00:00
|
|
|
// XXX old animation system! --------------------------------------
|
2006-03-05 17:35:06 +00:00
|
|
|
for (strip=ob->nlastrips.first; strip; strip=strip->next){
|
|
|
|
LIBTAG(strip->object);
|
|
|
|
LIBTAG(strip->act);
|
|
|
|
LIBTAG(strip->ipo);
|
|
|
|
}
|
2009-10-09 12:16:58 +00:00
|
|
|
// XXX: new animation system needs something like this?
|
2006-03-05 17:35:06 +00:00
|
|
|
|
|
|
|
for(a=0; a<ob->totcol; a++) {
|
|
|
|
LIBTAG(ob->mat[a]);
|
|
|
|
}
|
|
|
|
|
|
|
|
LIBTAG(ob->dup_group);
|
2007-01-25 11:59:29 +00:00
|
|
|
LIBTAG(ob->proxy);
|
|
|
|
|
2006-03-05 17:35:06 +00:00
|
|
|
me= ob->data;
|
|
|
|
LIBTAG(me);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-05 05:33:27 +00:00
|
|
|
void tag_main_lb(ListBase *lb, const short tag)
|
2009-08-07 03:51:28 +00:00
|
|
|
{
|
|
|
|
ID *id;
|
2011-01-05 05:33:27 +00:00
|
|
|
if(tag) {
|
|
|
|
for(id= lb->first; id; id= id->next) {
|
|
|
|
id->flag |= LIB_DOIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for(id= lb->first; id; id= id->next) {
|
|
|
|
id->flag &= ~LIB_DOIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void tag_main_idcode(struct Main *mainvar, const short type, const short tag)
|
|
|
|
{
|
|
|
|
ListBase *lb= which_libbase(mainvar, type);
|
|
|
|
|
|
|
|
tag_main_lb(lb, tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tag_main(struct Main *mainvar, const short tag)
|
|
|
|
{
|
|
|
|
ListBase *lbarray[MAX_LIBARRAY];
|
2009-08-07 03:51:28 +00:00
|
|
|
int a;
|
|
|
|
|
|
|
|
a= set_listbasepointers(mainvar, lbarray);
|
|
|
|
while(a--) {
|
2011-01-05 05:33:27 +00:00
|
|
|
tag_main_lb(lbarray[a], tag);
|
2009-08-07 03:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-05 17:35:06 +00:00
|
|
|
|
2004-04-22 19:58:54 +00:00
|
|
|
/* if lib!=NULL, only all from lib local */
|
2007-04-07 17:35:47 +00:00
|
|
|
void all_local(Library *lib, int untagged_only)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2011-02-13 10:52:18 +00:00
|
|
|
ListBase *lbarray[MAX_LIBARRAY], tempbase={NULL, NULL};
|
2002-10-12 11:37:38 +00:00
|
|
|
ID *id, *idn;
|
|
|
|
int a;
|
|
|
|
|
|
|
|
a= set_listbasepointers(G.main, lbarray);
|
|
|
|
while(a--) {
|
|
|
|
id= lbarray[a]->first;
|
|
|
|
|
|
|
|
while(id) {
|
2004-04-22 19:58:54 +00:00
|
|
|
id->newid= NULL;
|
2003-04-26 11:56:44 +00:00
|
|
|
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
|
2007-04-07 17:35:47 +00:00
|
|
|
* possible to tag data you dont want to be made local, used for
|
2010-07-17 18:08:14 +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)
|
|
|
|
* */
|
|
|
|
if(id->flag & (LIB_EXTERN|LIB_INDIRECT|LIB_NEW) &&
|
2010-01-07 16:19:38 +00:00
|
|
|
(untagged_only==0 || !(id->flag & LIB_PRE_EXISTING)))
|
2007-04-07 17:35:47 +00:00
|
|
|
{
|
2004-04-22 19:58:54 +00:00
|
|
|
if(lib==NULL || id->lib==lib) {
|
|
|
|
id->flag &= ~(LIB_EXTERN|LIB_INDIRECT|LIB_NEW);
|
|
|
|
|
|
|
|
if(id->lib) {
|
2006-02-09 19:47:53 +00:00
|
|
|
/* relative file patch */
|
|
|
|
if(GS(id->name)==ID_IM)
|
|
|
|
image_fix_relative_path((Image *)id);
|
|
|
|
|
2004-04-22 19:58:54 +00:00
|
|
|
id->lib= NULL;
|
2011-02-13 10:52:18 +00:00
|
|
|
new_id(lbarray[a], id, NULL); /* new_id only does it with double names */
|
2004-04-22 19:58:54 +00:00
|
|
|
sort_alpha_id(lbarray[a], id);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
id= idn;
|
|
|
|
}
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* patch2: make it aphabetically */
|
2002-10-12 11:37:38 +00:00
|
|
|
while( (id=tempbase.first) ) {
|
|
|
|
BLI_remlink(&tempbase, id);
|
|
|
|
BLI_addtail(lbarray[a], id);
|
2011-02-13 10:52:18 +00:00
|
|
|
new_id(lbarray[a], id, NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-05 17:35:06 +00:00
|
|
|
|
|
|
|
/* patch 3: make sure library data isn't indirect falsely... */
|
|
|
|
a= set_listbasepointers(G.main, lbarray);
|
|
|
|
while(a--) {
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
* 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
|
|
|
lb= which_libbase(G.main, GS(name-2) );
|
2011-02-13 10:52:18 +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 */
|
2009-12-29 15:40:26 +00:00
|
|
|
idtest= BLI_findstring(lb, name, offsetof(ID, name) + 2);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
if(idtest) if( new_id(lb, idtest, name)==0 ) sort_alpha_id(lb, idtest);
|
|
|
|
}
|
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
void text_idbutton(struct ID *id, char *text)
|
|
|
|
{
|
|
|
|
if(id) {
|
|
|
|
if(GS(id->name)==ID_SCE)
|
|
|
|
strcpy(text, "SCE: ");
|
2011-05-01 10:14:09 +00:00
|
|
|
else if(GS(id->name)==ID_SCR)
|
2009-04-22 18:39:44 +00:00
|
|
|
strcpy(text, "SCR: ");
|
2010-03-22 09:30:00 +00:00
|
|
|
else if(GS(id->name)==ID_MA && ((Material*)id)->use_nodes)
|
2009-04-22 18:39:44 +00:00
|
|
|
strcpy(text, "NT: ");
|
2010-03-22 09:30:00 +00:00
|
|
|
else {
|
2009-04-22 18:39:44 +00:00
|
|
|
text[0]= id->name[0];
|
|
|
|
text[1]= id->name[1];
|
|
|
|
text[2]= ':';
|
|
|
|
text[3]= ' ';
|
|
|
|
text[4]= 0;
|
2010-03-22 09:30:00 +00:00
|
|
|
}
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
2010-08-30 08:28:48 +00:00
|
|
|
else {
|
|
|
|
text[0]= '\0';
|
|
|
|
}
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2010-11-05 07:35:21 +00:00
|
|
|
BLI_strncpy(id->name+2, name, sizeof(id->name)-2);
|
* 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
|
|
|
lb= which_libbase(G.main, GS(id->name) );
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
new_id(lb, id, name);
|
|
|
|
}
|
2010-07-31 01:06:08 +00:00
|
|
|
|
|
|
|
void name_uiprefix_id(char *name, ID *id)
|
|
|
|
{
|
|
|
|
name[0] = id->lib ? 'L':' ';
|
2010-11-23 19:06:54 +00:00
|
|
|
name[1] = id->flag & LIB_FAKEUSER ? 'F': (id->us==0)?'0':' ';
|
2010-07-31 01:06:08 +00:00
|
|
|
name[2] = ' ';
|
|
|
|
|
|
|
|
strcpy(name+3, id->name+2);
|
|
|
|
}
|