diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-09-06 04:31:00 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-09-06 04:31:00 +0400 |
commit | c64336390569a344f972ce41d8a1fb96d3c9c38f (patch) | |
tree | ca5d281e088c2024e536f3a832c9606f99e46bc3 /source/blender/makesrna | |
parent | 5a3c6ccadb8925d6e2b1da2b2861de35b33f939f (diff) | |
parent | bf5a6531a61638b74b9e80e055e00c2b97483fdf (diff) |
svn merge -r39930:39947 https://svn.blender.org/svnroot/bf-blender/trunk/blender
Diffstat (limited to 'source/blender/makesrna')
20 files changed, 431 insertions, 285 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 6fe4d8d5f45..5da125bb440 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -327,10 +327,13 @@ extern StructRNA RNA_NearSensor; extern StructRNA RNA_NlaStrip; extern StructRNA RNA_NlaTrack; extern StructRNA RNA_Node; +extern StructRNA RNA_NodeForLoop; extern StructRNA RNA_NodeGroup; extern StructRNA RNA_NodeLink; extern StructRNA RNA_NodeSocket; +extern StructRNA RNA_NodeSocketPanel; extern StructRNA RNA_NodeTree; +extern StructRNA RNA_NodeWhileLoop; extern StructRNA RNA_NoiseTexture; extern StructRNA RNA_NorController; extern StructRNA RNA_Object; @@ -376,7 +379,6 @@ extern StructRNA RNA_PropertyGroupItem; extern StructRNA RNA_PropertySensor; extern StructRNA RNA_PythonConstraint; extern StructRNA RNA_PythonController; -extern StructRNA RNA_RGBANodeSocket; extern StructRNA RNA_RadarSensor; extern StructRNA RNA_RandomSensor; extern StructRNA RNA_RaySensor; @@ -553,9 +555,7 @@ extern StructRNA RNA_UserPreferencesFilePaths; extern StructRNA RNA_UserPreferencesSystem; extern StructRNA RNA_UserPreferencesView; extern StructRNA RNA_UserSolidLight; -extern StructRNA RNA_ValueNodeSocket; extern StructRNA RNA_VectorFont; -extern StructRNA RNA_VectorNodeSocket; extern StructRNA RNA_VertexGroup; extern StructRNA RNA_VertexGroupElement; extern StructRNA RNA_VertexPaint; @@ -602,6 +602,8 @@ extern const PointerRNA PointerRNA_NULL; /* Structs */ +StructRNA *RNA_struct_find(const char *identifier); + const char *RNA_struct_identifier(StructRNA *type); const char *RNA_struct_ui_name(StructRNA *type); const char *RNA_struct_ui_description(StructRNA *type); diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 0b63bb02436..2300b72910d 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -102,10 +102,12 @@ extern EnumPropertyItem transform_mode_types[]; extern EnumPropertyItem posebone_rotmode_items[]; extern EnumPropertyItem property_type_items[]; +extern EnumPropertyItem property_subtype_items[]; extern EnumPropertyItem property_unit_items[]; extern EnumPropertyItem viewport_shade_items[]; +extern EnumPropertyItem nodetree_type_items[]; extern EnumPropertyItem node_socket_type_items[]; extern EnumPropertyItem node_math_items[]; diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index f8199074f27..4a18518dde9 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -99,7 +99,10 @@ typedef enum PropertyUnit { #define RNA_ENUM_BITFLAG_SIZE 32 -/* also update enums in bpy_props.c when adding items here */ +/* also update enums in bpy_props.c when adding items here + * watch it: these values are written to files as part of + * node socket button subtypes! + */ typedef enum PropertySubType { PROP_NONE = 0, diff --git a/source/blender/makesrna/SConscript b/source/blender/makesrna/SConscript index 1cb24630fbe..10b20fc795a 100644 --- a/source/blender/makesrna/SConscript +++ b/source/blender/makesrna/SConscript @@ -9,6 +9,7 @@ objs += o incs = '#/intern/guardedalloc #/intern/memutil #/intern/audaspace/intern ../blenkernel ../blenlib ../makesdna intern .' incs += ' ../windowmanager ../editors/include ../gpu ../imbuf ../ikplugin ../blenfont ../blenloader' incs += ' ../render/extern/include' +incs += ' ../nodes' incs += ' #/extern/glew/include' defs = [] diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 0307b5222d7..c2b46a3b69a 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -200,7 +200,7 @@ if(NOT WITH_MOD_FLUID) endif() if(WITH_FFTW3) - add_definitions(-DFFTW3=1) + add_definitions(-DWITH_FFTW3) endif() if(WITH_SDL) diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index 24c892b96c4..5c2580e4b90 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -71,7 +71,7 @@ if env['WITH_BF_GAMEENGINE']: defs.append('WITH_GAMEENGINE') if env['WITH_BF_FFTW3']: - defs.append('FFTW3=1') + defs.append('WITH_FFTW3') if env['WITH_BF_SDL']: defs.append('WITH_SDL') diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index ad79771416d..936f2e5e40c 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -475,6 +475,17 @@ static const char *rna_ensure_property_name(PropertyRNA *prop) /* Structs */ +StructRNA *RNA_struct_find(const char *identifier) +{ + StructRNA *type; + if (identifier) { + for (type = BLENDER_RNA.structs.first; type; type = type->cont.next) + if (strcmp(type->identifier, identifier)==0) + return type; + } + return NULL; +} + const char *RNA_struct_identifier(StructRNA *type) { return type->identifier; diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 5eccba16c3d..3d0e177c94e 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -323,30 +323,6 @@ static void rna_Actuator_constraint_detect_material_set(struct PointerRNA *ptr, } } -static void rna_FcurveActuator_add_set(struct PointerRNA *ptr, int value) -{ - bActuator *act = (bActuator *)ptr->data; - bIpoActuator *ia = act->data; - - if(value == 1){ - ia->flag &= ~ACT_IPOFORCE; - ia->flag |= ACT_IPOADD; - }else - ia->flag &= ~ACT_IPOADD; -} - -static void rna_FcurveActuator_force_set(struct PointerRNA *ptr, int value) -{ - bActuator *act = (bActuator *)ptr->data; - bIpoActuator *ia = act->data; - - if(value == 1){ - ia->flag &= ~ACT_IPOADD; - ia->flag |= ACT_IPOFORCE; - }else - ia->flag &= ~ACT_IPOFORCE; -} - static void rna_ActionActuator_add_set(struct PointerRNA *ptr, int value) { bActuator *act = (bActuator *)ptr->data; @@ -858,77 +834,6 @@ static void rna_def_object_actuator(BlenderRNA *brna) RNA_def_property_update(prop, NC_LOGIC, NULL); } -/* The fcurve actuator has been replace with the action actuator, so this is no longer used */ -static void rna_def_fcurve_actuator(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static EnumPropertyItem prop_type_items[] ={ - {ACT_IPO_PLAY, "PLAY", 0, "Play", ""}, - {ACT_IPO_PINGPONG, "PINGPONG", 0, "Ping Pong", ""}, - {ACT_IPO_FLIPPER, "FLIPPER", 0, "Flipper", ""}, - {ACT_IPO_LOOP_STOP, "STOP", 0, "Loop Stop", ""}, - {ACT_IPO_LOOP_END, "END", 0, "Loop End", ""}, -// {ACT_IPO_KEY2KEY, "IPOCHILD", 0, "Key to Key", ""}, - {ACT_IPO_FROM_PROP, "PROP", 0, "Property", ""}, - {0, NULL, 0, NULL, NULL}}; - - srna= RNA_def_struct(brna, "FCurveActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "F-Curve Actuator", "Actuator to animate the object"); - RNA_def_struct_sdna_from(srna, "bIpoActuator", "data"); - - prop= RNA_def_property(srna, "play_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_type_items); - RNA_def_property_ui_text(prop, "F-Curve Type", "Specify the way you want to play the animation"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sta"); - RNA_def_property_ui_range(prop, 1.0, MAXFRAME, 100, 2); - RNA_def_property_ui_text(prop, "Start Frame", ""); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop= RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "end"); - RNA_def_property_ui_range(prop, 1.0, MAXFRAME, 100, 2); - RNA_def_property_ui_text(prop, "End Frame", ""); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_ui_text(prop, "Property", "Use this property to define the F-Curve position"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "frame_property", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "frameProp"); - RNA_def_property_ui_text(prop, "Frame Property", "Assign the action's current frame number to this property"); - - /* booleans */ - prop= RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOADD); - RNA_def_property_boolean_funcs(prop, NULL, "rna_FcurveActuator_add_set"); - RNA_def_property_ui_text(prop, "Add", "F-Curve is added to the current loc/rot/scale in global or local coordinate according to Local flag"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "use_force", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOFORCE); - RNA_def_property_boolean_funcs(prop, NULL, "rna_FcurveActuator_force_set"); - RNA_def_property_ui_text(prop, "Force", "Apply F-Curve as a global or local force depending on the local option (dynamic objects only)"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "use_local", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOLOCAL); - RNA_def_property_ui_text(prop, "L", "Let the F-Curve act in local coordinates, used in Force and Add mode"); - RNA_def_property_update(prop, NC_LOGIC, NULL); - - prop= RNA_def_property(srna, "apply_to_children", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOCHILD); - RNA_def_property_ui_text(prop, "Child", "Update F-Curve on all children Objects as well"); - RNA_def_property_update(prop, NC_LOGIC, NULL); -} - static void rna_def_camera_actuator(BlenderRNA *brna) { StructRNA *srna; diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index d69cb2063ab..1ba6905ea37 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -214,9 +214,7 @@ void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material struct bNodeTree *rna_Main_nodetree_new(Main *UNUSED(bmain), const char *name, int type) { - bNodeTree *tree = ntreeAddTree(name, type, TRUE); - -// ntreeMakeGroupSockets(tree); + bNodeTree *tree = ntreeAddTree(name, type, NODE_GROUP); id_us_min(&tree->id); return tree; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index d6e475fdbad..49a0458977a 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -30,13 +30,17 @@ #include <stdlib.h> #include <string.h> +#include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" #include "rna_internal.h" +#include "rna_internal_types.h" #include "DNA_material_types.h" +#include "DNA_mesh_types.h" #include "DNA_node_types.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_texture_types.h" @@ -53,9 +57,16 @@ #include "MEM_guardedalloc.h" +EnumPropertyItem nodetree_type_items[] = { + {NTREE_SHADER, "MATERIAL", ICON_MATERIAL, "Material", "Material nodes" }, + {NTREE_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture nodes" }, + {NTREE_COMPOSIT, "COMPOSITING", ICON_RENDERLAYERS, "Compositing", "Compositing nodes" }, + {0, NULL, 0, NULL, NULL} +}; + EnumPropertyItem node_socket_type_items[] = { - {SOCK_VALUE, "VALUE", 0, "Value", ""}, + {SOCK_FLOAT, "VALUE", 0, "Value", ""}, {SOCK_VECTOR, "VECTOR", 0, "Vector", ""}, {SOCK_RGBA, "RGBA", 0, "RGBA", ""}, {0, NULL, 0, NULL, NULL}}; @@ -99,6 +110,41 @@ EnumPropertyItem node_filter_items[] = { {6, "SHADOW", 0, "Shadow", ""}, {0, NULL, 0, NULL, NULL}}; + +/* Add any new socket value subtype here. + * When adding a new subtype here, make sure you also add it + * to the subtype definitions in DNA_node_types.h. + * This macro is used by the RNA and the internal converter functions + * to define all socket subtypes. The SUBTYPE macro must be defined + * before using this macro, and undefined afterwards. + */ +#define NODE_DEFINE_SUBTYPES_INT \ +SUBTYPE(INT, Int, NONE, None) \ +SUBTYPE(INT, Int, UNSIGNED, Unsigned) + +#define NODE_DEFINE_SUBTYPES_FLOAT \ +SUBTYPE(FLOAT, Float, NONE, None) \ +SUBTYPE(FLOAT, Float, UNSIGNED, Unsigned) \ +SUBTYPE(FLOAT, Float, PERCENTAGE, Percentage) \ +SUBTYPE(FLOAT, Float, FACTOR, Factor) \ +SUBTYPE(FLOAT, Float, ANGLE, Angle) \ +SUBTYPE(FLOAT, Float, TIME, Time) \ +SUBTYPE(FLOAT, Float, DISTANCE, Distance) + +#define NODE_DEFINE_SUBTYPES_VECTOR \ +SUBTYPE(VECTOR, Vector, NONE, None) \ +SUBTYPE(VECTOR, Vector, TRANSLATION, Translation) \ +SUBTYPE(VECTOR, Vector, DIRECTION, Direction) \ +SUBTYPE(VECTOR, Vector, VELOCITY, Velocity) \ +SUBTYPE(VECTOR, Vector, ACCELERATION, Acceleration) \ +SUBTYPE(VECTOR, Vector, EULER, Euler) \ +SUBTYPE(VECTOR, Vector, XYZ, XYZ) + +#define NODE_DEFINE_SUBTYPES \ +NODE_DEFINE_SUBTYPES_INT \ +NODE_DEFINE_SUBTYPES_FLOAT \ +NODE_DEFINE_SUBTYPES_VECTOR + #ifdef RNA_RUNTIME #include "BLI_linklist.h" @@ -121,32 +167,18 @@ static StructRNA *rna_Node_refine(struct PointerRNA *ptr) #include "rna_nodetree_types.h" - #undef DefNode - case NODE_GROUP: return &RNA_NodeGroup; + case NODE_FORLOOP: + return &RNA_NodeForLoop; + case NODE_WHILELOOP: + return &RNA_NodeWhileLoop; default: return &RNA_Node; } } -static StructRNA *rna_NodeSocketType_refine(struct PointerRNA *ptr) -{ - bNodeSocket *ns= (bNodeSocket*)ptr->data; - - switch(ns->type) { - case SOCK_VALUE: - return &RNA_ValueNodeSocket; - case SOCK_VECTOR: - return &RNA_VectorNodeSocket; - case SOCK_RGBA: - return &RNA_RGBANodeSocket; - default: - return &RNA_UnknownType; - } -} - static StructRNA *rna_NodeTree_refine(struct PointerRNA *ptr) { bNodeTree *ntree= (bNodeTree*)ptr->data; @@ -170,6 +202,46 @@ static char *rna_Node_path(PointerRNA *ptr) return BLI_sprintfN("nodes[\"%s\"]", node->name); } +static StructRNA *rna_NodeSocket_refine(PointerRNA *ptr) +{ + bNodeSocket *sock= (bNodeSocket*)ptr->data; + + if (sock->default_value) { + /* This returns the refined socket type with the full definition + * of the default input value with type and subtype. + */ + + #define SUBTYPE(socktype, stypename, id, idname) \ + { \ + bNodeSocketValue##stypename *value= (bNodeSocketValue##stypename*)sock->default_value; \ + if (value->subtype==PROP_##id) \ + return &RNA_NodeSocket##stypename##idname; \ + } + + switch (sock->type) { + case SOCK_FLOAT: + NODE_DEFINE_SUBTYPES_FLOAT + break; + case SOCK_INT: + NODE_DEFINE_SUBTYPES_INT + break; + case SOCK_BOOLEAN: + return &RNA_NodeSocketBoolean; + break; + case SOCK_VECTOR: + NODE_DEFINE_SUBTYPES_VECTOR + break; + case SOCK_RGBA: + return &RNA_NodeSocketRGBA; + break; + } + + #undef SUBTYPE + } + + return &RNA_NodeSocket; +} + static char *rna_NodeSocket_path(PointerRNA *ptr) { bNodeTree *ntree= (bNodeTree*)ptr->id.data; @@ -275,7 +347,7 @@ static void rna_NodeGroup_update(Main *bmain, Scene *scene, PointerRNA *ptr) bNodeTree *ntree= (bNodeTree*)ptr->id.data; bNode *node= (bNode*)ptr->data; - nodeGroupVerify((bNodeTree *)node->id); + ntreeUpdateTree((bNodeTree *)node->id); node_update(bmain, scene, ntree, node); } @@ -313,18 +385,42 @@ static void rna_NodeGroupSocket_update(Main *bmain, Scene *scene, PointerRNA *pt bNodeSocket *sock= (bNodeSocket*)ptr->data; bNode *node; - nodeGroupVerify(ntree); + ntreeUpdateTree(ntree); if (nodeFindNode(ntree, sock, &node, NULL, NULL)) node_update(bmain, scene, ntree, node); } -static void rna_NodeSocket_defvalue_range(PointerRNA *ptr, float *min, float *max) +static void rna_NodeLink_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bNodeTree *ntree= (bNodeTree*)ptr->id.data; + + ntree->update |= NTREE_UPDATE_LINKS; + ntreeUpdateTree(ntree); +} + +static void rna_NodeSocketInt_range(PointerRNA *ptr, int *min, int *max) { bNodeSocket *sock= (bNodeSocket*)ptr->data; + bNodeSocketValueInt *val= (bNodeSocketValueInt*)sock->default_value; + *min = val->min; + *max = val->max; +} - *min = sock->ns.min; - *max = sock->ns.max; +static void rna_NodeSocketFloat_range(PointerRNA *ptr, float *min, float *max) +{ + bNodeSocket *sock= (bNodeSocket*)ptr->data; + bNodeSocketValueFloat *val= (bNodeSocketValueFloat*)sock->default_value; + *min = val->min; + *max = val->max; +} + +static void rna_NodeSocketVector_range(PointerRNA *ptr, float *min, float *max) +{ + bNodeSocket *sock= (bNodeSocket*)ptr->data; + bNodeSocketValueVector *val= (bNodeSocketValueVector*)sock->default_value; + *min = val->min; + *max = val->max; } static void rna_Node_mapping_update(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -454,18 +550,22 @@ static EnumPropertyItem *rna_Node_channel_itemf(bContext *UNUSED(C), PointerRNA static bNode *rna_NodeTree_node_new(bNodeTree *ntree, bContext *UNUSED(C), ReportList *reports, int type, bNodeTree *group) { bNode *node; + bNodeTemplate ntemp; if (type == NODE_GROUP && group == NULL) { BKE_reportf(reports, RPT_ERROR, "node type \'GROUP\' missing group argument"); return NULL; } - node = nodeAddNodeType(ntree, type, group, NULL); - + + ntemp.type = type; + ntemp.ngroup = group; + node = nodeAddNode(ntree, &ntemp); + if (node == NULL) { BKE_reportf(reports, RPT_ERROR, "Unable to create node"); } else { - nodeGroupVerify(ntree); /* update group node socket links*/ + ntreeUpdateTree(ntree); /* update group node socket links*/ NodeTagChanged(ntree, node); WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); @@ -495,7 +595,7 @@ static bNode *rna_NodeTree_node_composite_new(bNodeTree *ntree, bContext *C, Rep } ntreeCompositForceHidden(ntree, CTX_data_scene(C)); - ntreeSolveOrder(ntree); + ntreeUpdateTree(ntree); } return node; @@ -523,7 +623,7 @@ static void rna_NodeTree_node_remove(bNodeTree *ntree, ReportList *reports, bNod id_us_min(node->id); nodeFreeNode(ntree, node); - nodeGroupVerify(ntree); /* update group node socket links*/ + ntreeUpdateTree(ntree); /* update group node socket links*/ WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); } @@ -551,9 +651,7 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, ReportList *reports, b if(ret) { NodeTagChanged(ntree, tonode); - nodeGroupVerify(ntree); /* update group node socket links*/ - - ntreeSolveOrder(ntree); + ntreeUpdateTree(ntree); WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); } @@ -567,8 +665,7 @@ static void rna_NodeTree_link_remove(bNodeTree *ntree, ReportList *reports, bNod } else { nodeRemLink(ntree, link); - ntreeSolveOrder(ntree); - nodeGroupVerify(ntree); /* update group node socket links*/ + ntreeUpdateTree(ntree); WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); } @@ -577,9 +674,10 @@ static void rna_NodeTree_link_remove(bNodeTree *ntree, ReportList *reports, bNod static bNodeSocket *rna_NodeTree_input_new(bNodeTree *ntree, ReportList *UNUSED(reports), const char *name, int type) { /* XXX should check if tree is a group here! no good way to do this currently. */ - bNodeSocket *gsock= nodeGroupAddSocket(ntree, name, type, SOCK_IN); + bNodeSocket *gsock= node_group_add_socket(ntree, name, type, SOCK_IN); - nodeGroupVerify(ntree); /* update group node socket links*/ + ntree->update |= NTREE_UPDATE_GROUP_IN; + ntreeUpdateTree(ntree); WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); return gsock; } @@ -587,9 +685,10 @@ static bNodeSocket *rna_NodeTree_input_new(bNodeTree *ntree, ReportList *UNUSED( static bNodeSocket *rna_NodeTree_output_new(bNodeTree *ntree, ReportList *UNUSED(reports), const char *name, int type) { /* XXX should check if tree is a group here! no good way to do this currently. */ - bNodeSocket *gsock= nodeGroupAddSocket(ntree, name, type, SOCK_OUT); + bNodeSocket *gsock= node_group_add_socket(ntree, name, type, SOCK_OUT); - nodeGroupVerify(ntree); /* update group node socket links*/ + ntree->update |= NTREE_UPDATE_GROUP_OUT; + ntreeUpdateTree(ntree); WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); return gsock; } @@ -606,11 +705,12 @@ static bNodeSocket *rna_NodeTree_input_expose(bNodeTree *ntree, ReportList *repo BKE_reportf(reports, RPT_ERROR, "Socket is not an input"); else { /* XXX should check if tree is a group here! no good way to do this currently. */ - gsock = nodeGroupAddSocket(ntree, sock->name, sock->type, SOCK_IN); + gsock = node_group_add_socket(ntree, sock->name, sock->type, SOCK_IN); if (add_link) nodeAddLink(ntree, NULL, gsock, node, sock); - nodeGroupVerify(ntree); /* update group node socket links*/ + ntree->update |= NTREE_UPDATE_GROUP_IN; + ntreeUpdateTree(ntree); WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); return gsock; } @@ -629,11 +729,12 @@ static bNodeSocket *rna_NodeTree_output_expose(bNodeTree *ntree, ReportList *rep BKE_reportf(reports, RPT_ERROR, "Socket is not an output"); else { /* XXX should check if tree is a group here! no good way to do this currently. */ - gsock = nodeGroupAddSocket(ntree, sock->name, sock->type, SOCK_OUT); + gsock = node_group_add_socket(ntree, sock->name, sock->type, SOCK_OUT); if (add_link) nodeAddLink(ntree, node, sock, NULL, gsock); - nodeGroupVerify(ntree); /* update group node socket links*/ + ntree->update |= NTREE_UPDATE_GROUP_OUT; + ntreeUpdateTree(ntree); WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); return gsock; } @@ -668,14 +769,16 @@ static EnumPropertyItem node_ycc_items[] = { { 2, "JFIF", 0, "Jpeg", ""}, {0, NULL, 0, NULL, NULL}}; -#define MaxNodes 1000 +#define MaxNodes 50000 enum { Category_GroupNode, + Category_LoopNode, + Category_LayoutNode, Category_ShaderNode, Category_CompositorNode, - Category_TextureNode + Category_TextureNode, }; typedef struct NodeInfo @@ -715,9 +818,10 @@ static void init(void) #include "rna_nodetree_types.h" - #undef DefNode - reg_node(NODE_GROUP, Category_GroupNode, "GROUP", "NodeGroup", "Node", "Group", ""); + reg_node(NODE_FORLOOP, Category_LoopNode, "FORLOOP", "NodeForLoop", "Node", "ForLoop", ""); + reg_node(NODE_WHILELOOP, Category_LoopNode, "WHILELOOP", "NodeWhileLoop", "Node", "WhileLoop", ""); + reg_node(NODE_FRAME, Category_LayoutNode, "FRAME", "NodeFrame", "Node", "Frame", ""); } static StructRNA* def_node(BlenderRNA *brna, int node_id) @@ -793,6 +897,41 @@ static void def_group(StructRNA *srna) RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeGroup_update"); } +static void def_forloop(StructRNA *srna) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "id"); + RNA_def_property_struct_type(prop, "NodeTree"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Node Tree", ""); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeGroup_update"); +} + +static void def_whileloop(StructRNA *srna) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "id"); + RNA_def_property_struct_type(prop, "NodeTree"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Node Tree", ""); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeGroup_update"); + + prop = RNA_def_property(srna, "max_iterations", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "custom1"); + RNA_def_property_range(prop, 0.0f, 10000000.0f); + RNA_def_property_ui_text(prop, "Max. Iterations", "Limit for number of iterations"); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeGroup_update"); +} + +static void def_frame(StructRNA *srna) +{ +// PropertyRNA *prop; + +} static void def_math(StructRNA *srna) { @@ -2510,94 +2649,112 @@ static void rna_def_node_socket(BlenderRNA *brna) srna = RNA_def_struct(brna, "NodeSocket", NULL); RNA_def_struct_ui_text(srna, "Node Socket", "Input or output socket of a node"); - RNA_def_struct_refine_func(srna, "rna_NodeSocketType_refine"); RNA_def_struct_sdna(srna, "bNodeSocket"); + RNA_def_struct_refine_func(srna, "rna_NodeSocket_refine"); RNA_def_struct_ui_icon(srna, ICON_PLUG); RNA_def_struct_path_func(srna, "rna_NodeSocket_path"); + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, node_socket_type_items); + RNA_def_property_enum_default(prop, 0); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Type", "Node Socket type"); + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); /* XXX must be editable for group sockets. if necessary use a special rna definition for these */ // RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Name", "Socket name"); RNA_def_struct_name_property(srna, prop); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeGroupSocket_update"); - - /* can add back if there is any use in reading them */ -#if 0 - prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ns.min"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Minimum Value", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update"); - - prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ns.max"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Maximum Value", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update"); -#endif - - prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_enum_items(prop, node_socket_type_items); - RNA_def_property_ui_text(prop, "Type", "Node Socket type"); } -static void rna_def_node_socket_value(BlenderRNA *brna) +static void rna_def_node_socket_subtype(BlenderRNA *brna, int type, int subtype, const char *name, const char *ui_name) { StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "ValueNodeSocket", "NodeSocket"); - RNA_def_struct_ui_text(srna, "Value Node Socket", "Input or output socket of a node"); + PropertyRNA *prop=NULL; + PropertySubType propsubtype= PROP_NONE; + + #define SUBTYPE(socktype, stypename, id, idname) { PROP_##id, #id, 0, #idname, ""}, + static EnumPropertyItem subtype_items[] = { + NODE_DEFINE_SUBTYPES + {0, NULL, 0, NULL, NULL} + }; + #undef SUBTYPE + + #define SUBTYPE(socktype, stypename, id, idname) if (subtype==PROP_##id) propsubtype = PROP_##id; + NODE_DEFINE_SUBTYPES + #undef SUBTYPE + + srna = RNA_def_struct(brna, name, "NodeSocket"); + RNA_def_struct_ui_text(srna, ui_name, "Input or output socket of a node"); RNA_def_struct_sdna(srna, "bNodeSocket"); RNA_def_struct_ui_icon(srna, ICON_PLUG); RNA_def_struct_path_func(srna, "rna_NodeSocket_path"); - - prop = RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ns.vec"); - RNA_def_property_array(prop, 1); - RNA_def_property_ui_text(prop, "Default Value", "Default value of the socket when no link is attached"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update"); - RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocket_defvalue_range"); -} - -static void rna_def_node_socket_vector(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "VectorNodeSocket", "NodeSocket"); - RNA_def_struct_ui_text(srna, "Vector Node Socket", "Input or output socket of a node"); - RNA_def_struct_sdna(srna, "bNodeSocket"); - RNA_def_struct_ui_icon(srna, ICON_PLUG); - RNA_def_struct_path_func(srna, "rna_NodeSocket_path"); - - prop = RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_XYZ); - RNA_def_property_float_sdna(prop, NULL, "ns.vec"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Default Value", "Default value of the socket when no link is attached"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update"); - RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocket_defvalue_range"); -} - -static void rna_def_node_socket_rgba(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "RGBANodeSocket", "NodeSocket"); - RNA_def_struct_ui_text(srna, "RGBA Node Socket", "Input or output socket of a node"); - RNA_def_struct_sdna(srna, "bNodeSocket"); - RNA_def_struct_ui_icon(srna, ICON_PLUG); - RNA_def_struct_path_func(srna, "rna_NodeSocket_path"); - - prop = RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "ns.vec"); - RNA_def_property_array(prop, 4); - RNA_def_property_ui_text(prop, "Default Value", "Default value of the socket when no link is attached"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update"); - RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocket_defvalue_range"); + + switch (type) { + case SOCK_INT: + RNA_def_struct_sdna_from(srna, "bNodeSocketValueInt", "default_value"); + + prop = RNA_def_property(srna, "subtype", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "subtype"); + RNA_def_property_enum_items(prop, subtype_items); + RNA_def_property_ui_text(prop, "Subtype", "Subtype defining the socket value details"); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update"); + + prop = RNA_def_property(srna, "default_value", PROP_INT, propsubtype); + RNA_def_property_int_sdna(prop, NULL, "value"); + RNA_def_property_int_funcs(prop, NULL, NULL, "rna_NodeSocketInt_range"); + RNA_def_property_ui_text(prop, "Default Value", ""); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update"); + break; + case SOCK_FLOAT: + RNA_def_struct_sdna_from(srna, "bNodeSocketValueFloat", "default_value"); + + prop = RNA_def_property(srna, "subtype", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "subtype"); + RNA_def_property_enum_items(prop, subtype_items); + RNA_def_property_ui_text(prop, "Subtype", "Subtype defining the socket value details"); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update"); + + prop = RNA_def_property(srna, "default_value", PROP_FLOAT, propsubtype); + RNA_def_property_float_sdna(prop, NULL, "value"); + RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocketFloat_range"); + RNA_def_property_ui_text(prop, "Default Value", ""); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update"); + break; + case SOCK_BOOLEAN: + RNA_def_struct_sdna_from(srna, "bNodeSocketValueBoolean", "default_value"); + + prop = RNA_def_property(srna, "default_value", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "value", 1); + RNA_def_property_ui_text(prop, "Default Value", ""); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update"); + break; + case SOCK_VECTOR: + RNA_def_struct_sdna_from(srna, "bNodeSocketValueVector", "default_value"); + + prop = RNA_def_property(srna, "subtype", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "subtype"); + RNA_def_property_enum_items(prop, subtype_items); + RNA_def_property_ui_text(prop, "Subtype", "Subtype defining the socket value details"); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update"); + + prop = RNA_def_property(srna, "default_value", PROP_FLOAT, propsubtype); + RNA_def_property_float_sdna(prop, NULL, "value"); + RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocketVector_range"); + RNA_def_property_ui_text(prop, "Default Value", ""); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update"); + break; + case SOCK_RGBA: + RNA_def_struct_sdna_from(srna, "bNodeSocketValueRGBA", "default_value"); + + prop = RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_COLOR); + RNA_def_property_float_sdna(prop, NULL, "value"); + RNA_def_property_ui_text(prop, "Default Value", ""); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_NodeSocket_update"); + break; + } } static void rna_def_node(BlenderRNA *brna) @@ -2625,6 +2782,11 @@ static void rna_def_node(BlenderRNA *brna) RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Node_name_set"); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + prop = RNA_def_property(srna, "label", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "label"); + RNA_def_property_ui_text(prop, "Label", "Optional custom node label"); + RNA_def_property_update(prop, NC_NODE, "rna_Node_update"); + prop = RNA_def_property(srna, "inputs", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "inputs", NULL); RNA_def_property_struct_type(prop, "NodeSocket"); @@ -2634,18 +2796,19 @@ static void rna_def_node(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "outputs", NULL); RNA_def_property_struct_type(prop, "NodeSocket"); RNA_def_property_ui_text(prop, "Outputs", ""); - - prop = RNA_def_property(srna, "label", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "label"); - RNA_def_property_ui_text(prop, "Label", "Optional custom node label"); - RNA_def_property_update(prop, NC_NODE, "rna_Node_update"); + + prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "parent"); + RNA_def_property_struct_type(prop, "Node"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Parent", "Parent this node is attached to"); } static void rna_def_node_link(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - + srna = RNA_def_struct(brna, "NodeLink", NULL); RNA_def_struct_ui_text(srna, "NodeLink", "Link between nodes in a node tree"); RNA_def_struct_sdna(srna, "bNodeLink"); @@ -2687,7 +2850,7 @@ static void rna_def_group_sockets_api(BlenderRNA *brna, PropertyRNA *cprop, int RNA_def_function_ui_description(func, "Add a socket to the group tree."); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_string(func, "name", "Socket", 32, "Name", "Name of the socket"); - RNA_def_enum(func, "type", node_socket_type_items, SOCK_VALUE, "Type", "Type of socket"); + RNA_def_enum(func, "type", node_socket_type_items, SOCK_FLOAT, "Type", "Type of socket"); /* return value */ parm= RNA_def_pointer(func, "socket", "NodeSocket", "", "New socket."); RNA_def_function_return(func, parm); @@ -2708,12 +2871,6 @@ static void rna_def_nodetree(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem nodetree_type_items[] = { - {NTREE_SHADER, "SHADER", 0, "Shader", ""}, - {NTREE_COMPOSIT, "COMPOSITE", 0, "Composite", ""}, - {NTREE_TEXTURE, "TEXTURE", 0, "Texture", ""}, - {0, NULL, 0, NULL, NULL}}; - srna = RNA_def_struct(brna, "NodeTree", "ID"); RNA_def_struct_ui_text(srna, "Node Tree", "Node tree consisting of linked nodes used for materials, textures and compositing"); RNA_def_struct_sdna(srna, "bNodeTree"); @@ -2826,15 +2983,23 @@ void RNA_def_nodetree(BlenderRNA *brna) { init(); rna_def_nodetree(brna); + rna_def_node_socket(brna); - rna_def_node_socket_value(brna); - rna_def_node_socket_vector(brna); - rna_def_node_socket_rgba(brna); + + /* Generate RNA definitions for all socket subtypes */ + #define SUBTYPE(socktype, stypename, id, idname) \ + rna_def_node_socket_subtype(brna, SOCK_##socktype, PROP_##id, "NodeSocket"#stypename#idname, #idname" "#stypename" Node Socket"); + NODE_DEFINE_SUBTYPES + #undef SUBTYPE + rna_def_node_socket_subtype(brna, SOCK_BOOLEAN, 0, "NodeSocketBoolean", "Boolean Node Socket"); + rna_def_node_socket_subtype(brna, SOCK_RGBA, 0, "NodeSocketRGBA", "RGBA Node Socket"); + rna_def_node(brna); rna_def_node_link(brna); rna_def_shader_node(brna); rna_def_compositor_node(brna); rna_def_texture_node(brna); + rna_def_composite_nodetree(brna); rna_def_shader_nodetree(brna); rna_def_texture_nodetree(brna); @@ -2843,10 +3008,14 @@ void RNA_def_nodetree(BlenderRNA *brna) #include "rna_nodetree_types.h" - #undef DefNode - define_specific_node(brna, NODE_GROUP, def_group); + define_specific_node(brna, NODE_FORLOOP, def_forloop); + define_specific_node(brna, NODE_WHILELOOP, def_whileloop); + define_specific_node(brna, NODE_FRAME, def_frame); } +/* clean up macro definition */ +#undef NODE_DEFINE_SUBTYPES + #endif diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index d48df85697a..a624d1d6403 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -26,7 +26,12 @@ * \ingroup RNA */ - + +/* Empty definitions for undefined macros to avoid warnings */ +#ifndef DefNode +#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) +#endif + /* Tree type Node ID RNA def function Enum name Struct name UI Name UI Description */ DefNode( ShaderNode, SH_NODE_OUTPUT, 0, "OUTPUT", Output, "Output", "" ) DefNode( ShaderNode, SH_NODE_MATERIAL, def_sh_material, "MATERIAL", Material, "Material", "" ) @@ -138,3 +143,6 @@ DefNode( TextureNode, TEX_NODE_DECOMPOSE, 0, "DECOM DefNode( TextureNode, TEX_NODE_VALTONOR, 0, "VALTONOR", ValToNor, "Val to Nor", "" ) DefNode( TextureNode, TEX_NODE_SCALE, 0, "SCALE", Scale, "Scale", "" ) + +/* undefine macros */ +#undef DefNode diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 4e2be7682f8..83efd9d1a9f 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -132,6 +132,7 @@ EnumPropertyItem object_type_curve_items[] = { #include "DNA_key_types.h" #include "DNA_constraint_types.h" #include "DNA_lattice_types.h" +#include "DNA_node_types.h" #include "BKE_armature.h" #include "BKE_bullet.h" @@ -2035,18 +2036,19 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Matrix", "Inverse of object's parent matrix at time of parenting"); RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_internal_update"); - /* collections */ + /* modifiers */ + prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "Modifier"); + RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the geometric data of the object"); + rna_def_object_modifiers(brna, prop); + + /* constraints */ prop= RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "Constraint"); RNA_def_property_ui_text(prop, "Constraints", "Constraints affecting the transformation of the object"); // RNA_def_property_collection_funcs(prop, 0, 0, 0, 0, 0, 0, 0, "constraints__add", "constraints__remove"); rna_def_object_constraints(brna, prop); - prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "Modifier"); - RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the geometric data of the object"); - rna_def_object_modifiers(brna, prop); - /* game engine */ prop= RNA_def_property(srna, "game", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index ba91fc3536b..77fa975761f 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -51,34 +51,34 @@ #include "WM_types.h" #include "WM_api.h" -static EnumPropertyItem part_from_items[] = { +EnumPropertyItem part_from_items[] = { {PART_FROM_VERT, "VERT", 0, "Verts", ""}, {PART_FROM_FACE, "FACE", 0, "Faces", ""}, {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""}, {0, NULL, 0, NULL, NULL} }; -static EnumPropertyItem part_reactor_from_items[] = { +EnumPropertyItem part_reactor_from_items[] = { {PART_FROM_VERT, "VERT", 0, "Verts", ""}, {PART_FROM_FACE, "FACE", 0, "Faces", ""}, {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""}, {0, NULL, 0, NULL, NULL} }; -static EnumPropertyItem part_dist_items[] = { +EnumPropertyItem part_dist_items[] = { {PART_DISTR_JIT, "JIT", 0, "Jittered", ""}, {PART_DISTR_RAND, "RAND", 0, "Random", ""}, {PART_DISTR_GRID, "GRID", 0, "Grid", ""}, {0, NULL, 0, NULL, NULL} }; -static EnumPropertyItem part_hair_dist_items[] = { +EnumPropertyItem part_hair_dist_items[] = { {PART_DISTR_JIT, "JIT", 0, "Jittered", ""}, {PART_DISTR_RAND, "RAND", 0, "Random", ""}, {0, NULL, 0, NULL, NULL} }; -static EnumPropertyItem part_draw_as_items[] = { +EnumPropertyItem part_draw_as_items[] = { {PART_DRAW_NOT, "NONE", 0, "None", ""}, {PART_DRAW_REND, "RENDER", 0, "Rendered", ""}, {PART_DRAW_DOT, "DOT", 0, "Point", ""}, @@ -88,14 +88,14 @@ static EnumPropertyItem part_draw_as_items[] = { {0, NULL, 0, NULL, NULL} }; -static EnumPropertyItem part_hair_draw_as_items[] = { +EnumPropertyItem part_hair_draw_as_items[] = { {PART_DRAW_NOT, "NONE", 0, "None", ""}, {PART_DRAW_REND, "RENDER", 0, "Rendered", ""}, {PART_DRAW_PATH, "PATH", 0, "Path", ""}, {0, NULL, 0, NULL, NULL} }; -static EnumPropertyItem part_ren_as_items[] = { +EnumPropertyItem part_ren_as_items[] = { {PART_DRAW_NOT, "NONE", 0, "None", ""}, {PART_DRAW_HALO, "HALO", 0, "Halo", ""}, {PART_DRAW_LINE, "LINE", 0, "Line", ""}, @@ -106,7 +106,7 @@ static EnumPropertyItem part_ren_as_items[] = { {0, NULL, 0, NULL, NULL} }; -static EnumPropertyItem part_hair_ren_as_items[] = { +EnumPropertyItem part_hair_ren_as_items[] = { {PART_DRAW_NOT, "NONE", 0, "None", ""}, {PART_DRAW_PATH, "PATH", 0, "Path", ""}, {PART_DRAW_OB, "OBJECT", 0, "Object", ""}, diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index e063f8ec85a..7f85a2fa1d7 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -46,6 +46,42 @@ EnumPropertyItem property_type_items[] = { {PROP_COLLECTION, "COLLECTION", 0, "Collection", ""}, {0, NULL, 0, NULL, NULL}}; +EnumPropertyItem property_subtype_items[] = { + {PROP_NONE, "NONE", 0, "None", ""}, + + /* strings */ + {PROP_FILEPATH, "FILEPATH", 0, "File Path", ""}, + {PROP_DIRPATH, "DIRPATH", 0, "Directory Path", ""}, + {PROP_FILENAME, "FILENAME", 0, "File Name", ""}, + + /* numbers */ + {PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned", ""}, + {PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""}, + {PROP_FACTOR, "FACTOR", 0, "Factor", ""}, + {PROP_ANGLE, "ANGLE", 0, "Angle", ""}, + {PROP_TIME, "TIME", 0, "Time", ""}, + {PROP_DISTANCE, "DISTANCE", 0, "Distance", ""}, + + /* number arrays */ + {PROP_COLOR, "COLOR", 0, "Color", ""}, + {PROP_TRANSLATION, "TRANSLATION", 0, "Translation", ""}, + {PROP_DIRECTION, "DIRECTION", 0, "Direction", ""}, + {PROP_VELOCITY, "VELOCITY", 0, "Velocity", ""}, + {PROP_ACCELERATION, "ACCELERATION", 0, "Acceleration", ""}, + {PROP_MATRIX, "MATRIX", 0, "Matrix", ""}, + {PROP_EULER, "EULER", 0, "Euler Angles", ""}, + {PROP_QUATERNION, "QUATERNION", 0, "Quaternion", ""}, + {PROP_AXISANGLE, "AXISANGLE", 0, "Axis-Angle", ""}, + {PROP_XYZ, "XYZ", 0, "XYZ", ""}, + {PROP_XYZ_LENGTH, "XYZ_LENGTH", 0, "XYZ Length", ""}, + {PROP_COLOR_GAMMA, "COLOR_GAMMA", 0, "Color", ""}, + {PROP_COORDS, "COORDS", 0, "Coordinates", ""}, + + /* booleans */ + {PROP_LAYER, "LAYER", 0, "Layer", ""}, + {PROP_LAYER_MEMBER, "LAYER_MEMBER", 0, "Layer Member", ""}, + {0, NULL, 0, NULL, NULL}}; + EnumPropertyItem property_unit_items[] = { {PROP_UNIT_NONE, "NONE", 0, "None", ""}, {PROP_UNIT_LENGTH, "LENGTH", 0, "Length", ""}, diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 3c60a3b4cd7..8c2f473c65e 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -439,11 +439,10 @@ static void rna_Scene_preview_range_end_frame_set(PointerRNA *ptr, int value) data->r.pefra= value; } -static void rna_Scene_frame_update(bContext *C, PointerRNA *UNUSED(ptr)) +static void rna_Scene_frame_update(Main *bmain, Scene *UNUSED(current_scene), PointerRNA *ptr) { - //Scene *scene= ptr->id.data; - //ED_update_for_newframe(C); - sound_seek_scene(C); + Scene *scene= (Scene*)ptr->id.data; + sound_seek_scene(bmain, scene); } static PointerRNA rna_Scene_active_keying_set_get(PointerRNA *ptr) @@ -3298,7 +3297,6 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_range(prop, MINAFRAME, MAXFRAME); RNA_def_property_int_funcs(prop, NULL, "rna_Scene_current_frame_set", NULL); RNA_def_property_ui_text(prop, "Current Frame", "Current Frame, to update animation data from python frame_set() instead"); - RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SCENE|ND_FRAME, "rna_Scene_frame_update"); prop= RNA_def_property(srna, "frame_subframe", PROP_FLOAT, PROP_TIME); diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index be4adb405e2..59707f05e6f 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -68,13 +68,13 @@ static void rna_Screen_scene_set(PointerRNA *ptr, PointerRNA value) sc->newscene= value.data; } -static void rna_Screen_scene_update(bContext *C, PointerRNA *ptr) +static void rna_Screen_scene_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { bScreen *sc= (bScreen*)ptr->data; /* exception: can't set screens inside of area/region handers */ if(sc->newscene) { - WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, sc->newscene); + WM_main_add_notifier(NC_SCENE|ND_SCENEBROWSE, sc->newscene); sc->newscene= NULL; } } @@ -231,7 +231,6 @@ static void rna_def_screen(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_NULL); RNA_def_property_pointer_funcs(prop, NULL, "rna_Screen_scene_set", NULL, NULL); RNA_def_property_ui_text(prop, "Scene", "Active scene to be edited in the screen"); - RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_Screen_scene_update"); /* collections */ diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index d439c2551f1..93ffa62a4c6 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -121,7 +121,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) static EnumPropertyItem prop_noise_type_items[] = { {MOD_SMOKE_NOISEWAVE, "NOISEWAVE", 0, "Wavelet", ""}, -#if FFTW3 == 1 +#ifdef WITH_FFTW3 {MOD_SMOKE_NOISEFFT, "NOISEFFT", 0, "FFT", ""}, #endif /* {MOD_SMOKE_NOISECURL, "NOISECURL", 0, "Curl", ""}, */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 35360910015..249cdb28ae1 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -48,6 +48,8 @@ #include "WM_api.h" #include "WM_types.h" +#include "RNA_enum_types.h" + EnumPropertyItem space_type_items[] = { {SPACE_EMPTY, "EMPTY", 0, "Empty", ""}, {SPACE_VIEW3D, "VIEW_3D", 0, "3D View", ""}, @@ -119,6 +121,7 @@ EnumPropertyItem viewport_shade_items[] = { #include "BKE_paint.h" #include "ED_image.h" +#include "ED_node.h" #include "ED_screen.h" #include "ED_view3d.h" #include "ED_sequencer.h" @@ -805,10 +808,9 @@ static void rna_SpaceDopeSheetEditor_mode_update(Main *UNUSED(bmain), Scene *sce /* Space Graph Editor */ -static void rna_SpaceGraphEditor_display_mode_update(bContext *C, PointerRNA *UNUSED(ptr)) +static void rna_SpaceGraphEditor_display_mode_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - //SpaceIpo *sipo= (SpaceIpo*)(ptr->data); - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa= rna_area_from_space(ptr); /* after changing view mode, must force recalculation of F-Curve colors * which can only be achieved using refresh as opposed to redraw @@ -822,11 +824,10 @@ static int rna_SpaceGraphEditor_has_ghost_curves_get(PointerRNA *ptr) return (sipo->ghostCurves.first != NULL); } -static void rna_Sequencer_display_mode_update(bContext *C, PointerRNA *ptr) +static void rna_Sequencer_view_type_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - int view = RNA_enum_get(ptr, "view_type"); - - ED_sequencer_update_view(C, view); + ScrArea *sa= rna_area_from_space(ptr); + ED_area_tag_refresh(sa); } static float rna_BackgroundImage_opacity_get(PointerRNA *ptr) @@ -841,6 +842,24 @@ static void rna_BackgroundImage_opacity_set(PointerRNA *ptr, float value) bgpic->blend = 1.0f - value; } +/* Space Node Editor */ + +static int rna_SpaceNodeEditor_node_tree_poll(PointerRNA *ptr, PointerRNA value) +{ + SpaceNode *snode= (SpaceNode*)ptr->data; + bNodeTree *ntree= (bNodeTree*)value.data; + + /* exclude group trees, only trees of the active type */ + return (ntree->nodetype==0 && ntree->type == snode->treetype); +} + +static void rna_SpaceNodeEditor_node_tree_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + SpaceNode *snode= (SpaceNode*)ptr->data; + + ED_node_tree_update(snode, scene); +} + static EnumPropertyItem *rna_SpaceProperties_texture_context_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { Scene *scene = CTX_data_scene(C); @@ -1689,8 +1708,7 @@ static void rna_def_space_sequencer(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "view"); RNA_def_property_enum_items(prop, view_type_items); RNA_def_property_ui_text(prop, "View Type", "The type of the Sequencer view (sequencer, preview or both)"); - RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); - RNA_def_property_update(prop, 0, "rna_Sequencer_display_mode_update"); + RNA_def_property_update(prop, 0, "rna_Sequencer_view_type_update"); /* display type, fairly important */ prop= RNA_def_property(srna, "display_mode", PROP_ENUM, PROP_NONE); @@ -1987,7 +2005,6 @@ static void rna_def_space_graph(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "mode"); RNA_def_property_enum_items(prop, mode_items); RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed"); - RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, "rna_SpaceGraphEditor_display_mode_update"); /* display */ @@ -2418,12 +2435,6 @@ static void rna_def_space_node(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem tree_type_items[] = { - {NTREE_SHADER, "MATERIAL", ICON_MATERIAL, "Material", "Material nodes"}, - {NTREE_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture nodes"}, - {NTREE_COMPOSIT, "COMPOSITING", ICON_RENDERLAYERS, "Compositing", "Compositing nodes"}, - {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem texture_type_items[] = { {SNODE_TEX_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Edit texture nodes from Object"}, {SNODE_TEX_WORLD, "WORLD", ICON_WORLD_DATA, "World", "Edit texture nodes from World"}, @@ -2442,7 +2453,7 @@ static void rna_def_space_node(BlenderRNA *brna) prop= RNA_def_property(srna, "tree_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "treetype"); - RNA_def_property_enum_items(prop, tree_type_items); + RNA_def_property_enum_items(prop, nodetree_type_items); RNA_def_property_ui_text(prop, "Tree Type", "Node tree type to display and edit"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_NODE, NULL); @@ -2463,8 +2474,10 @@ static void rna_def_space_node(BlenderRNA *brna) prop= RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "nodetree"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_SpaceNodeEditor_node_tree_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Node Tree", "Node tree being displayed and edited"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_NODE, "rna_SpaceNodeEditor_node_tree_update"); prop= RNA_def_property(srna, "show_backdrop", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SNODE_BACKDRAW); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index a1ce77b061d..503212201c4 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -48,7 +48,7 @@ #include "BKE_node.h" -static EnumPropertyItem texture_filter_items[] = { +EnumPropertyItem texture_filter_items[] = { {TXF_BOX, "BOX", 0, "Box", ""}, {TXF_EWA, "EWA", 0, "EWA", ""}, {TXF_FELINE, "FELINE", 0, "FELINE", ""}, diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 4c07a89a42f..a595b121d1a 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -482,13 +482,13 @@ static void rna_Window_screen_set(PointerRNA *ptr, PointerRNA value) win->newscreen= value.data; } -static void rna_Window_screen_update(bContext *C, PointerRNA *ptr) +static void rna_Window_screen_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { wmWindow *win= (wmWindow*)ptr->data; /* exception: can't set screens inside of area/region handers */ if(win->newscreen) { - WM_event_add_notifier(C, NC_SCREEN|ND_SCREENBROWSE, win->newscreen); + WM_main_add_notifier(NC_SCREEN|ND_SCREENBROWSE, win->newscreen); win->newscreen= NULL; } } @@ -1454,7 +1454,6 @@ static void rna_def_window(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Screen", "Active screen showing in the window"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_pointer_funcs(prop, NULL, "rna_Window_screen_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_Window_screen_update"); } |