From a7416eb4127657bb9700ef45a8a28a699566fb42 Mon Sep 17 00:00:00 2001 From: "ADS\\lanierd" Date: Wed, 18 Sep 2024 17:14:45 +0200 Subject: [PATCH] HYDRA-1120 : Support compilation of usd 24.08 --- lib/adskHydraSceneBrowser/lib/CMakeLists.txt | 33 ++++++++++++++----- ...pWireframeSelectionHighlightSceneIndex.cpp | 6 +++- .../hydraExtensions/pick/mhUsdPickHandler.cpp | 6 +++- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/lib/adskHydraSceneBrowser/lib/CMakeLists.txt b/lib/adskHydraSceneBrowser/lib/CMakeLists.txt index cdcd5433a0..35a4efe6e4 100644 --- a/lib/adskHydraSceneBrowser/lib/CMakeLists.txt +++ b/lib/adskHydraSceneBrowser/lib/CMakeLists.txt @@ -14,7 +14,11 @@ endif() # ----------------------------------------------------------------------------- # add library # ----------------------------------------------------------------------------- -add_library(${TARGET_NAME} SHARED adskHydraSceneBrowserApi.h) +if(PXR_VERSION VERSION_LESS 2408) + add_library(${TARGET_NAME} SHARED api.h) +else() + add_library(${TARGET_NAME} SHARED adskHydraSceneBrowserApi.h) +endif() # ----------------------------------------------------------------------------- # setup sources @@ -28,6 +32,11 @@ set(HEADERS sceneIndexObserverLoggingWidget.h sceneIndexTreeWidget.h ) + +if(PXR_VERSION VERSION_GREATER_EQUAL 2408) + list(APPEND HEADERS api.h) +endif() + set(SOURCES dataSourceTreeWidget.cpp dataSourceValueTreeView.cpp @@ -71,7 +80,9 @@ foreach(SOURCE IN ITEMS ${SOURCES}) # from a QLatin1StringView constructed with a C string. To patch this in we do the following replacements: # "QVariant(someVariable.str().c_str())" -> "QVariant(QLatin1StringView(someVariable.str().c_str()))" # "QVariant(someVariable.str().data())" -> "QVariant(QLatin1StringView(someVariable.str().data()))" - string(REGEX REPLACE "QVariant\\(\(${IDENTIFIER_REGEX}\)\.str\\(\\)\.\(c_str|data\)\\(\\)\\)" "QVariant(QLatin1StringView(\\1.str().\\2()))" FILE_CONTENTS "${FILE_CONTENTS}") + if(PXR_VERSION VERSION_LESS 2408) + string(REGEX REPLACE "QVariant\\(\(${IDENTIFIER_REGEX}\)\.str\\(\\)\.\(c_str|data\)\\(\\)\\)" "QVariant(QLatin1StringView(\\1.str().\\2()))" FILE_CONTENTS "${FILE_CONTENTS}") + endif() # Some setExpanded() calls are wrapped inside a QTimer::singleShot() call in order to defer their execution. # This was done by Pixar in order to work around a crash in what appears to be some of their proprietary code @@ -89,7 +100,9 @@ foreach(SOURCE IN ITEMS ${SOURCES}) prepend_include(FILE_CONTENTS "#include ") # Remove an unused lambda capture to fix a warning-treated-as-error on MacOS - string(REGEX REPLACE "\(\\[this, menu\), menuTreeWidget\(\\]\\(QTreeWidgetItem \\*item, int column\\)\)" "\\1\\2" FILE_CONTENTS "${FILE_CONTENTS}") + if(PXR_VERSION VERSION_LESS 2408) + string(REGEX REPLACE "\(\\[this, menu\), menuTreeWidget\(\\]\\(QTreeWidgetItem \\*item, int column\\)\)" "\\1\\2" FILE_CONTENTS "${FILE_CONTENTS}") + endif() file(WRITE "${PATCH_LOCATION}/${SOURCE}" "${FILE_CONTENTS}") endforeach() @@ -103,11 +116,15 @@ foreach(HEADER IN ITEMS ${HEADERS}) # Add DLL import/export support for Windows # Insert 'HDUI_API' symbols for class declarations # Note: we assume class declarations are always followed by double colons - string(REGEX REPLACE "class (${IDENTIFIER_REGEX}[^\;]:)" "class HDUI_API \\1" FILE_CONTENTS "${FILE_CONTENTS}") - - # Patch in '#include ' to have HDUI_API defined - prepend_include(FILE_CONTENTS "#include ") + if(PXR_VERSION VERSION_LESS 2408) + string(REGEX REPLACE "class (${IDENTIFIER_REGEX}[^\;]:)" "class HDUI_API \\1" FILE_CONTENTS "${FILE_CONTENTS}") + endif() + if(PXR_VERSION VERSION_LESS 2408) + # Patch in '#include ' to have HDUI_API defined + prepend_include(FILE_CONTENTS "#include ") + endif() + file(WRITE "${PATCH_LOCATION}/${HEADER}" "${FILE_CONTENTS}") endforeach() @@ -142,7 +159,7 @@ set_target_properties(Qt6::Core PROPERTIES INTERFACE_COMPILE_DEFINITIONS QT_NO_K target_compile_definitions(${TARGET_NAME} PRIVATE - HDUI_EXPORT + HDUI_EXPORTS ) mayaHydra_compile_config(${TARGET_NAME}) # TODO : This will have to be changed when moving to a standalone repo. diff --git a/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp b/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp index 2b9408feaf..8dfc022ef5 100644 --- a/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp +++ b/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp @@ -606,7 +606,11 @@ WireframeSelectionHighlightSceneIndex::_TrimMeshForSelectedGeomSubsets(const HdC continue; } - HdGeomSubsetSchema geomSubsetSchema = HdGeomSubsetSchema(childPrim.dataSource); + #if HD_API_VERSION >= 71 // USD 24.08+ + HdGeomSubsetSchema geomSubsetSchema = HdGeomSubsetSchema::GetFromParent(childPrim.dataSource); + #else + HdGeomSubsetSchema geomSubsetSchema = HdGeomSubsetSchema(childPrim.dataSource); + #endif if (!geomSubsetSchema.IsDefined() || geomSubsetSchema.GetType()->GetTypedValue(0) != HdGeomSubsetSchemaTokens->typeFaceSet) { continue; } diff --git a/lib/mayaHydra/hydraExtensions/pick/mhUsdPickHandler.cpp b/lib/mayaHydra/hydraExtensions/pick/mhUsdPickHandler.cpp index b9c73b2775..5916f90a31 100644 --- a/lib/mayaHydra/hydraExtensions/pick/mhUsdPickHandler.cpp +++ b/lib/mayaHydra/hydraExtensions/pick/mhUsdPickHandler.cpp @@ -248,7 +248,11 @@ std::vector resolveGeomSubsetsPicking( continue; } - HdGeomSubsetSchema geomSubsetSchema = HdGeomSubsetSchema(childPrim.dataSource); + #if HD_API_VERSION >= 71 // USD 24.08+ + HdGeomSubsetSchema geomSubsetSchema = HdGeomSubsetSchema::GetFromParent(childPrim.dataSource); + #else + HdGeomSubsetSchema geomSubsetSchema = HdGeomSubsetSchema(childPrim.dataSource); + #endif if (!geomSubsetSchema.IsDefined() || geomSubsetSchema.GetType()->GetTypedValue(0) != geomSubsetType) { continue; }