Revision: 49250
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49250
Author:   campbellbarton
Date:     2012-07-26 13:29:38 +0000 (Thu, 26 Jul 2012)
Log Message:
-----------
option to use manual size input for scene

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/nodes/COM_MaskNode.cpp
    trunk/blender/source/blender/compositor/operations/COM_MaskOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_MaskOperation.h
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/makesdna/DNA_node_types.h
    trunk/blender/source/blender/makesrna/intern/rna_nodetree.c

Modified: trunk/blender/source/blender/compositor/nodes/COM_MaskNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_MaskNode.cpp      
2012-07-26 12:04:11 UTC (rev 49249)
+++ trunk/blender/source/blender/compositor/nodes/COM_MaskNode.cpp      
2012-07-26 13:29:38 UTC (rev 49250)
@@ -46,9 +46,20 @@
        // always connect the output image
        MaskOperation *operation = new MaskOperation();
        operation->setbNode(editorNode);
-       operation->setMaskWidth(data->xsch * data->size / 100.0f);
-       operation->setMaskHeight(data->ysch * data->size / 100.0f);
 
+       if (editorNode->custom1 & CMP_NODEFLAG_MASK_FIXED) {
+               operation->setMaskWidth(editorNode->custom3);
+               operation->setMaskHeight(editorNode->custom4);
+       }
+       else if (editorNode->custom1 & CMP_NODEFLAG_MASK_FIXED_SCENE) {
+               operation->setMaskWidth(editorNode->custom3 * (data->size / 
100.0f));
+               operation->setMaskHeight(editorNode->custom4 * (data->size / 
100.0f));
+       }
+       else {
+               operation->setMaskWidth(data->xsch * data->size / 100.0f);
+               operation->setMaskHeight(data->ysch * data->size / 100.0f);
+       }
+
        if (outputMask->isConnected()) {
                outputMask->relinkConnections(operation->getOutputSocket());
        }

Modified: 
trunk/blender/source/blender/compositor/operations/COM_MaskOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_MaskOperation.cpp    
2012-07-26 12:04:11 UTC (rev 49249)
+++ trunk/blender/source/blender/compositor/operations/COM_MaskOperation.cpp    
2012-07-26 13:29:38 UTC (rev 49250)
@@ -145,12 +145,11 @@
 {
        if (this->m_mask) {
                if (this->m_rasterMaskHandle == NULL) {
-                       const int width = this->getWidth();
-                       const int height = this->getHeight();
-
                        this->m_rasterMaskHandle = 
BKE_maskrasterize_handle_new();
 
-                       BKE_maskrasterize_handle_init(this->m_rasterMaskHandle, 
this->m_mask, width, height, TRUE, this->m_do_smooth, this->m_do_feather);
+                       BKE_maskrasterize_handle_init(this->m_rasterMaskHandle, 
this->m_mask,
+                                                     this->m_maskWidth, 
this->m_maskHeight,
+                                                     TRUE, this->m_do_smooth, 
this->m_do_feather);
                }
        }
 }
@@ -183,8 +182,8 @@
 
 void MaskOperation::executePixel(float *color, float x, float y, PixelSampler 
sampler)
 {
-       const float xy[2] = {x / (float)this->m_maskWidth, y / 
(float)this->m_maskHeight};
        if (this->m_rasterMaskHandle) {
+               const float xy[2] = {x * this->m_maskWidthInv, y * 
this->m_maskHeightInv};
                color[0] = 
BKE_maskrasterize_handle_sample(this->m_rasterMaskHandle, xy);
        }
        else {

Modified: trunk/blender/source/blender/compositor/operations/COM_MaskOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_MaskOperation.h      
2012-07-26 12:04:11 UTC (rev 49249)
+++ trunk/blender/source/blender/compositor/operations/COM_MaskOperation.h      
2012-07-26 13:29:38 UTC (rev 49250)
@@ -46,8 +46,14 @@
 class MaskOperation : public NodeOperation {
 protected:
        Mask *m_mask;
-       int m_maskWidth;
-       int m_maskHeight;
+
+       /* note, these are used more like aspect,
+        * but they _do_ impact on mask detail */
+       int   m_maskWidth;
+       int   m_maskHeight;
+       float m_maskWidthInv;  /* 1 / m_maskWidth  */
+       float m_maskHeightInv; /* 1 / m_maskHeight */
+
        int m_framenumber;
        bool m_do_smooth;
        bool m_do_feather;
@@ -74,8 +80,16 @@
 
 
        void setMask(Mask *mask) { this->m_mask = mask; }
-       void setMaskWidth(int width) { this->m_maskWidth = width; }
-       void setMaskHeight(int height) { this->m_maskHeight = height; }
+       void setMaskWidth(int width)
+       {
+               this->m_maskWidth    = width;
+               this->m_maskWidthInv = 1.0f / (float)width;
+       }
+       void setMaskHeight(int height)
+       {
+               this->m_maskHeight = height;
+               this->m_maskHeightInv = 1.0f / (float)height;
+       }
        void setFramenumber(int framenumber) { this->m_framenumber = 
framenumber; }
        void setSmooth(bool smooth) { this->m_do_smooth = smooth; }
        void setFeather(bool feather) { this->m_do_feather = feather; }

Modified: trunk/blender/source/blender/editors/space_node/drawnode.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/drawnode.c  2012-07-26 
12:04:11 UTC (rev 49249)
+++ trunk/blender/source/blender/editors/space_node/drawnode.c  2012-07-26 
13:29:38 UTC (rev 49250)
@@ -2494,6 +2494,15 @@
        uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE);
        uiItemR(layout, ptr, "use_feather", 0, NULL, ICON_NONE);
 
+       uiItemR(layout, ptr, "size_source", 0, "", ICON_NONE);
+
+       {
+               bNode *node = ptr->data;
+               if (node->custom1 & (CMP_NODEFLAG_MASK_FIXED | 
CMP_NODEFLAG_MASK_FIXED_SCENE)) {
+                       uiItemR(layout, ptr, "size_x", 0, NULL, ICON_NONE);
+                       uiItemR(layout, ptr, "size_y", 0, NULL, ICON_NONE);
+               }
+       }
 }
 
 static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, 
PointerRNA *ptr)

