diff --git a/cmake/modules/FindUFE.cmake b/cmake/modules/FindUFE.cmake index 261aff70e9..15cb7a52d3 100644 --- a/cmake/modules/FindUFE.cmake +++ b/cmake/modules/FindUFE.cmake @@ -9,6 +9,7 @@ # UFE_LIBRARY Path to UFE library # UFE_INCLUDE_DIR Path to the UFE include directory # UFE_VERSION UFE version (major.minor.patch) from ufe.h +# UFE_LIGHTS_SUPPORT Presence of UFE lights support # find_path(UFE_INCLUDE_DIR @@ -97,3 +98,9 @@ if(UFE_FOUND) message(STATUS "UFE library: ${UFE_LIBRARY}") message(STATUS "UFE version: ${UFE_VERSION}") 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") + message(STATUS "Maya has UFE lights API") +endif() \ No newline at end of file diff --git a/lib/mayaUsd/ufe/CMakeLists.txt b/lib/mayaUsd/ufe/CMakeLists.txt index 639f6c17d2..3111e4fd28 100644 --- a/lib/mayaUsd/ufe/CMakeLists.txt +++ b/lib/mayaUsd/ufe/CMakeLists.txt @@ -80,15 +80,21 @@ if(CMAKE_UFE_V3_FEATURES_AVAILABLE) ) endif() -if(CMAKE_UFE_V4_FEATURES_AVAILABLE) - if (${UFE_PREVIEW_VERSION_NUM} GREATER_EQUAL 4007) - target_sources(${PROJECT_NAME} - PRIVATE - UsdLight.cpp - UsdLightHandler.cpp - ) - endif() +message(STATUS "UFE_LIGHTS_SUPPORT is ${UFE_LIGHTS_SUPPORT}") +if (UFE_LIGHTS_SUPPORT) + target_sources(${PROJECT_NAME} + PRIVATE + UsdLight.cpp + UsdLightHandler.cpp + ) + target_compile_definitions(${PROJECT_NAME} + PRIVATE + UFE_LIGHTS_SUPPORT=1 + ) +endif() + +if(CMAKE_UFE_V4_FEATURES_AVAILABLE) if (${UFE_PREVIEW_VERSION_NUM} GREATER_EQUAL 4001) target_sources(${PROJECT_NAME} PRIVATE @@ -193,14 +199,14 @@ if(CMAKE_UFE_V3_FEATURES_AVAILABLE) ) endif() -if(CMAKE_UFE_V4_FEATURES_AVAILABLE) - if (${UFE_PREVIEW_VERSION_NUM} GREATER_EQUAL 4007) - list(APPEND HEADERS - UsdLight.h - UsdLightHandler.h - ) - endif() +if (UFE_LIGHTS_SUPPORT) + list(APPEND HEADERS + UsdLight.h + UsdLightHandler.h + ) +endif() +if(CMAKE_UFE_V4_FEATURES_AVAILABLE) if (${UFE_PREVIEW_VERSION_NUM} GREATER_EQUAL 4001) list(APPEND HEADERS UsdShaderNodeDef.h diff --git a/lib/mayaUsd/ufe/Global.cpp b/lib/mayaUsd/ufe/Global.cpp index 14a961bb8c..f7ddef4af1 100644 --- a/lib/mayaUsd/ufe/Global.cpp +++ b/lib/mayaUsd/ufe/Global.cpp @@ -44,10 +44,10 @@ #include #include #endif -#ifdef UFE_V4_FEATURES_AVAILABLE -#if (UFE_PREVIEW_VERSION_NUM >= 4007) +#if UFE_LIGHTS_SUPPORT #include #endif +#ifdef UFE_V4_FEATURES_AVAILABLE #if (UFE_PREVIEW_VERSION_NUM >= 4001) #include #endif @@ -179,7 +179,7 @@ MStatus initialize() handlers.uiInfoHandler = UsdUIInfoHandler::create(); handlers.cameraHandler = UsdCameraHandler::create(); #ifdef UFE_V4_FEATURES_AVAILABLE -#if (UFE_PREVIEW_VERSION_NUM >= 4007) +#if UFE_LIGHTS_SUPPORT handlers.lightHandler = UsdLightHandler::create(); #endif #if (UFE_PREVIEW_VERSION_NUM >= 4001) @@ -227,6 +227,12 @@ MStatus initialize() g_USDRtid = runTimeMgr.register_(kUSDRunTimeName, handlers); MayaUsd::ufe::UsdUIUfeObserver::create(); +#ifndef UFE_V4_FEATURES_AVAILABLE +#if UFE_LIGHTS_SUPPORT + runTimeMgr.setLightHandler(g_USDRtid, UsdLightHandler::create()); +#endif +#endif + #ifdef HAVE_PATH_MAPPING g_MayaPathMappingHandler = runTimeMgr.pathMappingHandler(g_MayaRtid); auto pathMappingHndlr = UsdPathMappingHandler::create();