Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAYA-128473 - Move UFE to its own Project - Part 9 #3161

Merged
merged 4 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 32 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ endif()
# modules and definitions
#------------------------------------------------------------------------------
include(cmake/utils.cmake)
find_package(Maya 2018 REQUIRED)
if (BUILD_MAYAUSD_LIBRARY)
find_package(Maya 2018 REQUIRED)
endif()
Comment on lines +88 to +90
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added bunch of cmake changes to make UsdUfe buildable on its own. This library only needs Usd & Ufe (no Maya, etc).


if(APPLE AND BUILD_UB2 AND NOT MAYA_MACOSX_BUILT_WITH_UB2)
message(WARNING "Maya was NOT built with Universal Binary 2")
Expand Down Expand Up @@ -117,9 +119,16 @@ message(STATUS " PYTHON_INCLUDE_DIRS = ${PYTHON_INCLUDE_DIRS}")
message(STATUS " PYTHON_LIBRARIES = ${PYTHON_LIBRARIES}")
message(STATUS " Python_EXECUTABLE = ${Python_EXECUTABLE}")

include(cmake/jinja.cmake)
if (BUILD_MAYAUSD_LIBRARY)
include(cmake/jinja.cmake)
endif()

find_package(USD 0.21.11 REQUIRED)
if (BUILD_MAYAUSD_LIBRARY OR BUILD_AL_PLUGIN OR BUILD_TESTS)
if(NOT USD_GENSCHEMA)
message(FATAL_ERROR "Building MayaUsd requires usdGenSchema (from USD)")
endif()
endif()
if (CMAKE_WANT_MATERIALX_BUILD)
# Requires at least USD 21.08 for hdMtlx module and USD must have been built with MaterialX:
if(NOT TARGET hdMtlx)
Expand All @@ -129,11 +138,13 @@ if (CMAKE_WANT_MATERIALX_BUILD)
endif()
include(cmake/usd.cmake)

if(${MAYA_APP_VERSION} STRLESS "2019" AND CMAKE_WANT_UFE_BUILD)
set(CMAKE_WANT_UFE_BUILD OFF)
message(AUTHOR_WARNING "========================================================================================= \
UFE is not available in Maya${MAYA_MAJOR_VERSION}. Maya2019 and later are supported only. \
========================================================================================= ")
if(DEFINED MAYA_APP_VERSION)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't call find_package(Maya) above then MAYA_APP_VERSION is not defined.

if (${MAYA_APP_VERSION} STRLESS "2019" AND CMAKE_WANT_UFE_BUILD)
set(CMAKE_WANT_UFE_BUILD OFF)
message(AUTHOR_WARNING "========================================================================================= \
UFE is not available in Maya${MAYA_MAJOR_VERSION}. Maya2019 and later are supported only. \
========================================================================================= ")
endif()
endif()

if(CMAKE_WANT_UFE_BUILD)
Expand Down Expand Up @@ -163,15 +174,16 @@ if(DEFINED QT_LOCATION)
if(BUILD_WITH_QT_6)
set(QT_VERSION "6.5")
message(STATUS "Setting Qt version to Qt ${QT_VERSION}")
elseif(${MAYA_APP_VERSION} STRLESS_EQUAL "2019")
set(QT_VERSION "5.6")
message(STATUS "Setting Qt version to Qt ${QT_VERSION}")
elseif(${MAYA_APP_VERSION} STRLESS_EQUAL "2020")
set(QT_VERSION "5.12")
message(STATUS "Setting Qt version to Qt ${QT_VERSION}")
else() # 2022, 2023, 2024
set(QT_VERSION "5.15")
message(STATUS "Setting Qt version to Qt ${QT_VERSION}")
else()
set(QT_VERSION "5.15") # default version Maya 2022/2023/2024
if(DEFINED MAYA_APP_VERSION)
if(${MAYA_APP_VERSION} STRLESS_EQUAL "2019")
set(QT_VERSION "5.6")
elseif(${MAYA_APP_VERSION} STRLESS_EQUAL "2020")
set(QT_VERSION "5.12")
endif()
message(STATUS "Setting Qt version to Qt ${QT_VERSION}")
endif()
endif()
endif()
set(CMAKE_PREFIX_PATH "${QT_LOCATION}")
Expand All @@ -198,7 +210,9 @@ include(cmake/compiler_config.cmake)
#------------------------------------------------------------------------------
# gulrak filesystem
#------------------------------------------------------------------------------
include(cmake/gulrak.cmake)
if (BUILD_MAYAUSD_LIBRARY OR BUILD_AL_PLUGIN)
include(cmake/gulrak.cmake)
endif()