Modified: trunk/blender/source/blender/makesdna/DNA_node_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_node_types.h      2012-07-26 
12:04:11 UTC (rev 49249)
+++ trunk/blender/source/blender/makesdna/DNA_node_types.h      2012-07-26 
13:29:38 UTC (rev 49250)
@@ -376,7 +376,11 @@
 
 enum {
        CMP_NODEFLAG_MASK_AA         = (1 << 0),
-       CMP_NODEFLAG_MASK_NO_FEATHER = (1 << 1)
+       CMP_NODEFLAG_MASK_NO_FEATHER = (1 << 1),
+
+       /* we may want multiple aspect options, exposed as an rna enum */
+       CMP_NODEFLAG_MASK_FIXED       = (1 << 8),
+       CMP_NODEFLAG_MASK_FIXED_SCENE = (1 << 9)
 };
 
 enum {

Modified: trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_nodetree.c 2012-07-26 
12:04:11 UTC (rev 49249)
+++ trunk/blender/source/blender/makesrna/intern/rna_nodetree.c 2012-07-26 
13:29:38 UTC (rev 49250)
@@ -206,6 +206,30 @@
 #include "DNA_scene_types.h"
 #include "WM_api.h"
 
+static void rna_Node_custom3_set_as_int(PointerRNA *ptr, int value)
+{
+       bNode *node = (bNode *)ptr->data;
+       node->custom3 = value;
+}
+
+static int rna_Node_custom3_get_as_int(PointerRNA *ptr)
+{
+       bNode *node = (bNode *)ptr->data;
+       return (int)node->custom3;
+}
+
+static void rna_Node_custom4_set_as_int(PointerRNA *ptr, int value)
+{
+       bNode *node = (bNode *)ptr->data;
+       node->custom4 = value;
+}
+
+static int rna_Node_custom4_get_as_int(PointerRNA *ptr)
+{
+       bNode *node = (bNode *)ptr->data;
+       return (int)node->custom4;
+}
+
 static StructRNA *rna_Node_refine(struct PointerRNA *ptr)
 {
        bNode *node = (bNode *)ptr->data;
@@ -3137,6 +3161,13 @@
 {
        PropertyRNA *prop;
 
+       static EnumPropertyItem aspect_type_items[] = {
+               {0, "SCENE",   0, "Scene Size",   ""},
+               {CMP_NODEFLAG_MASK_FIXED, "FIXED",   0, "Fixed",   "Use pixel 
size for the buffer"},
+               {CMP_NODEFLAG_MASK_FIXED_SCENE, "FIXED_SCENE",   0, 
"Fixed/Scene", "Pixel size scaled by scene percentage"},
+               {0, NULL, 0, NULL, NULL}
+       };
+
        prop = RNA_def_property(srna, "mask", PROP_POINTER, PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "id");
        RNA_def_property_struct_type(prop, "Mask");
@@ -3152,6 +3183,24 @@
        RNA_def_property_boolean_negative_sdna(prop, NULL, "custom1", 
CMP_NODEFLAG_MASK_NO_FEATHER);
        RNA_def_property_ui_text(prop, "Feather", "Use feather information from 
the mask");
        RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+       prop = RNA_def_property(srna, "size_source", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_bitflag_sdna(prop, NULL, "custom1");
+       RNA_def_property_enum_items(prop, aspect_type_items);
+       RNA_def_property_ui_text(prop, "Size Source", "Where to get the mask 
size from for aspect/size information");
+       RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+       prop = RNA_def_property(srna, "size_x", PROP_INT, PROP_NONE);
+       RNA_def_property_int_funcs(prop, "rna_Node_custom3_get_as_int", 
"rna_Node_custom3_set_as_int", NULL);
+       RNA_def_property_range(prop, 1.0f, 10000.0f);
+       RNA_def_property_ui_text(prop, "X", "");
+       RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+       prop = RNA_def_property(srna, "size_y", PROP_INT, PROP_NONE);
+       RNA_def_property_int_funcs(prop, "rna_Node_custom4_get_as_int", 
"rna_Node_custom4_set_as_int", NULL);
+       RNA_def_property_range(prop, 1.0f, 10000.0f);
+       RNA_def_property_ui_text(prop, "Y", "");
+       RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
 
 static void dev_cmd_transform(StructRNA *srna)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to