Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_sensor.c
| Context not available. | |||||
| {SENS_NEAR, "NEAR", 0, "Near", ""}, | {SENS_NEAR, "NEAR", 0, "Near", ""}, | ||||
| {SENS_PROPERTY, "PROPERTY", 0, "Property", ""}, | {SENS_PROPERTY, "PROPERTY", 0, "Property", ""}, | ||||
| {SENS_RADAR, "RADAR", 0, "Radar", ""}, | {SENS_RADAR, "RADAR", 0, "Radar", ""}, | ||||
| {SENS_MOVEMENT, "MOVEMENT", 0, "Movement", ""}, | |||||
| {SENS_RANDOM, "RANDOM", 0, "Random", ""}, | {SENS_RANDOM, "RANDOM", 0, "Random", ""}, | ||||
| {SENS_RAY, "RAY", 0, "Ray", ""}, | {SENS_RAY, "RAY", 0, "Ray", ""}, | ||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| Context not available. | |||||
| return &RNA_RandomSensor; | return &RNA_RandomSensor; | ||||
| case SENS_RAY: | case SENS_RAY: | ||||
| return &RNA_RaySensor; | return &RNA_RaySensor; | ||||
| case SENS_MOVEMENT: | |||||
| return &RNA_MovementSensor; | |||||
| case SENS_MESSAGE: | case SENS_MESSAGE: | ||||
| return &RNA_MessageSensor; | return &RNA_MessageSensor; | ||||
| case SENS_JOYSTICK: | case SENS_JOYSTICK: | ||||
| Context not available. | |||||
| RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_KEYBOARD); | RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_KEYBOARD); | ||||
| RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_MESSAGE); | RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_MESSAGE); | ||||
| RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_MOUSE); | RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_MOUSE); | ||||
| RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_MOVEMENT); | |||||
| RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_NEAR); | RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_NEAR); | ||||
| RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_PROPERTY); | RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_PROPERTY); | ||||
| RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RADAR); | RNA_enum_items_add_value(&item, &totitem, sensor_type_items, SENS_RADAR); | ||||
| Context not available. | |||||
| RNA_def_property_enum_items(prop, axis_items); | RNA_def_property_enum_items(prop, axis_items); | ||||
| RNA_def_property_ui_text(prop, "Axis", "Along which axis the ray is cast"); | RNA_def_property_ui_text(prop, "Axis", "Along which axis the ray is cast"); | ||||
| RNA_def_property_update(prop, NC_LOGIC, NULL); | RNA_def_property_update(prop, NC_LOGIC, NULL); | ||||
| prop = RNA_def_property(srna, "mask", PROP_BOOLEAN, PROP_LAYER_MEMBER); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "mask", 1); | |||||
| RNA_def_property_array(prop, OB_MAX_COL_MASKS); | |||||
| RNA_def_property_ui_text(prop, "Mask", "Mask filter compared with object's collision group"); | |||||
| RNA_def_property_update(prop, NC_LOGIC, NULL); | |||||
| } | |||||
| static void rna_def_movement_sensor(BlenderRNA *brna) | |||||
| { | |||||
| StructRNA *srna; | |||||
| PropertyRNA *prop; | |||||
| static EnumPropertyItem axis_items[] = { | |||||
| { SENS_MOVEMENT_X_AXIS, "XAXIS", 0, "+X axis", "" }, | |||||
| { SENS_MOVEMENT_Y_AXIS, "YAXIS", 0, "+Y axis", "" }, | |||||
| { SENS_MOVEMENT_Z_AXIS, "ZAXIS", 0, "+Z axis", "" }, | |||||
| { SENS_MOVEMENT_NEG_X_AXIS, "NEGXAXIS", 0, "-X axis", "" }, | |||||
| { SENS_MOVEMENT_NEG_Y_AXIS, "NEGYAXIS", 0, "-Y axis", "" }, | |||||
| { SENS_MOVEMENT_NEG_Z_AXIS, "NEGZAXIS", 0, "-Z axis", "" }, | |||||
| { SENS_MOVEMENT_ALL_AXIS, "ALLAXIS", 0, "All axis", "" }, | |||||
| { 0, NULL, 0, NULL, NULL } | |||||
| }; | |||||
| srna = RNA_def_struct(brna, "MovementSensor", "Sensor"); | |||||
| RNA_def_struct_ui_text(srna, "Movement Sensor", "Sensor to detect if the owner has moved"); | |||||
| RNA_def_struct_sdna_from(srna, "bMovementSensor", "data"); | |||||
| prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); | |||||
| RNA_def_property_enum_sdna(prop, NULL, "axisflag"); | |||||
| RNA_def_property_enum_items(prop, axis_items); | |||||
| RNA_def_property_ui_text(prop, "Axis", "Along which axis movement has to be detected"); | |||||
| 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, "localflag", SENS_MOVEMENT_LOCAL); | |||||
| RNA_def_property_ui_text(prop, "Local", | |||||
| "Toggle beetween local/global coordinates"); | |||||
| RNA_def_property_update(prop, NC_LOGIC, NULL); | |||||
| prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE); | |||||
| RNA_def_property_float_sdna(prop, NULL, "threshold"); | |||||
| RNA_def_property_float_default(prop, 0.01f); | |||||
| RNA_def_property_ui_text(prop, "Threshold", "Set Threshold"); | |||||
| RNA_def_property_range(prop, 0.001f, 10000.0f); | |||||
| RNA_def_property_ui_range(prop, 0.001, 10000.0, 0.1, 3); | |||||
| RNA_def_property_update(prop, NC_LOGIC, NULL); | |||||
| } | } | ||||
| static void rna_def_message_sensor(BlenderRNA *brna) | static void rna_def_message_sensor(BlenderRNA *brna) | ||||
| Context not available. | |||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| static EnumPropertyItem event_type_joystick_items[] = { | static EnumPropertyItem event_type_joystick_items[] = { | ||||
| {SENS_JOY_BUTTON, "BUTTON", 0, "Button", ""}, | {SENS_JOY_AXIS, "STICK_DIRECTIONS", 0, "Stick Directions", ""}, | ||||
| {SENS_JOY_AXIS, "AXIS", 0, "Axis", ""}, | {SENS_JOY_AXIS_SINGLE, "STICK_AXIS", 0, "Stick Axis", ""}, | ||||
| {SENS_JOY_HAT, "HAT", 0, "Hat", ""}, | {SENS_JOY_SHOULDER_TRIGGER, "SHOULDER_TRIGGERS", 0, "Shoulder Triggers", ""}, | ||||
| {SENS_JOY_AXIS_SINGLE, "AXIS_SINGLE", 0, "Single Axis", ""}, | {SENS_JOY_BUTTON, "BUTTONS", 0, "Buttons", ""}, | ||||
| {0, NULL, 0, NULL, NULL} | |||||
| }; | |||||
| static EnumPropertyItem axis_items[] = { | |||||
| {SENS_JOY_LEFT_STICK, "LEFT_STICK", 0, "Left Stick", ""}, | |||||
| {SENS_JOY_RIGHT_STICK, "RIGHT_STICK", 0, "Right Stick", ""}, | |||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| static EnumPropertyItem axis_direction_items[] = { | static EnumPropertyItem axis_direction_items[] = { | ||||
| {SENS_JOY_X_AXIS, "RIGHTAXIS", 0, "Right Axis", ""}, | {SENS_JOY_X_AXIS, "RIGHTAXIS", 0, "Right", ""}, | ||||
| {SENS_JOY_Y_AXIS, "UPAXIS", 0, "Up Axis", ""}, | {SENS_JOY_Y_AXIS, "UPAXIS", 0, "Up", ""}, | ||||
| {SENS_JOY_NEG_X_AXIS, "LEFTAXIS", 0, "Left Axis", ""}, | {SENS_JOY_NEG_X_AXIS, "LEFTAXIS", 0, "Left", ""}, | ||||
| {SENS_JOY_NEG_Y_AXIS, "DOWNAXIS", 0, "Down Axis", ""}, | {SENS_JOY_NEG_Y_AXIS, "DOWNAXIS", 0, "Down", ""}, | ||||
| {0, NULL, 0, NULL, NULL} | |||||
| }; | |||||
| static EnumPropertyItem axis_trigger_items[] = { | |||||
| {SENS_JOY_LEFT_SHOULDER_TRIGGER, "LEFT_SHOULDER_TRIGGER", 0, "Left Shoulder Trigger", ""}, | |||||
| {SENS_JOY_RIGHT_SHOULDER_TRIGGER, "RIGHT_SHOULDER_TRIGGER", 0, "Right Shoulder Trigger", ""}, | |||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| static EnumPropertyItem hat_direction_items[] = { | static EnumPropertyItem axis_single_items[] = { | ||||
| {SENS_JOY_HAT_UP, "UP", 0, "Up", ""}, | {SENS_JOY_LEFT_STICK_HORIZONTAL, "LEFT_STICK_HORIZONTAL", 0, "Left Stick Horizontal", ""}, | ||||
| {SENS_JOY_HAT_DOWN, "DOWN", 0, "Down", ""}, | {SENS_JOY_LEFT_STICK_VERTICAL, "LEFT_STICK_VERTICAL", 0, "Left Stick Vertical", ""}, | ||||
| {SENS_JOY_HAT_LEFT, "LEFT", 0, "Left", ""}, | {SENS_JOY_RIGHT_STICK_HORIZONTAL, "RIGHT_STICK_HORIZONTAL", 0, "Right Stick Horizontal", ""}, | ||||
| {SENS_JOY_HAT_RIGHT, "RIGHT", 0, "Right", ""}, | {SENS_JOY_RIGHT_STICK_VERTICAL, "RIGHT_STICK_VERTICAL", 0, "Right Stick Vertical", ""}, | ||||
| {0, NULL, 0, NULL, NULL} | |||||
| }; | |||||
| {SENS_JOY_HAT_UP_RIGHT, "UPRIGHT", 0, "Up/Right", ""}, | static EnumPropertyItem button_items[] = { | ||||
| {SENS_JOY_HAT_DOWN_LEFT, "DOWNLEFT", 0, "Down/Left", ""}, | {SENS_JOY_BUTTON_A, "BUTTON_A", 0, "A", ""}, | ||||
| {SENS_JOY_HAT_UP_LEFT, "UPLEFT", 0, "Up/Left", ""}, | {SENS_JOY_BUTTON_B, "BUTTON_B", 0, "B", ""}, | ||||
| {SENS_JOY_HAT_DOWN_RIGHT, "DOWNRIGHT", 0, "Down/Right", ""}, | {SENS_JOY_BUTTON_X, "BUTTON_X", 0, "X", ""}, | ||||
| {SENS_JOY_BUTTON_Y, "BUTTON_Y", 0, "Y", ""}, | |||||
| {SENS_JOY_BUTTON_BACK, "BUTTON_BACK", 0, "Back", ""}, | |||||
| {SENS_JOY_BUTTON_GUIDE, "BUTTON_GUIDE", 0, "Guide", ""}, | |||||
| {SENS_JOY_BUTTON_START, "BUTTON_START", 0, "Start", ""}, | |||||
| {SENS_JOY_BUTTON_STICK_LEFT, "BUTTON_STICK_LEFT", 0, "Left Stick", ""}, | |||||
| {SENS_JOY_BUTTON_STICK_RIGHT, "BUTTON_STICK_RIGHT", 0, "Right Stick", ""}, | |||||
| {SENS_JOY_BUTTON_SHOULDER_LEFT, "BUTTON_SHOULDER_LEFT", 0, "Left Shoulder", ""}, | |||||
| {SENS_JOY_BUTTON_SHOULDER_RIGHT, "BUTTON_SHOULDER_RIGHT", 0, "Right Shoulder", ""}, | |||||
| {SENS_JOY_BUTTON_DPAD_UP, "BUTTON_DPAD_UP", 0, "Dpad Up", ""}, | |||||
| {SENS_JOY_BUTTON_DPAD_DOWN, "BUTTON_DPAD_DOWN", 0, "Dpad Down", ""}, | |||||
| {SENS_JOY_BUTTON_DPAD_LEFT, "BUTTON_DPAD_LEFT", 0, "Dpad Left", ""}, | |||||
| {SENS_JOY_BUTTON_DPAD_RIGHT, "BUTTON_DPAD_RIGHT", 0, "Dpad Right", ""}, | |||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| Context not available. | |||||
| prop = RNA_def_property(srna, "joystick_index", PROP_INT, PROP_NONE); | prop = RNA_def_property(srna, "joystick_index", PROP_INT, PROP_NONE); | ||||
| RNA_def_property_int_sdna(prop, NULL, "joyindex"); | RNA_def_property_int_sdna(prop, NULL, "joyindex"); | ||||
| RNA_def_property_ui_text(prop, "Index", "Which joystick to use"); | RNA_def_property_ui_text(prop, "Joystick Index", "Which joystick to use"); | ||||
| RNA_def_property_range(prop, 0, SENS_JOY_MAXINDEX - 1); | RNA_def_property_range(prop, 0, SENS_JOY_MAXINDEX - 1); | ||||
| RNA_def_property_update(prop, NC_LOGIC, NULL); | RNA_def_property_update(prop, NC_LOGIC, NULL); | ||||
| Context not available. | |||||
| prop = RNA_def_property(srna, "use_all_events", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_all_events", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_JOY_ANY_EVENT); | RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_JOY_ANY_EVENT); | ||||
| RNA_def_property_ui_text(prop, "All Events", | RNA_def_property_ui_text(prop, "All Events", | ||||
| "Triggered by all events on this joystick's current type (axis/button/hat)"); | "Triggered by all events on this joystick's current type (axis/button)"); | ||||
| RNA_def_property_update(prop, NC_LOGIC, NULL); | RNA_def_property_update(prop, NC_LOGIC, NULL); | ||||
| /* Button */ | /* Button */ | ||||
| prop = RNA_def_property(srna, "button_number", PROP_INT, PROP_NONE); | prop = RNA_def_property(srna, "button_number", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_int_sdna(prop, NULL, "button"); | RNA_def_property_enum_sdna(prop, NULL, "button"); | ||||
| RNA_def_property_ui_text(prop, "Button Number", "Which button to use"); | RNA_def_property_enum_items(prop, button_items); | ||||
| RNA_def_property_range(prop, 0, 18); | RNA_def_property_ui_text(prop, "Button", "Which button to use"); | ||||
| RNA_def_property_update(prop, NC_LOGIC, NULL); | RNA_def_property_update(prop, NC_LOGIC, NULL); | ||||
| /* Axis */ | /* Axis */ | ||||
| prop = RNA_def_property(srna, "axis_number", PROP_INT, PROP_NONE); | prop = RNA_def_property(srna, "axis_number", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_int_sdna(prop, NULL, "axis"); | RNA_def_property_enum_sdna(prop, NULL, "axis"); | ||||
| RNA_def_property_ui_text(prop, "Axis Number", "Which axis pair to use, 1 is usually the main direction input"); | RNA_def_property_enum_items(prop, axis_items); | ||||
| RNA_def_property_range(prop, 1, 8); | RNA_def_property_ui_text(prop, "Stick", "Which Stick to use"); | ||||
| RNA_def_property_update(prop, NC_LOGIC, NULL); | |||||
| prop = RNA_def_property(srna, "axis_threshold", PROP_INT, PROP_NONE); | |||||
| RNA_def_property_int_sdna(prop, NULL, "precision"); | |||||
| RNA_def_property_ui_text(prop, "Axis Threshold", "Precision of the axis"); | |||||
| RNA_def_property_range(prop, 0, 32768); | |||||
| RNA_def_property_update(prop, NC_LOGIC, NULL); | RNA_def_property_update(prop, NC_LOGIC, NULL); | ||||
| prop = RNA_def_property(srna, "axis_direction", PROP_ENUM, PROP_NONE); | prop = RNA_def_property(srna, "axis_direction", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_sdna(prop, NULL, "axisf"); | RNA_def_property_enum_sdna(prop, NULL, "axisf"); | ||||
| RNA_def_property_enum_items(prop, axis_direction_items); | RNA_def_property_enum_items(prop, axis_direction_items); | ||||
| RNA_def_property_ui_text(prop, "Axis Direction", "The direction of the axis"); | RNA_def_property_ui_text(prop, "Stick Direction", "The direction of the stick"); | ||||
| RNA_def_property_update(prop, NC_LOGIC, NULL); | RNA_def_property_update(prop, NC_LOGIC, NULL); | ||||
| /* Single Axis */ | /* Triggers */ | ||||
| prop = RNA_def_property(srna, "single_axis_number", PROP_INT, PROP_NONE); | prop = RNA_def_property(srna, "axis_trigger_number", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_int_sdna(prop, NULL, "axis_single"); | RNA_def_property_enum_sdna(prop, NULL, "axis_single"); | ||||
| RNA_def_property_ui_text(prop, "Axis Number", "Single axis (vertical/horizontal/other) to detect"); | RNA_def_property_enum_items(prop, axis_trigger_items); | ||||
| RNA_def_property_range(prop, 1, 16); | RNA_def_property_ui_text(prop, "Triggers", "Which trigger to detect"); | ||||
| RNA_def_property_update(prop, NC_LOGIC, NULL); | RNA_def_property_update(prop, NC_LOGIC, NULL); | ||||
| /* Hat */ | /* Single Axis */ | ||||
| prop = RNA_def_property(srna, "hat_number", PROP_INT, PROP_NONE); | prop = RNA_def_property(srna, "single_axis_number", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_int_sdna(prop, NULL, "hat"); | RNA_def_property_enum_sdna(prop, NULL, "axis_single"); | ||||
| RNA_def_property_ui_text(prop, "Hat Number", "Which hat to use"); | RNA_def_property_enum_items(prop, axis_single_items); | ||||
| RNA_def_property_range(prop, 1, 2); | RNA_def_property_ui_text(prop, "Stick Axis", "Which stick single axis (vertical/horizontal/other) to detect"); | ||||
| RNA_def_property_update(prop, NC_LOGIC, NULL); | RNA_def_property_update(prop, NC_LOGIC, NULL); | ||||
| prop = RNA_def_property(srna, "hat_direction", PROP_ENUM, PROP_NONE); | /* Common */ | ||||
| RNA_def_property_enum_sdna(prop, NULL, "hatf"); | prop = RNA_def_property(srna, "axis_threshold", PROP_INT, PROP_NONE); | ||||
| RNA_def_property_enum_items(prop, hat_direction_items); | RNA_def_property_int_sdna(prop, NULL, "precision"); | ||||
| RNA_def_property_ui_text(prop, "Hat Direction", "Hat direction"); | RNA_def_property_ui_text(prop, "Threshold", "Threshold minimum to detect the stick/trigger"); | ||||
| RNA_def_property_range(prop, 0, 32768); | |||||
| RNA_def_property_update(prop, NC_LOGIC, NULL); | RNA_def_property_update(prop, NC_LOGIC, NULL); | ||||
| } | } | ||||
| Context not available. | |||||
| rna_def_radar_sensor(brna); | rna_def_radar_sensor(brna); | ||||
| rna_def_random_sensor(brna); | rna_def_random_sensor(brna); | ||||
| rna_def_ray_sensor(brna); | rna_def_ray_sensor(brna); | ||||
| rna_def_movement_sensor(brna); | |||||
| rna_def_message_sensor(brna); | rna_def_message_sensor(brna); | ||||
| rna_def_joystick_sensor(brna); | rna_def_joystick_sensor(brna); | ||||
| } | } | ||||
| Context not available. | |||||