diff options
Diffstat (limited to 'source/creator')
-rw-r--r-- | source/creator/CMakeLists.txt | 13 | ||||
-rw-r--r-- | source/creator/creator.c | 21 |
2 files changed, 34 insertions, 0 deletions
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 96ceac5c4d4..a7a816385ad 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -1045,6 +1045,19 @@ unset(LIB) setup_liblinks(blender) +# ----------------------------------------------------------------------------- +# USD registry. +# USD requires a set of JSON files that define the standard schemas. These +# files are required at runtime. +if (WITH_USD) + add_definitions(-DWITH_USD) + install(DIRECTORY + ${LIBDIR}/usd/lib/usd + DESTINATION "${TARGETDIR_VER}/datafiles" + ) +endif() + + # vcpkg substitutes our libs with theirs, which will cause issues when you # you run these builds on other systems due to missing dlls. So we opt out # the use of vcpkg diff --git a/source/creator/creator.c b/source/creator/creator.c index f4f5e3dcbde..32377da5284 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -112,6 +112,20 @@ int main_python_enter(int argc, const char **argv); void main_python_exit(void); #endif +#ifdef WITH_USD +/* Workaround to make it possible to pass a path at runtime to USD. + * + * USD requires some JSON files, and it uses a static constructor to determine the possible + * filesystem paths to find those files. This made it impossible for Blender to pass a path to the + * USD library at runtime, as the constructor would run before Blender's main() function. We have + * patched USD (see usd.diff) to avoid that particular static constructor, and have an + * initialisation function instead. + * + * This function is implemented in the USD source code, pxr/base/lib/plug/initConfig.cpp. + */ +void usd_initialise_plugin_path(const char *datafiles_usd_path); +#endif + /* written to by 'creator_args.c' */ struct ApplicationState app_state = { .signal = @@ -411,6 +425,13 @@ int main(int argc, init_def_material(); +#ifdef WITH_USD + /* 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. + */ + usd_initialise_plugin_path(BKE_appdir_folder_id(BLENDER_DATAFILES, "usd")); +#endif + if (G.background == 0) { #ifndef WITH_PYTHON_MODULE BLI_argsParse(ba, 2, NULL, NULL); |