style cleanup: follow style guide for formatting of if/for/while loops, and else...
[blender.git] / source / blender / nodes / shader / nodes / node_shader_texture.c
index 42460e141e27a5a1ff6e6595e104bbeeb5ee3a55..8b6386fe2f6efe071e0f47635f0b8bc2f864b9e1 100644 (file)
@@ -36,7 +36,7 @@
 
 /* **************** TEXTURE ******************** */
 static bNodeSocketTemplate sh_node_texture_in[]= {
-       {       SOCK_VECTOR, 1, "Vector",       0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE},        /* no limit */
+       {       SOCK_VECTOR, 1, "Vector",       0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},       /* no limit */
        {       -1, 0, ""       }
 };
 static bNodeSocketTemplate sh_node_texture_out[]= {
@@ -48,9 +48,10 @@ static bNodeSocketTemplate sh_node_texture_out[]= {
 
 static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 {
-       if(data && node->id) {
+       if (data && node->id) {
                ShadeInput *shi= ((ShaderCallData *)data)->shi;
                TexResult texres;
+               bNodeSocket *sock_vector= node->inputs.first;
                float vec[3], nor[3]={0.0f, 0.0f, 0.0f};
                int retval;
                short which_output = node->custom1;
@@ -63,14 +64,15 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b
                texres.nor= nor;
                texres.tr= texres.tg= texres.tb= 0.0f;
                
-               if(in[0]->hasinput) {
+               /* don't use in[0]->hasinput, see material node for explanation */
+               if (sock_vector->link) {
                        nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
                        
-                       if(in[0]->datatype==NS_OSA_VECTORS) {
+                       if (in[0]->datatype==NS_OSA_VECTORS) {
                                float *fp= in[0]->data;
                                retval= multitex_nodes((Tex *)node->id, vec, fp, fp+3, shi->osatex, &texres, thread, which_output, NULL, NULL);
                        }
-                       else if(in[0]->datatype==NS_OSA_VALUES) {
+                       else if (in[0]->datatype==NS_OSA_VALUES) {
                                float *fp= in[0]->data;
                                float dxt[3], dyt[3];
                                
@@ -87,18 +89,18 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b
                }
                
                /* stupid exception */
-               if( ((Tex *)node->id)->type==TEX_STUCCI) {
+               if ( ((Tex *)node->id)->type==TEX_STUCCI) {
                        texres.tin= 0.5f + 0.7f*texres.nor[0];
                        CLAMP(texres.tin, 0.0f, 1.0f);
                }
                
                /* intensity and color need some handling */
-               if(texres.talpha)
+               if (texres.talpha)
                        out[0]->vec[0]= texres.ta;
                else
                        out[0]->vec[0]= texres.tin;
                
-               if((retval & TEX_RGB)==0) {
+               if ((retval & TEX_RGB)==0) {
                        out[1]->vec[0]= out[0]->vec[0];
                        out[1]->vec[1]= out[0]->vec[0];
                        out[1]->vec[2]= out[0]->vec[0];
@@ -113,7 +115,7 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b
                
                copy_v3_v3(out[2]->vec, nor);
                
-               if(shi->do_preview)
+               if (shi->do_preview)
                        nodeAddToPreview(node, out[1]->vec, shi->xs, shi->ys, shi->do_manage);
                
        }
@@ -123,7 +125,7 @@ static int gpu_shader_texture(GPUMaterial *mat, bNode *node, GPUNodeStack *in, G
 {
        Tex *tex = (Tex*)node->id;
 
-       if(tex && tex->type == TEX_IMAGE && tex->ima) {
+       if (tex && tex->type == TEX_IMAGE && tex->ima) {
                GPUNodeLink *texlink = GPU_image(tex->ima, NULL);
                return GPU_stack_link(mat, "texture_image", in, out, texlink);
        }
@@ -131,18 +133,16 @@ static int gpu_shader_texture(GPUMaterial *mat, bNode *node, GPUNodeStack *in, G
                return 0;
 }
 
-void register_node_type_sh_texture(ListBase *lb)
+void register_node_type_sh_texture(bNodeTreeType *ttype)
 {
        static bNodeType ntype;
 
-       node_type_base(&ntype, SH_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT, NODE_OPTIONS|NODE_PREVIEW);
+       node_type_base(ttype, &ntype, SH_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT, NODE_OPTIONS|NODE_PREVIEW);
        node_type_compatibility(&ntype, NODE_OLD_SHADING);
        node_type_socket_templates(&ntype, sh_node_texture_in, sh_node_texture_out);
        node_type_size(&ntype, 120, 80, 240);
        node_type_exec(&ntype, node_shader_exec_texture);
        node_type_gpu(&ntype, gpu_shader_texture);
 
-       nodeRegisterType(lb, &ntype);
+       nodeRegisterType(ttype, &ntype);
 }
-
-