From 8f1847e4c33f4276c6aaf123e658f9d2043f7dcb Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 2 Dec 2008 23:45:11 +0000 Subject: RNA: review of commits in the past days, check the diffs for the many small changes, but the two bigger ones are: * Sensors and controllers now use inheritance, rather than pointing to the data in a separate struct. Had to add some new RNA define functionality to support this better. * DNA_meta_types.h was marked as done but still missing many things, now completed. --- source/blender/makesrna/intern/rna_controller.c | 62 ++++++++++++++++--------- 1 file changed, 39 insertions(+), 23 deletions(-) (limited to 'source/blender/makesrna/intern/rna_controller.c') diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c index ec4ca1216a0..3b52069f556 100644 --- a/source/blender/makesrna/intern/rna_controller.c +++ b/source/blender/makesrna/intern/rna_controller.c @@ -33,31 +33,40 @@ #include "DNA_controller_types.h" #ifdef RNA_RUNTIME -static struct StructRNA* rna_Controller_data_type(struct PointerRNA *ptr) + +static struct StructRNA* rna_Controller_refine(struct PointerRNA *ptr) { bController *controller= (bController*)ptr->data; - switch(controller->type){ + + switch(controller->type) { case CONT_LOGIC_AND: + return &RNA_AndController; case CONT_LOGIC_OR: + return &RNA_OrController; case CONT_LOGIC_NAND: + return &RNA_NandController; case CONT_LOGIC_NOR: + return &RNA_NorController; case CONT_LOGIC_XOR: + return &RNA_XorController; case CONT_LOGIC_XNOR: - return &RNA_UnknownType; + return &RNA_XnorController; case CONT_EXPRESSION: - return &RNA_ExpressionCont; + return &RNA_ExpressionController; case CONT_PYTHON: - return &RNA_PythonCont; + return &RNA_PythonController; + default: + return &RNA_Controller; } - return &RNA_UnknownType; } + #else void RNA_def_controller(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem controller_types_items[] ={ + static EnumPropertyItem controller_type_items[] ={ {CONT_LOGIC_AND, "LOGICAND", "Logic And", ""}, {CONT_LOGIC_OR, "LOGICOR", "Logic Or", ""}, {CONT_LOGIC_NAND, "LOGICNAND", "Logic Nand", ""}, @@ -68,38 +77,45 @@ void RNA_def_controller(BlenderRNA *brna) {CONT_PYTHON, "PYTHON", "Python Script", ""}, {0, NULL, NULL, NULL}}; + /* Controller */ srna= RNA_def_struct(brna, "Controller", NULL , "Controller"); RNA_def_struct_sdna(srna, "bController"); + RNA_def_struct_funcs(srna, NULL, "rna_Controller_refine"); - prop= RNA_def_property(srna, "controller_name", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_string_maxlength(prop, 31); - RNA_def_property_ui_text(prop, "Name", "Controller name."); + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_struct_name_property(srna, prop); /* type is not editable, would need to do proper data free/alloc */ prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_flag(prop, PROP_NOT_EDITABLE); - RNA_def_property_enum_items(prop, controller_types_items); - RNA_def_property_ui_text(prop, "Controller Types", "Controller types."); - - prop= RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE); - RNA_def_property_ui_text(prop, "Data", "Controller data."); - RNA_def_property_pointer_funcs(prop, NULL, "rna_Controller_data_type", NULL); + RNA_def_property_enum_items(prop, controller_type_items); + RNA_def_property_ui_text(prop, "Type", ""); - srna= RNA_def_struct(brna, "ExpressionCont", NULL , "ExpressionCont"); - RNA_def_struct_sdna(srna, "bExpressionCont"); + /* Expression Controller */ + srna= RNA_def_struct(brna, "ExpressionController", "Controller", "Expression Controller"); + RNA_def_struct_sdna_from(srna, "bExpressionCont", "data"); prop= RNA_def_property(srna, "expression", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "str"); RNA_def_property_string_maxlength(prop, 127); - RNA_def_property_ui_text(prop, "Expression", "Expression."); + RNA_def_property_ui_text(prop, "Expression", ""); - srna= RNA_def_struct(brna, "PythonCont", NULL , "PythonCont"); - RNA_def_struct_sdna(srna, "bPythonCont"); + /* Python Controller */ + srna= RNA_def_struct(brna, "PythonController", "Controller" , "Python Controller"); + RNA_def_struct_sdna_from(srna, "bPythonCont", "data"); prop= RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ID"); - RNA_def_property_ui_text(prop, "Python Text", "Python text."); + RNA_def_property_ui_text(prop, "Python Text", ""); + + /* Other Controllers */ + RNA_def_struct(brna, "AndController", "Controller", "And Controller"); + RNA_def_struct(brna, "OrController", "Controller", "Or Controller"); + RNA_def_struct(brna, "NorController", "Controller", "Nor Controller"); + RNA_def_struct(brna, "NandController", "Controller", "Nand Controller"); + RNA_def_struct(brna, "XorController", "Controller", "Xor Controller"); + RNA_def_struct(brna, "XnorController", "Controller", "Xnor Controller"); } #endif -- cgit v1.2.3