How are node links stored?

How are node links stored? Does the link save a reference to the node’s socket index or the socket identifier?

NodeLinks store references and are separate types. Every (Shader)Node has “inputs” and “outputs” properties, which store 0…n references to NodeLinks:


Got another question: What nodes actually use the default_value of output sockets?

I know ShaderNodeNormal uses it, which seems really odd/hackish, but are there others?

http://www.blender.org/documentation/blender_python_api_2_70a_release/search.html?q=default_value&check_keywords=yes&area=default

I think you misunderstood. I want to know what/if other nodes use it internally even though it is an output socket (as opposed to an input socket). Just like ShaderNodeNormal.

The Normal Node has a Normal input and Normal output, both are one and the same type: NodeSocketVectorDirection

default_value is float vector property of NodeSocketVectorDirection, doesn’t matter if input or output.

>>> type(C.scene.node_tree.nodes['Normal'].inputs['Normal'])
<class 'bpy.types.NodeSocketVectorDirection'>

>>> type(C.scene.node_tree.nodes['Normal'].outputs['Normal'])
<class 'bpy.types.NodeSocketVectorDirection'>

>>> bpy.types.NodeSocketVectorDirection.bl_rna.properties['default_value'].type
'FLOAT'

...array_length
3

...subtype
DIRECTION

etc.

There’s no restriction to what you plug into it, or what else you connect it to - but you’ll probably experience unexpected results if you connect to an incompatible type - like 3x float into 1x int or similar.

This has nothing to do with what I am plugging into a socket or what the type of the socket is. It has everything to do with what the node type is and weather or not it uses the default_value of any of it’s output sockets.

Don’t worry about it. I already looked through all the shader nodes. So far:

ShaderNodeNormal uses the default_value of the first output socket to calc the dot product on the second output socket.
ShaderNodeRGB uses the default_value of the output socket
ShaderNodeValue uses the default_value of the output socket

Now I will search through the compositor nodes and see if any of those use the default_value of any output sockets aside from CompositorNodeNormal, CompositorNodeRGB and CompositorNodeValue obviously.

Are the texture nodes even used much at all? Do they only work for BI materials or do they work for things like displacement/particles/etc.?