Cleanup: remove unused USD plugin path registration
It is now in a location where USD automatically picks it up.
This commit is contained in:
parent
32bbfbb06e
commit
ff7dc64234
|
@ -72,7 +72,6 @@ set(SRC
|
|||
intern/usd_asset_utils.cc
|
||||
intern/usd_capi_export.cc
|
||||
intern/usd_capi_import.cc
|
||||
intern/usd_common.cc
|
||||
intern/usd_hierarchy_iterator.cc
|
||||
intern/usd_writer_abstract.cc
|
||||
intern/usd_writer_camera.cc
|
||||
|
@ -101,7 +100,6 @@ set(SRC
|
|||
usd.h
|
||||
|
||||
intern/usd_asset_utils.h
|
||||
intern/usd_common.h
|
||||
intern/usd_exporter_context.h
|
||||
intern/usd_hierarchy_iterator.h
|
||||
intern/usd_writer_abstract.h
|
||||
|
@ -161,8 +159,6 @@ if(WITH_GTESTS)
|
|||
tests/usd_curves_test.cc
|
||||
tests/usd_export_test.cc
|
||||
tests/usd_stage_creation_test.cc
|
||||
tests/usd_tests_common.cc
|
||||
tests/usd_tests_common.h
|
||||
tests/usd_usdz_export_test.cc
|
||||
intern/usd_writer_material.h
|
||||
)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "usd.h"
|
||||
#include "usd_common.h"
|
||||
#include "usd_hierarchy_iterator.h"
|
||||
|
||||
#include <pxr/base/plug/registry.h>
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "IO_types.h"
|
||||
#include "usd.h"
|
||||
#include "usd_common.h"
|
||||
#include "usd_hierarchy_iterator.h"
|
||||
#include "usd_reader_geom.h"
|
||||
#include "usd_reader_prim.h"
|
||||
|
@ -409,11 +408,6 @@ static void import_freejob(void *user_data)
|
|||
|
||||
using namespace blender::io::usd;
|
||||
|
||||
void USD_ensure_plugin_path_registered()
|
||||
{
|
||||
blender::io::usd::ensure_usd_plugin_path_registered();
|
||||
}
|
||||
|
||||
bool USD_import(struct bContext *C,
|
||||
const char *filepath,
|
||||
const USDImportParams *params,
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
/* SPDX-FileCopyrightText: 2021 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "usd_common.h"
|
||||
|
||||
#include <pxr/base/plug/registry.h>
|
||||
|
||||
#include "BKE_appdir.h"
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
void ensure_usd_plugin_path_registered()
|
||||
{
|
||||
/* If #PXR_PYTHON_SUPPORT_ENABLED is defined, we *must* be dynamic and
|
||||
* the plugins are placed relative to the USD shared library hence no
|
||||
* hinting is required. */
|
||||
#ifndef PXR_PYTHON_SUPPORT_ENABLED
|
||||
static bool plugin_path_registered = false;
|
||||
if (plugin_path_registered) {
|
||||
return;
|
||||
}
|
||||
plugin_path_registered = true;
|
||||
|
||||
/* Tell USD which directory to search for its JSON files. If 'datafiles/usd'
|
||||
* does not exist, the USD library will not be able to read or write any files. */
|
||||
const char *blender_usd_datafiles = BKE_appdir_folder_id(BLENDER_DATAFILES, "usd");
|
||||
if (blender_usd_datafiles) {
|
||||
const std::string blender_usd_data_folder = blender_usd_datafiles;
|
||||
/* The trailing slash indicates to the USD library that the path is a directory. */
|
||||
pxr::PlugRegistry::GetInstance().RegisterPlugins(blender_usd_data_folder + SEP_STR);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace blender::io::usd
|
|
@ -1,10 +0,0 @@
|
|||
/* SPDX-FileCopyrightText: 2021 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#pragma once
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
void ensure_usd_plugin_path_registered();
|
||||
|
||||
} // namespace blender::io::usd
|
|
@ -41,7 +41,6 @@
|
|||
#include "WM_api.h"
|
||||
|
||||
#include "usd.h"
|
||||
#include "usd_tests_common.h"
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
|
@ -86,10 +85,6 @@ class UsdCurvesTest : public BlendfileLoadingBaseTest {
|
|||
virtual void SetUp() override
|
||||
{
|
||||
BlendfileLoadingBaseTest::SetUp();
|
||||
std::string usd_plugin_path = register_usd_plugins_for_tests();
|
||||
if (usd_plugin_path.empty()) {
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void TearDown() override
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "WM_api.h"
|
||||
|
||||
#include "usd.h"
|
||||
#include "usd_tests_common.h"
|
||||
#include "usd_writer_material.h"
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
@ -73,10 +72,6 @@ class UsdExportTest : public BlendfileLoadingBaseTest {
|
|||
virtual void SetUp() override
|
||||
{
|
||||
BlendfileLoadingBaseTest::SetUp();
|
||||
std::string usd_plugin_path = register_usd_plugins_for_tests();
|
||||
if (usd_plugin_path.empty()) {
|
||||
FAIL() << "Unable to find the USD Plugins path.";
|
||||
}
|
||||
}
|
||||
|
||||
virtual void TearDown() override
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#include "testing/testing.h"
|
||||
|
||||
#include "usd_tests_common.h"
|
||||
|
||||
#include <pxr/usd/usd/stage.h>
|
||||
#include <pxr/usd/usdGeom/capsule.h>
|
||||
#include <pxr/usdImaging/usdImaging/capsuleAdapter.h>
|
||||
|
@ -21,13 +19,6 @@ TEST_F(USDImagingTest, CapsuleAdapterTest)
|
|||
* We create a capsule shape on an in-memory stage and attempt
|
||||
* to access the shape's points and topology. */
|
||||
|
||||
/* We must register USD plugin paths before creating the stage
|
||||
* to avoid a crash in the USD asset resolver initialization code. */
|
||||
if (register_usd_plugins_for_tests().empty()) {
|
||||
FAIL();
|
||||
return;
|
||||
}
|
||||
|
||||
pxr::UsdStageRefPtr stage = pxr::UsdStage::CreateInMemory();
|
||||
|
||||
if (!stage) {
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#include "testing/testing.h"
|
||||
|
||||
#include "usd_tests_common.h"
|
||||
|
||||
#include <pxr/base/plug/registry.h>
|
||||
#include <pxr/usd/usd/stage.h>
|
||||
|
||||
|
@ -22,12 +20,6 @@ class USDStageCreationTest : public testing::Test {
|
|||
|
||||
TEST_F(USDStageCreationTest, JSONFileLoadingTest)
|
||||
{
|
||||
std::string usd_datafiles_dir = register_usd_plugins_for_tests();
|
||||
if (usd_datafiles_dir.empty()) {
|
||||
FAIL();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Simply the ability to create a USD Stage for a specific filename means that the extension
|
||||
* has been recognized by the USD library, and that a USD plugin has been loaded to write such
|
||||
* files. Practically, this is a test to see whether the USD JSON files can be found and
|
||||
|
@ -41,8 +33,7 @@ TEST_F(USDStageCreationTest, JSONFileLoadingTest)
|
|||
unlink(filename.c_str());
|
||||
}
|
||||
else {
|
||||
FAIL() << "unable to find suitable USD plugin to write " << filename << "; looked in "
|
||||
<< usd_datafiles_dir;
|
||||
FAIL() << "unable to find suitable USD plugin to write " << filename;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
/* SPDX-FileCopyrightText: 2022 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "usd_tests_common.h"
|
||||
|
||||
#include "testing/testing.h"
|
||||
|
||||
#include <pxr/base/plug/registry.h>
|
||||
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_appdir.h"
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
std::string register_usd_plugins_for_tests()
|
||||
{
|
||||
static char usd_datafiles_dir[FILE_MAX] = {'\0'};
|
||||
static bool plugin_path_registered = false;
|
||||
if (plugin_path_registered) {
|
||||
return usd_datafiles_dir;
|
||||
}
|
||||
plugin_path_registered = true;
|
||||
|
||||
const std::string &release_dir = blender::tests::flags_test_release_dir();
|
||||
if (release_dir.empty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const size_t path_len = BLI_path_join(
|
||||
usd_datafiles_dir, FILE_MAX, release_dir.c_str(), "datafiles", "usd");
|
||||
|
||||
/* #BLI_path_join removes trailing slashes, but the USD library requires one in order to
|
||||
* recognize the path as directory. */
|
||||
BLI_assert(path_len + 1 < FILE_MAX);
|
||||
usd_datafiles_dir[path_len] = '/';
|
||||
usd_datafiles_dir[path_len + 1] = '\0';
|
||||
/* If #PXR_PYTHON_SUPPORT_ENABLED is defined, we *must* be dynamic and
|
||||
* the plugins are placed relative to the USD shared library hence no
|
||||
* hinting is required. */
|
||||
#ifndef PXR_PYTHON_SUPPORT_ENABLED
|
||||
pxr::PlugRegistry::GetInstance().RegisterPlugins(usd_datafiles_dir);
|
||||
#endif
|
||||
return usd_datafiles_dir;
|
||||
}
|
||||
|
||||
} // namespace blender::io::usd
|
|
@ -1,21 +0,0 @@
|
|||
/* SPDX-FileCopyrightText: 2022 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
/* Calls the function to load the USD plugins from the
|
||||
* USD data directory under the Blender bin directory
|
||||
* that was supplied as the --test-release-dir flag to `ctest`.
|
||||
* Thus function must be called before instantiating a USD
|
||||
* stage to avoid errors. The returned string is the path to
|
||||
* the USD data files directory from which the plugins were
|
||||
* loaded. If the USD data files directory can't be determined,
|
||||
* plugin registration is skipped and the empty string is
|
||||
* returned. */
|
||||
std::string register_usd_plugins_for_tests();
|
||||
|
||||
} // namespace blender::io::usd
|
|
@ -20,7 +20,6 @@
|
|||
#include "WM_api.h"
|
||||
|
||||
#include "usd.h"
|
||||
#include "usd_tests_common.h"
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
|
@ -52,10 +51,6 @@ class UsdUsdzExportTest : public BlendfileLoadingBaseTest {
|
|||
virtual void SetUp() override
|
||||
{
|
||||
BlendfileLoadingBaseTest::SetUp();
|
||||
std::string usd_plugin_path = register_usd_plugins_for_tests();
|
||||
if (usd_plugin_path.empty()) {
|
||||
FAIL();
|
||||
}
|
||||
|
||||
BKE_tempdir_init(nullptr);
|
||||
const char *temp_base_dir = BKE_tempdir_base();
|
||||
|
|
|
@ -149,7 +149,6 @@ struct CacheReader *CacheReader_open_usd_object(struct CacheArchiveHandle *handl
|
|||
|
||||
void USD_CacheReader_incref(struct CacheReader *reader);
|
||||
void USD_CacheReader_free(struct CacheReader *reader);
|
||||
void USD_ensure_plugin_path_registered(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -96,10 +96,6 @@
|
|||
# include "sdlew.h"
|
||||
#endif
|
||||
|
||||
#ifdef WITH_USD
|
||||
# include "usd.h"
|
||||
#endif
|
||||
|
||||
#include "creator_intern.h" /* Own include. */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
@ -476,10 +472,6 @@ int main(int argc,
|
|||
/* Initialize sub-systems that use `BKE_appdir.h`. */
|
||||
IMB_init();
|
||||
|
||||
#ifdef WITH_USD
|
||||
USD_ensure_plugin_path_registered();
|
||||
#endif
|
||||
|
||||
#ifndef WITH_PYTHON_MODULE
|
||||
/* First test for background-mode (#Global.background) */
|
||||
BLI_args_parse(ba, ARG_PASS_SETTINGS, NULL, NULL);
|
||||
|
|
Loading…
Reference in New Issue