Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_userdef.c
| Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | #ifdef WITH_OPENAL | ||||
| {2, "OPENAL", 0, "OpenAL", "OpenAL device - supports 3D audio, recommended for game engine usage"}, | {2, "OPENAL", 0, "OpenAL", "OpenAL device - supports 3D audio, recommended for game engine usage"}, | ||||
| #endif | #endif | ||||
| #ifdef WITH_JACK | #ifdef WITH_JACK | ||||
| {3, "JACK", 0, "JACK", "JACK Audio Connection Kit, recommended for pro audio users"}, | {3, "JACK", 0, "JACK", "JACK Audio Connection Kit, recommended for pro audio users"}, | ||||
| #endif | #endif | ||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| #ifdef WITH_INPUT_HMD | |||||
| static EnumPropertyItem hmd_device_items[] = { | |||||
| {-1, "NONE", 0, "None", "Don't use any HMD device"}, | |||||
| {0, NULL, 0, NULL, NULL} | |||||
| }; | |||||
| #endif | |||||
| EnumPropertyItem rna_enum_navigation_mode_items[] = { | EnumPropertyItem rna_enum_navigation_mode_items[] = { | ||||
| {VIEW_NAVIGATION_WALK, "WALK", 0, "Walk", "Interactively walk or free navigate around the scene"}, | {VIEW_NAVIGATION_WALK, "WALK", 0, "Walk", "Interactively walk or free navigate around the scene"}, | ||||
| {VIEW_NAVIGATION_FLY, "FLY", 0, "Fly", "Use fly dynamics to navigate the scene"}, | {VIEW_NAVIGATION_FLY, "FLY", 0, "Fly", "Use fly dynamics to navigate the scene"}, | ||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| #if defined(WITH_INTERNATIONAL) || !defined(RNA_RUNTIME) | #if defined(WITH_INTERNATIONAL) || !defined(RNA_RUNTIME) | ||||
| static EnumPropertyItem rna_enum_language_default_items[] = { | static EnumPropertyItem rna_enum_language_default_items[] = { | ||||
| Show All 9 Lines | |||||
| #include "BKE_blender.h" | #include "BKE_blender.h" | ||||
| #include "BKE_depsgraph.h" | #include "BKE_depsgraph.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_idprop.h" | #include "BKE_idprop.h" | ||||
| #include "BKE_pbvh.h" | #include "BKE_pbvh.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_screen.h" | |||||
| #include "BLI_string.h" | |||||
| #include "ED_screen.h" | |||||
| #include "GPU_draw.h" | #include "GPU_draw.h" | ||||
| #include "GPU_select.h" | #include "GPU_select.h" | ||||
| #include "BLF_api.h" | #include "BLF_api.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "MEM_CacheLimiterC-Api.h" | #include "MEM_CacheLimiterC-Api.h" | ||||
| ▲ Show 20 Lines • Show All 452 Lines • ▼ Show 20 Lines | #endif | ||||
| UNUSED_VARS(index, audio_device_items); | UNUSED_VARS(index, audio_device_items); | ||||
| RNA_enum_item_end(&item, &totitem); | RNA_enum_item_end(&item, &totitem); | ||||
| *r_free = true; | *r_free = true; | ||||
| return item; | return item; | ||||
| } | } | ||||
| #ifdef WITH_INPUT_HMD | |||||
| static EnumPropertyItem *rna_userdef_hmd_device_itemf( | |||||
| bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), | |||||
| bool *r_free) | |||||
| { | |||||
| static char names[MAX_HMD_DEVICES][MAX_NAME]; | |||||
| EnumPropertyItem *item = NULL; | |||||
| int totitem = 0; | |||||
| /* 'None' element */ | |||||
| RNA_enum_item_add(&item, &totitem, &hmd_device_items[0]); | |||||
| /* add devices */ | |||||
| for (int i = 0; i < WM_device_HMD_num_devices_get() && i < MAX_HMD_DEVICES; i++) { | |||||
| EnumPropertyItem tmp = {i, "", 0, "", ""}; | |||||
| BLI_snprintf(names[i], sizeof(names[i]), "%s %s", WM_device_HMD_vendor_get(i), WM_device_HMD_name_get(i)); | |||||
| tmp.identifier = tmp.name = names[i]; | |||||
| RNA_enum_item_add(&item, &totitem, &tmp); | |||||
| } | |||||
| RNA_enum_item_end(&item, &totitem); | |||||
| *r_free = true; | |||||
| return item; | |||||
| } | |||||
| static void rna_userdef_hmd_device_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) | |||||
| { | |||||
| const int act_device = WM_device_HMD_current_get(); | |||||
| if (U.hmd_settings.device < 0) { | |||||
| /* disabled device ('None' entry) */ | |||||
| WM_device_HMD_state_set(act_device, false); | |||||
| } | |||||
| else if (act_device != U.hmd_settings.device) { | |||||
| /* change device */ | |||||
| WM_device_HMD_state_set(U.hmd_settings.device, true); | |||||
| } | |||||
| } | |||||
| void rna_userdef_hmd_use_device_ipd_set(PointerRNA *UNUSED(ptr), int value) | |||||
| { | |||||
| if (value) { | |||||
| U.hmd_settings.flag |= USER_HMD_USE_DEVICE_IPD; | |||||
| WM_device_HMD_IPD_set(U.hmd_settings.init_ipd); | |||||
| } | |||||
| else { | |||||
| U.hmd_settings.flag &= ~USER_HMD_USE_DEVICE_IPD; | |||||
| U.hmd_settings.init_ipd = WM_device_HMD_IPD_get(); | |||||
| WM_device_HMD_IPD_set(U.hmd_settings.custom_ipd); | |||||
| } | |||||
| } | |||||
| static int rna_userdef_hmd_active_device_poll(PointerRNA *UNUSED(ptr), const char **r_info) | |||||
| { | |||||
| if (U.hmd_settings.device == -1) { | |||||
| *r_info = "No valid HMD device selected"; | |||||
| return false; | |||||
| } | |||||
| return PROP_EDITABLE; | |||||
| } | |||||
| void rna_userdef_hmd_custom_ipd_set(PointerRNA *UNUSED(ptr), float value) | |||||
| { | |||||
| U.hmd_settings.custom_ipd = value; | |||||
| if ((U.hmd_settings.flag & USER_HMD_USE_DEVICE_IPD) == 0) { | |||||
| WM_device_HMD_IPD_set(value); | |||||
| } | |||||
| } | |||||
| #endif | |||||
| #ifdef WITH_INTERNATIONAL | #ifdef WITH_INTERNATIONAL | ||||
| static EnumPropertyItem *rna_lang_enum_properties_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), | static EnumPropertyItem *rna_lang_enum_properties_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), | ||||
| PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) | PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) | ||||
| { | { | ||||
| EnumPropertyItem *items = BLT_lang_RNA_enum_properties(); | EnumPropertyItem *items = BLT_lang_RNA_enum_properties(); | ||||
| if (items == NULL) { | if (items == NULL) { | ||||
| items = rna_enum_language_default_items; | items = rna_enum_language_default_items; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 3,622 Lines • ▼ Show 20 Lines | |||||
| #ifdef WITH_CYCLES | #ifdef WITH_CYCLES | ||||
| prop = RNA_def_property(srna, "legacy_compute_device_type", PROP_INT, PROP_NONE); | prop = RNA_def_property(srna, "legacy_compute_device_type", PROP_INT, PROP_NONE); | ||||
| RNA_def_property_int_sdna(prop, NULL, "compute_device_type"); | RNA_def_property_int_sdna(prop, NULL, "compute_device_type"); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_flag(prop, PROP_HIDDEN); | RNA_def_property_flag(prop, PROP_HIDDEN); | ||||
| RNA_def_property_ui_text(prop, "Legacy Compute Device Type", "For backwards compatibility only"); | RNA_def_property_ui_text(prop, "Legacy Compute Device Type", "For backwards compatibility only"); | ||||
| #endif | #endif | ||||
| #ifdef WITH_INPUT_HMD | |||||
| prop = RNA_def_property(srna, "hmd_device", PROP_ENUM, PROP_NONE); | |||||
| RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); | |||||
| RNA_def_property_enum_sdna(prop, NULL, "hmd_settings.device"); | |||||
| RNA_def_property_enum_items(prop, hmd_device_items); | |||||
| RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_userdef_hmd_device_itemf"); | |||||
| RNA_def_property_ui_text(prop, "HMD Device", "Device to use for HMD view interaction"); | |||||
| RNA_def_property_update(prop, 0, "rna_userdef_hmd_device_update"); | |||||
| prop = RNA_def_property(srna, "hmd_use_device_ipd", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "hmd_settings.flag", USER_HMD_USE_DEVICE_IPD); | |||||
| RNA_def_property_boolean_funcs(prop, NULL, "rna_userdef_hmd_use_device_ipd_set"); | |||||
| RNA_def_property_ui_text(prop, "IPD from HMD", "Request the interpupillary distance (distance between the " | |||||
| "eye pupil centers) from the HMD driver"); | |||||
| RNA_def_property_editable_func(prop, "rna_userdef_hmd_active_device_poll"); | |||||
| RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); | |||||
| prop = RNA_def_property(srna, "hmd_use_device_rotation", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "hmd_settings.flag", USER_HMD_USE_DEVICE_ROT); | |||||
| RNA_def_property_ui_text(prop, "Rotation from HMD", "Use the rotation of a head mounted display if available"); | |||||
| RNA_def_property_editable_func(prop, "rna_userdef_hmd_active_device_poll"); | |||||
| RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); | |||||
| prop = RNA_def_property(srna, "hmd_custom_ipd", PROP_FLOAT, PROP_DISTANCE); | |||||
| RNA_def_property_float_sdna(prop, NULL, "hmd_settings.custom_ipd"); | |||||
| RNA_def_property_float_funcs(prop, NULL, "rna_userdef_hmd_custom_ipd_set", NULL); | |||||
| RNA_def_property_range(prop, 0.0f, FLT_MAX); | |||||
| RNA_def_property_ui_range(prop, 0.0f, 1e4f, 1, 3); | |||||
| RNA_def_property_ui_text(prop, "Custom IPD", "Set the interpupillary distance (distance between the " | |||||
| "eye pupil centers)"); | |||||
| RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); | |||||
| #endif | |||||
| } | } | ||||
| static void rna_def_userdef_input(BlenderRNA *brna) | static void rna_def_userdef_input(BlenderRNA *brna) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| static EnumPropertyItem select_mouse_items[] = { | static EnumPropertyItem select_mouse_items[] = { | ||||
| ▲ Show 20 Lines • Show All 527 Lines • Show Last 20 Lines | |||||