Skip to content

Commit

Permalink
HYDRA-307: Add the FootPrint node as an Hydra example (#75)
Browse files Browse the repository at this point in the history
* HYDRA-307: Add the FootPrint node as an Hydra example

* Remove mtoa from test scenes.

* Remove some mtoa attributes in the scenes

* HYDRA-307 : Fixes from code review.

* HYDRA-307 : Fix an issue with multiple nodes

* HYDRA-307 : Avoid crashing when mayaHydra is not loaded and creating this node

* Forgot a file.

* HYDRA-307 : modifications from code review

* Use a postConstructor method

* Fix tests failing.

* Do not use localized strings yet for error messages.

* HYDRA-307 : Modifs from code review.

* HYDRA-307 : Integrate changes from Pierre.

* HYDRA-307 : Remove usage of obsolete attributes, fix tests.
  • Loading branch information
lanierd-adsk authored Mar 6, 2024
1 parent 5c4eac3 commit b4fb348
Show file tree
Hide file tree
Showing 35 changed files with 1,251 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ void DataProducerSceneIndexDataBase::_CreateSceneIndexChainForDataProducerSceneI
HdSceneIndexBaseRefPtr DataProducerSceneIndexDataBase::_CreateUsdStageSceneIndexChain(HdSceneIndexBaseRefPtr const & inputStageSceneIndex)
{
_CreateSceneIndexChainForDataProducerSceneIndexWithDCCNode(inputStageSceneIndex);
UpdateHydraTransformFromParentPath();//Update the transform, this is useful when deleting the node and undoing it
return _lastSceneIndexChain;
}

Expand All @@ -136,6 +135,7 @@ void DataProducerSceneIndexDataBase::_CreateSceneIndexChainForDataProducerSceneI
{
_rootOverridesSceneIndex = UsdImagingRootOverridesSceneIndex::New(inputSceneIndex);
_lastSceneIndexChain = _rootOverridesSceneIndex;
UpdateHydraTransformFromParentPath();//Update the transform, this is useful when deleting the node and undoing it
}

void DataProducerSceneIndexDataBase::_CreateSceneIndexChainForDataProducerSceneIndexWithoutDCCNode(HdSceneIndexBaseRefPtr const & inputSceneIndex)
Expand Down
1 change: 1 addition & 0 deletions lib/mayaHydra/flowViewportAPIExamples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory(flowViewportAPIMayaLocator)
add_subdirectory(footPrintNode)
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ target_compile_definitions(${TARGET_NAME}
# private atm because M3dView is only used in .cpp right now
# gcc will NOT set this automatically
$<$<BOOL:${IS_LINUX}>:LINUX>
# Not sure if msvcc sets this automatically, but won't hurt to redefine
$<$<BOOL:${IS_WINDOWS}>:_WIN32>
MFB_ALT_PACKAGE_NAME="${TARGET_NAME}" # This is used by Pixar HdSceneIndexPluginRegistry::Define to create a unique name
)

Expand All @@ -38,19 +36,15 @@ if(DEFINED MAYAUSD_VERSION)
)
endif()

if(DEFINED MAYAHYDRA_VERSION)
target_compile_definitions(${TARGET_NAME}
PRIVATE
MAYAHYDRA_VERSION=${MAYAHYDRA_VERSION}
)
endif()
if(DEFINED MAYAHYDRA_CUT_ID)
target_compile_definitions(${TARGET_NAME}
PRIVATE
MAYAHYDRA_CUT_ID=${MAYAHYDRA_CUT_ID}
)
if(NOT DEFINED MAYAHYDRA_VERSION)
message(FATAL_ERROR "No MAYAHYDRA_VERSION defined, aborting configuration." )
endif()

target_compile_definitions(${TARGET_NAME}
PRIVATE
MAYAHYDRA_VERSION=${MAYAHYDRA_VERSION}
)

mayaHydra_compile_config(${TARGET_NAME})

# -----------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ namespace
}//end of anonymous namespace

//Initialization of static members
MTypeId FlowViewportAPIMayaLocator::id( 0x90517 );
MTypeId FlowViewportAPIMayaLocator::id( 0x00080101 );
MString FlowViewportAPIMayaLocator::nodeClassification("hydraAPIExample/geometry/FlowViewportAPIMayaLocator");

