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-129260 - MayaUsd: make building with Ufe mandatory and remove v1 support #3217

Merged
merged 9 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 5 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ if(APPLE)
option(BUILD_UB2 "Build Universal Binary 2 (UB2) Intel64+arm64" OFF)
endif()
set(BUILD_WITH_PYTHON_3_VERSION 3.7 CACHE STRING "The version of Python 3 to build with")
option(CMAKE_WANT_UFE_BUILD "Enable building with UFE (if found)." ON)
option(CMAKE_WANT_MATERIALX_BUILD "Enable building with MaterialX (experimental)." OFF)

option(BUILD_WITH_QT_6 "Build with QT 6." OFF)
Expand Down Expand Up @@ -135,14 +134,11 @@ if (CMAKE_WANT_MATERIALX_BUILD)
endif()
include(cmake/usd.cmake)

if(CMAKE_WANT_UFE_BUILD)
find_package(UFE QUIET)
if(UFE_FOUND)
message(STATUS "Building with UFE ${UFE_VERSION} features enabled.")
else()
message(STATUS "UFE not found. UFE features will be disabled.")
endif()
endif()
find_package(UFE 0.2.0 REQUIRED)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ufe is not mandatory and we must find at least v2 (for Maya 2022).

message(STATUS "Build MayaUsd with UFE version ${UFE_VERSION}")
message(STATUS " UFE include dir: ${UFE_INCLUDE_DIR}")
message(STATUS " UFE library: ${UFE_LIBRARY}")
message(STATUS " UFE preview features: ${UFE_PREVIEW_FEATURES}")

if(CMAKE_WANT_MATERIALX_BUILD AND MAYA_LIGHTAPI_VERSION LESS 2)
set(CMAKE_WANT_MATERIALX_BUILD OFF)
Expand Down
7 changes: 0 additions & 7 deletions cmake/modules/FindUFE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,6 @@ find_package_handle_standard_args(UFE
UFE_VERSION
)

if(UFE_FOUND)
message(STATUS "UFE include dir: ${UFE_INCLUDE_DIR}")
message(STATUS "UFE library: ${UFE_LIBRARY}")
message(STATUS "UFE version: ${UFE_VERSION}")
message(STATUS "UFE preview features: ${UFE_PREVIEW_FEATURES}")
endif()

set(UFE_LIGHTS_SUPPORT FALSE CACHE INTERNAL "ufeLights")
if (UFE_INCLUDE_DIR AND EXISTS "${UFE_INCLUDE_DIR}/ufe/lightHandler.h")
set(UFE_LIGHTS_SUPPORT TRUE CACHE INTERNAL "ufeLights")
Expand Down
1 change: 0 additions & 1 deletion doc/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ BUILD_STRICT_MODE | enforces all warnings as errors.
BUILD_WITH_PYTHON_3 | build with python 3. | OFF
BUILD_SHARED_LIBS | build libraries as shared or static. | ON
BUILD_UB2 | build universal binary 2 (UB2) Intel64+arm64 (apple only) | OFF
CMAKE_WANT_UFE_BUILD | enables building with UFE (if found). | ON
CMAKE_WANT_MATERIALX_BUILD | enable building with MaterialX (experimental). | OFF

##### Stages
Expand Down
6 changes: 3 additions & 3 deletions doc/codingGuidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ Headers should be included in the following order, with each section separated b

#include <string>

