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

UFE light support in versions below UFE 4 (particularly UFE 3.1) #2417

Merged
merged 1 commit into from
Jun 17, 2022
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
7 changes: 7 additions & 0 deletions cmake/modules/FindUFE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
36 changes: 21 additions & 15 deletions lib/mayaUsd/ufe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions lib/mayaUsd/ufe/Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
#include <mayaUsd/ufe/PulledObjectHierarchyHandler.h>
#include <mayaUsd/ufe/UsdPathMappingHandler.h>
#endif
#ifdef UFE_V4_FEATURES_AVAILABLE
#if (UFE_PREVIEW_VERSION_NUM >= 4007)
#if UFE_LIGHTS_SUPPORT
#include <mayaUsd/ufe/UsdLightHandler.h>
#endif
#ifdef UFE_V4_FEATURES_AVAILABLE
#if (UFE_PREVIEW_VERSION_NUM >= 4001)
#include <mayaUsd/ufe/UsdShaderNodeDefHandler.h>
#endif
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down