Skip to content

Commit

Permalink
Merge pull request #467 from maya3d/duvalb/HYDRA-425/introduce_basic_…
Browse files Browse the repository at this point in the history
…hydra_scene_browser_plugin

Duvalb/hydra 425/introduce basic hydra scene browser plugin
  • Loading branch information
bduval2 authored and GitHub Enterprise committed Aug 8, 2023
2 parents c208b51 + cbdf916 commit f56ab48
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 1 deletion.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ set(PXR_OVERRIDE_PLUGINPATH_NAME PXR_PLUGINPATH_NAME
CACHE STRING "Name of env var USD searches to find plugins")

option(BUILD_HDSBLIB "Build Hydra Scene Browser library (hdui)." OFF)
# Note: if BUILD_HDSB_PLUGIN is set to 'ON', the Hydra Scene Browser library
# will be built by default because it is a dependency of the plugin.
option(BUILD_HDSB_PLUGIN "Build Hydra Scene Browser plugin for Maya." OFF)

#------------------------------------------------------------------------------
# internal flags to control build
Expand Down Expand Up @@ -169,10 +172,17 @@ endif()
#------------------------------------------------------------------------------
add_subdirectory(lib)

if(BUILD_HDSBLIB AND IS_WINDOWS)
if((BUILD_HDSB_PLUGIN OR BUILD_HDSBLIB) AND IS_WINDOWS) # Only build for windows until it can be tested on Linux and MacOS
add_subdirectory(lib/adskHydraSceneBrowser)
endif()

#------------------------------------------------------------------------------
# plugin
#------------------------------------------------------------------------------
if(BUILD_HDSB_PLUGIN AND IS_WINDOWS) # Only build for windows until it can be tested on Linux and MacOS
add_subdirectory(plugin/mayaHydraSceneBrowser)
endif()

#------------------------------------------------------------------------------
# install
#------------------------------------------------------------------------------
Expand Down
62 changes: 62 additions & 0 deletions plugin/mayaHydraSceneBrowser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# -----------------------------------------------------------------------------
# setup
# -----------------------------------------------------------------------------
set(TARGET_NAME mayaHydraSceneBrowser)
add_library(${TARGET_NAME} SHARED)

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

# -----------------------------------------------------------------------------
# compiler configuration
# -----------------------------------------------------------------------------
mayaUsd_compile_config(${TARGET_NAME})

target_compile_definitions(${TARGET_NAME}
PRIVATE
$<$<BOOL:${IS_MACOSX}>:OSMac_>
$<$<BOOL:${IS_LINUX}>:LINUX>
)

# -----------------------------------------------------------------------------
# include directories
# -----------------------------------------------------------------------------
target_include_directories(${TARGET_NAME}
PUBLIC
${MAYA_INCLUDE_DIRS}
)

# -----------------------------------------------------------------------------
# link libraries
# -----------------------------------------------------------------------------
target_link_libraries(${TARGET_NAME}
PUBLIC
${MAYA_LIBRARIES}
mayaHydraLib
adskHydraSceneBrowser
)

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

# -----------------------------------------------------------------------------
# run-time search paths
# -----------------------------------------------------------------------------
if(IS_MACOSX OR IS_LINUX)
mayaUsd_init_rpath(rpath "lib/maya")
mayaUsd_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib/adskHydraSceneBrowser")
mayaUsd_install_rpath(rpath ${TARGET_NAME})
endif()

# -----------------------------------------------------------------------------
# install
# -----------------------------------------------------------------------------
install(TARGETS ${TARGET_NAME}
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/maya)
46 changes: 46 additions & 0 deletions plugin/mayaHydraSceneBrowser/mayaHydraSceneBrowser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "mayaHydraSceneBrowser.h"

#include <mayaHydraLib/hydraUtils.h>
#include <mayaHydraLib/interfaceImp.h>

#include <sceneIndexDebuggerWidget.h>

#include <maya/MFnPlugin.h>
#include <maya/MArgList.h>
#include <maya/MGlobal.h>

PXR_NAMESPACE_USING_DIRECTIVE

using namespace MAYAHYDRA_NS;

HduiSceneIndexDebuggerWidget* widget = nullptr;
MStatus mayaHydraSceneBrowserCmd::doIt( const MArgList& args )
{
const SceneIndicesVector& sceneIndices = GetMayaHydraLibInterface().GetTerminalSceneIndices();
if (sceneIndices.empty()) {
return MS::kFailure;
}
else {
if (!widget) {
widget = new HduiSceneIndexDebuggerWidget();
}
widget->SetSceneIndex("", sceneIndices.front(), true);
widget->show();
}

return MS::kSuccess;
}

MStatus initializePlugin( MObject obj )
{
MFnPlugin plugin( obj, "Autodesk", "1.0", "Any" );
plugin.registerCommand( "mayaHydraSceneBrowser", mayaHydraSceneBrowserCmd::creator );
return MS::kSuccess;
}

MStatus uninitializePlugin( MObject obj )
{
MFnPlugin plugin( obj );
plugin.deregisterCommand( "mayaHydraSceneBrowser" );
return MS::kSuccess;
}
16 changes: 16 additions & 0 deletions plugin/mayaHydraSceneBrowser/mayaHydraSceneBrowser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef MH_SCENEBROWSER_CMD
#define MH_SCENEBROWSER_CMD

#include <maya/MPxCommand.h>

class mayaHydraSceneBrowserCmd : public MPxCommand
{
public:
static void* creator() { return new mayaHydraSceneBrowserCmd(); }

static const MString name;

MStatus doIt(const MArgList& args) override;
};

#endif // MH_SCENEBROWSER_CMD

0 comments on commit f56ab48

Please sign in to comment.