diff options
author | Jacques Lucke <jacques@blender.org> | 2022-09-08 13:55:44 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-09-08 13:55:44 +0300 |
commit | 90edc4472e3300f44bea8888ac299b0193eb39a9 (patch) | |
tree | 291a7d433da30cc6f7b43dc3d69bb933947898be | |
parent | 3f9f9f03483ea244eeb277c3adde0b71053b3865 (diff) | |
parent | d481fb10efb9f20094330766b562a77c643a15b0 (diff) |
Merge branch 'master' into temp-geometry-nodes-evaluator-refactor
-rw-r--r-- | source/blender/blenkernel/BKE_appdir.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/appdir.c | 22 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node_runtime.cc | 1 | ||||
-rw-r--r-- | source/blender/editors/io/io_gpencil_export.c | 4 | ||||
-rw-r--r-- | source/blender/editors/io/io_obj.c | 91 | ||||
-rw-r--r-- | source/blender/editors/io/io_stl_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/io/io_usd.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_console/space_console.c | 3 | ||||
-rw-r--r-- | source/blender/io/wavefront_obj/IO_wavefront_obj.h | 2 | ||||
-rw-r--r-- | source/creator/creator.c | 26 |
10 files changed, 108 insertions, 50 deletions
diff --git a/source/blender/blenkernel/BKE_appdir.h b/source/blender/blenkernel/BKE_appdir.h index dcacc2ca7b3..16488bdbf09 100644 --- a/source/blender/blenkernel/BKE_appdir.h +++ b/source/blender/blenkernel/BKE_appdir.h @@ -105,8 +105,11 @@ void BKE_appdir_app_templates(struct ListBase *templates); /** * Initialize path to program executable. + * + * \param strict: When true, use `argv0` unmodified (besides making absolute & normalizing). + * Otherwise other methods may be used to find the program path, including searching `$PATH`. */ -void BKE_appdir_program_path_init(const char *argv0); +void BKE_appdir_program_path_init(const char *argv0, bool strict); /** * Path to executable diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c index 031d3647878..c19afdb4fb8 100644 --- a/source/blender/blenkernel/intern/appdir.c +++ b/source/blender/blenkernel/intern/appdir.c @@ -794,11 +794,11 @@ const char *BKE_appdir_folder_id_version(const int folder_id, * (must be #FILE_MAX minimum) * \param name: The name of the executable (usually `argv[0]`) to be checked */ -static void where_am_i(char *fullname, const size_t maxlen, const char *name) +static void where_am_i(char *fullname, const size_t maxlen, const char *name, const bool strict) { #ifdef WITH_BINRELOC /* Linux uses `binreloc` since `argv[0]` is not reliable, call `br_init(NULL)` first. */ - { + if (!strict) { const char *path = NULL; path = br_find_exe(NULL); if (path) { @@ -810,7 +810,7 @@ static void where_am_i(char *fullname, const size_t maxlen, const char *name) #endif #ifdef _WIN32 - { + if (!strict) { wchar_t *fullname_16 = MEM_mallocN(maxlen * sizeof(wchar_t), "ProgramPath"); if (GetModuleFileNameW(0, fullname_16, maxlen)) { conv_utf_16_to_8(fullname_16, fullname, maxlen); @@ -834,18 +834,24 @@ static void where_am_i(char *fullname, const size_t maxlen, const char *name) if (name[0] == '.') { BLI_path_abs_from_cwd(fullname, maxlen); #ifdef _WIN32 - BLI_path_program_extensions_add_win32(fullname, maxlen); + if (!strict) { + BLI_path_program_extensions_add_win32(fullname, maxlen); + } #endif } else if (BLI_path_slash_rfind(name)) { /* Full path. */ BLI_strncpy(fullname, name, maxlen); #ifdef _WIN32 - BLI_path_program_extensions_add_win32(fullname, maxlen); + if (!strict) { + BLI_path_program_extensions_add_win32(fullname, maxlen); + } #endif } else { - BLI_path_program_search(fullname, maxlen, name); + if (!strict) { + BLI_path_program_search(fullname, maxlen, name); + } } /* Remove "/./" and "/../" so string comparisons can be used on the path. */ BLI_path_normalize(NULL, fullname); @@ -858,9 +864,9 @@ static void where_am_i(char *fullname, const size_t maxlen, const char *name) } } -void BKE_appdir_program_path_init(const char *argv0) +void BKE_appdir_program_path_init(const char *argv0, const bool strict) { - where_am_i(g_app.program_filepath, sizeof(g_app.program_filepath), argv0); + where_am_i(g_app.program_filepath, sizeof(g_app.program_filepath), argv0, strict); BLI_split_dir_part(g_app.program_filepath, g_app.program_dirname, sizeof(g_app.program_dirname)); } diff --git a/source/blender/blenkernel/intern/node_runtime.cc b/source/blender/blenkernel/intern/node_runtime.cc index 9938091d267..fd3627cdc16 100644 --- a/source/blender/blenkernel/intern/node_runtime.cc +++ b/source/blender/blenkernel/intern/node_runtime.cc @@ -272,6 +272,7 @@ static void toposort_from_start_node(const ToposortDirection direction, Stack<Item, 64> nodes_to_check; nodes_to_check.push({&start_node}); + node_states[start_node.runtime->index_in_tree].is_in_stack = true; while (!nodes_to_check.is_empty()) { Item &item = nodes_to_check.peek(); bNode &node = *item.node; diff --git a/source/blender/editors/io/io_gpencil_export.c b/source/blender/editors/io/io_gpencil_export.c index 12d87113a66..662a372b608 100644 --- a/source/blender/editors/io/io_gpencil_export.c +++ b/source/blender/editors/io/io_gpencil_export.c @@ -217,7 +217,7 @@ void WM_OT_gpencil_export_svg(wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); gpencil_export_common_props_definition(ot); @@ -375,7 +375,7 @@ void WM_OT_gpencil_export_pdf(wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); static const EnumPropertyItem gpencil_export_frame_items[] = { {GP_EXPORT_FRAME_ACTIVE, "ACTIVE", 0, "Active", "Include only active frame"}, diff --git a/source/blender/editors/io/io_obj.c b/source/blender/editors/io/io_obj.c index 0c935a0e1da..66e95c019f6 100644 --- a/source/blender/editors/io/io_obj.c +++ b/source/blender/editors/io/io_obj.c @@ -114,28 +114,24 @@ static void ui_obj_export_settings(uiLayout *layout, PointerRNA *imfptr) uiLayoutSetPropSep(layout, true); uiLayoutSetPropDecorate(layout, false); - /* Animation options. */ - uiLayout *box = uiLayoutBox(layout); - uiItemL(box, IFACE_("Animation"), ICON_ANIM); - uiLayout *col = uiLayoutColumn(box, false); - uiLayout *sub = uiLayoutColumn(col, false); - uiItemR(sub, imfptr, "export_animation", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(sub, true); - uiItemR(sub, imfptr, "start_frame", 0, IFACE_("Frame Start"), ICON_NONE); - uiItemR(sub, imfptr, "end_frame", 0, IFACE_("End"), ICON_NONE); - uiLayoutSetEnabled(sub, export_animation); + uiLayout *box, *col, *sub, *row; /* Object Transform options. */ box = uiLayoutBox(layout); uiItemL(box, IFACE_("Object Properties"), ICON_OBJECT_DATA); col = uiLayoutColumn(box, false); - sub = uiLayoutColumn(col, false); - uiItemR(sub, imfptr, "forward_axis", 0, IFACE_("Axis Forward"), ICON_NONE); - uiItemR(sub, imfptr, "up_axis", 0, IFACE_("Up"), ICON_NONE); - sub = uiLayoutColumn(col, false); + sub = uiLayoutColumnWithHeading(col, false, IFACE_("Limit to")); + uiItemR(sub, imfptr, "export_selected_objects", 0, IFACE_("Selected Only"), ICON_NONE); uiItemR(sub, imfptr, "scaling_factor", 0, NULL, ICON_NONE); + + row = uiLayoutRow(box, false); + uiItemR(row, imfptr, "forward_axis", UI_ITEM_R_EXPAND, IFACE_("Foward Axis"), ICON_NONE); + row = uiLayoutRow(box, false); + uiItemR(row, imfptr, "up_axis", UI_ITEM_R_EXPAND, IFACE_("Up Axis"), ICON_NONE); + + col = uiLayoutColumn(box, false); + sub = uiLayoutColumn(col, false); sub = uiLayoutColumnWithHeading(col, false, IFACE_("Objects")); - uiItemR(sub, imfptr, "export_selected_objects", 0, IFACE_("Selected Only"), ICON_NONE); uiItemR(sub, imfptr, "apply_modifiers", 0, IFACE_("Apply Modifiers"), ICON_NONE); uiItemR(sub, imfptr, "export_eval_mode", 0, IFACE_("Properties"), ICON_NONE); sub = uiLayoutColumn(sub, false); @@ -144,7 +140,7 @@ static void ui_obj_export_settings(uiLayout *layout, PointerRNA *imfptr) /* Options for what to write. */ box = uiLayoutBox(layout); - uiItemL(box, IFACE_("Geometry Export"), ICON_EXPORT); + uiItemL(box, IFACE_("Geometry"), ICON_EXPORT); col = uiLayoutColumn(box, false); sub = uiLayoutColumnWithHeading(col, false, IFACE_("Export")); uiItemR(sub, imfptr, "export_uv", 0, IFACE_("UV Coordinates"), ICON_NONE); @@ -166,6 +162,17 @@ static void ui_obj_export_settings(uiLayout *layout, PointerRNA *imfptr) sub = uiLayoutColumn(sub, false); uiLayoutSetEnabled(sub, export_smooth_groups); uiItemR(sub, imfptr, "smooth_group_bitflags", 0, IFACE_("Smooth Group Bitflags"), ICON_NONE); + + /* Animation options. */ + box = uiLayoutBox(layout); + uiItemL(box, IFACE_("Animation"), ICON_ANIM); + col = uiLayoutColumn(box, false); + sub = uiLayoutColumn(col, false); + uiItemR(sub, imfptr, "export_animation", 0, NULL, ICON_NONE); + sub = uiLayoutColumn(sub, true); + uiItemR(sub, imfptr, "start_frame", 0, IFACE_("Frame Start"), ICON_NONE); + uiItemR(sub, imfptr, "end_frame", 0, IFACE_("End"), ICON_NONE); + uiLayoutSetEnabled(sub, export_animation); } static void wm_obj_export_draw(bContext *UNUSED(C), wmOperator *op) @@ -211,15 +218,30 @@ static bool wm_obj_export_check(bContext *C, wmOperator *op) RNA_int_set(op->ptr, "start_frame", start); RNA_int_set(op->ptr, "end_frame", end); } + return changed; +} - /* Both forward and up axes cannot be the same (or same except opposite sign). */ - if (RNA_enum_get(op->ptr, "forward_axis") % TOTAL_AXES == - (RNA_enum_get(op->ptr, "up_axis") % TOTAL_AXES)) { - /* TODO(@ankitm): Show a warning here. */ - RNA_enum_set(op->ptr, "up_axis", RNA_enum_get(op->ptr, "up_axis") % TOTAL_AXES + 1); - changed = true; +/* Both forward and up axes cannot be along the same direction. */ +static void forward_axis_update(struct Main *UNUSED(main), + struct Scene *UNUSED(scene), + struct PointerRNA *ptr) +{ + int forward = RNA_enum_get(ptr, "forward_axis"); + int up = RNA_enum_get(ptr, "up_axis"); + if ((forward % 3) == (up % 3)) { + RNA_enum_set(ptr, "up_axis", (up + 1) % 6); + } +} + +static void up_axis_update(struct Main *UNUSED(main), + struct Scene *UNUSED(scene), + struct PointerRNA *ptr) +{ + int forward = RNA_enum_get(ptr, "forward_axis"); + int up = RNA_enum_get(ptr, "up_axis"); + if ((forward % 3) == (up % 3)) { + RNA_enum_set(ptr, "forward_axis", (forward + 1) % 6); } - return changed; } void WM_OT_obj_export(struct wmOperatorType *ot) @@ -244,7 +266,7 @@ void WM_OT_obj_export(struct wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); /* Animation options. */ RNA_def_boolean(ot->srna, @@ -271,9 +293,11 @@ void WM_OT_obj_export(struct wmOperatorType *ot) INT_MIN, INT_MAX); /* Object transform options. */ - RNA_def_enum( + prop = RNA_def_enum( ot->srna, "forward_axis", io_transform_axis, IO_AXIS_NEGATIVE_Z, "Forward Axis", ""); - RNA_def_enum(ot->srna, "up_axis", io_transform_axis, IO_AXIS_Y, "Up Axis", ""); + RNA_def_property_update_runtime(prop, (void *)forward_axis_update); + prop = RNA_def_enum(ot->srna, "up_axis", io_transform_axis, IO_AXIS_Y, "Up Axis", ""); + RNA_def_property_update_runtime(prop, (void *)up_axis_update); RNA_def_float(ot->srna, "scaling_factor", 1.0f, @@ -428,8 +452,11 @@ static void ui_obj_import_settings(uiLayout *layout, PointerRNA *imfptr) uiLayout *sub = uiLayoutColumn(col, false); uiItemR(sub, imfptr, "clamp_size", 0, NULL, ICON_NONE); sub = uiLayoutColumn(col, false); - uiItemR(sub, imfptr, "forward_axis", 0, IFACE_("Axis Forward"), ICON_NONE); - uiItemR(sub, imfptr, "up_axis", 0, IFACE_("Up"), ICON_NONE); + + uiLayout *row = uiLayoutRow(box, false); + uiItemR(row, imfptr, "forward_axis", UI_ITEM_R_EXPAND, IFACE_("Forward Axis"), ICON_NONE); + row = uiLayoutRow(box, false); + uiItemR(row, imfptr, "up_axis", UI_ITEM_R_EXPAND, IFACE_("Up Axis"), ICON_NONE); box = uiLayoutBox(layout); uiItemL(box, IFACE_("Options"), ICON_EXPORT); @@ -467,7 +494,7 @@ void WM_OT_obj_import(struct wmOperatorType *ot) WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS | WM_FILESEL_DIRECTORY | WM_FILESEL_FILES, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_float( ot->srna, "clamp_size", @@ -478,9 +505,11 @@ void WM_OT_obj_import(struct wmOperatorType *ot) "Resize the objects to keep bounding box under this value. Value 0 disables clamping", 0.0f, 1000.0f); - RNA_def_enum( + prop = RNA_def_enum( ot->srna, "forward_axis", io_transform_axis, IO_AXIS_NEGATIVE_Z, "Forward Axis", ""); - RNA_def_enum(ot->srna, "up_axis", io_transform_axis, IO_AXIS_Y, "Up Axis", ""); + RNA_def_property_update_runtime(prop, (void *)forward_axis_update); + prop = RNA_def_enum(ot->srna, "up_axis", io_transform_axis, IO_AXIS_Y, "Up Axis", ""); + RNA_def_property_update_runtime(prop, (void *)up_axis_update); RNA_def_boolean(ot->srna, "import_vertex_groups", false, diff --git a/source/blender/editors/io/io_stl_ops.c b/source/blender/editors/io/io_stl_ops.c index 858ea131577..c98e5beaf3b 100644 --- a/source/blender/editors/io/io_stl_ops.c +++ b/source/blender/editors/io/io_stl_ops.c @@ -104,7 +104,7 @@ void WM_OT_stl_import(struct wmOperatorType *ot) WM_FILESEL_FILEPATH | WM_FILESEL_FILES | WM_FILESEL_DIRECTORY | WM_FILESEL_SHOW_PROPS, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_float(ot->srna, "global_scale", 1.0f, 1e-6f, 1e6f, "Scale", "", 0.001f, 1000.0f); RNA_def_boolean(ot->srna, diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c index 74ce0cca16c..ba118a5e289 100644 --- a/source/blender/editors/io/io_usd.c +++ b/source/blender/editors/io/io_usd.c @@ -487,7 +487,7 @@ void WM_OT_usd_import(struct wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_SHOW_PROPS, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_float( ot->srna, diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 417c65eb01a..a7ab6bc5169 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -121,6 +121,9 @@ static void console_main_region_init(wmWindowManager *wm, ARegion *region) region->v2d.cur.ymax = prev_y_min + cur_y_range; } + keymap = WM_keymap_ensure(wm->defaultconf, "View2D Buttons List", 0, 0); + WM_event_add_keymap_handler(®ion->handlers, keymap); + /* own keymap */ keymap = WM_keymap_ensure(wm->defaultconf, "Console", SPACE_CONSOLE, 0); WM_event_add_keymap_handler_v2d_mask(®ion->handlers, keymap); diff --git a/source/blender/io/wavefront_obj/IO_wavefront_obj.h b/source/blender/io/wavefront_obj/IO_wavefront_obj.h index 847b02d3fd1..544630c9cc0 100644 --- a/source/blender/io/wavefront_obj/IO_wavefront_obj.h +++ b/source/blender/io/wavefront_obj/IO_wavefront_obj.h @@ -16,8 +16,6 @@ extern "C" { #endif -static const int TOTAL_AXES = 3; - struct OBJExportParams { /** Full path to the destination .OBJ file. */ char filepath[FILE_MAX]; diff --git a/source/creator/creator.c b/source/creator/creator.c index e7a803d383f..e7e9eeed79a 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -233,6 +233,12 @@ void gmp_blender_init_allocator() /** \name Main Function * \{ */ +/* When building as a Python module, don't use special argument handling + * so the module loading logic can control the `argv` & `argc`. */ +#if defined(WIN32) && !defined(WITH_PYTHON_MODULE) +# define USE_WIN32_UNICODE_ARGS +#endif + /** * Blender's main function responsibilities are: * - setup subsystems. @@ -241,7 +247,7 @@ void gmp_blender_init_allocator() * or exit immediately when running in background-mode. */ int main(int argc, -#ifdef WIN32 +#ifdef USE_WIN32_UNICODE_ARGS const char **UNUSED(argv_c) #else const char **argv @@ -254,7 +260,7 @@ int main(int argc, bArgs *ba; #endif -#ifdef WIN32 +#ifdef USE_WIN32_UNICODE_ARGS char **argv; int argv_num; #endif @@ -284,6 +290,7 @@ int main(int argc, /* NOTE: cannot use `guardedalloc` allocation here, as it's not yet initialized * (it depends on the arguments passed in, which is what we're getting here!) */ +# ifdef USE_WIN32_UNICODE_ARGS { wchar_t **argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc); argv = malloc(argc * sizeof(char *)); @@ -296,7 +303,8 @@ int main(int argc, app_init_data.argv = argv; app_init_data.argv_num = argv_num; } -#endif /* WIN32 */ +# endif /* USE_WIN32_UNICODE_ARGS */ +#endif /* WIN32 */ /* NOTE: Special exception for guarded allocator type switch: * we need to perform switch from lock-free to fully @@ -388,7 +396,17 @@ int main(int argc, #endif /* Initialize path to executable. */ - BKE_appdir_program_path_init(argv[0]); + { +#ifdef WITH_PYTHON_MODULE + /* NOTE(@campbellbarton): Always use `argv[0]` as is, when building as a Python module. + * Otherwise other methods of detecting the binary that override this argument + * which must point to the Python module for data-files to be detected. */ + const bool strict = true; +#else + const bool strict = false; +#endif + BKE_appdir_program_path_init(argv[0], strict); + } BLI_threadapi_init(); |