Blender V2.61 - r43446

rna_nodetree.c

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * Contributor(s): Blender Foundation (2008), Nathan Letwory, Robin Allen, Bob Holcomb
00019  *
00020  * ***** END GPL LICENSE BLOCK *****
00021  */
00022 
00028 #include <stdlib.h>
00029 #include <string.h>
00030 
00031 #include "RNA_access.h"
00032 #include "RNA_define.h"
00033 #include "RNA_enum_types.h"
00034 
00035 #include "rna_internal.h"
00036 #include "rna_internal_types.h"
00037 
00038 #include "DNA_material_types.h"
00039 #include "DNA_mesh_types.h"
00040 #include "DNA_node_types.h"
00041 #include "DNA_object_types.h"
00042 #include "DNA_scene_types.h"
00043 #include "DNA_texture_types.h"
00044 
00045 #include "BKE_animsys.h"
00046 #include "BKE_main.h"
00047 #include "BKE_node.h"
00048 #include "BKE_image.h"
00049 #include "BKE_texture.h"
00050 
00051 #include "BLI_math.h"
00052 #include "BLI_utildefines.h"
00053 
00054 #include "WM_types.h"
00055 
00056 #include "MEM_guardedalloc.h"
00057 
00058 EnumPropertyItem nodetree_type_items[] = {
00059     {NTREE_SHADER,      "SHADER",       ICON_MATERIAL,      "Shader",       "Shader nodes"  },
00060     {NTREE_TEXTURE,     "TEXTURE",      ICON_TEXTURE,       "Texture",      "Texture nodes"     },
00061     {NTREE_COMPOSIT,    "COMPOSITING",  ICON_RENDERLAYERS,  "Compositing",  "Compositing nodes" },
00062     {0, NULL, 0, NULL, NULL}
00063 };
00064 
00065 
00066 EnumPropertyItem node_socket_type_items[] = {
00067     {SOCK_FLOAT,   "VALUE",     0,    "Value",     ""},
00068     {SOCK_VECTOR,  "VECTOR",    0,    "Vector",    ""},
00069     {SOCK_RGBA,    "RGBA",      0,    "RGBA",      ""},
00070     {SOCK_SHADER,  "SHADER",    0,    "Shader",    ""},
00071     {SOCK_BOOLEAN, "BOOLEAN",   0,    "Boolean",   ""},
00072     {SOCK_MESH,    "MESH",      0,    "Mesh",      ""},
00073     {SOCK_INT,     "INT",       0,    "Int",       ""},
00074     {0, NULL, 0, NULL, NULL}};
00075 
00076 EnumPropertyItem node_math_items[] = {
00077     { 0, "ADD",          0, "Add",          ""},
00078     { 1, "SUBTRACT",     0, "Subtract",     ""},
00079     { 2, "MULTIPLY",     0, "Multiply",     ""},
00080     { 3, "DIVIDE",       0, "Divide",       ""},
00081     { 4, "SINE",         0, "Sine",         ""},
00082     { 5, "COSINE",       0, "Cosine",       ""},
00083     { 6, "TANGENT",      0, "Tangent",      ""},
00084     { 7, "ARCSINE",      0, "Arcsine",      ""},
00085     { 8, "ARCCOSINE",    0, "Arccosine",    ""},
00086     { 9, "ARCTANGENT",   0, "Arctangent",   ""},
00087     {10, "POWER",        0, "Power",        ""},
00088     {11, "LOGARITHM",    0, "Logarithm",    ""},
00089     {12, "MINIMUM",      0, "Minimum",      ""},
00090     {13, "MAXIMUM",      0, "Maximum",      ""},
00091     {14, "ROUND",        0, "Round",        ""},
00092     {15, "LESS_THAN",    0, "Less Than",    ""},
00093     {16, "GREATER_THAN", 0, "Greater Than", ""},
00094     {0, NULL, 0, NULL, NULL}};
00095 
00096 EnumPropertyItem node_vec_math_items[] = {
00097     {0, "ADD",           0, "Add",           ""},
00098     {1, "SUBTRACT",      0, "Subtract",      ""},
00099     {2, "AVERAGE",       0, "Average",       ""},
00100     {3, "DOT_PRODUCT",   0, "Dot Product",   ""},
00101     {4, "CROSS_PRODUCT", 0, "Cross Product", ""},
00102     {5, "NORMALIZE",     0, "Normalize",     ""},
00103     {0, NULL, 0, NULL, NULL}};
00104 
00105 EnumPropertyItem node_filter_items[] = {
00106     {0, "SOFTEN",  0, "Soften",  ""},
00107     {1, "SHARPEN", 0, "Sharpen", ""},
00108     {2, "LAPLACE", 0, "Laplace", ""},
00109     {3, "SOBEL",   0, "Sobel",   ""},
00110     {4, "PREWITT", 0, "Prewitt", ""},
00111     {5, "KIRSCH",  0, "Kirsch",  ""},
00112     {6, "SHADOW",  0, "Shadow",  ""},
00113     {0, NULL, 0, NULL, NULL}};
00114 
00115 EnumPropertyItem prop_noise_basis_items[] = {
00116     {SHD_NOISE_PERLIN, "PERLIN", 0, "Perlin", ""},
00117     {SHD_NOISE_VORONOI_F1, "VORONOI_F1", 0, "Voronoi F1", ""},
00118     {SHD_NOISE_VORONOI_F2, "VORONOI_F2", 0, "Voronoi F2", ""},
00119     {SHD_NOISE_VORONOI_F3, "VORONOI_F3", 0, "Voronoi F3", ""},
00120     {SHD_NOISE_VORONOI_F4, "VORONOI_F4", 0, "Voronoi F4", ""},
00121     {SHD_NOISE_VORONOI_F2_F1, "VORONOI_F2_F1", 0, "Voronoi F2-F1", ""},
00122     {SHD_NOISE_VORONOI_CRACKLE, "VORONOI_CRACKLE", 0, "Voronoi Crackle", ""},
00123     {SHD_NOISE_CELL_NOISE, "CELL_NOISE", 0, "Cell Noise", ""},
00124     {0, NULL, 0, NULL, NULL}};
00125 
00126 EnumPropertyItem prop_noise_type_items[] = {
00127     {SHD_NOISE_SOFT, "SOFT", 0, "Soft", ""},
00128     {SHD_NOISE_HARD, "HARD", 0, "Hard", ""},
00129     {0, NULL, 0, NULL, NULL}};
00130 
00131 #if 0
00132 EnumPropertyItem prop_wave_items[] = {
00133     {SHD_WAVE_SINE, "SINE", 0, "Sine", "Use a sine wave to produce bands"},
00134     {SHD_WAVE_SAW, "SAW", 0, "Saw", "Use a saw wave to produce bands"},
00135     {SHD_WAVE_TRI, "TRI", 0, "Tri", "Use a triangle wave to produce bands"},
00136     {0, NULL, 0, NULL, NULL}};
00137 #endif
00138 
00139 /* Add any new socket value subtype here.
00140  * When adding a new subtype here, make sure you also add it
00141  * to the subtype definitions in DNA_node_types.h.
00142  * This macro is used by the RNA and the internal converter functions
00143  * to define all socket subtypes. The SUBTYPE macro must be defined
00144  * before using this macro, and undefined afterwards.
00145  */
00146 #define NODE_DEFINE_SUBTYPES_INT \
00147 SUBTYPE(INT, Int, NONE, None) \
00148 SUBTYPE(INT, Int, UNSIGNED, Unsigned)
00149 
00150 #define NODE_DEFINE_SUBTYPES_FLOAT \
00151 SUBTYPE(FLOAT, Float, NONE, None) \
00152 SUBTYPE(FLOAT, Float, UNSIGNED, Unsigned) \
00153 SUBTYPE(FLOAT, Float, PERCENTAGE, Percentage) \
00154 SUBTYPE(FLOAT, Float, FACTOR, Factor) \
00155 SUBTYPE(FLOAT, Float, ANGLE, Angle) \
00156 SUBTYPE(FLOAT, Float, TIME, Time) \
00157 SUBTYPE(FLOAT, Float, DISTANCE, Distance)
00158 
00159 #define NODE_DEFINE_SUBTYPES_VECTOR \
00160 SUBTYPE(VECTOR, Vector, NONE, None) \
00161 SUBTYPE(VECTOR, Vector, TRANSLATION, Translation) \
00162 SUBTYPE(VECTOR, Vector, DIRECTION, Direction) \
00163 SUBTYPE(VECTOR, Vector, VELOCITY, Velocity) \
00164 SUBTYPE(VECTOR, Vector, ACCELERATION, Acceleration) \
00165 SUBTYPE(VECTOR, Vector, EULER, Euler) \
00166 SUBTYPE(VECTOR, Vector, XYZ, XYZ)
00167 
00168 #define NODE_DEFINE_SUBTYPES \
00169 NODE_DEFINE_SUBTYPES_INT \
00170 NODE_DEFINE_SUBTYPES_FLOAT \
00171 NODE_DEFINE_SUBTYPES_VECTOR
00172 
00173 #ifdef RNA_RUNTIME
00174 
00175 #include "BLI_linklist.h"
00176 
00177 #include "ED_node.h"
00178 
00179 #include "RE_pipeline.h"
00180 
00181 #include "DNA_scene_types.h"
00182 #include "WM_api.h"
00183 
00184 static StructRNA *rna_Node_refine(struct PointerRNA *ptr)
00185 {
00186     bNode *node = (bNode*)ptr->data;
00187 
00188     switch(node->type) {
00189         
00190         #define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
00191             case ID: return &RNA_##Category##StructName;
00192                 
00193         #include "rna_nodetree_types.h"
00194         
00195         case NODE_GROUP:
00196             return &RNA_NodeGroup;
00197         case NODE_FORLOOP:
00198             return &RNA_NodeForLoop;
00199         case NODE_WHILELOOP:
00200             return &RNA_NodeWhileLoop;
00201             
00202         default:
00203             return &RNA_Node;
00204     }
00205 }
00206 
00207 static StructRNA *rna_NodeTree_refine(struct PointerRNA *ptr)
00208 {
00209     bNodeTree *ntree= (bNodeTree*)ptr->data;
00210 
00211     switch(ntree->type) {
00212         case NTREE_SHADER:
00213             return &RNA_ShaderNodeTree;
00214         case NTREE_COMPOSIT:
00215             return &RNA_CompositorNodeTree;
00216         case NTREE_TEXTURE:
00217             return &RNA_TextureNodeTree;
00218         default:
00219             return &RNA_NodeTree;
00220     }
00221 }
00222 
00223 static char *rna_Node_path(PointerRNA *ptr)
00224 {
00225     bNode *node= (bNode*)ptr->data;
00226 
00227     return BLI_sprintfN("nodes[\"%s\"]", node->name);
00228 }
00229 
00230 static StructRNA *rna_NodeSocket_refine(PointerRNA *ptr)
00231 {
00232     bNodeSocket *sock= (bNodeSocket*)ptr->data;
00233     
00234     if (sock->default_value) {
00235         /* This returns the refined socket type with the full definition
00236          * of the default input value with type and subtype.
00237          */
00238         
00239         #define SUBTYPE(socktype, stypename, id, idname) \
00240         { \
00241             bNodeSocketValue##stypename *value= (bNodeSocketValue##stypename*)sock->default_value; \
00242             if (value->subtype==PROP_##id) \
00243                 return &RNA_NodeSocket##stypename##idname; \
00244         }
00245         
00246         switch (sock->type) {
00247         case SOCK_FLOAT:
00248             NODE_DEFINE_SUBTYPES_FLOAT
00249             break;
00250         case SOCK_INT:
00251             NODE_DEFINE_SUBTYPES_INT
00252             break;
00253         case SOCK_BOOLEAN:
00254             return &RNA_NodeSocketBoolean;
00255             break;
00256         case SOCK_VECTOR:
00257             NODE_DEFINE_SUBTYPES_VECTOR
00258             break;
00259         case SOCK_RGBA:
00260             return &RNA_NodeSocketRGBA;
00261             break;
00262         case SOCK_SHADER:
00263             return &RNA_NodeSocketShader;
00264         }
00265         
00266         #undef SUBTYPE
00267     }
00268     
00269     return &RNA_NodeSocket;
00270 }
00271 
00272 static char *rna_NodeSocket_path(PointerRNA *ptr)
00273 {
00274     bNodeTree *ntree= (bNodeTree*)ptr->id.data;
00275     bNodeSocket *sock= (bNodeSocket*)ptr->data;
00276     bNode *node;
00277     int socketindex;
00278     
00279     /* group sockets */
00280     socketindex = BLI_findindex(&ntree->inputs, sock);
00281     if (socketindex != -1)
00282         return BLI_sprintfN("inputs[%d]", socketindex);
00283     
00284     socketindex = BLI_findindex(&ntree->outputs, sock);
00285     if (socketindex != -1)
00286         return BLI_sprintfN("outputs[%d]", socketindex);
00287     
00288     /* node sockets */
00289     if (!nodeFindNode(ntree, sock, &node, NULL, NULL)) return NULL;
00290     
00291     socketindex = BLI_findindex(&node->inputs, sock);
00292     if (socketindex != -1)
00293         return BLI_sprintfN("nodes[\"%s\"].inputs[%d]", node->name, socketindex);
00294     
00295     socketindex = BLI_findindex(&node->outputs, sock);
00296     if (socketindex != -1)
00297         return BLI_sprintfN("nodes[\"%s\"].outputs[%d]", node->name, socketindex);
00298     
00299     return NULL;
00300 }
00301 
00302 /* Button Set Funcs for Matte Nodes */
00303 static void rna_Matte_t1_set(PointerRNA *ptr, float value)
00304 {
00305     bNode *node= (bNode*)ptr->data;
00306     NodeChroma *chroma = node->storage;
00307     
00308     chroma->t1 = value;
00309     
00310     if(value < chroma->t2) 
00311         chroma->t2 = value;
00312 }
00313 
00314 static void rna_Matte_t2_set(PointerRNA *ptr, float value)
00315 {
00316     bNode *node= (bNode*)ptr->data;
00317     NodeChroma *chroma = node->storage;
00318     
00319     if(value > chroma->t1) 
00320         value = chroma->t1;
00321     
00322     chroma->t2 = value;
00323 }
00324 
00325 static void rna_Image_start_frame_set(PointerRNA *ptr, int value)
00326 {
00327     bNode *node= (bNode*)ptr->data;
00328     NodeImageFile *image = node->storage;
00329     
00330     CLAMP(value, MINFRAME, image->efra); 
00331     image->sfra= value;
00332 }
00333 
00334 static void rna_Image_end_frame_set(PointerRNA *ptr, int value)
00335 {
00336     bNode *node= (bNode*)ptr->data;
00337     NodeImageFile *image = node->storage;
00338 
00339     CLAMP(value, image->sfra, MAXFRAME);
00340     image->efra= value;
00341 }
00342 
00343 static void rna_Node_scene_set(PointerRNA *ptr, PointerRNA value)
00344 {
00345     bNode *node= (bNode*)ptr->data;
00346 
00347     if (node->id) {
00348         id_us_min(node->id);
00349         node->id= NULL;
00350     }
00351 
00352     node->id= value.data;
00353 
00354     id_us_plus(node->id);
00355 }
00356 
00357 
00358 
00359 static void node_update(Main *bmain, Scene *UNUSED(scene), bNodeTree *ntree, bNode *node)
00360 {
00361     ED_node_generic_update(bmain, ntree, node);
00362 }
00363 
00364 static void rna_Node_update(Main *bmain, Scene *scene, PointerRNA *ptr)
00365 {
00366     bNodeTree *ntree= (bNodeTree*)ptr->id.data;
00367     bNode *node= (bNode*)ptr->data;
00368 
00369     node_update(bmain, scene, ntree, node);
00370 }
00371 
00372 static void rna_Node_image_update(Main *bmain, Scene *scene, PointerRNA *ptr)
00373 {
00374     bNodeTree *ntree= (bNodeTree*)ptr->id.data;
00375     bNode *node= (bNode*)ptr->data;
00376 
00377     node_update(bmain, scene, ntree, node);
00378     WM_main_add_notifier(NC_IMAGE, NULL);
00379 }
00380 
00381 static void rna_Node_material_update(Main *bmain, Scene *scene, PointerRNA *ptr)
00382 {
00383     bNodeTree *ntree= (bNodeTree*)ptr->id.data;
00384     bNode *node= (bNode*)ptr->data;
00385 
00386     if(node->id)
00387         nodeSetActive(ntree, node);
00388 
00389     node_update(bmain, scene, ntree, node);
00390 }
00391 
00392 static void rna_NodeGroup_update(Main *bmain, Scene *scene, PointerRNA *ptr)
00393 {
00394     bNodeTree *ntree= (bNodeTree*)ptr->id.data;
00395     bNode *node= (bNode*)ptr->data;
00396     
00397     ntreeUpdateTree((bNodeTree *)node->id);
00398     
00399     node_update(bmain, scene, ntree, node);
00400 }
00401 
00402 static void rna_Node_name_set(PointerRNA *ptr, const char *value)
00403 {
00404     bNodeTree *ntree= (bNodeTree*)ptr->id.data;
00405     bNode *node= (bNode*)ptr->data;
00406     char oldname[sizeof(node->name)];
00407     
00408     /* make a copy of the old name first */
00409     BLI_strncpy(oldname, node->name, sizeof(node->name));
00410     /* set new name */
00411     BLI_strncpy_utf8(node->name, value, sizeof(node->name));
00412     
00413     nodeUniqueName(ntree, node);
00414     
00415     /* fix all the animation data which may link to this */
00416     BKE_all_animdata_fix_paths_rename("nodes", oldname, node->name);
00417 }
00418 
00419 static void rna_NodeSocket_update(Main *bmain, Scene *scene, PointerRNA *ptr)
00420 {
00421     bNodeTree *ntree= (bNodeTree*)ptr->id.data;
00422     bNodeSocket *sock= (bNodeSocket*)ptr->data;
00423     bNode *node;
00424     
00425     if (nodeFindNode(ntree, sock, &node, NULL, NULL))
00426         node_update(bmain, scene, ntree, node);
00427 }
00428 
00429 static void rna_NodeGroupSocket_update(Main *bmain, Scene *scene, PointerRNA *ptr)
00430 {
00431     bNodeTree *ntree= (bNodeTree*)ptr->id.data;
00432     bNodeSocket *sock= (bNodeSocket*)ptr->data;
00433     bNode *node;
00434     
00435     ntreeUpdateTree(ntree);
00436     
00437     if (nodeFindNode(ntree, sock, &node, NULL, NULL))
00438         node_update(bmain, scene, ntree, node);
00439 }
00440 
00441 #if 0 /* UNUSED */
00442 static void rna_NodeLink_update(Main *bmain, Scene *scene, PointerRNA *ptr)
00443 {
00444     bNodeTree *ntree= (bNodeTree*)ptr->id.data;
00445 
00446     ntree->update |= NTREE_UPDATE_LINKS;
00447     ntreeUpdateTree(ntree);
00448 }
00449 #endif
00450 
00451 static void rna_NodeSocketInt_range(PointerRNA *ptr, int *min, int *max)
00452 {
00453     bNodeSocket *sock= (bNodeSocket*)ptr->data;
00454     bNodeSocketValueInt *val= (bNodeSocketValueInt*)sock->default_value;
00455     *min = val->min;
00456     *max = val->max;
00457 }
00458 
00459 static void rna_NodeSocketFloat_range(PointerRNA *ptr, float *min, float *max)
00460 {
00461     bNodeSocket *sock= (bNodeSocket*)ptr->data;
00462     bNodeSocketValueFloat *val= (bNodeSocketValueFloat*)sock->default_value;
00463     *min = val->min;
00464     *max = val->max;
00465 }
00466 
00467 static void rna_NodeSocketVector_range(PointerRNA *ptr, float *min, float *max)
00468 {
00469     bNodeSocket *sock= (bNodeSocket*)ptr->data;
00470     bNodeSocketValueVector *val= (bNodeSocketValueVector*)sock->default_value;
00471     *min = val->min;
00472     *max = val->max;
00473 }
00474 
00475 static void rna_Node_image_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr)
00476 {
00477     bNode *node= (bNode*)ptr->data;
00478     Image *ima = (Image *)node->id;
00479     ImageUser *iuser= node->storage;
00480     
00481     BKE_image_multilayer_index(ima->rr, iuser);
00482     BKE_image_signal(ima, iuser, IMA_SIGNAL_SRC_CHANGE);
00483     
00484     rna_Node_update(bmain, scene, ptr);
00485 }
00486 
00487 static EnumPropertyItem *renderresult_layers_add_enum(RenderLayer *rl)
00488 {
00489     EnumPropertyItem *item= NULL;
00490     EnumPropertyItem tmp = {0, "", 0, "", ""};
00491     int i=0, totitem=0;
00492     
00493     while (rl) {
00494         tmp.identifier = rl->name;
00495         tmp.name= rl->name;
00496         tmp.value = i++;
00497         RNA_enum_item_add(&item, &totitem, &tmp);
00498         rl=rl->next;
00499     }
00500     
00501     RNA_enum_item_end(&item, &totitem);
00502 
00503     return item;
00504 }
00505 
00506 static EnumPropertyItem *rna_Node_image_layer_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free)
00507 {
00508     bNode *node= (bNode*)ptr->data;
00509     Image *ima = (Image *)node->id;
00510     EnumPropertyItem *item= NULL;
00511     RenderLayer *rl;
00512     
00513     if (!ima || !(ima->rr)) return NULL;
00514 
00515     rl = ima->rr->layers.first;
00516     item = renderresult_layers_add_enum(rl);
00517     
00518     *free= 1;
00519     
00520     return item;
00521 }
00522 
00523 static EnumPropertyItem *rna_Node_scene_layer_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free)
00524 {
00525     bNode *node= (bNode*)ptr->data;
00526     Scene *sce = (Scene *)node->id;
00527     EnumPropertyItem *item= NULL;
00528     RenderLayer *rl;
00529     
00530     if (!sce) return NULL;
00531     
00532     rl = sce->r.layers.first;
00533     item = renderresult_layers_add_enum(rl);
00534     
00535     *free= 1;
00536     
00537     return item;
00538 }
00539 
00540 static EnumPropertyItem *rna_Node_channel_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free)
00541 {
00542     bNode *node= (bNode*)ptr->data;
00543     EnumPropertyItem *item= NULL;
00544     EnumPropertyItem tmp = {0, "", 0, "", ""};
00545     int totitem=0;
00546     
00547     switch(node->custom1) {
00548         case CMP_NODE_CHANNEL_MATTE_CS_RGB:
00549             tmp.identifier= "R"; tmp.name= "R"; tmp.value= 1;
00550             RNA_enum_item_add(&item, &totitem, &tmp);
00551             tmp.identifier= "G"; tmp.name= "G"; tmp.value= 2;
00552             RNA_enum_item_add(&item, &totitem, &tmp);
00553             tmp.identifier= "B"; tmp.name= "B"; tmp.value= 3;
00554             RNA_enum_item_add(&item, &totitem, &tmp);
00555             break;
00556         case CMP_NODE_CHANNEL_MATTE_CS_HSV:
00557             tmp.identifier= "H"; tmp.name= "H"; tmp.value= 1;
00558             RNA_enum_item_add(&item, &totitem, &tmp);
00559             tmp.identifier= "S"; tmp.name= "S"; tmp.value= 2;
00560             RNA_enum_item_add(&item, &totitem, &tmp);
00561             tmp.identifier= "V"; tmp.name= "V"; tmp.value= 3;
00562             RNA_enum_item_add(&item, &totitem, &tmp);
00563             break;
00564         case CMP_NODE_CHANNEL_MATTE_CS_YUV:
00565             tmp.identifier= "Y"; tmp.name= "Y"; tmp.value= 1;
00566             RNA_enum_item_add(&item, &totitem, &tmp);
00567             tmp.identifier= "G"; tmp.name= "U"; tmp.value= 2;
00568             RNA_enum_item_add(&item, &totitem, &tmp);
00569             tmp.identifier= "V"; tmp.name= "V"; tmp.value= 3;
00570             RNA_enum_item_add(&item, &totitem, &tmp);
00571             break;
00572         case CMP_NODE_CHANNEL_MATTE_CS_YCC:
00573             tmp.identifier= "Y"; tmp.name= "Y"; tmp.value= 1;
00574             RNA_enum_item_add(&item, &totitem, &tmp);
00575             tmp.identifier= "CB"; tmp.name= "Cr"; tmp.value= 2;
00576             RNA_enum_item_add(&item, &totitem, &tmp);
00577             tmp.identifier= "CR"; tmp.name= "Cb"; tmp.value= 3;
00578             RNA_enum_item_add(&item, &totitem, &tmp);
00579             break;
00580         default:
00581             break;
00582     }
00583 
00584     RNA_enum_item_end(&item, &totitem);
00585     *free= 1;
00586     
00587     return item;
00588 }
00589 
00590 static bNode *rna_NodeTree_node_new(bNodeTree *ntree, bContext *UNUSED(C), ReportList *reports, int type, bNodeTree *group)
00591 {
00592     bNode *node;
00593     bNodeTemplate ntemp;
00594 
00595     if (type == NODE_GROUP && group == NULL) {
00596         BKE_reportf(reports, RPT_ERROR, "node type \'GROUP\' missing group argument");
00597         return NULL;
00598     }
00599     
00600     ntemp.type = type;
00601     ntemp.ngroup = group;
00602     node = nodeAddNode(ntree, &ntemp);
00603     
00604     if (node == NULL) {
00605         BKE_reportf(reports, RPT_ERROR, "Unable to create node");
00606     }
00607     else {
00608         ntreeUpdateTree(ntree); /* update group node socket links*/
00609         nodeUpdate(ntree, node);
00610         WM_main_add_notifier(NC_NODE|NA_EDITED, ntree);
00611 
00612         if (group)
00613             id_us_plus(&group->id);
00614     }
00615 
00616     return node;
00617 }
00618 
00619 static bNode *rna_NodeTree_node_composite_new(bNodeTree *ntree, bContext *C, ReportList *reports, int type, bNodeTree *group)
00620 {
00621     /* raises error on failier */
00622     bNode *node= rna_NodeTree_node_new(ntree, C, reports, type, group);
00623     
00624     if (node) {
00625         if(ELEM4(node->type, CMP_NODE_COMPOSITE, CMP_NODE_DEFOCUS, CMP_NODE_OUTPUT_FILE, CMP_NODE_R_LAYERS)) {
00626             /* annoying, find the node tree we are in, scene can be NULL */
00627             Scene *scene;
00628             for(scene= CTX_data_main(C)->scene.first; scene; scene= scene->id.next) {
00629                 if(scene->nodetree == ntree) {
00630                     break;
00631                 }
00632             }
00633             node->id= (ID *)scene;
00634             id_us_plus(node->id);
00635         }
00636 
00637         ntreeCompositForceHidden(ntree, CTX_data_scene(C));
00638         ntreeUpdateTree(ntree);
00639     }
00640 
00641     return node;
00642 }
00643 
00644 static bNode *rna_NodeTree_node_texture_new(bNodeTree *ntree, bContext *C, ReportList *reports, int type, bNodeTree *group)
00645 {
00646     /* raises error on failier */
00647     bNode *node= rna_NodeTree_node_new(ntree, C, reports, type, group);
00648 
00649     if (node) {
00650         ntreeTexCheckCyclics(ntree);
00651     }
00652 
00653     return node;
00654 }
00655 
00656 static void rna_NodeTree_node_remove(bNodeTree *ntree, ReportList *reports, bNode *node)
00657 {
00658     if (BLI_findindex(&ntree->nodes, node) == -1) {
00659         BKE_reportf(reports, RPT_ERROR, "Unable to locate node '%s' in nodetree", node->name);
00660     }
00661     else {
00662         if (node->id)
00663             id_us_min(node->id);
00664 
00665         nodeFreeNode(ntree, node);
00666         ntreeUpdateTree(ntree); /* update group node socket links*/
00667 
00668         WM_main_add_notifier(NC_NODE|NA_EDITED, ntree);
00669     }
00670 }
00671 
00672 static void rna_NodeTree_node_clear(bNodeTree *ntree)
00673 {
00674     bNode *node= ntree->nodes.first;
00675 
00676     while(node) {
00677         bNode *next_node= node->next;
00678 
00679         if (node->id)
00680             id_us_min(node->id);
00681 
00682         nodeFreeNode(ntree, node);
00683 
00684         node= next_node;
00685     }
00686 
00687     ntreeUpdateTree(ntree); /* update group node socket links*/
00688 
00689     WM_main_add_notifier(NC_NODE|NA_EDITED, ntree);
00690 }
00691 
00692 static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, ReportList *reports, bNodeSocket *in, bNodeSocket *out)
00693 {
00694     bNodeLink *ret;
00695     bNode *fromnode= NULL, *tonode= NULL;
00696     int from_in_out, to_in_out;
00697 
00698     nodeFindNode(ntree, in, &fromnode, NULL, &from_in_out);
00699     nodeFindNode(ntree, out, &tonode, NULL, &to_in_out);
00700     
00701     if (&from_in_out == &to_in_out) {
00702         BKE_reportf(reports, RPT_ERROR, "Same input/output direction of sockets");
00703         return NULL;
00704     }
00705 
00706     /* unlink node input socket */
00707     nodeRemSocketLinks(ntree, out);
00708 
00709     ret= nodeAddLink(ntree, fromnode, in, tonode, out);
00710     
00711     if(ret) {
00712         nodeUpdate(ntree, tonode);
00713 
00714         ntreeUpdateTree(ntree);
00715 
00716         WM_main_add_notifier(NC_NODE|NA_EDITED, ntree);
00717     }
00718     return ret;
00719 }
00720 
00721 static void rna_NodeTree_link_remove(bNodeTree *ntree, ReportList *reports, bNodeLink *link)
00722 {
00723     if (BLI_findindex(&ntree->links, link) == -1) {
00724         BKE_reportf(reports, RPT_ERROR, "Unable to locate link in nodetree");
00725     }
00726     else {
00727         nodeRemLink(ntree, link);
00728         ntreeUpdateTree(ntree);
00729 
00730         WM_main_add_notifier(NC_NODE|NA_EDITED, ntree);
00731     }
00732 }
00733 
00734 static void rna_NodeTree_link_clear(bNodeTree *ntree)
00735 {
00736     bNodeLink *link= ntree->links.first;
00737 
00738     while(link) {
00739         bNodeLink *next_link= link->next;
00740 
00741         nodeRemLink(ntree, link);
00742 
00743         link= next_link;
00744     }
00745     ntreeUpdateTree(ntree);
00746 
00747     WM_main_add_notifier(NC_NODE|NA_EDITED, ntree);
00748 }
00749 
00750 static bNodeSocket *rna_NodeTree_input_new(bNodeTree *ntree, ReportList *UNUSED(reports), const char *name, int type)
00751 {
00752     /* XXX should check if tree is a group here! no good way to do this currently. */
00753     bNodeSocket *gsock= node_group_add_socket(ntree, name, type, SOCK_IN);
00754     
00755     ntree->update |= NTREE_UPDATE_GROUP_IN;
00756     ntreeUpdateTree(ntree);
00757     WM_main_add_notifier(NC_NODE|NA_EDITED, ntree);
00758     return gsock;
00759 }
00760 
00761 static bNodeSocket *rna_NodeTree_output_new(bNodeTree *ntree, ReportList *UNUSED(reports), const char *name, int type)
00762 {
00763     /* XXX should check if tree is a group here! no good way to do this currently. */
00764     bNodeSocket *gsock= node_group_add_socket(ntree, name, type, SOCK_OUT);
00765     
00766     ntree->update |= NTREE_UPDATE_GROUP_OUT;
00767     ntreeUpdateTree(ntree);
00768     WM_main_add_notifier(NC_NODE|NA_EDITED, ntree);
00769     return gsock;
00770 }
00771 
00772 static bNodeSocket *rna_NodeTree_input_expose(bNodeTree *ntree, ReportList *reports, bNodeSocket *sock, int add_link)
00773 {
00774     bNode *node;
00775     bNodeSocket *gsock;
00776     int index, in_out;
00777     
00778     if (!nodeFindNode(ntree, sock, &node, &index, &in_out))
00779         BKE_reportf(reports, RPT_ERROR, "Unable to locate socket in nodetree");
00780     else if (in_out!=SOCK_IN)
00781         BKE_reportf(reports, RPT_ERROR, "Socket is not an input");
00782     else {
00783         /* XXX should check if tree is a group here! no good way to do this currently. */
00784         gsock = node_group_add_socket(ntree, sock->name, sock->type, SOCK_IN);
00785         if (add_link)
00786             nodeAddLink(ntree, NULL, gsock, node, sock);
00787         
00788         ntree->update |= NTREE_UPDATE_GROUP_IN;
00789         ntreeUpdateTree(ntree);
00790         WM_main_add_notifier(NC_NODE|NA_EDITED, ntree);
00791         return gsock;
00792     }
00793     return NULL;
00794 }
00795 
00796 static bNodeSocket *rna_NodeTree_output_expose(bNodeTree *ntree, ReportList *reports, bNodeSocket *sock, int add_link)
00797 {
00798     bNode *node;
00799     bNodeSocket *gsock;
00800     int index, in_out;
00801     
00802     if (!nodeFindNode(ntree, sock, &node, &index, &in_out))
00803         BKE_reportf(reports, RPT_ERROR, "Unable to locate socket in nodetree");
00804     else if (in_out!=SOCK_OUT)
00805         BKE_reportf(reports, RPT_ERROR, "Socket is not an output");
00806     else {
00807         /* XXX should check if tree is a group here! no good way to do this currently. */
00808         gsock = node_group_add_socket(ntree, sock->name, sock->type, SOCK_OUT);
00809         if (add_link)
00810             nodeAddLink(ntree, node, sock, NULL, gsock);
00811         
00812         ntree->update |= NTREE_UPDATE_GROUP_OUT;
00813         ntreeUpdateTree(ntree);
00814         WM_main_add_notifier(NC_NODE|NA_EDITED, ntree);
00815         return gsock;
00816     }
00817     return NULL;
00818 }
00819 
00820 static void rna_Mapping_Node_update(Main *bmain, Scene *scene, PointerRNA *ptr)
00821 {
00822     bNode *node = ptr->data;
00823     init_tex_mapping(node->storage);
00824     rna_Node_update(bmain, scene, ptr);
00825 }
00826 
00827 #else
00828 
00829 static EnumPropertyItem prop_image_layer_items[] = {
00830 { 0, "PLACEHOLDER",          0, "Placeholder",          ""},
00831 {0, NULL, 0, NULL, NULL}};
00832 
00833 static EnumPropertyItem prop_scene_layer_items[] = {
00834 { 0, "PLACEHOLDER",          0, "Placeholder",          ""},
00835 {0, NULL, 0, NULL, NULL}};
00836 
00837 static EnumPropertyItem prop_tri_channel_items[] = {
00838 { 1, "R", 0, "R", ""},
00839 { 2, "G", 0, "G", ""},
00840 { 3, "B", 0, "B", ""},
00841 {0, NULL, 0, NULL, NULL}};
00842 
00843 static EnumPropertyItem node_flip_items[] = {
00844 {0, "X",  0, "Flip X",     ""},
00845 {1, "Y",  0, "Flip Y",     ""},
00846 {2, "XY", 0, "Flip X & Y", ""},
00847 {0, NULL, 0, NULL, NULL}};
00848 
00849 static EnumPropertyItem node_ycc_items[] = {
00850 { 0, "ITUBT601", 0, "ITU 601",  ""},
00851 { 1, "ITUBT709", 0, "ITU 709",  ""},
00852 { 2, "JFIF",     0, "Jpeg",     ""},
00853 {0, NULL, 0, NULL, NULL}};
00854 
00855 static EnumPropertyItem node_glossy_items[] = {
00856 {SHD_GLOSSY_SHARP,    "SHARP",    0, "Sharp",    ""},
00857 {SHD_GLOSSY_BECKMANN, "BECKMANN", 0, "Beckmann", ""},
00858 {SHD_GLOSSY_GGX,      "GGX",      0, "GGX",      ""},
00859 {0, NULL, 0, NULL, NULL}};
00860 
00861 #define MaxNodes 50000
00862 
00863 enum
00864 {
00865     Category_GroupNode,
00866     Category_LoopNode,
00867     Category_LayoutNode,
00868     Category_ShaderNode,
00869     Category_CompositorNode,
00870     Category_TextureNode,
00871 };
00872 
00873 typedef struct NodeInfo
00874 {
00875     int defined;
00876     int category;
00877     const char *enum_name;
00878     const char *struct_name;
00879     const char *base_name;
00880     int icon;
00881     const char *ui_name;
00882     const char *ui_desc;
00883 } NodeInfo;
00884 
00885 static NodeInfo nodes[MaxNodes];
00886 
00887 static void reg_node(int ID, int category, const char *enum_name, const char *struct_name,
00888                      const char *base_name, const char *ui_name, const char *ui_desc)
00889 {
00890     NodeInfo *ni = nodes + ID;
00891     
00892     ni->defined = 1;
00893     ni->category = category;
00894     ni->enum_name = enum_name;
00895     ni->struct_name = struct_name;
00896     ni->base_name = base_name;
00897     ni->ui_name = ui_name;
00898     ni->ui_desc = ui_desc;
00899 }
00900 
00901 static void init(void)
00902 {
00903     memset(nodes, 0, sizeof nodes);
00904     
00905     #define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
00906         reg_node(ID, Category_##Category, EnumName, STRINGIFY_ARG(Category##StructName), #Category, UIName, UIDesc);
00907         
00908     #include "rna_nodetree_types.h"
00909     
00910     reg_node(NODE_GROUP, Category_GroupNode, "GROUP", "NodeGroup", "Node", "Group", "");
00911     reg_node(NODE_FORLOOP, Category_LoopNode, "FORLOOP", "NodeForLoop", "Node", "ForLoop", "");
00912     reg_node(NODE_WHILELOOP, Category_LoopNode, "WHILELOOP", "NodeWhileLoop", "Node", "WhileLoop", "");
00913     reg_node(NODE_FRAME, Category_LayoutNode, "FRAME", "NodeFrame", "Node", "Frame", "");
00914 }
00915 
00916 static StructRNA* def_node(BlenderRNA *brna, int node_id)
00917 {
00918     StructRNA *srna;
00919     NodeInfo *node = nodes + node_id;
00920     
00921     srna = RNA_def_struct(brna, node->struct_name, node->base_name);
00922     RNA_def_struct_ui_text(srna, node->ui_name, node->ui_desc);
00923     RNA_def_struct_sdna(srna, "bNode");
00924     
00925     return srna;
00926 }
00927 
00928 static void alloc_node_type_items(EnumPropertyItem *items, int category)
00929 {
00930     int i;
00931     int count = 3;
00932     EnumPropertyItem *item  = items;
00933     
00934     for(i=0; i<MaxNodes; i++)
00935         if(nodes[i].defined && nodes[i].category == category)
00936             count++;
00937         
00938     /*item = items = MEM_callocN(count * sizeof(EnumPropertyItem), "alloc_node_type_items");*/
00939     
00940     for(i=0; i<MaxNodes; i++) {
00941         NodeInfo *node = nodes + i;
00942         if(node->defined && node->category == category) {
00943             item->value = i;
00944             item->identifier = node->enum_name;
00945             item->icon = node->icon;
00946             item->name = node->ui_name;
00947             item->description = node->ui_desc;
00948         
00949             item++;
00950         }
00951     }
00952     
00953     item->value = NODE_DYNAMIC;
00954     item->identifier = "SCRIPT";
00955     item->icon = 0;
00956     item->name = "Script";
00957     item->description = "";
00958     
00959     item++;
00960     
00961     item->value = NODE_GROUP;
00962     item->identifier = "GROUP";
00963     item->icon = 0;
00964     item->name = "Group";
00965     item->description = "";
00966     
00967     item++;
00968     
00969     /* NOTE!, increase 'count' when adding items here */
00970     
00971     memset(item, 0, sizeof(EnumPropertyItem));
00972 }
00973 
00974 
00975 /* -- Common nodes ---------------------------------------------------------- */
00976 
00977 static void def_group(StructRNA *srna)
00978 {
00979     PropertyRNA *prop;
00980     
00981     prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
00982     RNA_def_property_pointer_sdna(prop, NULL, "id");
00983     RNA_def_property_struct_type(prop, "NodeTree");
00984     RNA_def_property_flag(prop, PROP_EDITABLE);
00985     RNA_def_property_ui_text(prop, "Node Tree", "");
00986     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeGroup_update");
00987 }
00988 
00989 static void def_forloop(StructRNA *srna)
00990 {
00991     PropertyRNA *prop;
00992     
00993     prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
00994     RNA_def_property_pointer_sdna(prop, NULL, "id");
00995     RNA_def_property_struct_type(prop, "NodeTree");
00996     RNA_def_property_flag(prop, PROP_EDITABLE);
00997     RNA_def_property_ui_text(prop, "Node Tree", "");
00998     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeGroup_update");
00999 }
01000 
01001 static void def_whileloop(StructRNA *srna)
01002 {
01003     PropertyRNA *prop;
01004     
01005     prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
01006     RNA_def_property_pointer_sdna(prop, NULL, "id");
01007     RNA_def_property_struct_type(prop, "NodeTree");
01008     RNA_def_property_flag(prop, PROP_EDITABLE);
01009     RNA_def_property_ui_text(prop, "Node Tree", "");
01010     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeGroup_update");
01011 
01012     prop = RNA_def_property(srna, "max_iterations", PROP_INT, PROP_NONE);
01013     RNA_def_property_int_sdna(prop, NULL, "custom1");
01014     RNA_def_property_range(prop, 0.0f, SHRT_MAX);
01015     RNA_def_property_ui_text(prop, "Max. Iterations", "Limit for number of iterations");
01016     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeGroup_update");
01017 }
01018 
01019 static void def_frame(StructRNA *srna)
01020 {
01021 //  PropertyRNA *prop;
01022     
01023 }
01024 
01025 static void def_math(StructRNA *srna)
01026 {
01027     PropertyRNA *prop;
01028     
01029     prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE);
01030     RNA_def_property_enum_sdna(prop, NULL, "custom1");
01031     RNA_def_property_enum_items(prop, node_math_items);
01032     RNA_def_property_ui_text(prop, "Operation", "");
01033     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01034 }
01035 
01036 static void def_vector_math(StructRNA *srna)
01037 {
01038     PropertyRNA *prop;
01039     
01040     prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE);
01041     RNA_def_property_enum_sdna(prop, NULL, "custom1");
01042     RNA_def_property_enum_items(prop, node_vec_math_items);
01043     RNA_def_property_ui_text(prop, "Operation", "");
01044     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01045 }
01046 
01047 static void def_rgb_curve(StructRNA *srna)
01048 {
01049     PropertyRNA *prop;
01050     
01051     prop = RNA_def_property(srna, "mapping", PROP_POINTER, PROP_NONE);
01052     RNA_def_property_pointer_sdna(prop, NULL, "storage");
01053     RNA_def_property_struct_type(prop, "CurveMapping");
01054     RNA_def_property_ui_text(prop, "Mapping", "");
01055     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01056 }
01057 
01058 static void def_vector_curve(StructRNA *srna)
01059 {
01060     PropertyRNA *prop;
01061     
01062     prop = RNA_def_property(srna, "mapping", PROP_POINTER, PROP_NONE);
01063     RNA_def_property_pointer_sdna(prop, NULL, "storage");
01064     RNA_def_property_struct_type(prop, "CurveMapping");
01065     RNA_def_property_ui_text(prop, "Mapping", "");
01066     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01067 }
01068 
01069 static void def_time(StructRNA *srna)
01070 {
01071     PropertyRNA *prop;
01072     
01073     prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
01074     RNA_def_property_pointer_sdna(prop, NULL, "storage");
01075     RNA_def_property_struct_type(prop, "CurveMapping");
01076     RNA_def_property_ui_text(prop, "Curve", "");
01077     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01078     
01079     prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE);
01080     RNA_def_property_int_sdna(prop, NULL, "custom1");
01081     RNA_def_property_ui_text(prop, "Start Frame", "");
01082     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01083     
01084     prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE);
01085     RNA_def_property_int_sdna(prop, NULL, "custom2");
01086     RNA_def_property_ui_text(prop, "End Frame", "");
01087     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01088 }
01089 
01090 static void def_colorramp(StructRNA *srna)
01091 {
01092     PropertyRNA *prop;
01093     
01094     prop = RNA_def_property(srna, "color_ramp", PROP_POINTER, PROP_NONE);
01095     RNA_def_property_pointer_sdna(prop, NULL, "storage");
01096     RNA_def_property_struct_type(prop, "ColorRamp");
01097     RNA_def_property_ui_text(prop, "Color Ramp", "");
01098     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01099 }
01100 
01101 static void def_mix_rgb(StructRNA *srna)
01102 {
01103     PropertyRNA *prop;
01104     
01105     prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
01106     RNA_def_property_enum_sdna(prop, NULL, "custom1");
01107     RNA_def_property_enum_items(prop, ramp_blend_items);
01108     RNA_def_property_ui_text(prop, "Blend Type", "");
01109     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01110     
01111     prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
01112     RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1);
01113     RNA_def_property_ui_text(prop, "Alpha", "Include alpha of second input in this operation");
01114     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01115 }
01116 
01117 static void def_texture(StructRNA *srna)
01118 {
01119     PropertyRNA *prop;
01120     
01121     prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE);
01122     RNA_def_property_pointer_sdna(prop, NULL, "id");
01123     RNA_def_property_struct_type(prop, "Texture");
01124     RNA_def_property_flag(prop, PROP_EDITABLE);
01125     RNA_def_property_ui_text(prop, "Texture", "");
01126     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01127     
01128     prop = RNA_def_property(srna, "node_output", PROP_INT, PROP_NONE);
01129     RNA_def_property_int_sdna(prop, NULL, "custom1");
01130     RNA_def_property_ui_text(prop, "Node Output", "For node-based textures, which output node to use");
01131     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01132 }
01133 
01134 
01135 /* -- Shader Nodes ---------------------------------------------------------- */
01136 
01137 static void def_sh_material(StructRNA *srna)
01138 {
01139     PropertyRNA *prop;
01140 
01141     prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
01142     RNA_def_property_pointer_sdna(prop, NULL, "id");
01143     RNA_def_property_struct_type(prop, "Material");
01144     RNA_def_property_flag(prop, PROP_EDITABLE);
01145     RNA_def_property_ui_text(prop, "Material", "");
01146     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_material_update");
01147 
01148     prop = RNA_def_property(srna, "use_diffuse", PROP_BOOLEAN, PROP_NONE);
01149     RNA_def_property_boolean_sdna(prop, NULL, "custom1", SH_NODE_MAT_DIFF);
01150     RNA_def_property_ui_text(prop, "Diffuse", "Material Node outputs Diffuse");
01151     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01152 
01153     prop = RNA_def_property(srna, "use_specular", PROP_BOOLEAN, PROP_NONE);
01154     RNA_def_property_boolean_sdna(prop, NULL, "custom1", SH_NODE_MAT_SPEC);
01155     RNA_def_property_ui_text(prop, "Specular", "Material Node outputs Specular");
01156     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01157     
01158     prop = RNA_def_property(srna, "invert_normal", PROP_BOOLEAN, PROP_NONE);
01159     RNA_def_property_boolean_sdna(prop, NULL, "custom1", SH_NODE_MAT_NEG);
01160     RNA_def_property_ui_text(prop, "Invert Normal", "Material Node uses inverted normal");
01161     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01162 }
01163 
01164 static void def_sh_mapping(StructRNA *srna)
01165 {
01166     PropertyRNA *prop;
01167     
01168     RNA_def_struct_sdna_from(srna, "TexMapping", "storage");
01169 
01170     prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
01171     RNA_def_property_float_sdna(prop, NULL, "loc");
01172     RNA_def_property_ui_text(prop, "Location", "");
01173     RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
01174     
01175     prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER); /* Not PROP_XYZ, this is now in radians, no more degrees */
01176     RNA_def_property_float_sdna(prop, NULL, "rot");
01177     RNA_def_property_ui_text(prop, "Rotation", "");
01178     RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
01179     
01180     prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
01181     RNA_def_property_float_sdna(prop, NULL, "size");
01182     RNA_def_property_ui_text(prop, "Scale", "");
01183     RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
01184     
01185     prop= RNA_def_property(srna, "min", PROP_FLOAT, PROP_XYZ);
01186     RNA_def_property_float_sdna(prop, NULL, "min");
01187     RNA_def_property_ui_text(prop, "Minimum", "Minimum value for clipping");
01188     RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
01189     
01190     prop= RNA_def_property(srna, "max", PROP_FLOAT, PROP_XYZ);
01191     RNA_def_property_float_sdna(prop, NULL, "max");
01192     RNA_def_property_ui_text(prop, "Maximum", "Maximum value for clipping");
01193     RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
01194     
01195     prop= RNA_def_property(srna, "use_min", PROP_BOOLEAN, PROP_NONE);
01196     RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MIN);
01197     RNA_def_property_ui_text(prop, "Has Minimum", "Whether to use minimum clipping value");
01198     RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
01199     
01200     prop= RNA_def_property(srna, "use_max", PROP_BOOLEAN, PROP_NONE);
01201     RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MAX);
01202     RNA_def_property_ui_text(prop, "Has Maximum", "Whether to use maximum clipping value");
01203     RNA_def_property_update(prop, 0, "rna_Mapping_Node_update");
01204 }
01205 
01206 static void def_sh_geometry(StructRNA *srna)
01207 {
01208     PropertyRNA *prop;
01209     
01210     RNA_def_struct_sdna_from(srna, "NodeGeometry", "storage");
01211     
01212     prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
01213     RNA_def_property_string_sdna(prop, NULL, "uvname");
01214     RNA_def_property_ui_text(prop, "UV Map", "");
01215     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01216     
01217     prop = RNA_def_property(srna, "color_layer", PROP_STRING, PROP_NONE);
01218     RNA_def_property_string_sdna(prop, NULL, "colname");
01219     RNA_def_property_ui_text(prop, "Vertex Color Layer", "");
01220     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01221 }
01222 
01223 static void def_sh_attribute(StructRNA *srna)
01224 {
01225     PropertyRNA *prop;
01226     
01227     RNA_def_struct_sdna_from(srna, "NodeShaderAttribute", "storage");
01228     
01229     prop = RNA_def_property(srna, "attribute_name", PROP_STRING, PROP_NONE);
01230     RNA_def_property_string_sdna(prop, NULL, "name");
01231     RNA_def_property_ui_text(prop, "Attribute Name", "");
01232     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01233 }
01234 
01235 static void def_sh_tex(StructRNA *srna)
01236 {
01237     PropertyRNA *prop;
01238 
01239     prop= RNA_def_property(srna, "texture_mapping", PROP_POINTER, PROP_NONE);
01240     RNA_def_property_pointer_sdna(prop, NULL, "base.tex_mapping");
01241     RNA_def_property_flag(prop, PROP_NEVER_NULL);
01242     RNA_def_property_ui_text(prop, "Texture Mapping", "Texture coordinate mapping settings");
01243 
01244     prop= RNA_def_property(srna, "color_mapping", PROP_POINTER, PROP_NONE);
01245     RNA_def_property_pointer_sdna(prop, NULL, "base.color_mapping");
01246     RNA_def_property_flag(prop, PROP_NEVER_NULL);
01247     RNA_def_property_ui_text(prop, "Color Mapping", "Color mapping settings");
01248 }
01249 
01250 static void def_sh_tex_sky(StructRNA *srna)
01251 {
01252     PropertyRNA *prop;
01253     
01254     RNA_def_struct_sdna_from(srna, "NodeTexSky", "storage");
01255     def_sh_tex(srna);
01256     
01257     prop = RNA_def_property(srna, "sun_direction", PROP_FLOAT, PROP_DIRECTION);
01258     RNA_def_property_ui_text(prop, "Sun Direction", "Direction from where the sun is shining");
01259     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01260     
01261     prop = RNA_def_property(srna, "turbidity", PROP_FLOAT, PROP_NONE);
01262     RNA_def_property_ui_text(prop, "Turbidity", "");
01263     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01264 }
01265 
01266 static void def_sh_tex_environment(StructRNA *srna)
01267 {
01268     static const EnumPropertyItem prop_color_space_items[]= {
01269         {SHD_COLORSPACE_SRGB, "SRGB", 0, "sRGB", "Image is in sRGB color space"},
01270         {SHD_COLORSPACE_LINEAR, "LINEAR", 0, "Linear", "Image is in scene linear color space"},
01271         {0, NULL, 0, NULL, NULL}};
01272 
01273     PropertyRNA *prop;
01274 
01275     prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
01276     RNA_def_property_pointer_sdna(prop, NULL, "id");
01277     RNA_def_property_struct_type(prop, "Image");
01278     RNA_def_property_flag(prop, PROP_EDITABLE);
01279     RNA_def_property_ui_text(prop, "Image", "");
01280     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_image_update");
01281 
01282     RNA_def_struct_sdna_from(srna, "NodeTexImage", "storage");
01283     def_sh_tex(srna);
01284 
01285     prop= RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE);
01286     RNA_def_property_enum_items(prop, prop_color_space_items);
01287     RNA_def_property_ui_text(prop, "Color Space", "Image file color space");
01288     RNA_def_property_update(prop, 0, "rna_Node_update");
01289 }
01290 
01291 static void def_sh_tex_image(StructRNA *srna)
01292 {
01293     static const EnumPropertyItem prop_color_space_items[]= {
01294         {SHD_COLORSPACE_LINEAR, "LINEAR", 0, "Linear", "Image is in scene linear color space"},
01295         {SHD_COLORSPACE_SRGB, "SRGB", 0, "sRGB", "Image is in sRGB color space"},
01296         {0, NULL, 0, NULL, NULL}};
01297 
01298     PropertyRNA *prop;
01299 
01300     prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
01301     RNA_def_property_pointer_sdna(prop, NULL, "id");
01302     RNA_def_property_struct_type(prop, "Image");
01303     RNA_def_property_flag(prop, PROP_EDITABLE);
01304     RNA_def_property_ui_text(prop, "Image", "");
01305     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_image_update");
01306 
01307     RNA_def_struct_sdna_from(srna, "NodeTexImage", "storage");
01308     def_sh_tex(srna);
01309 
01310     prop= RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE);
01311     RNA_def_property_enum_items(prop, prop_color_space_items);
01312     RNA_def_property_ui_text(prop, "Color Space", "Image file color space");
01313     RNA_def_property_update(prop, 0, "rna_Node_update");
01314 }
01315 
01316 static void def_sh_tex_gradient(StructRNA *srna)
01317 {
01318     static EnumPropertyItem prop_gradient_type[] = {
01319         {SHD_BLEND_LINEAR, "LINEAR", 0, "Linear", "Create a linear progression"},
01320         {SHD_BLEND_QUADRATIC, "QUADRATIC", 0, "Quadratic", "Create a quadratic progression"},
01321         {SHD_BLEND_EASING, "EASING", 0, "Easing", "Create a progression easing from one step to the next"},
01322         {SHD_BLEND_DIAGONAL, "DIAGONAL", 0, "Diagonal", "Create a diagonal progression"},
01323         {SHD_BLEND_SPHERICAL, "SPHERICAL", 0, "Spherical", "Create a spherical progression"},
01324         {SHD_BLEND_QUADRATIC_SPHERE, "QUADRATIC_SPHERE", 0, "Quadratic sphere", "Create a quadratic progression in the shape of a sphere"},
01325         {SHD_BLEND_RADIAL, "RADIAL", 0, "Radial", "Create a radial progression"},
01326         {0, NULL, 0, NULL, NULL}};
01327 
01328     PropertyRNA *prop;
01329     
01330     RNA_def_struct_sdna_from(srna, "NodeTexGradient", "storage");
01331     def_sh_tex(srna);
01332 
01333     prop= RNA_def_property(srna, "gradient_type", PROP_ENUM, PROP_NONE);
01334     RNA_def_property_enum_items(prop, prop_gradient_type);
01335     RNA_def_property_ui_text(prop, "Gradient Type", "Style of the color blending");
01336     RNA_def_property_update(prop, 0, "rna_Node_update");
01337 }
01338 
01339 static void def_sh_tex_noise(StructRNA *srna)
01340 {
01341     RNA_def_struct_sdna_from(srna, "NodeTexNoise", "storage");
01342     def_sh_tex(srna);
01343 }
01344 
01345 static void def_sh_tex_checker(StructRNA *srna)
01346 {
01347     RNA_def_struct_sdna_from(srna, "NodeTexChecker", "storage");
01348     def_sh_tex(srna);
01349 }
01350 
01351 static void def_sh_tex_magic(StructRNA *srna)
01352 {
01353     PropertyRNA *prop;
01354     
01355     RNA_def_struct_sdna_from(srna, "NodeTexMagic", "storage");
01356     def_sh_tex(srna);
01357 
01358     prop= RNA_def_property(srna, "turbulence_depth", PROP_INT, PROP_NONE);
01359     RNA_def_property_int_sdna(prop, NULL, "depth");
01360     RNA_def_property_range(prop, 0, 10);
01361     RNA_def_property_ui_text(prop, "Depth", "Level of detail in the added turbulent noise");
01362     RNA_def_property_update(prop, 0, "rna_Node_update");
01363 }
01364 
01365 static void def_sh_tex_musgrave(StructRNA *srna)
01366 {
01367     static EnumPropertyItem prop_musgrave_type[] = {
01368         {SHD_MUSGRAVE_MULTIFRACTAL, "MULTIFRACTAL", 0, "Multifractal", ""},
01369         {SHD_MUSGRAVE_RIDGED_MULTIFRACTAL, "RIDGED_MULTIFRACTAL", 0, "Ridged Multifractal", ""},
01370         {SHD_MUSGRAVE_HYBRID_MULTIFRACTAL, "HYBRID_MULTIFRACTAL", 0, "Hybrid Multifractal", ""},
01371         {SHD_MUSGRAVE_FBM, "FBM", 0, "fBM", ""},
01372         {SHD_MUSGRAVE_HETERO_TERRAIN, "HETERO_TERRAIN", 0, "Hetero Terrain", ""},
01373         {0, NULL, 0, NULL, NULL}};
01374 
01375     PropertyRNA *prop;
01376     
01377     RNA_def_struct_sdna_from(srna, "NodeTexMusgrave", "storage");
01378     def_sh_tex(srna);
01379 
01380     prop= RNA_def_property(srna, "musgrave_type", PROP_ENUM, PROP_NONE);
01381     RNA_def_property_enum_sdna(prop, NULL, "musgrave_type");
01382     RNA_def_property_enum_items(prop, prop_musgrave_type);
01383     RNA_def_property_ui_text(prop, "Type", "");
01384     RNA_def_property_update(prop, 0, "rna_Node_update");
01385 }
01386 
01387 static void def_sh_tex_voronoi(StructRNA *srna)
01388 {
01389     static EnumPropertyItem prop_coloring_items[] = {
01390         {SHD_VORONOI_INTENSITY, "INTENSITY", 0, "Intensity", "Only calculate intensity"},
01391         {SHD_VORONOI_CELLS, "CELLS", 0, "Cells", "Color cells by position"},
01392         {0, NULL, 0, NULL, NULL}};
01393 
01394     PropertyRNA *prop;
01395     
01396     RNA_def_struct_sdna_from(srna, "NodeTexVoronoi", "storage");
01397     def_sh_tex(srna);
01398 
01399     prop= RNA_def_property(srna, "coloring", PROP_ENUM, PROP_NONE);
01400     RNA_def_property_enum_sdna(prop, NULL, "coloring");
01401     RNA_def_property_enum_items(prop, prop_coloring_items);
01402     RNA_def_property_ui_text(prop, "Coloring", "");
01403     RNA_def_property_update(prop, 0, "rna_Node_update");
01404 }
01405 
01406 static void def_sh_tex_wave(StructRNA *srna)
01407 {
01408     static EnumPropertyItem prop_wave_type_items[] = {
01409     {SHD_WAVE_BANDS, "BANDS", 0, "Bands", "Use standard wave texture in bands"},
01410     {SHD_WAVE_RINGS, "RINGS", 0, "Rings", "Use wave texture in rings"},
01411     {0, NULL, 0, NULL, NULL}};
01412 
01413     PropertyRNA *prop;
01414     
01415     RNA_def_struct_sdna_from(srna, "NodeTexWave", "storage");
01416     def_sh_tex(srna);
01417 
01418     prop= RNA_def_property(srna, "wave_type", PROP_ENUM, PROP_NONE);
01419     RNA_def_property_enum_sdna(prop, NULL, "wave_type");
01420     RNA_def_property_enum_items(prop, prop_wave_type_items);
01421     RNA_def_property_ui_text(prop, "Wave Type", "");
01422     RNA_def_property_update(prop, 0, "rna_Node_update");
01423 }
01424 
01425 static void def_glossy(StructRNA *srna)
01426 {
01427     PropertyRNA *prop;
01428     
01429     prop = RNA_def_property(srna, "distribution", PROP_ENUM, PROP_NONE);
01430     RNA_def_property_enum_sdna(prop, NULL, "custom1");
01431     RNA_def_property_enum_items(prop, node_glossy_items);
01432     RNA_def_property_ui_text(prop, "Distribution", "");
01433     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01434 }
01435 
01436 /* -- Compositor Nodes ------------------------------------------------------ */
01437 
01438 static void def_cmp_alpha_over(StructRNA *srna)
01439 {
01440     PropertyRNA *prop;
01441     
01442     // XXX: Tooltip
01443     prop = RNA_def_property(srna, "use_premultiply", PROP_BOOLEAN, PROP_NONE);
01444     RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1);
01445     RNA_def_property_ui_text(prop, "Convert Premul", "");
01446     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01447     
01448     RNA_def_struct_sdna_from(srna, "NodeTwoFloats", "storage");
01449     
01450     prop = RNA_def_property(srna, "premul", PROP_FLOAT, PROP_NONE);
01451     RNA_def_property_float_sdna(prop, NULL, "x");
01452     RNA_def_property_range(prop, 0.0f, 1.0f);
01453     RNA_def_property_ui_text(prop, "Premul", "Mix Factor");
01454     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01455 }
01456 
01457 static void def_cmp_hue_saturation(StructRNA *srna)
01458 {
01459     PropertyRNA *prop;
01460 
01461     RNA_def_struct_sdna_from(srna, "NodeHueSat", "storage");
01462     
01463     prop = RNA_def_property(srna, "color_hue", PROP_FLOAT, PROP_NONE);
01464     RNA_def_property_float_sdna(prop, NULL, "hue");
01465     RNA_def_property_range(prop, 0.0f, 1.0f);
01466     RNA_def_property_ui_text(prop, "Hue", "");
01467     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01468     
01469     prop = RNA_def_property(srna, "color_saturation", PROP_FLOAT, PROP_NONE);
01470     RNA_def_property_float_sdna(prop, NULL, "sat");
01471     RNA_def_property_range(prop, 0.0f, 2.0f);
01472     RNA_def_property_ui_text(prop, "Saturation", "");
01473     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01474     
01475     prop = RNA_def_property(srna, "color_value", PROP_FLOAT, PROP_NONE);
01476     RNA_def_property_float_sdna(prop, NULL, "val");
01477     RNA_def_property_range(prop, 0.0f, 2.0f);
01478     RNA_def_property_ui_text(prop, "Value", "");
01479     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01480 }
01481 
01482 static void def_cmp_blur(StructRNA *srna)
01483 {
01484     PropertyRNA *prop;
01485     
01486     static EnumPropertyItem filter_type_items[] = {
01487         {R_FILTER_BOX,        "FLAT",       0, "Flat",          ""},
01488         {R_FILTER_TENT,       "TENT",       0, "Tent",          ""},
01489         {R_FILTER_QUAD,       "QUAD",       0, "Quadratic",     ""},
01490         {R_FILTER_CUBIC,      "CUBIC",      0, "Cubic",         ""},
01491         {R_FILTER_GAUSS,      "GAUSS",      0, "Gaussian",      ""},
01492         {R_FILTER_FAST_GAUSS, "FAST_GAUSS", 0, "Fast Gaussian", ""},
01493         {R_FILTER_CATROM,     "CATROM",     0, "Catrom",        ""},
01494         {R_FILTER_MITCH,      "MITCH",      0, "Mitch",         ""},
01495         {0, NULL, 0, NULL, NULL}};
01496 
01497     static EnumPropertyItem aspect_correction_type_items[] = {
01498         {CMP_NODE_BLUR_ASPECT_NONE, "NONE", 0,  "None", ""},
01499         {CMP_NODE_BLUR_ASPECT_Y,    "Y",    0,  "Y",    ""},
01500         {CMP_NODE_BLUR_ASPECT_X,    "X",    0,  "X",    ""},
01501         {0, NULL, 0, NULL, NULL}};
01502 
01503     RNA_def_struct_sdna_from(srna, "NodeBlurData", "storage");
01504     
01505     prop = RNA_def_property(srna, "size_x", PROP_INT, PROP_NONE);
01506     RNA_def_property_int_sdna(prop, NULL, "sizex");
01507     RNA_def_property_range(prop, 0, 2048);
01508     RNA_def_property_ui_text(prop, "Size X", "");
01509     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01510     
01511     prop = RNA_def_property(srna, "size_y", PROP_INT, PROP_NONE);
01512     RNA_def_property_int_sdna(prop, NULL, "sizey");
01513     RNA_def_property_range(prop, 0, 2048);
01514     RNA_def_property_ui_text(prop, "Size Y", "");
01515     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01516 
01517     prop = RNA_def_property(srna, "use_relative", PROP_BOOLEAN, PROP_NONE);
01518     RNA_def_property_boolean_sdna(prop, NULL, "relative", 1);
01519     RNA_def_property_ui_text(prop, "Relative", "Use relative (percent) values to define blur radius");
01520     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01521     
01522     prop = RNA_def_property(srna, "aspect_correction", PROP_ENUM, PROP_NONE);
01523     RNA_def_property_enum_sdna(prop, NULL, "aspect");
01524     RNA_def_property_enum_items(prop, aspect_correction_type_items);
01525     RNA_def_property_ui_text(prop, "Aspect Correction", "Type of aspect correction to use");
01526     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01527 
01528     prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE);
01529     RNA_def_property_float_sdna(prop, NULL, "fac");
01530     RNA_def_property_range(prop, 0.0f, 2.0f);
01531     RNA_def_property_ui_text(prop, "Factor", "");
01532     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01533     
01534     prop = RNA_def_property(srna, "factor_x", PROP_FLOAT, PROP_PERCENTAGE);
01535     RNA_def_property_float_sdna(prop, NULL, "percentx");
01536     RNA_def_property_range(prop, 0.0f, 100.0f);
01537     RNA_def_property_ui_text(prop, "Relative Size X", "");
01538     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01539     
01540     prop = RNA_def_property(srna, "factor_y", PROP_FLOAT, PROP_PERCENTAGE);
01541     RNA_def_property_float_sdna(prop, NULL, "percenty");
01542     RNA_def_property_range(prop, 0.0f, 100.0f);
01543     RNA_def_property_ui_text(prop, "Relative Size Y", "");
01544     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01545     
01546     prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE);
01547     RNA_def_property_enum_sdna(prop, NULL, "filtertype");
01548     RNA_def_property_enum_items(prop, filter_type_items);
01549     RNA_def_property_ui_text(prop, "Filter Type", "");
01550     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01551     
01552     prop = RNA_def_property(srna, "use_bokeh", PROP_BOOLEAN, PROP_NONE);
01553     RNA_def_property_boolean_sdna(prop, NULL, "bokeh", 1);
01554     RNA_def_property_ui_text(prop, "Bokeh", "Use circular filter (slower)");
01555     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01556     
01557     prop = RNA_def_property(srna, "use_gamma_correction", PROP_BOOLEAN, PROP_NONE);
01558     RNA_def_property_boolean_sdna(prop, NULL, "gamma", 1);
01559     RNA_def_property_ui_text(prop, "Gamma", "Apply filter on gamma corrected values");
01560     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01561     
01562 }
01563 
01564 static void def_cmp_filter(StructRNA *srna)
01565 {
01566     PropertyRNA *prop;
01567 
01568     prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE);
01569     RNA_def_property_enum_sdna(prop, NULL, "custom1");
01570     RNA_def_property_enum_items(prop, node_filter_items);
01571     RNA_def_property_ui_text(prop, "Filter Type", "");
01572     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01573 }
01574 
01575 static void def_cmp_map_value(StructRNA *srna)
01576 {
01577     PropertyRNA *prop;
01578     
01579     RNA_def_struct_sdna_from(srna, "TexMapping", "storage");
01580     
01581     prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
01582     RNA_def_property_float_sdna(prop, NULL, "loc");
01583     RNA_def_property_array(prop, 1);
01584     RNA_def_property_range(prop, -1000.0f, 1000.0f);
01585     RNA_def_property_ui_text(prop, "Offset", "");
01586     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01587     
01588     prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
01589     RNA_def_property_float_sdna(prop, NULL, "size");
01590     RNA_def_property_array(prop, 1);
01591     RNA_def_property_range(prop, -1000.0f, 1000.0f);
01592     RNA_def_property_ui_text(prop, "Size", "");
01593     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01594     
01595     prop = RNA_def_property(srna, "use_min", PROP_BOOLEAN, PROP_NONE);
01596     RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MIN);
01597     RNA_def_property_ui_text(prop, "Use Minimum", "");
01598     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01599     
01600     prop = RNA_def_property(srna, "use_max", PROP_BOOLEAN, PROP_NONE);
01601     RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MAX);
01602     RNA_def_property_ui_text(prop, "Use Maximum", "");
01603     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01604     
01605     prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE);
01606     RNA_def_property_float_sdna(prop, NULL, "min");
01607     RNA_def_property_array(prop, 1);
01608     RNA_def_property_range(prop, -1000.0f, 1000.0f);
01609     RNA_def_property_ui_text(prop, "Minimum", "");
01610     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01611     
01612     prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE);
01613     RNA_def_property_float_sdna(prop, NULL, "max");
01614     RNA_def_property_array(prop, 1);
01615     RNA_def_property_range(prop, -1000.0f, 1000.0f);
01616     RNA_def_property_ui_text(prop, "Maximum", "");
01617     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01618 }
01619 
01620 static void def_cmp_vector_blur(StructRNA *srna)
01621 {
01622     PropertyRNA *prop;
01623     
01624     RNA_def_struct_sdna_from(srna, "NodeBlurData", "storage");
01625     
01626     prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE);
01627     RNA_def_property_int_sdna(prop, NULL, "samples");
01628     RNA_def_property_range(prop, 1, 256);
01629     RNA_def_property_ui_text(prop, "Samples", "");
01630     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01631     
01632     prop = RNA_def_property(srna, "speed_min", PROP_INT, PROP_NONE);
01633     RNA_def_property_int_sdna(prop, NULL, "minspeed");
01634     RNA_def_property_range(prop, 0, 1024);
01635     RNA_def_property_ui_text(prop, "Min Speed", "Minimum speed for a pixel to be blurred (used to separate background from foreground)");
01636     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01637         
01638     prop = RNA_def_property(srna, "speed_max", PROP_INT, PROP_NONE);
01639     RNA_def_property_int_sdna(prop, NULL, "maxspeed");
01640     RNA_def_property_range(prop, 0, 1024);
01641     RNA_def_property_ui_text(prop, "Max Speed", "Maximum speed, or zero for none");
01642     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01643     
01644     prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE);
01645     RNA_def_property_float_sdna(prop, NULL, "fac");
01646     RNA_def_property_range(prop, 0.0f, 2.0f);
01647     RNA_def_property_ui_text(prop, "Blur Factor", "Scaling factor for motion vectors (actually, 'shutter speed', in frames)");
01648     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01649     
01650     prop = RNA_def_property(srna, "use_curved", PROP_BOOLEAN, PROP_NONE);
01651     RNA_def_property_boolean_sdna(prop, NULL, "curved", 1);
01652     RNA_def_property_ui_text(prop, "Curved", "Interpolate between frames in a Bezier curve, rather than linearly");
01653     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01654 }
01655 
01656 static void def_cmp_levels(StructRNA *srna)
01657 {
01658     PropertyRNA *prop;
01659     
01660     static EnumPropertyItem channel_items[] = {
01661         {1, "COMBINED_RGB", 0, "C", "Combined RGB"},
01662         {2, "RED", 0, "R", "Red Channel"},
01663         {3, "GREEN", 0, "G", "Green Channel"},
01664         {4, "BLUE", 0, "B", "Blue Channel"},
01665         {5, "LUMINANCE", 0, "L", "Luminance Channel"},
01666         {0, NULL, 0, NULL, NULL}};
01667     
01668     prop = RNA_def_property(srna, "channel", PROP_ENUM, PROP_NONE);
01669     RNA_def_property_enum_sdna(prop, NULL, "custom1");
01670     RNA_def_property_enum_items(prop, channel_items);
01671     RNA_def_property_ui_text(prop, "Channel", "");
01672     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01673 }
01674 
01675 static void def_cmp_image(StructRNA *srna)
01676 {
01677     PropertyRNA *prop;
01678     
01679     /*
01680      static EnumPropertyItem type_items[] = {
01681         {IMA_SRC_FILE,      "IMAGE",     0, "Image",     ""},
01682         {IMA_SRC_MOVIE,     "MOVIE",     "Movie",     ""},
01683         {IMA_SRC_SEQUENCE,  "SEQUENCE",  "Sequence",  ""},
01684         {IMA_SRC_GENERATED, "GENERATED", "Generated", ""},
01685         {0, NULL, 0, NULL, NULL}};
01686     */
01687     
01688     prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
01689     RNA_def_property_pointer_sdna(prop, NULL, "id");
01690     RNA_def_property_struct_type(prop, "Image");
01691     RNA_def_property_flag(prop, PROP_EDITABLE);
01692     RNA_def_property_ui_text(prop, "Image", "");
01693     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01694     
01695     RNA_def_struct_sdna_from(srna, "ImageUser", "storage");
01696     
01697     prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE);
01698     RNA_def_property_int_sdna(prop, NULL, "frames");
01699     RNA_def_property_range(prop, 0, MAXFRAMEF);
01700     RNA_def_property_ui_text(prop, "Frames", "Number of images of a movie to use"); /* copied from the rna_image.c */
01701     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01702     
01703     prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE);
01704     RNA_def_property_int_sdna(prop, NULL, "sfra");
01705     RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
01706     RNA_def_property_ui_text(prop, "Start Frame", "Global starting frame of the movie/sequence, assuming first picture has a #1"); /* copied from the rna_image.c */
01707     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01708     
01709     prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
01710     RNA_def_property_int_sdna(prop, NULL, "offset");
01711     RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
01712     RNA_def_property_ui_text(prop, "Offset", "Offset the number of the frame to use in the animation"); /* copied from the rna_image.c */
01713     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01714     
01715     prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE);
01716     RNA_def_property_boolean_sdna(prop, NULL, "cycl", 1);
01717     RNA_def_property_ui_text(prop, "Cyclic", "Cycle the images in the movie"); /* copied from the rna_image.c */
01718     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01719     
01720     prop = RNA_def_property(srna, "use_auto_refresh", PROP_BOOLEAN, PROP_NONE);
01721     RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_ANIM_ALWAYS);
01722     RNA_def_property_ui_text(prop, "Auto-Refresh", "Always refresh image on frame changes"); /* copied from the rna_image.c */
01723     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01724     
01725     prop= RNA_def_property(srna, "layer", PROP_ENUM, PROP_NONE);
01726     RNA_def_property_enum_sdna(prop, NULL, "layer");
01727     RNA_def_property_enum_items(prop, prop_image_layer_items);
01728     RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_image_layer_itemf");
01729     RNA_def_property_ui_text(prop, "Layer", "");
01730     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_image_layer_update");
01731 }
01732 
01733 static void def_cmp_render_layers(StructRNA *srna)
01734 {
01735     PropertyRNA *prop;
01736     
01737     prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
01738     RNA_def_property_pointer_sdna(prop, NULL, "id");
01739     RNA_def_property_pointer_funcs(prop, NULL, "rna_Node_scene_set", NULL, NULL);
01740     RNA_def_property_struct_type(prop, "Scene");
01741     RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK);
01742     RNA_def_property_ui_text(prop, "Scene", "");
01743     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01744     
01745     prop= RNA_def_property(srna, "layer", PROP_ENUM, PROP_NONE);
01746     RNA_def_property_enum_sdna(prop, NULL, "custom1");
01747     RNA_def_property_enum_items(prop, prop_scene_layer_items);
01748     RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_scene_layer_itemf");
01749     RNA_def_property_ui_text(prop, "Layer", "");
01750     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01751 }
01752 
01753 static void def_cmp_output_file(StructRNA *srna)
01754 {
01755     PropertyRNA *prop;
01756     
01757     RNA_def_struct_sdna_from(srna, "NodeImageFile", "storage");
01758     
01759     prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
01760     RNA_def_property_string_sdna(prop, NULL, "name");
01761     RNA_def_property_ui_text(prop, "File Path", "Output path for the image, same functionality as render output");
01762     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01763     
01764     prop= RNA_def_property(srna, "image_settings", PROP_POINTER, PROP_NONE);
01765     RNA_def_property_flag(prop, PROP_NEVER_NULL);
01766     RNA_def_property_pointer_sdna(prop, NULL, "im_format");
01767     RNA_def_property_struct_type(prop, "ImageFormatSettings");
01768     RNA_def_property_ui_text(prop, "Image Format", "");
01769 
01770     prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE);
01771     RNA_def_property_int_sdna(prop, NULL, "sfra");
01772     RNA_def_property_int_funcs(prop, NULL, "rna_Image_start_frame_set", NULL);
01773     RNA_def_property_range(prop, MINFRAMEF, MAXFRAMEF);
01774     RNA_def_property_ui_text(prop, "Start Frame", "");
01775     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01776     
01777     prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE);
01778     RNA_def_property_int_sdna(prop, NULL, "efra");
01779     RNA_def_property_int_funcs(prop, NULL, "rna_Image_end_frame_set", NULL);
01780     RNA_def_property_range(prop, MINFRAMEF, MAXFRAMEF);
01781     RNA_def_property_ui_text(prop, "End Frame", "");
01782     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01783 }
01784 
01785 static void def_cmp_dilate_erode(StructRNA *srna)
01786 {
01787     PropertyRNA *prop;
01788     
01789     prop = RNA_def_property(srna, "distance", PROP_INT, PROP_NONE);
01790     RNA_def_property_int_sdna(prop, NULL, "custom2");
01791     RNA_def_property_range(prop, -100, 100);
01792     RNA_def_property_ui_text(prop, "Distance", "Distance to grow/shrink (number of iterations)");
01793     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01794 }
01795 
01796 static void def_cmp_scale(StructRNA *srna)
01797 {
01798     PropertyRNA *prop;
01799     
01800     static EnumPropertyItem space_items[] = {
01801         {0, "RELATIVE",   0, "Relative",   ""},
01802         {1, "ABSOLUTE",   0, "Absolute",   ""},
01803         {2, "SCENE_SIZE", 0, "Scene Size", ""},
01804         {3, "RENDER_SIZE", 0, "Render Size", ""},
01805         {0, NULL, 0, NULL, NULL}};
01806     
01807     prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE);
01808     RNA_def_property_enum_sdna(prop, NULL, "custom1");
01809     RNA_def_property_enum_items(prop, space_items);
01810     RNA_def_property_ui_text(prop, "Space", "Coordinate space to scale relative to");
01811     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01812 }
01813 
01814 static void def_cmp_rotate(StructRNA *srna)
01815 {
01816     PropertyRNA *prop;
01817     
01818     static EnumPropertyItem rotate_items[] = {
01819         {0, "NEAREST",   0, "Nearest",   ""},
01820         {1, "BILINEAR",   0, "Bilinear",   ""},
01821         {2, "BICUBIC", 0, "Bicubic", ""},
01822         {0, NULL, 0, NULL, NULL}};
01823     
01824     prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE);
01825     RNA_def_property_enum_sdna(prop, NULL, "custom1");
01826     RNA_def_property_enum_items(prop, rotate_items);
01827     RNA_def_property_ui_text(prop, "Filter", "Method to use to filter rotation");
01828     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01829 }
01830 
01831 static void def_cmp_diff_matte(StructRNA *srna)
01832 {
01833     PropertyRNA *prop;
01834 
01835     RNA_def_struct_sdna_from(srna, "NodeChroma", "storage");
01836     
01837     prop = RNA_def_property(srna, "tolerance", PROP_FLOAT, PROP_NONE);
01838     RNA_def_property_float_sdna(prop, NULL, "t1");
01839     RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t1_set", NULL);
01840     RNA_def_property_range(prop, 0.0f, 1.0f);
01841     RNA_def_property_ui_text(prop, "Tolerance", "Color distances below this threshold are keyed");
01842     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01843     
01844     prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE);
01845     RNA_def_property_float_sdna(prop, NULL, "t2");
01846     RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t2_set", NULL);
01847     RNA_def_property_range(prop, 0.0f, 1.0f);
01848     RNA_def_property_ui_text(prop, "Falloff", "Color distances below this additional threshold are partially keyed");
01849     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01850 }
01851 
01852 static void def_cmp_color_matte(StructRNA *srna)
01853 {
01854     PropertyRNA *prop;
01855     
01856     RNA_def_struct_sdna_from(srna, "NodeChroma", "storage");
01857 
01858     prop = RNA_def_property(srna, "color_hue", PROP_FLOAT, PROP_NONE);
01859     RNA_def_property_float_sdna(prop, NULL, "t1");
01860     RNA_def_property_range(prop, 0.0f, 1.0f);
01861     RNA_def_property_ui_text(prop, "H", "Hue tolerance for colors to be considered a keying color");
01862     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01863     
01864     prop = RNA_def_property(srna, "color_saturation", PROP_FLOAT, PROP_NONE);
01865     RNA_def_property_float_sdna(prop, NULL, "t2");
01866     RNA_def_property_range(prop, 0.0f, 1.0f);
01867     RNA_def_property_ui_text(prop, "S", "Saturation Tolerance for the color");
01868     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01869     
01870     prop = RNA_def_property(srna, "color_value", PROP_FLOAT, PROP_NONE);
01871     RNA_def_property_float_sdna(prop, NULL, "t3");
01872     RNA_def_property_range(prop, 0.0f, 1.0f);
01873     RNA_def_property_ui_text(prop, "V", "Value Tolerance for the color");
01874     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01875 }
01876 
01877 static void def_cmp_distance_matte(StructRNA *srna)
01878 {
01879     PropertyRNA *prop;
01880     
01881     RNA_def_struct_sdna_from(srna, "NodeChroma", "storage");
01882     
01883     prop = RNA_def_property(srna, "tolerance", PROP_FLOAT, PROP_NONE);
01884     RNA_def_property_float_sdna(prop, NULL, "t1");
01885     RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t1_set", NULL);
01886     RNA_def_property_range(prop, 0.0f, 1.0f);
01887     RNA_def_property_ui_text(prop, "Tolerance", "Color distances below this threshold are keyed");
01888     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01889     
01890     prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE);
01891     RNA_def_property_float_sdna(prop, NULL, "t2");
01892     RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t2_set", NULL);
01893     RNA_def_property_range(prop, 0.0f, 1.0f);
01894     RNA_def_property_ui_text(prop, "Falloff", "Color distances below this additional threshold are partially keyed");
01895     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01896 }
01897 
01898 static void def_cmp_color_spill(StructRNA *srna)
01899 {
01900     PropertyRNA *prop;
01901 
01902     static EnumPropertyItem channel_items[] = {
01903         {1, "R", 0, "R", "Red Spill Suppression"},
01904         {2, "G", 0, "G", "Green Spill Suppression"},
01905         {3, "B", 0, "B", "Blue Spill Suppression"},
01906         {0, NULL, 0, NULL, NULL}};
01907 
01908     static EnumPropertyItem limit_channel_items[] = {
01909         {1, "R", 0, "R", "Limit by Red"},
01910         {2, "G", 0, "G", "Limit by Green"},
01911         {3, "B", 0, "B", "Limit by Blue"},
01912         {0, NULL, 0, NULL, NULL}};
01913 
01914     static EnumPropertyItem algorithm_items[] = {
01915         {0, "SIMPLE", 0, "Simple", "Simple Limit Algorithm"},
01916         {1, "AVERAGE", 0, "Average", "Average Limit Algorithm"},
01917         {0, NULL, 0, NULL, NULL}};
01918     
01919     prop = RNA_def_property(srna, "channel", PROP_ENUM, PROP_NONE);
01920     RNA_def_property_enum_sdna(prop, NULL, "custom1");
01921     RNA_def_property_enum_items(prop, channel_items);
01922     RNA_def_property_ui_text(prop, "Channel", "");
01923     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01924     
01925     prop = RNA_def_property(srna, "limit_method", PROP_ENUM, PROP_NONE);
01926     RNA_def_property_enum_sdna(prop, NULL, "custom2");
01927     RNA_def_property_enum_items(prop, algorithm_items);
01928     RNA_def_property_ui_text(prop, "Algorithm", "");
01929     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01930 
01931     RNA_def_struct_sdna_from(srna, "NodeColorspill", "storage");
01932 
01933     prop = RNA_def_property(srna, "limit_channel", PROP_ENUM, PROP_NONE);
01934     RNA_def_property_enum_sdna(prop, NULL, "limchan");
01935     RNA_def_property_enum_items(prop, limit_channel_items);
01936     RNA_def_property_ui_text(prop, "Limit Channel", "");
01937     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01938 
01939     prop = RNA_def_property(srna, "ratio", PROP_FLOAT, PROP_NONE);
01940     RNA_def_property_float_sdna(prop, NULL, "limscale");
01941     RNA_def_property_range(prop, 0.5f, 1.5f);
01942     RNA_def_property_ui_text(prop, "Ratio", "Scale limit by value");
01943     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01944 
01945     prop = RNA_def_property(srna, "use_unspill", PROP_BOOLEAN, PROP_NONE);
01946     RNA_def_property_boolean_sdna(prop, NULL, "unspill", 0);
01947     RNA_def_property_ui_text(prop, "Unspill", "Compensate all channels (differently) by hand");
01948     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01949 
01950     prop = RNA_def_property(srna, "unspill_red", PROP_FLOAT, PROP_NONE);
01951     RNA_def_property_float_sdna(prop, NULL, "uspillr");
01952     RNA_def_property_range(prop, 0.0f, 1.5f);
01953     RNA_def_property_ui_text(prop, "R", "Red spillmap scale");
01954     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01955 
01956     prop = RNA_def_property(srna, "unspill_green", PROP_FLOAT, PROP_NONE);
01957     RNA_def_property_float_sdna(prop, NULL, "uspillg");
01958     RNA_def_property_range(prop, 0.0f, 1.5f);
01959     RNA_def_property_ui_text(prop, "G", "Green spillmap scale");
01960     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01961 
01962     prop = RNA_def_property(srna, "unspill_blue", PROP_FLOAT, PROP_NONE);
01963     RNA_def_property_float_sdna(prop, NULL, "uspillb");
01964     RNA_def_property_range(prop, 0.0f, 1.5f);
01965     RNA_def_property_ui_text(prop, "B", "Blue spillmap scale");
01966     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01967 }
01968 
01969 static void def_cmp_luma_matte(StructRNA *srna)
01970 {
01971     PropertyRNA *prop;
01972     
01973     RNA_def_struct_sdna_from(srna, "NodeChroma", "storage");
01974     
01975     prop = RNA_def_property(srna, "limit_max", PROP_FLOAT, PROP_NONE);
01976     RNA_def_property_float_sdna(prop, NULL, "t1");
01977     RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t1_set", NULL);
01978     RNA_def_property_range(prop, 0.0f, 1.0f);
01979     RNA_def_property_ui_text(prop, "High", "Values higher than this setting are 100% opaque");
01980     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01981     
01982     prop = RNA_def_property(srna, "limit_min", PROP_FLOAT, PROP_NONE);
01983     RNA_def_property_float_sdna(prop, NULL, "t2");
01984     RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t2_set", NULL);
01985     RNA_def_property_range(prop, 0.0f, 1.0f);
01986     RNA_def_property_ui_text(prop, "Low", "Values lower than this setting are 100% keyed");
01987     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
01988 }
01989 
01990 static void def_cmp_chroma_matte(StructRNA *srna)
01991 {
01992     PropertyRNA *prop;
01993     
01994     RNA_def_struct_sdna_from(srna, "NodeChroma", "storage");
01995     
01996     prop = RNA_def_property(srna, "tolerance", PROP_FLOAT, PROP_ANGLE);
01997     RNA_def_property_float_sdna(prop, NULL, "t1");
01998     RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t1_set", NULL);
01999     RNA_def_property_range(prop, DEG2RADF(1.0f), DEG2RADF(80.0f));
02000     RNA_def_property_ui_text(prop, "Acceptance", "Tolerance for a color to be considered a keying color");
02001     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02002     
02003     prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_ANGLE);
02004     RNA_def_property_float_sdna(prop, NULL, "t2");
02005     RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t2_set", NULL);
02006     RNA_def_property_range(prop, 0.0f, DEG2RADF(30.0f));
02007     RNA_def_property_ui_text(prop, "Cutoff", "Tolerance below which colors will be considered as exact matches");
02008     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02009 
02010     prop = RNA_def_property(srna, "lift", PROP_FLOAT, PROP_NONE);
02011     RNA_def_property_float_sdna(prop, NULL, "fsize");
02012     RNA_def_property_range(prop, 0.0f, 1.0f);
02013     RNA_def_property_ui_text(prop, "Lift", "Alpha lift");
02014     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02015     
02016     prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_NONE);
02017     RNA_def_property_float_sdna(prop, NULL, "fstrength");
02018     RNA_def_property_range(prop, 0.0f, 1.0f);
02019     RNA_def_property_ui_text(prop, "Gain", "Alpha gain");
02020     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02021     
02022     prop = RNA_def_property(srna, "shadow_adjust", PROP_FLOAT, PROP_NONE);
02023     RNA_def_property_float_sdna(prop, NULL, "t3");
02024     RNA_def_property_range(prop, 0.0f, 1.0f);
02025     RNA_def_property_ui_text(prop, "Shadow Adjust", "Adjusts the brightness of any shadows captured");
02026     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02027 }
02028 
02029 static void def_cmp_channel_matte(StructRNA *srna)
02030 {
02031     PropertyRNA *prop;
02032     
02033     static EnumPropertyItem color_space_items[] = {
02034         {CMP_NODE_CHANNEL_MATTE_CS_RGB, "RGB", 0, "RGB",   "RGB Color Space"},
02035         {CMP_NODE_CHANNEL_MATTE_CS_HSV, "HSV", 0, "HSV",   "HSV Color Space"},
02036         {CMP_NODE_CHANNEL_MATTE_CS_YUV, "YUV", 0, "YUV",   "YUV Color Space"},
02037         {CMP_NODE_CHANNEL_MATTE_CS_YCC, "YCC", 0, "YCbCr", "YCbCr Color Space"},
02038         {0, NULL, 0, NULL, NULL}};
02039 
02040     static EnumPropertyItem algorithm_items[] = {
02041         {0, "SINGLE", 0, "Single", "Limit by single channel"},
02042         {1, "MAX", 0, "Max", "Limit by max of other channels "},
02043         {0, NULL, 0, NULL, NULL}};
02044     
02045     prop = RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE);
02046     RNA_def_property_enum_sdna(prop, NULL, "custom1");
02047     RNA_def_property_enum_items(prop, color_space_items);
02048     RNA_def_property_ui_text(prop, "Color Space", "");
02049     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02050     
02051     prop= RNA_def_property(srna, "matte_channel", PROP_ENUM, PROP_NONE);
02052     RNA_def_property_enum_sdna(prop, NULL, "custom2");
02053     RNA_def_property_enum_items(prop, prop_tri_channel_items);
02054     RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_channel_itemf");
02055     RNA_def_property_ui_text(prop, "Channel", "Channel used to determine matte");
02056     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02057 
02058     RNA_def_struct_sdna_from(srna, "NodeChroma", "storage");
02059 
02060     prop = RNA_def_property(srna, "limit_method", PROP_ENUM, PROP_NONE);
02061     RNA_def_property_enum_sdna(prop, NULL, "algorithm");
02062     RNA_def_property_enum_items(prop, algorithm_items);
02063     RNA_def_property_ui_text(prop, "Algorithm", "Algorithm to use to limit channel");
02064     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02065 
02066     prop = RNA_def_property(srna, "limit_channel", PROP_ENUM, PROP_NONE);
02067     RNA_def_property_enum_sdna(prop, NULL, "channel");
02068     RNA_def_property_enum_items(prop, prop_tri_channel_items);
02069     RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_channel_itemf");
02070     RNA_def_property_ui_text(prop, "Limit Channel", "Limit by this channel's value");
02071     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02072     
02073     prop = RNA_def_property(srna, "limit_max", PROP_FLOAT, PROP_NONE);
02074     RNA_def_property_float_sdna(prop, NULL, "t1");
02075     RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t1_set", NULL);
02076     RNA_def_property_range(prop, 0.0f, 1.0f);
02077     RNA_def_property_ui_text(prop, "High", "Values higher than this setting are 100% opaque");
02078     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02079     
02080     prop = RNA_def_property(srna, "limit_min", PROP_FLOAT, PROP_NONE);
02081     RNA_def_property_float_sdna(prop, NULL, "t2");
02082     RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t2_set", NULL);
02083     RNA_def_property_range(prop, 0.0f, 1.0f);
02084     RNA_def_property_ui_text(prop, "Low", "Values lower than this setting are 100% keyed");
02085     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02086 }
02087 
02088 static void def_cmp_flip(StructRNA *srna)
02089 {
02090     PropertyRNA *prop;
02091     
02092     prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
02093     RNA_def_property_enum_sdna(prop, NULL, "custom1");
02094     RNA_def_property_enum_items(prop, node_flip_items);
02095     RNA_def_property_ui_text(prop, "Axis", "");
02096     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02097 }
02098 
02099 static void def_cmp_splitviewer(StructRNA *srna)
02100 {
02101     PropertyRNA *prop;
02102     
02103     static EnumPropertyItem axis_items[] = {
02104         {0, "X",  0, "X",     ""},
02105         {1, "Y",  0, "Y",     ""},
02106         {0, NULL, 0, NULL, NULL}};
02107     
02108     prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
02109     RNA_def_property_enum_sdna(prop, NULL, "custom2");
02110     RNA_def_property_enum_items(prop, axis_items);
02111     RNA_def_property_ui_text(prop, "Axis", "");
02112     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02113 
02114     prop = RNA_def_property(srna, "factor", PROP_INT, PROP_FACTOR);
02115     RNA_def_property_int_sdna(prop, NULL, "custom1");
02116     RNA_def_property_range(prop, 0, 100);
02117     RNA_def_property_ui_text(prop, "Factor", "");
02118     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02119 }
02120 
02121 static void def_cmp_id_mask(StructRNA *srna)
02122 {
02123     PropertyRNA *prop;
02124     
02125     prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
02126     RNA_def_property_int_sdna(prop, NULL, "custom1");
02127     RNA_def_property_range(prop, 0, 32767);
02128     RNA_def_property_ui_text(prop, "Index", "Pass index number to convert to alpha");
02129     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02130 
02131     prop = RNA_def_property(srna, "use_smooth_mask", PROP_BOOLEAN, PROP_NONE);
02132     RNA_def_property_boolean_sdna(prop, NULL, "custom2", 0);
02133     RNA_def_property_ui_text(prop, "Smooth Mask", "Apply an anti-aliasing filter to the mask");
02134     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02135 }
02136 
02137 static void def_cmp_double_edge_mask(StructRNA * srna)
02138 {
02139     PropertyRNA *prop;
02140 
02141     static EnumPropertyItem BufEdgeMode_items[] = {
02142         {0, "BLEED_OUT",  0, "Bleed Out",     "Allow mask pixels to bleed along edges"},
02143         {1, "KEEP_IN",  0, "Keep In",     "Restrict mask pixels from touching edges"},
02144         {0, NULL, 0, NULL, NULL}
02145     };
02146 
02147     static EnumPropertyItem InnerEdgeMode_items[] = {
02148         {0, "ALL", 0, "All", "All pixels on inner mask edge are considered during mask calculation"},
02149         {1, "ADJACENT_ONLY", 0, "Adjacent Only", "Only inner mask pixels adjacent to outer mask pixels are considered during mask calculation"},
02150         {0, NULL, 0, NULL, NULL}
02151     };
02152 
02153     prop = RNA_def_property(srna, "inner_mode", PROP_ENUM, PROP_NONE);
02154     RNA_def_property_enum_sdna(prop, NULL, "custom2");
02155     RNA_def_property_enum_items(prop, InnerEdgeMode_items);
02156     RNA_def_property_ui_text(prop, "Inner Edge Mode", "");
02157     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02158 
02159     prop = RNA_def_property(srna, "edge_mode", PROP_ENUM, PROP_NONE);
02160     RNA_def_property_enum_sdna(prop, NULL, "custom1");
02161     RNA_def_property_enum_items(prop, BufEdgeMode_items);
02162     RNA_def_property_ui_text(prop, "Buffer Edge Mode", "");
02163     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02164 }
02165 
02166 static void def_cmp_map_uv(StructRNA *srna)
02167 {
02168     PropertyRNA *prop;
02169 
02170     prop = RNA_def_property(srna, "alpha", PROP_INT, PROP_FACTOR);
02171     RNA_def_property_int_sdna(prop, NULL, "custom1");
02172     RNA_def_property_range(prop, 0, 100);
02173     RNA_def_property_ui_text(prop, "Alpha", "");
02174     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02175 }
02176 
02177 static void def_cmp_defocus(StructRNA *srna)
02178 {
02179     PropertyRNA *prop;
02180     
02181     static EnumPropertyItem bokeh_items[] = {
02182         {8, "OCTAGON",  0, "Octagonal",  "8 sides"},
02183         {7, "HEPTAGON", 0, "Heptagonal", "7 sides"},
02184         {6, "HEXAGON",  0, "Hexagonal",  "6 sides"},
02185         {5, "PENTAGON", 0, "Pentagonal", "5 sides"},
02186         {4, "SQUARE",   0, "Square",     "4 sides"},
02187         {3, "TRIANGLE", 0, "Triangular", "3 sides"},
02188         {0, "CIRCLE",   0, "Circular",   ""},
02189         {0, NULL, 0, NULL, NULL}};
02190     
02191     RNA_def_struct_sdna_from(srna, "NodeDefocus", "storage");
02192     
02193     prop = RNA_def_property(srna, "bokeh", PROP_ENUM, PROP_NONE);
02194     RNA_def_property_enum_sdna(prop, NULL, "bktype");
02195     RNA_def_property_enum_items(prop, bokeh_items);
02196     RNA_def_property_ui_text(prop, "Bokeh Type", "");
02197     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02198 
02199     /* TODO: angle in degrees */        
02200     prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
02201     RNA_def_property_float_sdna(prop, NULL, "rotation");
02202     RNA_def_property_range(prop, 0.0f, DEG2RADF(90.0f));
02203     RNA_def_property_ui_text(prop, "Angle", "Bokeh shape rotation offset");
02204     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02205     
02206     prop = RNA_def_property(srna, "use_gamma_correction", PROP_BOOLEAN, PROP_NONE);
02207     RNA_def_property_boolean_sdna(prop, NULL, "gamco", 1);
02208     RNA_def_property_ui_text(prop, "Gamma Correction", "Enable gamma correction before and after main process");
02209     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02210 
02211     /* TODO */
02212     prop = RNA_def_property(srna, "f_stop", PROP_FLOAT, PROP_NONE);
02213     RNA_def_property_float_sdna(prop, NULL, "fstop");
02214     RNA_def_property_range(prop, 0.0f, 128.0f);
02215     RNA_def_property_ui_text(prop, "fStop", "Amount of focal blur, 128=infinity=perfect focus, half the value doubles the blur radius");
02216     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02217     
02218     prop = RNA_def_property(srna, "blur_max", PROP_FLOAT, PROP_NONE);
02219     RNA_def_property_float_sdna(prop, NULL, "maxblur");
02220     RNA_def_property_range(prop, 0.0f, 10000.0f);
02221     RNA_def_property_ui_text(prop, "Max Blur", "blur limit, maximum CoC radius, 0=no limit");
02222     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02223     
02224     prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
02225     RNA_def_property_float_sdna(prop, NULL, "bthresh");
02226     RNA_def_property_range(prop, 0.0f, 100.0f);
02227     RNA_def_property_ui_text(prop, "Threshold", "CoC radius threshold, prevents background bleed on in-focus midground, 0=off");
02228     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02229     
02230     prop = RNA_def_property(srna, "use_preview", PROP_BOOLEAN, PROP_NONE);
02231     RNA_def_property_boolean_sdna(prop, NULL, "preview", 1);
02232     RNA_def_property_ui_text(prop, "Preview", "Enable sampling mode, useful for preview when using low samplecounts");
02233     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02234     
02235     prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE);
02236     RNA_def_property_int_sdna(prop, NULL, "samples");
02237     RNA_def_property_range(prop, 16, 256);
02238     RNA_def_property_ui_text(prop, "Samples", "Number of samples (16=grainy, higher=less noise)");
02239     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02240     
02241     prop = RNA_def_property(srna, "use_zbuffer", PROP_BOOLEAN, PROP_NONE);
02242     RNA_def_property_boolean_negative_sdna(prop, NULL, "no_zbuf", 1);
02243     RNA_def_property_ui_text(prop, "Use Z-Buffer", "Disable when using an image as input instead of actual z-buffer (auto enabled if node not image based, eg. time node)");
02244     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02245     
02246     prop = RNA_def_property(srna, "z_scale", PROP_FLOAT, PROP_NONE);
02247     RNA_def_property_float_sdna(prop, NULL, "scale");
02248     RNA_def_property_range(prop, 0.0f, 1000.0f);
02249     RNA_def_property_ui_text(prop, "Z-Scale", "Scale the Z input when not using a z-buffer, controls maximum blur designated by the color white or input value 1");
02250     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02251 }
02252 
02253 static void def_cmp_invert(StructRNA *srna)
02254 {
02255     PropertyRNA *prop;
02256     
02257     prop = RNA_def_property(srna, "invert_rgb", PROP_BOOLEAN, PROP_NONE);
02258     RNA_def_property_boolean_sdna(prop, NULL, "custom1", CMP_CHAN_RGB);
02259     RNA_def_property_ui_text(prop, "RGB", "");
02260     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02261     
02262     prop = RNA_def_property(srna, "invert_alpha", PROP_BOOLEAN, PROP_NONE);
02263     RNA_def_property_boolean_sdna(prop, NULL, "custom1", CMP_CHAN_A);
02264     RNA_def_property_ui_text(prop, "Alpha", "");
02265     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02266 }
02267 
02268 static void def_cmp_crop(StructRNA *srna)
02269 {
02270     PropertyRNA *prop;
02271     
02272     prop = RNA_def_property(srna, "use_crop_size", PROP_BOOLEAN, PROP_NONE);
02273     RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1);
02274     RNA_def_property_ui_text(prop, "Crop Image Size", "Whether to crop the size of the input image");
02275     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02276 
02277     prop = RNA_def_property(srna, "relative", PROP_BOOLEAN, PROP_NONE);
02278     RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1);
02279     RNA_def_property_ui_text(prop, "Relative", "Use relative values to crop image");
02280     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02281 
02282     RNA_def_struct_sdna_from(srna, "NodeTwoXYs", "storage");
02283 
02284     prop = RNA_def_property(srna, "min_x", PROP_INT, PROP_NONE);
02285     RNA_def_property_int_sdna(prop, NULL, "x1");
02286     RNA_def_property_range(prop, 0, 10000);
02287     RNA_def_property_ui_text(prop, "X1", "");
02288     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02289     
02290     prop = RNA_def_property(srna, "max_x", PROP_INT, PROP_NONE);
02291     RNA_def_property_int_sdna(prop, NULL, "x2");
02292     RNA_def_property_range(prop, 0, 10000);
02293     RNA_def_property_ui_text(prop, "X2", "");
02294     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02295     
02296     prop = RNA_def_property(srna, "min_y", PROP_INT, PROP_NONE);
02297     RNA_def_property_int_sdna(prop, NULL, "y1");
02298     RNA_def_property_range(prop, 0, 10000);
02299     RNA_def_property_ui_text(prop, "Y1", "");
02300     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02301     
02302     prop = RNA_def_property(srna, "max_y", PROP_INT, PROP_NONE);
02303     RNA_def_property_int_sdna(prop, NULL, "y2");
02304     RNA_def_property_range(prop, 0, 10000);
02305     RNA_def_property_ui_text(prop, "Y2", "");
02306     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02307 
02308     prop = RNA_def_property(srna, "rel_min_x", PROP_FLOAT, PROP_NONE);
02309     RNA_def_property_float_sdna(prop, NULL, "fac_x1");
02310     RNA_def_property_range(prop, 0.0, 1.0);
02311     RNA_def_property_ui_text(prop, "X1", "");
02312     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02313 
02314     prop = RNA_def_property(srna, "rel_max_x", PROP_FLOAT, PROP_NONE);
02315     RNA_def_property_float_sdna(prop, NULL, "fac_x2");
02316     RNA_def_property_range(prop, 0.0, 1.0);
02317     RNA_def_property_ui_text(prop, "X2", "");
02318     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02319 
02320     prop = RNA_def_property(srna, "rel_min_y", PROP_FLOAT, PROP_NONE);
02321     RNA_def_property_float_sdna(prop, NULL, "fac_y1");
02322     RNA_def_property_range(prop, 0.0, 1.0);
02323     RNA_def_property_ui_text(prop, "Y1", "");
02324     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02325 
02326     prop = RNA_def_property(srna, "rel_max_y", PROP_FLOAT, PROP_NONE);
02327     RNA_def_property_float_sdna(prop, NULL, "fac_y2");
02328     RNA_def_property_range(prop, 0.0, 1.0);
02329     RNA_def_property_ui_text(prop, "Y2", "");
02330     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02331 }
02332 
02333 static void def_cmp_dblur(StructRNA *srna)
02334 {
02335     PropertyRNA *prop;
02336     
02337     RNA_def_struct_sdna_from(srna, "NodeDBlurData", "storage");
02338     
02339     prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
02340     RNA_def_property_int_sdna(prop, NULL, "iter");
02341     RNA_def_property_range(prop, 1, 32);
02342     RNA_def_property_ui_text(prop, "Iterations", "");
02343     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02344     
02345     prop = RNA_def_property(srna, "use_wrap", PROP_BOOLEAN, PROP_NONE);
02346     RNA_def_property_boolean_sdna(prop, NULL, "wrap", 1);
02347     RNA_def_property_ui_text(prop, "Wrap", "");
02348     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02349     
02350     prop = RNA_def_property(srna, "center_x", PROP_FLOAT, PROP_NONE);
02351     RNA_def_property_float_sdna(prop, NULL, "center_x");
02352     RNA_def_property_range(prop, 0.0f, 1.0f);
02353     RNA_def_property_ui_text(prop, "Center X", "");
02354     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02355     
02356     prop = RNA_def_property(srna, "center_y", PROP_FLOAT, PROP_NONE);
02357     RNA_def_property_float_sdna(prop, NULL, "center_y");
02358     RNA_def_property_range(prop, 0.0f, 1.0f);
02359     RNA_def_property_ui_text(prop, "Center Y", "");
02360     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02361     
02362     prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
02363     RNA_def_property_float_sdna(prop, NULL, "distance");
02364     RNA_def_property_range(prop, -1.0f, 1.0f);
02365     RNA_def_property_ui_text(prop, "Distance", "");
02366     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02367     
02368     prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
02369     RNA_def_property_float_sdna(prop, NULL, "angle");
02370     RNA_def_property_range(prop, 0.0f, DEG2RADF(360.0f));
02371     RNA_def_property_ui_text(prop, "Angle", "");
02372     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02373     
02374     prop = RNA_def_property(srna, "spin", PROP_FLOAT, PROP_ANGLE);
02375     RNA_def_property_float_sdna(prop, NULL, "spin");
02376     RNA_def_property_range(prop, DEG2RADF(-360.0f), DEG2RADF(360.0f));
02377     RNA_def_property_ui_text(prop, "Spin", "");
02378     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02379     
02380     prop = RNA_def_property(srna, "zoom", PROP_FLOAT, PROP_NONE);
02381     RNA_def_property_float_sdna(prop, NULL, "zoom");
02382     RNA_def_property_range(prop, 0.0f, 100.0f);
02383     RNA_def_property_ui_text(prop, "Zoom", "");
02384     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02385 }
02386 
02387 static void def_cmp_bilateral_blur(StructRNA *srna)
02388 {
02389     PropertyRNA *prop;
02390     
02391     RNA_def_struct_sdna_from(srna, "NodeBilateralBlurData", "storage");
02392     
02393     prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
02394     RNA_def_property_int_sdna(prop, NULL, "iter");
02395     RNA_def_property_range(prop, 1, 128);
02396     RNA_def_property_ui_text(prop, "Iterations", "");
02397     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02398     
02399     prop = RNA_def_property(srna, "sigma_color", PROP_FLOAT, PROP_NONE);
02400     RNA_def_property_float_sdna(prop, NULL, "sigma_color");
02401     RNA_def_property_range(prop, 0.01f, 3.0f);
02402     RNA_def_property_ui_text(prop, "Color Sigma", "");
02403     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02404     
02405     prop = RNA_def_property(srna, "sigma_space", PROP_FLOAT, PROP_NONE);
02406     RNA_def_property_float_sdna(prop, NULL, "sigma_space");
02407     RNA_def_property_range(prop, 0.01f, 30.0f);
02408     RNA_def_property_ui_text(prop, "Space Sigma", "");  
02409     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02410 }
02411 
02412 static void def_cmp_premul_key(StructRNA *srna)
02413 {
02414     PropertyRNA *prop;
02415     
02416     static EnumPropertyItem type_items[] = {
02417         {0, "KEY_TO_PREMUL", 0, "Key to Premul", ""},
02418         {1, "PREMUL_TO_KEY", 0, "Premul to Key", ""},
02419         {0, NULL, 0, NULL, NULL}};
02420     
02421     prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
02422     RNA_def_property_enum_sdna(prop, NULL, "custom1");
02423     RNA_def_property_enum_items(prop, type_items);
02424     RNA_def_property_ui_text(prop, "Mapping", "Conversion between premultiplied alpha and key alpha");
02425     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02426     
02427 }
02428 
02429 static void def_cmp_glare(StructRNA *srna)
02430 {
02431     PropertyRNA *prop;
02432     
02433     static EnumPropertyItem type_items[] = {
02434         {3, "GHOSTS",      0, "Ghosts",      ""},
02435         {2, "STREAKS",     0, "Streaks",     ""},
02436         {1, "FOG_GLOW",    0, "Fog Glow",    ""},
02437         {0, "SIMPLE_STAR", 0, "Simple Star", ""},
02438         {0, NULL, 0, NULL, NULL}};
02439     
02440     static EnumPropertyItem quality_items[] = {
02441         {0, "HIGH",   0, "High",   ""},
02442         {1, "MEDIUM", 0, "Medium", ""},
02443         {2, "LOW",    0, "Low",    ""},
02444         {0, NULL, 0, NULL, NULL}};
02445     
02446     RNA_def_struct_sdna_from(srna, "NodeGlare", "storage");
02447     
02448     prop = RNA_def_property(srna, "glare_type", PROP_ENUM, PROP_NONE);
02449     RNA_def_property_enum_sdna(prop, NULL, "type");
02450     RNA_def_property_enum_items(prop, type_items);
02451     RNA_def_property_ui_text(prop, "Glare Type", "");
02452     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02453     
02454     prop = RNA_def_property(srna, "quality", PROP_ENUM, PROP_NONE);
02455     RNA_def_property_enum_sdna(prop, NULL, "quality");
02456     RNA_def_property_enum_items(prop, quality_items);
02457     RNA_def_property_ui_text(prop, "Quality", "If not set to high quality, the effect will be applied to a low-res copy of the source image");
02458     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02459     
02460     prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
02461     RNA_def_property_int_sdna(prop, NULL, "iter");
02462     RNA_def_property_range(prop, 2, 5);
02463     RNA_def_property_ui_text(prop, "Iterations", "");
02464     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02465     
02466     prop = RNA_def_property(srna, "color_modulation", PROP_FLOAT, PROP_NONE);
02467     RNA_def_property_float_sdna(prop, NULL, "colmod");
02468     RNA_def_property_range(prop, 0.0f, 1.0f);
02469     RNA_def_property_ui_text(prop, "Color Modulation", "Amount of Color Modulation, modulates colors of streaks and ghosts for a spectral dispersion effect");
02470     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02471     
02472     prop = RNA_def_property(srna, "mix", PROP_FLOAT, PROP_NONE);
02473     RNA_def_property_float_sdna(prop, NULL, "mix");
02474     RNA_def_property_range(prop, -1.0f, 1.0f);
02475     RNA_def_property_ui_text(prop, "Mix", "-1 is original image only, 0 is exact 50/50 mix, 1 is processed image only");
02476     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02477     
02478     prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
02479     RNA_def_property_float_sdna(prop, NULL, "threshold");
02480     RNA_def_property_range(prop, 0.0f, 1000.0f);
02481     RNA_def_property_ui_text(prop, "Threshold", "The glare filter will only be applied to pixels brighter than this value");
02482     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02483     
02484     prop = RNA_def_property(srna, "streaks", PROP_INT, PROP_NONE);
02485     RNA_def_property_int_sdna(prop, NULL, "angle");
02486     RNA_def_property_range(prop, 2, 16);
02487     RNA_def_property_ui_text(prop, "Streaks", "Total number of streaks");
02488     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02489     
02490     prop = RNA_def_property(srna, "angle_offset", PROP_FLOAT, PROP_ANGLE);
02491     RNA_def_property_float_sdna(prop, NULL, "angle_ofs");
02492     RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
02493     RNA_def_property_ui_text(prop, "Angle Offset", "Streak angle offset");
02494     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02495     
02496     prop = RNA_def_property(srna, "fade", PROP_FLOAT, PROP_NONE);
02497     RNA_def_property_float_sdna(prop, NULL, "fade");
02498     RNA_def_property_range(prop, 0.75f, 1.0f);
02499     RNA_def_property_ui_text(prop, "Fade", "Streak fade-out factor");
02500     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02501     
02502     prop = RNA_def_property(srna, "use_rotate_45", PROP_BOOLEAN, PROP_NONE);
02503     RNA_def_property_boolean_sdna(prop, NULL, "angle", 0);
02504     RNA_def_property_ui_text(prop, "Rotate 45", "Simple star filter: add 45 degree rotation offset");
02505     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02506     
02507     prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE);
02508     RNA_def_property_int_sdna(prop, NULL, "size");
02509     RNA_def_property_range(prop, 6, 9);
02510     RNA_def_property_ui_text(prop, "Size", "Glow/glare size (not actual size; relative to initial size of bright area of pixels)");
02511     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02512     
02513     /* TODO */
02514 }
02515 
02516 static void def_cmp_tonemap(StructRNA *srna)
02517 {
02518     PropertyRNA *prop;
02519     
02520     static EnumPropertyItem type_items[] = {
02521         {1, "RD_PHOTORECEPTOR", 0, "R/D Photoreceptor", ""},
02522         {0, "RH_SIMPLE",        0, "Rh Simple",         ""},
02523         {0, NULL, 0, NULL, NULL}};
02524     
02525     RNA_def_struct_sdna_from(srna, "NodeTonemap", "storage");
02526     
02527     prop = RNA_def_property(srna, "tonemap_type", PROP_ENUM, PROP_NONE);
02528     RNA_def_property_enum_sdna(prop, NULL, "type");
02529     RNA_def_property_enum_items(prop, type_items);
02530     RNA_def_property_ui_text(prop, "Tonemap Type", "");
02531     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02532     
02533     prop = RNA_def_property(srna, "key", PROP_FLOAT, PROP_NONE);
02534     RNA_def_property_float_sdna(prop, NULL, "key");
02535     RNA_def_property_range(prop, 0.0f, 1.0f);
02536     RNA_def_property_ui_text(prop, "Key", "The value the average luminance is mapped to");
02537     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02538     
02539     prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
02540     RNA_def_property_float_sdna(prop, NULL, "offset");
02541     RNA_def_property_range(prop, 0.001f, 10.0f);
02542     RNA_def_property_ui_text(prop, "Offset", "Normally always 1, but can be used as an extra control to alter the brightness curve");
02543     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02544     
02545     prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_NONE);
02546     RNA_def_property_float_sdna(prop, NULL, "gamma");
02547     RNA_def_property_range(prop, 0.001f, 3.0f);
02548     RNA_def_property_ui_text(prop, "Gamma", "If not used, set to 1");
02549     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02550     
02551     prop = RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE);
02552     RNA_def_property_float_sdna(prop, NULL, "f");
02553     RNA_def_property_range(prop, -8.0f, 8.0f);
02554     RNA_def_property_ui_text(prop, "Intensity", "If less than zero, darkens image; otherwise, makes it brighter");
02555     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02556     
02557     prop = RNA_def_property(srna, "contrast", PROP_FLOAT, PROP_NONE);
02558     RNA_def_property_float_sdna(prop, NULL, "m");
02559     RNA_def_property_range(prop, 0.0f, 1.0f);
02560     RNA_def_property_ui_text(prop, "Contrast", "Set to 0 to use estimate from input image");
02561     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02562     
02563     prop = RNA_def_property(srna, "adaptation", PROP_FLOAT, PROP_NONE);
02564     RNA_def_property_float_sdna(prop, NULL, "a");
02565     RNA_def_property_range(prop, 0.0f, 1.0f);
02566     RNA_def_property_ui_text(prop, "Adaptation", "If 0, global; if 1, based on pixel intensity");
02567     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02568     
02569     prop = RNA_def_property(srna, "correction", PROP_FLOAT, PROP_NONE);
02570     RNA_def_property_float_sdna(prop, NULL, "c");
02571     RNA_def_property_range(prop, 0.0f, 1.0f);
02572     RNA_def_property_ui_text(prop, "Color Correction", "If 0, same for all channels; if 1, each independent");
02573     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02574 }
02575 
02576 static void def_cmp_lensdist(StructRNA *srna)
02577 {
02578     PropertyRNA *prop;
02579     
02580     RNA_def_struct_sdna_from(srna, "NodeLensDist", "storage");
02581     
02582     prop = RNA_def_property(srna, "use_projector", PROP_BOOLEAN, PROP_NONE);
02583     RNA_def_property_boolean_sdna(prop, NULL, "proj", 1);
02584     RNA_def_property_ui_text(prop, "Projector", "Enable/disable projector mode (the effect is applied in horizontal direction only)");
02585     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02586     
02587     prop = RNA_def_property(srna, "use_jitter", PROP_BOOLEAN, PROP_NONE);
02588     RNA_def_property_boolean_sdna(prop, NULL, "jit", 1);
02589     RNA_def_property_ui_text(prop, "Jitter", "Enable/disable jittering (faster, but also noisier)");
02590     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02591     
02592     prop = RNA_def_property(srna, "use_fit", PROP_BOOLEAN, PROP_NONE);
02593     RNA_def_property_boolean_sdna(prop, NULL, "fit", 1);
02594     RNA_def_property_ui_text(prop, "Fit", "For positive distortion factor only: scale image such that black areas are not visible");
02595     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02596 }
02597 
02598 static void def_cmp_colorbalance(StructRNA *srna)
02599 {
02600     PropertyRNA *prop;
02601     static float default_1[3] = {1.f, 1.f, 1.f};
02602     
02603     static EnumPropertyItem type_items[] = {
02604         {0, "LIFT_GAMMA_GAIN",      0, "Lift/Gamma/Gain",      ""},
02605         {1, "OFFSET_POWER_SLOPE",     0, "Offset/Power/Slope (ASC-CDL)",     "ASC-CDL standard color correction"},
02606         {0, NULL, 0, NULL, NULL}};
02607     
02608     prop = RNA_def_property(srna, "correction_method", PROP_ENUM, PROP_NONE);
02609     RNA_def_property_enum_sdna(prop, NULL, "custom1");
02610     RNA_def_property_enum_items(prop, type_items);
02611     RNA_def_property_ui_text(prop, "Correction Formula", "");
02612     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02613     
02614     RNA_def_struct_sdna_from(srna, "NodeColorBalance", "storage");
02615     
02616     prop = RNA_def_property(srna, "lift", PROP_FLOAT, PROP_COLOR_GAMMA);
02617     RNA_def_property_float_sdna(prop, NULL, "lift");
02618     RNA_def_property_array(prop, 3);
02619     RNA_def_property_float_array_default(prop, default_1);
02620     RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
02621     RNA_def_property_ui_text(prop, "Lift", "Correction for Shadows");
02622     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02623     
02624     prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_COLOR_GAMMA);
02625     RNA_def_property_float_sdna(prop, NULL, "gamma");
02626     RNA_def_property_array(prop, 3);
02627     RNA_def_property_float_array_default(prop, default_1);
02628     RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
02629     RNA_def_property_ui_text(prop, "Gamma", "Correction for Midtones");
02630     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02631     
02632     prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_COLOR_GAMMA);
02633     RNA_def_property_float_sdna(prop, NULL, "gain");
02634     RNA_def_property_array(prop, 3);
02635     RNA_def_property_float_array_default(prop, default_1);
02636     RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
02637     RNA_def_property_ui_text(prop, "Gain", "Correction for Highlights");
02638     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02639     
02640     
02641     prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_COLOR_GAMMA);
02642     RNA_def_property_float_sdna(prop, NULL, "lift");
02643     RNA_def_property_array(prop, 3);
02644     RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
02645     RNA_def_property_ui_text(prop, "Offset", "Correction for Shadows");
02646     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02647     
02648     prop = RNA_def_property(srna, "power", PROP_FLOAT, PROP_COLOR_GAMMA);
02649     RNA_def_property_float_sdna(prop, NULL, "gamma");
02650     RNA_def_property_array(prop, 3);
02651     RNA_def_property_float_array_default(prop, default_1);
02652     RNA_def_property_range(prop, 0.f, FLT_MAX);
02653     RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
02654     RNA_def_property_ui_text(prop, "Power", "Correction for Midtones");
02655     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02656     
02657     prop = RNA_def_property(srna, "slope", PROP_FLOAT, PROP_COLOR_GAMMA);
02658     RNA_def_property_float_sdna(prop, NULL, "gain");
02659     RNA_def_property_array(prop, 3);
02660     RNA_def_property_float_array_default(prop, default_1);
02661     RNA_def_property_range(prop, 0.f, FLT_MAX);
02662     RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
02663     RNA_def_property_ui_text(prop, "Slope", "Correction for Highlights");
02664     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02665 }
02666 
02667 static void def_cmp_huecorrect(StructRNA *srna)
02668 {
02669     PropertyRNA *prop;
02670     
02671     prop = RNA_def_property(srna, "mapping", PROP_POINTER, PROP_NONE);
02672     RNA_def_property_pointer_sdna(prop, NULL, "storage");
02673     RNA_def_property_struct_type(prop, "CurveMapping");
02674     RNA_def_property_ui_text(prop, "Mapping", "");
02675     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02676 }
02677 
02678 static void def_cmp_zcombine(StructRNA *srna)
02679 {
02680     PropertyRNA *prop;
02681     
02682     prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
02683     RNA_def_property_boolean_sdna(prop, NULL, "custom1", 0);
02684     RNA_def_property_ui_text(prop, "Use Alpha", "Take Alpha channel into account when doing the Z operation");
02685     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02686 }
02687 
02688 static void def_cmp_ycc(StructRNA *srna)
02689 {
02690     PropertyRNA *prop;
02691     
02692     prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
02693     RNA_def_property_enum_sdna(prop, NULL, "custom1");
02694     RNA_def_property_enum_items(prop, node_ycc_items);
02695     RNA_def_property_ui_text(prop, "Mode", "");
02696     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02697 }
02698 
02699 static void def_cmp_movieclip(StructRNA *srna)
02700 {
02701     PropertyRNA *prop;
02702 
02703     prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE);
02704     RNA_def_property_pointer_sdna(prop, NULL, "id");
02705     RNA_def_property_struct_type(prop, "MovieClip");
02706     RNA_def_property_flag(prop, PROP_EDITABLE);
02707     RNA_def_property_ui_text(prop, "Movie Clip", "");
02708     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02709 
02710     RNA_def_struct_sdna_from(srna, "MovieClipUser", "storage");
02711 }
02712 
02713 static void def_cmp_stabilize2d(StructRNA *srna)
02714 {
02715     PropertyRNA *prop;
02716 
02717     static EnumPropertyItem filter_type_items[] = {
02718         {0, "NEAREST",   0, "Nearest",   ""},
02719         {1, "BILINEAR",   0, "Bilinear",   ""},
02720         {2, "BICUBIC", 0, "Bicubic", ""},
02721         {0, NULL, 0, NULL, NULL}};
02722 
02723     prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE);
02724     RNA_def_property_pointer_sdna(prop, NULL, "id");
02725     RNA_def_property_struct_type(prop, "MovieClip");
02726     RNA_def_property_flag(prop, PROP_EDITABLE);
02727     RNA_def_property_ui_text(prop, "Movie Clip", "");
02728     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02729 
02730     prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE);
02731     RNA_def_property_enum_sdna(prop, NULL, "custom1");
02732     RNA_def_property_enum_items(prop, filter_type_items);
02733     RNA_def_property_ui_text(prop, "Filter", "Method to use to filter stabilization");
02734     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02735 }
02736 
02737 static void def_cmp_moviedistortion(StructRNA *srna)
02738 {
02739     PropertyRNA *prop;
02740 
02741     static EnumPropertyItem distortion_type_items[] = {
02742         {0, "UNDISTORT",   0, "Undistort",   ""},
02743         {1, "DISTORT", 0, "Distort", ""},
02744         {0, NULL, 0, NULL, NULL}};
02745 
02746     prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE);
02747     RNA_def_property_pointer_sdna(prop, NULL, "id");
02748     RNA_def_property_struct_type(prop, "MovieClip");
02749     RNA_def_property_flag(prop, PROP_EDITABLE);
02750     RNA_def_property_ui_text(prop, "Movie Clip", "");
02751     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02752 
02753     prop = RNA_def_property(srna, "distortion_type", PROP_ENUM, PROP_NONE);
02754     RNA_def_property_enum_sdna(prop, NULL, "custom1");
02755     RNA_def_property_enum_items(prop, distortion_type_items);
02756     RNA_def_property_ui_text(prop, "Distortion", "Distortion to use to filter image");
02757     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02758 }
02759 
02760 static void dev_cmd_transform(StructRNA *srna)
02761 {
02762     PropertyRNA *prop;
02763 
02764     static EnumPropertyItem filter_type_items[] = {
02765         {0, "NEAREST",   0, "Nearest",   ""},
02766         {1, "BILINEAR",   0, "Bilinear",   ""},
02767         {2, "BICUBIC", 0, "Bicubic", ""},
02768         {0, NULL, 0, NULL, NULL}};
02769 
02770     prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE);
02771     RNA_def_property_enum_sdna(prop, NULL, "custom1");
02772     RNA_def_property_enum_items(prop, filter_type_items);
02773     RNA_def_property_ui_text(prop, "Filter", "Method to use to filter transform");
02774     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02775 }
02776 
02777 
02778 /* -- Texture Nodes --------------------------------------------------------- */
02779 
02780 static void def_tex_output(StructRNA *srna)
02781 {
02782     PropertyRNA *prop;
02783 
02784     RNA_def_struct_sdna_from(srna, "TexNodeOutput", "storage");
02785     
02786     prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_NONE);
02787     RNA_def_property_string_sdna(prop, NULL, "name");
02788     RNA_def_property_ui_text(prop, "Output Name", "");
02789     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02790 }
02791 
02792 static void def_tex_image(StructRNA *srna)
02793 {
02794     PropertyRNA *prop;
02795 
02796     prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
02797     RNA_def_property_pointer_sdna(prop, NULL, "id");
02798     RNA_def_property_struct_type(prop, "Image");
02799     RNA_def_property_flag(prop, PROP_EDITABLE);
02800     RNA_def_property_ui_text(prop, "Image", "");
02801     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02802     
02803     /* is this supposed to be exposed? not sure..
02804     prop = RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE);
02805     RNA_def_property_pointer_sdna(prop, NULL, "storage");
02806     RNA_def_property_struct_type(prop, "ImageUser");
02807     RNA_def_property_ui_text(prop, "Settings", "");
02808     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02809      */
02810 }
02811 
02812 static void def_tex_bricks(StructRNA *srna)
02813 {
02814     PropertyRNA *prop;
02815 
02816     prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
02817     RNA_def_property_float_sdna(prop, NULL, "custom3");
02818     RNA_def_property_range(prop, 0.0f, 1.0f);
02819     RNA_def_property_ui_text(prop, "Offset Amount", "");
02820     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02821     
02822     prop = RNA_def_property(srna, "offset_frequency", PROP_INT, PROP_NONE);
02823     RNA_def_property_int_sdna(prop, NULL, "custom1");
02824     RNA_def_property_range(prop, 2, 99);
02825     RNA_def_property_ui_text(prop, "Offset Frequency", "Offset every N rows");
02826     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02827     
02828     prop = RNA_def_property(srna, "squash", PROP_FLOAT, PROP_NONE);
02829     RNA_def_property_float_sdna(prop, NULL, "custom4");
02830     RNA_def_property_range(prop, 0.0f, 99.0f);
02831     RNA_def_property_ui_text(prop, "Squash Amount", "");
02832     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02833     
02834     prop = RNA_def_property(srna, "squash_frequency", PROP_INT, PROP_NONE);
02835     RNA_def_property_int_sdna(prop, NULL, "custom2");
02836     RNA_def_property_range(prop, 2, 99);
02837     RNA_def_property_ui_text(prop, "Squash Frequency", "Squash every N rows");
02838     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
02839 }
02840 
02841 /* -------------------------------------------------------------------------- */
02842 
02843 static EnumPropertyItem shader_node_type_items[MaxNodes];
02844 static void rna_def_shader_node(BlenderRNA *brna)
02845 {
02846     StructRNA *srna;
02847     PropertyRNA *prop;
02848     
02849     alloc_node_type_items(shader_node_type_items, Category_ShaderNode);
02850 
02851     srna = RNA_def_struct(brna, "ShaderNode", "Node");
02852     RNA_def_struct_ui_text(srna, "Shader Node", "Material shader node");
02853     RNA_def_struct_sdna(srna, "bNode");
02854 
02855     prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
02856     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
02857     RNA_def_property_enum_items(prop, shader_node_type_items);
02858     RNA_def_property_ui_text(prop, "Type", "");
02859 }
02860 
02861 static EnumPropertyItem compositor_node_type_items[MaxNodes];
02862 static void rna_def_compositor_node(BlenderRNA *brna)
02863 {
02864     StructRNA *srna;
02865     PropertyRNA *prop;
02866     
02867     alloc_node_type_items(compositor_node_type_items, Category_CompositorNode);
02868     
02869     srna = RNA_def_struct(brna, "CompositorNode", "Node");
02870     RNA_def_struct_ui_text(srna, "Compositor Node", "");
02871     RNA_def_struct_sdna(srna, "bNode");
02872 
02873     prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
02874     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
02875     RNA_def_property_enum_items(prop, compositor_node_type_items);
02876     RNA_def_property_ui_text(prop, "Type", "");
02877 }
02878 
02879 static EnumPropertyItem texture_node_type_items[MaxNodes];
02880 static void rna_def_texture_node(BlenderRNA *brna)
02881 {
02882     StructRNA *srna;
02883     PropertyRNA *prop;
02884     
02885     alloc_node_type_items(texture_node_type_items, Category_TextureNode);
02886     
02887     srna = RNA_def_struct(brna, "TextureNode", "Node");
02888     RNA_def_struct_ui_text(srna, "Texture Node", "");
02889     RNA_def_struct_sdna(srna, "bNode");
02890 
02891     prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
02892     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
02893     RNA_def_property_enum_items(prop, texture_node_type_items);
02894     RNA_def_property_ui_text(prop, "Type", "");
02895 }
02896 
02897 /* -------------------------------------------------------------------------- */
02898 
02899 static void rna_def_nodetree_link_api(BlenderRNA *brna, PropertyRNA *cprop)
02900 {
02901     StructRNA *srna;
02902     PropertyRNA *parm;
02903     FunctionRNA *func;
02904 
02905     RNA_def_property_srna(cprop, "NodeLinks");
02906     srna= RNA_def_struct(brna, "NodeLinks", NULL);
02907     RNA_def_struct_sdna(srna, "bNodeTree");
02908     RNA_def_struct_ui_text(srna, "Node Links", "Collection of Node Links");
02909 
02910     func= RNA_def_function(srna, "new", "rna_NodeTree_link_new");
02911     RNA_def_function_ui_description(func, "Add a node link to this node tree");
02912     RNA_def_function_flag(func, FUNC_USE_REPORTS);
02913     parm= RNA_def_pointer(func, "input", "NodeSocket", "", "The input socket");
02914     RNA_def_property_flag(parm, PROP_REQUIRED);
02915     parm= RNA_def_pointer(func, "output", "NodeSocket", "", "The output socket");
02916     RNA_def_property_flag(parm, PROP_REQUIRED);
02917     /* return */
02918     parm= RNA_def_pointer(func, "link", "NodeLink", "", "New node link");
02919     RNA_def_function_return(func, parm);
02920 
02921     func= RNA_def_function(srna, "remove", "rna_NodeTree_link_remove");
02922     RNA_def_function_ui_description(func, "remove a node link from the node tree");
02923     RNA_def_function_flag(func, FUNC_USE_REPORTS);
02924     parm= RNA_def_pointer(func, "link", "NodeLink", "", "The node link to remove");
02925     RNA_def_property_flag(parm, PROP_REQUIRED);
02926 
02927     func= RNA_def_function(srna, "clear", "rna_NodeTree_link_clear");
02928     RNA_def_function_ui_description(func, "remove all node links from the node tree");
02929 }
02930 
02931 static void rna_def_composite_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop)
02932 {
02933     StructRNA *srna;
02934     PropertyRNA *parm;
02935     FunctionRNA *func;
02936 
02937     RNA_def_property_srna(cprop, "CompositorNodes");
02938     srna= RNA_def_struct(brna, "CompositorNodes", NULL);
02939     RNA_def_struct_sdna(srna, "bNodeTree");
02940     RNA_def_struct_ui_text(srna, "Compositor Nodes", "Collection of Compositor Nodes");
02941 
02942     func= RNA_def_function(srna, "new", "rna_NodeTree_node_composite_new");
02943     RNA_def_function_ui_description(func, "Add a node to this node tree");
02944     RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
02945     parm= RNA_def_enum(func, "type", compositor_node_type_items, 0, "Type", "Type of node to add");
02946     RNA_def_property_flag(parm, PROP_REQUIRED);
02947     RNA_def_pointer(func, "group", "NodeTree", "", "The group tree");
02948     /* return value */
02949     parm= RNA_def_pointer(func, "node", "Node", "", "New node");
02950     RNA_def_function_return(func, parm);
02951 
02952     func= RNA_def_function(srna, "remove", "rna_NodeTree_node_remove");
02953     RNA_def_function_ui_description(func, "Remove a node from this node tree");
02954     RNA_def_function_flag(func, FUNC_USE_REPORTS);
02955     parm= RNA_def_pointer(func, "node", "Node", "", "The node to remove");
02956     RNA_def_property_flag(parm, PROP_REQUIRED);
02957 
02958     func= RNA_def_function(srna, "clear", "rna_NodeTree_node_clear");
02959     RNA_def_function_ui_description(func, "Remove all nodes from this node tree");
02960 }
02961 
02962 static void rna_def_shader_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop)
02963 {
02964     StructRNA *srna;
02965     PropertyRNA *parm;
02966     FunctionRNA *func;
02967 
02968     RNA_def_property_srna(cprop, "ShaderNodes");
02969     srna= RNA_def_struct(brna, "ShaderNodes", NULL);
02970     RNA_def_struct_sdna(srna, "bNodeTree");
02971     RNA_def_struct_ui_text(srna, "Shader Nodes", "Collection of Shader Nodes");
02972 
02973     func= RNA_def_function(srna, "new", "rna_NodeTree_node_new");
02974     RNA_def_function_ui_description(func, "Add a node to this node tree");
02975     RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
02976     parm= RNA_def_enum(func, "type", shader_node_type_items, 0, "Type", "Type of node to add");
02977     RNA_def_property_flag(parm, PROP_REQUIRED);
02978     RNA_def_pointer(func, "group", "NodeTree", "", "The group tree");
02979     /* return value */
02980     parm= RNA_def_pointer(func, "node", "Node", "", "New node");
02981     RNA_def_function_return(func, parm);
02982 
02983     func= RNA_def_function(srna, "remove", "rna_NodeTree_node_remove");
02984     RNA_def_function_ui_description(func, "Remove a node from this node tree");
02985     RNA_def_function_flag(func, FUNC_USE_REPORTS);
02986     parm= RNA_def_pointer(func, "node", "Node", "", "The node to remove");
02987     RNA_def_property_flag(parm, PROP_REQUIRED);
02988 
02989     func= RNA_def_function(srna, "clear", "rna_NodeTree_node_clear");
02990     RNA_def_function_ui_description(func, "Remove all nodes from this node tree");
02991 }
02992 
02993 static void rna_def_texture_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop)
02994 {
02995     StructRNA *srna;
02996     PropertyRNA *parm;
02997     FunctionRNA *func;
02998 
02999     RNA_def_property_srna(cprop, "TextureNodes");
03000     srna= RNA_def_struct(brna, "TextureNodes", NULL);
03001     RNA_def_struct_sdna(srna, "bNodeTree");
03002     RNA_def_struct_ui_text(srna, "Texture Nodes", "Collection of Texture Nodes");
03003 
03004     func= RNA_def_function(srna, "new", "rna_NodeTree_node_texture_new");
03005     RNA_def_function_ui_description(func, "Add a node to this node tree");
03006     RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
03007     parm= RNA_def_enum(func, "type", texture_node_type_items, 0, "Type", "Type of node to add");
03008     RNA_def_property_flag(parm, PROP_REQUIRED);
03009     RNA_def_pointer(func, "group", "NodeTree", "", "The group tree");
03010     /* return value */
03011     parm= RNA_def_pointer(func, "node", "Node", "", "New node");
03012     RNA_def_function_return(func, parm);
03013 
03014     func= RNA_def_function(srna, "remove", "rna_NodeTree_node_remove");
03015     RNA_def_function_ui_description(func, "Remove a node from this node tree");
03016     RNA_def_function_flag(func, FUNC_USE_REPORTS);
03017     parm= RNA_def_pointer(func, "node", "Node", "", "The node to remove");
03018     RNA_def_property_flag(parm, PROP_REQUIRED);
03019 
03020     func= RNA_def_function(srna, "clear", "rna_NodeTree_node_clear");
03021     RNA_def_function_ui_description(func, "Remove all nodes from this node tree");
03022 }
03023 
03024 static void rna_def_node_socket(BlenderRNA *brna)
03025 {
03026     StructRNA *srna;
03027     PropertyRNA *prop;
03028 
03029     srna = RNA_def_struct(brna, "NodeSocket", NULL);
03030     RNA_def_struct_ui_text(srna, "Node Socket", "Input or output socket of a node");
03031     RNA_def_struct_sdna(srna, "bNodeSocket");
03032     RNA_def_struct_refine_func(srna, "rna_NodeSocket_refine");
03033     RNA_def_struct_ui_icon(srna, ICON_PLUG);
03034     RNA_def_struct_path_func(srna, "rna_NodeSocket_path");
03035 
03036     prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
03037     RNA_def_property_enum_sdna(prop, NULL, "type");
03038     RNA_def_property_enum_items(prop, node_socket_type_items);
03039     RNA_def_property_enum_default(prop, 0);
03040     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
03041     RNA_def_property_ui_text(prop, "Type", "Node Socket type");
03042 
03043     prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
03044     /* XXX must be editable for group sockets. if necessary use a special rna definition for these */
03045 //  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
03046     RNA_def_property_ui_text(prop, "Name", "Socket name");
03047     RNA_def_struct_name_property(srna, prop);
03048     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeGroupSocket_update");
03049 
03050     prop = RNA_def_property(srna, "group_socket", PROP_POINTER, PROP_NONE);
03051     RNA_def_property_pointer_sdna(prop, NULL, "groupsock");
03052     RNA_def_property_struct_type(prop, "NodeSocket");
03053     RNA_def_property_ui_text(prop, "Group Socket", "For group nodes, the group input or output socket this corresponds to");
03054 
03055     prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
03056     RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SOCK_COLLAPSED);
03057     RNA_def_property_ui_text(prop, "Expanded", "Socket links are expanded in the user interface");
03058     RNA_def_property_update(prop, NC_NODE|NA_EDITED, NULL);
03059 }
03060 
03061 static void rna_def_node_socket_subtype(BlenderRNA *brna, int type, int subtype, const char *name, const char *ui_name)
03062 {
03063     StructRNA *srna;
03064     PropertyRNA *prop=NULL;
03065     PropertySubType propsubtype= PROP_NONE;
03066     
03067     #define SUBTYPE(socktype, stypename, id, idname)    { PROP_##id, #socktype "_" #id, 0, #idname, ""},
03068     static EnumPropertyItem subtype_items[] = {
03069         NODE_DEFINE_SUBTYPES
03070         {0, NULL, 0, NULL, NULL}
03071     };
03072     #undef SUBTYPE
03073 
03074     #define SUBTYPE(socktype, stypename, id, idname)    if (subtype==PROP_##id) propsubtype = PROP_##id;
03075     NODE_DEFINE_SUBTYPES
03076     #undef SUBTYPE
03077     
03078     srna = RNA_def_struct(brna, name, "NodeSocket");
03079     RNA_def_struct_ui_text(srna, ui_name, "Input or output socket of a node");
03080     RNA_def_struct_sdna(srna, "bNodeSocket");
03081     RNA_def_struct_ui_icon(srna, ICON_PLUG);
03082     RNA_def_struct_path_func(srna, "rna_NodeSocket_path");
03083     
03084     switch (type) {
03085     case SOCK_INT:
03086         RNA_def_struct_sdna_from(srna, "bNodeSocketValueInt", "default_value");
03087         
03088         prop = RNA_def_property(srna, "subtype", PROP_ENUM, PROP_NONE);
03089         RNA_def_property_enum_sdna(prop, NULL, "subtype");
03090         RNA_def_property_enum_items(prop, subtype_items);
03091         RNA_def_property_ui_text(prop, "Subtype", "Subtype defining the socket value details");
03092         RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update");
03093         
03094         prop = RNA_def_property(srna, "default_value", PROP_INT, propsubtype);
03095         RNA_def_property_int_sdna(prop, NULL, "value");
03096         RNA_def_property_int_funcs(prop, NULL, NULL, "rna_NodeSocketInt_range");
03097         RNA_def_property_ui_text(prop, "Default Value", "");
03098         RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update");
03099         break;
03100     case SOCK_FLOAT:
03101         RNA_def_struct_sdna_from(srna, "bNodeSocketValueFloat", "default_value");
03102         
03103         prop = RNA_def_property(srna, "subtype", PROP_ENUM, PROP_NONE);
03104         RNA_def_property_enum_sdna(prop, NULL, "subtype");
03105         RNA_def_property_enum_items(prop, subtype_items);
03106         RNA_def_property_ui_text(prop, "Subtype", "Subtype defining the socket value details");
03107         RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update");
03108         
03109         prop = RNA_def_property(srna, "default_value", PROP_FLOAT, propsubtype);
03110         RNA_def_property_float_sdna(prop, NULL, "value");
03111         RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocketFloat_range");
03112         RNA_def_property_ui_text(prop, "Default Value", "");
03113         RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update");
03114         break;
03115     case SOCK_BOOLEAN:
03116         RNA_def_struct_sdna_from(srna, "bNodeSocketValueBoolean", "default_value");
03117         
03118         prop = RNA_def_property(srna, "default_value", PROP_BOOLEAN, PROP_NONE);
03119         RNA_def_property_boolean_sdna(prop, NULL, "value", 1);
03120         RNA_def_property_ui_text(prop, "Default Value", "");
03121         RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update");
03122         break;
03123     case SOCK_VECTOR:
03124         RNA_def_struct_sdna_from(srna, "bNodeSocketValueVector", "default_value");
03125         
03126         prop = RNA_def_property(srna, "subtype", PROP_ENUM, PROP_NONE);
03127         RNA_def_property_enum_sdna(prop, NULL, "subtype");
03128         RNA_def_property_enum_items(prop, subtype_items);
03129         RNA_def_property_ui_text(prop, "Subtype", "Subtype defining the socket value details");
03130         RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update");
03131         
03132         prop = RNA_def_property(srna, "default_value", PROP_FLOAT, propsubtype);
03133         RNA_def_property_float_sdna(prop, NULL, "value");
03134         RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocketVector_range");
03135         RNA_def_property_ui_text(prop, "Default Value", "");
03136         RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update");
03137         break;
03138     case SOCK_RGBA:
03139         RNA_def_struct_sdna_from(srna, "bNodeSocketValueRGBA", "default_value");
03140         
03141         prop = RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_COLOR);
03142         RNA_def_property_float_sdna(prop, NULL, "value");
03143         RNA_def_property_ui_text(prop, "Default Value", "");
03144         RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update");
03145         break;
03146     }
03147 }
03148 
03149 static void rna_def_node(BlenderRNA *brna)
03150 {
03151     StructRNA *srna;
03152     PropertyRNA *prop;
03153     
03154     srna = RNA_def_struct(brna, "Node", NULL);
03155     RNA_def_struct_ui_text(srna, "Node", "Node in a node tree");
03156     RNA_def_struct_sdna(srna, "bNode");
03157     RNA_def_struct_ui_icon(srna, ICON_NODE);
03158     RNA_def_struct_refine_func(srna, "rna_Node_refine");
03159     RNA_def_struct_path_func(srna, "rna_Node_path");
03160     
03161     prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ);
03162     RNA_def_property_float_sdna(prop, NULL, "locx");
03163     RNA_def_property_array(prop, 2);
03164     RNA_def_property_range(prop, -10000.0f, 10000.0f);
03165     RNA_def_property_ui_text(prop, "Location", "");
03166     RNA_def_property_update(prop, NC_NODE, "rna_Node_update");
03167     
03168     prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
03169     RNA_def_property_ui_text(prop, "Name", "Unique node identifier");
03170     RNA_def_struct_name_property(srna, prop);
03171     RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Node_name_set");
03172     RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
03173     
03174     prop = RNA_def_property(srna, "label", PROP_STRING, PROP_NONE);
03175     RNA_def_property_string_sdna(prop, NULL, "label");
03176     RNA_def_property_ui_text(prop, "Label", "Optional custom node label");
03177     RNA_def_property_update(prop, NC_NODE, "rna_Node_update");
03178     
03179     prop = RNA_def_property(srna, "inputs", PROP_COLLECTION, PROP_NONE);
03180     RNA_def_property_collection_sdna(prop, NULL, "inputs", NULL);
03181     RNA_def_property_struct_type(prop, "NodeSocket");
03182     RNA_def_property_ui_text(prop, "Inputs", "");
03183     
03184     prop = RNA_def_property(srna, "outputs", PROP_COLLECTION, PROP_NONE);
03185     RNA_def_property_collection_sdna(prop, NULL, "outputs", NULL);
03186     RNA_def_property_struct_type(prop, "NodeSocket");
03187     RNA_def_property_ui_text(prop, "Outputs", "");
03188 
03189     prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
03190     RNA_def_property_pointer_sdna(prop, NULL, "parent");
03191     RNA_def_property_struct_type(prop, "Node");
03192     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
03193     RNA_def_property_ui_text(prop, "Parent", "Parent this node is attached to");
03194 
03195     prop = RNA_def_property(srna, "show_texture", PROP_BOOLEAN, PROP_NONE);
03196     RNA_def_property_boolean_sdna(prop, NULL, "flag", NODE_ACTIVE_TEXTURE);
03197     RNA_def_property_ui_text(prop, "Show Texture", "Draw node in viewport textured draw mode");
03198     RNA_def_property_update(prop, 0, "rna_Node_update");
03199 }
03200 
03201 static void rna_def_node_link(BlenderRNA *brna)
03202 {
03203     StructRNA *srna;
03204     PropertyRNA *prop;
03205 
03206     srna = RNA_def_struct(brna, "NodeLink", NULL);
03207     RNA_def_struct_ui_text(srna, "NodeLink", "Link between nodes in a node tree");
03208     RNA_def_struct_sdna(srna, "bNodeLink");
03209     RNA_def_struct_ui_icon(srna, ICON_NODE);
03210 
03211     prop = RNA_def_property(srna, "from_node", PROP_POINTER, PROP_NONE);
03212     RNA_def_property_pointer_sdna(prop, NULL, "fromnode");
03213     RNA_def_property_struct_type(prop, "Node");
03214     RNA_def_property_ui_text(prop, "From node", "");
03215 
03216     prop = RNA_def_property(srna, "to_node", PROP_POINTER, PROP_NONE);
03217     RNA_def_property_pointer_sdna(prop, NULL, "tonode");
03218     RNA_def_property_struct_type(prop, "Node");
03219     RNA_def_property_ui_text(prop, "To node", "");
03220 
03221     prop = RNA_def_property(srna, "from_socket", PROP_POINTER, PROP_NONE);
03222     RNA_def_property_pointer_sdna(prop, NULL, "fromsock");
03223     RNA_def_property_struct_type(prop, "NodeSocket");
03224     RNA_def_property_ui_text(prop, "From socket", "");
03225 
03226     prop = RNA_def_property(srna, "to_socket", PROP_POINTER, PROP_NONE);
03227     RNA_def_property_pointer_sdna(prop, NULL, "tosock");
03228     RNA_def_property_struct_type(prop, "NodeSocket");
03229     RNA_def_property_ui_text(prop, "To socket", "");
03230 }
03231 
03232 static void rna_def_group_sockets_api(BlenderRNA *brna, PropertyRNA *cprop, int in_out)
03233 {
03234     StructRNA *srna;
03235     PropertyRNA *parm;
03236     FunctionRNA *func;
03237 
03238     RNA_def_property_srna(cprop, (in_out==SOCK_IN ? "GroupInputs" : "GroupOutputs"));
03239     srna= RNA_def_struct(brna, (in_out==SOCK_IN ? "GroupInputs" : "GroupOutputs"), NULL);
03240     RNA_def_struct_sdna(srna, "bNodeTree");
03241     RNA_def_struct_ui_text(srna, "Group Sockets", "Collection of group sockets");
03242 
03243     func= RNA_def_function(srna, "new", (in_out==SOCK_IN ? "rna_NodeTree_input_new" : "rna_NodeTree_output_new"));
03244     RNA_def_function_ui_description(func, "Add a socket to the group tree");
03245     RNA_def_function_flag(func, FUNC_USE_REPORTS);
03246     RNA_def_string(func, "name", "Socket", MAX_NAME, "Name", "Name of the socket");
03247     RNA_def_enum(func, "type", node_socket_type_items, SOCK_FLOAT, "Type", "Type of socket");
03248     /* return value */
03249     parm= RNA_def_pointer(func, "socket", "NodeSocket", "", "New socket");
03250     RNA_def_function_return(func, parm);
03251 
03252     func= RNA_def_function(srna, "expose", (in_out==SOCK_IN ? "rna_NodeTree_input_expose" : "rna_NodeTree_output_expose"));
03253     RNA_def_function_ui_description(func, "Expose an internal socket in the group tree");
03254     RNA_def_function_flag(func, FUNC_USE_REPORTS);
03255     RNA_def_pointer(func, "sock", "NodeSocket", "Socket", "Internal node socket to expose");
03256     RNA_def_property_flag(parm, PROP_REQUIRED);
03257     RNA_def_boolean(func, "add_link", TRUE, "Add Link", "If TRUE, adds a link to the internal socket");
03258     /* return value */
03259     parm= RNA_def_pointer(func, "socket", "NodeSocket", "", "New socket");
03260     RNA_def_function_return(func, parm);
03261 }
03262 
03263 static void rna_def_nodetree(BlenderRNA *brna)
03264 {
03265     StructRNA *srna;
03266     PropertyRNA *prop;
03267 
03268     srna = RNA_def_struct(brna, "NodeTree", "ID");
03269     RNA_def_struct_ui_text(srna, "Node Tree", "Node tree consisting of linked nodes used for shading, textures and compositing");
03270     RNA_def_struct_sdna(srna, "bNodeTree");
03271     RNA_def_struct_ui_icon(srna, ICON_NODETREE);
03272     RNA_def_struct_refine_func(srna, "rna_NodeTree_refine");
03273 
03274     /* AnimData */
03275     rna_def_animdata_common(srna);
03276     
03277     /* NodeLinks Collection */
03278     prop = RNA_def_property(srna, "links", PROP_COLLECTION, PROP_NONE);
03279     RNA_def_property_collection_sdna(prop, NULL, "links", NULL);
03280     RNA_def_property_struct_type(prop, "NodeLink");
03281     RNA_def_property_ui_text(prop, "Links", "");
03282     rna_def_nodetree_link_api(brna, prop);
03283 
03284     /* Grease Pencil */
03285     prop= RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
03286     RNA_def_property_pointer_sdna(prop, NULL, "gpd");
03287     RNA_def_property_flag(prop, PROP_EDITABLE);
03288     RNA_def_property_struct_type(prop, "GreasePencil");
03289     RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock");
03290     RNA_def_property_update(prop, NC_NODE, NULL);
03291     
03292     prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
03293     RNA_def_property_clear_flag(prop, PROP_EDITABLE);
03294     RNA_def_property_enum_items(prop, nodetree_type_items);
03295     RNA_def_property_ui_text(prop, "Type", "Node Tree type");
03296 
03297     /* group sockets */
03298     prop = RNA_def_property(srna, "inputs", PROP_COLLECTION, PROP_NONE);
03299     RNA_def_property_collection_sdna(prop, NULL, "inputs", NULL);
03300     RNA_def_property_struct_type(prop, "NodeSocket");
03301     RNA_def_property_ui_text(prop, "Inputs", "");
03302     rna_def_group_sockets_api(brna, prop, SOCK_IN);
03303     
03304     prop = RNA_def_property(srna, "outputs", PROP_COLLECTION, PROP_NONE);
03305     RNA_def_property_collection_sdna(prop, NULL, "outputs", NULL);
03306     RNA_def_property_struct_type(prop, "NodeSocket");
03307     RNA_def_property_ui_text(prop, "Outputs", "");
03308     rna_def_group_sockets_api(brna, prop, SOCK_OUT);
03309 }
03310 
03311 static void rna_def_composite_nodetree(BlenderRNA *brna)
03312 {
03313     StructRNA *srna;
03314     PropertyRNA *prop;
03315 
03316     srna = RNA_def_struct(brna, "CompositorNodeTree", "NodeTree");
03317     RNA_def_struct_ui_text(srna, "Compositor Node Tree", "Node tree consisting of linked nodes used for compositing");
03318     RNA_def_struct_sdna(srna, "bNodeTree");
03319     RNA_def_struct_ui_icon(srna, ICON_NODETREE);
03320 
03321     /* Nodes Collection */
03322     prop = RNA_def_property(srna, "nodes", PROP_COLLECTION, PROP_NONE);
03323     RNA_def_property_collection_sdna(prop, NULL, "nodes", NULL);
03324     RNA_def_property_struct_type(prop, "Node");
03325     RNA_def_property_ui_text(prop, "Nodes", "");
03326 
03327     rna_def_composite_nodetree_api(brna, prop);
03328 }
03329 
03330 static void rna_def_shader_nodetree(BlenderRNA *brna)
03331 {
03332     StructRNA *srna;
03333     PropertyRNA *prop;
03334 
03335     srna = RNA_def_struct(brna, "ShaderNodeTree", "NodeTree");
03336     RNA_def_struct_ui_text(srna, "Shader Node Tree", "Node tree consisting of linked nodes used for materials (and other shading datablocks)");
03337     RNA_def_struct_sdna(srna, "bNodeTree");
03338     RNA_def_struct_ui_icon(srna, ICON_NODETREE);
03339 
03340     /* Nodes Collection */
03341     prop = RNA_def_property(srna, "nodes", PROP_COLLECTION, PROP_NONE);
03342     RNA_def_property_collection_sdna(prop, NULL, "nodes", NULL);
03343     RNA_def_property_struct_type(prop, "Node");
03344     RNA_def_property_ui_text(prop, "Nodes", "");
03345 
03346     rna_def_shader_nodetree_api(brna, prop);
03347 }
03348 
03349 static void rna_def_texture_nodetree(BlenderRNA *brna)
03350 {
03351     StructRNA *srna;
03352     PropertyRNA *prop;
03353 
03354     srna = RNA_def_struct(brna, "TextureNodeTree", "NodeTree");
03355     RNA_def_struct_ui_text(srna, "Texture Node Tree", "Node tree consisting of linked nodes used for textures");
03356     RNA_def_struct_sdna(srna, "bNodeTree");
03357     RNA_def_struct_ui_icon(srna, ICON_NODETREE);
03358 
03359     /* Nodes Collection */
03360     prop = RNA_def_property(srna, "nodes", PROP_COLLECTION, PROP_NONE);
03361     RNA_def_property_collection_sdna(prop, NULL, "nodes", NULL);
03362     RNA_def_property_struct_type(prop, "Node");
03363     RNA_def_property_ui_text(prop, "Nodes", "");
03364 
03365     rna_def_texture_nodetree_api(brna, prop);
03366 }
03367 
03368 static void define_specific_node(BlenderRNA *brna, int id, void (*func)(StructRNA*))
03369 {
03370     StructRNA *srna = def_node(brna, id);
03371     
03372     if(func)
03373         func(srna);
03374 }
03375 
03376 void RNA_def_nodetree(BlenderRNA *brna)
03377 {
03378     init();
03379     rna_def_nodetree(brna);
03380     
03381     rna_def_node_socket(brna);
03382     
03383     /* Generate RNA definitions for all socket subtypes */
03384     #define SUBTYPE(socktype, stypename, id, idname) \
03385     rna_def_node_socket_subtype(brna, SOCK_##socktype, PROP_##id, "NodeSocket"#stypename#idname, #idname" "#stypename" Node Socket");
03386     NODE_DEFINE_SUBTYPES
03387     #undef SUBTYPE
03388     rna_def_node_socket_subtype(brna, SOCK_BOOLEAN, 0, "NodeSocketBoolean", "Boolean Node Socket");
03389     rna_def_node_socket_subtype(brna, SOCK_RGBA, 0, "NodeSocketRGBA", "RGBA Node Socket");
03390     rna_def_node_socket_subtype(brna, SOCK_SHADER, 0, "NodeSocketShader", "Shader Closure Node Socket");
03391     
03392     rna_def_node(brna);
03393     rna_def_node_link(brna);
03394     rna_def_shader_node(brna);
03395     rna_def_compositor_node(brna);
03396     rna_def_texture_node(brna);
03397     
03398     rna_def_composite_nodetree(brna);
03399     rna_def_shader_nodetree(brna);
03400     rna_def_texture_nodetree(brna);
03401     #define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
03402         define_specific_node(brna, ID, DefFunc);
03403         
03404     #include "rna_nodetree_types.h"
03405     
03406     define_specific_node(brna, NODE_GROUP, def_group);
03407     define_specific_node(brna, NODE_FORLOOP, def_forloop);
03408     define_specific_node(brna, NODE_WHILELOOP, def_whileloop);
03409     define_specific_node(brna, NODE_FRAME, def_frame);
03410 }
03411 
03412 /* clean up macro definition */
03413 #undef NODE_DEFINE_SUBTYPES
03414 
03415 #endif