Skip to content

Commit

Permalink
Merge pull request #3986 from Autodesk/azharia/EMSUSD-1686/Camera-Per…
Browse files Browse the repository at this point in the history
…formance-Fix-Backport

EMSUSD-1686 Camera Performance Fix Backport
  • Loading branch information
seando-adsk authored Dec 9, 2024
2 parents 018d922 + 267620f commit 1082fa2
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 14 deletions.
9 changes: 9 additions & 0 deletions cmake/modules/FindUFE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,12 @@ if(UFE_INCLUDE_DIR AND EXISTS "${UFE_INCLUDE_DIR}/ufe/sceneSegmentHandler.h")
message(STATUS "Maya has UFE SceneSegmentHandler's rootSceneSegmentRootPath interface")
endif()
endif()

set(UFE_CAMERAHANDLER_HAS_FINDALL FALSE CACHE INTERNAL "findAll")
if(UFE_INCLUDE_DIR AND EXISTS "${UFE_INCLUDE_DIR}/ufe/cameraHandler.h")
file(STRINGS ${UFE_INCLUDE_DIR}/ufe/cameraHandler.h UFE_HAS_API REGEX "findAll")
if(UFE_HAS_API)
set(UFE_CAMERAHANDLER_HAS_FINDALL TRUE CACHE INTERNAL "ufeCameraHandlerHasFindAll")
message(STATUS "Maya has UFE CameraHandler's findAll interface")
endif()
endif()
21 changes: 19 additions & 2 deletions lib/mayaUsd/ufe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,26 @@ if (NOT MAYA_APP_VERSION VERSION_GREATER 2025)
)
endif()

if (UFE_CAMERAHANDLER_HAS_FINDALL)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
UFE_CAMERAHANDLER_HAS_FINDALL=1
)
endif()

if(UFE_CAMERAHANDLER_HAS_FINDALL)
target_sources(${PROJECT_NAME}
PRIVATE
ProxyShapeCameraHandler.cpp
)
endif()

if(CMAKE_UFE_V4_FEATURES_AVAILABLE)
target_sources(${PROJECT_NAME}
PRIVATE
UsdShaderNodeDef.cpp
UsdShaderNodeDefHandler.cpp
UsdUndoCreateFromNodeDefCommand.cpp
ProxyShapeCameraHandler.cpp
UsdConnections.cpp
UsdConnectionHandler.cpp
UsdUINodeGraphNode.cpp
Expand Down Expand Up @@ -243,12 +255,17 @@ if(CodeWrapperHandler IN_LIST UFE_PREVIEW_FEATURES)
)
endif()

if(UFE_CAMERAHANDLER_HAS_FINDALL)
list(APPEND HEADERS
ProxyShapeCameraHandler.h
)
endif()

