~ubuntu-branches/ubuntu/trusty/blender/trusty-proposed

« back to all changes in this revision

Viewing changes to source/blender/nodes/intern/node_util.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2013-08-14 10:43:49 UTC
  • mfrom: (14.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20130814104349-t1d5mtwkphp12dyj
Tags: 2.68a-3
* Upload to unstable
* debian/: python3.3 Depends simplified
  - debian/control: python3.3 Depends dropped
    for blender-data package
  - 0001-blender_thumbnailer.patch refreshed
* debian/control: libavcodec b-dep versioning dropped

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 */
31
31
 
32
32
#include <limits.h>
 
33
#include <string.h>
33
34
 
34
35
#include "DNA_action_types.h"
35
36
#include "DNA_node_types.h"
63
64
        }
64
65
}
65
66
 
66
 
void node_copy_curves(bNode *orig_node, bNode *new_node)
67
 
{
68
 
        new_node->storage = curvemapping_copy(orig_node->storage);
69
 
}
70
 
 
71
 
void node_copy_standard_storage(bNode *orig_node, bNode *new_node)
72
 
{
73
 
        new_node->storage = MEM_dupallocN(orig_node->storage);
74
 
}
75
 
 
76
 
void *node_initexec_curves(bNode *node)
 
67
void node_copy_curves(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, bNode *src_node)
 
68
{
 
69
        dest_node->storage = curvemapping_copy(src_node->storage);
 
70
}
 
71
 
 
72
void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, bNode *src_node)
 
73
{
 
74
        dest_node->storage = MEM_dupallocN(src_node->storage);
 
75
}
 
76
 
 
77
void *node_initexec_curves(bNodeExecContext *UNUSED(context), bNode *node, bNodeInstanceKey UNUSED(key))
77
78
{
78
79
        curvemapping_initialize(node->storage);
79
80
        return NULL;  /* unused return */
111
112
 
112
113
void node_update_internal_links_default(bNodeTree *ntree, bNode *node)
113
114
{
114
 
        bNodeSocket *fromsock_first=NULL, *tosock_first=NULL;   /* used for fallback link if no other reconnections are found */
 
115
        bNodeSocket *fromsock_first = NULL, *tosock_first = NULL;   /* used for fallback link if no other reconnections are found */
115
116
        int datatype;
116
117
        int num_links_in = 0, num_links_out = 0, num_reconnect = 0;
117
118
 
119
120
        if (!ntree)
120
121
                return;
121
122
 
122
 
        for (datatype=0; datatype < NUM_SOCKET_TYPES; ++datatype) {
 
123
        for (datatype = 0; datatype < NUM_SOCKET_TYPES; ++datatype) {
123
124
                bNodeSocket *fromsock, *tosock;
124
125
                int fromindex, toindex;
125
126
                bNodeLink *link;
128
129
                
129
130
                fromindex = INT_MAX;
130
131
                fromsock = NULL;
131
 
                for (link=ntree->links.first; link; link=link->next) {
 
132
                for (link = ntree->links.first; link; link = link->next) {
 
133
                        if (nodeLinkIsHidden(link))
 
134
                                continue;
132
135
                        if (link->tonode == node && link->tosock->type == datatype) {
133
136
                                int index = BLI_findindex(&node->inputs, link->tosock);
134
137
                                if (index < fromindex) {
145
148
                
146
149
                toindex = INT_MAX;
147
150
                tosock = NULL;
148
 
                for (link=ntree->links.first; link; link=link->next) {
 
151
                for (link = ntree->links.first; link; link = link->next) {
 
152
                        if (nodeLinkIsHidden(link))
 
153
                                continue;
149
154
                        if (link->fromnode == node && link->fromsock->type == datatype) {
150
155
                                int index = BLI_findindex(&node->outputs, link->fromsock);
151
156
                                if (index < toindex) {
177
182
        /* if there is one input and one output link, but no reconnections by type,
178
183
         * simply connect those two sockets.
179
184
         */
180
 
        if (num_reconnect==0 && num_links_in==1 && num_links_out==1) {
 
185
        if ((num_reconnect == 0) && (num_links_in == 1) && (num_links_out == 1)) {
181
186
                bNodeLink *ilink = MEM_callocN(sizeof(bNodeLink), "internal node link");
182
187
                ilink->fromnode = node;
183
188
                ilink->fromsock = fromsock_first;
188
193
                BLI_addtail(&node->internal_links, ilink);
189
194
        }
190
195
}
 
196
 
 
197
float node_socket_get_float(bNodeTree *ntree, bNode *UNUSED(node), bNodeSocket *sock)
 
198
{
 
199
        PointerRNA ptr;
 
200
        RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
 
201
        return RNA_float_get(&ptr, "default_value");
 
202
}
 
203
 
 
204
void node_socket_set_float(bNodeTree *ntree, bNode *UNUSED(node), bNodeSocket *sock, float value)
 
205
{
 
206
        PointerRNA ptr;
 
207
        RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
 
208
        RNA_float_set(&ptr, "default_value", value);
 
209
}
 
210
 
 
211
void node_socket_get_color(bNodeTree *ntree, bNode *UNUSED(node), bNodeSocket *sock, float *value)
 
212
{
 
213
        PointerRNA ptr;
 
214
        RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
 
215
        RNA_float_get_array(&ptr, "default_value", value);
 
216
}
 
217
 
 
218
void node_socket_set_color(bNodeTree *ntree, bNode *UNUSED(node), bNodeSocket *sock, const float *value)
 
219
{
 
220
        PointerRNA ptr;
 
221
        RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
 
222
        RNA_float_set_array(&ptr, "default_value", value);
 
223
}
 
224
 
 
225
void node_socket_get_vector(bNodeTree *ntree, bNode *UNUSED(node), bNodeSocket *sock, float *value)
 
226
{
 
227
        PointerRNA ptr;
 
228
        RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
 
229
        RNA_float_get_array(&ptr, "default_value", value);
 
230
}
 
231
 
 
232
void node_socket_set_vector(bNodeTree *ntree, bNode *UNUSED(node), bNodeSocket *sock, const float *value)
 
233
{
 
234
        PointerRNA ptr;
 
235
        RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
 
236
        RNA_float_set_array(&ptr, "default_value", value);
 
237
}