From 3bcbbf8992b0f41f19bef466129ce5b88984ac2b Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Thu, 3 Feb 2022 09:30:55 -0500 Subject: Split Python OBJ importer and exporter, enabling only the importer. This is from patch D13988. It removes the "- New" from the menu of the new obj exporter, changes the default addon to just io_import_obj, and does the right versioning thing. Also disables the python tests for the old python exporter. --- release/scripts/startup/bl_ui/space_topbar.py | 2 +- source/blender/blenkernel/intern/blendfile.c | 2 +- source/blender/blenloader/intern/versioning_userdef.c | 7 +++++++ tests/python/CMakeLists.txt | 5 +++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index 99abc60db6f..513c1c2ae2e 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -481,7 +481,7 @@ class TOPBAR_MT_file_export(Menu): bl_owner_use_filter = False def draw(self, _context): - self.layout.operator("wm.obj_export", text="Wavefront OBJ (.obj) - New") + self.layout.operator("wm.obj_export", text="Wavefront OBJ (.obj)") if bpy.app.build_options.collada: self.layout.operator("wm.collada_export", text="Collada (Default) (.dae)") diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 6ae19c8036f..53c9fe49fb7 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -603,12 +603,12 @@ UserDef *BKE_blendfile_userdef_from_defaults(void) const char *addons[] = { "io_anim_bvh", "io_curve_svg", + "io_import_obj", "io_mesh_ply", "io_mesh_stl", "io_mesh_uv_layout", "io_scene_fbx", "io_scene_gltf2", - "io_scene_obj", "io_scene_x3d", "cycles", "pose_library", diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index 064d7977c68..520059649e6 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -973,6 +973,13 @@ void blo_do_versions_userdef(UserDef *userdef) */ { /* Keep this block, even when empty. */ + if (!USER_VERSION_ATLEAST(301, 7)) { + /* io_scene_obj directory is gone, split into io_import_obj and io_export_obj, + * with io_import_obj enabled by default and io_export_obj replaced by the C++ version. + */ + BKE_addon_remove_safe(&userdef->addons, "io_scene_obj"); + BKE_addon_ensure(&userdef->addons, "io_import_obj"); + } } LISTBASE_FOREACH (bTheme *, btheme, &userdef->themes) { diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt index d6575436bd6..63dcdc0f925 100644 --- a/tests/python/CMakeLists.txt +++ b/tests/python/CMakeLists.txt @@ -324,7 +324,10 @@ add_blender_test( ) endif() +if(FALSE) # OBJ Export tests +# Disabled because new C++ Obj exporter has C++ tests. + add_blender_test( export_obj_cube ${TEST_SRC_DIR}/io_tests/blend_geometry/all_quads.blend @@ -345,8 +348,6 @@ add_blender_test( --md5=a733ae4fa4a591ea9b0912da3af042de --md5_method=FILE ) -# disabled until updated & working -if(FALSE) add_blender_test( export_obj_all_objects ${TEST_SRC_DIR}/io_tests/blend_scene/all_objects.blend -- cgit v1.2.3 From 946c70e6a7892985289bf8dfaead8512d33eba79 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 3 Feb 2022 15:34:56 +0100 Subject: Fix (unreported) broken do_version of hidden layers from pre-2.8 files. `BKE_collection_object_add` ensures given object is added to an editable collection, and not e.g. a linked or override one. However, some processes like do_version manipulate collections also from libraries, i.e. linked collections, in those cases we need a version of the code that unconditionnally adds the given object to the given colleciton. --- source/blender/blenkernel/BKE_collection.h | 11 ++++++++++- source/blender/blenkernel/intern/collection.c | 17 +++++++++++++---- source/blender/blenloader/intern/versioning_280.c | 6 +++--- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h index 402bffea91d..bce15349880 100644 --- a/source/blender/blenkernel/BKE_collection.h +++ b/source/blender/blenkernel/BKE_collection.h @@ -123,11 +123,20 @@ struct Collection *BKE_collection_object_find(struct Main *bmain, bool BKE_collection_is_empty(const struct Collection *collection); /** - * Add object to collection + * Add object to given collection, ensuring this collection is 'editable' (i.e. local and not a + * liboverride), and finding a suitable parent one otherwise. */ bool BKE_collection_object_add(struct Main *bmain, struct Collection *collection, struct Object *ob); +/** + * Same as #BKE_collection_object_add, but uncondionnaly adds the object to the given collection. + * + * NOTE: required in certain cases, like do-versionning or complex ID management tasks. + */ +bool BKE_collection_object_add_notest(struct Main *bmain, + struct Collection *collection, + struct Object *ob); /** * Add \a ob_dst to all scene collections that reference object \a ob_src is in. * Used for copying objects. diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index e6ce4eb9440..79f40c1c888 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -1094,14 +1094,12 @@ static bool collection_object_remove(Main *bmain, return true; } -bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob) +bool BKE_collection_object_add_notest(Main *bmain, Collection *collection, Object *ob) { - if (ELEM(NULL, collection, ob)) { + if (ob == NULL) { return false; } - collection = collection_parent_editable_find_recursive(collection); - /* Only case where this pointer can be NULL is when scene itself is linked, this case should * never be reached. */ BLI_assert(collection != NULL); @@ -1122,6 +1120,17 @@ bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob) return true; } +bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob) +{ + if (collection == NULL) { + return false; + } + + collection = collection_parent_editable_find_recursive(collection); + + return BKE_collection_object_add_notest(bmain, collection, ob); +} + void BKE_collection_object_add_from(Main *bmain, Scene *scene, Object *ob_src, Object *ob_dst) { bool is_instantiated = false; diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index ceddc451a46..57105ca5884 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -349,7 +349,7 @@ static void do_version_scene_collection_convert( LISTBASE_FOREACH (LinkData *, link, &sc->objects) { Object *ob = link->data; if (ob) { - BKE_collection_object_add(bmain, collection, ob); + BKE_collection_object_add_notest(bmain, collection, ob); id_us_min(&ob->id); } } @@ -459,7 +459,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) /* Note usually this would do slow collection syncing for view layers, * but since no view layers exists yet at this point it's fast. */ - BKE_collection_object_add(bmain, collections[layer], base->object); + BKE_collection_object_add_notest(bmain, collections[layer], base->object); } if (base->flag & SELECT) { @@ -1235,7 +1235,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) (*collection_hidden)->flag |= COLLECTION_HIDE_VIEWPORT | COLLECTION_HIDE_RENDER; } - BKE_collection_object_add(bmain, *collection_hidden, ob); + BKE_collection_object_add_notest(bmain, *collection_hidden, ob); BKE_collection_object_remove(bmain, collection, ob, true); } } -- cgit v1.2.3