~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/nodes/composite/nodes/node_composite_mapValue.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ***** BEGIN GPL LICENSE BLOCK *****
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License
 
6
 * as published by the Free Software Foundation; either version 2
 
7
 * of the License, or (at your option) any later version. 
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software Foundation,
 
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
17
 *
 
18
 * The Original Code is Copyright (C) 2006 Blender Foundation.
 
19
 * All rights reserved.
 
20
 *
 
21
 * The Original Code is: all of this file.
 
22
 *
 
23
 * Contributor(s): none yet.
 
24
 *
 
25
 * ***** END GPL LICENSE BLOCK *****
 
26
 */
 
27
 
 
28
/** \file blender/nodes/composite/nodes/node_composite_mapValue.c
 
29
 *  \ingroup cmpnodes
 
30
 */
 
31
 
 
32
 
 
33
#include "node_composite_util.h"
 
34
 
 
35
/* **************** MAP VALUE ******************** */
 
36
static bNodeSocketTemplate cmp_node_map_value_in[]= {
 
37
        {       SOCK_FLOAT, 1, "Value",                 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
 
38
        {       -1, 0, ""       }
 
39
};
 
40
static bNodeSocketTemplate cmp_node_map_value_out[]= {
 
41
        {       SOCK_FLOAT, 0, "Value"},
 
42
        {       -1, 0, ""       }
 
43
};
 
44
 
 
45
static void do_map_value(bNode *node, float *out, float *src)
 
46
{
 
47
        TexMapping *texmap= node->storage;
 
48
        
 
49
        out[0]= (src[0] + texmap->loc[0])*texmap->size[0];
 
50
        if (texmap->flag & TEXMAP_CLIP_MIN)
 
51
                if (out[0]<texmap->min[0])
 
52
                        out[0]= texmap->min[0];
 
53
        if (texmap->flag & TEXMAP_CLIP_MAX)
 
54
                if (out[0]>texmap->max[0])
 
55
                        out[0]= texmap->max[0];
 
56
}
 
57
 
 
58
static void node_composit_exec_map_value(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
 
59
{
 
60
        /* stack order in: valbuf */
 
61
        /* stack order out: valbuf */
 
62
        if (out[0]->hasoutput==0) return;
 
63
        
 
64
        /* input no image? then only value operation */
 
65
        if (in[0]->data==NULL) {
 
66
                do_map_value(node, out[0]->vec, in[0]->vec);
 
67
        }
 
68
        else {
 
69
                /* make output size of input image */
 
70
                CompBuf *cbuf= in[0]->data;
 
71
                CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1); /* allocs */
 
72
                
 
73
                composit1_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, do_map_value, CB_VAL);
 
74
                
 
75
                out[0]->data= stackbuf;
 
76
        }
 
77
}
 
78
 
 
79
 
 
80
static void node_composit_init_map_value(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 
81
{
 
82
        node->storage= add_tex_mapping();
 
83
}
 
84
 
 
85
void register_node_type_cmp_map_value(bNodeTreeType *ttype)
 
86
{
 
87
        static bNodeType ntype;
 
88
 
 
89
        node_type_base(ttype, &ntype, CMP_NODE_MAP_VALUE, "Map Value", NODE_CLASS_OP_VECTOR, NODE_OPTIONS);
 
90
        node_type_socket_templates(&ntype, cmp_node_map_value_in, cmp_node_map_value_out);
 
91
        node_type_size(&ntype, 100, 60, 150);
 
92
        node_type_init(&ntype, node_composit_init_map_value);
 
93
        node_type_storage(&ntype, "TexMapping", node_free_standard_storage, node_copy_standard_storage);
 
94
        node_type_exec(&ntype, node_composit_exec_map_value);
 
95
 
 
96
        nodeRegisterType(ttype, &ntype);
 
97
}