if(CMAKE_UFE_V4_FEATURES_AVAILABLE)
list(APPEND HEADERS
UsdShaderNodeDef.h
UsdShaderNodeDefHandler.h
UsdUndoCreateFromNodeDefCommand.h
ProxyShapeCameraHandler.h
UsdConnections.h
UsdConnectionHandler.h
UsdUINodeGraphNode.h
Expand Down
7 changes: 5 additions & 2 deletions lib/mayaUsd/ufe/Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@
#include <mayaUsd/ufe/UsdMaterialHandler.h>
#endif

#ifdef UFE_V4_FEATURES_AVAILABLE
#if defined(UFE_V4_FEATURES_AVAILABLE) || (UFE_MAJOR_VERSION == 3 && UFE_CAMERAHANDLER_HAS_FINDALL)
#include <mayaUsd/ufe/ProxyShapeCameraHandler.h>
#endif

#ifdef UFE_V4_FEATURES_AVAILABLE
#include <mayaUsd/ufe/UsdConnectionHandler.h>
#include <mayaUsd/ufe/UsdShaderNodeDefHandler.h>
#include <mayaUsd/ufe/UsdUINodeGraphNodeHandler.h>
Expand Down Expand Up @@ -276,7 +279,7 @@ MStatus initialize()
runTimeMgr.setSceneSegmentHandler(g_MayaRtid, proxyShapeSceneSegmentHandler);
#endif

#ifdef UFE_V4_FEATURES_AVAILABLE
#if defined(UFE_V4_FEATURES_AVAILABLE) || (UFE_MAJOR_VERSION == 3 && UFE_CAMERAHANDLER_HAS_FINDALL)
// set up the ProxyShapeCameraHandler
g_MayaCameraHandler = runTimeMgr.cameraHandler(g_MayaRtid);
auto proxyShapeCameraHandler = ProxyShapeCameraHandler::create(g_MayaCameraHandler);
Expand Down
11 changes: 8 additions & 3 deletions lib/mayaUsd/ufe/ProxyShapeCameraHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ PXR_NAMESPACE_USING_DIRECTIVE
namespace MAYAUSD_NS_DEF {
namespace ufe {

#if UFE_MAJOR_VERSION == 3 && UFE_CAMERAHANDLER_HAS_FINDALL
MAYAUSD_VERIFY_CLASS_SETUP(Ufe::CameraHandler_v3_4, ProxyShapeCameraHandler);
#else
MAYAUSD_VERIFY_CLASS_SETUP(Ufe::CameraHandler, ProxyShapeCameraHandler);
#endif // UFE_CAMERAHANDLER_HAS_FINDALL

ProxyShapeCameraHandler::ProxyShapeCameraHandler(const Ufe::CameraHandler::Ptr& mayaCameraHandler)
: Ufe::CameraHandler()
ProxyShapeCameraHandler::ProxyShapeCameraHandler(const CAMERAHANDLERBASE::Ptr& mayaCameraHandler)
: CAMERAHANDLERBASE()
, _mayaCameraHandler(mayaCameraHandler)
{
}
Expand All @@ -43,7 +47,8 @@ ProxyShapeCameraHandler::ProxyShapeCameraHandler(const Ufe::CameraHandler::Ptr&
ProxyShapeCameraHandler::Ptr
ProxyShapeCameraHandler::create(const Ufe::CameraHandler::Ptr& mayaCameraHandler)
{
return std::make_shared<ProxyShapeCameraHandler>(mayaCameraHandler);
auto mayaCameraHandlerBase = std::static_pointer_cast<CAMERAHANDLERBASE>(mayaCameraHandler);
return std::make_shared<ProxyShapeCameraHandler>(mayaCameraHandlerBase);
}

//------------------------------------------------------------------------------
Expand Down
12 changes: 9 additions & 3 deletions lib/mayaUsd/ufe/ProxyShapeCameraHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@
namespace MAYAUSD_NS_DEF {
namespace ufe {

#if UFE_MAJOR_VERSION == 3 && UFE_CAMERAHANDLER_HAS_FINDALL
#define CAMERAHANDLERBASE Ufe::CameraHandler_v3_4
#else
#define CAMERAHANDLERBASE Ufe::CameraHandler
#endif // UFE_CAMERAHANDLER_HAS_FINDALL

//! \brief Interface to create a ProxyShapeCameraHandler interface object.
class MAYAUSD_CORE_PUBLIC ProxyShapeCameraHandler : public Ufe::CameraHandler
class MAYAUSD_CORE_PUBLIC ProxyShapeCameraHandler : public CAMERAHANDLERBASE
{
public:
typedef std::shared_ptr<ProxyShapeCameraHandler> Ptr;

ProxyShapeCameraHandler(const Ufe::CameraHandler::Ptr&);
ProxyShapeCameraHandler(const CAMERAHANDLERBASE::Ptr&);

MAYAUSD_DISALLOW_COPY_MOVE_AND_ASSIGNMENT(ProxyShapeCameraHandler);

Expand All @@ -42,7 +48,7 @@ class MAYAUSD_CORE_PUBLIC ProxyShapeCameraHandler : public Ufe::CameraHandler
Ufe::Selection find_(const Ufe::Path& path) const override;

private:
Ufe::CameraHandler::Ptr _mayaCameraHandler;
CAMERAHANDLERBASE::Ptr _mayaCameraHandler;

}; // ProxyShapeCameraHandler

Expand Down
7 changes: 7 additions & 0 deletions lib/usdUfe/ufe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ if (UFE_HAS_NATIVE_TYPE_METADATA)
)
endif()

if (UFE_CAMERAHANDLER_HAS_FINDALL)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
UFE_CAMERAHANDLER_HAS_FINDALL=1
)
endif()

set(HEADERS
Global.h
SetVariantSelectionCommand.h
Expand Down
8 changes: 6 additions & 2 deletions lib/usdUfe/ufe/UsdCameraHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ PXR_NAMESPACE_USING_DIRECTIVE

namespace USDUFE_NS_DEF {

#if UFE_MAJOR_VERSION == 3 && UFE_CAMERAHANDLER_HAS_FINDALL
USDUFE_VERIFY_CLASS_SETUP(Ufe::CameraHandler_v3_4, UsdCameraHandler);
#else
USDUFE_VERIFY_CLASS_SETUP(Ufe::CameraHandler, UsdCameraHandler);
#endif // UFE_CAMERAHANDLER_HAS_FINDALL

/*static*/
UsdCameraHandler::Ptr UsdCameraHandler::create() { return std::make_shared<UsdCameraHandler>(); }
Expand All @@ -53,7 +57,7 @@ Ufe::Camera::Ptr UsdCameraHandler::camera(const Ufe::SceneItem::Ptr& item) const
return UsdCamera::create(usdItem);
}

#ifdef UFE_V4_FEATURES_AVAILABLE
#if defined(UFE_V4_FEATURES_AVAILABLE) || (UFE_MAJOR_VERSION == 3 && UFE_CAMERAHANDLER_HAS_FINDALL)
Ufe::Selection UsdCameraHandler::find_(const Ufe::Path& path) const
{
TF_VERIFY(path.runTimeId() == getUsdRunTimeId());
Expand All @@ -80,6 +84,6 @@ Ufe::Selection UsdCameraHandler::find(
}
return result;
}
#endif
#endif // UFE_MAJOR_VERSION == 3 && UFE_CAMERAHANDLER_HAS_FINDALL

} // namespace USDUFE_NS_DEF
8 changes: 6 additions & 2 deletions lib/usdUfe/ufe/UsdCameraHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
namespace USDUFE_NS_DEF {

//! \brief Interface to create a UsdCameraHandler interface object.
#if UFE_MAJOR_VERSION == 3 && UFE_CAMERAHANDLER_HAS_FINDALL
class USDUFE_PUBLIC UsdCameraHandler : public Ufe::CameraHandler_v3_4
#else
class USDUFE_PUBLIC UsdCameraHandler : public Ufe::CameraHandler
#endif // UFE_CAMERAHANDLER_HAS_FINDALL
{
public:
typedef std::shared_ptr<UsdCameraHandler> Ptr;
Expand All @@ -40,12 +44,12 @@ class USDUFE_PUBLIC UsdCameraHandler : public Ufe::CameraHandler
// Ufe::CameraHandler overrides
Ufe::Camera::Ptr camera(const Ufe::SceneItem::Ptr& item) const override;

#ifdef UFE_V4_FEATURES_AVAILABLE
#if defined(UFE_V4_FEATURES_AVAILABLE) || (UFE_MAJOR_VERSION == 3 && UFE_CAMERAHANDLER_HAS_FINDALL)
Ufe::Selection find_(const Ufe::Path& path) const override;

static Ufe::Selection
find(const Ufe::Path& stagePath, const Ufe::Path& searchPath, const PXR_NS::UsdPrim& prim);
#endif
#endif // UFE_CAMERAHANDLER_HAS_FINDALL

}; // UsdCameraHandler

Expand Down

0 comments on commit 1082fa2

Please sign in to comment.