converted more mixed tab/space indentations to tabs. only whitespace changes.
[blender.git] / source / blender / nodes / intern / CMP_nodes / CMP_crop.c
index c2edb3d..0331217 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  *
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
  * ***** END GPL LICENSE BLOCK *****
  */
 
+/** \file blender/nodes/intern/CMP_nodes/CMP_crop.c
+ *  \ingroup cmpnodes
+ */
+
+
 #include "../CMP_util.h"
 
 /* **************** Crop  ******************** */
@@ -40,7 +45,7 @@ static bNodeSocketType cmp_node_crop_out[]= {
        {       -1, 0, ""       }
 };
 
-static void node_composit_exec_crop(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+static void node_composit_exec_crop(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
 {
        if(in[0]->data) {
                NodeTwoXYs *ntxy= node->storage;
@@ -50,6 +55,13 @@ static void node_composit_exec_crop(void *data, bNode *node, bNodeStack **in, bN
                float *srcfp, *outfp;
                rcti outputrect;
 
+               if(node->custom2) {
+                       ntxy->x1= cbuf->x* ntxy->fac_x1;
+                       ntxy->x2= cbuf->x* ntxy->fac_x2;
+                       ntxy->y1= cbuf->y* ntxy->fac_y1;
+                       ntxy->y2= cbuf->y* ntxy->fac_y2;
+               }
+
                /* check input image size */
                if(cbuf->x <= ntxy->x1 + 1)
                        ntxy->x1= cbuf->x - 1;
@@ -93,27 +105,25 @@ static void node_composit_exec_crop(void *data, bNode *node, bNodeStack **in, bN
 
 static void node_composit_init_crop(bNode* node)
 {
-   NodeTwoXYs *nxy= MEM_callocN(sizeof(NodeTwoXYs), "node xy data");
-   node->storage= nxy;
-   nxy->x1= 0;
-   nxy->x2= 0;
-   nxy->y1= 0;
-   nxy->y2= 0;
+       NodeTwoXYs *nxy= MEM_callocN(sizeof(NodeTwoXYs), "node xy data");
+       node->storage= nxy;
+       nxy->x1= 0;
+       nxy->x2= 0;
+       nxy->y1= 0;
+       nxy->y2= 0;
+}
+
+void register_node_type_cmp_crop(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, CMP_NODE_CROP, "Crop", NODE_CLASS_DISTORT, NODE_OPTIONS,
+               cmp_node_crop_in, cmp_node_crop_out);
+       node_type_size(&ntype, 140, 100, 320);
+       node_type_init(&ntype, node_composit_init_crop);
+       node_type_storage(&ntype, "NodeTwoXYs", node_free_standard_storage, node_copy_standard_storage);
+       node_type_exec(&ntype, node_composit_exec_crop);
+
+       nodeRegisterType(lb, &ntype);
 }
 
-bNodeType cmp_node_crop= {
-       /* *next,*prev */       NULL, NULL,
-       /* type code   */       CMP_NODE_CROP,
-       /* name        */       "Crop",
-       /* width+range */       140, 100, 320,
-       /* class+opts  */       NODE_CLASS_DISTORT, NODE_OPTIONS,
-       /* input sock  */       cmp_node_crop_in,
-       /* output sock */       cmp_node_crop_out,
-       /* storage     */       "NodeTwoXYs",
-       /* execfunc    */       node_composit_exec_crop,
-       /* butfunc     */       NULL,
-       /* initfunc    */       node_composit_init_crop,
-       /* freestoragefunc    */        node_free_standard_storage,
-       /* copystoragefunc    */        node_copy_standard_storage,
-       /* id          */       NULL
-};