Skip to content

Commit

Permalink
HYDRA-1120 : Support compilation of usd 24.08
Browse files Browse the repository at this point in the history
  • Loading branch information
lanierd-adsk committed Sep 18, 2024
1 parent 6756a66 commit a7416eb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
33 changes: 25 additions & 8 deletions lib/adskHydraSceneBrowser/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -89,7 +100,9 @@ foreach(SOURCE IN ITEMS ${SOURCES})
prepend_include(FILE_CONTENTS "#include <QString>")

# 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()
Expand All @@ -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 <adskHydraSceneBrowserApi.h>' to have HDUI_API defined
prepend_include(FILE_CONTENTS "#include <adskHydraSceneBrowserApi.h>")
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 <adskHydraSceneBrowserApi.h>' to have HDUI_API defined
prepend_include(FILE_CONTENTS "#include <adskHydraSceneBrowserApi.h>")
endif()

file(WRITE "${PATCH_LOCATION}/${HEADER}" "${FILE_CONTENTS}")
endforeach()

Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 5 additions & 1 deletion lib/mayaHydra/hydraExtensions/pick/mhUsdPickHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ std::vector<UsdPickHandler::HitPath> 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;
}
Expand Down

0 comments on commit a7416eb

Please sign in to comment.