diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_actuator.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_actuator.c | 183 |
1 files changed, 119 insertions, 64 deletions
diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 23698e8140f..4254f4280f8 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -33,8 +33,31 @@ #include "WM_types.h" +EnumPropertyItem actuator_type_items[] ={ + {ACT_ACTION, "ACTION", 0, "Action", ""}, + {ACT_ARMATURE, "ARMATURE", 0, "Armature", ""}, + {ACT_CAMERA, "CAMERA", 0, "Camera", ""}, + {ACT_CONSTRAINT, "CONSTRAINT", 0, "Constraint", ""}, + {ACT_EDIT_OBJECT, "EDIT_OBJECT", 0, "Edit Object", ""}, + {ACT_2DFILTER, "FILTER_2D", 0, "2D Filter", ""}, + {ACT_GAME, "GAME", 0, "Game", ""}, + {ACT_IPO, "IPO", 0, "IPO", ""}, + {ACT_MESSAGE, "MESSAGE", 0, "Message", ""}, + {ACT_OBJECT, "OBJECT", 0, "Motion", ""}, + {ACT_PARENT, "PARENT", 0, "Parent", ""}, + {ACT_PROPERTY, "PROPERTY", 0, "Property", ""}, + {ACT_RANDOM, "RANDOM", 0, "Random", ""}, + {ACT_SCENE, "SCENE", 0, "Scene", ""}, + {ACT_SHAPEACTION, "SHAPE_ACTION", 0, "Shape Action", ""}, + {ACT_SOUND, "SOUND", 0, "Sound", ""}, + {ACT_STATE, "STATE", 0, "State", ""}, + {ACT_VISIBILITY, "VISIBILITY", 0, "Visibility", ""}, + {0, NULL, 0, NULL, NULL}}; + #ifdef RNA_RUNTIME +#include "BKE_sca.h" + static StructRNA* rna_Actuator_refine(struct PointerRNA *ptr) { bActuator *actuator= (bActuator*)ptr->data; @@ -65,7 +88,7 @@ static StructRNA* rna_Actuator_refine(struct PointerRNA *ptr) case ACT_VISIBILITY: return &RNA_VisibilityActuator; case ACT_2DFILTER: - return &RNA_TwoDFilterActuator; + return &RNA_Filter2DActuator; case ACT_PARENT: return &RNA_ParentActuator; case ACT_SHAPEACTION: @@ -79,6 +102,13 @@ static StructRNA* rna_Actuator_refine(struct PointerRNA *ptr) } } +static void rna_Actuator_type_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bActuator *act= (bActuator *)ptr->data; + + init_actuator(act); +} + #else void rna_def_actuator(BlenderRNA *brna) @@ -86,27 +116,6 @@ void rna_def_actuator(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem actuator_type_items[] ={ - {ACT_OBJECT, "OBJECT", 0, "Motion", ""}, - {ACT_IPO, "IPO", 0, "IPO", ""}, - {ACT_CAMERA, "CAMERA", 0, "Camera", ""}, - {ACT_SOUND, "SOUND", 0, "Sound", ""}, - {ACT_PROPERTY, "PROPERTY", 0, "Property", ""}, - {ACT_CONSTRAINT, "CONSTRAINT", 0, "Constraint", ""}, - {ACT_EDIT_OBJECT, "EDIT_OBJECT", 0, "Edit Object", ""}, - {ACT_SCENE, "SCENE", 0, "Scene", ""}, - {ACT_RANDOM, "RANDOM", 0, "Random", ""}, - {ACT_MESSAGE, "MESSAGE", 0, "Message", ""}, - {ACT_ACTION, "ACTION", 0, "Action", ""}, - {ACT_GAME, "GAME", 0, "Game", ""}, - {ACT_VISIBILITY, "VISIBILITY", 0, "Visibility", ""}, - {ACT_2DFILTER, "FILTER_2D", 0, "2D Filter", ""}, - {ACT_PARENT, "PARENT", 0, "Parent", ""}, - {ACT_SHAPEACTION, "SHAPE_ACTION", 0, "Shape Action", ""}, - {ACT_STATE, "STATE", 0, "State", ""}, - {ACT_ARMATURE, "ARMATURE", 0, "Armature", ""}, - {0, NULL, 0, NULL, NULL}}; - srna= RNA_def_struct(brna, "Actuator", NULL); RNA_def_struct_ui_text(srna, "Actuator", "Actuator to apply actions in the game engine"); RNA_def_struct_sdna(srna, "bActuator"); @@ -115,12 +124,18 @@ void rna_def_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", ""); - /* 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_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_enum_items(prop, actuator_type_items); RNA_def_property_ui_text(prop, "Type", ""); + RNA_def_property_update(prop, 0, "rna_Actuator_type_update"); + + prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_SHOW); + RNA_def_property_ui_text(prop, "Expanded", "Set actuator expanded in the user interface"); + RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); + } static void rna_def_object_actuator(BlenderRNA *brna) @@ -138,7 +153,8 @@ static void rna_def_object_actuator(BlenderRNA *brna) RNA_def_struct_sdna_from(srna, "bObjectActuator", "data"); - prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "mode", 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, "Motion Type", "Specify the motion system"); RNA_def_property_update(prop, NC_LOGIC, NULL); @@ -174,28 +190,43 @@ static void rna_def_object_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Derivate Coefficient", "Not required, high values can cause instability"); RNA_def_property_update(prop, NC_LOGIC, NULL); - /* XXX We need one of those special get/set functions here: - int offset - if (flag & ACT_SERVO_LIMIT_X): - offset = 0 - elif (flag & ACT_SERVO_LIMIT_Y): - offset = 1 - elif (flag & ACT_SERVO_LIMIT_Z): - offset = 2 - - prop= RNA_def_property(srna, "force_max", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "dloc[offset]"); + /* Servo Limit */ + prop= RNA_def_property(srna, "force_max_x", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "dloc[0]"); RNA_def_property_ui_range(prop, -100.0, 100.0, 1.0, 0.1); RNA_def_property_ui_text(prop, "Max", "Set the upper limit for force"); RNA_def_property_update(prop, NC_LOGIC, NULL); - prop= RNA_def_property(srna, "force_max", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "drot[offset]"); + prop= RNA_def_property(srna, "force_min_x", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "drot[0]"); + RNA_def_property_ui_range(prop, -100.0, 100.0, 1.0, 0.1); + RNA_def_property_ui_text(prop, "Max", "Set the lower limit for force"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "force_max_y", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "dloc[0]"); RNA_def_property_ui_range(prop, -100.0, 100.0, 1.0, 0.1); RNA_def_property_ui_text(prop, "Max", "Set the upper limit for force"); RNA_def_property_update(prop, NC_LOGIC, NULL); - */ - + + prop= RNA_def_property(srna, "force_min_y", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "drot[1]"); + RNA_def_property_ui_range(prop, -100.0, 100.0, 1.0, 0.1); + RNA_def_property_ui_text(prop, "Max", "Set the lower limit for force"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "force_max_z", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "dloc[2]"); + RNA_def_property_ui_range(prop, -100.0, 100.0, 1.0, 0.1); + RNA_def_property_ui_text(prop, "Max", "Set the upper limit for force"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + prop= RNA_def_property(srna, "force_min_z", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "drot[2]"); + RNA_def_property_ui_range(prop, -100.0, 100.0, 1.0, 0.1); + RNA_def_property_ui_text(prop, "Max", "Set the lower limit for force"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + /* floats 3 Arrays*/ prop= RNA_def_property(srna, "loc", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "dloc"); @@ -307,13 +338,13 @@ static void rna_def_ipo_actuator(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "IpoActuator", "Actuator"); - RNA_def_struct_ui_text(srna, "Ipo Actuator", "Actuator to animate the object"); + RNA_def_struct_ui_text(srna, "IPO 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, "Ipo Type", "Specify the way you want to play the animation"); + RNA_def_property_ui_text(prop, "IPO 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_INT, PROP_NONE); @@ -340,14 +371,14 @@ static void rna_def_ipo_actuator(BlenderRNA *brna) /* booleans */ prop= RNA_def_property(srna, "force", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOFORCE); - RNA_def_property_ui_text(prop, "Force", "Apply Ipo as a global or local force depending on the local option (dynamic objects only)"); + RNA_def_property_ui_text(prop, "Force", "Apply IPO as a global or local force depending on the local option (dynamic objects only)"); RNA_def_property_update(prop, NC_LOGIC, NULL); -// logic_window::change_ipo_actuator +//XXX logic_window::change_ipo_actuator // RNA_def_property_boolean_funcs(prop, "rna_Actuator_Ipo_get", "rna_Actuator_Ipo_get", "rna_Actuator_Ipo_range"); prop= RNA_def_property(srna, "local", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOLOCAL); - RNA_def_property_ui_text(prop, "L", "Let the ipo acts in local coordinates, used in Force and Add mode"); + RNA_def_property_ui_text(prop, "L", "Let the IPO act in local coordinates, used in Force and Add mode"); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "child", PROP_BOOLEAN, PROP_NONE); @@ -359,7 +390,7 @@ static void rna_def_ipo_actuator(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_IPOADD); RNA_def_property_ui_text(prop, "Add", "Ipo 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); -// logic_window::change_ipo_actuator +//XXX logic_window::change_ipo_actuator // RNA_def_property_boolean_funcs(prop, "rna_Actuator_Ipo_get", "rna_Actuator_Ipo_get", "rna_Actuator_Ipo_range"); } @@ -405,8 +436,10 @@ static void rna_def_camera_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "axis"); RNA_def_property_enum_items(prop, prop_axis_items); - RNA_def_property_ui_text(prop, "Axis", "Specify the axy the Camera will try to get behind"); + RNA_def_property_ui_text(prop, "Axis", "Specify the axis the Camera will try to get behind"); RNA_def_property_update(prop, NC_LOGIC, NULL); + //XXX it's not working (no default value) + // probably need to make a get/set function } static void rna_def_sound_actuator(BlenderRNA *brna) @@ -434,7 +467,8 @@ static void rna_def_sound_actuator(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Sound", "Sound file"); RNA_def_property_update(prop, NC_LOGIC, NULL); - prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "mode", 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, "Type", ""); RNA_def_property_update(prop, NC_LOGIC, NULL); @@ -523,11 +557,13 @@ static void rna_def_property_actuator(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Property Actuator", "Actuator to handle properties"); RNA_def_struct_sdna_from(srna, "bPropertyActuator", "data"); - prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "mode", 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, "Mode", ""); RNA_def_property_update(prop, NC_LOGIC, NULL); + //XXX add magic property lookup prop= RNA_def_property(srna, "prop_name", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Property", "The name of the property"); @@ -536,6 +572,20 @@ static void rna_def_property_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "value", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Value", "The value to use, use \"\" around strings"); RNA_def_property_update(prop, NC_LOGIC, NULL); + + /* Copy Mode */ + prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_pointer_sdna(prop, NULL, "ob"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Object", "Copy from this Object"); + RNA_def_property_update(prop, NC_LOGIC, NULL); + + //XXX add even magic'er property lookup (need to look for the property list of the target object) + prop= RNA_def_property(srna, "object_prop_name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "value"); + RNA_def_property_ui_text(prop, "Property Name", "Copy this property"); + RNA_def_property_update(prop, NC_LOGIC, NULL); } static void rna_def_constraint_actuator(BlenderRNA *brna) @@ -583,7 +633,7 @@ static void rna_def_edit_object_actuator(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Edit Object Actuator", "Actuator used to edit objects"); RNA_def_struct_sdna_from(srna, "bEditObjectActuator", "data"); - prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "mode", 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, "Edit Object", "The mode of the actuator"); @@ -688,13 +738,14 @@ static void rna_def_scene_actuator(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Scene Actuator", "Actuator to .."); RNA_def_struct_sdna_from(srna, "bSceneActuator", "data"); - prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "mode", 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, "Scene", ""); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_struct_type(prop, "Camera"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Camera Object", "Set this Camera. Leave empty to refer to self object"); RNA_def_property_update(prop, NC_LOGIC, NULL); @@ -705,7 +756,7 @@ static void rna_def_scene_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Scene", "Set the Scene to be added/removed/paused/resumed"); RNA_def_property_update(prop, NC_LOGIC, NULL); - /* XXX + /* XXX no need for those tooltips. to remove soon Originally we had different 'scene' tooltips for different values of 'type'. They were: ACT_SCENE_RESTART "" @@ -750,6 +801,7 @@ static void rna_def_random_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Seed", "Initial seed of the random generator. Use Python for more freedom (choose 0 for not random)"); RNA_def_property_update(prop, NC_LOGIC, NULL); + //XXX add magic property lookup prop= RNA_def_property(srna, "property", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "propname"); RNA_def_property_ui_text(prop, "Property", "Assign the random value to this property"); @@ -910,14 +962,17 @@ static void rna_def_game_actuator(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Game Actuator", ""); RNA_def_struct_sdna_from(srna, "bGameActuator", "data"); - prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "mode", 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, "Game", ""); RNA_def_property_update(prop, NC_LOGIC, NULL); - prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_NONE); + /* ACT_GAME_LOAD */ + prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); RNA_def_property_ui_text(prop, "File", "Load this blend file, use the \"//\" prefix for a path relative to the current blend file"); RNA_def_property_update(prop, NC_LOGIC, NULL); + //XXX to do: an operator that calls file_browse with relative_path on and blender filtering active } static void rna_def_visibility_actuator(BlenderRNA *brna) @@ -969,11 +1024,12 @@ static void rna_def_twodfilter_actuator(BlenderRNA *brna) // {ACT_2DFILTER_NUMBER_OF_FILTERS, "", 0, "Do not use it. Sentinel", ""}, {0, NULL, 0, NULL, NULL}}; - srna= RNA_def_struct(brna, "TwoDFilterActuator", "Actuator"); + srna= RNA_def_struct(brna, "Filter2DActuator", "Actuator"); RNA_def_struct_ui_text(srna, "2D Filter Actuator", "Actuator to .."); RNA_def_struct_sdna_from(srna, "bTwoDFilterActuator", "data"); - prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "mode", 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, "2D Filter Type", ""); RNA_def_property_update(prop, NC_LOGIC, NULL); @@ -998,11 +1054,8 @@ static void rna_def_twodfilter_actuator(BlenderRNA *brna) RNA_def_property_update(prop, NC_LOGIC, NULL); /* booleans */ - // it must be renamed to enable_motion_blur. - // it'll require code change and do_version() - // or RNA_def_property_boolean_funcs() to flip the boolean value - prop= RNA_def_property(srna, "disable_motion_blur", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", 1); + prop= RNA_def_property(srna, "enable_motion_blur", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", 1); RNA_def_property_ui_text(prop, "D", "Enable/Disable Motion Blur"); RNA_def_property_update(prop, NC_LOGIC, NULL); } @@ -1021,7 +1074,8 @@ static void rna_def_parent_actuator(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Parent Actuator", ""); RNA_def_struct_sdna_from(srna, "bParentActuator", "data"); - prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "mode", 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, "Scene", ""); RNA_def_property_update(prop, NC_LOGIC, NULL); @@ -1065,7 +1119,8 @@ static void rna_def_shape_action_actuator(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Shape Action Actuator", "Actuator to .."); RNA_def_struct_sdna_from(srna, "bActionActuator", "data"); - prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "mode", 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, "Action type", "Action playback type"); RNA_def_property_update(prop, NC_LOGIC, NULL); |