diff options
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sensor.c | 90 |
3 files changed, 90 insertions, 4 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 84d77adb6ee..a42ae8b16fc 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -82,6 +82,7 @@ extern StructRNA RNA_Region; extern StructRNA RNA_Operator; extern StructRNA RNA_WindowManager; extern StructRNA RNA_Sensor; +extern StructRNA RNA_MouseSensor; /* Pointer * diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index f2a69798bcf..aa2cc819177 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -58,6 +58,9 @@ void RNA_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "loc", PROP_FLOAT, PROP_VECTOR); RNA_def_property_ui_text(prop, "Location", ""); + prop= RNA_def_property(srna, "sensors", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "Sensor"); + RNA_def_property_ui_text(prop, "Sensors", "Sensors of this object."); } #endif diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 2e71a6252ed..69ed9bbd667 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -33,16 +33,98 @@ #include "DNA_sensor_types.h" #ifdef RNA_RUNTIME - +/* +static struct StructRNA* rna_Sensor_data_type(struct PointerRNA *ptr) +{ +// This function should reture the type of +// void* data; +// in bSensor structure + switch( ((bSensor*)ptr)->type ){ + case SENS_MOUSE: + return &RNA_MouseSensor; + } + return NULL; +} +*/ #else - void RNA_def_sensor(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - - srna= RNA_def_struct(brna, "Sensor", NULL, "Sensor"); + static EnumPropertyItem pulse_modes[]={ + {SENS_PULSE_CONT, "CONTINUE", "Continue Pulse", ""}, + {SENS_PULSE_REPEAT, "REPEAT", "Repeat Pulse", ""}, + {SENS_NEG_PULSE_MODE, "NEGATIVE", "Negative Pulse", ""}, + {0, NULL, NULL, NULL}}; + + static EnumPropertyItem sensor_types_items[] ={ + {SENS_ALWAYS, "ALWAYS", "Always", ""}, + {SENS_TOUCH, "TOUCH", "Touch", ""}, + {SENS_NEAR, "NEAR", "Near", ""}, + {SENS_KEYBOARD, "KEYBOARD", "Keyboard", ""}, + {SENS_PROPERTY, "PROPERTY", "Property", ""}, + {SENS_MOUSE, "MOUSE", "Mouse", ""}, + {SENS_COLLISION, "COLLISION", "Collision", ""}, + {SENS_RADAR, "RADAR", "Radar", ""}, + {SENS_RANDOM, "RANDOM", "Random", ""}, + {SENS_RAY, "RAY", "Ray", ""}, + {SENS_MESSAGE, "MESSAGE", "Message", ""}, + {SENS_JOYSTICK, "JOYSTICK", "joystick", ""}, + {SENS_ACTUATOR, "ACTUATOR", "Actuator", ""}, + {SENS_DELAY, "DELAY", "Delay", ""}, + {0, NULL, NULL, NULL}}; + + static EnumPropertyItem mouse_event_items[] ={ + {BL_SENS_MOUSE_LEFT_BUTTON, "LEFTCLICK", "Left Button", ""}, + {BL_SENS_MOUSE_MIDDLE_BUTTON, "MIDDLECLICK", "Middle Button", ""}, + {BL_SENS_MOUSE_RIGHT_BUTTON, "RIGHTCLICK", "Right Button", ""}, + {BL_SENS_MOUSE_WHEEL_UP, "WHEELUP", "Wheel Up", ""}, + {BL_SENS_MOUSE_WHEEL_DOWN, "WHEELDOWN", "Wheel Down", ""}, + {BL_SENS_MOUSE_MOVEMENT, "MOVEMENT", "Movement", ""}, + {BL_SENS_MOUSE_MOUSEOVER, "MOUSEOVER", "Mouse Over", ""}, + {BL_SENS_MOUSE_MOUSEOVER_ANY, "MOUSEOVERANY", "Mouse Over Any", ""}, + {0, NULL, NULL, NULL}}; + + srna= RNA_def_struct(brna, "Sensor", NULL , "Sensor"); + RNA_def_struct_sdna(srna, "bSensor"); + + prop= RNA_def_property(srna, "sensor_name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "name"); + RNA_def_property_ui_text(prop, "Name", "Sensor name."); + + prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, sensor_types_items); + RNA_def_property_ui_text(prop, "Sensor types", "Sensor Types."); + + prop= RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Invert Output", "Invert the level(output) of this sensor."); + + prop= RNA_def_property(srna, "level", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Level", "Level detector, trigger controllers of new states(only applicable upon logic state transition)."); + + prop= RNA_def_property(srna, "pulse", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, pulse_modes); + RNA_def_property_ui_text(prop, "Sensor pulse modes", "Sensor pulse modes."); + + prop= RNA_def_property(srna, "freq", PROP_INT, PROP_NONE); + RNA_def_property_ui_text(prop, "Frequency", "Delay between repeated pulses(in logic tics, 0=no delay)."); + RNA_def_property_range(prop, 0, 10000); + + /* + //This add data property to Sensor, and because data can be bMouseSensor, bNearSensor, bAlwaysSensor ... + //rna_Sensor_data_type defines above in runtime section to get its type and proper structure for data + prop= RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Data", "Sensor data."); + RNA_def_property_pointer_funcs(prop, NULL, "rna_Sensor_data_type", NULL); + + srna= RNA_def_struct(brna, "MouseSensor", NULL , "MouseSensor"); + RNA_def_struct_sdna(srna, "bMouseSensor"); + + prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, mouse_event_items); + RNA_def_property_ui_text(prop, "MouseEvent", "Specify the type of event this mouse sensor should trigger on."); + */ } #endif |