MObject FlowViewportAPIMayaLocator::mNumCubeLevelsX;
Expand Down Expand Up @@ -554,7 +554,7 @@ MStatus FlowViewportAPIMayaLocator::initialize()
MAKE_INPUT(nAttr);
CHECK_MSTATUS ( nAttr.setDefault(5.0, 5.0, 5.0) );

//Create dummy output attribute to trigger a call to the compute function on demand. as it's in the compute fonction that we add our scene indices
//Create dummy input attribute to trigger a call to the compute function on demand. as it's in the compute fonction that we add our scene indices
mDummyInput = nAttr.create("dummyInput", "dI", MFnNumericData::kInt, 1.0, &status);
MAKE_INPUT(nAttr);
CHECK_MSTATUS ( nAttr.setDefault(1) );
Expand Down
97 changes: 97 additions & 0 deletions lib/mayaHydra/flowViewportAPIExamples/footPrintNode/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
set(TARGET_NAME mayaHydraFootPrintNode)

add_library(${TARGET_NAME} SHARED)

# -----------------------------------------------------------------------------
# sources
# -----------------------------------------------------------------------------
target_sources(${TARGET_NAME}
PRIVATE
mhFootPrintNode.cpp
)

set(HEADERS
PRIVATE
)

# -----------------------------------------------------------------------------
# compiler configuration
# -----------------------------------------------------------------------------
target_compile_definitions(${TARGET_NAME}
PRIVATE
# M3dView needs this (technically, MNativeWindowHdl.h)
# private atm because M3dView is only used in .cpp right now
# gcc will NOT set this automatically
$<$<BOOL:${IS_LINUX}>:LINUX>
MFB_ALT_PACKAGE_NAME="${TARGET_NAME}" # This is used by Pixar HdSceneIndexPluginRegistry::Define to create a unique name
)

# -----------------------------------------------------------------------------
# include directories
# -----------------------------------------------------------------------------
if(DEFINED MAYAUSD_VERSION)
target_compile_definitions(${TARGET_NAME}
PRIVATE
MAYAUSD_VERSION=${MAYAUSD_VERSION}
)
endif()

if(NOT DEFINED MAYAHYDRA_VERSION)
message(FATAL_ERROR "No MAYAHYDRA_VERSION defined, aborting configuration." )
endif()

target_compile_definitions(${TARGET_NAME}
PRIVATE
MAYAHYDRA_VERSION=${MAYAHYDRA_VERSION}
)

mayaHydra_compile_config(${TARGET_NAME})

# -----------------------------------------------------------------------------
# link libraries
# -----------------------------------------------------------------------------
target_link_libraries(${TARGET_NAME}
PRIVATE
mayaHydraLib
)

# -----------------------------------------------------------------------------
# properties
# -----------------------------------------------------------------------------
maya_set_plugin_properties(${TARGET_NAME})

# -----------------------------------------------------------------------------
# run-time search paths
# -----------------------------------------------------------------------------
if(IS_MACOSX OR IS_LINUX)
mayaUsd_init_rpath(rpath "lib/maya")
if(DEFINED MAYAUSD_TO_USD_RELATIVE_PATH)
mayaUsd_add_rpath(rpath "../../${MAYAUSD_TO_USD_RELATIVE_PATH}/lib")
if (IS_LINUX)
mayaUsd_add_rpath(rpath "../../${MAYAUSD_TO_USD_RELATIVE_PATH}/lib64")
endif()
if(IS_MACOSX)
mayaUsd_add_rpath(rpath "../../../../Maya.app/Contents/MacOS")
endif()
elseif(DEFINED PXR_USD_LOCATION)
mayaUsd_add_rpath(rpath "${PXR_USD_LOCATION}/lib")
endif()

mayaUsd_add_rpath(rpath "../")
mayaUsd_install_rpath(rpath ${TARGET_NAME})
endif()

# -----------------------------------------------------------------------------
# install
# -----------------------------------------------------------------------------
install(TARGETS ${TARGET_NAME}
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/maya)

if(IS_WINDOWS)
install(FILES $<TARGET_PDB_FILE:${TARGET_NAME}>
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/maya OPTIONAL)
endif()

set(LIBFILENAME ${CMAKE_SHARED_LIBRARY_PREFIX}${TARGET_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
set(PLUG_INFO_LIBRARY_PATH "../../../${LIBFILENAME}")
set(PLUG_INFO_RESOURCE_PATH "resources")
Loading

0 comments on commit b4fb348

Please sign in to comment.