diff --git a/cmake/defaults/Options.cmake b/cmake/defaults/Options.cmake index de86bb56eb..d7821cf808 100644 --- a/cmake/defaults/Options.cmake +++ b/cmake/defaults/Options.cmake @@ -29,6 +29,7 @@ option(PXR_BUILD_USD_IMAGING "Build USD imaging components" ON) option(PXR_BUILD_KATANA_PLUGIN "Build usd katana plugin" OFF) option(PXR_BUILD_MAYA_PLUGIN "Build usd maya plugin" OFF) option(PXR_BUILD_ALEMBIC_PLUGIN "Build the Alembic plugin for USD" OFF) +option(PXR_ENABLE_MULTIVERSE_SUPPORT "Enable Multiverse backend in the Alembic plugin for USD" OFF) option(PXR_MAYA_TBB_BUG_WORKAROUND "Turn on linker flag (-Wl,-Bsymbolic) to work around a Maya TBB bug" OFF) set(PXR_INSTALL_LOCATION "" diff --git a/cmake/defaults/Packages.cmake b/cmake/defaults/Packages.cmake index bfa01e5d56..044d582688 100644 --- a/cmake/defaults/Packages.cmake +++ b/cmake/defaults/Packages.cmake @@ -125,4 +125,13 @@ if (PXR_BUILD_ALEMBIC_PLUGIN) HL REQUIRED ) + if (PXR_ENABLE_MULTIVERSE_SUPPORT) + find_package(Boost + COMPONENTS + filesystem + REQUIRED + ) + find_library(GIT2_LIB git2) + endif() + endif() diff --git a/cmake/modules/FindAlembic.cmake b/cmake/modules/FindAlembic.cmake index db48e74b07..83aa58045c 100644 --- a/cmake/modules/FindAlembic.cmake +++ b/cmake/modules/FindAlembic.cmake @@ -75,6 +75,15 @@ if(NOT ALEMBIC_LIBRARY) PATHS ${LIBRARY_PATHS} ) + if (PXR_ENABLE_MULTIVERSE_SUPPORT) + find_library(ALEMBIC_ABCCOREGIT_LIBRARY + NAMES AlembicAbcCoreGit + PATHS ${LIBRARY_PATHS} + ) + else() + set(ALEMBIC_ABCCOREGIT_LIBRARY "") + endif() + find_library(ALEMBIC_ABCCOREHDF5_LIBRARY NAMES AlembicAbcCoreHDF5 PATHS ${LIBRARY_PATHS} @@ -105,6 +114,7 @@ if(NOT ALEMBIC_LIBRARY) ${ALEMBIC_ABC_LIBRARY} ${ALEMBIC_ABCCOREHDF5_LIBRARY} ${ALEMBIC_ABCCOREOGAWA_LIBRARY} + ${ALEMBIC_ABCCOREGIT_LIBRARY} ${ALEMBIC_ABCCOREABSTRACT_LIBRARY} ${ALEMBIC_UTIL_LIBRARY} ${ALEMBIC_OGAWA_LIBRARY} diff --git a/pxr/usd/plugin/usdAbc/CMakeLists.txt b/pxr/usd/plugin/usdAbc/CMakeLists.txt index 90ad70bd43..bd6cb56728 100644 --- a/pxr/usd/plugin/usdAbc/CMakeLists.txt +++ b/pxr/usd/plugin/usdAbc/CMakeLists.txt @@ -6,6 +6,14 @@ if(NOT ALEMBIC_FOUND) return() endif() +set(MULTIVERSE_DEPS "") +if (PXR_ENABLE_MULTIVERSE_SUPPORT) + list(APPEND MULTIVERSE_DEPS ${GIT2_LIB}) + list(APPEND MULTIVERSE_DEPS ${Boost_FILESYSTEM_LIBRARY}) + list(APPEND MULTIVERSE_DEPS ${Boost_SYSTEM_LIBRARY}) + add_definitions(-DUSDABC_MULTIVERSE_SUPPORT) +endif() + pxr_plugin(usdAbc LIBRARIES tf @@ -16,6 +24,7 @@ pxr_plugin(usdAbc ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} ${OPENEXR_Iex_LIBRARY} + ${MULTIVERSE_DEPS} INCLUDE_DIRS ${ALEMBIC_INCLUDE_DIR} diff --git a/pxr/usd/plugin/usdAbc/alembicReader.cpp b/pxr/usd/plugin/usdAbc/alembicReader.cpp index ffb06df6c5..dd38824282 100644 --- a/pxr/usd/plugin/usdAbc/alembicReader.cpp +++ b/pxr/usd/plugin/usdAbc/alembicReader.cpp @@ -42,6 +42,11 @@ #include #include #include + +#ifdef USDABC_MULTIVERSE_SUPPORT +#include +#endif // #ifdef USDABC_MULTIVERSE_SUPPORT + #include #include #include @@ -740,6 +745,11 @@ class _ReaderContext { bool _OpenOgawa(const std::string& filePath, IArchive*, std::string* format, std::recursive_mutex** mutex) const; +#ifdef USDABC_MULTIVERSE_SUPPORT + bool _OpenGit(const std::string& filePath, IArchive*, + std::string* format, std::recursive_mutex** mutex) const; +#endif // #ifdef USDABC_MULTIVERSE_SUPPORT + // Walk the object hierarchy looking for instances and instance sources. static void _FindInstances(const IObject& parent, _SourceToInstancesMap* instances); @@ -844,11 +854,20 @@ _ReaderContext::Open(const std::string& filePath, std::string* errorLog) IArchive archive; std::string format; - if (!(_OpenOgawa(filePath, &archive, &format, &_mutex) || +#ifdef USDABC_MULTIVERSE_SUPPORT + if (not (_OpenOgawa(filePath, &archive, &format, &_mutex) || + _OpenHDF5(filePath, &archive, &format, &_mutex) || + _OpenGit(filePath, &archive, &format, &_mutex))) { + *errorLog = "Unsupported format"; + return false; + } +#else + if (not (_OpenOgawa(filePath, &archive, &format, &_mutex) || _OpenHDF5(filePath, &archive, &format, &_mutex))) { *errorLog = "Unsupported format"; return false; } +#endif // #ifdef USDABC_MULTIVERSE_SUPPORT // Lock _mutex if it exists for remainder of this method. _Lock lock(_mutex); @@ -1316,6 +1335,21 @@ _ReaderContext::_OpenOgawa( return *result; } +#ifdef USDABC_MULTIVERSE_SUPPORT +bool +_ReaderContext::_OpenGit( + const std::string& filePath, + IArchive* result, + std::string* format, + std::recursive_mutex** mutex) const +{ + *format = "Git"; + *result = IArchive(Alembic::AbcCoreGit::ReadArchive(), + filePath, ErrorHandler::kQuietNoopPolicy); + return *result; +} +#endif // #ifdef USDABC_MULTIVERSE_SUPPORT + void _ReaderContext::_FindInstances( const IObject& parent,