#------------------------------------------------------------------------------
# test
Expand All @@ -215,9 +229,7 @@ endif()
#------------------------------------------------------------------------------
# lib
#------------------------------------------------------------------------------
if (BUILD_MAYAUSD_LIBRARY)
add_subdirectory(lib)
endif()
add_subdirectory(lib)

#------------------------------------------------------------------------------
# plugins
Expand Down
24 changes: 15 additions & 9 deletions cmake/modules/FindUSD.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ find_path(USD_INCLUDE_DIR
"USD Include directory"
)

# This component is optional.
find_file(USD_GENSCHEMA
NAMES
usdGenSchema
Expand Down Expand Up @@ -142,26 +143,31 @@ if (USD_LIBRARY_DIR AND EXISTS "${USD_LIBRARY_DIR}/${USD_LIB_PREFIX}usdMtlx${CMA
endif()
endif()

message(STATUS "USD include dir: ${USD_INCLUDE_DIR}")
message(STATUS "USD library dir: ${USD_LIBRARY_DIR}")
message(STATUS "USD version: ${USD_VERSION}")
message(STATUS "Autodesk USD version: ${ADSK_USD_VERSION}")
if(DEFINED USD_BOOST_VERSION)
message(STATUS "USD Boost::boost version: ${USD_BOOST_VERSION}")
endif()

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(USD
REQUIRED_VARS
PXR_USD_LOCATION
USD_INCLUDE_DIR
USD_LIBRARY_DIR
USD_GENSCHEMA
USD_CONFIG_FILE
USD_VERSION
ADSK_USD_VERSION
PXR_VERSION
VERSION_VAR
USD_VERSION
)

if (USD_FOUND)
# This will follow a message "-- Found USD: <path> ..."
message(STATUS " USD include dir: ${USD_INCLUDE_DIR}")
message(STATUS " USD library dir: ${USD_LIBRARY_DIR}")
if (USD_GENSCHEMA)
message(STATUS " usdGenSchema: ${USD_GENSCHEMA}")
endif()
message(STATUS " USD version: ${USD_VERSION}")
message(STATUS " Autodesk USD version: ${ADSK_USD_VERSION}")
if(DEFINED USD_BOOST_VERSION)
message(STATUS " USD Boost::boost version: ${USD_BOOST_VERSION}")
endif()
endif()
6 changes: 4 additions & 2 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ if(UFE_FOUND)
add_subdirectory(usdUfe)
endif()

add_subdirectory(mayaUsd)
add_subdirectory(usd)
if (BUILD_MAYAUSD_LIBRARY)
add_subdirectory(mayaUsd)
add_subdirectory(usd)
endif()
6 changes: 3 additions & 3 deletions lib/mayaUsd/fileio/primUpdaterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <mayaUsd/fileio/utils/writeUtil.h>
#include <mayaUsd/nodes/proxyShapeBase.h>
#include <mayaUsd/ufe/Global.h>
#include <mayaUsd/ufe/Utils.h>
#include <mayaUsd/undo/OpUndoItemMuting.h>
#include <mayaUsd/undo/OpUndoItems.h>
#include <mayaUsd/utils/dynamicAttribute.h>
Expand All @@ -37,6 +36,7 @@
#include <mayaUsd/utils/trieVisitor.h>

#include <usdUfe/ufe/UsdSceneItem.h>
#include <usdUfe/ufe/Utils.h>
#include <usdUfe/undo/UsdUndoBlock.h>

#include <pxr/base/tf/diagnostic.h>
Expand Down Expand Up @@ -618,7 +618,7 @@ UsdMayaPrimUpdaterSharedPtr createUpdater(
// path to form a proper UFE path.
auto psPath = MayaUsd::ufe::stagePath(context.GetUsdStage());
Ufe::Path::Segments segments { psPath.getSegments()[0],
MayaUsd::ufe::usdPathToUfePathSegment(dstPath) };
UsdUfe::usdPathToUfePathSegment(dstPath) };
Ufe::Path ufePath(std::move(segments));

// Get the Maya object corresponding to the SdfPath. As of 19-Oct-2021,
Expand Down Expand Up @@ -1596,7 +1596,7 @@ void PrimUpdaterManager::onProxyContentChanged(
!= UsdMayaPrimUpdater::Supports::AutoPull)
return false;

const Ufe::PathSegment pathSegment = MayaUsd::ufe::usdPathToUfePathSegment(prim.GetPath());
const Ufe::PathSegment pathSegment = UsdUfe::usdPathToUfePathSegment(prim.GetPath());
const Ufe::Path path = proxyShapeUfePath + pathSegment;

auto factory = std::get<UpdaterFactoryFn>(registryItem);
Expand Down
5 changes: 3 additions & 2 deletions lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <mayaUsd/utils/diagnosticDelegate.h>
#include <mayaUsd/utils/selectability.h>

#include <usdUfe/ufe/Utils.h>

#include <pxr/base/tf/diagnostic.h>
#include <pxr/base/tf/staticTokens.h>
#include <pxr/base/tf/stringUtils.h>
Expand Down Expand Up @@ -1487,8 +1489,7 @@ bool ProxyRenderDelegate::getInstancedSelectionPath(
}
}

const Ufe::PathSegment pathSegment
= MayaUsd::ufe::usdPathToUfePathSegment(usdPath, instanceIndex);
const Ufe::PathSegment pathSegment = UsdUfe::usdPathToUfePathSegment(usdPath, instanceIndex);
const Ufe::SceneItem::Ptr& si
= handler->createItem(_proxyShapeData->ProxyShape()->ufePath() + pathSegment);
if (!si) {
Expand Down
6 changes: 4 additions & 2 deletions lib/mayaUsd/sceneIndex/proxyShapeSceneIndexPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <mayaUsd/ufe/Global.h>
#endif

#include <usdUfe/ufe/Utils.h>

#include <pxr/imaging/hd/flatteningSceneIndex.h>
#if defined(HD_API_VERSION) && HD_API_VERSION >= 51
#include <pxr/imaging/hd/materialBindingsSchema.h>
Expand Down Expand Up @@ -211,8 +213,8 @@ Ufe::Path MayaUsdProxyShapeSceneIndex::InterpretRprimPath(
MStatus status;
MDagPath dagPath(
MDagPath::getAPathTo(proxyShapeSceneIndex->_proxyShape->thisMObject(), &status));
return Ufe::Path({ MayaUsd::ufe::dagPathToPathSegment(dagPath),
MayaUsd::ufe::usdPathToUfePathSegment(path) });
return Ufe::Path(
{ MayaUsd::ufe::dagPathToPathSegment(dagPath), UsdUfe::usdPathToUfePathSegment(path) });
}

return Ufe::Path();
Expand Down
8 changes: 2 additions & 6 deletions lib/mayaUsd/ufe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
target_sources(${PROJECT_NAME}
PRIVATE
Global.cpp
MayaStagesSubject.cpp
ProxyShapeHandler.cpp
ProxyShapeHierarchy.cpp
ProxyShapeHierarchyHandler.cpp
SetVariantSelectionCommand.cpp
StagesSubject.cpp
UsdPointInstanceOrientationModifier.cpp
UsdPointInstancePositionModifier.cpp
UsdPointInstanceScaleModifier.cpp
Expand Down Expand Up @@ -41,8 +41,6 @@ if(CMAKE_UFE_V2_FEATURES_AVAILABLE)
UsdAttributeHolder.cpp
UsdAttributes.cpp
UsdAttributesHandler.cpp
UsdCamera.cpp
UsdCameraHandler.cpp
UsdContextOps.cpp
UsdContextOpsHandler.cpp
UsdSetXformOpUndoableCommandBase.cpp
Expand Down Expand Up @@ -177,11 +175,11 @@ endif()

set(HEADERS
Global.h
MayaStagesSubject.h
ProxyShapeHandler.h
ProxyShapeHierarchy.h
ProxyShapeHierarchyHandler.h
SetVariantSelectionCommand.h
StagesSubject.h
UsdPointInstanceModifierBase.h
UsdPointInstanceOrientationModifier.h
UsdPointInstancePositionModifier.h
Expand Down Expand Up @@ -213,8 +211,6 @@ if(CMAKE_UFE_V2_FEATURES_AVAILABLE)
UsdAttributeHolder.h
UsdAttributes.h
UsdAttributesHandler.h
UsdCamera.h
UsdCameraHandler.h
UsdContextOps.h
UsdContextOpsHandler.h
UsdPointInstanceUndoableCommands.h
Expand Down
18 changes: 5 additions & 13 deletions lib/mayaUsd/ufe/Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

#include "private/UfeNotifGuard.h"

#include <mayaUsd/ufe/MayaStagesSubject.h>
#include <mayaUsd/ufe/ProxyShapeHandler.h>
#include <mayaUsd/ufe/ProxyShapeHierarchyHandler.h>
#include <mayaUsd/ufe/StagesSubject.h>
#include <mayaUsd/ufe/UsdSceneItemOpsHandler.h>
#include <mayaUsd/ufe/UsdTransform3dHandler.h>
#include <mayaUsd/ufe/Utils.h>
Expand All @@ -29,7 +29,6 @@
#include <mayaUsd/ufe/MayaUsdObject3dHandler.h>
#include <mayaUsd/ufe/ProxyShapeContextOpsHandler.h>
#include <mayaUsd/ufe/UsdAttributesHandler.h>
#include <mayaUsd/ufe/UsdCameraHandler.h>
#include <mayaUsd/ufe/UsdContextOpsHandler.h>
#include <mayaUsd/ufe/UsdTransform3dCommonAPI.h>
#include <mayaUsd/ufe/UsdTransform3dFallbackMayaXformStack.h>
Expand Down Expand Up @@ -145,9 +144,6 @@ Ufe::PathMappingHandler::Ptr g_MayaPathMappingHandler;
Ufe::UIInfoHandler::Ptr g_MayaUIInfoHandler;
#endif

// Subject singleton for observation of all USD stages.
StagesSubject::Ptr g_StagesSubject;

//------------------------------------------------------------------------------
// Functions
//------------------------------------------------------------------------------
Expand All @@ -162,6 +158,8 @@ MStatus initialize()

// Set the Maya specific functions required for the UsdUfe plugin to work correctly.
UsdUfe::DCCFunctions dccFunctions;
dccFunctions.stageAccessorFn = MayaUsd::ufe::getStage;
dccFunctions.stagePathAccessorFn = MayaUsd::ufe::stagePath;
Comment on lines +161 to +162
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two new required DCC functions for the StagesSubject.

dccFunctions.ufePathToPrimFn = MayaUsd::ufe::ufePathToPrim;
dccFunctions.timeAccessorFn = MayaUsd::ufe::getTime;
dccFunctions.isAttributeLockedFn = MayaUsd::Editability::isAttributeLocked;
Expand Down Expand Up @@ -203,7 +201,6 @@ MStatus initialize()
usdUfeHandlers.object3dHandler = MayaUsdObject3dHandler::create();
handlers.contextOpsHandler = UsdContextOpsHandler::create();
handlers.uiInfoHandler = UsdUIInfoHandler::create();
handlers.cameraHandler = UsdCameraHandler::create();

#ifdef UFE_V4_FEATURES_AVAILABLE

Expand Down Expand Up @@ -269,7 +266,8 @@ MStatus initialize()

// Initialize UsdUfe which will register all the default handlers
// and the overrides we provide.
auto usdRtid = UsdUfe::initialize(dccFunctions, usdUfeHandlers);
auto ss = MayaStagesSubject::create();
auto usdRtid = UsdUfe::initialize(dccFunctions, usdUfeHandlers, ss);
Comment on lines +269 to +270
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We create the MayaStagesSubject (derived from StagesSubject in UsdUfe) and pass that to initialize. So UsdUfe won't created the base version it will save ours.


// TEMP (UsdUfe)
// Can only call Ufe::RunTimeMgr::register_() once for a given runtime name.
Expand All @@ -287,8 +285,6 @@ MStatus initialize()
runTimeMgr.setContextOpsHandler(usdRtid, handlers.contextOpsHandler);
if (handlers.uiInfoHandler)
runTimeMgr.setUIInfoHandler(usdRtid, handlers.uiInfoHandler);
if (handlers.cameraHandler)
runTimeMgr.setCameraHandler(usdRtid, handlers.cameraHandler);
Comment on lines -290 to -291
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CameraHandler was moved to UsdUfe and we have no Maya derived version

#ifdef UFE_V4_FEATURES_AVAILABLE
if (handlers.lightHandler)
runTimeMgr.setLightHandler(usdRtid, handlers.lightHandler);
Expand Down Expand Up @@ -336,8 +332,6 @@ MStatus initialize()
if (usdRtid == 0)
return MS::kFailure;

g_StagesSubject = StagesSubject::create();

// Register for UFE string to path service using path component separator '/'
UFE_V2(Ufe::PathString::registerPathComponentSeparator(usdRtid, '/');)

Expand Down Expand Up @@ -389,8 +383,6 @@ MStatus finalize(bool exiting)
g_MayaUIInfoHandler.reset();
#endif

g_StagesSubject.Reset();

MMessage::removeCallback(gExitingCbId);

return MS::kSuccess;
Expand Down
Loading