style cleanup: follow style guide for formatting of if/for/while loops, and else...
[blender.git] / source / blender / nodes / composite / nodes / node_composite_mapUV.c
index b1cae62274b384df2cbf20c90dcf41f08dd9e23d..7d62e6b8030e462522e0876447be44a9cf9c9eaa 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -37,7 +35,7 @@
 /* **************** Map UV  ******************** */
 
 static bNodeSocketTemplate cmp_node_mapuv_in[]= {
-       {       SOCK_RGBA, 1, "Image",                  0.8f, 0.8f, 0.8f, 1.0f},
+       {       SOCK_RGBA, 1, "Image",                  1.0f, 1.0f, 1.0f, 1.0f},
        {       SOCK_VECTOR, 1, "UV",                   1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
        {       -1, 0, ""       }
 };
@@ -66,65 +64,65 @@ static void do_mapuv(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *uvbuf, float thr
        sx= stackbuf->x;
        sy= stackbuf->y;
        
-       for(y=0; y<sy; y++) {
-               for(x=0; x<sx; x++, out+=4, uv+=3, uvnext+=3, uvprev+=3) {
-                       if(x>0 && x<sx-1 && y>0 && y<sy-1) {
-                               if(uv[2]!=0.0f) {
+       for (y=0; y<sy; y++) {
+               for (x=0; x<sx; x++, out+=4, uv+=3, uvnext+=3, uvprev+=3) {
+                       if (x>0 && x<sx-1 && y>0 && y<sy-1) {
+                               if (uv[2]!=0.0f) {
                                        float uv_l, uv_r;
                                        
                                        /* adaptive sampling, red (U) channel */
                                        
                                        /* prevent alpha zero UVs to be used */
-                                       uv_l= uv[-1]!=0.0f? fabs(uv[0]-uv[-3]) : 0.0f;
-                                       uv_r= uv[ 5]!=0.0f? fabs(uv[0]-uv[ 3]) : 0.0f;
+                                       uv_l= uv[-1]!=0.0f? fabsf(uv[0]-uv[-3]) : 0.0f;
+                                       uv_r= uv[ 5]!=0.0f? fabsf(uv[0]-uv[ 3]) : 0.0f;
                                        
                                        //dx= 0.5f*(fabs(uv[0]-uv[-3]) + fabs(uv[0]-uv[3]));
                                        dx= 0.5f*(uv_l + uv_r);
                                        
-                                       uv_l= uvprev[-1]!=0.0f? fabs(uv[0]-uvprev[-3]) : 0.0f;
-                                       uv_r= uvnext[-1]!=0.0f? fabs(uv[0]-uvnext[-3]) : 0.0f;
+                                       uv_l= uvprev[-1]!=0.0f? fabsf(uv[0]-uvprev[-3]) : 0.0f;
+                                       uv_r= uvnext[-1]!=0.0f? fabsf(uv[0]-uvnext[-3]) : 0.0f;
                                        
                                        //dx+= 0.25f*(fabs(uv[0]-uvprev[-3]) + fabs(uv[0]-uvnext[-3]));
                                        dx+= 0.25f*(uv_l + uv_r);
                                                
-                                       uv_l= uvprev[ 5]!=0.0f? fabs(uv[0]-uvprev[+3]) : 0.0f;
-                                       uv_r= uvnext[ 5]!=0.0f? fabs(uv[0]-uvnext[+3]) : 0.0f;
+                                       uv_l= uvprev[ 5]!=0.0f? fabsf(uv[0]-uvprev[+3]) : 0.0f;
+                                       uv_r= uvnext[ 5]!=0.0f? fabsf(uv[0]-uvnext[+3]) : 0.0f;
                                        
                                        //dx+= 0.25f*(fabs(uv[0]-uvprev[+3]) + fabs(uv[0]-uvnext[+3]));
                                        dx+= 0.25f*(uv_l + uv_r);
                                        
                                        /* adaptive sampling, green (V) channel */
                                        
-                                       uv_l= uv[-row+2]!=0.0f? fabs(uv[1]-uv[-row+1]) : 0.0f;
-                                       uv_r= uv[ row+2]!=0.0f? fabs(uv[1]-uv[ row+1]) : 0.0f;
+                                       uv_l= uv[-row+2]!=0.0f? fabsf(uv[1]-uv[-row+1]) : 0.0f;
+                                       uv_r= uv[ row+2]!=0.0f? fabsf(uv[1]-uv[ row+1]) : 0.0f;
                                        
                                        //dy= 0.5f*(fabs(uv[1]-uv[-row+1]) + fabs(uv[1]-uv[row+1]));
                                        dy= 0.5f*(uv_l + uv_r);
                                        
-                                       uv_l= uvprev[-1]!=0.0f? fabs(uv[1]-uvprev[+1-3]) : 0.0f;
-                                       uv_r= uvnext[-1]!=0.0f? fabs(uv[1]-uvnext[+1-3]) : 0.0f;
+                                       uv_l= uvprev[-1]!=0.0f? fabsf(uv[1]-uvprev[+1-3]) : 0.0f;
+                                       uv_r= uvnext[-1]!=0.0f? fabsf(uv[1]-uvnext[+1-3]) : 0.0f;
                                        
                                        //dy+= 0.25f*(fabs(uv[1]-uvprev[+1-3]) + fabs(uv[1]-uvnext[+1-3]));
                                        dy+= 0.25f*(uv_l + uv_r);
                                        
-                                       uv_l= uvprev[ 5]!=0.0f? fabs(uv[1]-uvprev[+1+3]) : 0.0f;
-                                       uv_r= uvnext[ 5]!=0.0f? fabs(uv[1]-uvnext[+1+3]) : 0.0f;
+                                       uv_l= uvprev[ 5]!=0.0f? fabsf(uv[1]-uvprev[+1+3]) : 0.0f;
+                                       uv_r= uvnext[ 5]!=0.0f? fabsf(uv[1]-uvnext[+1+3]) : 0.0f;
                                        
                                        //dy+= 0.25f*(fabs(uv[1]-uvprev[+1+3]) + fabs(uv[1]-uvnext[+1+3]));
                                        dy+= 0.25f*(uv_l + uv_r);
                                        
                                        /* UV to alpha threshold */
                                        alpha= 1.0f - threshold*(dx+dy);
-                                       if(alpha<0.0f) alpha= 0.0f;
+                                       if (alpha<0.0f) alpha= 0.0f;
                                        else alpha*= uv[2];
                                        
                                        /* should use mipmap */
-                                       if(dx > 0.20f) dx= 0.20f;
-                                       if(dy > 0.20f) dy= 0.20f;
+                                       if (dx > 0.20f) dx= 0.20f;
+                                       if (dy > 0.20f) dy= 0.20f;
                                        
                                        ibuf_sample(ibuf, uv[0], uv[1], dx, dy, out);
                                        /* premul */
-                                       if(alpha<1.0f) {
+                                       if (alpha<1.0f) {
                                                out[0]*= alpha;
                                                out[1]*= alpha;
                                                out[2]*= alpha;
@@ -141,10 +139,10 @@ static void do_mapuv(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *uvbuf, float thr
 
 static void node_composit_exec_mapuv(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
 {
-       if(out[0]->hasoutput==0)
+       if (out[0]->hasoutput==0)
                return;
        
-       if(in[0]->data && in[1]->data) {
+       if (in[0]->data && in[1]->data) {
                CompBuf *cbuf= in[0]->data;
                CompBuf *uvbuf= in[1]->data;
                CompBuf *stackbuf;
@@ -157,24 +155,21 @@ static void node_composit_exec_mapuv(void *UNUSED(data), bNode *node, bNodeStack
                
                out[0]->data= stackbuf;
                
-               if(cbuf!=in[0]->data)
+               if (cbuf!=in[0]->data)
                        free_compbuf(cbuf);
-               if(uvbuf!=in[1]->data)
+               if (uvbuf!=in[1]->data)
                        free_compbuf(uvbuf);
        }
 }
 
-void register_node_type_cmp_mapuv(ListBase *lb)
+void register_node_type_cmp_mapuv(bNodeTreeType *ttype)
 {
        static bNodeType ntype;
 
-       node_type_base(&ntype, CMP_NODE_MAP_UV, "Map UV", NODE_CLASS_DISTORT, NODE_OPTIONS);
+       node_type_base(ttype, &ntype, CMP_NODE_MAP_UV, "Map UV", NODE_CLASS_DISTORT, NODE_OPTIONS);
        node_type_socket_templates(&ntype, cmp_node_mapuv_in, cmp_node_mapuv_out);
        node_type_size(&ntype, 140, 100, 320);
        node_type_exec(&ntype, node_composit_exec_mapuv);
 
-       nodeRegisterType(lb, &ntype);
+       nodeRegisterType(ttype, &ntype);
 }
-
-
-