#if defined(WANT_UFE_BUILD)
#include <ufe/ufe.h>
#ifdef UFE_V3_FEATURES_AVAILABLE
#include <ufe/types.h>
#endif
```

Expand All @@ -242,7 +242,7 @@ Headers should be included in the following order, with each section separated b
* `MAYA_APP_VERSION` is a simple year number, so it is not allowed in C++ code. However it is set as a CMake variable and allowed in cmake files.

**UFE**
* `WANT_UFE_BUILD` equals 1 if UFE is found and it should be used for conditional compilation on codes depending on UFE.
* Each version of Ufe contains a features available define (in ufe.h) such as `UFE_V4_FEATURES_AVAILABLE` that can be used for conditional compilation on code depending on Ufe Version.

**USD**
* `PXR_VERSION` is the macro to test USD version (`PXR_MAJOR_VERSION` * 10000 + `PXR_MINOR_VERSION` * 100 + `PXR_PATCH_VERSION`)
Expand Down
5 changes: 1 addition & 4 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
if(UFE_FOUND)
add_subdirectory(usdUfe)
endif()

add_subdirectory(usdUfe)
if (BUILD_MAYAUSD_LIBRARY)
add_subdirectory(mayaUsd)
add_subdirectory(usd)
Expand Down
11 changes: 4 additions & 7 deletions lib/mayaUsd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ target_compile_definitions(${PROJECT_NAME}
$<$<STREQUAL:${CMAKE_BUILD_TYPE},Debug>:TBB_USE_DEBUG>
$<$<STREQUAL:${CMAKE_BUILD_TYPE},Debug>:BOOST_DEBUG_PYTHON>
$<$<STREQUAL:${CMAKE_BUILD_TYPE},Debug>:BOOST_LINKING_PYTHON>
$<$<BOOL:${UFE_FOUND}>:WANT_UFE_BUILD>
$<$<BOOL:${MAYA_ENABLE_NEW_PRIM_DELETE}>:MAYA_ENABLE_NEW_PRIM_DELETE>
PRIVATE
MAYAUSD_MACROS_EXPORT
Expand Down Expand Up @@ -183,7 +182,7 @@ if (MAYA_LIGHTAPI_VERSION GREATER_EQUAL 2)
endif()

# Some of the UFE classes are exporting STL classes which causes this warning.
if(UFE_FOUND AND MSVC)
if(MSVC)
target_compile_options(${PROJECT_NAME}
PUBLIC
/wd4251
Expand Down Expand Up @@ -215,7 +214,7 @@ target_include_directories(${PROJECT_NAME}
PUBLIC
${MAYA_INCLUDE_DIRS}
${PXR_INCLUDE_DIRS}
$<$<BOOL:${UFE_FOUND}>:${UFE_INCLUDE_DIR}>
${UFE_INCLUDE_DIR}
${CMAKE_BINARY_DIR}/include

PRIVATE
Expand Down Expand Up @@ -251,7 +250,7 @@ target_link_libraries(${PROJECT_NAME}
usdUtils
$<$<BOOL:$<VERSION_GREATER_EQUAL:${UFE_PREVIEW_VERSION_NUM},4023>>:usdUI>
vt
$<$<BOOL:${UFE_FOUND}>:${UFE_LIBRARY}>
${UFE_LIBRARY}
${MAYA_LIBRARIES}
mayaUsdUtils
usdUfe
Expand Down Expand Up @@ -324,9 +323,7 @@ add_subdirectory(resources)
if( PXR_VERSION GREATER_EQUAL 2211 )
add_subdirectory(sceneIndex)
endif()
if(UFE_FOUND)
add_subdirectory(ufe)
endif()
add_subdirectory(ufe)
add_subdirectory(undo)
add_subdirectory(utils)

Expand Down
24 changes: 4 additions & 20 deletions lib/mayaUsd/commands/layerEditorCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "layerEditorCommand.h"

#include <mayaUsd/ufe/Global.h>
#include <mayaUsd/ufe/Utils.h>
#include <mayaUsd/utils/query.h>
#include <mayaUsd/utils/utilFileSystem.h>

Expand All @@ -25,14 +27,8 @@
#include <maya/MArgParser.h>
#include <maya/MStringArray.h>
#include <maya/MSyntax.h>

#if defined(WANT_UFE_BUILD)
#include <mayaUsd/ufe/Global.h>
#include <mayaUsd/ufe/Utils.h>

#include <ufe/globalSelection.h>
#include <ufe/observableSelection.h>
#endif

#include <ghc/filesystem.hpp>

Expand Down Expand Up @@ -282,7 +278,6 @@ class InsertRemoveSubPathBase : public BaseCmd

void saveSelection()
{
#if defined(WANT_UFE_BUILD)
// Make a copy of the global selection, to restore it on undo.
auto globalSn = Ufe::GlobalSelection::get();
_savedSn.replaceWith(*globalSn);
Expand All @@ -294,12 +289,10 @@ class InsertRemoveSubPathBase : public BaseCmd
Ufe::Path path(
Ufe::PathSegment("world" + _proxyShapePath, MayaUsd::ufe::getMayaRunTimeId(), '|'));
globalSn->replaceWith(MayaUsd::ufe::removeDescendants(_savedSn, path));
#endif
}

void restoreSelection()
{
#if defined(WANT_UFE_BUILD)
// Restore the saved selection to the global selection. If a saved
// selection item started with the proxy shape path, re-create it.
// We know the path to the proxy shape has a single segment. Not
Expand All @@ -310,14 +303,11 @@ class InsertRemoveSubPathBase : public BaseCmd
Ufe::PathSegment("world" + _proxyShapePath, MayaUsd::ufe::getMayaRunTimeId(), '|'));
auto globalSn = Ufe::GlobalSelection::get();
globalSn->replaceWith(MayaUsd::ufe::recreateDescendants(_savedSn, path));
#endif
}

protected:
std::string _editTargetPath;
#if defined(WANT_UFE_BUILD)
std::string _editTargetPath;
Ufe::Selection _savedSn;
#endif

UsdStageWeakPtr getStage()
{
Expand Down Expand Up @@ -665,7 +655,6 @@ class MuteLayer : public BaseCmd

void saveSelection()
{
#if defined(WANT_UFE_BUILD)
// Make a copy of the global selection, to restore it on unmute.
auto globalSn = Ufe::GlobalSelection::get();
_savedSn.replaceWith(*globalSn);
Expand All @@ -677,12 +666,10 @@ class MuteLayer : public BaseCmd
Ufe::Path path(
Ufe::PathSegment("world" + _proxyShapePath, MayaUsd::ufe::getMayaRunTimeId(), '|'));
globalSn->replaceWith(MayaUsd::ufe::removeDescendants(_savedSn, path));
#endif
}

void restoreSelection()
{
#if defined(WANT_UFE_BUILD)
// Restore the saved selection to the global selection. If a saved
// selection item started with the proxy shape path, re-create it.
// We know the path to the proxy shape has a single segment. Not
Expand All @@ -693,12 +680,9 @@ class MuteLayer : public BaseCmd
Ufe::PathSegment("world" + _proxyShapePath, MayaUsd::ufe::getMayaRunTimeId(), '|'));
auto globalSn = Ufe::GlobalSelection::get();
globalSn->replaceWith(MayaUsd::ufe::recreateDescendants(_savedSn, path));
#endif
}

#if defined(WANT_UFE_BUILD)
Ufe::Selection _savedSn;
#endif
Ufe::Selection _savedSn;
PXR_NS::SdfLayerRefPtr _mutedLayer;
};

Expand Down
12 changes: 2 additions & 10 deletions lib/mayaUsd/nodes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
target_sources(${PROJECT_NAME}
PRIVATE
hdImagingShape.cpp
layerManager.cpp
pointBasedDeformerNode.cpp
proxyAccessor.cpp
proxyShapeBase.cpp
Expand All @@ -17,6 +18,7 @@ target_sources(${PROJECT_NAME}

set(HEADERS
hdImagingShape.h
layerManager.h
pointBasedDeformerNode.h
proxyAccessor.h
proxyShapeBase.h
Expand All @@ -29,16 +31,6 @@ set(HEADERS
usdPrimProvider.h
)

if (UFE_FOUND)
target_sources(${PROJECT_NAME}
PRIVATE
layerManager.cpp
)
list(APPEND HEADERS
layerManager.h
)
endif()

# -----------------------------------------------------------------------------
# promoted headers
# -----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lib/mayaUsd/nodes/layerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ bool LayerDatabase::hasDirtyLayer() const
bool LayerDatabase::getProxiesToSave(bool isExport)
{
bool checkSelection = isExport && (MFileIO::kExportTypeSelected == MFileIO::exportType());
const UFE_NS::GlobalSelection::Ptr& ufeSelection = UFE_NS::GlobalSelection::get();
const Ufe::GlobalSelection::Ptr& ufeSelection = Ufe::GlobalSelection::get();

clearProxies();

Expand Down
10 changes: 2 additions & 8 deletions lib/mayaUsd/nodes/proxyAccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@
#include "proxyAccessor.h"

#include <mayaUsd/base/debugCodes.h>
#include <mayaUsd/utils/converter.h>

#if defined(WANT_UFE_BUILD)
#include <mayaUsd/ufe/Utils.h>
#endif
#include <mayaUsd/utils/converter.h>

#include <pxr/pxr.h>
#include <pxr/usd/ar/resolverScopedCache.h>
Expand Down Expand Up @@ -603,13 +600,10 @@ MStatus ProxyAccessor::computeOutput(
dstArray.setAllClean();
} else if (item.property == combinedVisibilityToken) {
// First, verify visibility of the proxy shape
#if defined(WANT_UFE_BUILD)
Ufe::Path proxyShapeUfePath = MayaUsd::ufe::stagePath(stage);
MDagPath proxyShapeDagPath = MayaUsd::ufe::ufeToDagPath(proxyShapeUfePath);
bool visible = proxyShapeDagPath.isVisible();
#else
bool visible = true;
#endif

// Next, verify visibility of the usd prim
UsdGeomImageable imageable(itemPrim);
if (visible && imageable) {
Expand Down
Loading