From cc0df71f3ef1d96d91bd81aed513c27b12ac58ef Mon Sep 17 00:00:00 2001 From: Huidong Chen Date: Sun, 28 Jul 2019 19:37:35 -0400 Subject: [PATCH 01/22] MAYA-99646 minor build fix (#78) --- lib/render/vp2RenderDelegate/proxyRenderDelegate.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/render/vp2RenderDelegate/proxyRenderDelegate.h b/lib/render/vp2RenderDelegate/proxyRenderDelegate.h index 52dd12de1b..336c9552bd 100644 --- a/lib/render/vp2RenderDelegate/proxyRenderDelegate.h +++ b/lib/render/vp2RenderDelegate/proxyRenderDelegate.h @@ -104,7 +104,7 @@ class ProxyRenderDelegate : public MHWRender::MPxSubSceneOverride void SelectionChanged(); MAYAUSD_CORE_PUBLIC - bool ProxyRenderDelegate::IsFullySelected(const SdfPath& path) const; + bool IsFullySelected(const SdfPath& path) const; private: ProxyRenderDelegate(const ProxyRenderDelegate&) = delete; From 5bd561283e3b7112ae99be930aa186ca83838b49 Mon Sep 17 00:00:00 2001 From: Hamed Sabri Date: Mon, 29 Jul 2019 14:25:47 -0400 Subject: [PATCH 02/22] Update README.md Fix typo in README! --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 033990ab85..00d0ec6f39 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Pixar maintains a list of contributors to USD in their documentation [here](http Both Animal Logic and Pixar have their own Google interest groups which will remain great places to go with questions. Pixar forum is [here](https://groups.google.com/forum/#!forum/usd-interest) -Animal Lock forum is [here](https://groups.google.com/forum/#!forum/al_usdmaya-discussion) +Animal Logic forum is [here](https://groups.google.com/forum/#!forum/al_usdmaya-discussion) ## Detailed Documentation From 27173060a79df730eb069bb4edffc1e158f88e11 Mon Sep 17 00:00:00 2001 From: Sean Donnelly Date: Mon, 29 Jul 2019 14:41:17 -0400 Subject: [PATCH 03/22] MAYA-99741 - Build all 3 plugins build/work in sandbox (#77) * MAYA-99741 - Build all 3 plugins build/work in sandbox * Override postConstructor in Maya & Pixar proxy shape and call the base class. * Remove from the base class: PxrMayaHdImagingShape::GetOrCreateInstance(); * From all three plugins (Maya/Pixar/AL) call the base class and in Maya/Pixar (not AL) put the call to GetOrCreateInstance and conditionally call it using MayaUsdProxyShapePlugin::useVP2_NativeUSD_Rendering() * MAYA-99741 - Build all 3 plugins build/work in sandbox * Oops, fixed mistake in logic. --- lib/nodes/proxyShapeBase.cpp | 4 ---- plugin/adsk/plugin/ProxyShape.cpp | 15 +++++++++++++++ plugin/adsk/plugin/ProxyShape.h | 2 ++ .../AL_USDMaya/AL/usdmaya/nodes/ProxyShape.cpp | 2 +- .../lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShape.h | 2 ++ plugin/pxr/maya/lib/usdMaya/proxyShape.cpp | 14 ++++++++++++++ plugin/pxr/maya/lib/usdMaya/proxyShape.h | 2 ++ 7 files changed, 36 insertions(+), 5 deletions(-) diff --git a/lib/nodes/proxyShapeBase.cpp b/lib/nodes/proxyShapeBase.cpp index 4202867e97..545297fad9 100644 --- a/lib/nodes/proxyShapeBase.cpp +++ b/lib/nodes/proxyShapeBase.cpp @@ -348,10 +348,6 @@ void MayaUsdProxyShapeBase::postConstructor() { setRenderable(true); - - // This shape uses Hydra for imaging, so make sure that the - // pxrHdImagingShape is setup. - PxrMayaHdImagingShape::GetOrCreateInstance(); } /* virtual */ diff --git a/plugin/adsk/plugin/ProxyShape.cpp b/plugin/adsk/plugin/ProxyShape.cpp index 7f61b08262..3d1b6cab32 100644 --- a/plugin/adsk/plugin/ProxyShape.cpp +++ b/plugin/adsk/plugin/ProxyShape.cpp @@ -15,6 +15,9 @@ // #include "ProxyShape.h" +#include +#include + MAYAUSD_NS_DEF { // ======================================================== @@ -54,4 +57,16 @@ ProxyShape::~ProxyShape() // } +void ProxyShape::postConstructor() +{ + ParentClass::postConstructor(); + + if (!MayaUsdProxyShapePlugin::useVP2_NativeUSD_Rendering()) + { + // This shape uses Hydra for imaging, so make sure that the + // pxrHdImagingShape is setup. + PXR_NS::PxrMayaHdImagingShape::GetOrCreateInstance(); + } +} + } // MayaUsd diff --git a/plugin/adsk/plugin/ProxyShape.h b/plugin/adsk/plugin/ProxyShape.h index 5f45c474e2..e4d58925dc 100644 --- a/plugin/adsk/plugin/ProxyShape.h +++ b/plugin/adsk/plugin/ProxyShape.h @@ -41,6 +41,8 @@ class ProxyShape : public MayaUsdProxyShapeBase MAYAUSD_PLUGIN_PUBLIC static MStatus initialize(); + void postConstructor() override; + private: ProxyShape(); diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShape.cpp b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShape.cpp index 94594089a7..1e6eb7ac02 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShape.cpp +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShape.cpp @@ -1608,7 +1608,7 @@ void ProxyShape::constructLockPrims() void ProxyShape::postConstructor() { TF_DEBUG(ALUSDMAYA_EVALUATION).Msg("ProxyShape::postConstructor\n"); - setRenderable(true); + ParentClass::postConstructor(); } //---------------------------------------------------------------------------------------------------------------------- diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShape.h b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShape.h index c98812a0fa..07009e215e 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShape.h +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShape.h @@ -260,6 +260,8 @@ class ProxyShape friend class ProxyShapeUI; friend class StageReloadGuard; friend class ProxyDrawOverride; + + typedef MayaUsdProxyShapeBase ParentClass; public: /// a method that registers all of the events in the ProxyShape diff --git a/plugin/pxr/maya/lib/usdMaya/proxyShape.cpp b/plugin/pxr/maya/lib/usdMaya/proxyShape.cpp index d5bf58d7b4..57f110321f 100644 --- a/plugin/pxr/maya/lib/usdMaya/proxyShape.cpp +++ b/plugin/pxr/maya/lib/usdMaya/proxyShape.cpp @@ -16,6 +16,7 @@ #include "usdMaya/proxyShape.h" #include +#include #include #include #include @@ -309,4 +310,17 @@ UsdMayaProxyShape::canBeSoftSelected() const return softSelHandle.asBool(); } +void UsdMayaProxyShape::postConstructor() +{ + ParentClass::postConstructor(); + + if (!MayaUsdProxyShapePlugin::useVP2_NativeUSD_Rendering()) + { + // This shape uses Hydra for imaging, so make sure that the + // pxrHdImagingShape is setup. + PxrMayaHdImagingShape::GetOrCreateInstance(); + } +} + + PXR_NAMESPACE_CLOSE_SCOPE diff --git a/plugin/pxr/maya/lib/usdMaya/proxyShape.h b/plugin/pxr/maya/lib/usdMaya/proxyShape.h index 3d9a44507b..27910b4eab 100644 --- a/plugin/pxr/maya/lib/usdMaya/proxyShape.h +++ b/plugin/pxr/maya/lib/usdMaya/proxyShape.h @@ -110,6 +110,8 @@ class UsdMayaProxyShape : public MayaUsdProxyShapeBase MDataHandle& dataHandle, MDGContext& ctx) override; + void postConstructor() override; + protected: // Use the variant key to get the session layer from the prim path. PXRUSDMAYA_API From a66591c5b54a15cc5b5c45c4c9525e3f42622dbd Mon Sep 17 00:00:00 2001 From: Sean Donnelly Date: Mon, 29 Jul 2019 16:36:11 -0400 Subject: [PATCH 04/22] MAYA-99741 - Build all 3 plugins build/work in sandbox (#81) * Add back the jinja.cmake file, which is only used when building inside the Maya build. * Make sure the build and install folders have the variant. --- CMakeLists.txt | 7 +++++++ build.py | 33 +++++++++++++++-------------- cmake/jinja.cmake | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 15 deletions(-) create mode 100644 cmake/jinja.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 71e4fe7f75..48d073c28e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,13 @@ include(cmake/python.cmake) include(cmake/utils.cmake) include(cmake/usd.cmake) +# The building of the schemas requires some extra python packages which may or +# may not be installed. If they aren't we provide an option to add them from +# a python egg. +if (BUILD_USDMAYA_SCHEMAS) + include(cmake/jinja.cmake) +endif() + #============================================================================== # Compiler #============================================================================== diff --git a/build.py b/build.py index e72347dc0d..8ac684c22d 100644 --- a/build.py +++ b/build.py @@ -157,7 +157,7 @@ def Run(cmd, logCommandOutput=True): """Run the specified command in a subprocess.""" PrintInfo('Running "{cmd}"'.format(cmd=cmd)) - with open(context.logFileName, "a") as logfile: + with open(context.logFileLocation, "a") as logfile: logfile.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M")) logfile.write("\n") logfile.write(cmd) @@ -183,10 +183,10 @@ def Run(cmd, logCommandOutput=True): # If verbosity >= 3, we'll have already been printing out command output # so no reason to print the log file again. if verbosity < 3: - with open(context.logFileName, "r") as logfile: + with open(context.logFileLocation, "r") as logfile: Print(logfile.read()) raise RuntimeError("Failed to run '{cmd}'\nSee {log} for more details." - .format(cmd=cmd, log=os.path.abspath(context.logFileName))) + .format(cmd=cmd, log=os.path.abspath(context.logFileLocation))) def BuildVariant(context): if context.buildDebug: @@ -227,11 +227,13 @@ def RunCMake(context, force, extraArgs=None): source code is located in the current working directory.""" srcDir = os.getcwd() - instDir = os.path.join(context.instDir, BuildVariant(context)) - buildDir = os.path.join(context.buildDir, os.path.split(srcDir)[1]) + instDir = context.instDir + buildDir = context.buildDir if force and os.path.isdir(buildDir): shutil.rmtree(buildDir) + if force and os.path.isdir(instDir): + shutil.rmtree(instDir) if not os.path.isdir(buildDir): os.makedirs(buildDir) @@ -366,21 +368,22 @@ def __init__(self, args): self.mayaUsdSrcDir = os.path.normpath( os.path.join(os.path.abspath(os.path.dirname(__file__)))) + # Build type + # Must be done early, so we can call BuildVariant(self) + self.buildDebug = args.build_debug + self.buildRelease = args.build_release + self.buildRelWithDebug = args.build_relwithdebug + # Workspace directory self.workspaceDir = os.path.abspath(args.workspace_location) # Build directory self.buildDir = (os.path.abspath(args.build_location) if args.build_location - else os.path.join(self.workspaceDir, "build")) + else os.path.join(self.workspaceDir, "build", BuildVariant(self))) # Install directory self.instDir = (os.path.abspath(args.install_location) if args.install_location - else os.path.join(self.workspaceDir, "install")) - - # Build type - self.buildDebug = args.build_debug - self.buildRelease = args.build_release - self.buildRelWithDebug = args.build_relwithdebug + else os.path.join(self.workspaceDir, "install", BuildVariant(self))) # Forced to be built self.forceBuild = args.force_clean_build @@ -406,8 +409,8 @@ def __init__(self, args): if args.devkit_location else None) # Log File Name - self.logFileName="build_log.txt" - self.logFileLocation=os.path.join(self.buildDir, os.path.basename(os.getcwd()),self.logFileName) + logFileName="build_log.txt" + self.logFileLocation=os.path.join(self.buildDir, logFileName) # Build arguments self.buildArgs = list() @@ -454,7 +457,7 @@ def __init__(self, args): InstallMayaUSD(context, context.forceBuild, context.buildArgs) # Ensure directory structure is created and is writable. -for dir in [context.workspaceDir, context.buildDir]: +for dir in [context.workspaceDir, context.buildDir, context.instDir]: try: if os.path.isdir(dir): testFile = os.path.join(dir, "canwrite") diff --git a/cmake/jinja.cmake b/cmake/jinja.cmake new file mode 100644 index 0000000000..116e8d8f5d --- /dev/null +++ b/cmake/jinja.cmake @@ -0,0 +1,53 @@ +#- +# ======================================================================= +# Copyright 2018 Autodesk, Inc. All rights reserved. +# +# This computer source code and related instructions and comments are the +# unpublished confidential and proprietary information of Autodesk, Inc. +# and are protected under applicable copyright and trade secret law. They +# may not be disclosed to, copied or used by any third party without the +# prior written consent of Autodesk, Inc. +# ======================================================================= +#+ + +#------------------------------------------------------------------------------ +# +# Gets the Jinja2 and the dependant MarkupSafe python libraries from +# artifactory and set them up. +# +function(init_markupsafe) + + find_python_module(markupsafe) + + if (NOT MARKUPSAFE_FOUND) + if (NOT MARKUPSAFE_LOCATION) + message(FATAL_ERROR "MARKUPSAFE_LOCATION not set") + endif() + + set(MARKUPSAFE_ROOT "${MARKUPSAFE_LOCATION}/src") + + # Add MarkupSafe to the python path so that Jinja2 can run properly. + append_path_to_env_var("PYTHONPATH" "${MARKUPSAFE_ROOT}") + endif() + +endfunction() + +function(init_jinja) + + find_python_module(jinja2) + + if (NOT JINJA2_FOUND) + if (NOT JINJA_LOCATION) + message(FATAL_ERROR "JINJA_LOCATION not set") + endif() + + set(JINJA_ROOT "${JINJA_LOCATION}") + + # Add Jinja2 to the python path so that usdGenSchemas can run properly. + append_path_to_env_var("PYTHONPATH" "${JINJA_ROOT}") + endif() + +endfunction() + +init_markupsafe() +init_jinja() From c034731ff4108db5abef9a603c2a416f492d8901 Mon Sep 17 00:00:00 2001 From: Huidong Chen Date: Tue, 30 Jul 2019 11:52:14 -0400 Subject: [PATCH 05/22] MAYA-99646 Complete selection highlight support for VP2RenderDelegate (#83) * MAYA-99646 Fix selection highlight issues * Selection highlight for proxy selection from Outliner. * Selection highlight for Xform prims from Outliner. * Selection highlight for USD instancing objects. * MAYA-99646 capitalize function name * MAYA-99646 Differentiate the processing for "wasProxySelected" and "isProxySelected" case. --- lib/render/vp2RenderDelegate/mesh.cpp | 39 +++++++---- lib/render/vp2RenderDelegate/mesh.h | 4 +- .../vp2RenderDelegate/proxyRenderDelegate.cpp | 69 +++++++++++++------ .../vp2RenderDelegate/proxyRenderDelegate.h | 8 ++- 4 files changed, 83 insertions(+), 37 deletions(-) diff --git a/lib/render/vp2RenderDelegate/mesh.cpp b/lib/render/vp2RenderDelegate/mesh.cpp index 480d48b0d4..98f2ef7cf4 100644 --- a/lib/render/vp2RenderDelegate/mesh.cpp +++ b/lib/render/vp2RenderDelegate/mesh.cpp @@ -240,8 +240,9 @@ void HdVP2Mesh::_InitRepr(const TfToken& reprToken, HdDirtyBits* dirtyBits) { // to share draw items with future implementation of wireframe mode. If // it won't, we can then define a customized "selectionHighlight" repr. if (reprToken == HdReprTokens->wire) { - bool fullySelected = param->GetDrawScene().IsFullySelected(GetId()); - if (_UpdateSelectedState(repr, dirtyBits, fullySelected)) + const bool selected = param->GetDrawScene().IsProxySelected() || + (param->GetDrawScene().GetPrimSelectionState(GetId()) != nullptr); + if (_EnableWireDrawItems(repr, dirtyBits, selected)) return; } else if (!isNew) { @@ -679,12 +680,26 @@ void HdVP2Mesh::_UpdateDrawItem( renderIndex.GetInstancer(GetInstancerId()); VtMatrix4dArray transforms = static_cast(instancer)-> - ComputeInstanceTransforms(GetId()); + ComputeInstanceTransforms(meshId); double instanceMatrix[4][4]; - for (size_t i = 0; i < transforms.size(); ++i) { - transforms[i].Get(instanceMatrix); - stateToCommit._instanceTransforms.append(MMatrix(instanceMatrix)); + + if ((desc.geomStyle == HdMeshGeomStyleHullEdgeOnly) && + !param->GetDrawScene().IsProxySelected()) { + if (auto state = param->GetDrawScene().GetPrimSelectionState(meshId)) { + for (const auto& indexArray : state->instanceIndices) { + for (const auto index : indexArray) { + transforms[index].Get(instanceMatrix); + stateToCommit._instanceTransforms.append(MMatrix(instanceMatrix)); + } + } + } + } + else { + for (size_t i = 0; i < transforms.size(); ++i) { + transforms[i].Get(instanceMatrix); + stateToCommit._instanceTransforms.append(MMatrix(instanceMatrix)); + } } } @@ -861,20 +876,20 @@ MHWRender::MRenderItem* HdVP2Mesh::_CreateRenderItem( return renderItem; } -/*! \brief Update the selected state and enable/disable the wireframe draw item. +/*! \brief Enable or disable the wireframe draw item. \return True if no draw items should be created for the repr. */ -bool HdVP2Mesh::_UpdateSelectedState( +bool HdVP2Mesh::_EnableWireDrawItems( const HdReprSharedPtr& repr, HdDirtyBits* dirtyBits, - bool fullySelected) + bool enable) { - if (_fullySelected == fullySelected) { + if (_wireItemsEnabled == enable) { return true; } - _fullySelected = fullySelected; + _wireItemsEnabled = enable; if (repr) { const HdRepr::DrawItems& items = repr->GetDrawItems(); @@ -882,7 +897,7 @@ bool HdVP2Mesh::_UpdateSelectedState( if (auto drawItem = static_cast(item)) { const HdMeshReprDesc& reprDesc = drawItem->GetReprDesc(); if (reprDesc.geomStyle == HdMeshGeomStyleHullEdgeOnly) { - drawItem->Enable(fullySelected); + drawItem->Enable(enable); *dirtyBits |= HdChangeTracker::DirtyVisibility; return true; } diff --git a/lib/render/vp2RenderDelegate/mesh.h b/lib/render/vp2RenderDelegate/mesh.h index 340c1c0fd1..0971ba3a79 100644 --- a/lib/render/vp2RenderDelegate/mesh.h +++ b/lib/render/vp2RenderDelegate/mesh.h @@ -59,7 +59,7 @@ class HdVP2Mesh final : public HdMesh { HdSceneDelegate*, HdVP2DrawItem*, HdDirtyBits*, const HdMeshReprDesc&, bool requireSmoothNormals, bool requireFlatNormals); - bool _UpdateSelectedState(const HdReprSharedPtr& repr, HdDirtyBits* dirtyBits, bool fullySelected); + bool _EnableWireDrawItems(const HdReprSharedPtr& repr, HdDirtyBits* dirtyBits, bool enable); MHWRender::MRenderItem* _CreateRenderItem(const MString& name, const HdMeshReprDesc& desc) const; MHWRender::MRenderItem* _CreateSmoothHullRenderItem(const MString& name) const; @@ -81,7 +81,7 @@ class HdVP2Mesh final : public HdMesh { // TODO: Define HdVP2MeshSharedData to hold extra shared data specific to VP2? std::unique_ptr _positionsBuffer; //!< Per-Rprim position buffer to be shared among render items - bool _fullySelected { false }; //!< Whether the Rprim is fully selected. + bool _wireItemsEnabled{ false }; //!< Whether draw items for the wire repr are enabled using HdVP2DrawItemCollection = std::vector>; HdVP2DrawItemCollection _createdDrawItems; //!< In current design, HdRepr doesn't take the ownership of draw items. diff --git a/lib/render/vp2RenderDelegate/proxyRenderDelegate.cpp b/lib/render/vp2RenderDelegate/proxyRenderDelegate.cpp index 31228387f4..af5978aadc 100644 --- a/lib/render/vp2RenderDelegate/proxyRenderDelegate.cpp +++ b/lib/render/vp2RenderDelegate/proxyRenderDelegate.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -435,11 +436,6 @@ void ProxyRenderDelegate::SelectionChanged() void ProxyRenderDelegate::_FilterSelection() { #if defined(WANT_UFE_BUILD) - // HdC_TODO: add selection highlight support: - // - Maya proxy and its DAG parents. - // - USD Xform prims. - // - Instancing prims. - MayaUsdProxyShapeBase* proxyShape = getProxyShape(); if (proxyShape == nullptr) { return; @@ -462,7 +458,9 @@ void ProxyRenderDelegate::_FilterSelection() const SdfPath usdPath(segments[1].string()); const SdfPath idxPath(_sceneDelegate->GetPathForIndex(usdPath)); - _selection->AddRprim(HdSelection::HighlightModeSelect, idxPath); + + _sceneDelegate->PopulateSelection(HdSelection::HighlightModeSelect, + idxPath, UsdImagingDelegate::ALL_INSTANCES, _selection); } #endif } @@ -473,35 +471,64 @@ void ProxyRenderDelegate::_FilterSelection() */ bool ProxyRenderDelegate::_UpdateSelectionHighlight() { - SdfPathVector oldSelection = - _selection->GetSelectedPrimPaths(HdSelection::HighlightModeSelect); + bool retVal = false; + + const bool wasProxySelected = _isProxySelected; + + MDagPath proxyDagPath; + MDagPath::getAPathTo(_mObject, proxyDagPath); + auto status = MHWRender::MGeometryUtilities::displayStatus(proxyDagPath); + _isProxySelected = ((status == MHWRender::kHilite) || (status == MHWRender::kLead)); - _FilterSelection(); + constexpr HdSelection::HighlightMode mode = HdSelection::HighlightModeSelect; - SdfPathVector newSelection = - _selection->GetSelectedPrimPaths(HdSelection::HighlightModeSelect); + SdfPathVector rootPaths; - if (!oldSelection.empty() || !newSelection.empty()) { - SdfPathVector rootPaths = std::move(oldSelection); - rootPaths.reserve(rootPaths.size() + newSelection.size()); - rootPaths.insert(rootPaths.end(), newSelection.begin(), newSelection.end()); + if (_isProxySelected) { + rootPaths.push_back(SdfPath::AbsoluteRootPath()); + retVal = true; + } + else if (wasProxySelected) { + rootPaths.push_back(SdfPath::AbsoluteRootPath()); + _FilterSelection(); + retVal = !_selection->GetSelectedPrimPaths(mode).empty(); + } + else { + SdfPathVector oldPaths = _selection->GetSelectedPrimPaths(mode); + _FilterSelection(); + SdfPathVector newPaths = _selection->GetSelectedPrimPaths(mode); + + if (!oldPaths.empty() || !newPaths.empty()) { + rootPaths = std::move(oldPaths); + rootPaths.reserve(rootPaths.size() + newPaths.size()); + rootPaths.insert(rootPaths.end(), newPaths.begin(), newPaths.end()); + } + retVal = !newPaths.empty(); + } + + if (!rootPaths.empty()) { _selectionHighlightCollection->SetRootPaths(rootPaths); _taskController->SetCollection(*_selectionHighlightCollection); _engine.Execute(*_renderIndex, _dummyTasks); _taskController->SetCollection(*_defaultCollection); } - return !newSelection.empty(); + return retVal; } -//! \brief Query whether the given prim is selected -bool ProxyRenderDelegate::IsFullySelected(const SdfPath& path) const +//! \brief Query whether the proxy is selected. +bool ProxyRenderDelegate::IsProxySelected() const { - const HdSelection::PrimSelectionState* selectionState = - _selection->GetPrimSelectionState(HdSelection::HighlightModeSelect, path); + return _isProxySelected; +} - return (selectionState && selectionState->fullySelected); +//! \brief Query the selection state of a given prim. +const HdSelection::PrimSelectionState* +ProxyRenderDelegate::GetPrimSelectionState(const SdfPath& path) const +{ + return (_selection == nullptr) ? nullptr : + _selection->GetPrimSelectionState(HdSelection::HighlightModeSelect, path); } PXR_NAMESPACE_CLOSE_SCOPE diff --git a/lib/render/vp2RenderDelegate/proxyRenderDelegate.h b/lib/render/vp2RenderDelegate/proxyRenderDelegate.h index 336c9552bd..0d50e5f91d 100644 --- a/lib/render/vp2RenderDelegate/proxyRenderDelegate.h +++ b/lib/render/vp2RenderDelegate/proxyRenderDelegate.h @@ -104,7 +104,10 @@ class ProxyRenderDelegate : public MHWRender::MPxSubSceneOverride void SelectionChanged(); MAYAUSD_CORE_PUBLIC - bool IsFullySelected(const SdfPath& path) const; + bool IsProxySelected() const; + + MAYAUSD_CORE_PUBLIC + const HdSelection::PrimSelectionState* GetPrimSelectionState(const SdfPath& path) const; private: ProxyRenderDelegate(const ProxyRenderDelegate&) = delete; @@ -133,6 +136,7 @@ class ProxyRenderDelegate : public MHWRender::MPxSubSceneOverride bool _isPopulated{ false }; //!< If false, scene delegate wasn't populated yet within render index bool _selectionChanged{ false }; //!< Whether there is any selection change or not + bool _isProxySelected{ false }; //!< Whether the proxy shape is selected //! A collection of Rprims to prepare render data for specified reprs std::unique_ptr _defaultCollection; @@ -141,7 +145,7 @@ class ProxyRenderDelegate : public MHWRender::MPxSubSceneOverride std::unique_ptr _selectionHighlightCollection; //! A collection of Rprims being selected - std::unique_ptr _selection; + HdSelectionSharedPtr _selection; #if defined(WANT_UFE_BUILD) //! Observer for UFE global selection change From aee93ad828b598b099f25fb5b9ce90870309ef0b Mon Sep 17 00:00:00 2001 From: Hamed Sabri Date: Tue, 30 Jul 2019 14:42:05 -0400 Subject: [PATCH 06/22] Make 3 main branches mergeable, and unify changes (#5) (#86) * Make sure the build and install folders have the variant (#2) * Enable generating compile_commands.json by default * Make sure the build and install folders have the variant * Fix typo in ReadMe * temporarily revert line endings to windows to do merge * standardize on linux-style line endings (newline only) (cherry picked from commit 8073eaf0647b710e45281fbe691b2cd98c225198) --- build.py | 949 +++++++++++++++++++++-------------------- doc/AL_CONTRIBUTORS.md | 58 +-- doc/CONTRIBUTING.md | 64 +-- doc/DEVELOPER.md | 14 +- 4 files changed, 543 insertions(+), 542 deletions(-) diff --git a/build.py b/build.py index 8ac684c22d..c24072dfda 100644 --- a/build.py +++ b/build.py @@ -1,474 +1,475 @@ -from distutils.spawn import find_executable - -import argparse -import contextlib -import datetime -import distutils -import multiprocessing -import os -import platform -import re -import shlex -import shutil -import subprocess -import sys - -############################################################ -# Helpers for printing output -verbosity = 1 - -def Print(msg): - if verbosity > 0: - print msg - -def PrintWarning(warning): - if verbosity > 0: - print "WARNING:", warning - -def PrintStatus(status): - if verbosity >= 1: - print "STATUS:", status - -def PrintInfo(info): - if verbosity >= 2: - print "INFO:", info - -def PrintCommandOutput(output): - if verbosity >= 3: - sys.stdout.write(output) - -def PrintError(error): - if verbosity >= 3 and sys.exc_info()[1] is not None: - import traceback - traceback.print_exc() - print "ERROR:", error - -############################################################ - -def Windows(): - return platform.system() == "Windows" - -def Linux(): - return platform.system() == "Linux" - -def MacOS(): - return platform.system() == "Darwin" - -def GetCommandOutput(command): - """Executes the specified command and returns output or None.""" - try: - return subprocess.check_output( - shlex.split(command), stderr=subprocess.STDOUT).strip() - except subprocess.CalledProcessError: - pass - return None - -def GetXcodeDeveloperDirectory(): - """Returns the active developer directory as reported by 'xcode-select -p'. - Returns None if none is set.""" - if not MacOS(): - return None - - return GetCommandOutput("xcode-select -p") - -def GetVisualStudioCompilerAndVersion(): - """Returns a tuple containing the path to the Visual Studio compiler - and a tuple for its version, e.g. (14, 0). If the compiler is not found - or version number cannot be determined, returns None.""" - if not Windows(): - return None - - msvcCompiler = find_executable('cl') - if msvcCompiler: - # VisualStudioVersion environment variable should be set by the - # Visual Studio Command Prompt. - match = re.search( - "(\d+).(\d+)", - os.environ.get("VisualStudioVersion", "")) - if match: - return (msvcCompiler, tuple(int(v) for v in match.groups())) - return None - -def IsVisualStudio2017OrGreater(): - VISUAL_STUDIO_2017_VERSION = (15, 0) - msvcCompilerAndVersion = GetVisualStudioCompilerAndVersion() - if msvcCompilerAndVersion: - _, version = msvcCompilerAndVersion - return version >= VISUAL_STUDIO_2017_VERSION - return False - -def GetPythonInfo(): - """Returns a tuple containing the path to the Python executable, shared - library, and include directory corresponding to the version of Python - currently running. Returns None if any path could not be determined. This - function always returns None on Windows or Linux. - - This function is primarily used to determine which version of - Python USD should link against when multiple versions are installed. - """ - # We just skip all this on Windows. Users on Windows are unlikely to have - # multiple copies of the same version of Python, so the problem this - # function is intended to solve doesn't arise on that platform. - if Windows(): - return None - - # We also skip all this on Linux. The below code gets the wrong answer on - # certain distributions like Ubuntu, which organizes libraries based on - # multiarch. The below code yields /usr/lib/libpython2.7.so, but - # the library is actually in /usr/lib/x86_64-linux-gnu. Since the problem - # this function is intended to solve primarily occurs on macOS, so it's - # simpler to just skip this for now. - if Linux(): - return None - - try: - import distutils.sysconfig - - pythonExecPath = None - pythonLibPath = None - - pythonPrefix = distutils.sysconfig.PREFIX - if pythonPrefix: - pythonExecPath = os.path.join(pythonPrefix, 'bin', 'python') - pythonLibPath = os.path.join(pythonPrefix, 'lib', 'libpython2.7.dylib') - - pythonIncludeDir = distutils.sysconfig.get_python_inc() - except: - return None - - if pythonExecPath and pythonIncludeDir and pythonLibPath: - # Ensure that the paths are absolute, since depending on the version of - # Python being run and the path used to invoke it, we may have gotten a - # relative path from distutils.sysconfig.PREFIX. - return ( - os.path.abspath(pythonExecPath), - os.path.abspath(pythonLibPath), - os.path.abspath(pythonIncludeDir)) - - return None - -def GetCPUCount(): - try: - return multiprocessing.cpu_count() - except NotImplementedError: - return 1 - -def Run(cmd, logCommandOutput=True): - """Run the specified command in a subprocess.""" - PrintInfo('Running "{cmd}"'.format(cmd=cmd)) - - with open(context.logFileLocation, "a") as logfile: - logfile.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M")) - logfile.write("\n") - logfile.write(cmd) - logfile.write("\n") - - # Let exceptions escape from subprocess calls -- higher level - # code will handle them. - if logCommandOutput: - p = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - while True: - l = p.stdout.readline() - if l != "": - logfile.write(l) - PrintCommandOutput(l) - elif p.poll() is not None: - break - else: - p = subprocess.Popen(shlex.split(cmd)) - p.wait() - - if p.returncode != 0: - # If verbosity >= 3, we'll have already been printing out command output - # so no reason to print the log file again. - if verbosity < 3: - with open(context.logFileLocation, "r") as logfile: - Print(logfile.read()) - raise RuntimeError("Failed to run '{cmd}'\nSee {log} for more details." - .format(cmd=cmd, log=os.path.abspath(context.logFileLocation))) - -def BuildVariant(context): - if context.buildDebug: - return "Debug" - elif context.buildRelease: - return "Release" - elif context.buildRelWithDebug: - return "RelWithDebInfo" - return "RelWithDebInfo" - -def FormatMultiProcs(numJobs, generator): - tag = "-j" - if generator: - if "Visual Studio" in generator: - tag = "/M:" - elif "Xcode" in generator: - tag = "-j " - - return "{tag}{procs}".format(tag=tag, procs=numJobs) - -############################################################ -# contextmanager -@contextlib.contextmanager -def CurrentWorkingDirectory(dir): - """Context manager that sets the current working directory to the given - directory and resets it to the original directory when closed.""" - curdir = os.getcwd() - os.chdir(dir) - try: - yield - finally: - os.chdir(curdir) - -############################################################ -# CMAKE -def RunCMake(context, force, extraArgs=None): - """Invoke CMake to configure, build, and install a library whose - source code is located in the current working directory.""" - - srcDir = os.getcwd() - instDir = context.instDir - buildDir = context.buildDir - - if force and os.path.isdir(buildDir): - shutil.rmtree(buildDir) - if force and os.path.isdir(instDir): - shutil.rmtree(instDir) - - if not os.path.isdir(buildDir): - os.makedirs(buildDir) - - generator = context.cmakeGenerator - - # On Windows, we need to explicitly specify the generator to ensure we're - # building a 64-bit project. (Surely there is a better way to do this?) - # TODO: figure out exactly what "vcvarsall.bat x64" sets to force x64 - if generator is None and Windows(): - if IsVisualStudio2017OrGreater(): - generator = "Visual Studio 15 2017 Win64" - else: - generator = "Visual Studio 14 2015 Win64" - - if generator is not None: - generator = '-G "{gen}"'.format(gen=generator) - - # On MacOS, enable the use of @rpath for relocatable builds. - osx_rpath = None - if MacOS(): - osx_rpath = "-DCMAKE_MACOSX_RPATH=ON" - - # get build variant - variant= BuildVariant(context) - - with CurrentWorkingDirectory(buildDir): - # recreate build_log.txt everytime the script runs - if os.path.isfile(context.logFileLocation): - os.remove(context.logFileLocation) - - Run('cmake ' - '-DCMAKE_INSTALL_PREFIX="{instDir}" ' - '-DCMAKE_BUILD_TYPE={variant} ' - '{osx_rpath} ' - '{generator} ' - '{extraArgs} ' - '"{srcDir}"' - .format(instDir=instDir, - variant=variant, - srcDir=srcDir, - osx_rpath=(osx_rpath or ""), - generator=(generator or ""), - extraArgs=(" ".join(extraArgs) if extraArgs else ""))) - Run("cmake --build . --config {variant} --target install -- {multiproc}" - .format(variant=variant, - multiproc=FormatMultiProcs(context.numJobs, generator))) - -############################################################ -# Maya USD -def InstallMayaUSD(context, force, buildArgs): - with CurrentWorkingDirectory(context.mayaUsdSrcDir): - extraArgs = [] - - if context.mayaLocation: - extraArgs.append('-DMAYA_LOCATION="{mayaLocation}"' - .format(mayaLocation=context.mayaLocation)) - - if context.pxrUsdLocation: - extraArgs.append('-DPXR_USD_LOCATION="{pxrUsdLocation}"' - .format(pxrUsdLocation=context.pxrUsdLocation)) - - if context.devkitLocation: - extraArgs.append('-DMAYA_DEVKIT_LOCATION="{devkitLocation}"' - .format(devkitLocation=context.devkitLocation)) - - # Add on any user-specified extra arguments. - extraArgs += buildArgs - - RunCMake(context, force, extraArgs) - -############################################################ -# ArgumentParser - -parser = argparse.ArgumentParser( - formatter_class=argparse.RawDescriptionHelpFormatter) - -parser.add_argument("workspace_location", type=str, - help="Directory where the project use as a workspace to build and install plugin/libraries.") - -parser.add_argument("--generator", type=str, - help=("CMake generator to use when building libraries with " - "cmake")) - -parser.add_argument("--build-location", type=str, - help=("Set Build directory" - "(default: /build-location)")) - -parser.add_argument("--install-location", type=str, - help=("Set Install directory" - "(default: /install-location)")) - -parser.add_argument("--maya-location", type=str, - help="Directory where Maya is installed.") - -parser.add_argument("--pxrusd-location", type=str, - help="Directory where Pixar USD is installed.") - -parser.add_argument("--devkit-location", type=str, - help="Directory where Maya Devkit is installed.") - -parser.add_argument("--build-debug", dest="build_debug", action="store_true", - help="Build in Debug mode") - -parser.add_argument("--build-release", dest="build_release", action="store_true", - help="Build in Release mode") - -parser.add_argument("--build-relwithdebug", dest="build_relwithdebug", action="store_true", - help="Build in RelWithDebInfo mode") - -parser.add_argument("--build-args", type=str, nargs="*", default=[], - help=("Custom arguments to pass to build system when " - "building libraries")) - -parser.add_argument("-j", "--jobs", type=int, default=GetCPUCount(), - help=("Number of build jobs to run in parallel. " - "(default: # of processors [{0}])" - .format(GetCPUCount()))) - -parser.add_argument("--force", type=str, action="append", dest="force_clean_build", - default=[], - help=("Force clean build.")) - -args = parser.parse_args() - -############################################################ -# InstallContext -class InstallContext: - def __init__(self, args): - - # Assume the project's top level cmake is in the current source directory - self.mayaUsdSrcDir = os.path.normpath( - os.path.join(os.path.abspath(os.path.dirname(__file__)))) - - # Build type - # Must be done early, so we can call BuildVariant(self) - self.buildDebug = args.build_debug - self.buildRelease = args.build_release - self.buildRelWithDebug = args.build_relwithdebug - - # Workspace directory - self.workspaceDir = os.path.abspath(args.workspace_location) - - # Build directory - self.buildDir = (os.path.abspath(args.build_location) if args.build_location - else os.path.join(self.workspaceDir, "build", BuildVariant(self))) - - # Install directory - self.instDir = (os.path.abspath(args.install_location) if args.install_location - else os.path.join(self.workspaceDir, "install", BuildVariant(self))) - - # Forced to be built - self.forceBuild = args.force_clean_build - - # CMake generator - self.cmakeGenerator = args.generator - - # Number of jobs - self.numJobs = args.jobs - if self.numJobs <= 0: - raise ValueError("Number of jobs must be greater than 0") - - # Maya Location - self.mayaLocation = (os.path.abspath(args.maya_location) - if args.maya_location else None) - - # PXR USD Location - self.pxrUsdLocation = (os.path.abspath(args.pxrusd_location) - if args.pxrusd_location else None) - - # Maya Devkit Location - self.devkitLocation = (os.path.abspath(args.devkit_location) - if args.devkit_location else None) - - # Log File Name - logFileName="build_log.txt" - self.logFileLocation=os.path.join(self.buildDir, logFileName) - - # Build arguments - self.buildArgs = list() - for args in args.build_args: - argList = args.split(",") - for arg in argList: - self.buildArgs.append(arg) -try: - context = InstallContext(args) -except Exception as e: - PrintError(str(e)) - sys.exit(1) - -# Summarize -summaryMsg = """ -Building with settings: - Source directory {mayaUsdSrcDir} - Workspace directory {workspaceDir} - Build directory {buildDir} - Install directory {instDir} - Variant {buildVariant} - CMake generator {cmakeGenerator} - Build Log {logFileLocation}""" - -if context.buildArgs: - summaryMsg += """ - Extra Build arguments {buildArgs}""" - -summaryMsg = summaryMsg.format( - mayaUsdSrcDir=context.mayaUsdSrcDir, - workspaceDir=context.workspaceDir, - buildDir=context.buildDir, - instDir=context.instDir, - logFileLocation=context.logFileLocation, - buildArgs=context.buildArgs, - buildVariant=BuildVariant(context), - cmakeGenerator=("Default" if not context.cmakeGenerator - else context.cmakeGenerator) -) - -Print(summaryMsg) - -# Install MayaUSD -InstallMayaUSD(context, context.forceBuild, context.buildArgs) - -# Ensure directory structure is created and is writable. -for dir in [context.workspaceDir, context.buildDir, context.instDir]: - try: - if os.path.isdir(dir): - testFile = os.path.join(dir, "canwrite") - open(testFile, "w").close() - os.remove(testFile) - else: - os.makedirs(dir) - except Exception as e: - PrintError("Could not write to directory {dir}. Change permissions " - "or choose a different location to install to." - .format(dir=dir)) - sys.exit(1) - -Print("""Success Maya USD build and install !!!!""") +from distutils.spawn import find_executable + +import argparse +import contextlib +import datetime +import distutils +import multiprocessing +import os +import platform +import re +import shlex +import shutil +import subprocess +import sys + +############################################################ +# Helpers for printing output +verbosity = 1 + +def Print(msg): + if verbosity > 0: + print msg + +def PrintWarning(warning): + if verbosity > 0: + print "WARNING:", warning + +def PrintStatus(status): + if verbosity >= 1: + print "STATUS:", status + +def PrintInfo(info): + if verbosity >= 2: + print "INFO:", info + +def PrintCommandOutput(output): + if verbosity >= 3: + sys.stdout.write(output) + +def PrintError(error): + if verbosity >= 3 and sys.exc_info()[1] is not None: + import traceback + traceback.print_exc() + print "ERROR:", error + +############################################################ + +def Windows(): + return platform.system() == "Windows" + +def Linux(): + return platform.system() == "Linux" + +def MacOS(): + return platform.system() == "Darwin" + +def GetCommandOutput(command): + """Executes the specified command and returns output or None.""" + try: + return subprocess.check_output( + shlex.split(command), stderr=subprocess.STDOUT).strip() + except subprocess.CalledProcessError: + pass + return None + +def GetXcodeDeveloperDirectory(): + """Returns the active developer directory as reported by 'xcode-select -p'. + Returns None if none is set.""" + if not MacOS(): + return None + + return GetCommandOutput("xcode-select -p") + +def GetVisualStudioCompilerAndVersion(): + """Returns a tuple containing the path to the Visual Studio compiler + and a tuple for its version, e.g. (14, 0). If the compiler is not found + or version number cannot be determined, returns None.""" + if not Windows(): + return None + + msvcCompiler = find_executable('cl') + if msvcCompiler: + # VisualStudioVersion environment variable should be set by the + # Visual Studio Command Prompt. + match = re.search( + "(\d+).(\d+)", + os.environ.get("VisualStudioVersion", "")) + if match: + return (msvcCompiler, tuple(int(v) for v in match.groups())) + return None + +def IsVisualStudio2017OrGreater(): + VISUAL_STUDIO_2017_VERSION = (15, 0) + msvcCompilerAndVersion = GetVisualStudioCompilerAndVersion() + if msvcCompilerAndVersion: + _, version = msvcCompilerAndVersion + return version >= VISUAL_STUDIO_2017_VERSION + return False + +def GetPythonInfo(): + """Returns a tuple containing the path to the Python executable, shared + library, and include directory corresponding to the version of Python + currently running. Returns None if any path could not be determined. This + function always returns None on Windows or Linux. + + This function is primarily used to determine which version of + Python USD should link against when multiple versions are installed. + """ + # We just skip all this on Windows. Users on Windows are unlikely to have + # multiple copies of the same version of Python, so the problem this + # function is intended to solve doesn't arise on that platform. + if Windows(): + return None + + # We also skip all this on Linux. The below code gets the wrong answer on + # certain distributions like Ubuntu, which organizes libraries based on + # multiarch. The below code yields /usr/lib/libpython2.7.so, but + # the library is actually in /usr/lib/x86_64-linux-gnu. Since the problem + # this function is intended to solve primarily occurs on macOS, so it's + # simpler to just skip this for now. + if Linux(): + return None + + try: + import distutils.sysconfig + + pythonExecPath = None + pythonLibPath = None + + pythonPrefix = distutils.sysconfig.PREFIX + if pythonPrefix: + pythonExecPath = os.path.join(pythonPrefix, 'bin', 'python') + pythonLibPath = os.path.join(pythonPrefix, 'lib', 'libpython2.7.dylib') + + pythonIncludeDir = distutils.sysconfig.get_python_inc() + except: + return None + + if pythonExecPath and pythonIncludeDir and pythonLibPath: + # Ensure that the paths are absolute, since depending on the version of + # Python being run and the path used to invoke it, we may have gotten a + # relative path from distutils.sysconfig.PREFIX. + return ( + os.path.abspath(pythonExecPath), + os.path.abspath(pythonLibPath), + os.path.abspath(pythonIncludeDir)) + + return None + +def GetCPUCount(): + try: + return multiprocessing.cpu_count() + except NotImplementedError: + return 1 + +def Run(cmd, logCommandOutput=True): + """Run the specified command in a subprocess.""" + PrintInfo('Running "{cmd}"'.format(cmd=cmd)) + + with open(context.logFileLocation, "a") as logfile: + logfile.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M")) + logfile.write("\n") + logfile.write(cmd) + logfile.write("\n") + + # Let exceptions escape from subprocess calls -- higher level + # code will handle them. + if logCommandOutput: + p = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + while True: + l = p.stdout.readline() + if l != "": + logfile.write(l) + PrintCommandOutput(l) + elif p.poll() is not None: + break + else: + p = subprocess.Popen(shlex.split(cmd)) + p.wait() + + if p.returncode != 0: + # If verbosity >= 3, we'll have already been printing out command output + # so no reason to print the log file again. + if verbosity < 3: + with open(context.logFileLocation, "r") as logfile: + Print(logfile.read()) + raise RuntimeError("Failed to run '{cmd}'\nSee {log} for more details." + .format(cmd=cmd, log=os.path.abspath(context.logFileLocation))) + +def BuildVariant(context): + if context.buildDebug: + return "Debug" + elif context.buildRelease: + return "Release" + elif context.buildRelWithDebug: + return "RelWithDebInfo" + return "RelWithDebInfo" + +def FormatMultiProcs(numJobs, generator): + tag = "-j" + if generator: + if "Visual Studio" in generator: + tag = "/M:" + elif "Xcode" in generator: + tag = "-j " + + return "{tag}{procs}".format(tag=tag, procs=numJobs) + +############################################################ +# contextmanager +@contextlib.contextmanager +def CurrentWorkingDirectory(dir): + """Context manager that sets the current working directory to the given + directory and resets it to the original directory when closed.""" + curdir = os.getcwd() + os.chdir(dir) + try: + yield + finally: + os.chdir(curdir) + +############################################################ +# CMAKE +def RunCMake(context, force, extraArgs=None): + """Invoke CMake to configure, build, and install a library whose + source code is located in the current working directory.""" + + srcDir = os.getcwd() + instDir = context.instDir + buildDir = context.buildDir + + if force and os.path.isdir(buildDir): + shutil.rmtree(buildDir) + if force and os.path.isdir(instDir): + shutil.rmtree(instDir) + + if not os.path.isdir(buildDir): + os.makedirs(buildDir) + + generator = context.cmakeGenerator + + # On Windows, we need to explicitly specify the generator to ensure we're + # building a 64-bit project. (Surely there is a better way to do this?) + # TODO: figure out exactly what "vcvarsall.bat x64" sets to force x64 + if generator is None and Windows(): + if IsVisualStudio2017OrGreater(): + generator = "Visual Studio 15 2017 Win64" + else: + generator = "Visual Studio 14 2015 Win64" + + if generator is not None: + generator = '-G "{gen}"'.format(gen=generator) + + # On MacOS, enable the use of @rpath for relocatable builds. + osx_rpath = None + if MacOS(): + osx_rpath = "-DCMAKE_MACOSX_RPATH=ON" + + # get build variant + variant= BuildVariant(context) + + with CurrentWorkingDirectory(buildDir): + # recreate build_log.txt everytime the script runs + if os.path.isfile(context.logFileLocation): + os.remove(context.logFileLocation) + + Run('cmake ' + '-DCMAKE_INSTALL_PREFIX="{instDir}" ' + '-DCMAKE_BUILD_TYPE={variant} ' + '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON' + '{osx_rpath} ' + '{generator} ' + '{extraArgs} ' + '"{srcDir}"' + .format(instDir=instDir, + variant=variant, + srcDir=srcDir, + osx_rpath=(osx_rpath or ""), + generator=(generator or ""), + extraArgs=(" ".join(extraArgs) if extraArgs else ""))) + Run("cmake --build . --config {variant} --target install -- {multiproc}" + .format(variant=variant, + multiproc=FormatMultiProcs(context.numJobs, generator))) + +############################################################ +# Maya USD +def InstallMayaUSD(context, force, buildArgs): + with CurrentWorkingDirectory(context.mayaUsdSrcDir): + extraArgs = [] + + if context.mayaLocation: + extraArgs.append('-DMAYA_LOCATION="{mayaLocation}"' + .format(mayaLocation=context.mayaLocation)) + + if context.pxrUsdLocation: + extraArgs.append('-DPXR_USD_LOCATION="{pxrUsdLocation}"' + .format(pxrUsdLocation=context.pxrUsdLocation)) + + if context.devkitLocation: + extraArgs.append('-DMAYA_DEVKIT_LOCATION="{devkitLocation}"' + .format(devkitLocation=context.devkitLocation)) + + # Add on any user-specified extra arguments. + extraArgs += buildArgs + + RunCMake(context, force, extraArgs) + +############################################################ +# ArgumentParser + +parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter) + +parser.add_argument("workspace_location", type=str, + help="Directory where the project use as a workspace to build and install plugin/libraries.") + +parser.add_argument("--generator", type=str, + help=("CMake generator to use when building libraries with " + "cmake")) + +parser.add_argument("--build-location", type=str, + help=("Set Build directory" + "(default: /build-location)")) + +parser.add_argument("--install-location", type=str, + help=("Set Install directory" + "(default: /install-location)")) + +parser.add_argument("--maya-location", type=str, + help="Directory where Maya is installed.") + +parser.add_argument("--pxrusd-location", type=str, + help="Directory where Pixar USD is installed.") + +parser.add_argument("--devkit-location", type=str, + help="Directory where Maya Devkit is installed.") + +parser.add_argument("--build-debug", dest="build_debug", action="store_true", + help="Build in Debug mode") + +parser.add_argument("--build-release", dest="build_release", action="store_true", + help="Build in Release mode") + +parser.add_argument("--build-relwithdebug", dest="build_relwithdebug", action="store_true", + help="Build in RelWithDebInfo mode") + +parser.add_argument("--build-args", type=str, nargs="*", default=[], + help=("Custom arguments to pass to build system when " + "building libraries")) + +parser.add_argument("-j", "--jobs", type=int, default=GetCPUCount(), + help=("Number of build jobs to run in parallel. " + "(default: # of processors [{0}])" + .format(GetCPUCount()))) + +parser.add_argument("--force", type=str, action="append", dest="force_clean_build", + default=[], + help=("Force clean build.")) + +args = parser.parse_args() + +############################################################ +# InstallContext +class InstallContext: + def __init__(self, args): + + # Assume the project's top level cmake is in the current source directory + self.mayaUsdSrcDir = os.path.normpath( + os.path.join(os.path.abspath(os.path.dirname(__file__)))) + + # Build type + # Must be done early, so we can call BuildVariant(self) + self.buildDebug = args.build_debug + self.buildRelease = args.build_release + self.buildRelWithDebug = args.build_relwithdebug + + # Workspace directory + self.workspaceDir = os.path.abspath(args.workspace_location) + + # Build directory + self.buildDir = (os.path.abspath(args.build_location) if args.build_location + else os.path.join(self.workspaceDir, "build", BuildVariant(self))) + + # Install directory + self.instDir = (os.path.abspath(args.install_location) if args.install_location + else os.path.join(self.workspaceDir, "install", BuildVariant(self))) + + # Forced to be built + self.forceBuild = args.force_clean_build + + # CMake generator + self.cmakeGenerator = args.generator + + # Number of jobs + self.numJobs = args.jobs + if self.numJobs <= 0: + raise ValueError("Number of jobs must be greater than 0") + + # Maya Location + self.mayaLocation = (os.path.abspath(args.maya_location) + if args.maya_location else None) + + # PXR USD Location + self.pxrUsdLocation = (os.path.abspath(args.pxrusd_location) + if args.pxrusd_location else None) + + # Maya Devkit Location + self.devkitLocation = (os.path.abspath(args.devkit_location) + if args.devkit_location else None) + + # Log File Name + logFileName="build_log.txt" + self.logFileLocation=os.path.join(self.buildDir, logFileName) + + # Build arguments + self.buildArgs = list() + for args in args.build_args: + argList = args.split(",") + for arg in argList: + self.buildArgs.append(arg) +try: + context = InstallContext(args) +except Exception as e: + PrintError(str(e)) + sys.exit(1) + +# Summarize +summaryMsg = """ +Building with settings: + Source directory {mayaUsdSrcDir} + Workspace directory {workspaceDir} + Build directory {buildDir} + Install directory {instDir} + Variant {buildVariant} + CMake generator {cmakeGenerator} + Build Log {logFileLocation}""" + +if context.buildArgs: + summaryMsg += """ + Extra Build arguments {buildArgs}""" + +summaryMsg = summaryMsg.format( + mayaUsdSrcDir=context.mayaUsdSrcDir, + workspaceDir=context.workspaceDir, + buildDir=context.buildDir, + instDir=context.instDir, + logFileLocation=context.logFileLocation, + buildArgs=context.buildArgs, + buildVariant=BuildVariant(context), + cmakeGenerator=("Default" if not context.cmakeGenerator + else context.cmakeGenerator) +) + +Print(summaryMsg) + +# Install MayaUSD +InstallMayaUSD(context, context.forceBuild, context.buildArgs) + +# Ensure directory structure is created and is writable. +for dir in [context.workspaceDir, context.buildDir, context.instDir]: + try: + if os.path.isdir(dir): + testFile = os.path.join(dir, "canwrite") + open(testFile, "w").close() + os.remove(testFile) + else: + os.makedirs(dir) + except Exception as e: + PrintError("Could not write to directory {dir}. Change permissions " + "or choose a different location to install to." + .format(dir=dir)) + sys.exit(1) + +Print("""Success Maya USD build and install !!!!""") diff --git a/doc/AL_CONTRIBUTORS.md b/doc/AL_CONTRIBUTORS.md index 0f42843069..3a916de477 100644 --- a/doc/AL_CONTRIBUTORS.md +++ b/doc/AL_CONTRIBUTORS.md @@ -1,29 +1,29 @@ -# Animal Logic Contributors -This is a list of the contributors to the Animal Logic USD Maya plugin. Please let us know if anyone is missing from this list, as we value all contributions made! - -``` -Aloys Baillet -Daniel Barry -Rob Bateman -Frieder Czeschla -Sebastien Dalgo -Miguel Gao -Matthew Hampsey -Eddie Hoyle -Hongbin Hu -Jakub Jeziorski -Haoliang Jiang -Nicolas Kendall-Bar -Fabrice Macagno -Aleka McAdams -Pal Mezei -Joshua Miller -Pilar Molina -Paul Molodowitch -Eoin Murphy -Michael Quandt -Nathan Rusch -Alex Schwank -Daniel Scott -Wen Tan -``` +# Animal Logic Contributors +This is a list of the contributors to the Animal Logic USD Maya plugin. Please let us know if anyone is missing from this list, as we value all contributions made! + +``` +Aloys Baillet +Daniel Barry +Rob Bateman +Frieder Czeschla +Sebastien Dalgo +Miguel Gao +Matthew Hampsey +Eddie Hoyle +Hongbin Hu +Jakub Jeziorski +Haoliang Jiang +Nicolas Kendall-Bar +Fabrice Macagno +Aleka McAdams +Pal Mezei +Joshua Miller +Pilar Molina +Paul Molodowitch +Eoin Murphy +Michael Quandt +Nathan Rusch +Alex Schwank +Daniel Scott +Wen Tan +``` diff --git a/doc/CONTRIBUTING.md b/doc/CONTRIBUTING.md index 0f4f833fb6..adae2bf330 100644 --- a/doc/CONTRIBUTING.md +++ b/doc/CONTRIBUTING.md @@ -1,32 +1,32 @@ -# Contributing to USD For Maya - -## Contributor License Agreement # -Before contributing code to this project, we ask that you sign a Contributor License Agreement (CLA). - -+ [AutodeskFormCorpContribAgmtForOpenSource.docx](AutodeskFormCorpContribAgmtForOpenSource.docx) please sign this one for corporate use -+ [AutodeskFormIndContribAgmtForOpenSource.docx](AutodeskFormIndContribAgmtForOpenSource.docx) please sign this one if you're an individual contributor - -The documents include instructions on where to send the completed forms to. Once a signed form has been received you will be able to submit pull requests. - - -## Filing Issues - -### Suggestions - -The USD for Maya project is meant to evolve with feedback - the project and its users greatly appreciate any thoughts on ways to improve the design or features. Please use the `enhancement` tag to specifically denote issues that are suggestions - this helps us triage and respond appropriately. - -### Bugs - -As with all pieces of software, you may end up running into bugs. Please submit bugs as regular issues on GitHub - Maya developers are regularly monitoring issues and will prioritize and schedule fixes. - -The best bug reports include a detailed way to predictably reproduce the issue, and possibly even a working example that demonstrates the issue. - -## Contributing Code - -The USD for Maya project accepts and greatly appreciates contributions. The project follows the [fork & pull](https://help.github.com/articles/using-pull-requests/#fork--pull) model for accepting contributions. - -When contributing code, please also include appropriate tests as part of the pull request, and follow the same comment and coding style as the rest of the project. Take a look through the existing code for examples of the testing and style practices the project follows. - -All development should happen against the "develop" branch of the repository. Please make sure the base branch of your pull request is set to the "develop" branch when filing your pull request. - -It is highly recommended that an issue be logged on GitHub before any work is started. This will allow for early feedback from other developers and avoid multiple parallel efforts. +# Contributing to USD For Maya + +## Contributor License Agreement # +Before contributing code to this project, we ask that you sign a Contributor License Agreement (CLA). + ++ [AutodeskFormCorpContribAgmtForOpenSource.docx](AutodeskFormCorpContribAgmtForOpenSource.docx) please sign this one for corporate use ++ [AutodeskFormIndContribAgmtForOpenSource.docx](AutodeskFormIndContribAgmtForOpenSource.docx) please sign this one if you're an individual contributor + +The documents include instructions on where to send the completed forms to. Once a signed form has been received you will be able to submit pull requests. + + +## Filing Issues + +### Suggestions + +The USD for Maya project is meant to evolve with feedback - the project and its users greatly appreciate any thoughts on ways to improve the design or features. Please use the `enhancement` tag to specifically denote issues that are suggestions - this helps us triage and respond appropriately. + +### Bugs + +As with all pieces of software, you may end up running into bugs. Please submit bugs as regular issues on GitHub - Maya developers are regularly monitoring issues and will prioritize and schedule fixes. + +The best bug reports include a detailed way to predictably reproduce the issue, and possibly even a working example that demonstrates the issue. + +## Contributing Code + +The USD for Maya project accepts and greatly appreciates contributions. The project follows the [fork & pull](https://help.github.com/articles/using-pull-requests/#fork--pull) model for accepting contributions. + +When contributing code, please also include appropriate tests as part of the pull request, and follow the same comment and coding style as the rest of the project. Take a look through the existing code for examples of the testing and style practices the project follows. + +All development should happen against the "develop" branch of the repository. Please make sure the base branch of your pull request is set to the "develop" branch when filing your pull request. + +It is highly recommended that an issue be logged on GitHub before any work is started. This will allow for early feedback from other developers and avoid multiple parallel efforts. diff --git a/doc/DEVELOPER.md b/doc/DEVELOPER.md index 2a26c7556f..bc5e8948f1 100644 --- a/doc/DEVELOPER.md +++ b/doc/DEVELOPER.md @@ -1,8 +1,8 @@ -## Repository Layout - -| Location | Description | -| ------------- | --------------- | -| lib | The libraries that all other plugins depend on. Will contain common utilities and features. | -| plugin/adsk | The Autodesk Maya plugin | -| plugin/pxr | The Pixar Maya plugin | +## Repository Layout + +| Location | Description | +| ------------- | --------------- | +| lib | The libraries that all other plugins depend on. Will contain common utilities and features. | +| plugin/adsk | The Autodesk Maya plugin | +| plugin/pxr | The Pixar Maya plugin | | plugin/al | The Animal Logic Maya plugin | \ No newline at end of file From 1c70628ca828c32394bc4e64b34edc5a0a5b9293 Mon Sep 17 00:00:00 2001 From: Pierre Tremblay Date: Wed, 31 Jul 2019 08:58:35 -0700 Subject: [PATCH 07/22] Linux translator plugins (#82) * mayaUsd_Translators and mayaUsd_Schemas Pixar PlugPlugin's load. * Removed translator plugin requirement for sidecar Maya plugin. * Compilation and hdMaya camelCase fixes. * Addressed code review feedback. --- lib/CMakeLists.txt | 2 +- lib/render/mayaToHydra/CMakeLists.txt | 4 +-- .../mayaToHydra/defaultLightDelegate.cpp | 4 +-- lib/render/mayaToHydra/renderGlobals.cpp | 2 +- lib/render/mayaToHydra/renderOverride.cpp | 2 +- lib/render/mayaToHydra/renderOverride.h | 2 +- .../mayaToHydra/shadingModeExporter.cpp | 2 +- lib/usd/CMakeLists.txt | 36 ++++++++++++++++++- lib/usd/hdMaya/CMakeLists.txt | 22 ++++++------ lib/usd/hdMaya/adapters/adapterRegistry.cpp | 2 +- lib/usd/hdMaya/adapters/imagePlaneAdapter.cpp | 2 +- .../adapters/imagePlaneMaterialAdapter.cpp | 2 +- lib/usd/hdMaya/adapters/lightAdapter.cpp | 2 +- lib/usd/hdMaya/adapters/materialAdapter.cpp | 2 +- lib/usd/hdMaya/adapters/proxyAdapter.cpp | 4 +-- lib/usd/hdMaya/adapters/proxyAdapter.h | 2 +- lib/usd/hdMaya/debugCodes.cpp | 4 +-- lib/usd/hdMaya/delegates/delegate.h | 2 +- lib/usd/hdMaya/delegates/delegateCtx.cpp | 4 +-- .../hdMaya/delegates/delegateDebugCodes.cpp | 2 +- lib/usd/hdMaya/delegates/proxyDelegate.cpp | 2 +- .../delegates/proxyUsdImagingDelegate.cpp | 2 +- lib/usd/hdMaya/delegates/sceneDelegate.cpp | 2 +- lib/usd/hdMaya/delegates/sceneDelegate.h | 2 +- lib/usd/hdMaya/{hdmaya.h.in => hdMaya.h.in} | 0 lib/usd/hdMaya/plugInfo.json | 2 +- lib/usd/schemas/CMakeLists.txt | 14 ++++++-- lib/usd/schemas/ModuleDeps.cpp | 2 +- lib/usd/schemas/plugInfo.json.in | 6 ++-- lib/usd/schemas/schema.usda.in | 2 +- lib/usd/translators/CMakeLists.txt | 21 ++--------- lib/usd/translators/mayaReferenceReader.cpp | 2 +- lib/usd/translators/mayaReferenceUpdater.cpp | 2 +- lib/usd/translators/plugInfo.json | 7 ++-- 34 files changed, 97 insertions(+), 73 deletions(-) rename lib/usd/hdMaya/{hdmaya.h.in => hdMaya.h.in} (100%) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 0e02caa3f6..a64b7e94de 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -551,4 +551,4 @@ install(FILES ${mayaUsdPxrUsdMayaGL_headers} add_subdirectory(usd) add_subdirectory(render/mayaToHydra) -add_dependencies(mtoh hdmaya) \ No newline at end of file +add_dependencies(mtoh hdMaya) diff --git a/lib/render/mayaToHydra/CMakeLists.txt b/lib/render/mayaToHydra/CMakeLists.txt index 064a0e8692..c70508a979 100644 --- a/lib/render/mayaToHydra/CMakeLists.txt +++ b/lib/render/mayaToHydra/CMakeLists.txt @@ -16,7 +16,7 @@ set(SRC add_library(${TARGET_NAME} SHARED ${SRC}) target_link_libraries(${TARGET_NAME} PRIVATE - hdmaya + hdMaya usdShade ${MAYA_LIBRARIES} ) @@ -77,4 +77,4 @@ endif() #MAYA_SCRIPT_PATH +:= scripts #PYTHONPATH +:= scripts #\")") -#endif () \ No newline at end of file +#endif () diff --git a/lib/render/mayaToHydra/defaultLightDelegate.cpp b/lib/render/mayaToHydra/defaultLightDelegate.cpp index 247da7cff7..47ba5bcb2e 100644 --- a/lib/render/mayaToHydra/defaultLightDelegate.cpp +++ b/lib/render/mayaToHydra/defaultLightDelegate.cpp @@ -23,9 +23,9 @@ // #include "defaultLightDelegate.h" -#include +#include -#include "../../usd/hdmaya/delegates/delegateDebugCodes.h" +#include "../../usd/hdMaya/delegates/delegateDebugCodes.h" #include #include diff --git a/lib/render/mayaToHydra/renderGlobals.cpp b/lib/render/mayaToHydra/renderGlobals.cpp index feaf0c3775..7dab26523c 100644 --- a/lib/render/mayaToHydra/renderGlobals.cpp +++ b/lib/render/mayaToHydra/renderGlobals.cpp @@ -23,7 +23,7 @@ // #include "renderGlobals.h" -#include +#include #include #include diff --git a/lib/render/mayaToHydra/renderOverride.cpp b/lib/render/mayaToHydra/renderOverride.cpp index f3414f39da..e2533dc6aa 100644 --- a/lib/render/mayaToHydra/renderOverride.cpp +++ b/lib/render/mayaToHydra/renderOverride.cpp @@ -23,7 +23,7 @@ // #include "renderOverride.h" -#include +#include #include diff --git a/lib/render/mayaToHydra/renderOverride.h b/lib/render/mayaToHydra/renderOverride.h index 1993467fcc..77bf2a502b 100644 --- a/lib/render/mayaToHydra/renderOverride.h +++ b/lib/render/mayaToHydra/renderOverride.h @@ -27,7 +27,7 @@ #include #include -#include +#include #include diff --git a/lib/render/mayaToHydra/shadingModeExporter.cpp b/lib/render/mayaToHydra/shadingModeExporter.cpp index 991e44a35e..9450b32e18 100644 --- a/lib/render/mayaToHydra/shadingModeExporter.cpp +++ b/lib/render/mayaToHydra/shadingModeExporter.cpp @@ -23,7 +23,7 @@ // #include -#include +#include #ifdef HDMAYA_USD_001905_BUILD #include diff --git a/lib/usd/CMakeLists.txt b/lib/usd/CMakeLists.txt index 299b8b6660..608fa98fdc 100644 --- a/lib/usd/CMakeLists.txt +++ b/lib/usd/CMakeLists.txt @@ -1,5 +1,5 @@ #============================================================================== -# Configuration hdmaya +# Configuration hdMaya #============================================================================== set(MTOH_CXX_STD "11" CACHE @@ -39,5 +39,39 @@ endif() add_subdirectory(hdMaya) +# Adds the proper RPATH (on Mac OS) or RUNPATH (on Linux) for PlugPlugin +# translator plugins. RUNPATH is preferable to RPATH on Linux, as it is +# overridable with LD_LIBRARY_PATH. There is no RUNPATH on Mac OS. +function(set_translators_plugin_properties plugin) + # ${PXR_USD_LOCATION}/lib is added to the RPATH only if PXR_USD_LOCATION + # is set. + if(APPLE) + set(TARGET_RPATH "@loader_path/../lib;@loader_path/../../USD/lib") + if(DEFINED PXR_USD_LOCATION) + string(APPEND TARGET_RPATH ";${PXR_USD_LOCATION}/lib") + endif() + set(CMAKE_MACOSX_RPATH ON) + set_target_properties(${plugin} + PROPERTIES + SUFFIX ".bundle" + BUILD_WITH_INSTALL_RPATH TRUE + INSTALL_RPATH "${TARGET_RPATH}" + ) + # No such thing as a CMake LINUX variable, contrary to APPLE and MSVC. + elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(TARGET_RPATH "$ORIGIN/../lib:$ORIGIN/../../USD/lib") + if(DEFINED PXR_USD_LOCATION) + string(APPEND TARGET_RPATH ":${PXR_USD_LOCATION}/lib:${PXR_USD_LOCATION}/lib64") + endif() + # Use RUNPATH instead of RPATH. + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags" PARENT_SCOPE) + set_target_properties(${plugin} + PROPERTIES + INSTALL_RPATH "${TARGET_RPATH}" + BUILD_WITH_INSTALL_RPATH TRUE + ) + endif() +endfunction(set_translators_plugin_properties) + add_subdirectory(translators) add_subdirectory(schemas) diff --git a/lib/usd/hdMaya/CMakeLists.txt b/lib/usd/hdMaya/CMakeLists.txt index a0cf42daab..b41bef232a 100644 --- a/lib/usd/hdMaya/CMakeLists.txt +++ b/lib/usd/hdMaya/CMakeLists.txt @@ -1,4 +1,4 @@ -set(TARGET_NAME hdmaya) +set(TARGET_NAME hdMaya) if (LUMA_USD_BUILD) set(HDMAYA_LUMA_BUILD_INT 1) @@ -6,10 +6,10 @@ else () set(HDMAYA_LUMA_BUILD_INT 0) endif () -set(HDMAYA_H "${CMAKE_CURRENT_BINARY_DIR}/hdmaya.h") +set(HDMAYA_H "${CMAKE_CURRENT_BINARY_DIR}/hdMaya.h") configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/hdmaya.h.in" + "${CMAKE_CURRENT_SOURCE_DIR}/hdMaya.h.in" ${HDMAYA_H} @ONLY ) @@ -126,11 +126,11 @@ if (LUMA_USD_BUILD) endif () # Wanted to do this: -# get_target_property(LIB_FULLPATH hdmaya LOCATION) +# get_target_property(LIB_FULLPATH hdMaya LOCATION) # get_filename_component(LIB_NAME ${LIB_FULLPATH} NAME) # set(PLUG_INFO_LIBRARY_PATH ${LIB_NAME}) # But apparently you can't look up LOCATION in cmake-2.8.0... nor can you use -# the generator expression "$" outside of special +# the generator expression "$" outside of special # commands, like add_custom_command... # So just building "manually" with PREFIX / SUFFIX get_target_property(LIB_PREFIX ${TARGET_NAME} PREFIX) @@ -143,7 +143,7 @@ if (LIB_SUFFIX STREQUAL LIB_SUFFIX-NOTFOUND OR LIB_SUFFIX STREQUAL NOTFOUND) set(LIB_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) endif (LIB_SUFFIX STREQUAL LIB_SUFFIX-NOTFOUND OR LIB_SUFFIX STREQUAL NOTFOUND) -set(PLUG_INFO_LIBRARY_PATH ${LIB_PREFIX}hdmaya${LIB_SUFFIX}) +set(PLUG_INFO_LIBRARY_PATH ${LIB_PREFIX}hdMaya${LIB_SUFFIX}) set(PLUG_INFO_PATH "plugInfo.json") @@ -157,7 +157,7 @@ configure_file( #============================================================================== install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PLUG_INFO_PATH} - DESTINATION lib/usd/hdmaya/resources) + DESTINATION lib/usd/hdMaya/resources) install( TARGETS ${TARGET_NAME} @@ -177,7 +177,7 @@ install( adapters/mayaAttrs.h adapters/shapeAdapter.h adapters/tokens.h - DESTINATION include/hdmaya/adapters) + DESTINATION include/hdMaya/adapters) install( FILES @@ -189,7 +189,7 @@ install( delegates/proxyDelegate.h delegates/proxyUsdImagingDelegate.h delegates/sceneDelegate.h - DESTINATION include/hdmaya/delegates) + DESTINATION include/hdMaya/delegates) install( FILES @@ -198,8 +198,8 @@ install( debugCodes.h ${HDMAYA_H} - DESTINATION include/hdmaya) + DESTINATION include/hdMaya) if(MSVC) install(FILES $ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib OPTIONAL) -endif() \ No newline at end of file +endif() diff --git a/lib/usd/hdMaya/adapters/adapterRegistry.cpp b/lib/usd/hdMaya/adapters/adapterRegistry.cpp index 06186b302e..90fe0070c5 100644 --- a/lib/usd/hdMaya/adapters/adapterRegistry.cpp +++ b/lib/usd/hdMaya/adapters/adapterRegistry.cpp @@ -30,7 +30,7 @@ #include -#include <../../../nodes/proxyShapeBase.h> +#include "../../../nodes/proxyShapeBase.h" #include diff --git a/lib/usd/hdMaya/adapters/imagePlaneAdapter.cpp b/lib/usd/hdMaya/adapters/imagePlaneAdapter.cpp index 730f4173ad..66810a6368 100644 --- a/lib/usd/hdMaya/adapters/imagePlaneAdapter.cpp +++ b/lib/usd/hdMaya/adapters/imagePlaneAdapter.cpp @@ -21,7 +21,7 @@ // KIND, either express or implied. See the Apache License for the specific // language governing permissions and limitations under the Apache License. // -#include +#include #if HDMAYA_LUMA_BUILD #include diff --git a/lib/usd/hdMaya/adapters/imagePlaneMaterialAdapter.cpp b/lib/usd/hdMaya/adapters/imagePlaneMaterialAdapter.cpp index 339256f52e..5bd3b71429 100644 --- a/lib/usd/hdMaya/adapters/imagePlaneMaterialAdapter.cpp +++ b/lib/usd/hdMaya/adapters/imagePlaneMaterialAdapter.cpp @@ -21,7 +21,7 @@ // KIND, either express or implied. See the Apache License for the specific // language governing permissions and limitations under the Apache License. // -#include +#include #if HDMAYA_LUMA_BUILD #include "materialAdapter.h" diff --git a/lib/usd/hdMaya/adapters/lightAdapter.cpp b/lib/usd/hdMaya/adapters/lightAdapter.cpp index 0c75896511..2942a9ffb8 100644 --- a/lib/usd/hdMaya/adapters/lightAdapter.cpp +++ b/lib/usd/hdMaya/adapters/lightAdapter.cpp @@ -23,7 +23,7 @@ // #include "lightAdapter.h" -#include +#include #include #include diff --git a/lib/usd/hdMaya/adapters/materialAdapter.cpp b/lib/usd/hdMaya/adapters/materialAdapter.cpp index 77edb1acee..4116956be7 100644 --- a/lib/usd/hdMaya/adapters/materialAdapter.cpp +++ b/lib/usd/hdMaya/adapters/materialAdapter.cpp @@ -23,7 +23,7 @@ // #include "materialAdapter.h" -#include +#include #include diff --git a/lib/usd/hdMaya/adapters/proxyAdapter.cpp b/lib/usd/hdMaya/adapters/proxyAdapter.cpp index c67b6c0163..d51efccd59 100644 --- a/lib/usd/hdMaya/adapters/proxyAdapter.cpp +++ b/lib/usd/hdMaya/adapters/proxyAdapter.cpp @@ -30,9 +30,9 @@ #include "../delegates/proxyDelegate.h" #include "../delegates/sceneDelegate.h" -#include +#include -#include <../../../nodes/proxyShapeBase.h> +#include "../../../nodes/proxyShapeBase.h" #include #include diff --git a/lib/usd/hdMaya/adapters/proxyAdapter.h b/lib/usd/hdMaya/adapters/proxyAdapter.h index f822f9a1ff..5de3096e8a 100644 --- a/lib/usd/hdMaya/adapters/proxyAdapter.h +++ b/lib/usd/hdMaya/adapters/proxyAdapter.h @@ -9,7 +9,7 @@ #include -#include <../../../listeners/proxyShapeNotice.h> +#include "../../../listeners/proxyShapeNotice.h" PXR_NAMESPACE_OPEN_SCOPE diff --git a/lib/usd/hdMaya/debugCodes.cpp b/lib/usd/hdMaya/debugCodes.cpp index 352c3bc1ee..dd0b123491 100644 --- a/lib/usd/hdMaya/debugCodes.cpp +++ b/lib/usd/hdMaya/debugCodes.cpp @@ -31,10 +31,10 @@ PXR_NAMESPACE_OPEN_SCOPE TF_REGISTRY_FUNCTION(TfDebug) { TF_DEBUG_ENVIRONMENT_SYMBOL( HDMAYA_AL_CALLBACKS, - "Print info about the various callbacks used by hdmaya_al"); + "Print info about the various callbacks used by hdMaya_al"); TF_DEBUG_ENVIRONMENT_SYMBOL( HDMAYA_AL_PLUGIN, - "Print info about the loading of the hdmaya_al plugin"); + "Print info about the loading of the hdMaya_al plugin"); TF_DEBUG_ENVIRONMENT_SYMBOL( HDMAYA_AL_POPULATE, "Print info about populating the delegate from the stage"); diff --git a/lib/usd/hdMaya/delegates/delegate.h b/lib/usd/hdMaya/delegates/delegate.h index 0e3912574b..32713dfc59 100644 --- a/lib/usd/hdMaya/delegates/delegate.h +++ b/lib/usd/hdMaya/delegates/delegate.h @@ -26,7 +26,7 @@ #include -#include +#include #include #include diff --git a/lib/usd/hdMaya/delegates/delegateCtx.cpp b/lib/usd/hdMaya/delegates/delegateCtx.cpp index ac60df25a3..eb21a194a0 100644 --- a/lib/usd/hdMaya/delegates/delegateCtx.cpp +++ b/lib/usd/hdMaya/delegates/delegateCtx.cpp @@ -23,7 +23,7 @@ // #include "delegateCtx.h" -#include +#include #include #include @@ -38,7 +38,7 @@ #include #endif // HDMAYA_USD_001905_BUILD -#include <../../../utils/util.h> +#include "../../../utils/util.h" #include diff --git a/lib/usd/hdMaya/delegates/delegateDebugCodes.cpp b/lib/usd/hdMaya/delegates/delegateDebugCodes.cpp index 9a0ee42834..13bb7a5141 100644 --- a/lib/usd/hdMaya/delegates/delegateDebugCodes.cpp +++ b/lib/usd/hdMaya/delegates/delegateDebugCodes.cpp @@ -158,7 +158,7 @@ TF_REGISTRY_FUNCTION(TfDebug) { TF_DEBUG_ENVIRONMENT_SYMBOL( HDMAYA_DELEGATE_SELECTION, - "Print information about hdmaya delegate selection."); + "Print information about hdMaya delegate selection."); } PXR_NAMESPACE_CLOSE_SCOPE diff --git a/lib/usd/hdMaya/delegates/proxyDelegate.cpp b/lib/usd/hdMaya/delegates/proxyDelegate.cpp index 94162aec5c..a42ed51f57 100644 --- a/lib/usd/hdMaya/delegates/proxyDelegate.cpp +++ b/lib/usd/hdMaya/delegates/proxyDelegate.cpp @@ -29,7 +29,7 @@ #include "delegateRegistry.h" -#include <../../../nodes/proxyShapeBase.h> +#include "../../../nodes/proxyShapeBase.h" #include #include diff --git a/lib/usd/hdMaya/delegates/proxyUsdImagingDelegate.cpp b/lib/usd/hdMaya/delegates/proxyUsdImagingDelegate.cpp index eb5b9169df..1f62fa076f 100644 --- a/lib/usd/hdMaya/delegates/proxyUsdImagingDelegate.cpp +++ b/lib/usd/hdMaya/delegates/proxyUsdImagingDelegate.cpp @@ -24,7 +24,7 @@ #include "proxyUsdImagingDelegate.h" -#include <../../../nodes/proxyShapeBase.h> +#include "../../../nodes/proxyShapeBase.h" #include diff --git a/lib/usd/hdMaya/delegates/sceneDelegate.cpp b/lib/usd/hdMaya/delegates/sceneDelegate.cpp index f7631a2d7b..47ef69054b 100644 --- a/lib/usd/hdMaya/delegates/sceneDelegate.cpp +++ b/lib/usd/hdMaya/delegates/sceneDelegate.cpp @@ -23,7 +23,7 @@ // #include "sceneDelegate.h" -#include +#include #include #include diff --git a/lib/usd/hdMaya/delegates/sceneDelegate.h b/lib/usd/hdMaya/delegates/sceneDelegate.h index 087c971309..b75bb56de4 100644 --- a/lib/usd/hdMaya/delegates/sceneDelegate.h +++ b/lib/usd/hdMaya/delegates/sceneDelegate.h @@ -26,7 +26,7 @@ #include -#include +#include #include diff --git a/lib/usd/hdMaya/hdmaya.h.in b/lib/usd/hdMaya/hdMaya.h.in similarity index 100% rename from lib/usd/hdMaya/hdmaya.h.in rename to lib/usd/hdMaya/hdMaya.h.in diff --git a/lib/usd/hdMaya/plugInfo.json b/lib/usd/hdMaya/plugInfo.json index 2800df31eb..1f811b7cb6 100644 --- a/lib/usd/hdMaya/plugInfo.json +++ b/lib/usd/hdMaya/plugInfo.json @@ -117,7 +117,7 @@ } }, "LibraryPath": "@PLUG_INFO_LIBRARY_PATH@", - "Name": "hdmaya", + "Name": "@TARGET_NAME@", "Root": ".", "Type": "library" } diff --git a/lib/usd/schemas/CMakeLists.txt b/lib/usd/schemas/CMakeLists.txt index 75cc8a75dd..b0f3a7d46d 100644 --- a/lib/usd/schemas/CMakeLists.txt +++ b/lib/usd/schemas/CMakeLists.txt @@ -54,14 +54,18 @@ add_library(${SCHEMA_PLUGIN} SHARED MayaReference.cpp tokens.cpp - ModuleDeps.cpp +# Python wrappers are not yet defined for this library. See +# plugin/al/schemas/AL/usd/schemas/maya/CMakeLists.txt +# for the existing AL schema Python wrappers. PPT, 26-Jul-2019. +# ModuleDeps.cpp ) target_compile_definitions(${SCHEMA_PLUGIN} PRIVATE MFB_PACKAGE_NAME=${SCHEMA_PLUGIN} MFB_ALT_PACKAGE_NAME=${SCHEMA_PLUGIN} - MFB_PACKAGE_MODULE=AL.usd.schemas.maya +# Python wrappers are not yet defined for this library. PPT, 26-Jul-2019. +# MFB_PACKAGE_MODULE=AL.usd.schemas.maya MAYAUSDCORE_SCHEMAS_EXPORTS ) @@ -72,6 +76,12 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(PTHREAD_LINK -lpthread -lm) endif() +#====================================================================== +# TARGET PROPERTIES +#====================================================================== + +set_translators_plugin_properties("${SCHEMA_PLUGIN}") + target_link_libraries(${SCHEMA_PLUGIN} ${DEPENDANT_LIBRARIES} ${PTHREAD_LINK}) install( diff --git a/lib/usd/schemas/ModuleDeps.cpp b/lib/usd/schemas/ModuleDeps.cpp index 4da4abc20c..31d76ed26a 100644 --- a/lib/usd/schemas/ModuleDeps.cpp +++ b/lib/usd/schemas/ModuleDeps.cpp @@ -12,7 +12,7 @@ TF_REGISTRY_FUNCTION(TfScriptModuleLoader) { reqs.push_back(TfToken("usd")); reqs.push_back(TfToken("usdGeom")); TfScriptModuleLoader::GetInstance(). - RegisterLibrary(TfToken("MayaUsd_Schemas"), TfToken("AL.usd.schemas.maya"), reqs); + RegisterLibrary(TfToken(#MFB_PACKAGE_NAME), TfToken("AL.usd.schemas.maya"), reqs); } PXR_NAMESPACE_CLOSE_SCOPE diff --git a/lib/usd/schemas/plugInfo.json.in b/lib/usd/schemas/plugInfo.json.in index 4f9306fcdc..53fb8b1348 100644 --- a/lib/usd/schemas/plugInfo.json.in +++ b/lib/usd/schemas/plugInfo.json.in @@ -17,11 +17,11 @@ } } }, - "LibraryPath": "${SCHEMAS_LIBRARY_DIR}/@CMAKE_SHARED_LIBRARY_PREFIX@MayaUsd_Schemas@CMAKE_SHARED_LIBRARY_SUFFIX@", - "Name": "MayaUsd_Schemas", + "LibraryPath": "${SCHEMAS_LIBRARY_DIR}/@CMAKE_SHARED_LIBRARY_PREFIX@@SCHEMA_PLUGIN@@CMAKE_SHARED_LIBRARY_SUFFIX@", + "Name": "@SCHEMA_PLUGIN@", "ResourcePath": "@PLUG_INFO_RESOURCE_PATH@", "Root": "..", "Type": "library" } ] -} \ No newline at end of file +} diff --git a/lib/usd/schemas/schema.usda.in b/lib/usd/schemas/schema.usda.in index a04cec8915..94ef20cf92 100644 --- a/lib/usd/schemas/schema.usda.in +++ b/lib/usd/schemas/schema.usda.in @@ -11,7 +11,7 @@ over "GLOBAL" ( customData = { - string libraryName = "MayaUsd_Schemas" + string libraryName = "@SCHEMA_PLUGIN@" string libraryPath = "." string libraryPrefix = "AL_usd_"#This AL_ is here to get around that the Jinja template doesn't generate a template that supports namespaces. If we had a AL namespace then I could remove this AL. string tokensPrefix = "MayaUsd_Schemas" diff --git a/lib/usd/translators/CMakeLists.txt b/lib/usd/translators/CMakeLists.txt index be26b47b24..560f659ef3 100644 --- a/lib/usd/translators/CMakeLists.txt +++ b/lib/usd/translators/CMakeLists.txt @@ -64,25 +64,8 @@ add_library(${TRANSLATORS_PLUGIN} SHARED ${source}) #====================================================================== # TARGET PROPERTIES #====================================================================== -if(MSVC) - set_target_properties(${TRANSLATORS_PLUGIN} PROPERTIES SUFFIX ".mll") -elseif(APPLE) - set(CMAKE_MACOSX_RPATH ON) - set_target_properties(${TRANSLATORS_PLUGIN} - PROPERTIES - PREFIX "" - SUFFIX ".bundle" - BUILD_WITH_INSTALL_RPATH TRUE - INSTALL_RPATH "@loader_path/../lib;@loader_path/../../USD/lib;@loader_path/../../USD/maya/lib;${PXR_USD_LOCATION}/lib" - ) -else() - set_target_properties(${TRANSLATORS_PLUGIN} - PROPERTIES - PREFIX "" - INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/../../USD/lib:$ORIGIN/../../USD/maya/lib:${PXR_USD_LOCATION}/lib:${PXR_USD_LOCATION}/lib64" - BUILD_WITH_INSTALL_RPATH TRUE - ) -endif() + +set_translators_plugin_properties("${TRANSLATORS_PLUGIN}") #====================================================================== # INCLUDE, LINK diff --git a/lib/usd/translators/mayaReferenceReader.cpp b/lib/usd/translators/mayaReferenceReader.cpp index cc8923c588..214fb507bd 100644 --- a/lib/usd/translators/mayaReferenceReader.cpp +++ b/lib/usd/translators/mayaReferenceReader.cpp @@ -34,7 +34,7 @@ #include <../../fileio/primReaderRegistry.h> #include <../../fileio/translators/translatorMayaReference.h> -#include <../../schemas/MayaReference.h> +#include <../schemas/MayaReference.h> #include "pxr/usd/usd/prim.h" #include "pxr/usd/usdGeom/camera.h" diff --git a/lib/usd/translators/mayaReferenceUpdater.cpp b/lib/usd/translators/mayaReferenceUpdater.cpp index e169a11d29..b796096ca5 100644 --- a/lib/usd/translators/mayaReferenceUpdater.cpp +++ b/lib/usd/translators/mayaReferenceUpdater.cpp @@ -19,7 +19,7 @@ #include <../../fileio/utils/adaptor.h> #include <../../fileio/primUpdaterRegistry.h> #include <../../utils/util.h> -#include <../../schemas/MayaReference.h> +#include <../schemas/MayaReference.h> #include <../../fileio/translators/translatorMayaReference.h> #include "pxr/base/gf/vec2f.h" diff --git a/lib/usd/translators/plugInfo.json b/lib/usd/translators/plugInfo.json index 60d76325fb..4618b09857 100644 --- a/lib/usd/translators/plugInfo.json +++ b/lib/usd/translators/plugInfo.json @@ -4,7 +4,6 @@ "Info": { "UsdMaya": { "PrimReader": { - "mayaPlugin": "mayaUsdTranslators", "providesTranslator": [ "UsdGeomCamera", "UsdGeomMesh", @@ -27,13 +26,11 @@ ] }, "PrimUpdater": { - "mayaPlugin": "mayaUsdTranslators", "providesTranslator": [ "AL_usd_MayaReference" ] }, "PrimWriter": { - "mayaPlugin": "mayaUsdTranslators", "providesTranslator": [ "camera", "file", @@ -57,8 +54,8 @@ } } }, - "LibraryPath": "../../../mayaUsd_Translators.mll", - "Name": "mayaUsd_Translators", + "LibraryPath": "../../../@CMAKE_SHARED_LIBRARY_PREFIX@@TRANSLATORS_PLUGIN@@CMAKE_SHARED_LIBRARY_SUFFIX@", + "Name": "@TRANSLATORS_PLUGIN@", "Type": "library" } ] From 0811aace46d23a5eaff999dc639b9db8d1021c02 Mon Sep 17 00:00:00 2001 From: Huidong Chen Date: Wed, 31 Jul 2019 13:41:22 -0400 Subject: [PATCH 08/22] MAYA-99736 Fix build errors with Maya 2018 (#87) Build with Maya 2018 has passed on Windows. Smoke test looks fine. --- lib/render/vp2RenderDelegate/material.cpp | 1 - lib/render/vp2RenderDelegate/mesh.cpp | 36 +++++++++++++------ .../vp2RenderDelegate/proxyRenderDelegate.cpp | 23 +++++++----- .../vp2RenderDelegate/render_delegate.cpp | 12 +++++-- .../vp2RenderDelegate/render_delegate.h | 2 ++ lib/render/vp2RenderDelegate/render_param.cpp | 4 --- lib/render/vp2RenderDelegate/texture.cpp | 4 --- 7 files changed, 50 insertions(+), 32 deletions(-) diff --git a/lib/render/vp2RenderDelegate/material.cpp b/lib/render/vp2RenderDelegate/material.cpp index 669d61cc62..fcb78e650e 100644 --- a/lib/render/vp2RenderDelegate/material.cpp +++ b/lib/render/vp2RenderDelegate/material.cpp @@ -26,7 +26,6 @@ PXR_NAMESPACE_OPEN_SCOPE namespace { -int _profilerCategory = MProfiler::addCategory("HdVP2RenderDelegate", "HdVP2RenderDelegate"); //!< Profiler category /* \brief Finds the path to an XML shader fragment file based on plugin.json. */ diff --git a/lib/render/vp2RenderDelegate/mesh.cpp b/lib/render/vp2RenderDelegate/mesh.cpp index 98f2ef7cf4..261238df29 100644 --- a/lib/render/vp2RenderDelegate/mesh.cpp +++ b/lib/render/vp2RenderDelegate/mesh.cpp @@ -83,7 +83,15 @@ namespace { } } - int _profilerCategory = MProfiler::addCategory("HdVP2RenderDelegate", "HdVP2RenderDelegate"); //!< Profiler category + //! Helper utility function to adapt Maya API changes. + void setWantConsolidation(MHWRender::MRenderItem& renderItem, bool state) + { +#if MAYA_API_VERSION >= 20190000 + renderItem.setWantConsolidation(state); +#else + renderItem.setWantSubSceneConsolidation(state); +#endif + } } //namespace @@ -105,7 +113,8 @@ void HdVP2Mesh::Sync( HdSceneDelegate* delegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, const TfToken& reprToken) { - MProfilingScope profilingScope(_profilerCategory, MProfiler::kColorC_L2, GetId().GetText(), "HdVP2Mesh Sync"); + MProfilingScope profilingScope(HdVP2RenderDelegate::sProfilerCategory, + MProfiler::kColorC_L2, GetId().GetText(), "HdVP2Mesh Sync"); if (*dirtyBits & HdChangeTracker::DirtyMaterialId) { _SetMaterialId(delegate->GetRenderIndex().GetChangeTracker(), @@ -711,10 +720,8 @@ void HdVP2Mesh::_UpdateDrawItem( { const MString& renderItemName = drawItem->GetRenderItemName(); - MProfilingScope profilingScope( - _profilerCategory, MProfiler::kColorC_L2, - renderItemName.asChar(), "HdVP2Mesh Commit Buffers" - ); + MProfilingScope profilingScope(HdVP2RenderDelegate::sProfilerCategory, + MProfiler::kColorC_L2, renderItemName.asChar(), "HdVP2Mesh Commit Buffers"); MHWRender::MRenderItem* renderItem = param->GetContainer()->find(renderItemName); if(!renderItem) { @@ -771,7 +778,7 @@ void HdVP2Mesh::_UpdateDrawItem( auto& oldInstanceCount = stateToCommit._drawItemData._instanceCount; auto newInstanceCount = stateToCommit._instanceTransforms.length(); if(newInstanceCount > 0) { - renderItem->setWantConsolidation(false); + setWantConsolidation(*renderItem, false); if(oldInstanceCount == newInstanceCount) { for (unsigned int i = 0; i < newInstanceCount; i++) { // VP2 defines instance ID of the first instance to be 1. @@ -782,7 +789,7 @@ void HdVP2Mesh::_UpdateDrawItem( } oldInstanceCount = newInstanceCount; } else if(oldInstanceCount > 0) { - renderItem->setWantConsolidation(true); + setWantConsolidation(*renderItem, true); param->GetDrawScene().removeAllInstances(*renderItem); oldInstanceCount = 0; } @@ -802,13 +809,14 @@ MHWRender::MRenderItem* HdVP2Mesh::_CreatePointsRenderItem(const MString& name) renderItem->setDrawMode(MHWRender::MGeometry::kSelectionOnly); renderItem->castsShadows(false); renderItem->receivesShadows(false); - renderItem->setWantConsolidation(true); renderItem->setShader(_delegate->Get3dFatPointShader()); MSelectionMask selectionMask(MSelectionMask::kSelectPointsForGravity); selectionMask.addMask(MSelectionMask::kSelectMeshVerts); renderItem->setSelectionMask(selectionMask); + setWantConsolidation(*renderItem, true); + return renderItem; } @@ -825,9 +833,12 @@ MHWRender::MRenderItem* HdVP2Mesh::_CreateWireframeRenderItem(const MString& nam renderItem->depthPriority(MHWRender::MRenderItem::sActiveWireDepthPriority); renderItem->castsShadows(false); renderItem->receivesShadows(false); - renderItem->setWantConsolidation(true); renderItem->setShader(_delegate->Get3dSolidShader()); + renderItem->setSelectionMask(MSelectionMask()); + + setWantConsolidation(*renderItem, true); + return renderItem; } @@ -844,9 +855,12 @@ MHWRender::MRenderItem* HdVP2Mesh::_CreateSmoothHullRenderItem(const MString& na renderItem->setExcludedFromPostEffects(false); renderItem->castsShadows(true); renderItem->receivesShadows(true); - renderItem->setWantConsolidation(true); renderItem->setShader(_delegate->GetFallbackShader()); + renderItem->setSelectionMask(MSelectionMask::kSelectMeshes); + + setWantConsolidation(*renderItem, true); + return renderItem; } diff --git a/lib/render/vp2RenderDelegate/proxyRenderDelegate.cpp b/lib/render/vp2RenderDelegate/proxyRenderDelegate.cpp index af5978aadc..c9592c34a9 100644 --- a/lib/render/vp2RenderDelegate/proxyRenderDelegate.cpp +++ b/lib/render/vp2RenderDelegate/proxyRenderDelegate.cpp @@ -41,8 +41,6 @@ PXR_NAMESPACE_OPEN_SCOPE namespace { - int _profilerCategory = MProfiler::addCategory("HdVP2RenderDelegate", "HdVP2RenderDelegate"); //!< Profiler category - MGlobal::ListAdjustment GetListAdjustment() { // Keyboard modifiers can be queried from QApplication::keyboardModifiers() @@ -169,17 +167,20 @@ void ProxyRenderDelegate::_InitRenderDelegate() { } if (!_renderDelegate) { - MProfilingScope subProfilingScope(_profilerCategory, MProfiler::kColorD_L1, "Allocate VP2RenderDelegate"); + MProfilingScope subProfilingScope(HdVP2RenderDelegate::sProfilerCategory, + MProfiler::kColorD_L1, "Allocate VP2RenderDelegate"); _renderDelegate = new HdVP2RenderDelegate(*this); } if (!_renderIndex) { - MProfilingScope subProfilingScope(_profilerCategory, MProfiler::kColorD_L1, "Allocate RenderIndex"); + MProfilingScope subProfilingScope(HdVP2RenderDelegate::sProfilerCategory, + MProfiler::kColorD_L1, "Allocate RenderIndex"); _renderIndex = HdRenderIndex::New(_renderDelegate); } if (!_sceneDelegate) { - MProfilingScope subProfilingScope(_profilerCategory, MProfiler::kColorD_L1, "Allocate SceneDelegate"); + MProfilingScope subProfilingScope(HdVP2RenderDelegate::sProfilerCategory, + MProfiler::kColorD_L1, "Allocate SceneDelegate"); SdfPath delegateID = SdfPath::AbsoluteRootPath().AppendChild(TfToken(TfStringPrintf( "Proxy_%s_%p", usdSubSceneShape->name().asChar(), usdSubSceneShape))); @@ -240,7 +241,8 @@ bool ProxyRenderDelegate::_Populate() { return false; if (!_isPopulated && _usdStage) { - MProfilingScope subProfilingScope(_profilerCategory, MProfiler::kColorD_L1, "Populate"); + MProfilingScope subProfilingScope(HdVP2RenderDelegate::sProfilerCategory, + MProfiler::kColorD_L1, "Populate"); _sceneDelegate->Populate(_usdStage->GetPseudoRoot()); _isPopulated = true; @@ -251,7 +253,8 @@ bool ProxyRenderDelegate::_Populate() { //! \brief Synchronize USD scene delegate time with Maya's scene time. void ProxyRenderDelegate::_UpdateTime() { - MProfilingScope profilingScope(_profilerCategory, MProfiler::kColorC_L1, "Update Time"); + MProfilingScope profilingScope(HdVP2RenderDelegate::sProfilerCategory, + MProfiler::kColorC_L1, "Update Time"); MayaUsdProxyShapeBase* usdSubSceneShape = getProxyShape(); if(usdSubSceneShape && _sceneDelegate) { @@ -262,7 +265,8 @@ void ProxyRenderDelegate::_UpdateTime() { //! \brief Execute Hydra engine which will performe minimal update VP2 state update based on change tracker. void ProxyRenderDelegate::_Execute(const MHWRender::MFrameContext& frameContext) { - MProfilingScope profilingScope(_profilerCategory, MProfiler::kColorC_L1, "Execute"); + MProfilingScope profilingScope(HdVP2RenderDelegate::sProfilerCategory, + MProfiler::kColorC_L1, "Execute"); #if defined(MAYA_ENABLE_UPDATE_FOR_SELECTION) // Since Maya 2020, subscene update can be invoked in a selection pass. @@ -311,7 +315,8 @@ void ProxyRenderDelegate::_Execute(const MHWRender::MFrameContext& frameContext) //! \brief Main update entry from subscene override. void ProxyRenderDelegate::update(MSubSceneContainer& container, const MFrameContext& frameContext) { - MProfilingScope profilingScope(_profilerCategory, MProfiler::kColorD_L1, "ProxyRenderDelegate::update"); + MProfilingScope profilingScope(HdVP2RenderDelegate::sProfilerCategory, + MProfiler::kColorD_L1, "ProxyRenderDelegate::update"); _InitRenderDelegate(); if (_Populate()) { diff --git a/lib/render/vp2RenderDelegate/render_delegate.cpp b/lib/render/vp2RenderDelegate/render_delegate.cpp index 50acb6bfbc..4b801a525d 100644 --- a/lib/render/vp2RenderDelegate/render_delegate.cpp +++ b/lib/render/vp2RenderDelegate/render_delegate.cpp @@ -80,10 +80,16 @@ namespace const MString _diffuseColorParameterName = "diffuseColor"; //!< Shader parameter name const MString _solidColorParameterName = "solidColor"; //!< Shader parameter name const MString _pointSizeParameterName = "pointSize"; //!< Shader parameter name - - int _profilerCategory = MProfiler::addCategory("HdVP2RenderDelegate", "HdVP2RenderDelegate"); //!< Profiler category } // namespace +const int HdVP2RenderDelegate::sProfilerCategory = MProfiler::addCategory( +#if MAYA_API_VERSION >= 20190000 + "HdVP2RenderDelegate", "HdVP2RenderDelegate" +#else + "HdVP2RenderDelegate" +#endif +); + std::mutex HdVP2RenderDelegate::_mutexResourceRegistry; std::atomic_int HdVP2RenderDelegate::_counterResourceRegistry; HdResourceRegistrySharedPtr HdVP2RenderDelegate::_resourceRegistry; @@ -130,7 +136,7 @@ HdRenderParam* HdVP2RenderDelegate::GetRenderParam() const { void HdVP2RenderDelegate::CommitResources(HdChangeTracker* tracker) { TF_UNUSED(tracker); - MProfilingScope profilingScope(_profilerCategory, MProfiler::kColorC_L2, "Commit resources"); + MProfilingScope profilingScope(sProfilerCategory, MProfiler::kColorC_L2, "Commit resources"); // --------------------------------------------------------------------- // // RESOLVE, COMPUTE & COMMIT PHASE diff --git a/lib/render/vp2RenderDelegate/render_delegate.h b/lib/render/vp2RenderDelegate/render_delegate.h index 35ca5c40f9..53d4100c6e 100644 --- a/lib/render/vp2RenderDelegate/render_delegate.h +++ b/lib/render/vp2RenderDelegate/render_delegate.h @@ -102,6 +102,8 @@ class HdVP2RenderDelegate final : public HdRenderDelegate { MHWRender::MShaderInstance* Get3dSolidShader() const; MHWRender::MShaderInstance* Get3dFatPointShader() const; + static const int sProfilerCategory; //!< Profiler category + private: HdVP2RenderDelegate(const HdVP2RenderDelegate&) = delete; HdVP2RenderDelegate& operator=(const HdVP2RenderDelegate&) = delete; diff --git a/lib/render/vp2RenderDelegate/render_param.cpp b/lib/render/vp2RenderDelegate/render_param.cpp index 705408074b..67a25f6cf5 100644 --- a/lib/render/vp2RenderDelegate/render_param.cpp +++ b/lib/render/vp2RenderDelegate/render_param.cpp @@ -12,10 +12,6 @@ PXR_NAMESPACE_OPEN_SCOPE -namespace { - int _profilerCategory = MProfiler::addCategory("HdVP2RenderDelegate", "HdVP2RenderDelegate"); //!< Profiler category -} //namespace - /*! \brief Begin update before rendering of VP2 starts. */ void HdVP2RenderParam::BeginUpdate(MSubSceneContainer& container, UsdTimeCode frame) { diff --git a/lib/render/vp2RenderDelegate/texture.cpp b/lib/render/vp2RenderDelegate/texture.cpp index 288d77c199..969b809e56 100644 --- a/lib/render/vp2RenderDelegate/texture.cpp +++ b/lib/render/vp2RenderDelegate/texture.cpp @@ -14,10 +14,6 @@ PXR_NAMESPACE_OPEN_SCOPE -namespace { - int _profilerCategory = MProfiler::addCategory("HdVP2RenderDelegate", "HdVP2RenderDelegate"); //!< Profiler category -} //namespace - /*! \brief Constructor */ HdVP2Texture::HdVP2Texture( From b82530ffae88a1b4aaa73597875bbe9a84d2065f Mon Sep 17 00:00:00 2001 From: Hamed Sabri Date: Wed, 31 Jul 2019 14:28:36 -0400 Subject: [PATCH 09/22] - Added support for stages in the build script. Comma-separated list of stages can now be passed to the build system using --stages flag. By default 'clean','configure','build','install' stages are executed if this argument is not set. (#88) (cherry picked from commit 2124591d77246595f578cfbeb712f9e113083470) (cherry picked from commit e3524c668c50cb1cde80f4e9313229d8a9d27d16) --- build.py | 83 ++++++++++++++++++++++++++++++++-------------------- doc/build.md | 5 +++- 2 files changed, 55 insertions(+), 33 deletions(-) diff --git a/build.py b/build.py index c24072dfda..c429288d5b 100644 --- a/build.py +++ b/build.py @@ -222,7 +222,7 @@ def CurrentWorkingDirectory(dir): ############################################################ # CMAKE -def RunCMake(context, force, extraArgs=None): +def RunCMake(context, extraArgs=None, stages=None): """Invoke CMake to configure, build, and install a library whose source code is located in the current working directory.""" @@ -230,9 +230,10 @@ def RunCMake(context, force, extraArgs=None): instDir = context.instDir buildDir = context.buildDir - if force and os.path.isdir(buildDir): + if 'clean' in stages and os.path.isdir(buildDir): shutil.rmtree(buildDir) - if force and os.path.isdir(instDir): + + if 'clean' in stages and os.path.isdir(instDir): shutil.rmtree(instDir) if not os.path.isdir(buildDir): @@ -265,30 +266,37 @@ def RunCMake(context, force, extraArgs=None): if os.path.isfile(context.logFileLocation): os.remove(context.logFileLocation) - Run('cmake ' - '-DCMAKE_INSTALL_PREFIX="{instDir}" ' - '-DCMAKE_BUILD_TYPE={variant} ' - '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON' - '{osx_rpath} ' - '{generator} ' - '{extraArgs} ' - '"{srcDir}"' - .format(instDir=instDir, - variant=variant, - srcDir=srcDir, - osx_rpath=(osx_rpath or ""), - generator=(generator or ""), - extraArgs=(" ".join(extraArgs) if extraArgs else ""))) - Run("cmake --build . --config {variant} --target install -- {multiproc}" + if 'configure' in stages: + Run('cmake ' + '-DCMAKE_INSTALL_PREFIX="{instDir}" ' + '-DCMAKE_BUILD_TYPE={variant} ' + '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON' + '{osx_rpath} ' + '{generator} ' + '{extraArgs} ' + '"{srcDir}"' + .format(instDir=instDir, + variant=variant, + srcDir=srcDir, + osx_rpath=(osx_rpath or ""), + generator=(generator or ""), + extraArgs=(" ".join(extraArgs) if extraArgs else ""))) + + installArg = "" + if 'install' in stages: + installArg = "--target install" + + Run("cmake --build . --config {variant} {installArg} -- {multiproc}" .format(variant=variant, + installArg=installArg, multiproc=FormatMultiProcs(context.numJobs, generator))) ############################################################ # Maya USD -def InstallMayaUSD(context, force, buildArgs): +def InstallMayaUSD(context, buildArgs, stages): with CurrentWorkingDirectory(context.mayaUsdSrcDir): extraArgs = [] - + stagesArgs = [] if context.mayaLocation: extraArgs.append('-DMAYA_LOCATION="{mayaLocation}"' .format(mayaLocation=context.mayaLocation)) @@ -304,7 +312,10 @@ def InstallMayaUSD(context, force, buildArgs): # Add on any user-specified extra arguments. extraArgs += buildArgs - RunCMake(context, force, extraArgs) + # Add on any user-specified stages arguments. + stagesArgs += stages + + RunCMake(context, extraArgs, stagesArgs) ############################################################ # ArgumentParser @@ -346,18 +357,16 @@ def InstallMayaUSD(context, force, buildArgs): help="Build in RelWithDebInfo mode") parser.add_argument("--build-args", type=str, nargs="*", default=[], - help=("Custom arguments to pass to build system when " - "building libraries")) + help=("Comma-separated list of arguments passed into CMake when building libraries")) + +parser.add_argument("--stages", type=str, nargs="*", default=['clean','configure','build','install'], + help=("Comma-separated list of stages to execute.( possible stages: clean, configure, build, install)")) parser.add_argument("-j", "--jobs", type=int, default=GetCPUCount(), help=("Number of build jobs to run in parallel. " "(default: # of processors [{0}])" .format(GetCPUCount()))) -parser.add_argument("--force", type=str, action="append", dest="force_clean_build", - default=[], - help=("Force clean build.")) - args = parser.parse_args() ############################################################ @@ -386,9 +395,6 @@ def __init__(self, args): self.instDir = (os.path.abspath(args.install_location) if args.install_location else os.path.join(self.workspaceDir, "install", BuildVariant(self))) - # Forced to be built - self.forceBuild = args.force_clean_build - # CMake generator self.cmakeGenerator = args.generator @@ -419,6 +425,14 @@ def __init__(self, args): argList = args.split(",") for arg in argList: self.buildArgs.append(arg) + + # Stages arguments + self.stagesArgs = list() + for args in args.stages: + argList = args.split(",") + for arg in argList: + self.stagesArgs.append(arg) + try: context = InstallContext(args) except Exception as e: @@ -438,7 +452,11 @@ def __init__(self, args): if context.buildArgs: summaryMsg += """ - Extra Build arguments {buildArgs}""" + Extra Build arguments {buildArgs}""" + +if context.stagesArgs: + summaryMsg += """ + Stages arguments {stagesArgs}""" summaryMsg = summaryMsg.format( mayaUsdSrcDir=context.mayaUsdSrcDir, @@ -447,6 +465,7 @@ def __init__(self, args): instDir=context.instDir, logFileLocation=context.logFileLocation, buildArgs=context.buildArgs, + stagesArgs=context.stagesArgs, buildVariant=BuildVariant(context), cmakeGenerator=("Default" if not context.cmakeGenerator else context.cmakeGenerator) @@ -455,7 +474,7 @@ def __init__(self, args): Print(summaryMsg) # Install MayaUSD -InstallMayaUSD(context, context.forceBuild, context.buildArgs) +InstallMayaUSD(context, context.buildArgs, context.stagesArgs) # Ensure directory structure is created and is writable. for dir in [context.workspaceDir, context.buildDir, context.instDir]: diff --git a/doc/build.md b/doc/build.md index b293520275..e9f62a8de9 100644 --- a/doc/build.md +++ b/doc/build.md @@ -36,12 +36,15 @@ There are four arguments that must be passed to the script: When building Pixar USD Core, you need to pass ```--no-maya``` to ensure that ```third_party/maya``` plugin doesn't get built. -Custom arguments can be also passed to build system using ```--build-args```. +Comma-separated list of cmake variables can be also passed to build system using ```--build-args```. e.g ``` python build.py --build-args="-DBUILD_ADSK_PLUGIN=ON,-DBUILD_PXR_PLUGIN=OFF" ``` +Comma-separated list of stages can also be passed to the build system using ```--stages```. By default +'clean','configure','build','install' stages are executed if this argument is not set. + #### 4. CMake Generator It is up to the user to select the CMake Generator of choice but, we encourage the use of the Ninja generator. From 3b79e1be908179b8763f530d75aa020d6dbe25ed Mon Sep 17 00:00:00 2001 From: Hamed Sabri Date: Wed, 31 Jul 2019 14:41:09 -0400 Subject: [PATCH 10/22] - Added the check for build stage that I missed in my initial commit. (cherry picked from commit 8b3b348342777896d9fe91a129b9bbaec33d5114) --- build.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build.py b/build.py index c429288d5b..dfc3dbcb8c 100644 --- a/build.py +++ b/build.py @@ -285,11 +285,12 @@ def RunCMake(context, extraArgs=None, stages=None): installArg = "" if 'install' in stages: installArg = "--target install" - - Run("cmake --build . --config {variant} {installArg} -- {multiproc}" - .format(variant=variant, - installArg=installArg, - multiproc=FormatMultiProcs(context.numJobs, generator))) + + if 'build' in stages: + Run("cmake --build . --config {variant} {installArg} -- {multiproc}" + .format(variant=variant, + installArg=installArg, + multiproc=FormatMultiProcs(context.numJobs, generator))) ############################################################ # Maya USD From 578e24d522965fc5fe92f2c01c3ccce65177994a Mon Sep 17 00:00:00 2001 From: Hamed Sabri Date: Wed, 31 Jul 2019 15:01:11 -0400 Subject: [PATCH 11/22] Revert "- Added the check for build stage that I missed in my initial commit." This reverts commit 3b79e1be908179b8763f530d75aa020d6dbe25ed. --- build.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build.py b/build.py index dfc3dbcb8c..c429288d5b 100644 --- a/build.py +++ b/build.py @@ -285,12 +285,11 @@ def RunCMake(context, extraArgs=None, stages=None): installArg = "" if 'install' in stages: installArg = "--target install" - - if 'build' in stages: - Run("cmake --build . --config {variant} {installArg} -- {multiproc}" - .format(variant=variant, - installArg=installArg, - multiproc=FormatMultiProcs(context.numJobs, generator))) + + Run("cmake --build . --config {variant} {installArg} -- {multiproc}" + .format(variant=variant, + installArg=installArg, + multiproc=FormatMultiProcs(context.numJobs, generator))) ############################################################ # Maya USD From ea6fd603f5b28d699ddd23d9d986cd1a78e38c98 Mon Sep 17 00:00:00 2001 From: Sean Donnelly Date: Wed, 31 Jul 2019 15:42:21 -0400 Subject: [PATCH 12/22] MAYA-99741 - Build all 3 plugins build/work in sandbox (#90) * Linux (gcc) and Mac (clang) fixes. --- lib/render/mayaToHydra/shadingModeExporter.cpp | 4 ++-- lib/usd/hdMaya/adapters/materialAdapter.cpp | 2 +- lib/usd/hdMaya/adapters/materialNetworkConverter.h | 2 +- lib/usd/translators/cameraReader.cpp | 4 ++-- lib/usd/translators/cameraWriter.cpp | 10 +++++----- lib/usd/translators/cameraWriter.h | 4 ++-- lib/usd/translators/fileTextureWriter.cpp | 8 ++++---- lib/usd/translators/fileTextureWriter.h | 4 ++-- lib/usd/translators/instancerWriter.cpp | 10 +++++----- lib/usd/translators/instancerWriter.h | 6 +++--- lib/usd/translators/jointWriter.cpp | 14 +++++++------- lib/usd/translators/jointWriter.h | 4 ++-- lib/usd/translators/lightReader.cpp | 4 ++-- lib/usd/translators/lightWriter.cpp | 4 ++-- lib/usd/translators/locatorWriter.cpp | 6 +++--- lib/usd/translators/locatorWriter.h | 4 ++-- lib/usd/translators/materialReader.cpp | 4 ++-- lib/usd/translators/mayaReferenceReader.cpp | 6 +++--- lib/usd/translators/mayaReferenceUpdater.cpp | 10 +++++----- lib/usd/translators/mayaReferenceUpdater.h | 2 +- lib/usd/translators/meshReader.cpp | 4 ++-- lib/usd/translators/meshWriter.cpp | 14 +++++++------- lib/usd/translators/meshWriter.h | 4 ++-- lib/usd/translators/meshWriter_Primvars.cpp | 8 ++++---- lib/usd/translators/meshWriter_Skin.cpp | 6 +++--- lib/usd/translators/nurbsCurveWriter.cpp | 8 ++++---- lib/usd/translators/nurbsCurveWriter.h | 4 ++-- lib/usd/translators/nurbsCurvesReader.cpp | 4 ++-- lib/usd/translators/nurbsPatchReader.cpp | 4 ++-- lib/usd/translators/nurbsSurfaceWriter.cpp | 10 +++++----- lib/usd/translators/nurbsSurfaceWriter.h | 4 ++-- lib/usd/translators/particleWriter.cpp | 8 ++++---- lib/usd/translators/particleWriter.h | 4 ++-- lib/usd/translators/scopeReader.cpp | 4 ++-- lib/usd/translators/skelReader.cpp | 6 +++--- lib/usd/translators/xformReader.cpp | 4 ++-- 36 files changed, 104 insertions(+), 104 deletions(-) diff --git a/lib/render/mayaToHydra/shadingModeExporter.cpp b/lib/render/mayaToHydra/shadingModeExporter.cpp index 9450b32e18..2c493a4b92 100644 --- a/lib/render/mayaToHydra/shadingModeExporter.cpp +++ b/lib/render/mayaToHydra/shadingModeExporter.cpp @@ -37,8 +37,8 @@ auto& HioGlslfxTokens = PXR_NS::GlfGLSLFXTokens; #include #include -#include <../../fileio/shading/shadingModeExporter.h> -#include <../../fileio/shading/shadingModeRegistry.h> +#include "../../fileio/shading/shadingModeExporter.h" +#include "../../fileio/shading/shadingModeRegistry.h" #include "../../usd/hdMaya/adapters/materialNetworkConverter.h" diff --git a/lib/usd/hdMaya/adapters/materialAdapter.cpp b/lib/usd/hdMaya/adapters/materialAdapter.cpp index 4116956be7..db6843fb53 100644 --- a/lib/usd/hdMaya/adapters/materialAdapter.cpp +++ b/lib/usd/hdMaya/adapters/materialAdapter.cpp @@ -599,7 +599,7 @@ class HdMayaShadingEngineAdapter : public HdMayaMaterialAdapter { inline std::tuple _GetWrappingParams( const MObject& fileObj) { - constexpr std::tuple def{HdWrapClamp, HdWrapClamp}; + const std::tuple def{HdWrapClamp, HdWrapClamp}; MStatus status; MFnDependencyNode fileNode(fileObj, &status); if (!status) { return def; } diff --git a/lib/usd/hdMaya/adapters/materialNetworkConverter.h b/lib/usd/hdMaya/adapters/materialNetworkConverter.h index 9a26047ac1..2a0f47afe0 100644 --- a/lib/usd/hdMaya/adapters/materialNetworkConverter.h +++ b/lib/usd/hdMaya/adapters/materialNetworkConverter.h @@ -121,7 +121,7 @@ class HdMayaMaterialNodeConverter { private: NameToAttrConverterMap _attrConverters; - const TfToken _identifier; + mutable TfToken _identifier; }; class HdMayaMaterialNetworkConverter { diff --git a/lib/usd/translators/cameraReader.cpp b/lib/usd/translators/cameraReader.cpp index f465476648..978425a794 100644 --- a/lib/usd/translators/cameraReader.cpp +++ b/lib/usd/translators/cameraReader.cpp @@ -15,8 +15,8 @@ // #include "pxr/pxr.h" -#include <../../fileio/primReaderRegistry.h> -#include <../../fileio/translators/translatorCamera.h> +#include "../../fileio/primReaderRegistry.h" +#include "../../fileio/translators/translatorCamera.h" #include "pxr/usd/usd/prim.h" #include "pxr/usd/usdGeom/camera.h" diff --git a/lib/usd/translators/cameraWriter.cpp b/lib/usd/translators/cameraWriter.cpp index 21e50915f7..a792783500 100644 --- a/lib/usd/translators/cameraWriter.cpp +++ b/lib/usd/translators/cameraWriter.cpp @@ -16,11 +16,11 @@ #include "pxr/pxr.h" #include "cameraWriter.h" -#include <../../fileio/utils/adaptor.h> -#include <../../fileio/primWriter.h> -#include <../../fileio/primWriterRegistry.h> -#include <../../utils/util.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/utils/adaptor.h" +#include "../../fileio/primWriter.h" +#include "../../fileio/primWriterRegistry.h" +#include "../../utils/util.h" +#include "../../fileio/writeJobContext.h" #include "pxr/base/gf/vec2f.h" #include "pxr/base/tf/diagnostic.h" diff --git a/lib/usd/translators/cameraWriter.h b/lib/usd/translators/cameraWriter.h index 8adba795c7..ff44cb6330 100644 --- a/lib/usd/translators/cameraWriter.h +++ b/lib/usd/translators/cameraWriter.h @@ -20,8 +20,8 @@ #include "pxr/pxr.h" -#include <../../fileio/primWriter.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/primWriter.h" +#include "../../fileio/writeJobContext.h" #include "pxr/usd/sdf/path.h" #include "pxr/usd/usd/timeCode.h" diff --git a/lib/usd/translators/fileTextureWriter.cpp b/lib/usd/translators/fileTextureWriter.cpp index c3b538407b..833eb76a83 100644 --- a/lib/usd/translators/fileTextureWriter.cpp +++ b/lib/usd/translators/fileTextureWriter.cpp @@ -16,10 +16,10 @@ #include "pxr/pxr.h" #include "fileTextureWriter.h" -#include <../../fileio/primWriterRegistry.h> -#include <../../fileio/shaderWriter.h> -#include <../../utils/util.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/primWriterRegistry.h" +#include "../../fileio/shaderWriter.h" +#include "../../utils/util.h" +#include "../../fileio/writeJobContext.h" #include "pxr/base/gf/vec3f.h" #include "pxr/base/gf/vec4f.h" diff --git a/lib/usd/translators/fileTextureWriter.h b/lib/usd/translators/fileTextureWriter.h index 18626d17e5..da15784c35 100644 --- a/lib/usd/translators/fileTextureWriter.h +++ b/lib/usd/translators/fileTextureWriter.h @@ -19,8 +19,8 @@ /// \file pxrUsdTranslators/fileTextureWriter.h #include "pxr/pxr.h" -#include <../../fileio/shaderWriter.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/shaderWriter.h" +#include "../../fileio/writeJobContext.h" #include "pxr/base/tf/token.h" #include "pxr/usd/sdf/path.h" diff --git a/lib/usd/translators/instancerWriter.cpp b/lib/usd/translators/instancerWriter.cpp index b5b35484cf..dab0177291 100644 --- a/lib/usd/translators/instancerWriter.cpp +++ b/lib/usd/translators/instancerWriter.cpp @@ -15,11 +15,11 @@ // #include "instancerWriter.h" -#include <../../fileio/utils/adaptor.h> -#include <../../fileio/primWriterRegistry.h> -#include <../../utils/util.h> -#include <../../fileio/writeJobContext.h> -#include <../../fileio/utils/writeUtil.h> +#include "../../fileio/utils/adaptor.h" +#include "../../fileio/primWriterRegistry.h" +#include "../../utils/util.h" +#include "../../fileio/writeJobContext.h" +#include "../../fileio/utils/writeUtil.h" #include "pxr/base/tf/staticTokens.h" #include "pxr/base/tf/token.h" diff --git a/lib/usd/translators/instancerWriter.h b/lib/usd/translators/instancerWriter.h index 6c762f870f..cd615ad3a4 100644 --- a/lib/usd/translators/instancerWriter.h +++ b/lib/usd/translators/instancerWriter.h @@ -20,10 +20,10 @@ #include "pxr/pxr.h" -#include <../../fileio/transformWriter.h> +#include "../../fileio/transformWriter.h" -#include <../../fileio/primWriter.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/primWriter.h" +#include "../../fileio/writeJobContext.h" #include "pxr/usd/sdf/path.h" #include "pxr/usd/usd/timeCode.h" diff --git a/lib/usd/translators/jointWriter.cpp b/lib/usd/translators/jointWriter.cpp index 3e04e2a6ec..f32450f5e3 100644 --- a/lib/usd/translators/jointWriter.cpp +++ b/lib/usd/translators/jointWriter.cpp @@ -16,13 +16,13 @@ #include "pxr/pxr.h" #include "jointWriter.h" -#include <../../fileio/utils/adaptor.h> -#include <../../fileio/primWriter.h> -#include <../../fileio/primWriterRegistry.h> -#include <../../fileio/translators/translatorSkel.h> -#include <../../fileio/translators/translatorUtil.h> -#include <../../utils/util.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/utils/adaptor.h" +#include "../../fileio/primWriter.h" +#include "../../fileio/primWriterRegistry.h" +#include "../../fileio/translators/translatorSkel.h" +#include "../../fileio/translators/translatorUtil.h" +#include "../../utils/util.h" +#include "../../fileio/writeJobContext.h" #include "pxr/base/tf/staticTokens.h" #include "pxr/base/tf/token.h" diff --git a/lib/usd/translators/jointWriter.h b/lib/usd/translators/jointWriter.h index 36991b16b1..3320bb568a 100644 --- a/lib/usd/translators/jointWriter.h +++ b/lib/usd/translators/jointWriter.h @@ -20,8 +20,8 @@ #include "pxr/pxr.h" -#include <../../fileio/primWriter.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/primWriter.h" +#include "../../fileio/writeJobContext.h" #include "pxr/usd/sdf/path.h" #include "pxr/usd/usd/timeCode.h" diff --git a/lib/usd/translators/lightReader.cpp b/lib/usd/translators/lightReader.cpp index 3b69874de6..85c172a401 100644 --- a/lib/usd/translators/lightReader.cpp +++ b/lib/usd/translators/lightReader.cpp @@ -14,8 +14,8 @@ // limitations under the License. // -#include <../../fileio/translators/translatorRfMLight.h> -#include <../../fileio/primReaderRegistry.h> +#include "../../fileio/translators/translatorRfMLight.h" +#include "../../fileio/primReaderRegistry.h" #include "pxr/usd/usdLux/diskLight.h" #include "pxr/usd/usdLux/distantLight.h" diff --git a/lib/usd/translators/lightWriter.cpp b/lib/usd/translators/lightWriter.cpp index 3371163712..b7dae2bc92 100644 --- a/lib/usd/translators/lightWriter.cpp +++ b/lib/usd/translators/lightWriter.cpp @@ -14,8 +14,8 @@ // limitations under the License. // -#include <../../fileio/translators/translatorRfMLight.h> -#include <../../fileio/primWriterRegistry.h> +#include "../../fileio/translators/translatorRfMLight.h" +#include "../../fileio/primWriterRegistry.h" PXR_NAMESPACE_OPEN_SCOPE diff --git a/lib/usd/translators/locatorWriter.cpp b/lib/usd/translators/locatorWriter.cpp index 3d6133baac..4c1775603a 100644 --- a/lib/usd/translators/locatorWriter.cpp +++ b/lib/usd/translators/locatorWriter.cpp @@ -16,9 +16,9 @@ #include "pxr/pxr.h" #include "locatorWriter.h" -#include <../../fileio/utils/adaptor.h> -#include <../../fileio/primWriterRegistry.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/utils/adaptor.h" +#include "../../fileio/primWriterRegistry.h" +#include "../../fileio/writeJobContext.h" #include "pxr/usd/sdf/path.h" #include "pxr/usd/usdGeom/xform.h" diff --git a/lib/usd/translators/locatorWriter.h b/lib/usd/translators/locatorWriter.h index 71662ae69d..32376dc9d2 100644 --- a/lib/usd/translators/locatorWriter.h +++ b/lib/usd/translators/locatorWriter.h @@ -20,8 +20,8 @@ #include "pxr/pxr.h" -#include <../../fileio/primWriter.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/primWriter.h" +#include "../../fileio/writeJobContext.h" #include "pxr/usd/sdf/path.h" diff --git a/lib/usd/translators/materialReader.cpp b/lib/usd/translators/materialReader.cpp index 018df5063c..a2c6c0dc6b 100644 --- a/lib/usd/translators/materialReader.cpp +++ b/lib/usd/translators/materialReader.cpp @@ -15,8 +15,8 @@ // #include "pxr/pxr.h" -#include <../../fileio/primReaderRegistry.h> -#include <../../fileio/translators/translatorMaterial.h> +#include "../../fileio/primReaderRegistry.h" +#include "../../fileio/translators/translatorMaterial.h" #include "pxr/usd/usdShade/material.h" diff --git a/lib/usd/translators/mayaReferenceReader.cpp b/lib/usd/translators/mayaReferenceReader.cpp index 214fb507bd..d33295564a 100644 --- a/lib/usd/translators/mayaReferenceReader.cpp +++ b/lib/usd/translators/mayaReferenceReader.cpp @@ -32,9 +32,9 @@ #include "pxr/pxr.h" -#include <../../fileio/primReaderRegistry.h> -#include <../../fileio/translators/translatorMayaReference.h> -#include <../schemas/MayaReference.h> +#include "../../fileio/primReaderRegistry.h" +#include "../../fileio/translators/translatorMayaReference.h" +#include "../schemas/MayaReference.h" #include "pxr/usd/usd/prim.h" #include "pxr/usd/usdGeom/camera.h" diff --git a/lib/usd/translators/mayaReferenceUpdater.cpp b/lib/usd/translators/mayaReferenceUpdater.cpp index b796096ca5..33c2fc5753 100644 --- a/lib/usd/translators/mayaReferenceUpdater.cpp +++ b/lib/usd/translators/mayaReferenceUpdater.cpp @@ -16,11 +16,11 @@ #include "pxr/pxr.h" #include "mayaReferenceUpdater.h" -#include <../../fileio/utils/adaptor.h> -#include <../../fileio/primUpdaterRegistry.h> -#include <../../utils/util.h> -#include <../schemas/MayaReference.h> -#include <../../fileio/translators/translatorMayaReference.h> +#include "../../fileio/utils/adaptor.h" +#include "../../fileio/primUpdaterRegistry.h" +#include "../../utils/util.h" +#include "../schemas/MayaReference.h" +#include "../../fileio/translators/translatorMayaReference.h" #include "pxr/base/gf/vec2f.h" #include "pxr/base/tf/diagnostic.h" diff --git a/lib/usd/translators/mayaReferenceUpdater.h b/lib/usd/translators/mayaReferenceUpdater.h index 61f53635cf..b2c4717c9c 100644 --- a/lib/usd/translators/mayaReferenceUpdater.h +++ b/lib/usd/translators/mayaReferenceUpdater.h @@ -20,7 +20,7 @@ #include "pxr/pxr.h" -#include <../../fileio/primUpdater.h> +#include "../../fileio/primUpdater.h" #include diff --git a/lib/usd/translators/meshReader.cpp b/lib/usd/translators/meshReader.cpp index 77f4b9097f..05a20bfc56 100644 --- a/lib/usd/translators/meshReader.cpp +++ b/lib/usd/translators/meshReader.cpp @@ -15,8 +15,8 @@ // #include "pxr/pxr.h" -#include <../../fileio/primReaderRegistry.h> -#include <../../fileio/translators/translatorMesh.h> +#include "../../fileio/primReaderRegistry.h" +#include "../../fileio/translators/translatorMesh.h" #include "pxr/usd/usdGeom/mesh.h" diff --git a/lib/usd/translators/meshWriter.cpp b/lib/usd/translators/meshWriter.cpp index 072b91424c..b4c40bc8b2 100644 --- a/lib/usd/translators/meshWriter.cpp +++ b/lib/usd/translators/meshWriter.cpp @@ -16,13 +16,13 @@ #include "pxr/pxr.h" #include "meshWriter.h" -#include <../../fileio/utils/adaptor.h> -#include <../../fileio/utils/meshUtil.h> -#include <../../fileio/primWriter.h> -#include <../../fileio/primWriterRegistry.h> -#include <../../utils/util.h> -#include <../../fileio/utils/writeUtil.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/utils/adaptor.h" +#include "../../fileio/utils/meshUtil.h" +#include "../../fileio/primWriter.h" +#include "../../fileio/primWriterRegistry.h" +#include "../../utils/util.h" +#include "../../fileio/utils/writeUtil.h" +#include "../../fileio/writeJobContext.h" #include "pxr/base/gf/vec2f.h" #include "pxr/base/gf/vec3f.h" diff --git a/lib/usd/translators/meshWriter.h b/lib/usd/translators/meshWriter.h index d6bff857de..b8f560ee54 100644 --- a/lib/usd/translators/meshWriter.h +++ b/lib/usd/translators/meshWriter.h @@ -20,8 +20,8 @@ #include "pxr/pxr.h" -#include <../../fileio/primWriter.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/primWriter.h" +#include "../../fileio/writeJobContext.h" #include "pxr/base/gf/vec2f.h" #include "pxr/base/gf/vec3f.h" diff --git a/lib/usd/translators/meshWriter_Primvars.cpp b/lib/usd/translators/meshWriter_Primvars.cpp index b5b052e57c..f202dffa33 100644 --- a/lib/usd/translators/meshWriter_Primvars.cpp +++ b/lib/usd/translators/meshWriter_Primvars.cpp @@ -15,10 +15,10 @@ // #include "meshWriter.h" -#include <../../utils/colorSpace.h> -#include <../../fileio/utils/roundTripUtil.h> -#include <../../utils/util.h> -#include <../../fileio/utils/writeUtil.h> +#include "../../utils/colorSpace.h" +#include "../../fileio/utils/roundTripUtil.h" +#include "../../utils/util.h" +#include "../../fileio/utils/writeUtil.h" #include "pxr/base/gf/gamma.h" #include "pxr/base/gf/math.h" diff --git a/lib/usd/translators/meshWriter_Skin.cpp b/lib/usd/translators/meshWriter_Skin.cpp index 88ac2da24d..5b0d553d69 100644 --- a/lib/usd/translators/meshWriter_Skin.cpp +++ b/lib/usd/translators/meshWriter_Skin.cpp @@ -18,9 +18,9 @@ #include "meshWriter.h" #include "jointWriter.h" -#include <../../fileio/translators/translatorSkel.h> -#include <../../fileio/translators/translatorUtil.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/translators/translatorSkel.h" +#include "../../fileio/translators/translatorUtil.h" +#include "../../fileio/writeJobContext.h" #include "pxr/base/gf/matrix4d.h" #include "pxr/base/tf/staticTokens.h" diff --git a/lib/usd/translators/nurbsCurveWriter.cpp b/lib/usd/translators/nurbsCurveWriter.cpp index e775f13d53..e2b1d133f6 100644 --- a/lib/usd/translators/nurbsCurveWriter.cpp +++ b/lib/usd/translators/nurbsCurveWriter.cpp @@ -16,10 +16,10 @@ #include "pxr/pxr.h" #include "nurbsCurveWriter.h" -#include <../../fileio/utils/adaptor.h> -#include <../../fileio/primWriter.h> -#include <../../fileio/primWriterRegistry.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/utils/adaptor.h" +#include "../../fileio/primWriter.h" +#include "../../fileio/primWriterRegistry.h" +#include "../../fileio/writeJobContext.h" #include "pxr/base/gf/vec2d.h" #include "pxr/base/gf/vec3f.h" diff --git a/lib/usd/translators/nurbsCurveWriter.h b/lib/usd/translators/nurbsCurveWriter.h index 68b5902630..fbaab2c230 100644 --- a/lib/usd/translators/nurbsCurveWriter.h +++ b/lib/usd/translators/nurbsCurveWriter.h @@ -20,8 +20,8 @@ #include "pxr/pxr.h" -#include <../../fileio/primWriter.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/primWriter.h" +#include "../../fileio/writeJobContext.h" #include "pxr/usd/sdf/path.h" #include "pxr/usd/usd/timeCode.h" diff --git a/lib/usd/translators/nurbsCurvesReader.cpp b/lib/usd/translators/nurbsCurvesReader.cpp index efcf7610a2..eb1017ea5b 100644 --- a/lib/usd/translators/nurbsCurvesReader.cpp +++ b/lib/usd/translators/nurbsCurvesReader.cpp @@ -15,8 +15,8 @@ // #include "pxr/pxr.h" -#include <../../fileio/primReaderRegistry.h> -#include <../../fileio/translators/translatorCurves.h> +#include "../../fileio/primReaderRegistry.h" +#include "../../fileio/translators/translatorCurves.h" #include "pxr/usd/usdGeom/nurbsCurves.h" diff --git a/lib/usd/translators/nurbsPatchReader.cpp b/lib/usd/translators/nurbsPatchReader.cpp index 429decb60b..c59c409f04 100644 --- a/lib/usd/translators/nurbsPatchReader.cpp +++ b/lib/usd/translators/nurbsPatchReader.cpp @@ -15,8 +15,8 @@ // #include "pxr/pxr.h" -#include <../../fileio/primReaderRegistry.h> -#include <../../fileio/translators/translatorNurbsPatch.h> +#include "../../fileio/primReaderRegistry.h" +#include "../../fileio/translators/translatorNurbsPatch.h" #include "pxr/usd/usd/prim.h" #include "pxr/usd/usdGeom/nurbsPatch.h" diff --git a/lib/usd/translators/nurbsSurfaceWriter.cpp b/lib/usd/translators/nurbsSurfaceWriter.cpp index 8c6480e682..5fd2dd8676 100644 --- a/lib/usd/translators/nurbsSurfaceWriter.cpp +++ b/lib/usd/translators/nurbsSurfaceWriter.cpp @@ -16,11 +16,11 @@ #include "pxr/pxr.h" #include "nurbsSurfaceWriter.h" -#include <../../fileio/utils/adaptor.h> -#include <../../fileio/primWriter.h> -#include <../../fileio/primWriterRegistry.h> -#include <../../fileio/writeJobContext.h> -#include <../../fileio/utils/writeUtil.h> +#include "../../fileio/utils/adaptor.h" +#include "../../fileio/primWriter.h" +#include "../../fileio/primWriterRegistry.h" +#include "../../fileio/writeJobContext.h" +#include "../../fileio/utils/writeUtil.h" #include "pxr/base/gf/vec2d.h" #include "pxr/base/gf/vec2f.h" diff --git a/lib/usd/translators/nurbsSurfaceWriter.h b/lib/usd/translators/nurbsSurfaceWriter.h index fb84645747..e5d3ebe613 100644 --- a/lib/usd/translators/nurbsSurfaceWriter.h +++ b/lib/usd/translators/nurbsSurfaceWriter.h @@ -20,8 +20,8 @@ #include "pxr/pxr.h" -#include <../../fileio/primWriter.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/primWriter.h" +#include "../../fileio/writeJobContext.h" #include "pxr/usd/sdf/path.h" #include "pxr/usd/usd/timeCode.h" diff --git a/lib/usd/translators/particleWriter.cpp b/lib/usd/translators/particleWriter.cpp index 1abcbb148b..f4066be364 100644 --- a/lib/usd/translators/particleWriter.cpp +++ b/lib/usd/translators/particleWriter.cpp @@ -16,10 +16,10 @@ #include "pxr/pxr.h" #include "particleWriter.h" -#include <../../fileio/utils/adaptor.h> -#include <../../fileio/primWriterRegistry.h> -#include <../../fileio/transformWriter.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/utils/adaptor.h" +#include "../../fileio/primWriterRegistry.h" +#include "../../fileio/transformWriter.h" +#include "../../fileio/writeJobContext.h" #include "pxr/base/gf/vec3f.h" #include "pxr/base/tf/stringUtils.h" diff --git a/lib/usd/translators/particleWriter.h b/lib/usd/translators/particleWriter.h index e2a49d954f..1a8131fc98 100644 --- a/lib/usd/translators/particleWriter.h +++ b/lib/usd/translators/particleWriter.h @@ -20,8 +20,8 @@ #include "pxr/pxr.h" -#include <../../fileio/transformWriter.h> -#include <../../fileio/writeJobContext.h> +#include "../../fileio/transformWriter.h" +#include "../../fileio/writeJobContext.h" #include "pxr/base/tf/token.h" #include "pxr/usd/sdf/path.h" diff --git a/lib/usd/translators/scopeReader.cpp b/lib/usd/translators/scopeReader.cpp index 43ae165310..3a4d6c5b46 100644 --- a/lib/usd/translators/scopeReader.cpp +++ b/lib/usd/translators/scopeReader.cpp @@ -15,8 +15,8 @@ // #include "pxr/pxr.h" -#include <../../fileio/primReaderRegistry.h> -#include <../../fileio/translators/translatorUtil.h> +#include "../../fileio/primReaderRegistry.h" +#include "../../fileio/translators/translatorUtil.h" #include "pxr/usd/usd/prim.h" #include "pxr/usd/usdGeom/scope.h" diff --git a/lib/usd/translators/skelReader.cpp b/lib/usd/translators/skelReader.cpp index d30857309c..e2c2551c0d 100644 --- a/lib/usd/translators/skelReader.cpp +++ b/lib/usd/translators/skelReader.cpp @@ -15,9 +15,9 @@ // #include "pxr/pxr.h" -#include <../../fileio/primReaderRegistry.h> -#include <../../fileio/translators/translatorSkel.h> -#include <../../fileio/translators/translatorUtil.h> +#include "../../fileio/primReaderRegistry.h" +#include "../../fileio/translators/translatorSkel.h" +#include "../../fileio/translators/translatorUtil.h" #include "pxr/usd/usd/prim.h" #include "pxr/usd/usd/primRange.h" diff --git a/lib/usd/translators/xformReader.cpp b/lib/usd/translators/xformReader.cpp index d6d4c16e9e..a27eee6b8b 100644 --- a/lib/usd/translators/xformReader.cpp +++ b/lib/usd/translators/xformReader.cpp @@ -15,8 +15,8 @@ // #include "pxr/pxr.h" -#include <../../fileio/primReaderRegistry.h> -#include <../../fileio/translators/translatorUtil.h> +#include "../../fileio/primReaderRegistry.h" +#include "../../fileio/translators/translatorUtil.h" #include "pxr/usd/usd/prim.h" #include "pxr/usd/usdGeom/xform.h" From 1a92ea3f4003807f91d57ca221efb87a1cf1baf3 Mon Sep 17 00:00:00 2001 From: Sean Donnelly Date: Thu, 1 Aug 2019 10:51:11 -0400 Subject: [PATCH 13/22] MAYA-99741 - Build all 3 plugins build/work in sandbox (#91) * MAYA-99741 - Build all 3 plugins build/work in sandbox * Added top-level cmake option "CMAKE_WANT_UFE_BUILD" with default value ON. When enabled, we (quietly) try to find UFE and if available we enable it and use it for building. If not available, then don't compile UFE features. * Being an option means users UFE can be disabled if needed. * Removed logic which looked for UFE only when devkit location was set. * Replaced specialized "HDMAYA_UFE_BUILD" define with our generic "WANT_UFE_BUILD" define. * Replaced xxx_INT vars with cmake configure logic. * Added missing UFE to pxrUsd plugin. * MAYA-99741 - Build all 3 plugins build/work in sandbox * No need for extra #define in the promoted header file hdMaya.h. Just use the standard cmake add_definitions which works on all platforms and is consistent with the rest of our repo. --- CMakeLists.txt | 10 ++-- build.py | 4 +- cmake/modules/FindUFE.cmake | 11 +++-- lib/CMakeLists.txt | 52 ++++++++++---------- lib/MayaUsd.cmake | 3 +- lib/render/mayaToHydra/renderOverride.cpp | 24 ++++----- lib/render/mayaToHydra/renderOverride.h | 8 +-- lib/usd/CMakeLists.txt | 32 ++++-------- lib/usd/hdMaya/CMakeLists.txt | 6 +-- lib/usd/hdMaya/adapters/proxyAdapter.cpp | 8 +-- lib/usd/hdMaya/delegates/delegate.h | 8 +-- lib/usd/hdMaya/delegates/proxyDelegate.cpp | 16 +++--- lib/usd/hdMaya/delegates/proxyDelegate.h | 8 +-- lib/usd/hdMaya/hdMaya.h.in | 4 +- plugin/adsk/plugin/CMakeLists.txt | 15 +++--- plugin/al/CMakeLists.txt | 21 +++----- plugin/al/lib/AL_USDMaya/CMakeLists.txt | 5 +- plugin/pxr/maya/plugin/pxrUsd/CMakeLists.txt | 15 ++++++ 18 files changed, 128 insertions(+), 122 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 48d073c28e..e6df334e8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,10 +21,12 @@ cmake_minimum_required(VERSION 3.1.1) #============================================================================== # Define common build variables #============================================================================== -set(BUILD_MAYAUSD_LIBRARY ON CACHE BOOL "Build Core USD libraries.") -set(BUILD_ADSK_PLUGIN ON CACHE BOOL "Build Autodesk USD plugin.") -set(BUILD_PXR_PLUGIN ON CACHE BOOL "Build the Pixar USD plugin and libraries.") -set(BUILD_AL_PLUGIN ON CACHE BOOL "Build the Animal Logic USD plugin and libraries.") +option(BUILD_MAYAUSD_LIBRARY "Build Core USD libraries." ON) +option(BUILD_ADSK_PLUGIN "Build Autodesk USD plugin." ON) +option(BUILD_PXR_PLUGIN "Build the Pixar USD plugin and libraries." ON) +option(BUILD_AL_PLUGIN "Build the Animal Logic USD plugin and libraries." ON) + +option(CMAKE_WANT_UFE_BUILD "Enable building with UFE (if found)." ON) #============================================================================== # Modules and Definitions diff --git a/build.py b/build.py index c429288d5b..9e7718f01d 100644 --- a/build.py +++ b/build.py @@ -452,11 +452,11 @@ def __init__(self, args): if context.buildArgs: summaryMsg += """ - Extra Build arguments {buildArgs}""" + Extra Build arguments {buildArgs}""" if context.stagesArgs: summaryMsg += """ - Stages arguments {stagesArgs}""" + Stages arguments {stagesArgs}""" summaryMsg = summaryMsg.format( mayaUsdSrcDir=context.mayaUsdSrcDir, diff --git a/cmake/modules/FindUFE.cmake b/cmake/modules/FindUFE.cmake index 7bbf859276..37b7e8b969 100644 --- a/cmake/modules/FindUFE.cmake +++ b/cmake/modules/FindUFE.cmake @@ -65,10 +65,6 @@ find_library(UFE_LIBRARY NO_DEFAULT_PATH ) -message(STATUS "UFE include dir: ${UFE_INCLUDE_DIR}") -message(STATUS "UFE library: ${UFE_LIBRARY}") -message(STATUS "UFE version: ${UFE_VERSION}") - # Handle the QUIETLY and REQUIRED arguments and set UFE_FOUND to TRUE if # all listed variables are TRUE. include(FindPackageHandleStandardArgs) @@ -77,5 +73,12 @@ find_package_handle_standard_args(UFE REQUIRED_VARS UFE_INCLUDE_DIR UFE_LIBRARY + VERSION_VAR UFE_VERSION ) + +if(UFE_FOUND) + message(STATUS "UFE include dir: ${UFE_INCLUDE_DIR}") + message(STATUS "UFE library: ${UFE_LIBRARY}") + message(STATUS "UFE version: ${UFE_VERSION}") +endif() diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index a64b7e94de..3243eb5d61 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -67,28 +67,28 @@ find_package(Maya REQUIRED) find_package(USD REQUIRED) include(${USD_CONFIG_FILE}) -if("${MAYA_DEVKIT_LOCATION}" STREQUAL "") - set(CMAKE_WANT_UFE_BUILD OFF) -else() - set(CMAKE_WANT_UFE_BUILD ON) -endif() - if(CMAKE_WANT_UFE_BUILD) - find_package(UFE REQUIRED) - add_definitions(-DWANT_UFE_BUILD) - - # UFE Group interface is available on 2.0+ and 0.2+ but not 1.x. - if((NOT UFE_VERSION VERSION_LESS 2.0.0) OR - ((UFE_VERSION VERSION_LESS 1.0.0) AND (NOT UFE_VERSION VERSION_LESS 0.2.0))) - set(CMAKE_UFE_GROUP_INTERFACE_AVAILABLE ON) - add_definitions(-DUFE_GROUP_INTERFACE_AVAILABLE) + find_package(UFE QUIET) + if(UFE_FOUND) + message(STATUS "Building with UFE ${UFE_VERSION} features enabled.") + include_directories(${UFE_INCLUDE_DIR}) + add_definitions(-DWANT_UFE_BUILD) + + # UFE Group interface is available on 2.0+ and 0.2+ but not 1.x. + if((NOT UFE_VERSION VERSION_LESS 2.0.0) OR + ((UFE_VERSION VERSION_LESS 1.0.0) AND (NOT UFE_VERSION VERSION_LESS 0.2.0))) + set(CMAKE_UFE_GROUP_INTERFACE_AVAILABLE ON) + add_definitions(-DUFE_GROUP_INTERFACE_AVAILABLE) + else() + set(CMAKE_UFE_GROUP_INTERFACE_AVAILABLE OFF) + endif() + + if(MSVC) + # Silence this warning until we fix it in UFE. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251") + endif() else() - set(CMAKE_UFE_GROUP_INTERFACE_AVAILABLE OFF) - endif() - - if(MSVC) - # Silence this warning until we fix it in UFE. - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251") + message(STATUS "UFE not found. UFE features will be disabled.") endif() endif() @@ -225,7 +225,7 @@ list(APPEND mayaUsd_src render/px_vp20/utils_legacy.cpp ) -if(CMAKE_WANT_UFE_BUILD) +if(UFE_FOUND) list(APPEND mayaUsd_src ufe/Global.cpp ufe/Utils.cpp @@ -361,7 +361,7 @@ list(APPEND mayaUsdVP2RenderDelegate_headers render/vp2RenderDelegate/proxyRenderDelegate.h ) -if(CMAKE_WANT_UFE_BUILD) +if(UFE_FOUND) list(APPEND mayaUsdUfe_headers ufe/Global.h ufe/Utils.h @@ -430,7 +430,6 @@ target_include_directories( ${LIBRARY_NAME} PUBLIC ${MAYA_INCLUDE_DIRS} - ${UFE_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../base ${PXR_INCLUDE_DIRS} @@ -442,7 +441,6 @@ target_link_libraries(${LIBRARY_NAME} ${MAYA_OpenMaya_LIBRARY} ${MAYA_OpenMayaRender_LIBRARY} ${MAYA_OpenMayaUI_LIBRARY} - ${UFE_LIBRARY} ar gf hd @@ -464,6 +462,10 @@ target_link_libraries(${LIBRARY_NAME} vt ) +if (UFE_FOUND) + target_link_libraries(${LIBRARY_NAME} ${UFE_LIBRARY}) +endif() + if(APPLE) set(CMAKE_MACOSX_RPATH ON) set_target_properties(${LIBRARY_NAME} @@ -538,7 +540,7 @@ install(FILES ${mayaUsdVP2RenderDelegate_headers} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/mayaUsd/render/vp2RenderDelegate ) -if(CMAKE_WANT_UFE_BUILD) +if(UFE_FOUND) install(FILES ${mayaUsdUfe_headers} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/mayaUsd/ufe ) diff --git a/lib/MayaUsd.cmake b/lib/MayaUsd.cmake index 291495eb03..6dc373c230 100644 --- a/lib/MayaUsd.cmake +++ b/lib/MayaUsd.cmake @@ -27,7 +27,8 @@ macro(add_mayausd_define var) endif() endmacro(add_mayausd_define) -# Add top level variabels here +# Add top level variabels here +add_mayausd_define(CMAKE_WANT_UFE_BUILD) add_mayausd_define(MAYAUSD_VERSION) add_mayausd_define(MAYAUSD_MAJOR_VERSION) add_mayausd_define(MAYAUSD_MINOR_VERSION) diff --git a/lib/render/mayaToHydra/renderOverride.cpp b/lib/render/mayaToHydra/renderOverride.cpp index e2533dc6aa..dc11296397 100644 --- a/lib/render/mayaToHydra/renderOverride.cpp +++ b/lib/render/mayaToHydra/renderOverride.cpp @@ -61,12 +61,12 @@ #include "tokens.h" #include "utils.h" -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD #include #include #include #include -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD PXR_NAMESPACE_OPEN_SCOPE @@ -86,7 +86,7 @@ namespace { std::mutex _allInstancesMutex; std::vector _allInstances; -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD // Observe UFE scene items for transformation changed only when they are // selected. @@ -117,7 +117,7 @@ class UfeSelectionObserver : public UFE_NS::Observer { MtohRenderOverride& _mtohRenderOverride; }; -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD /// Simple RAII class to save uniform buffer bindings, to deal with a maya /// issue. @@ -218,14 +218,14 @@ MtohRenderOverride::MtohRenderOverride(const MtohRendererDescription& desc) _globals = MtohGetRenderGlobals(); -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD const UFE_NS::GlobalSelection::Ptr& ufeSelection = UFE_NS::GlobalSelection::get(); if (ufeSelection) { _ufeSelectionObserver = std::make_shared(*this); ufeSelection->addObserver(_ufeSelectionObserver); } -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD } MtohRenderOverride::~MtohRenderOverride() { @@ -252,14 +252,14 @@ MtohRenderOverride::~MtohRenderOverride() { _allInstances.end()); } -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD const UFE_NS::GlobalSelection::Ptr& ufeSelection = UFE_NS::GlobalSelection::get(); if (ufeSelection) { ufeSelection->removeObserver(_ufeSelectionObserver); _ufeSelectionObserver = nullptr; } -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD } void MtohRenderOverride::UpdateRenderGlobals() { @@ -693,13 +693,13 @@ void MtohRenderOverride::_SelectionChanged() { SdfPathVector selectedPaths; auto selection = boost::make_shared(); -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD const UFE_NS::GlobalSelection::Ptr& ufeSelection = UFE_NS::GlobalSelection::get(); -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD for (auto& it : _delegates) { -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD if (it->SupportsUfeSelection()) { if (ufeSelection) { it->PopulateSelectedPaths( @@ -708,7 +708,7 @@ void MtohRenderOverride::_SelectionChanged() { // skip non-ufe PopulateSelectedPaths call continue; } -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD it->PopulateSelectedPaths(sel, selectedPaths, selection); } _selectionCollection.SetRootPaths(selectedPaths); diff --git a/lib/render/mayaToHydra/renderOverride.h b/lib/render/mayaToHydra/renderOverride.h index 77bf2a502b..a71673c9d8 100644 --- a/lib/render/mayaToHydra/renderOverride.h +++ b/lib/render/mayaToHydra/renderOverride.h @@ -57,9 +57,9 @@ #include #include -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD #include -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD PXR_NAMESPACE_OPEN_SCOPE @@ -176,9 +176,9 @@ class MtohRenderOverride : public MHWRender::MRenderOverride { bool _selectionChanged = true; bool _isConverged = false; -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD UFE_NS::Observer::Ptr _ufeSelectionObserver; -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD }; PXR_NAMESPACE_CLOSE_SCOPE diff --git a/lib/usd/CMakeLists.txt b/lib/usd/CMakeLists.txt index 608fa98fdc..4500317193 100644 --- a/lib/usd/CMakeLists.txt +++ b/lib/usd/CMakeLists.txt @@ -10,31 +10,17 @@ set(MTOH_CXX_STD "11" option(LUMA_USD_BUILD "Build the plugin for Luma's version of USD." OFF) option(INSTALL_MAYA_MOD "Installs a maya module file for the plugin." OFF) option(HDMAYA_BUILD_TESTS "Build the maya-to-hydra tests" OFF) -option(HDMAYA_UFE_BUILD "Build UFE support for the maya-to-hydra plugin." OFF) option(BUILD_DOCS "Whether or not to build the documentation." OFF) -# HDMAYA_UFE_BUILD is used in maya-to-hydra plugin for #if test. -# Make sure HDMAYA_UFE_BUILD_INT is an int. -set(HDMAYA_UFE_BUILD_INT 0) - -if (NOT "${MAYA_DEVKIT_LOCATION}" STREQUAL "") - find_package(UFE REQUIRED) - include_directories(${UFE_INCLUDE_DIR}) - - # Currently we control whether or not we want UFE by setting MAYA_DEVKIT_LOCATION - # It will then force maya-to-hyra to build with UFE. - set(HDMAYA_UFE_BUILD ON) - - # WANT_UFE_BUILD is used in mayaUsdPlugin for #ifdef test. - add_definitions(-DWANT_UFE_BUILD) - - # HDMAYA_UFE_BUILD is used in maya-to-hydra plugin for #if test. - # Make sure HDMAYA_UFE_BUILD_INT is an int. - set(HDMAYA_UFE_BUILD_INT 1) - - message(STATUS "Found UFE version: ${UFE_VERSION}") - message(STATUS "UFE Include directory: ${UFE_INCLUDE_DIR}") - message(STATUS "UFE Library: ${UFE_LIBRARY}") +if(CMAKE_WANT_UFE_BUILD) + find_package(UFE QUIET) + if(UFE_FOUND) + message(STATUS "Building with UFE ${UFE_VERSION} features enabled.") + include_directories(${UFE_INCLUDE_DIR}) + add_definitions(-DWANT_UFE_BUILD) + else() + message(STATUS "UFE not found. UFE features will be disabled.") + endif() endif() add_subdirectory(hdMaya) diff --git a/lib/usd/hdMaya/CMakeLists.txt b/lib/usd/hdMaya/CMakeLists.txt index b41bef232a..3f2274cacf 100644 --- a/lib/usd/hdMaya/CMakeLists.txt +++ b/lib/usd/hdMaya/CMakeLists.txt @@ -1,9 +1,7 @@ set(TARGET_NAME hdMaya) if (LUMA_USD_BUILD) - set(HDMAYA_LUMA_BUILD_INT 1) -else () - set(HDMAYA_LUMA_BUILD_INT 0) + set(HDMAYA_LUMA_BUILD 1) endif () set(HDMAYA_H "${CMAKE_CURRENT_BINARY_DIR}/hdMaya.h") @@ -98,7 +96,7 @@ target_include_directories(${TARGET_NAME} ${CMAKE_BINARY_DIR} ) -if (HDMAYA_UFE_BUILD) +if (UFE_FOUND) target_link_libraries(${TARGET_NAME} PUBLIC ${UFE_LIBRARY}) endif() diff --git a/lib/usd/hdMaya/adapters/proxyAdapter.cpp b/lib/usd/hdMaya/adapters/proxyAdapter.cpp index d51efccd59..1362c1b086 100644 --- a/lib/usd/hdMaya/adapters/proxyAdapter.cpp +++ b/lib/usd/hdMaya/adapters/proxyAdapter.cpp @@ -52,17 +52,17 @@ #include #endif // HD_MAYA_AL_OVERRIDE_PROXY_SELECTION -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD #include #include -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD namespace { -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD constexpr auto USD_UFE_RUNTIME_NAME = "USD"; // static UFE_NS::Rtid usdUfeRtid = 0; -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD #ifdef HD_MAYA_AL_OVERRIDE_PROXY_SELECTION diff --git a/lib/usd/hdMaya/delegates/delegate.h b/lib/usd/hdMaya/delegates/delegate.h index 32713dfc59..26041ff578 100644 --- a/lib/usd/hdMaya/delegates/delegate.h +++ b/lib/usd/hdMaya/delegates/delegate.h @@ -45,9 +45,9 @@ #include "../api.h" #include "params.h" -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD #include -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD PXR_NAMESPACE_OPEN_SCOPE @@ -97,13 +97,13 @@ class HdMayaDelegate { const MSelectionList& mayaSelection, SdfPathVector& selectedSdfPaths, const HdSelectionSharedPtr& selection) {} -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD virtual void PopulateSelectedPaths( const UFE_NS::Selection& ufeSelection, SdfPathVector& selectedSdfPaths, const HdSelectionSharedPtr& selection) {} virtual bool SupportsUfeSelection() { return false; } -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD void SetLightsEnabled(const bool enabled) { _lightsEnabled = enabled; } bool GetLightsEnabled() { return _lightsEnabled; } diff --git a/lib/usd/hdMaya/delegates/proxyDelegate.cpp b/lib/usd/hdMaya/delegates/proxyDelegate.cpp index a42ed51f57..239f39d150 100644 --- a/lib/usd/hdMaya/delegates/proxyDelegate.cpp +++ b/lib/usd/hdMaya/delegates/proxyDelegate.cpp @@ -47,10 +47,10 @@ #include #include -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD #include #include -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD PXR_NAMESPACE_OPEN_SCOPE @@ -71,10 +71,10 @@ TF_REGISTRY_FUNCTION_WITH_TAG(HdMayaDelegateRegistry, HdMayaProxyDelegate) { namespace { -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD constexpr auto USD_UFE_RUNTIME_NAME = "USD"; static UFE_NS::Rtid usdUfeRtid = 0; -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD // Don't know if this variable would be accessed from multiple threads, but // plugin load/unload is infrequent enough that performance isn't an issue, and @@ -152,7 +152,7 @@ HdMayaProxyDelegate::HdMayaProxyDelegate(const InitData& initData) MStatus status; -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD if (usdUfeRtid == 0) { try { usdUfeRtid = @@ -164,7 +164,7 @@ HdMayaProxyDelegate::HdMayaProxyDelegate(const InitData& initData) TF_WARN("USD UFE Runtime plugin not loaded!\n"); } } -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD } HdMayaProxyDelegate::~HdMayaProxyDelegate() { @@ -282,7 +282,7 @@ void HdMayaProxyDelegate::PopulateSelectedPaths( #endif } -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD void HdMayaProxyDelegate::PopulateSelectedPaths( const UFE_NS::Selection& ufeSelection, SdfPathVector& selectedSdfPaths, @@ -379,6 +379,6 @@ void HdMayaProxyDelegate::PopulateSelectedPaths( bool HdMayaProxyDelegate::SupportsUfeSelection() { return usdUfeRtid != 0; } -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD PXR_NAMESPACE_CLOSE_SCOPE diff --git a/lib/usd/hdMaya/delegates/proxyDelegate.h b/lib/usd/hdMaya/delegates/proxyDelegate.h index 1d8b4de038..16a01e446b 100644 --- a/lib/usd/hdMaya/delegates/proxyDelegate.h +++ b/lib/usd/hdMaya/delegates/proxyDelegate.h @@ -38,9 +38,9 @@ #include -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD #include -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD PXR_NAMESPACE_OPEN_SCOPE @@ -64,12 +64,12 @@ class HdMayaProxyDelegate : public HdMayaDelegate { const MSelectionList& mayaSelection, SdfPathVector& selectedSdfPaths, const HdSelectionSharedPtr& selection) override; -#if HDMAYA_UFE_BUILD +#if WANT_UFE_BUILD void PopulateSelectedPaths( const UFE_NS::Selection& ufeSelection, SdfPathVector& selectedSdfPaths, const HdSelectionSharedPtr& selection) override; bool SupportsUfeSelection() override; -#endif // HDMAYA_UFE_BUILD +#endif // WANT_UFE_BUILD }; PXR_NAMESPACE_CLOSE_SCOPE diff --git a/lib/usd/hdMaya/hdMaya.h.in b/lib/usd/hdMaya/hdMaya.h.in index 59bb245433..eb8c76e6a3 100644 --- a/lib/usd/hdMaya/hdMaya.h.in +++ b/lib/usd/hdMaya/hdMaya.h.in @@ -24,9 +24,7 @@ #ifndef __HDMAYA_HDMAYA_H__ #define __HDMAYA_HDMAYA_H__ -#define HDMAYA_UFE_BUILD @HDMAYA_UFE_BUILD_INT@ - -#define HDMAYA_LUMA_BUILD @HDMAYA_LUMA_BUILD_INT@ +#cmakedefine01 HDMAYA_LUMA_BUILD #define HDMAYA_USD_MAJOR_VERSION @USD_MAJOR_VERSION@ #define HDMAYA_USD_MINOR_VERSION @USD_MINOR_VERSION@ diff --git a/plugin/adsk/plugin/CMakeLists.txt b/plugin/adsk/plugin/CMakeLists.txt index 2b7a566df8..9efe6c82f6 100644 --- a/plugin/adsk/plugin/CMakeLists.txt +++ b/plugin/adsk/plugin/CMakeLists.txt @@ -1,11 +1,14 @@ set(PLUGIN_PACKAGE mayaUsdPlugin) -if (NOT "${MAYA_DEVKIT_LOCATION}" STREQUAL "") - find_package(UFE REQUIRED) - include_directories(${UFE_INCLUDE_DIR}) - - # WANT_UFE_BUILD is used in mayaUsdPlugin for #ifdef test. - add_definitions(-DWANT_UFE_BUILD) +if(CMAKE_WANT_UFE_BUILD) + find_package(UFE QUIET) + if(UFE_FOUND) + message(STATUS "Building with UFE ${UFE_VERSION} features enabled.") + include_directories(${UFE_INCLUDE_DIR}) + add_definitions(-DWANT_UFE_BUILD) + else() + message(STATUS "UFE not found. UFE features will be disabled.") + endif() endif() add_library(${PLUGIN_PACKAGE} MODULE diff --git a/plugin/al/CMakeLists.txt b/plugin/al/CMakeLists.txt index fd555da118..af62bfbf6a 100644 --- a/plugin/al/CMakeLists.txt +++ b/plugin/al/CMakeLists.txt @@ -17,12 +17,6 @@ option(BUILD_USDMAYA_SCHEMAS "Build optional schemas." ON) option(BUILD_USDMAYA_TRANSLATORS "Build optional translators." ON) option(SKIP_USDMAYA_TESTS "Build tests" ON) -if ("${MAYA_DEVKIT_LOCATION}" STREQUAL "") - set(CMAKE_WANT_UFE_BUILD OFF) -else() - set(CMAKE_WANT_UFE_BUILD ON) -endif() - # AL_USDMAYA uses pxrConfig.cmake exported targets # find_package(USD) can use either ${PXR_USD_LOCATION}, or ${USD_CONFIG_FILE} (which should be ${PXR_USD_LOCATION}/pxrConfig.cmake) # to find USD, defined as either Cmake var or env var @@ -37,13 +31,14 @@ find_package(PythonInterp) find_package(MayaUSD REQUIRED) if(CMAKE_WANT_UFE_BUILD) - add_definitions(-DWANT_UFE_BUILD) - - find_package(UFE REQUIRED) - include_directories(${UFE_INCLUDE_DIR}) - - message("UFE Build Enabled") - message("Using UFE version : ${UFE_VERSION}") + find_package(UFE QUIET) + if(UFE_FOUND) + message(STATUS "Building with UFE ${UFE_VERSION} features enabled.") + include_directories(${UFE_INCLUDE_DIR}) + add_definitions(-DWANT_UFE_BUILD) + else() + message(STATUS "UFE not found. UFE features will be disabled.") + endif() endif() # FindBoost is particularly buggy, and doesn't like custom boost locations. diff --git a/plugin/al/lib/AL_USDMaya/CMakeLists.txt b/plugin/al/lib/AL_USDMaya/CMakeLists.txt index 6ef546de97..0991ab2032 100644 --- a/plugin/al/lib/AL_USDMaya/CMakeLists.txt +++ b/plugin/al/lib/AL_USDMaya/CMakeLists.txt @@ -207,10 +207,13 @@ target_link_libraries(${LIBRARY_NAME} ${MAYA_OpenMayaUI_LIBRARY} ${MAYA_OpenMaya_LIBRARY} ${MAYA_OpenMayaRender_LIBRARY} - ${UFE_LIBRARY} ${MAYAUSD_LIBRARIES} ) +if(UFE_FOUND) + target_link_libraries(${LIBRARY_NAME} ${UFE_LIBRARY}) +endif() + if(NEED_BOOST_FILESYSTEM) target_link_libraries(${LIBRARY_NAME} ${Boost_FILESYSTEM_LIBRARY} diff --git a/plugin/pxr/maya/plugin/pxrUsd/CMakeLists.txt b/plugin/pxr/maya/plugin/pxrUsd/CMakeLists.txt index 891f0dfd3b..29bc3be7aa 100644 --- a/plugin/pxr/maya/plugin/pxrUsd/CMakeLists.txt +++ b/plugin/pxr/maya/plugin/pxrUsd/CMakeLists.txt @@ -29,6 +29,21 @@ pxr_plugin(${PXR_PACKAGE} DISABLE_PRECOMPILED_HEADERS ) +if(CMAKE_WANT_UFE_BUILD) + find_package(UFE QUIET) + if(UFE_FOUND) + message(STATUS "Building with UFE ${UFE_VERSION} features enabled.") + include_directories(${UFE_INCLUDE_DIR}) + add_definitions(-DWANT_UFE_BUILD) + else() + message(STATUS "UFE not found. UFE features will be disabled.") + endif() +endif() + +if (UFE_FOUND) + target_link_libraries(${PXR_PACKAGE} ${UFE_LIBRARY}) +endif() + pxr_test_scripts( testenv/testPxrUsdAlembicChaser.py ) From 29ac3fbd034cccb496582aa64e91d64e433bd98a Mon Sep 17 00:00:00 2001 From: Hamed Sabri Date: Thu, 1 Aug 2019 11:46:34 -0400 Subject: [PATCH 14/22] - trying to be explicit here for sake of clarity! (#89) * - trying to be explicit here for sake of clarity! * - Fix MacOSX python issue that was caused by overriding args. Thanks to Pierre! (cherry picked from commit cc2ca87e1e8ac028b70efaeca033d8b1f80ed543) --- build.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/build.py b/build.py index 9e7718f01d..c9e3d25000 100644 --- a/build.py +++ b/build.py @@ -285,11 +285,12 @@ def RunCMake(context, extraArgs=None, stages=None): installArg = "" if 'install' in stages: installArg = "--target install" - - Run("cmake --build . --config {variant} {installArg} -- {multiproc}" - .format(variant=variant, - installArg=installArg, - multiproc=FormatMultiProcs(context.numJobs, generator))) + + if 'build' in stages or 'install' in stages: + Run("cmake --build . --config {variant} {installArg} -- {multiproc}" + .format(variant=variant, + installArg=installArg, + multiproc=FormatMultiProcs(context.numJobs, generator))) ############################################################ # Maya USD @@ -421,18 +422,15 @@ def __init__(self, args): # Build arguments self.buildArgs = list() - for args in args.build_args: - argList = args.split(",") - for arg in argList: + for argList in args.build_args: + for arg in argList.split(","): self.buildArgs.append(arg) # Stages arguments self.stagesArgs = list() - for args in args.stages: - argList = args.split(",") - for arg in argList: + for argList in args.stages: + for arg in argList.split(","): self.stagesArgs.append(arg) - try: context = InstallContext(args) except Exception as e: From a6a816d4aa69d1a591210a59a06c23ce0be3dea6 Mon Sep 17 00:00:00 2001 From: Hamed Sabri Date: Fri, 2 Aug 2019 10:52:57 -0400 Subject: [PATCH 15/22] Merge pull request #92 from maya3d/sabrih/update_build_doc (cherry picked from commit 09d835f119f727529e1b69577d974601768eecf9) --- doc/build.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/build.md b/doc/build.md index e9f62a8de9..2af754e588 100644 --- a/doc/build.md +++ b/doc/build.md @@ -34,8 +34,6 @@ There are four arguments that must be passed to the script: - --devkit-location ---> Directory where Maya Devkit is installed. - workspace_location ---> Directory where the project use as a workspace to build and install plugin/libraries. -When building Pixar USD Core, you need to pass ```--no-maya``` to ensure that ```third_party/maya``` plugin doesn't get built. - Comma-separated list of cmake variables can be also passed to build system using ```--build-args```. e.g ``` @@ -89,6 +87,12 @@ BUILD_PXR_PLUGIN | Builds the Pixar USD plugin and libraries. # Building USD +##### Flags, Version + +When building Pixar USD, you need to pass ```--no-maya``` flag to ensure that ```third_party/maya``` plugin doesn't get built since this plugin is now part of maya-usd. + +It is important that the version between ```Pixar USD``` and ```Maya USD plugin```match. We are currently using ```v19.05``` for Maya plugin in ```master``` branch and therefore ```Pixar USD``` build should match this version. + ##### Boost: Currently Animal Logic plugin has a dependency on some of the boost components ( e.g thread, filesystem ). When building Pixar USD, one needs to pass following key,value paired arguments for boost to include those components: From 79de90fae51814c44909ca03ccea8694d6e96f05 Mon Sep 17 00:00:00 2001 From: Sean Donnelly Date: Fri, 2 Aug 2019 14:09:03 -0400 Subject: [PATCH 16/22] MAYA-99741 - Build all 3 plugins build/work in sandbox (#93) * Fix for building in debug. --- cmake/defaults/CXXDefaults.cmake | 1 + lib/CMakeLists.txt | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/defaults/CXXDefaults.cmake b/cmake/defaults/CXXDefaults.cmake index 0b5c29a9a3..4d293a0513 100644 --- a/cmake/defaults/CXXDefaults.cmake +++ b/cmake/defaults/CXXDefaults.cmake @@ -38,6 +38,7 @@ endif() if(CMAKE_BUILD_TYPE STREQUAL "Debug") _add_define(BUILD_OPTLEVEL_DEV) + _add_define(TBB_USE_DEBUG) endif() # Set plugin path environment variable name diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 3243eb5d61..558576161f 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -431,7 +431,6 @@ target_include_directories( PUBLIC ${MAYA_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/../base ${PXR_INCLUDE_DIRS} ) From 0760ad8ee702ee79536a9f79dab620204e236de5 Mon Sep 17 00:00:00 2001 From: Pierre Tremblay Date: Tue, 6 Aug 2019 08:41:15 -0700 Subject: [PATCH 17/22] Fix import (#97) * Fixed pxrUsd RPATH, and removed incorrect linking to mayaUsd_Schemas plugin. * Import works in ADSK and PXR plugins. * AL translator now loads and imports. * Addressed review comments. --- cmake/modules/FindMayaUSD.cmake | 21 +++++++++++++- plugin/adsk/plugin/plugin.cpp | 31 +++++++++++++++++++- plugin/al/translators/CMakeLists.txt | 37 ++++++++++++++++++++---- plugin/pxr/cmake/macros/Private.cmake | 9 +++--- plugin/pxr/maya/plugin/pxrUsd/plugin.cpp | 26 +++++++++++++++++ 5 files changed, 113 insertions(+), 11 deletions(-) diff --git a/cmake/modules/FindMayaUSD.cmake b/cmake/modules/FindMayaUSD.cmake index 39cf9bf782..d2647d6120 100644 --- a/cmake/modules/FindMayaUSD.cmake +++ b/cmake/modules/FindMayaUSD.cmake @@ -76,7 +76,7 @@ find_path(MAYAUSD_INCLUDE_DIR # Use find_library to account for platform-specific library name prefixes # (e.g. lib) and suffixes (e.g. .lib, .so, .dylib). -foreach(MAYAUSD_LIB mayaUsd mayaUsd_Schemas) +foreach(MAYAUSD_LIB mayaUsd) find_library(MAYAUSD_${MAYAUSD_LIB}_LIBRARY ${MAYAUSD_LIB} @@ -91,6 +91,23 @@ foreach(MAYAUSD_LIB mayaUsd mayaUsd_Schemas) endforeach(MAYAUSD_LIB) +# Schema libraries are PxrPlugin plugins, but are also linked against by plugins +# providing import, export or updater behavior for the types they provide. +foreach(MAYAUSD_LIB mayaUsd_Schemas) + + find_library(MAYAUSD_${MAYAUSD_LIB}_LIBRARY + ${MAYAUSD_LIB} + HINTS + ${MAYAUSD_LIBRARY_DIR} + NO_DEFAULT_PATH + ) + + if (MAYAUSD_${MAYAUSD_LIB}_LIBRARY) + list(APPEND MAYAUSD_SCHEMA_LIBRARIES ${MAYAUSD_${MAYAUSD_LIB}_LIBRARY}) + endif() + +endforeach(MAYAUSD_LIB) + # If we weren't passed in the MayaUsd version info, read it from the header file. if (NOT DEFINED MAYAUSD_MAJOR_VERSION) file(READ ${MAYAUSD_INCLUDE_DIR}/mayaUsd/mayaUsd.h MAYAUSD_MAIN_HEADER) @@ -102,6 +119,7 @@ set(MAYAUSD_VERSION "${MAYAUSD_MAJOR_VERSION}.${MAYAUSD_MINOR_VERSION}.${MAYAUSD message(STATUS "MayaUSD include dir: ${MAYAUSD_INCLUDE_DIR}") message(STATUS "MayaUSD libraries: ${MAYAUSD_LIBRARIES}") +message(STATUS "MayaUSD schema libraries: ${MAYAUSD_SCHEMA_LIBRARIES}") message(STATUS "MayaUSD version: ${MAYAUSD_VERSION}") # handle the QUIETLY and REQUIRED arguments and set MAYAUSD_FOUND to TRUE if @@ -112,6 +130,7 @@ find_package_handle_standard_args(MAYAUSD REQUIRED_VARS MAYAUSD_INCLUDE_DIR MAYAUSD_LIBRARIES + MAYAUSD_SCHEMA_LIBRARIES VERSION_VAR MAYAUSD_VERSION ) diff --git a/plugin/adsk/plugin/plugin.cpp b/plugin/adsk/plugin/plugin.cpp index 8d2a59d5af..836cf978dd 100644 --- a/plugin/adsk/plugin/plugin.cpp +++ b/plugin/adsk/plugin/plugin.cpp @@ -5,7 +5,6 @@ // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== -#include "pxr/base/tf/envSetting.h" #include "base/api.h" #include "importTranslator.h" @@ -25,6 +24,12 @@ #include #include +#include "pxr/base/tf/envSetting.h" +#include "pxr/base/plug/plugin.h" +#include "pxr/base/plug/registry.h" + +#include + PXR_NAMESPACE_USING_DIRECTIVE MAYAUSD_PLUGIN_PUBLIC @@ -63,6 +68,30 @@ MStatus initializePlugin(MObject obj) MayaUsdProxyShapePlugin::getProxyShapeClassification()); CHECK_MSTATUS(status); + // As of 2-Aug-2019, these PlugPlugin translators are not loaded + // automatically. To be investigated. A duplicate of this code is in the + // Pixar plugin.cpp. + const std::vector translatorPluginNames{ + "mayaUsd_Schemas", "mayaUsd_Translators"}; + const auto& plugRegistry = PlugRegistry::GetInstance(); + std::stringstream msg("mayaUsdPlugin: "); + for (const auto& pluginName : translatorPluginNames) { + auto plugin = plugRegistry.GetPluginWithName(pluginName); + if (!plugin) { + status = MStatus::kFailure; + msg << "translator " << pluginName << " not found."; + status.perror(msg.str().c_str()); + } + else { + // Load is a no-op if already loaded. + if (!plugin->Load()) { + status = MStatus::kFailure; + msg << pluginName << " translator load failed."; + status.perror(msg.str().c_str()); + } + } + } + return status; } diff --git a/plugin/al/translators/CMakeLists.txt b/plugin/al/translators/CMakeLists.txt index a9ee113c3e..8288ef0355 100644 --- a/plugin/al/translators/CMakeLists.txt +++ b/plugin/al/translators/CMakeLists.txt @@ -1,4 +1,8 @@ -list(APPEND DEPENDANT_LIBRARIES AL_USDMaya AL_USDMayaSchemas ${MAYAUSD_LIBRARIES} gf plug tf) +# MayaReference provides import translation for AL_usd_MayaReference. +# As such, its AL_USDMAYA_DEFINE_TRANSLATOR does a +# TfType::Find, which requires AL_usd_MayaReference's +# typeid. We must therefore link against mayaUsd_Schemas. +list(APPEND DEPENDANT_LIBRARIES AL_USDMaya AL_USDMayaSchemas ${MAYAUSD_LIBRARIES} ${MAYAUSD_SCHEMA_LIBRARIES} gf plug tf) set(DIRECTORY_PATH AL/usdmaya/fileio/translators) @@ -65,10 +69,33 @@ set_target_properties(${TRANSLATORS_PACKAGE} "MFB_TRANSLATORS_PACKAGE=${TRANSLATORS_PACKAGE};MFB_ALT_TRANSLATORS_PACKAGE=${TRANSLATORS_PACKAGE}" ) -set_target_properties(${TRANSLATORS_PACKAGE} - PROPERTIES COMPILE_DEFINITIONS - "MFB_TRANSLATORS_PACKAGE=${TRANSLATORS_PACKAGE};MFB_ALT_TRANSLATORS_PACKAGE=${TRANSLATORS_PACKAGE}" - ) +# ${PXR_USD_LOCATION}/lib is added to the RPATH only if PXR_USD_LOCATION +# is set. +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(TARGET_RPATH "@loader_path/../lib;@loader_path/../../../lib") + if(DEFINED PXR_USD_LOCATION) + string(APPEND TARGET_RPATH ";${PXR_USD_LOCATION}/lib") + endif() + set(CMAKE_MACOSX_RPATH ON) + set_target_properties(${TRANSLATORS_PACKAGE} + PROPERTIES + SUFFIX ".bundle" + BUILD_WITH_INSTALL_RPATH TRUE + INSTALL_RPATH "${TARGET_RPATH}" + ) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(TARGET_RPATH "$ORIGIN/../lib:$ORIGIN/../../../lib") + if(DEFINED PXR_USD_LOCATION) + string(APPEND TARGET_RPATH ":${PXR_USD_LOCATION}/lib:${PXR_USD_LOCATION}/lib64") + endif() + # Use RUNPATH instead of RPATH. + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags" PARENT_SCOPE) + set_target_properties(${TRANSLATORS_PACKAGE} + PROPERTIES + INSTALL_RPATH "${TARGET_RPATH}" + BUILD_WITH_INSTALL_RPATH TRUE + ) +endif() target_link_libraries(${TRANSLATORS_PACKAGE} ${DEPENDANT_LIBRARIES}) diff --git a/plugin/pxr/cmake/macros/Private.cmake b/plugin/pxr/cmake/macros/Private.cmake index e506b539d6..288619db47 100644 --- a/plugin/pxr/cmake/macros/Private.cmake +++ b/plugin/pxr/cmake/macros/Private.cmake @@ -1258,12 +1258,13 @@ function(_pxr_library NAME) # XXX -- May want some plugins to be baked into monolithic. _pxr_target_link_libraries(${NAME} ${args_LIBRARIES}) - # Rpath has libraries under the USD/third party prefix and the install prefix. - # The former is for helper libraries for a third party application and - # the latter for core USD libraries. _pxr_init_rpath(rpath "${libInstallPrefix}") + # Add path for Pixar-specific Maya shared libraries. As of 1-Aug-2019, + # this is only the usdMaya shared library. _pxr_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/${INSTALL_DIR_SUFFIX}/${PXR_INSTALL_SUBDIR}/lib") - _pxr_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/${INSTALL_DIR_SUFFIX}/lib") + # Add path for common mayaUsd shared libraries. As of 1-Aug-2019, this is + # only the mayaUsd shared library. + _pxr_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") _pxr_install_rpath(rpath ${NAME}) # diff --git a/plugin/pxr/maya/plugin/pxrUsd/plugin.cpp b/plugin/pxr/maya/plugin/pxrUsd/plugin.cpp index 39b9e876e3..ec6b61fb2c 100644 --- a/plugin/pxr/maya/plugin/pxrUsd/plugin.cpp +++ b/plugin/pxr/maya/plugin/pxrUsd/plugin.cpp @@ -43,6 +43,8 @@ #include #endif +#include "pxr/base/plug/plugin.h" +#include "pxr/base/plug/registry.h" PXR_NAMESPACE_USING_DIRECTIVE @@ -185,6 +187,30 @@ initializePlugin(MObject obj) UsdMayaSceneResetNotice::InstallListener(); UsdMayaDiagnosticDelegate::InstallDelegate(); + // As of 2-Aug-2019, these PlugPlugin translators are not loaded + // automatically. To be investigated. A duplicate of this code is in the + // Autodesk plugin.cpp. + const std::vector translatorPluginNames{ + "mayaUsd_Schemas", "mayaUsd_Translators"}; + const auto& plugRegistry = PlugRegistry::GetInstance(); + std::stringstream msg("mayaUsdPlugin: "); + for (const auto& pluginName : translatorPluginNames) { + auto plugin = plugRegistry.GetPluginWithName(pluginName); + if (!plugin) { + status = MStatus::kFailure; + msg << "translator " << pluginName << " not found."; + status.perror(msg.str().c_str()); + } + else { + // Load is a no-op if already loaded. + if (!plugin->Load()) { + status = MStatus::kFailure; + msg << pluginName << " translator load failed."; + status.perror(msg.str().c_str()); + } + } + } + return status; } From b1c679a97e5196dd397e2860a9cea86e46b193ee Mon Sep 17 00:00:00 2001 From: Krystian Ligenza Date: Wed, 7 Aug 2019 06:52:10 -0700 Subject: [PATCH 18/22] Fix variant switching after merge of proxy shapes (#98) --- .../AL_USDMaya/AL/usdmaya/ForwardDeclares.h | 1 - .../AL_USDMaya/AL/usdmaya/PluginRegister.h | 3 - .../lib/AL_USDMaya/AL/usdmaya/StageData.cpp | 61 --------------- .../al/lib/AL_USDMaya/AL/usdmaya/StageData.h | 75 ------------------- .../AL/usdmaya/nodes/MeshAnimCreator.cpp | 5 +- .../AL/usdmaya/nodes/MeshAnimDeformer.cpp | 5 +- .../AL/usdmaya/nodes/ProxyShape.cpp | 2 +- .../AL/usdmaya/nodes/ProxyUsdGeomCamera.cpp | 7 +- .../AL_USDMaya/AL/usdmaya/nodes/Transform.cpp | 11 +-- plugin/al/lib/AL_USDMaya/CMakeLists.txt | 2 - .../test_translators_Translator.cpp | 3 +- 11 files changed, 19 insertions(+), 156 deletions(-) delete mode 100644 plugin/al/lib/AL_USDMaya/AL/usdmaya/StageData.cpp delete mode 100644 plugin/al/lib/AL_USDMaya/AL/usdmaya/StageData.h diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/ForwardDeclares.h b/plugin/al/lib/AL_USDMaya/AL/usdmaya/ForwardDeclares.h index fbc8ee32d6..48542d3692 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/ForwardDeclares.h +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/ForwardDeclares.h @@ -24,7 +24,6 @@ namespace usdmaya { struct guid; class Global; struct MObjectMap; -class StageData; class StageCache; namespace cmds { diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/PluginRegister.h b/plugin/al/lib/AL_USDMaya/AL/usdmaya/PluginRegister.h index b3d43cf772..4130bb6972 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/PluginRegister.h +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/PluginRegister.h @@ -19,7 +19,6 @@ #include "AL/maya/utils/CommandGuiHelper.h" #include "AL/maya/utils/MenuBuilder.h" #include "AL/usdmaya/Global.h" -#include "AL/usdmaya/StageData.h" #include "AL/usdmaya/cmds/CreateUsdPrim.h" #include "AL/usdmaya/cmds/DebugCommands.h" #include "AL/usdmaya/cmds/EventCommand.h" @@ -215,7 +214,6 @@ MStatus registerPlugin(AFnPlugin& plugin) } } - AL_REGISTER_DATA(plugin, AL::usdmaya::StageData); AL_REGISTER_COMMAND(plugin, AL::maya::utils::CommandGuiListGen); AL_REGISTER_COMMAND(plugin, AL::usdmaya::cmds::CreateUsdPrim); AL_REGISTER_COMMAND(plugin, AL::usdmaya::cmds::LayerCreateLayer); @@ -417,7 +415,6 @@ MStatus unregisterPlugin(AFnPlugin& plugin) AL_UNREGISTER_NODE(plugin, AL::usdmaya::nodes::RendererManager); AL_UNREGISTER_NODE(plugin, AL::usdmaya::nodes::Layer); AL_UNREGISTER_NODE(plugin, AL::usdmaya::nodes::LayerManager); - AL_UNREGISTER_DATA(plugin, AL::usdmaya::StageData); AL::usdmaya::Global::onPluginUnload(); return status; diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/StageData.cpp b/plugin/al/lib/AL_USDMaya/AL/usdmaya/StageData.cpp deleted file mode 100644 index a7d16c7830..0000000000 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/StageData.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// -// Copyright 2017 Animal Logic -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#include "AL/usdmaya/StageData.h" -#include "AL/usdmaya/TypeIDs.h" -#include "AL/usdmaya/DebugCodes.h" -#include "AL/maya/event/MayaEventManager.h" - -namespace AL { -namespace usdmaya { - -const MTypeId StageData::kTypeId(AL_USDMAYA_STAGEDATA); -const MString StageData::kName("AL_usdmaya_StageData"); - - -//---------------------------------------------------------------------------------------------------------------------- -void* StageData::creator() -{ - return new StageData; -} - -//---------------------------------------------------------------------------------------------------------------------- -StageData::StageData() : ParentClass() -{ - TF_DEBUG(ALUSDMAYA_EVALUATION).Msg("StageData::StageData() created: %p\n", this); -} - -//---------------------------------------------------------------------------------------------------------------------- -StageData::~StageData() -{ - TF_DEBUG(ALUSDMAYA_EVALUATION).Msg("StageData::StageData() deleted: %p\n", this); -} - - -//---------------------------------------------------------------------------------------------------------------------- -MTypeId StageData::typeId() const -{ - return kTypeId; -} - -//---------------------------------------------------------------------------------------------------------------------- -MString StageData::name() const -{ - return kName; -} -} -//---------------------------------------------------------------------------------------------------------------------- -} // al -//---------------------------------------------------------------------------------------------------------------------- diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/StageData.h b/plugin/al/lib/AL_USDMaya/AL/usdmaya/StageData.h deleted file mode 100644 index 8886b5a794..0000000000 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/StageData.h +++ /dev/null @@ -1,75 +0,0 @@ -// -// Copyright 2017 Animal Logic -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#pragma once - -#include "AL/usdmaya/Api.h" - -#include "AL/event/EventHandler.h" - -#include - -#include "pxr/usd/usd/stage.h" - -PXR_NAMESPACE_USING_DIRECTIVE - -namespace AL { -namespace usdmaya { - -//---------------------------------------------------------------------------------------------------------------------- -/// \brief This code is effectively copied from the pixar plugin. It's just used to pass the usd stage through the DG -/// \ingroup usdmaya -//---------------------------------------------------------------------------------------------------------------------- - -// At time of writing, we keep this class for AL backward compatibility only, -// because it's registered with a different type ID than its base class, and -// existing Maya files with "requires" statements depend on it. It should be -// unused otherwise. To investigate: mark StageData attributes as -// non-storable. PPT, 8-Apr-2019. - -class StageData - : public MayaUsdStageData -{ -public: - - typedef MayaUsdStageData ParentClass; - - /// \brief ctor - StageData(); - - /// \brief dtor - ~StageData(); - - /// \brief creates an instance of this data object - AL_USDMAYA_PUBLIC - static void* creator(); - - /// the type id of the stage data - AL_USDMAYA_PUBLIC - static const MTypeId kTypeId; - - /// the type name of the stage data - AL_USDMAYA_PUBLIC - static const MString kName; - -private: - MTypeId typeId() const override; - MString name() const override; -}; - -//---------------------------------------------------------------------------------------------------------------------- -} // usdmaya -} // AL -//---------------------------------------------------------------------------------------------------------------------- diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/MeshAnimCreator.cpp b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/MeshAnimCreator.cpp index f68c40248a..9257a38e90 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/MeshAnimCreator.cpp +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/MeshAnimCreator.cpp @@ -19,7 +19,6 @@ #include "AL/usdmaya/DebugCodes.h" #include "AL/usdmaya/nodes/MeshAnimCreator.h" #include "AL/usdmaya/nodes/ProxyShape.h" -#include "AL/usdmaya/StageData.h" #include "AL/usdmaya/utils/Utils.h" #include "AL/usdmaya/utils/MeshUtils.h" @@ -28,6 +27,8 @@ #include "pxr/usd/usdGeom/mesh.h" +#include + namespace AL { namespace usdmaya { namespace nodes { @@ -52,7 +53,7 @@ MStatus MeshAnimCreator::initialise() // do not write these nodes to the file. They will be created automagically by the proxy shape m_primPath = addStringAttr("primPath", "pp", kReadable | kWritable); m_inTime = addTimeAttr("inTime", "it", MTime(), kReadable | kWritable | kStorable | kConnectable); - m_inStageData = addDataAttr("inStageData", "isd", StageData::kTypeId, kWritable | kStorable | kConnectable); + m_inStageData = addDataAttr("inStageData", "isd", MayaUsdStageData::mayaTypeId, kWritable | kStorable | kConnectable); m_outMesh = addMeshAttr("outMesh", "out", kReadable | kStorable | kConnectable); attributeAffects(m_primPath, m_outMesh); attributeAffects(m_inTime, m_outMesh); diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/MeshAnimDeformer.cpp b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/MeshAnimDeformer.cpp index 560167273e..dbab7178ed 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/MeshAnimDeformer.cpp +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/MeshAnimDeformer.cpp @@ -19,7 +19,6 @@ #include "AL/usdmaya/DebugCodes.h" #include "AL/usdmaya/nodes/MeshAnimDeformer.h" #include "AL/usdmaya/nodes/ProxyShape.h" -#include "AL/usdmaya/StageData.h" #include "AL/usdmaya/utils/Utils.h" #include "maya/MFnMesh.h" @@ -27,6 +26,8 @@ #include "pxr/usd/usdGeom/mesh.h" +#include + namespace AL { namespace usdmaya { namespace nodes { @@ -52,7 +53,7 @@ MStatus MeshAnimDeformer::initialise() // do not write these nodes to the file. They will be created automagically by the proxy shape m_primPath = addStringAttr("primPath", "pp", kReadable | kWritable); m_inTime = addTimeAttr("inTime", "it", MTime(), kReadable | kWritable | kStorable | kConnectable); - m_inStageData = addDataAttr("inStageData", "isd", StageData::kTypeId, kWritable | kStorable | kConnectable); + m_inStageData = addDataAttr("inStageData", "isd", MayaUsdStageData::mayaTypeId, kWritable | kStorable | kConnectable); m_outMesh = addMeshAttr("outMesh", "out", kReadable | kStorable | kConnectable); m_inMesh = addMeshAttr("inMesh", "in", kWritable | kStorable | kConnectable); attributeAffects(m_primPath, m_outMesh); diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShape.cpp b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShape.cpp index 1e6eb7ac02..d92e7c9e0b 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShape.cpp +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShape.cpp @@ -61,7 +61,6 @@ typedef boost::filesystem::path path; #include "AL/usdmaya/nodes/Transform.h" #include "AL/usdmaya/nodes/TransformationMatrix.h" #include "AL/usdmaya/StageCache.h" -#include "AL/usdmaya/StageData.h" #include "AL/usdmaya/TypeIDs.h" #include "AL/usdmaya/Version.h" #include "AL/usdmaya/utils/Utils.h" @@ -76,6 +75,7 @@ typedef boost::filesystem::path path; #include "pxr/usdImaging/usdImaging/delegate.h" #include +#include #if defined(WANT_UFE_BUILD) #include "ufe/path.h" diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyUsdGeomCamera.cpp b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyUsdGeomCamera.cpp index 52b700a4e2..efe0b33731 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyUsdGeomCamera.cpp +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyUsdGeomCamera.cpp @@ -31,9 +31,10 @@ #include #include "AL/usdmaya/TypeIDs.h" -#include #include +#include + namespace AL { namespace usdmaya { namespace nodes { @@ -81,7 +82,7 @@ UsdGeomCamera ProxyUsdGeomCamera::getCamera() const { // Pull in stage data MFnPluginData fnData(stageObject); - AL::usdmaya::StageData* stageData = static_cast(fnData.data()); + auto* stageData = static_cast(fnData.data()); if (stageData != nullptr) { @@ -514,7 +515,7 @@ MStatus ProxyUsdGeomCamera::initialise() m_path = addStringAttr("path", "p", "", kStorable | kWritable); - m_stage = addDataAttr("stage", "s", AL::usdmaya::StageData::kTypeId, kWritable | kHidden | kConnectable, MFnNumericAttribute::kReset); + m_stage = addDataAttr("stage", "s", MayaUsdStageData::mayaTypeId, kWritable | kHidden | kConnectable, MFnNumericAttribute::kReset); m_time = addTimeAttr("time", "tm", MTime(0.0), kCached | kConnectable | kReadable | kWritable | kHidden | kStorable | kAffectsAppearance); diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/Transform.cpp b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/Transform.cpp index b0f8a5a9f2..06a38cb8bf 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/Transform.cpp +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/Transform.cpp @@ -15,11 +15,12 @@ // #include "AL/usdmaya/TypeIDs.h" #include "AL/usdmaya/DebugCodes.h" -#include "AL/usdmaya/StageData.h" #include "AL/usdmaya/nodes/ProxyShape.h" #include "AL/usdmaya/nodes/Transform.h" #include "AL/usdmaya/nodes/TransformationMatrix.h" +#include + #include "maya/MBoundingBox.h" #include "maya/MGlobal.h" #include "maya/MTime.h" @@ -97,7 +98,7 @@ MStatus Transform::initialise() addFrame("USD Prim Information"); m_primPath = addStringAttr("primPath", "pp", kReadable | kWritable | kStorable | kConnectable | kAffectsWorldSpace, true); - m_inStageData = addDataAttr("inStageData", "isd", StageData::kTypeId, kWritable | kStorable | kConnectable | kHidden | kAffectsWorldSpace); + m_inStageData = addDataAttr("inStageData", "isd", MayaUsdStageData::mayaTypeId, kWritable | kStorable | kConnectable | kHidden | kAffectsWorldSpace); addFrame("USD Timing Information"); m_time = addTimeAttr("time", "tm", MTime(0.0), kKeyable | kConnectable | kReadable | kWritable | kStorable | kAffectsWorldSpace); @@ -177,7 +178,7 @@ MStatus Transform::compute(const MPlug& plug, MDataBlock& dataBlock) // This should only be computed if there's no connection, so set it to an empty stage // create new stage data MObject data; - StageData* usdStageData = createData(StageData::kTypeId, data); + auto* usdStageData = createData(MayaUsdStageData::mayaTypeId, data); if(!usdStageData) { return MS::kFailure; @@ -435,7 +436,7 @@ MStatus Transform::validateAndSetValue(const MPlug& plug, const MDataHandle& han if(plug == m_inStageData) { MDataBlock dataBlock = forceCache(*(MDGContext *)&context); - StageData* data = inputDataValue(dataBlock, m_inStageData); + auto* data = inputDataValue(dataBlock, m_inStageData); if (data && data->stage) { MString path = inputStringValue(dataBlock, m_primPath); @@ -461,7 +462,7 @@ MStatus Transform::validateAndSetValue(const MPlug& plug, const MDataHandle& han MString path = handle.asString(); outputStringValue(dataBlock, m_primPath, path); - StageData* data = inputDataValue(dataBlock, m_inStageData); + auto* data = inputDataValue(dataBlock, m_inStageData); if (data && data->stage) { SdfPath primPath; diff --git a/plugin/al/lib/AL_USDMaya/CMakeLists.txt b/plugin/al/lib/AL_USDMaya/CMakeLists.txt index 0991ab2032..912b89d650 100644 --- a/plugin/al/lib/AL_USDMaya/CMakeLists.txt +++ b/plugin/al/lib/AL_USDMaya/CMakeLists.txt @@ -9,7 +9,6 @@ list(APPEND AL_usdmaya_headers AL/usdmaya/PluginRegister.h AL/usdmaya/SelectabilityDB.h AL/usdmaya/StageCache.h - AL/usdmaya/StageData.h AL/usdmaya/TransformOperation.h AL/usdmaya/TypeIDs.h AL/usdmaya/ForwardDeclares.h @@ -22,7 +21,6 @@ list(APPEND AL_usdmaya_source AL/usdmaya/Metadata.cpp AL/usdmaya/SelectabilityDB.cpp AL/usdmaya/StageCache.cpp - AL/usdmaya/StageData.cpp AL/usdmaya/TransformOperation.cpp AL/usdmaya/CodeTimings.cpp AL/usdmaya/moduleDeps.cpp diff --git a/plugin/al/plugin/AL_USDMayaTestPlugin/test_translators_Translator.cpp b/plugin/al/plugin/AL_USDMayaTestPlugin/test_translators_Translator.cpp index 0c6fec2834..41005b77a8 100644 --- a/plugin/al/plugin/AL_USDMayaTestPlugin/test_translators_Translator.cpp +++ b/plugin/al/plugin/AL_USDMayaTestPlugin/test_translators_Translator.cpp @@ -18,9 +18,10 @@ #include "AL/usdmaya/fileio/translators/TranslatorBase.h" #include "AL/usdmaya/fileio/translators/TranslatorContext.h" #include "AL/usdmaya/fileio/translators/TranslatorTestType.h" -#include "AL/usdmaya/StageData.h" #include "AL/usdmaya/nodes/ProxyShape.h" +#include + #include "maya/MDagModifier.h" #include "pxr/base/tf/refPtr.h" From f0bf0f85dfbae84e50d0ed2dd53a0d471a4c6646 Mon Sep 17 00:00:00 2001 From: Hamed Sabri Date: Mon, 12 Aug 2019 11:07:03 -0400 Subject: [PATCH 19/22] Run time path improvement for MacOSX and Linux(#99) * Brought over Pixar's runtime path routines into cmake/utils module and started using them in the project * Fixed MacOSX build * Added IS_WINDOWS, IS_LINUX, IS_MACOSX variables to determine the OS type --- CMakeLists.txt | 2 +- cmake/defaults/CXXDefaults.cmake | 2 +- cmake/modules/FindMaya.cmake | 14 +-- cmake/modules/FindMayaUSD.cmake | 6 +- cmake/utils.cmake | 109 +++++++++++++++--- lib/CMakeLists.txt | 12 +- lib/render/mayaToHydra/CMakeLists.txt | 31 +++-- lib/usd/CMakeLists.txt | 34 ------ lib/usd/hdMaya/CMakeLists.txt | 10 +- lib/usd/schemas/CMakeLists.txt | 14 ++- lib/usd/schemas/MayaReference.cpp | 2 +- lib/usd/schemas/MayaReference.h | 4 +- lib/usd/schemas/tokens.cpp | 2 +- lib/usd/schemas/tokens.h | 2 +- lib/usd/schemas/wrapMayaReference.cpp | 2 +- lib/usd/translators/CMakeLists.txt | 12 +- plugin/adsk/plugin/CMakeLists.txt | 32 +++-- plugin/al/CMakeLists.txt | 2 +- plugin/al/lib/AL_USDMaya/CMakeLists.txt | 4 +- plugin/al/mayautils/AL/maya/CMakeLists.txt | 2 +- .../al/plugin/AL_USDMayaPlugin/CMakeLists.txt | 34 +++--- .../AL_USDMayaTestPlugin/CMakeLists.txt | 33 +++--- .../AL/usd/schemas/maya/CMakeLists.txt | 6 +- plugin/al/translators/CMakeLists.txt | 38 ++---- .../pxrUsdTranslators/CMakeLists.txt | 34 +++--- .../AL/usdmaya/utils/CMakeLists.txt | 2 +- .../al/usdutils/AL/usd/utils/CMakeLists.txt | 2 +- plugin/al/utils/AL/CMakeLists.txt | 2 +- plugin/pxr/cmake/macros/Private.cmake | 93 ++------------- plugin/pxr/cmake/macros/Public.cmake | 24 ++-- 30 files changed, 260 insertions(+), 306 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6df334e8c..af8bc505d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ if (BUILD_MAYAUSD_LIBRARY) endif() if (APPLE) - set(OSX_ARCHITECTURES "x86_64") + set(CMAKE_OSX_ARCHITECTURES "x86_64") add_definitions(-DOSMac_ -DMAC_PLUGIN) add_definitions(-D_BOOL -DREQUIRE_IOSTREAM) endif() diff --git a/cmake/defaults/CXXDefaults.cmake b/cmake/defaults/CXXDefaults.cmake index 4d293a0513..18693623c6 100644 --- a/cmake/defaults/CXXDefaults.cmake +++ b/cmake/defaults/CXXDefaults.cmake @@ -32,7 +32,7 @@ _add_define(GLX_GLXEXT_PROTOTYPES) _add_define(BOOST_PYTHON_NO_PY_SIGNATURES) # Maya seems to require this -if (CMAKE_SYSTEM_NAME STREQUAL "Linux") +if (IS_LINUX) _add_define(LINUX) endif() diff --git a/cmake/modules/FindMaya.cmake b/cmake/modules/FindMaya.cmake index d8f5091b43..03e7df1f80 100644 --- a/cmake/modules/FindMaya.cmake +++ b/cmake/modules/FindMaya.cmake @@ -39,7 +39,7 @@ macro(MAYA_SET_PLUGIN_PROPERTIES target) set(_maya_DEFINES REQUIRE_IOSTREAM _BOOL) - if(APPLE) + if(IS_MACOSX) set(_maya_DEFINES "${_maya_DEFINES}" MAC_PLUGIN OSMac_ OSMac_MachO) set_target_properties(${target} PROPERTIES PREFIX "" @@ -78,15 +78,15 @@ macro(MAYA_SET_PLUGIN_PROPERTIES target) endmacro(MAYA_SET_PLUGIN_PROPERTIES) #============================================================================= -if(APPLE) +if(IS_MACOSX) set(MAYA_PLUGIN_SUFFIX ".bundle") -elseif(WIN32) +elseif(IS_WINDOWS) set(MAYA_PLUGIN_SUFFIX ".mll") -else() #LINUX +else(IS_LINUX) set(MAYA_PLUGIN_SUFFIX ".so") endif() -if(APPLE) +if(IS_MACOSX) find_path(MAYA_BASE_DIR include/maya/MFn.h HINTS @@ -111,7 +111,7 @@ if(APPLE) DOC "Maya's libraries path" ) -elseif(UNIX) +elseif(IS_LINUX) find_path(MAYA_BASE_DIR include/maya/MFn.h HINTS @@ -136,7 +136,7 @@ elseif(UNIX) DOC "Maya's libraries path" ) -elseif(WIN32) +elseif(IS_WINDOWS) find_path(MAYA_BASE_DIR include/maya/MFn.h HINTS diff --git a/cmake/modules/FindMayaUSD.cmake b/cmake/modules/FindMayaUSD.cmake index d2647d6120..7638412519 100644 --- a/cmake/modules/FindMayaUSD.cmake +++ b/cmake/modules/FindMayaUSD.cmake @@ -8,7 +8,7 @@ # MAYAUSD_INCLUDE_DIR Path to the MAYAUSD's include directories # -if(APPLE) +if(IS_MACOSX) find_path(MAYAUSD_LIBRARY_DIR libmayaUsd.dylib HINTS @@ -24,7 +24,7 @@ if(APPLE) DOC "MayaUSD's libraries path" ) -elseif(UNIX) +elseif(IS_LINUX) find_path(MAYAUSD_LIBRARY_DIR libmayaUsd.so HINTS @@ -40,7 +40,7 @@ elseif(UNIX) DOC "MayaUSD's libraries path" ) -elseif(WIN32) +elseif(IS_WINDOWS) find_path(MAYAUSD_LIBRARY_DIR mayaUsd.lib HINTS diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 9e7f506e77..f2b49c06a3 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -16,6 +16,15 @@ # ======================================================================= # +# The name of the operating system for which CMake is to build +if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set(IS_WINDOWS TRUE) +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(IS_LINUX TRUE) +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(IS_MACOSX TRUE) +endif() + # Appends a path to an environment variable. # Note: if you want to append multiple paths either call this multiple # times, or send in the paths with the proper platform separator. @@ -26,7 +35,7 @@ function(append_path_to_env_var envVar pathToAppend) file(TO_NATIVE_PATH "${pathToAppend}" nativePathToAppend) if(DEFINED ENV{${envVar}}) - if(WIN32) + if(IS_WINDOWS) set(newPath "$ENV{${envVar}};${nativePathToAppend}") else() set(newPath "$ENV{${envVar}}:${nativePathToAppend}") @@ -44,20 +53,86 @@ endfunction() # module The python module to find # function(find_python_module module) - string(TOUPPER ${module} module_upper) - set(module_found "${module_upper}_FOUND") - if(NOT ${module_found}) - if(ARGC GREATER 1 AND ARGV1 STREQUAL "REQUIRED") - set(${module}_FIND_REQUIRED TRUE) - endif() - execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" - "import re, ${module}; print re.compile('/__init__.py.*').sub('',${module}.__file__)" - RESULT_VARIABLE _${module}_status - OUTPUT_VARIABLE _${module}_location - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT _${module}_status) - set(${module_found} ${_${module}_location} CACHE STRING - "Location of Python module ${module}") - endif(NOT _${module}_status) - endif(NOT ${module_found}) + string(TOUPPER ${module} module_upper) + set(module_found "${module_upper}_FOUND") + if(NOT ${module_found}) + if(ARGC GREATER 1 AND ARGV1 STREQUAL "REQUIRED") + set(${module}_FIND_REQUIRED TRUE) + endif() + execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" + "import re, ${module}; print re.compile('/__init__.py.*').sub('',${module}.__file__)" + RESULT_VARIABLE _${module}_status + OUTPUT_VARIABLE _${module}_location + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT _${module}_status) + set(${module_found} ${_${module}_location} CACHE STRING + "Location of Python module ${module}") + endif(NOT _${module}_status) + endif(NOT ${module_found}) endfunction(find_python_module) + +# Initialize a variable to accumulate an rpath. The origin is the +# RUNTIME DESTINATION of the target. If not absolute it's appended +# to CMAKE_INSTALL_PREFIX. +function(init_rpath rpathRef origin) + if(NOT IS_ABSOLUTE ${origin}) + set(origin "${CMAKE_INSTALL_PREFIX}/${INSTALL_DIR_SUFFIX}/${origin}") + get_filename_component(origin "${origin}" REALPATH) + endif() + set(${rpathRef} "${origin}" PARENT_SCOPE) +endfunction() + +# Add a relative target path to the rpath. If target is absolute compute +# and add a relative path from the origin to the target. +function(add_rpath rpathRef target) + if(IS_ABSOLUTE "${target}") + # Make target relative to $ORIGIN (which is the first element in + # rpath when initialized with _pxr_init_rpath()). + list(GET ${rpathRef} 0 origin) + file(RELATIVE_PATH + target + "${origin}" + "${target}" + ) + if("x${target}" STREQUAL "x") + set(target ".") + endif() + endif() + file(TO_CMAKE_PATH "${target}" target) + set(new_rpath "${${rpathRef}}") + list(APPEND new_rpath "$ORIGIN/${target}") + set(${rpathRef} "${new_rpath}" PARENT_SCOPE) +endfunction() + +function(install_rpath rpathRef NAME) + # Get and remove the origin. + list(GET ${rpathRef} 0 origin) + set(rpath ${${rpathRef}}) + list(REMOVE_AT rpath 0) + + # Canonicalize and uniquify paths. + set(final "") + foreach(path ${rpath}) + # Replace $ORIGIN with @loader_path + if(IS_MACOSX) + if("${path}/" MATCHES "^[$]ORIGIN/") + # Replace with origin path. + string(REPLACE "$ORIGIN/" "@loader_path/" path "${path}/") + endif() + endif() + + # Strip trailing slashes. + string(REGEX REPLACE "/+$" "" path "${path}") + + # Ignore paths we already have. + if (NOT ";${final};" MATCHES ";${path};") + list(APPEND final "${path}") + endif() + endforeach() + + set_target_properties(${NAME} + PROPERTIES + INSTALL_RPATH_USE_LINK_PATH TRUE + INSTALL_RPATH "${final}" + ) +endfunction() \ No newline at end of file diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 558576161f..2054b8311b 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -32,6 +32,8 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake/modules ) +include(${PROJECT_SOURCE_DIR}/../cmake/utils.cmake) + #============================================================================== # Compiler #============================================================================== @@ -53,8 +55,7 @@ string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") set(CMAKE_INCLUDE_CURRENT_DIR ON) if (APPLE) - set(CMAKE_MACOSX_RPATH ON) - set(OSX_ARCHITECTURES "x86_64") + set(CMAKE_OSX_ARCHITECTURES "x86_64") add_definitions(-DOSMac_ -DMAC_PLUGIN) add_definitions(-D_BOOL -DREQUIRE_IOSTREAM) endif() @@ -83,7 +84,7 @@ if(CMAKE_WANT_UFE_BUILD) set(CMAKE_UFE_GROUP_INTERFACE_AVAILABLE OFF) endif() - if(MSVC) + if(IS_WINDOWS) # Silence this warning until we fix it in UFE. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251") endif() @@ -465,8 +466,7 @@ if (UFE_FOUND) target_link_libraries(${LIBRARY_NAME} ${UFE_LIBRARY}) endif() -if(APPLE) - set(CMAKE_MACOSX_RPATH ON) +if(IS_MACOSX) set_target_properties(${LIBRARY_NAME} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE @@ -488,7 +488,7 @@ install(TARGETS ${LIBRARY_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/lib ) -if(MSVC) +if(IS_WINDOWS) install(FILES $ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib OPTIONAL) endif() diff --git a/lib/render/mayaToHydra/CMakeLists.txt b/lib/render/mayaToHydra/CMakeLists.txt index c70508a979..67df8d66e6 100644 --- a/lib/render/mayaToHydra/CMakeLists.txt +++ b/lib/render/mayaToHydra/CMakeLists.txt @@ -27,31 +27,28 @@ target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_BINARY_DIR}/usd ) -set_target_properties(${TARGET_NAME} PROPERTIES - PREFIX "" - INSTALL_RPATH_USE_LINK_PATH ON -) - -if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "@loader_path/../lib") -elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") - set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN/../lib") -endif () - -maya_set_plugin_properties(${TARGET_NAME}) +# rpath setup +if(IS_MACOSX OR IS_LINUX) + init_rpath(rpath "plugin") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") + install_rpath(rpath ${TARGET_NAME}) +endif() # M3dView needs this (technically, MNativeWindowHdl.h) # private atm because M3dView is only used in .cpp right now -if (CMAKE_SYSTEM_NAME STREQUAL "Linux") +if (IS_LINUX) + set_target_properties(${TARGET_NAME} PROPERTIES PREFIX "") # gcc will NOT set this automatically target_compile_definitions(${TARGET_NAME} PRIVATE "LINUX") -elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows") +elseif (IS_WINDOWS) + set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ".mll") # Not sure if msvcc sets this automatically, but won't hurt to redefine target_compile_definitions(${TARGET_NAME} PRIVATE "_WIN32") -elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin") +elseif (IS_MACOSX) + set_target_properties(${TARGET_NAME} PROPERTIES PREFIX "" SUFFIX ".bundle") # Not sure if osx sets this automatically, but won't hurt to redefine target_compile_definitions(${TARGET_NAME} PRIVATE "OSMac_") -endif (CMAKE_SYSTEM_NAME STREQUAL "Linux") +endif() #============================================================================== # Install @@ -60,7 +57,7 @@ install( TARGETS ${TARGET_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/maya) -if(MSVC) +if(IS_WINDOWS) install(FILES $ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/maya OPTIONAL) endif() diff --git a/lib/usd/CMakeLists.txt b/lib/usd/CMakeLists.txt index 4500317193..a9ea494d1d 100644 --- a/lib/usd/CMakeLists.txt +++ b/lib/usd/CMakeLists.txt @@ -25,39 +25,5 @@ endif() add_subdirectory(hdMaya) -# Adds the proper RPATH (on Mac OS) or RUNPATH (on Linux) for PlugPlugin -# translator plugins. RUNPATH is preferable to RPATH on Linux, as it is -# overridable with LD_LIBRARY_PATH. There is no RUNPATH on Mac OS. -function(set_translators_plugin_properties plugin) - # ${PXR_USD_LOCATION}/lib is added to the RPATH only if PXR_USD_LOCATION - # is set. - if(APPLE) - set(TARGET_RPATH "@loader_path/../lib;@loader_path/../../USD/lib") - if(DEFINED PXR_USD_LOCATION) - string(APPEND TARGET_RPATH ";${PXR_USD_LOCATION}/lib") - endif() - set(CMAKE_MACOSX_RPATH ON) - set_target_properties(${plugin} - PROPERTIES - SUFFIX ".bundle" - BUILD_WITH_INSTALL_RPATH TRUE - INSTALL_RPATH "${TARGET_RPATH}" - ) - # No such thing as a CMake LINUX variable, contrary to APPLE and MSVC. - elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(TARGET_RPATH "$ORIGIN/../lib:$ORIGIN/../../USD/lib") - if(DEFINED PXR_USD_LOCATION) - string(APPEND TARGET_RPATH ":${PXR_USD_LOCATION}/lib:${PXR_USD_LOCATION}/lib64") - endif() - # Use RUNPATH instead of RPATH. - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags" PARENT_SCOPE) - set_target_properties(${plugin} - PROPERTIES - INSTALL_RPATH "${TARGET_RPATH}" - BUILD_WITH_INSTALL_RPATH TRUE - ) - endif() -endfunction(set_translators_plugin_properties) - add_subdirectory(translators) add_subdirectory(schemas) diff --git a/lib/usd/hdMaya/CMakeLists.txt b/lib/usd/hdMaya/CMakeLists.txt index 3f2274cacf..1a7e6ad9d2 100644 --- a/lib/usd/hdMaya/CMakeLists.txt +++ b/lib/usd/hdMaya/CMakeLists.txt @@ -107,15 +107,11 @@ elseif (MTOH_CXX_STD MATCHES "^14$") endif () target_compile_definitions(${TARGET_NAME} PRIVATE "HDMAYA_EXPORT=1") -set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON) -if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_NAME_DIR "@loader_path/../lib") -endif () -if (CMAKE_SYSTEM_NAME STREQUAL "Windows") +if (IS_WINDOWS) # Prevent windows.h from defining min and max macros. target_compile_definitions(${TARGET_NAME} PUBLIC "NOMINMAX=1") -elseif (APPLE) +elseif (IS_MACOSX) target_compile_definitions(${TARGET_NAME} PUBLIC "OSMac_") endif () @@ -198,6 +194,6 @@ install( DESTINATION include/hdMaya) -if(MSVC) +if(IS_WINDOWS) install(FILES $ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib OPTIONAL) endif() diff --git a/lib/usd/schemas/CMakeLists.txt b/lib/usd/schemas/CMakeLists.txt index b0f3a7d46d..9164054f1d 100644 --- a/lib/usd/schemas/CMakeLists.txt +++ b/lib/usd/schemas/CMakeLists.txt @@ -72,15 +72,23 @@ target_compile_definitions(${SCHEMA_PLUGIN} # Hamed 2019 # https://stackoverflow.com/questions/25617839/undefined-reference-to-symbol-pthread-key-deleteglibc-2-2-5 set(PTHREAD_LINK "") -if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") +if(IS_LINUX) set(PTHREAD_LINK -lpthread -lm) endif() #====================================================================== # TARGET PROPERTIES #====================================================================== +if(IS_MACOSX OR IS_LINUX) + # rpath setup + init_rpath(rpath "plugin") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") + install_rpath(rpath ${SCHEMA_PLUGIN}) +endif() -set_translators_plugin_properties("${SCHEMA_PLUGIN}") +if(IS_LINUX) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags" PARENT_SCOPE) +endif() target_link_libraries(${SCHEMA_PLUGIN} ${DEPENDANT_LIBRARIES} ${PTHREAD_LINK}) @@ -93,7 +101,7 @@ install( RUNTIME DESTINATION ${library_install_path} ) -if(MSVC) +if(IS_WINDOWS) install(FILES $ DESTINATION ${library_install_path} OPTIONAL) endif() diff --git a/lib/usd/schemas/MayaReference.cpp b/lib/usd/schemas/MayaReference.cpp index 0177c25683..95035a2a92 100644 --- a/lib/usd/schemas/MayaReference.cpp +++ b/lib/usd/schemas/MayaReference.cpp @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "./MayaReference.h" +#include "MayaReference.h" #include "pxr/usd/usd/schemaRegistry.h" #include "pxr/usd/usd/typed.h" diff --git a/lib/usd/schemas/MayaReference.h b/lib/usd/schemas/MayaReference.h index 756f441da2..5169127506 100644 --- a/lib/usd/schemas/MayaReference.h +++ b/lib/usd/schemas/MayaReference.h @@ -19,11 +19,11 @@ /// \file MayaUsd_Schemas/MayaReference.h #include "pxr/pxr.h" -#include "./api.h" +#include "api.h" #include "pxr/usd/usdGeom/xformable.h" #include "pxr/usd/usd/prim.h" #include "pxr/usd/usd/stage.h" -#include "./tokens.h" +#include "tokens.h" #include "pxr/base/vt/value.h" diff --git a/lib/usd/schemas/tokens.cpp b/lib/usd/schemas/tokens.cpp index 000d3f007b..b260802c3f 100644 --- a/lib/usd/schemas/tokens.cpp +++ b/lib/usd/schemas/tokens.cpp @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "./tokens.h" +#include "tokens.h" PXR_NAMESPACE_OPEN_SCOPE diff --git a/lib/usd/schemas/tokens.h b/lib/usd/schemas/tokens.h index dbf2e4e1de..c5ab03f94f 100644 --- a/lib/usd/schemas/tokens.h +++ b/lib/usd/schemas/tokens.h @@ -26,7 +26,7 @@ // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #include "pxr/pxr.h" -#include "./api.h" +#include "api.h" #include "pxr/base/tf/staticData.h" #include "pxr/base/tf/token.h" #include diff --git a/lib/usd/schemas/wrapMayaReference.cpp b/lib/usd/schemas/wrapMayaReference.cpp index c4cdce2254..533846e1c1 100644 --- a/lib/usd/schemas/wrapMayaReference.cpp +++ b/lib/usd/schemas/wrapMayaReference.cpp @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "./MayaReference.h" +#include "MayaReference.h" #include "pxr/usd/usd/schemaBase.h" #include "pxr/usd/sdf/primSpec.h" diff --git a/lib/usd/translators/CMakeLists.txt b/lib/usd/translators/CMakeLists.txt index 560f659ef3..72d652efb3 100644 --- a/lib/usd/translators/CMakeLists.txt +++ b/lib/usd/translators/CMakeLists.txt @@ -64,8 +64,16 @@ add_library(${TRANSLATORS_PLUGIN} SHARED ${source}) #====================================================================== # TARGET PROPERTIES #====================================================================== +if(IS_MACOSX OR IS_LINUX) + # rpath setup + init_rpath(rpath "plugin") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") + install_rpath(rpath ${TRANSLATORS_PLUGIN}) +endif() -set_translators_plugin_properties("${TRANSLATORS_PLUGIN}") +if(IS_LINUX) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags" PARENT_SCOPE) +endif() #====================================================================== # INCLUDE, LINK @@ -113,6 +121,6 @@ install( RUNTIME DESTINATION ${library_install_path} ) -if(MSVC) +if(IS_WINDOWS) install(FILES $ DESTINATION ${library_install_path} OPTIONAL) endif() diff --git a/plugin/adsk/plugin/CMakeLists.txt b/plugin/adsk/plugin/CMakeLists.txt index 9efe6c82f6..1f8460b4ac 100644 --- a/plugin/adsk/plugin/CMakeLists.txt +++ b/plugin/adsk/plugin/CMakeLists.txt @@ -44,24 +44,19 @@ target_link_libraries(${PLUGIN_PACKAGE} usdUtils ) -if(MSVC) +if(IS_WINDOWS) set_target_properties(${PLUGIN_PACKAGE} PROPERTIES SUFFIX ".mll") -elseif(APPLE) - set_target_properties(${PLUGIN_PACKAGE} - PROPERTIES - PREFIX "" - SUFFIX ".bundle" - MACOSX_RPATH TRUE - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "@loader_path/../../../lib" - ) -else() - set_target_properties(${PLUGIN_PACKAGE} - PROPERTIES - PREFIX "" - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "$ORIGIN/../../../lib" - ) +elseif(IS_MACOSX) + set_target_properties(${PLUGIN_PACKAGE} PROPERTIES PREFIX "" SUFFIX ".bundle") +elseif(IS_LINUX) + set_target_properties(${PLUGIN_PACKAGE} PROPERTIES PREFIX "") +endif() + +# rpath setup +if(IS_MACOSX OR IS_LINUX) + init_rpath(rpath "plugin") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") + install_rpath(rpath ${PLUGIN_PACKAGE}) endif() install(TARGETS @@ -71,7 +66,8 @@ install(TARGETS RUNTIME DESTINATION ${INSTALL_DIR_SUFFIX}/plugin ) -if(MSVC) + +if(IS_WINDOWS) install(FILES $ DESTINATION ${INSTALL_DIR_SUFFIX}/plugin OPTIONAL) endif() diff --git a/plugin/al/CMakeLists.txt b/plugin/al/CMakeLists.txt index af62bfbf6a..21a81a76cc 100644 --- a/plugin/al/CMakeLists.txt +++ b/plugin/al/CMakeLists.txt @@ -95,7 +95,7 @@ if(NOT SKIP_USDMAYA_TESTS) message(STATUS "========== Installing GoogleTest... ==========") set(FORCE_SHARED_CRT "") - if(MSVC) + if(IS_WINDOWS) set(FORCE_SHARED_CRT -DFORCE_SHARED_CRT=OFF) endif() execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} . ${FORCE_SHARED_CRT} diff --git a/plugin/al/lib/AL_USDMaya/CMakeLists.txt b/plugin/al/lib/AL_USDMaya/CMakeLists.txt index 912b89d650..b172ba61c8 100644 --- a/plugin/al/lib/AL_USDMaya/CMakeLists.txt +++ b/plugin/al/lib/AL_USDMaya/CMakeLists.txt @@ -224,7 +224,7 @@ install(TARGETS ${LIBRARY_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/lib ) -if(MSVC) +if(IS_WINDOWS) install(FILES $ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib OPTIONAL) endif() @@ -251,7 +251,7 @@ set_target_properties(${PYTHON_LIBRARY_NAME} PROPERTIES PREFIX "" ) -if(MSVC) +if(IS_WINDOWS) set_target_properties(${PYTHON_LIBRARY_NAME} PROPERTIES SUFFIX ".pyd" diff --git a/plugin/al/mayautils/AL/maya/CMakeLists.txt b/plugin/al/mayautils/AL/maya/CMakeLists.txt index dd83b1d978..9532d057e5 100755 --- a/plugin/al/mayautils/AL/maya/CMakeLists.txt +++ b/plugin/al/mayautils/AL/maya/CMakeLists.txt @@ -86,7 +86,7 @@ install(TARGETS ${MAYAUTILS_LIBRARY_NAME} RUNTIME DESTINATION ${MAYAUTILS_LIBRARY_LOCATION} ) -if(MSVC) +if(IS_WINDOWS) install(FILES $ DESTINATION ${MAYAUTILS_LIBRARY_LOCATION} OPTIONAL) endif() diff --git a/plugin/al/plugin/AL_USDMayaPlugin/CMakeLists.txt b/plugin/al/plugin/AL_USDMayaPlugin/CMakeLists.txt index af7b2084db..aec5dbc404 100644 --- a/plugin/al/plugin/AL_USDMayaPlugin/CMakeLists.txt +++ b/plugin/al/plugin/AL_USDMayaPlugin/CMakeLists.txt @@ -29,24 +29,22 @@ target_include_directories(${PXR_PACKAGE} "../../lib/AL_USDMaya" ) -if(MSVC) +if(IS_WINDOWS) set_target_properties(${PXR_PACKAGE} PROPERTIES SUFFIX ".mll") -elseif(APPLE) - set_target_properties(${PXR_PACKAGE} - PROPERTIES - PREFIX "" - SUFFIX ".bundle" - MACOSX_RPATH TRUE - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "@loader_path/../lib;@loader_path/../../lib;@loader_path/../../pxr/lib;@loader_path/../../pxr/maya/lib;${PXR_USD_LOCATION}/lib" - ) -else() - set_target_properties(${PXR_PACKAGE} - PROPERTIES - PREFIX "" - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/../../../lib:$ORIGIN/../../pxr/lib:$ORIGIN/../../pxr/maya/lib:${PXR_USD_LOCATION}/lib:${PXR_USD_LOCATION}/lib64" - ) +elseif(IS_MACOSX) + set_target_properties(${PXR_PACKAGE} PROPERTIES PREFIX "" SUFFIX ".bundle") +elseif(IS_LINUX) + set_target_properties(${PXR_PACKAGE} PROPERTIES PREFIX "") +endif() + +# rpath setup +if(IS_MACOSX OR IS_LINUX) + init_rpath(rpath "plugin") + add_rpath(rpath "../lib") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/plugin/pxr/lib") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/plugin/pxr/maya/lib") + install_rpath(rpath ${PXR_PACKAGE}) endif() install(TARGETS @@ -56,6 +54,6 @@ install(TARGETS RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/plugin ) -if(MSVC) +if(IS_WINDOWS) install(FILES $ DESTINATION ${CMAKE_INSTALL_PREFIX}/plugin OPTIONAL) endif() diff --git a/plugin/al/plugin/AL_USDMayaTestPlugin/CMakeLists.txt b/plugin/al/plugin/AL_USDMayaTestPlugin/CMakeLists.txt index 549a11db87..a649a35e2a 100644 --- a/plugin/al/plugin/AL_USDMayaTestPlugin/CMakeLists.txt +++ b/plugin/al/plugin/AL_USDMayaTestPlugin/CMakeLists.txt @@ -80,25 +80,22 @@ PRIVATE ${MAYATEST_INCLUDE_LOCATION} ) -if(MSVC) +if(IS_WINDOWS) set_target_properties(${PXR_PACKAGE} PROPERTIES SUFFIX ".mll") -elseif(APPLE) - set(CMAKE_MACOSX_RPATH ON) - set_target_properties(${PXR_PACKAGE} - PROPERTIES - PREFIX "" - SUFFIX ".bundle" - MACOSX_RPATH TRUE - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "@loader_path/../lib;@loader_path/../../lib;@loader_path/../../pxr/lib;@loader_path/../../pxr/maya/lib;${PXR_USD_LOCATION}/lib" - ) -else() - set_target_properties(${PXR_PACKAGE} - PROPERTIES - PREFIX "" - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/../../lib:$ORIGIN/../../pxr/lib:$ORIGIN/../../pxr/maya/lib:${PXR_USD_LOCATION}/lib:${PXR_USD_LOCATION}/lib64" - ) +elseif(IS_MACOSX) + set_target_properties(${PXR_PACKAGE} PROPERTIES PREFIX "" SUFFIX ".bundle") +elseif(IS_LINUX) + set_target_properties(${PXR_PACKAGE} PROPERTIES PREFIX "") +endif() + +# rpath setup +if(IS_MACOSX OR IS_LINUX) + init_rpath(rpath "plugin") + add_rpath(rpath "../lib") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/plugin/pxr/lib") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/plugin/pxr/maya/lib") + install_rpath(rpath ${PXR_PACKAGE}) endif() install(TARGETS diff --git a/plugin/al/schemas/AL/usd/schemas/maya/CMakeLists.txt b/plugin/al/schemas/AL/usd/schemas/maya/CMakeLists.txt index 93348feeb5..26f6ae4f0c 100644 --- a/plugin/al/schemas/AL/usd/schemas/maya/CMakeLists.txt +++ b/plugin/al/schemas/AL/usd/schemas/maya/CMakeLists.txt @@ -72,7 +72,7 @@ target_compile_definitions(AL_USDMayaSchemas # Hamed 2019 # https://stackoverflow.com/questions/25617839/undefined-reference-to-symbol-pthread-key-deleteglibc-2-2-5 set(PTHREAD_LINK "") -if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") +if(IS_LINUX) set(PTHREAD_LINK -lpthread -lm) endif() @@ -85,7 +85,7 @@ install( RUNTIME DESTINATION ${library_install_path} ) -if(MSVC) +if(IS_WINDOWS) install(FILES $ DESTINATION ${library_install_path} OPTIONAL) endif() @@ -113,7 +113,7 @@ set_target_properties(_AL_USDMayaSchemas PREFIX "" ) -if(MSVC) +if(IS_WINDOWS) set_target_properties(_AL_USDMayaSchemas PROPERTIES SUFFIX ".pyd" diff --git a/plugin/al/translators/CMakeLists.txt b/plugin/al/translators/CMakeLists.txt index 8288ef0355..6709fe01c4 100644 --- a/plugin/al/translators/CMakeLists.txt +++ b/plugin/al/translators/CMakeLists.txt @@ -69,32 +69,16 @@ set_target_properties(${TRANSLATORS_PACKAGE} "MFB_TRANSLATORS_PACKAGE=${TRANSLATORS_PACKAGE};MFB_ALT_TRANSLATORS_PACKAGE=${TRANSLATORS_PACKAGE}" ) -# ${PXR_USD_LOCATION}/lib is added to the RPATH only if PXR_USD_LOCATION -# is set. -if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set(TARGET_RPATH "@loader_path/../lib;@loader_path/../../../lib") - if(DEFINED PXR_USD_LOCATION) - string(APPEND TARGET_RPATH ";${PXR_USD_LOCATION}/lib") - endif() - set(CMAKE_MACOSX_RPATH ON) - set_target_properties(${TRANSLATORS_PACKAGE} - PROPERTIES - SUFFIX ".bundle" - BUILD_WITH_INSTALL_RPATH TRUE - INSTALL_RPATH "${TARGET_RPATH}" - ) -elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(TARGET_RPATH "$ORIGIN/../lib:$ORIGIN/../../../lib") - if(DEFINED PXR_USD_LOCATION) - string(APPEND TARGET_RPATH ":${PXR_USD_LOCATION}/lib:${PXR_USD_LOCATION}/lib64") - endif() - # Use RUNPATH instead of RPATH. - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags" PARENT_SCOPE) - set_target_properties(${TRANSLATORS_PACKAGE} - PROPERTIES - INSTALL_RPATH "${TARGET_RPATH}" - BUILD_WITH_INSTALL_RPATH TRUE - ) +# rpath setup +if(IS_MACOSX OR IS_LINUX) + init_rpath(rpath "plugin") + add_rpath(rpath "../lib") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") + install_rpath(rpath ${TRANSLATORS_PACKAGE}) +endif() + +if (IS_LINUX) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags" PARENT_SCOPE) endif() target_link_libraries(${TRANSLATORS_PACKAGE} ${DEPENDANT_LIBRARIES}) @@ -105,7 +89,7 @@ install(TARGETS ${TRANSLATORS_PACKAGE} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/lib ) -if(MSVC) +if(IS_WINDOWS) install(FILES $ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib OPTIONAL) endif() diff --git a/plugin/al/translators/pxrUsdTranslators/CMakeLists.txt b/plugin/al/translators/pxrUsdTranslators/CMakeLists.txt index 2a23aad89c..736843904d 100644 --- a/plugin/al/translators/pxrUsdTranslators/CMakeLists.txt +++ b/plugin/al/translators/pxrUsdTranslators/CMakeLists.txt @@ -30,24 +30,22 @@ add_library(${PXR_TRANSLATORS_PACKAGE} plugin.cpp ) -if(MSVC) +if(IS_WINDOWS) set_target_properties(${PXR_TRANSLATORS_PACKAGE} PROPERTIES SUFFIX ".mll") -elseif(APPLE) - set_target_properties(${PXR_TRANSLATORS_PACKAGE} - PROPERTIES - PREFIX "" - SUFFIX ".bundle" - MACOSX_RPATH TRUE - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "@loader_path/../lib;@loader_path/../../../lib;@loader_path/../../pxr/lib;@loader_path/../../pxr/maya/lib;${PXR_USD_LOCATION}/lib" - ) -else() - set_target_properties(${PXR_TRANSLATORS_PACKAGE} - PROPERTIES - PREFIX "" - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "$ORIGIN/../lib:$ORIGIN/../../../lib:$ORIGIN/../../pxr/lib:$ORIGIN/../../pxr/maya/lib:${PXR_USD_LOCATION}/lib:${PXR_USD_LOCATION}/lib64" - ) +elseif(IS_MACOSX) + set_target_properties(${PXR_TRANSLATORS_PACKAGE} PROPERTIES PREFIX "" SUFFIX ".bundle") +elseif(IS_LINUX) + set_target_properties(${PXR_TRANSLATORS_PACKAGE} PROPERTIES PREFIX "") +endif() + +# rpath setup +if(IS_MACOSX OR IS_LINUX) + init_rpath(rpath "plugin") + add_rpath(rpath "../lib") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/plugin/pxr/lib") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/plugin/pxr/maya/lib") + install_rpath(rpath ${PXR_TRANSLATORS_PACKAGE}) endif() target_include_directories( @@ -65,7 +63,7 @@ install(TARGETS ${PXR_TRANSLATORS_PACKAGE} RUNTIME DESTINATION ${INSTALL_DIR_SUFFIX}/plugin ) -if(MSVC) +if(IS_WINDOWS) install(FILES $ DESTINATION ${INSTALL_DIR_SUFFIX}/plugin OPTIONAL) endif() diff --git a/plugin/al/usdmayautils/AL/usdmaya/utils/CMakeLists.txt b/plugin/al/usdmayautils/AL/usdmaya/utils/CMakeLists.txt index b6e9d9205c..65172da23d 100755 --- a/plugin/al/usdmayautils/AL/usdmaya/utils/CMakeLists.txt +++ b/plugin/al/usdmayautils/AL/usdmaya/utils/CMakeLists.txt @@ -76,6 +76,6 @@ install(TARGETS ${USDMAYA_UTILS_LIBRARY_NAME} RUNTIME DESTINATION ${MAYA_UTILS_LIBRARY_LOCATION} ) -if(MSVC) +if(IS_WINDOWS) install(FILES $ DESTINATION ${MAYA_UTILS_LIBRARY_LOCATION} OPTIONAL) endif() diff --git a/plugin/al/usdutils/AL/usd/utils/CMakeLists.txt b/plugin/al/usdutils/AL/usd/utils/CMakeLists.txt index 6d2b26418f..ce1d49fc90 100755 --- a/plugin/al/usdutils/AL/usd/utils/CMakeLists.txt +++ b/plugin/al/usdutils/AL/usd/utils/CMakeLists.txt @@ -64,6 +64,6 @@ install(TARGETS ${USDUTILS_LIBRARY_NAME} RUNTIME DESTINATION ${USDUTILS_LIBRARY_LOCATION} ) -if(MSVC) +if(IS_WINDOWS) install(FILES $ DESTINATION ${USDUTILS_LIBRARY_LOCATION} OPTIONAL) endif() diff --git a/plugin/al/utils/AL/CMakeLists.txt b/plugin/al/utils/AL/CMakeLists.txt index 89ec4aabd6..6f0236ee8f 100755 --- a/plugin/al/utils/AL/CMakeLists.txt +++ b/plugin/al/utils/AL/CMakeLists.txt @@ -42,6 +42,6 @@ install(TARGETS ${EVENTS_LIBRARY_NAME} RUNTIME DESTINATION ${EVENTS_LIBRARY_LOCATION} ) -if(MSVC) +if(IS_WINDOWS) install(FILES $ DESTINATION ${EVENTS_LIBRARY_LOCATION} OPTIONAL) endif() diff --git a/plugin/pxr/cmake/macros/Private.cmake b/plugin/pxr/cmake/macros/Private.cmake index 288619db47..cf3261ad66 100644 --- a/plugin/pxr/cmake/macros/Private.cmake +++ b/plugin/pxr/cmake/macros/Private.cmake @@ -446,7 +446,7 @@ function(_pxr_enable_precompiled_header TARGET_NAME) # Additional compile flags to use precompiled header. This will be set(compile_flags "") - if(MSVC) + if(IS_WINDOWS) # Build with precompiled header (/Yu, /Fp) and automatically # include the header (/FI). set(compile_flags "/Yu\"${rel_output_header_path}\" /FI\"${rel_output_header_path}\" /Fp\"${abs_precompiled_path}\"") @@ -458,7 +458,7 @@ function(_pxr_enable_precompiled_header TARGET_NAME) # Use FALSE if we have an external precompiled header we can use. if(TRUE) - if(MSVC) + if(IS_WINDOWS) # Copy the header to precompile. add_custom_command( OUTPUT "${abs_output_header_path}" @@ -578,75 +578,6 @@ function(_pxr_enable_precompiled_header TARGET_NAME) endforeach() endfunction() -# Initialize a variable to accumulate an rpath. The origin is the -# RUNTIME DESTINATION of the target. If not absolute it's appended -# to CMAKE_INSTALL_PREFIX. -function(_pxr_init_rpath rpathRef origin) - if(NOT IS_ABSOLUTE ${origin}) - set(origin "${CMAKE_INSTALL_PREFIX}/${INSTALL_DIR_SUFFIX}/${origin}") - get_filename_component(origin "${origin}" REALPATH) - endif() - set(${rpathRef} "${origin}" PARENT_SCOPE) -endfunction() - -# Add a relative target path to the rpath. If target is absolute compute -# and add a relative path from the origin to the target. -function(_pxr_add_rpath rpathRef target) - if(IS_ABSOLUTE "${target}") - # Make target relative to $ORIGIN (which is the first element in - # rpath when initialized with _pxr_init_rpath()). - list(GET ${rpathRef} 0 origin) - file(RELATIVE_PATH - target - "${origin}" - "${target}" - ) - if("x${target}" STREQUAL "x") - set(target ".") - endif() - endif() - file(TO_CMAKE_PATH "${target}" target) - set(new_rpath "${${rpathRef}}") - list(APPEND new_rpath "$ORIGIN/${target}") - set(${rpathRef} "${new_rpath}" PARENT_SCOPE) -endfunction() - -function(_pxr_install_rpath rpathRef NAME) - # Get and remove the origin. - list(GET ${rpathRef} 0 origin) - set(rpath ${${rpathRef}}) - list(REMOVE_AT rpath 0) - - # Canonicalize and uniquify paths. - set(final "") - foreach(path ${rpath}) - # Replace $ORIGIN with @loader_path - if(APPLE) - if("${path}/" MATCHES "^[$]ORIGIN/") - # Replace with origin path. - string(REPLACE "$ORIGIN/" "@loader_path/" path "${path}/") - - # Simplify. - get_filename_component(path "${path}" REALPATH) - endif() - endif() - - # Strip trailing slashes. - string(REGEX REPLACE "/+$" "" path "${path}") - - # Ignore paths we already have. - if (NOT ";${final};" MATCHES ";${path};") - list(APPEND final "${path}") - endif() - endforeach() - - set_target_properties(${NAME} - PROPERTIES - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "${final}" - ) -endfunction() - # Split the library (target) names in libs into internal-to-the-monolithic- # library and external-of-it lists. function(_pxr_split_libraries libs internal_result external_result) @@ -828,7 +759,7 @@ function(_pxr_target_link_libraries NAME) if(";${PXR_STATIC_LIBS};" MATCHES ";${lib};") # The library is explicitly static. list(APPEND final ${lib}) - elseif(MSVC) + elseif(IS_WINDOWS) # The syntax here is -WHOLEARCHIVE[:lib] but CMake will # treat that as a link flag and not "see" the library. # As a result it won't replace a target with the path @@ -951,11 +882,11 @@ function(_pxr_python_module NAME) # Python modules need to be able to access their corresponding # wrapped library and the install lib directory. - _pxr_init_rpath(rpath "${libInstallPrefix}") - _pxr_add_rpath(rpath + init_rpath(rpath "${libInstallPrefix}") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/${args_WRAPPED_LIB_INSTALL_PREFIX}") - _pxr_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") - _pxr_install_rpath(rpath ${LIBRARY_NAME}) + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") + install_rpath(rpath ${LIBRARY_NAME}) _get_folder("_python" folder) set_target_properties(${LIBRARY_NAME} @@ -969,7 +900,7 @@ function(_pxr_python_module NAME) PROPERTIES SUFFIX ".pyd" ) - elseif(APPLE) + elseif(IS_MACOSX) # Python modules must be suffixed with .so on Mac. set_target_properties(${LIBRARY_NAME} PROPERTIES @@ -1258,14 +1189,14 @@ function(_pxr_library NAME) # XXX -- May want some plugins to be baked into monolithic. _pxr_target_link_libraries(${NAME} ${args_LIBRARIES}) - _pxr_init_rpath(rpath "${libInstallPrefix}") + init_rpath(rpath "${libInstallPrefix}") # Add path for Pixar-specific Maya shared libraries. As of 1-Aug-2019, # this is only the usdMaya shared library. - _pxr_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/${INSTALL_DIR_SUFFIX}/${PXR_INSTALL_SUBDIR}/lib") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/${INSTALL_DIR_SUFFIX}/${PXR_INSTALL_SUBDIR}/lib") # Add path for common mayaUsd shared libraries. As of 1-Aug-2019, this is # only the mayaUsd shared library. - _pxr_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") - _pxr_install_rpath(rpath ${NAME}) + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") + install_rpath(rpath ${NAME}) # # Set up the install. diff --git a/plugin/pxr/cmake/macros/Public.cmake b/plugin/pxr/cmake/macros/Public.cmake index 0934a404bb..2ce047bdeb 100644 --- a/plugin/pxr/cmake/macros/Public.cmake +++ b/plugin/pxr/cmake/macros/Public.cmake @@ -114,7 +114,7 @@ function(pxr_library NAME) if(args_MAYA_PLUGIN) if (WIN32) set(suffix ".mll") - elseif(APPLE) + elseif(IS_MACOSX) set(suffix ".bundle") endif() endif() @@ -267,9 +267,9 @@ function(pxr_build_test_shared_lib LIBRARY_NAME) # Find libraries under the install prefix, which has the core USD # libraries. - _pxr_init_rpath(rpath "tests/lib") - _pxr_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") - _pxr_install_rpath(rpath ${LIBRARY_NAME}) + init_rpath(rpath "tests/lib") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") + install_rpath(rpath ${LIBRARY_NAME}) if (NOT bt_SOURCE_DIR) set(bt_SOURCE_DIR testenv) @@ -347,9 +347,9 @@ function(pxr_build_test TEST_NAME) # Find libraries under the install prefix, which has the core USD # libraries. - _pxr_init_rpath(rpath "tests") - _pxr_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") - _pxr_install_rpath(rpath ${TEST_NAME}) + init_rpath(rpath "tests") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") + install_rpath(rpath ${TEST_NAME}) # XXX -- We shouldn't have to install to run tests. install(TARGETS ${TEST_NAME} @@ -738,7 +738,7 @@ function(pxr_toplevel_epilogue) # that we carefully avoid adding the usd_m target itself by using # TARGET_FILE. Linking the usd_m target would link usd_m and # everything it links to. - if(MSVC) + if(IS_WINDOWS) target_link_libraries(usd_ms PRIVATE -WHOLEARCHIVE:$ @@ -783,10 +783,10 @@ function(pxr_toplevel_epilogue) ${PXR_THREAD_LIBS} ) - _pxr_init_rpath(rpath "${libInstallPrefix}") - _pxr_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/${PXR_INSTALL_SUBDIR}/lib") - _pxr_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") - _pxr_install_rpath(rpath usd_ms) + init_rpath(rpath "${libInstallPrefix}") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/${PXR_INSTALL_SUBDIR}/lib") + add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib") + install_rpath(rpath usd_ms) endif() # Setup the plugins in the top epilogue to ensure that everybody has had a From 9f524d4abd599162a6e4c9d91f9717edb9c05176 Mon Sep 17 00:00:00 2001 From: Pierre Tremblay Date: Mon, 12 Aug 2019 10:41:38 -0700 Subject: [PATCH 20/22] Reference assembly cleanup (#100) * Factored out scene assembly from base readJob class. * Factored code to remove REFACTOR_PROXY_SHAPE. * Factored reference assembly out of instancerImager. * Factored reference assembly out of instancerShapeAdapter. * Enabled used of derived instancer shape adapter factory. --- lib/CMakeLists.txt | 2 + lib/fileio/jobs/readJob.cpp | 31 +- lib/fileio/jobs/readJob.h | 12 +- lib/render/pxrUsdMayaGL/instancerImager.cpp | 56 +- lib/render/pxrUsdMayaGL/instancerImager.h | 30 + .../pxrUsdMayaGL/instancerShapeAdapter.cpp | 102 +--- .../pxrUsdMayaGL/instancerShapeAdapter.h | 9 + .../pxrUsdMayaGL/proxyShapeDelegate.cpp | 15 - plugin/adsk/plugin/importTranslator.cpp | 8 +- .../pxr/maya/lib/pxrUsdMayaGL/CMakeLists.txt | 44 -- plugin/pxr/maya/lib/pxrUsdMayaGL/api.h | 32 -- .../maya/lib/pxrUsdMayaGL/instancerImager.cpp | 427 -------------- .../maya/lib/pxrUsdMayaGL/instancerImager.h | 162 ------ .../pxrUsdMayaGL/instancerShapeAdapter.cpp | 525 ------------------ .../lib/pxrUsdMayaGL/instancerShapeAdapter.h | 140 ----- plugin/pxr/maya/lib/usdMaya/CMakeLists.txt | 1 + .../pxr/maya/lib/usdMaya/importTranslator.cpp | 9 +- ...instancerShapeAdapterWithSceneAssembly.cpp | 135 +++++ .../instancerShapeAdapterWithSceneAssembly.h | 52 ++ plugin/pxr/maya/lib/usdMaya/proxyShape.cpp | 17 + .../lib/usdMaya/readJobWithSceneAssembly.cpp | 24 + .../lib/usdMaya/readJobWithSceneAssembly.h | 5 + .../maya/lib/usdMaya/referenceAssembly.cpp | 27 +- 23 files changed, 382 insertions(+), 1483 deletions(-) delete mode 100644 plugin/pxr/maya/lib/pxrUsdMayaGL/CMakeLists.txt delete mode 100644 plugin/pxr/maya/lib/pxrUsdMayaGL/api.h delete mode 100644 plugin/pxr/maya/lib/pxrUsdMayaGL/instancerImager.cpp delete mode 100644 plugin/pxr/maya/lib/pxrUsdMayaGL/instancerImager.h delete mode 100644 plugin/pxr/maya/lib/pxrUsdMayaGL/instancerShapeAdapter.cpp delete mode 100644 plugin/pxr/maya/lib/pxrUsdMayaGL/instancerShapeAdapter.h create mode 100644 plugin/pxr/maya/lib/usdMaya/instancerShapeAdapterWithSceneAssembly.cpp create mode 100644 plugin/pxr/maya/lib/usdMaya/instancerShapeAdapterWithSceneAssembly.h diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 2054b8311b..3f067b4aa2 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -395,8 +395,10 @@ endif() list(APPEND mayaUsdPxrUsdMayaGL_headers render/pxrUsdMayaGL/batchRenderer.h + render/pxrUsdMayaGL/debugCodes.h render/pxrUsdMayaGL/hdImagingShapeUI.h render/pxrUsdMayaGL/hdImagingShapeDrawOverride.h + render/pxrUsdMayaGL/instancerImager.h render/pxrUsdMayaGL/instancerShapeAdapter.h render/pxrUsdMayaGL/proxyShapeUI.h render/pxrUsdMayaGL/proxyDrawOverride.h diff --git a/lib/fileio/jobs/readJob.cpp b/lib/fileio/jobs/readJob.cpp index 6da932bb02..b46e63a015 100644 --- a/lib/fileio/jobs/readJob.cpp +++ b/lib/fileio/jobs/readJob.cpp @@ -16,11 +16,9 @@ #include "readJob.h" #include "../primReaderRegistry.h" -#include "../shading/shadingModeRegistry.h" #include "../../utils/stageCache.h" #include "../../nodes/stageNode.h" #include "../translators/translatorMaterial.h" -//#include "usdMaya/translatorModelAssembly.h" #include "../translators/translatorXformable.h" #include "../../utils/util.h" @@ -59,14 +57,6 @@ PXR_NAMESPACE_OPEN_SCOPE - -// for now, we hard code this to use displayColor. But maybe the more -// appropriate thing to do is just to leave shadingMode a lone and pass -// "displayColor" in from the UsdMayaRepresentationFull -// (usdMaya/referenceAssembly.cpp) -const static TfToken ASSEMBLY_SHADING_MODE = UsdMayaShadingModeTokens->displayColor; - - UsdMaya_ReadJob::UsdMaya_ReadJob( const std::string &iFileName, const std::string &iPrimPath, @@ -175,7 +165,7 @@ UsdMaya_ReadJob::Read(std::vector* addedDagPaths) usdRootPrim = stage->GetPseudoRoot(); } - bool isImportingPsuedoRoot = (usdRootPrim == stage->GetPseudoRoot()); + bool isImportingPseudoRoot = (usdRootPrim == stage->GetPseudoRoot()); if (!usdRootPrim) { TF_RUNTIME_ERROR( @@ -191,10 +181,7 @@ UsdMaya_ReadJob::Read(std::vector* addedDagPaths) .SetVariantSelection(variant.second); } - bool isSceneAssembly = mMayaRootDagPath.node().hasFn(MFn::kAssembly); - if (isSceneAssembly) { - mArgs.shadingMode = ASSEMBLY_SHADING_MODE; - } + PreImport(); UsdPrimRange range(usdRootPrim); if (range.empty()) { @@ -211,9 +198,7 @@ UsdMaya_ReadJob::Read(std::vector* addedDagPaths) // usdRootPrim's path. SdfPath rootPathToRegister = usdRootPrim.GetPath(); - if (isImportingPsuedoRoot || isSceneAssembly) { - // Skip the root prim if it is the pseudoroot, or if we are importing - // on behalf of a scene assembly. + if (SkipRootPrim(isImportingPseudoRoot)) { range.increment_begin(); } else { // Otherwise, associate the usdRootPrim's *parent* with the root Maya @@ -256,7 +241,7 @@ UsdMaya_ReadJob::Read(std::vector* addedDagPaths) DoImport(range, usdRootPrim); SdfPathSet topImportedPaths; - if (isImportingPsuedoRoot) { + if (isImportingPseudoRoot) { // get all the dag paths for the root prims TF_FOR_ALL(childIter, stage->GetPseudoRoot().GetChildren()) { topImportedPaths.insert(childIter->GetPath()); @@ -353,6 +338,14 @@ UsdMaya_ReadJob::_DoImport(UsdPrimRange& rootRange, const UsdPrim& usdRootPrim) return true; } +void UsdMaya_ReadJob::PreImport() +{} + +bool UsdMaya_ReadJob::SkipRootPrim(bool isImportingPseudoRoot) +{ + return isImportingPseudoRoot; +} + bool UsdMaya_ReadJob::Redo() { diff --git a/lib/fileio/jobs/readJob.h b/lib/fileio/jobs/readJob.h index b7bba3216c..5135aa2dc7 100644 --- a/lib/fileio/jobs/readJob.h +++ b/lib/fileio/jobs/readJob.h @@ -92,11 +92,22 @@ class UsdMaya_ReadJob MAYAUSD_CORE_PUBLIC bool _DoImport(UsdPrimRange& range, const UsdPrim& usdRootPrim); + // Hook for derived classes to perform processing before import. + // Method in this class is a no-op. + MAYAUSD_CORE_PUBLIC + virtual void PreImport(); + + // Hook for derived classes to determine whether to skip the root prim + // on prim traversal. This class returns the argument unchanged. + MAYAUSD_CORE_PUBLIC + virtual bool SkipRootPrim(bool isImportingPseudoRoot); + // Data UsdMayaJobImportArgs mArgs; std::string mFileName; std::map mVariants; UsdMayaPrimReaderContext::ObjectRegistry mNewNodeRegistry; + MDagPath mMayaRootDagPath; private: @@ -104,7 +115,6 @@ class UsdMaya_ReadJob std::string mPrimPath; MDagModifier mDagModifierUndo; bool mDagModifierSeeded; - MDagPath mMayaRootDagPath; }; diff --git a/lib/render/pxrUsdMayaGL/instancerImager.cpp b/lib/render/pxrUsdMayaGL/instancerImager.cpp index 3fd12d8dc9..0078e7aee9 100644 --- a/lib/render/pxrUsdMayaGL/instancerImager.cpp +++ b/lib/render/pxrUsdMayaGL/instancerImager.cpp @@ -19,9 +19,6 @@ #include "./debugCodes.h" #include "../../nodes/hdImagingShape.h" -#ifdef REFACTOR_REFERENCE_ASSEMBLY -#include "usdMaya/referenceAssembly.h" -#endif #include "pxr/base/tf/instantiateSingleton.h" @@ -36,6 +33,12 @@ PXR_NAMESPACE_OPEN_SCOPE TF_INSTANTIATE_SINGLETON(UsdMayaGL_InstancerImager); +UsdMayaGL_InstancerImager::ContinueTrackingOnDisconnectDelegate +UsdMayaGL_InstancerImager::_continueTrackingOnDisconnectDelegate = nullptr; + +UsdMayaGL_InstancerImager::InstancerShapeAdapterFactory +UsdMayaGL_InstancerImager::_instancerShapeAdapterFactory = nullptr; + /* static */ UsdMayaGL_InstancerImager& UsdMayaGL_InstancerImager::GetInstance() @@ -97,7 +100,7 @@ UsdMayaGL_InstancerImager::_SyncShapeAdapters( std::unique_ptr& adapter = entry.adapterVp2; if (!adapter) { - adapter.reset(new UsdMayaGL_InstancerShapeAdapter()); + adapter.reset(CreateInstancerShapeAdapter()); } if (adapter->Sync( @@ -112,7 +115,7 @@ UsdMayaGL_InstancerImager::_SyncShapeAdapters( std::unique_ptr& adapter = entry.adapterLegacy; if (!adapter) { - adapter.reset(new UsdMayaGL_InstancerShapeAdapter()); + adapter.reset(CreateInstancerShapeAdapter()); } if (adapter->Sync( @@ -384,13 +387,10 @@ UsdMayaGL_InstancerImager::_OnDisconnection( continue; } -#ifdef REFACTOR_REFERENCE_ASSEMBLY - if (sourceNode.typeId() == UsdMayaReferenceAssembly::typeId) { - // There's at least one USD reference assembly still connected to - // this point instancer, so continue tracking the instancer node. + if (ContinueTrackingOnDisconnect(sourceNode)) { + // Continue tracking the instancer node. return; } -#endif } // Queue the instancer for removal. We don't remove it right away because @@ -418,16 +418,40 @@ UsdMayaGL_InstancerImager::~UsdMayaGL_InstancerImager() _instancers.size()); } -UsdMayaGL_InstancerImager::_InstancerEntry::~_InstancerEntry() +void UsdMayaGL_InstancerImager::SetContinueTrackingOnDisconnectDelegate( + ContinueTrackingOnDisconnectDelegate delegate) { - MMessage::removeCallbacks(callbacks); + _continueTrackingOnDisconnectDelegate = delegate; } -#ifdef REFACTOR_REFERENCE_ASSEMBLY -TF_REGISTRY_FUNCTION(UsdMayaReferenceAssembly) +bool UsdMayaGL_InstancerImager::ContinueTrackingOnDisconnect( + const MFnDependencyNode& fn +) { - TfSingleton::GetInstance(); + if (!_continueTrackingOnDisconnectDelegate) { + return false; + } + return _continueTrackingOnDisconnectDelegate(fn); +} + +void UsdMayaGL_InstancerImager::SetInstancerShapeAdapterFactory( + InstancerShapeAdapterFactory factory) +{ + _instancerShapeAdapterFactory = factory; +} + +UsdMayaGL_InstancerShapeAdapter* +UsdMayaGL_InstancerImager::CreateInstancerShapeAdapter() +{ + if (!_instancerShapeAdapterFactory) { + return new UsdMayaGL_InstancerShapeAdapter(); + } + return _instancerShapeAdapterFactory(); +} + +UsdMayaGL_InstancerImager::_InstancerEntry::~_InstancerEntry() +{ + MMessage::removeCallbacks(callbacks); } -#endif PXR_NAMESPACE_CLOSE_SCOPE diff --git a/lib/render/pxrUsdMayaGL/instancerImager.h b/lib/render/pxrUsdMayaGL/instancerImager.h index fcdc3d9282..7aa9d59ec0 100644 --- a/lib/render/pxrUsdMayaGL/instancerImager.h +++ b/lib/render/pxrUsdMayaGL/instancerImager.h @@ -29,6 +29,9 @@ #include #include +#include + +#include PXR_NAMESPACE_OPEN_SCOPE @@ -60,6 +63,20 @@ class UsdMayaGL_InstancerImager : public TfWeakBase { /// Legacy Viewport adapters. void RemoveShapeAdapters(bool vp2); + /// Delegate function for returning whether we should continue tracking the + /// instancer node on disconnect. + typedef std::function ContinueTrackingOnDisconnectDelegate; + + static void SetContinueTrackingOnDisconnectDelegate( + ContinueTrackingOnDisconnectDelegate delegate); + + /// Factory function for creating instancer shape adapters. + typedef std::function InstancerShapeAdapterFactory; + + /// Set the factory function for creating instancer shape adapters. + static void SetInstancerShapeAdapterFactory( + InstancerShapeAdapterFactory factory); + private: /// Helper struct that owns all the data needed to track and draw a /// particular instancer node. @@ -151,10 +168,23 @@ class UsdMayaGL_InstancerImager : public TfWeakBase { /// @} + // Invoke the delegate, if present, else return false. + static bool ContinueTrackingOnDisconnect(const MFnDependencyNode&); + + /// Invoke the factory function for creating instancer shape adapters. If + /// no factory has been set, returns a UsdMayaGL_InstancerShapeAdapter base + /// class object. The caller must manage the lifescope of the returned + /// object. + static UsdMayaGL_InstancerShapeAdapter* CreateInstancerShapeAdapter(); + UsdMayaGL_InstancerImager(); ~UsdMayaGL_InstancerImager(); friend class TfSingleton; + + static ContinueTrackingOnDisconnectDelegate _continueTrackingOnDisconnectDelegate; + + static InstancerShapeAdapterFactory _instancerShapeAdapterFactory; }; PXR_NAMESPACE_CLOSE_SCOPE diff --git a/lib/render/pxrUsdMayaGL/instancerShapeAdapter.cpp b/lib/render/pxrUsdMayaGL/instancerShapeAdapter.cpp index 6288d5d244..c73cc41c42 100644 --- a/lib/render/pxrUsdMayaGL/instancerShapeAdapter.cpp +++ b/lib/render/pxrUsdMayaGL/instancerShapeAdapter.cpp @@ -20,9 +20,6 @@ #include "./renderParams.h" #include "./shapeAdapter.h" -#ifdef REFACTOR_REFERENCE_ASSEMBLY -#include "usdMaya/referenceAssembly.h" -#endif #include "../../utils/util.h" #include "../../fileio/utils/writeUtil.h" @@ -170,92 +167,8 @@ UsdMayaGL_InstancerShapeAdapter::_SyncInstancerPrototypes( UsdModelAPI(prototypePrim).SetKind(KindTokens->component); usdInstancer.GetPrototypesRel().AddTarget(prototypeUsdPath); - UsdReferences prototypeRefs = prototypePrim.GetReferences(); - prototypeRefs.ClearReferences(); - - // Collect data about what prototype this is. - MPlug hierarchyPlug = inputHierarchy[i]; - MPlug source = UsdMayaUtil::GetConnected(hierarchyPlug); - if (source.isNull()) { - continue; - } - - MStatus status; - MFnDependencyNode sourceNode(source.node(), &status); - if (!status) { - continue; - } - -#ifdef REFACTOR_REFERENCE_ASSEMBLY - // If this is a non-full-representation USD reference assembly, add a - // reference. Otherwise, leave the prim empty. - if (sourceNode.typeId() != UsdMayaReferenceAssembly::typeId) { - continue; - } - - UsdMayaReferenceAssembly* usdRefAssem = - dynamic_cast( - sourceNode.userNode()); - if (!usdRefAssem) { - continue; - } - - if (usdRefAssem->getActive() == - UsdMayaRepresentationFull::_assemblyType) { - continue; - } - - UsdPrim prim = usdRefAssem->usdPrim(); - if (!prim) { - continue; - } - - // Add main reference data. - const std::string& layerId = - prim.GetStage()->GetRootLayer()->GetIdentifier(); - const SdfPath primPath = prim.GetPath(); - prototypeRefs.AddReference(SdfReference(layerId, primPath)); - - // Reference session data. - // We also mute any sublayers of the session layer, because those - // correspond to assembly edits generated by UsdMayaReferenceAssembly, - // and UsdMayaReferenceAssembly won't give us the assembly edits - // consistently between different representations. - // (Most session layers won't have sublayers; they only show up when - // there's assembly edits in Collapsed/Expanded representations.) - // XXX Handle assembly edits on instancer prototypes? - if (SdfLayerHandle sessionLayer = prim.GetStage()->GetSessionLayer()) { - if (sessionLayer->GetPrimAtPath(primPath)) { - prototypeRefs.AddReference( - SdfReference(sessionLayer->GetIdentifier(), primPath), - UsdListPositionFrontOfPrependList); - const SdfSubLayerProxy subLayers = - sessionLayer->GetSubLayerPaths(); - layerIdsToMute.insert( - layerIdsToMute.end(), - subLayers.begin(), - subLayers.end()); - } - } - - // Also handles instancerTranslate. - // These are all in "physical", not "logical" indices. - auto holder = UsdMayaUtil::GetPlugDataHandle(hierarchyPlug); - MMatrix mMat = MFnMatrixData(holder->GetDataHandle().data()).matrix(); - GfMatrix4d gfMat(mMat.matrix); - - MPlug translatePlug = sourceNode.findPlug("translate", &status); - if (status) { - // OK if we didn't find plug, assume instancerTranslate is zero. - GfVec3d tr(translatePlug.child(0).asDouble(), - translatePlug.child(1).asDouble(), - translatePlug.child(2).asDouble()); - gfMat = gfMat * GfMatrix4d().SetTranslate(-tr); - } - - UsdGeomXformable xformable(prototypePrim); - xformable.MakeMatrixXform().Set(gfMat); -#endif + SyncInstancerPerPrototypePostHook( + inputHierarchy[i], prototypePrim, layerIdsToMute); } // Actually do all the muting in a batch. @@ -486,6 +399,17 @@ UsdMayaGL_InstancerShapeAdapter::_Init(HdRenderIndex* renderIndex) return true; } +/* virtual */ +void UsdMayaGL_InstancerShapeAdapter::SyncInstancerPerPrototypePostHook( + const MPlug& , + UsdPrim& prototypePrim, + std::vector& +) +{ + UsdReferences prototypeRefs = prototypePrim.GetReferences(); + prototypeRefs.ClearReferences(); +} + UsdMayaGL_InstancerShapeAdapter::UsdMayaGL_InstancerShapeAdapter() { TF_DEBUG(PXRUSDMAYAGL_SHAPE_ADAPTER_LIFECYCLE).Msg( diff --git a/lib/render/pxrUsdMayaGL/instancerShapeAdapter.h b/lib/render/pxrUsdMayaGL/instancerShapeAdapter.h index 2153fdfa1c..1154b2fa71 100644 --- a/lib/render/pxrUsdMayaGL/instancerShapeAdapter.h +++ b/lib/render/pxrUsdMayaGL/instancerShapeAdapter.h @@ -94,6 +94,15 @@ class UsdMayaGL_InstancerShapeAdapter : public PxrMayaHdShapeAdapter /// instances of this class. UsdMayaGL_InstancerShapeAdapter(); + // Derived class hook to allow derived classes to augment + // _SyncInstancerPrototypes(), for each prototype. The implementation + // in this class clears references on the argument prototypePrim. + virtual void SyncInstancerPerPrototypePostHook( + const MPlug& hierarchyPlug, + UsdPrim& prototypePrim, + std::vector& layerIdsToMute + ); + private: /// Initialize the shape adapter using the given \p renderIndex. diff --git a/lib/render/pxrUsdMayaGL/proxyShapeDelegate.cpp b/lib/render/pxrUsdMayaGL/proxyShapeDelegate.cpp index 4f1a74c3a0..d5e87ee412 100644 --- a/lib/render/pxrUsdMayaGL/proxyShapeDelegate.cpp +++ b/lib/render/pxrUsdMayaGL/proxyShapeDelegate.cpp @@ -188,25 +188,10 @@ UsdMayaGL_ClosestPointOnProxyShape( return true; } -/// Delegate for returning whether object soft-select mode is currently on -/// Technically, we could make ProxyShape track this itself, but then that would -/// be making two callbacks to track the same thing... so we use BatchRenderer -/// implementation -bool -UsdMayaGL_ObjectSoftSelectEnabled() -{ - return UsdMayaGLBatchRenderer::GetInstance().GetObjectSoftSelectEnabled(); -} - - TF_REGISTRY_FUNCTION(MayaUsdProxyShapeBase) { MayaUsdProxyShapeBase::SetClosestPointDelegate( UsdMayaGL_ClosestPointOnProxyShape); -#ifdef REFACTOR_PROXY_SHAPE - MayaUsdProxyShapeBase::SetObjectSoftSelectEnabledDelegate( - UsdMayaGL_ObjectSoftSelectEnabled); -#endif } PXR_NAMESPACE_CLOSE_SCOPE diff --git a/plugin/adsk/plugin/importTranslator.cpp b/plugin/adsk/plugin/importTranslator.cpp index 6d13d15ca4..17d8b2034f 100644 --- a/plugin/adsk/plugin/importTranslator.cpp +++ b/plugin/adsk/plugin/importTranslator.cpp @@ -112,13 +112,9 @@ UsdMayaImportTranslator::reader( userArgs, /* importWithProxyShapes = */ false, timeInterval); - UsdMaya_ReadJob* mUsdReadJob = - new UsdMaya_ReadJob(fileName, - primPath, - variants, - jobArgs); + UsdMaya_ReadJob mUsdReadJob(fileName, primPath, variants, jobArgs); std::vector addedDagPaths; - bool success = mUsdReadJob->Read(&addedDagPaths); + bool success = mUsdReadJob.Read(&addedDagPaths); return (success) ? MS::kSuccess : MS::kFailure; } diff --git a/plugin/pxr/maya/lib/pxrUsdMayaGL/CMakeLists.txt b/plugin/pxr/maya/lib/pxrUsdMayaGL/CMakeLists.txt deleted file mode 100644 index 4148c85102..0000000000 --- a/plugin/pxr/maya/lib/pxrUsdMayaGL/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -set(PXR_PACKAGE pxrUsdMayaGL) - -if (NOT ${PXR_ENABLE_GL_SUPPORT}) - message(STATUS - "Skipping ${PXR_PACKAGE} because PXR_ENABLE_GL_SUPPORT is OFF") - return() -endif() - -pxr_shared_library(${PXR_PACKAGE} - LIBRARIES - arch - gf - glf - hd - hdSt - hdx - px_vp20 - sdf - tf - usd - usdGeom - usdImaging - usdImagingGL - usdMaya - vt - ${Boost_LIBRARIES} - ${MAYA_LIBRARIES} - ${MAYAUSD_LIBRARIES} - - INCLUDE_DIRS - ${Boost_INCLUDE_DIRS} - ${MAYA_INCLUDE_DIRS} - ${MAYAUSD_INCLUDE_DIR} - - PUBLIC_HEADERS - api.h - - PRIVATE_CLASSES - instancerImager - instancerShapeAdapter - - DISABLE_PRECOMPILED_HEADERS -) - diff --git a/plugin/pxr/maya/lib/pxrUsdMayaGL/api.h b/plugin/pxr/maya/lib/pxrUsdMayaGL/api.h deleted file mode 100644 index 40856405f8..0000000000 --- a/plugin/pxr/maya/lib/pxrUsdMayaGL/api.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright 2017 Pixar -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef PXRUSDMAYAGL_API_H -#define PXRUSDMAYAGL_API_H - -#include "pxr/base/arch/export.h" - -#if defined(PXRUSDMAYAGL_EXPORTS) -# define PXRUSDMAYAGL_API ARCH_EXPORT -# define PXRUSDMAYAGL_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__) -# define PXRUSDMAYAGL_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__) -#else -# define PXRUSDMAYAGL_API ARCH_IMPORT -# define PXRUSDMAYAGL_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__) -# define PXRUSDMAYAGL_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__) -#endif -#define PXRUSDMAYAGL_LOCAL ARCH_HIDDEN - -#endif diff --git a/plugin/pxr/maya/lib/pxrUsdMayaGL/instancerImager.cpp b/plugin/pxr/maya/lib/pxrUsdMayaGL/instancerImager.cpp deleted file mode 100644 index e9f0b16106..0000000000 --- a/plugin/pxr/maya/lib/pxrUsdMayaGL/instancerImager.cpp +++ /dev/null @@ -1,427 +0,0 @@ -// -// Copyright 2018 Pixar -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#include "pxrUsdMayaGL/instancerImager.h" - -#include "pxrUsdMayaGL/batchRenderer.h" -#include "pxrUsdMayaGL/debugCodes.h" - -#include -#include "usdMaya/referenceAssembly.h" - -#include "pxr/base/tf/instantiateSingleton.h" - -#include -#include -#include -#include -#include -#include - -PXR_NAMESPACE_OPEN_SCOPE - -TF_INSTANTIATE_SINGLETON(UsdMayaGL_InstancerImager); - -/* static */ -UsdMayaGL_InstancerImager& -UsdMayaGL_InstancerImager::GetInstance() -{ - return TfSingleton::GetInstance(); -} - -void -UsdMayaGL_InstancerImager::SyncShapeAdapters(const unsigned int displayStyle) -{ - // Viewport 2.0 sync. - _SyncShapeAdapters(true, displayStyle, M3dView::DisplayStyle::kBoundingBox); -} - -void -UsdMayaGL_InstancerImager::SyncShapeAdapters( - const M3dView::DisplayStyle legacyDisplayStyle) -{ - // Legacy sync. - _SyncShapeAdapters(false, 0, legacyDisplayStyle); -} - -void -UsdMayaGL_InstancerImager::_SyncShapeAdapters( - bool vp2, - const unsigned int vp2DisplayStyle, - const M3dView::DisplayStyle legacyDisplayStyle) -{ - // Clean up any instancers scheduled for deletion, and remove their shape - // adapters. - for (const MObjectHandle& handle : _instancersToRemove) { - _StopTrackingInstancer(handle); - } - _instancersToRemove.clear(); - - // Sync all of the shape adapters. - // This will create the shape adapters if they don't yet exist. - UsdMayaUtil::MObjectHandleUnorderedSet& dirtyInstancers = - vp2 ? _dirtyInstancersVp2 : _dirtyInstancersLegacy; - for (const MObjectHandle& handle : dirtyInstancers) { - auto iter = _instancers.find(handle); - if (iter == _instancers.end()) { - continue; - } - - if (!TF_VERIFY(handle.isAlive())) { - // We should have removed this handle from all dirty lists before - // it died. Clean it up now so that this doesn't happen again. - _StopTrackingInstancer(handle); - continue; - } - - const MDagPath firstInstancePath = - MDagPath::getAPathTo(handle.object()); - - // Create the adapter if it doesn't exist yet. - _InstancerEntry& entry = iter->second; - if (vp2) { - std::unique_ptr& adapter = - entry.adapterVp2; - if (!adapter) { - adapter.reset(new UsdMayaGL_InstancerShapeAdapter()); - } - - if (adapter->Sync( - firstInstancePath, - vp2DisplayStyle, - MHWRender::kDormant)) { - UsdMayaGLBatchRenderer::GetInstance().AddShapeAdapter( - adapter.get()); - } - } - else { - std::unique_ptr& adapter = - entry.adapterLegacy; - if (!adapter) { - adapter.reset(new UsdMayaGL_InstancerShapeAdapter()); - } - - if (adapter->Sync( - firstInstancePath, - legacyDisplayStyle, - M3dView::kDormant)) { - UsdMayaGLBatchRenderer::GetInstance().AddShapeAdapter( - adapter.get()); - } - } - } - dirtyInstancers.clear(); - - // Sync all of the dirty root transforms now. - // The shape adapters should already have been created above. - UsdMayaUtil::MObjectHandleUnorderedSet& dirtyInstancerXforms = - vp2 ? _dirtyInstancerXformsVp2 : _dirtyInstancerXformsLegacy; - for (const MObjectHandle& handle : dirtyInstancerXforms) { - auto iter = _instancers.find(handle); - if (iter == _instancers.end()) { - continue; - } - - if (!TF_VERIFY(handle.isAlive())) { - // We should have removed this handle from all dirty lists before - // it died. Clean it up now so that this doesn't happen again. - _StopTrackingInstancer(handle); - continue; - } - - const MDagPath firstInstancePath = - MDagPath::getAPathTo(handle.object()); - - // *Don't* create the adapter if it doesn't exist. - // Logically, it should have already been created. - _InstancerEntry& entry = iter->second; - std::unique_ptr& adapter = - vp2 ? entry.adapterVp2 : entry.adapterLegacy; - if (!adapter) { - TF_CODING_ERROR( - "Trying to update xform for '%s' but can't find adapter", - firstInstancePath.fullPathName().asChar()); - continue; - } - - MStatus status; - const MMatrix transform = firstInstancePath.inclusiveMatrix(&status); - CHECK_MSTATUS(status); - adapter->SetRootXform(GfMatrix4d(transform.matrix)); - } - dirtyInstancerXforms.clear(); -} - -void -UsdMayaGL_InstancerImager::RemoveShapeAdapters(bool vp2) -{ - UsdMayaGLBatchRenderer& renderer = - UsdMayaGLBatchRenderer::GetInstance(); - for (auto& handleAndEntry : _instancers) { - const MObjectHandle& handle = handleAndEntry.first; - _InstancerEntry& entry = handleAndEntry.second; - - // After deleting the shape adapters, insert the handles into the - // appropriate dirty queues so that the shape adapters get properly - // recreated if SyncShapeAdapters() is called again. - if (vp2 && entry.adapterVp2) { - renderer.RemoveShapeAdapter(entry.adapterVp2.get()); - entry.adapterVp2.reset(); - - _dirtyInstancersVp2.insert(handle); - _dirtyInstancerXformsVp2.insert(handle); - } - else if (!vp2 && entry.adapterLegacy) { - renderer.RemoveShapeAdapter(entry.adapterLegacy.get()); - entry.adapterLegacy.reset(); - - _dirtyInstancersLegacy.insert(handle); - _dirtyInstancerXformsLegacy.insert(handle); - } - } -} - -void -UsdMayaGL_InstancerImager::_DirtyHdImagingShape(bool createIfNeeded) -{ - MObject hdImagingShape; - if (_cachedHdImagingShape.isAlive()) { - hdImagingShape = _cachedHdImagingShape.object(); - } - else if (createIfNeeded) { - hdImagingShape = PxrMayaHdImagingShape::GetOrCreateInstance(); - _cachedHdImagingShape = MObjectHandle(hdImagingShape); - } - - if (!hdImagingShape.isNull()) { - MHWRender::MRenderer::setGeometryDrawDirty(hdImagingShape); - } -} - -void -UsdMayaGL_InstancerImager::_StartTrackingInstancer(const MObject& instancer) -{ - MObject nonConstInstancer = instancer; - MObjectHandle instancerHandle(instancer); - _InstancerEntry& entry = _instancers[instancerHandle]; - const auto iter = _instancers.find(instancerHandle); - - MDagPath firstInstancePath = MDagPath::getAPathTo(instancer); - - // Note that in the callback below, it is safe to keep a pointer to the - // key-value pair (&*iter) because pointers into unordered_maps are not - // invalidated unless the element is erased. And when the element is erased, - // the callback is removed in the _InstancerEntry's destructor. - // Note also the peculiar (and seemingly undocumented) behavior of - // addWorldMatrixModifiedCallback: it listens to world matrix changes on - // _any instance_, not just the instance specified by firstInstancePath. - // (That's good in this case!) - entry.callbacks.append(MDagMessage::addWorldMatrixModifiedCallback( - firstInstancePath, _OnWorldMatrixChanged, &*iter)); - entry.callbacks.append(MNodeMessage::addNodeDirtyCallback( - nonConstInstancer, _OnNodeDirty, nullptr)); - - TF_DEBUG(PXRUSDMAYAGL_INSTANCER_TRACKING).Msg( - "Started tracking instancer '%s' (%u)\n", - firstInstancePath.fullPathName().asChar(), - instancerHandle.hashCode()); - - // Newly-tracked instancers should be marked dirty. - _dirtyInstancersVp2.insert(instancerHandle); - _dirtyInstancersLegacy.insert(instancerHandle); - _dirtyInstancerXformsVp2.insert(instancerHandle); - _dirtyInstancerXformsLegacy.insert(instancerHandle); - _DirtyHdImagingShape(true); -} - -void -UsdMayaGL_InstancerImager::_StopTrackingInstancer( - const MObjectHandle& instancerHandle) -{ - auto iter = _instancers.find(instancerHandle); - if (iter == _instancers.end()) { - // We're not currently tracking this instancer. - return; - } - - // Remove shape adapters from batch renderer. - _InstancerEntry& entry = iter->second; - if (entry.adapterVp2) { - UsdMayaGLBatchRenderer::GetInstance().RemoveShapeAdapter( - entry.adapterVp2.get()); - } - if (entry.adapterLegacy) { - UsdMayaGLBatchRenderer::GetInstance().RemoveShapeAdapter( - entry.adapterLegacy.get()); - } - - // Remove it from the master list. This will also remove all callbacks. - _instancers.erase(instancerHandle); - - TF_DEBUG(PXRUSDMAYAGL_INSTANCER_TRACKING).Msg( - "Stopped tracking instancer (%u)\n", - instancerHandle.hashCode()); - - // Remove it from any dirty lists so that we don't try to sync it again. - _dirtyInstancersVp2.erase(instancerHandle); - _dirtyInstancersLegacy.erase(instancerHandle); - _dirtyInstancerXformsVp2.erase(instancerHandle); - _dirtyInstancerXformsLegacy.erase(instancerHandle); -} - -/* static */ -void -UsdMayaGL_InstancerImager::_OnNodeDirty(MObject& node, void* clientData) -{ - UsdMayaGL_InstancerImager& me = GetInstance(); - const MObjectHandle handle(node); - - bool inserted = false; - inserted |= me._dirtyInstancersVp2.insert(handle).second; - inserted |= me._dirtyInstancersLegacy.insert(handle).second; - if (inserted) { - me._DirtyHdImagingShape(false); - } -} - -/* static */ -void -UsdMayaGL_InstancerImager::_OnWorldMatrixChanged( - MObject &transformNode, - MDagMessage::MatrixModifiedFlags &modified, - void *clientData) -{ - UsdMayaGL_InstancerImager& me = GetInstance(); - const auto handleEntryPair = - static_cast*>(clientData); - const MObjectHandle& handle = handleEntryPair->first; - - bool inserted = false; - inserted |= me._dirtyInstancerXformsVp2.insert(handle).second; - inserted |= me._dirtyInstancerXformsLegacy.insert(handle).second; - if (inserted) { - me._DirtyHdImagingShape(false); - } -} - -void -UsdMayaGL_InstancerImager::_OnSceneReset(const UsdMayaSceneResetNotice& notice) -{ - TfSingleton::DeleteInstance(); - TfSingleton::GetInstance(); -} - -void -UsdMayaGL_InstancerImager::_OnConnection( - const UsdMayaAssemblyConnectedToInstancerNotice& notice) -{ - if (MGlobal::mayaState() != MGlobal::kInteractive) { - return; - } - - MObject instancer = notice.GetInstancer(); - const MObjectHandle instancerHandle(instancer); - - // Remove the instancer from the removal list, if it was previously - // scheduled for removal. - _instancersToRemove.erase(instancerHandle); - - // Create a new entry in our instancers list only if we haven't seen this - // instancer before. - if (_instancers.count(instancerHandle) == 0) { - _StartTrackingInstancer(instancer); - } -} - -void -UsdMayaGL_InstancerImager::_OnDisconnection( - const UsdMayaAssemblyDisconnectedFromInstancerNotice& notice) -{ - if (MGlobal::mayaState() != MGlobal::kInteractive) { - return; - } - - MObject instancer = notice.GetInstancer(); - const MObjectHandle instancerHandle(instancer); - - MStatus status; - MFnDependencyNode instancerDepNode(instancer, &status); - if (!status) { - return; - } - - MPlug inputHierarchy = instancerDepNode.findPlug("inputHierarchy", &status); - if (!status) { - return; - } - - // Check the input hierarchy (prototypes) of the instancer to see if it - // still requires Hydra drawing. - const unsigned int numElements = inputHierarchy.numElements(); - for (unsigned int i = 0; i < numElements; ++i) { - MPlug hierarchyPlug = inputHierarchy[i]; - MPlug source = UsdMayaUtil::GetConnected(hierarchyPlug); - if (source.isNull()) { - continue; - } - - MFnDependencyNode sourceNode(source.node(), &status); - if (!status) { - continue; - } - - if (sourceNode.typeId() == UsdMayaReferenceAssembly::typeId) { - // There's at least one USD reference assembly still connected to - // this point instancer, so continue tracking the instancer node. - return; - } - } - - // Queue the instancer for removal. We don't remove it right away because - // changing prototypes causes instancers to briefly enter states where they - // have no prototypes (and thus don't need Hydra drawing). Instancers - // queued for removal will actually be removed on the next invocation of - // _SyncShapeAdapters(). - _instancersToRemove.insert(instancerHandle); - _DirtyHdImagingShape(false); -} - -UsdMayaGL_InstancerImager::UsdMayaGL_InstancerImager() -{ - TfWeakPtr me(this); - TfNotice::Register(me, &UsdMayaGL_InstancerImager::_OnSceneReset); - TfNotice::Register(me, &UsdMayaGL_InstancerImager::_OnConnection); - TfNotice::Register(me, &UsdMayaGL_InstancerImager::_OnDisconnection); -} - -UsdMayaGL_InstancerImager::~UsdMayaGL_InstancerImager() -{ - TF_DEBUG(PXRUSDMAYAGL_INSTANCER_TRACKING).Msg( - "UsdMayaGL_InstancerImager dying; stopped tracking remaining " - " %zu instancers\n", - _instancers.size()); -} - -UsdMayaGL_InstancerImager::_InstancerEntry::~_InstancerEntry() -{ - MMessage::removeCallbacks(callbacks); -} - -TF_REGISTRY_FUNCTION(UsdMayaReferenceAssembly) -{ - TfSingleton::GetInstance(); -} - -PXR_NAMESPACE_CLOSE_SCOPE diff --git a/plugin/pxr/maya/lib/pxrUsdMayaGL/instancerImager.h b/plugin/pxr/maya/lib/pxrUsdMayaGL/instancerImager.h deleted file mode 100644 index d244179240..0000000000 --- a/plugin/pxr/maya/lib/pxrUsdMayaGL/instancerImager.h +++ /dev/null @@ -1,162 +0,0 @@ -// -// Copyright 2018 Pixar -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef PXRUSDMAYAGL_INSTANCER_IMAGER_H -#define PXRUSDMAYAGL_INSTANCER_IMAGER_H - -/// \file pxrUsdMayaGL/instancerImager.h - -#include "pxrUsdMayaGL/api.h" -#include "pxrUsdMayaGL/instancerShapeAdapter.h" - -#include "pxr/base/tf/singleton.h" -#include "pxr/base/tf/weakBase.h" - -#include -#include - -#include -#include - -PXR_NAMESPACE_OPEN_SCOPE - -/// Class for syncing native Maya instancers with the pxrHdImagingShape so that -/// it can draw USD reference assemblies connected to native Maya instancers. -/// -/// XXX We currently don't support drawing multiple instanced instancers. -/// When instancer nodes appear at multiple points in the DAG path via native -/// Maya instancing, we only draw the 0th instance. This behavior is similar to -/// the current imaging behavior of USD proxy shapes, where only one instance -/// gets drawn by the draw override. -class UsdMayaGL_InstancerImager : public TfWeakBase { -public: - static UsdMayaGL_InstancerImager& GetInstance(); - - /// Sync all dirty instancer shape adapters for Viewport 2.0. - /// If the shape adapters do not yet exist, they will be created. - void SyncShapeAdapters(const unsigned int displayStyle); - - /// Sync all dirty instancer shape adapters for Legacy Viewport. - /// If the shape adapters do not yet exist, they will be created. - void SyncShapeAdapters(const M3dView::DisplayStyle legacyDisplayStyle); - - /// Destroys all shape adapters for currently tracked instancers, but - /// does not stop tracking the instancers. - /// Calling SyncShapeAdapters() again after this will recreate the shape - /// adapters. - /// If \p vp2 is set, destroys the VP2 adapters. Otherwise, destroys the - /// Legacy Viewport adapters. - void RemoveShapeAdapters(bool vp2); - -private: - /// Helper struct that owns all the data needed to track and draw a - /// particular instancer node. - struct _InstancerEntry { - MCallbackIdArray callbacks; - - // The shape adapter generates an in-memory USD stage, so don't create - // the shape adapters until we need them. For example, we might never - // need the legacy shape adapter if we only have VP2 viewports. - std::unique_ptr adapterVp2; - std::unique_ptr adapterLegacy; - - ~_InstancerEntry(); - }; - - /// Master list of all instancers being tracked. - UsdMayaUtil::MObjectHandleUnorderedMap<_InstancerEntry> _instancers; - - /// List of instancers queued for removal. Won't be removed immediately, - /// but will be removed on the next _StopTrackingInstancersToRemove(). - UsdMayaUtil::MObjectHandleUnorderedSet _instancersToRemove; - - /// Instancers that need a sync of their prototypes or instance data. - UsdMayaUtil::MObjectHandleUnorderedSet _dirtyInstancersVp2; - UsdMayaUtil::MObjectHandleUnorderedSet _dirtyInstancersLegacy; - - /// Instancers that need a sync of their world-space xform. - UsdMayaUtil::MObjectHandleUnorderedSet _dirtyInstancerXformsVp2; - UsdMayaUtil::MObjectHandleUnorderedSet _dirtyInstancerXformsLegacy; - - /// Cached handle to the global, singleton pxrHdImagingShape. - MObjectHandle _cachedHdImagingShape; - - /// \name Maya MMessage callbacks (statics) - /// @{ - - /// Maya callback for when the given \p node becomes dirty. - static void _OnNodeDirty( - MObject& node, - void* clientData); - - /// Maya callback for when the \p transformNode's world-space xform changes. - /// \p transformNode is either the node for which the callback was - /// registered or one of its ancestors. - static void _OnWorldMatrixChanged( - MObject &transformNode, - MDagMessage::MatrixModifiedFlags& modified, - void *clientData); - - /// @} - /// \name Helpers - /// @{ - - /// Helper method to sync shape adapters for any instancers marked as dirty; - /// this handles differences between VP2 and Legacy Viewport. - void _SyncShapeAdapters( - bool vp2, - const unsigned int vp2DisplayStyle, - const M3dView::DisplayStyle legacyDisplayStyle); - - /// Marks the global pxrHdImagingShape as dirty. - /// If \p createIfNeeded is true, then creates the pxrHdImagingShape if it - /// doesn't exist, and then marks it dirty. Otherwise, only dirties the - /// shape if it already exists. - void _DirtyHdImagingShape(bool createIfNeeded); - - /// @} - /// \name Native instancer node management - /// @{ - - /// Adds an entry for the given instancer. - void _StartTrackingInstancer(const MObject& instancer); - /// Removes the entry for the given instancer. - void _StopTrackingInstancer(const MObjectHandle& instancerHandle); - - /// @} - /// \name Notice listeners (instance methods) - /// @{ - - /// Notice listener method for when the Maya scene resets. - void _OnSceneReset( - const UsdMayaSceneResetNotice& notice); - /// Notice listener method for assembly-instancer connections. - void _OnConnection( - const UsdMayaAssemblyConnectedToInstancerNotice& notice); - /// Notice listener method for assembly-instancer disconnections. - void _OnDisconnection( - const UsdMayaAssemblyDisconnectedFromInstancerNotice& notice); - - /// @} - - UsdMayaGL_InstancerImager(); - ~UsdMayaGL_InstancerImager(); - - friend class TfSingleton; -}; - -PXR_NAMESPACE_CLOSE_SCOPE - -#endif diff --git a/plugin/pxr/maya/lib/pxrUsdMayaGL/instancerShapeAdapter.cpp b/plugin/pxr/maya/lib/pxrUsdMayaGL/instancerShapeAdapter.cpp deleted file mode 100644 index 6cda808fcb..0000000000 --- a/plugin/pxr/maya/lib/pxrUsdMayaGL/instancerShapeAdapter.cpp +++ /dev/null @@ -1,525 +0,0 @@ -// -// Copyright 2018 Pixar -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#include "pxrUsdMayaGL/instancerShapeAdapter.h" - -#include "pxrUsdMayaGL/batchRenderer.h" -#include "pxrUsdMayaGL/debugCodes.h" -#include "pxrUsdMayaGL/renderParams.h" -#include "pxrUsdMayaGL/shapeAdapter.h" - -#include "usdMaya/referenceAssembly.h" -#include -#include - -#include "pxr/base/gf/vec4f.h" -#include "pxr/base/gf/matrix4d.h" - -#include "pxr/base/tf/debug.h" -#include "pxr/base/tf/diagnostic.h" -#include "pxr/base/tf/staticTokens.h" -#include "pxr/base/tf/stringUtils.h" -#include "pxr/base/tf/token.h" - -#include "pxr/imaging/hd/enums.h" -#include "pxr/imaging/hd/renderIndex.h" -#include "pxr/imaging/hd/repr.h" -#include "pxr/imaging/hd/rprimCollection.h" -#include "pxr/imaging/hd/tokens.h" - -#include "pxr/usd/kind/registry.h" - -#include "pxr/usd/sdf/path.h" - -#include "pxr/usd/usd/modelAPI.h" -#include "pxr/usd/usd/prim.h" -#include "pxr/usd/usd/timeCode.h" - -#include "pxr/usd/usdGeom/pointInstancer.h" - -#include "pxr/usdImaging/usdImaging/delegate.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - - -PXR_NAMESPACE_OPEN_SCOPE - - -TF_DEFINE_PRIVATE_TOKENS( - _tokens, - ((NativeInstancerType, "instancer")) - (Instancer) - (Prototypes) - (EmptyPrim) -); - -/* virtual */ -bool -UsdMayaGL_InstancerShapeAdapter::UpdateVisibility(const M3dView* view) -{ - bool isVisible; - if (!_GetVisibility(_shapeDagPath, view, &isVisible)) { - return false; - } - - if (_delegate && _delegate->GetRootVisibility() != isVisible) { - _delegate->SetRootVisibility(isVisible); - return true; - } - - return false; -} - -/* virtual */ -bool -UsdMayaGL_InstancerShapeAdapter::IsVisible() const -{ - return (_delegate && _delegate->GetRootVisibility()); -} - -/* virtual */ -void -UsdMayaGL_InstancerShapeAdapter::SetRootXform(const GfMatrix4d& transform) -{ - _rootXform = transform; - - if (_delegate) { - _delegate->SetRootTransform(_rootXform); - } -} - -/* virtual */ -const SdfPath& -UsdMayaGL_InstancerShapeAdapter::GetDelegateID() const -{ - if (_delegate) { - return _delegate->GetDelegateID(); - } - - return SdfPath::EmptyPath(); -} - -static void -_ClearInstancer(const UsdGeomPointInstancer& usdInstancer) -{ - usdInstancer.GetPrototypesRel().SetTargets({ - SdfPath::AbsoluteRootPath() - .AppendChild(_tokens->Instancer) - .AppendChild(_tokens->EmptyPrim)}); - usdInstancer.CreateProtoIndicesAttr().Set(VtIntArray()); - usdInstancer.CreatePositionsAttr().Set(VtVec3fArray()); - usdInstancer.CreateOrientationsAttr().Set(VtQuathArray()); - usdInstancer.CreateScalesAttr().Set(VtVec3fArray()); -} - -size_t -UsdMayaGL_InstancerShapeAdapter::_SyncInstancerPrototypes( - const UsdGeomPointInstancer& usdInstancer, - const MPlug& inputHierarchy) -{ - usdInstancer.GetPrototypesRel().ClearTargets(/*removeSpec*/ false); - - // Write prototypes using a custom code path. We're only going to - // export USD reference assemblies; any native objects will be left - // as empty prims. - const UsdStagePtr stage = usdInstancer.GetPrim().GetStage(); - stage->MuteAndUnmuteLayers({}, stage->GetMutedLayers()); - - const SdfPath prototypesGroupPath = SdfPath::AbsoluteRootPath() - .AppendChild(_tokens->Instancer) - .AppendChild(_tokens->Prototypes); - std::vector layerIdsToMute; - for (unsigned int i = 0; i < inputHierarchy.numElements(); ++i) { - // Set up an empty prim for the prototype reference. - // This code path is designed so that, after setting up the prim, - // we can just leave it and "continue" if we error trying to set it up. - const TfToken prototypeName(TfStringPrintf("prototype_%d", i)); - const SdfPath prototypeUsdPath = - prototypesGroupPath.AppendChild(prototypeName); - UsdPrim prototypePrim = stage->DefinePrim(prototypeUsdPath); - UsdModelAPI(prototypePrim).SetKind(KindTokens->component); - usdInstancer.GetPrototypesRel().AddTarget(prototypeUsdPath); - - UsdReferences prototypeRefs = prototypePrim.GetReferences(); - prototypeRefs.ClearReferences(); - - // Collect data about what prototype this is. - MPlug hierarchyPlug = inputHierarchy[i]; - MPlug source = UsdMayaUtil::GetConnected(hierarchyPlug); - if (source.isNull()) { - continue; - } - - MStatus status; - MFnDependencyNode sourceNode(source.node(), &status); - if (!status) { - continue; - } - - // If this is a non-full-representation USD reference assembly, add a - // reference. Otherwise, leave the prim empty. - if (sourceNode.typeId() != UsdMayaReferenceAssembly::typeId) { - continue; - } - - UsdMayaReferenceAssembly* usdRefAssem = - dynamic_cast( - sourceNode.userNode()); - if (!usdRefAssem) { - continue; - } - - if (usdRefAssem->getActive() == - UsdMayaRepresentationFull::_assemblyType) { - continue; - } - - UsdPrim prim = usdRefAssem->usdPrim(); - if (!prim) { - continue; - } - - // Add main reference data. - const std::string& layerId = - prim.GetStage()->GetRootLayer()->GetIdentifier(); - const SdfPath primPath = prim.GetPath(); - prototypeRefs.AddReference(SdfReference(layerId, primPath)); - - // Reference session data. - // We also mute any sublayers of the session layer, because those - // correspond to assembly edits generated by UsdMayaReferenceAssembly, - // and UsdMayaReferenceAssembly won't give us the assembly edits - // consistently between different representations. - // (Most session layers won't have sublayers; they only show up when - // there's assembly edits in Collapsed/Expanded representations.) - // XXX Handle assembly edits on instancer prototypes? - if (SdfLayerHandle sessionLayer = prim.GetStage()->GetSessionLayer()) { - if (sessionLayer->GetPrimAtPath(primPath)) { - prototypeRefs.AddReference( - SdfReference(sessionLayer->GetIdentifier(), primPath), - UsdListPositionFrontOfPrependList); - const SdfSubLayerProxy subLayers = - sessionLayer->GetSubLayerPaths(); - layerIdsToMute.insert( - layerIdsToMute.end(), - subLayers.begin(), - subLayers.end()); - } - } - - // Also handles instancerTranslate. - // These are all in "physical", not "logical" indices. - auto holder = UsdMayaUtil::GetPlugDataHandle(hierarchyPlug); - MMatrix mMat = MFnMatrixData(holder->GetDataHandle().data()).matrix(); - GfMatrix4d gfMat(mMat.matrix); - - MPlug translatePlug = sourceNode.findPlug("translate", &status); - if (status) { - // OK if we didn't find plug, assume instancerTranslate is zero. - GfVec3d tr(translatePlug.child(0).asDouble(), - translatePlug.child(1).asDouble(), - translatePlug.child(2).asDouble()); - gfMat = gfMat * GfMatrix4d().SetTranslate(-tr); - } - - UsdGeomXformable xformable(prototypePrim); - xformable.MakeMatrixXform().Set(gfMat); - } - - // Actually do all the muting in a batch. - stage->MuteAndUnmuteLayers(layerIdsToMute, {}); - - return inputHierarchy.numElements(); -} - -void -UsdMayaGL_InstancerShapeAdapter::_SyncInstancer( - const UsdGeomPointInstancer& usdInstancer, - const MDagPath& mayaInstancerPath) -{ - MStatus status; - MFnDagNode dagNode(mayaInstancerPath, &status); - if (!status) { - _ClearInstancer(usdInstancer); - return; - } - - MPlug inputPoints = dagNode.findPlug("inputPoints", &status); - if (!status) { - _ClearInstancer(usdInstancer); - return; - } - - MPlug inputHierarchy = dagNode.findPlug("inputHierarchy", &status); - if (!status) { - _ClearInstancer(usdInstancer); - return; - } - - MPlug inputPointsSrc = UsdMayaUtil::GetConnected(inputPoints); - if (inputPointsSrc.isNull()) { - _ClearInstancer(usdInstancer); - return; - } - - auto holder = UsdMayaUtil::GetPlugDataHandle(inputPointsSrc); - if (!holder) { - _ClearInstancer(usdInstancer); - return; - } - - MFnArrayAttrsData data(holder->GetDataHandle().data(), &status); - if (!status) { - _ClearInstancer(usdInstancer); - return; - } - - size_t numPrototypes = _SyncInstancerPrototypes( - usdInstancer, inputHierarchy); - if (!numPrototypes) { - _ClearInstancer(usdInstancer); - return; - } - - // Write PointInstancer attrs using export code path. - UsdMayaWriteUtil::WriteArrayAttrsToInstancer( - data, usdInstancer, numPrototypes, - UsdTimeCode::Default()); -} - -/* virtual */ -bool -UsdMayaGL_InstancerShapeAdapter::_Sync( - const MDagPath& shapeDagPath, - const unsigned int displayStyle, - const MHWRender::DisplayStatus displayStatus) -{ - MStatus status; - UsdPrim usdPrim = _instancerStage->GetDefaultPrim(); - UsdGeomPointInstancer instancer(usdPrim); - _SyncInstancer(instancer, shapeDagPath); - - // Check for updates to the shape or changes in the batch renderer that - // require us to re-initialize the shape adapter. - HdRenderIndex* renderIndex = - UsdMayaGLBatchRenderer::GetInstance().GetRenderIndex(); - if (!(shapeDagPath == _shapeDagPath) || - !_delegate || - renderIndex != &_delegate->GetRenderIndex()) { - _shapeDagPath = shapeDagPath; - - if (!_Init(renderIndex)) { - return false; - } - } - - // Reset _renderParams to the defaults. - _renderParams = PxrMayaHdRenderParams(); - - const MMatrix transform = _shapeDagPath.inclusiveMatrix(&status); - if (status == MS::kSuccess) { - _rootXform = GfMatrix4d(transform.matrix); - _delegate->SetRootTransform(_rootXform); - } - - _delegate->SetTime(UsdTimeCode::EarliestTime()); - - // In contrast with the other shape adapters, this adapter ignores the - // selection wireframe. The native instancer doesn't draw selection - // wireframes, so we want to mimic that behavior for consistency. - HdReprSelector reprSelector = - GetReprSelectorForDisplayState( - displayStyle, - displayStatus); - - _drawShape = reprSelector.AnyActiveRepr(); - - // We won't ever draw the bounding box here because the native Maya - // instancer already draws a bounding box, and we don't want to draw two. - // XXX: The native Maya instancer's bounding box will only cover the native - // geometry, though; is there any way to "teach" it about our bounds? - _drawBoundingBox = false; - - // If the repr selector specifies a wireframe-only repr, then disable - // lighting. - if (reprSelector.Contains(HdReprTokens->wire) || - reprSelector.Contains(HdReprTokens->refinedWire)) { - _renderParams.enableLighting = false; - } - - if (_delegate->GetRootVisibility() != _drawShape) { - _delegate->SetRootVisibility(_drawShape); - } - - if (_rprimCollection.GetReprSelector() != reprSelector) { - _rprimCollection.SetReprSelector(reprSelector); - - TF_DEBUG(PXRUSDMAYAGL_SHAPE_ADAPTER_LIFECYCLE).Msg( - " Repr selector changed: %s\n" - " Marking collection dirty: %s\n", - reprSelector.GetText(), - _rprimCollection.GetName().GetText()); - - _delegate->GetRenderIndex().GetChangeTracker().MarkCollectionDirty( - _rprimCollection.GetName()); - } - - // The kBackfaceCulling display style was introduced in Maya 2016 SP2. - HdCullStyle cullStyle = HdCullStyleNothing; -#if MAYA_API_VERSION >= 201603 - if (displayStyle & MHWRender::MFrameContext::DisplayStyle::kBackfaceCulling) { - cullStyle = HdCullStyleBackUnlessDoubleSided; - } -#endif - - _delegate->SetCullStyleFallback(cullStyle); - - return true; -} - -bool -UsdMayaGL_InstancerShapeAdapter::_Init(HdRenderIndex* renderIndex) -{ - if (!TF_VERIFY(renderIndex, - "Cannot initialize shape adapter with invalid HdRenderIndex")) { - return false; - } - - const SdfPath delegatePrefix = - UsdMayaGLBatchRenderer::GetInstance().GetDelegatePrefix(_isViewport2); - - // Create a simple "name" for this shape adapter to insert into the batch - // renderer's SdfPath hierarchy. - // - // XXX: For as long as we're using the MAYA_VP2_USE_VP1_SELECTION - // environment variable, we need to be able to pass responsibility back and - // forth between the MPxDrawOverride's shape adapter for drawing and the - // MPxSurfaceShapeUI's shape adapter for selection. This requires both - // shape adapters to have the same "name", which forces us to build it - // from data on the shape that will be common to both classes, as we do - // below. When we remove MAYA_VP2_USE_VP1_SELECTION and can trust that a - // single shape adapter handles both drawing and selection, we can do - // something even simpler instead like using the shape adapter's memory - // address as the "name". - size_t shapeHash(MObjectHandle(_shapeDagPath.transform()).hashCode()); - boost::hash_combine(shapeHash, _instancerStage->GetDefaultPrim()); - - // We prepend the Maya type name to the beginning of the delegate name to - // ensure that there are no name collisions between shape adapters of - // shapes with different Maya types. - const TfToken delegateName( - TfStringPrintf("%s_%zx", - _tokens->NativeInstancerType.GetText(), - shapeHash)); - - const SdfPath delegateId = delegatePrefix.AppendChild(delegateName); - - if (_delegate && - delegateId == GetDelegateID() && - renderIndex == &_delegate->GetRenderIndex()) { - // The delegate's current ID matches the delegate ID we computed and - // the render index matches, so it must be up to date already. - return true; - } - - const TfToken collectionName(_shapeDagPath.fullPathName().asChar()); - - TF_DEBUG(PXRUSDMAYAGL_SHAPE_ADAPTER_LIFECYCLE).Msg( - "Initializing UsdMayaGL_InstancerShapeAdapter: %p\n" - " collection name: %s\n" - " delegateId : %s\n", - this, - collectionName.GetText(), - delegateId.GetText()); - - _delegate.reset(new UsdImagingDelegate(renderIndex, delegateId)); - if (!TF_VERIFY(_delegate, - "Failed to create shape adapter delegate for shape %s", - _shapeDagPath.fullPathName().asChar())) { - return false; - } - - UsdPrim usdPrim = _instancerStage->GetDefaultPrim(); - _delegate->Populate(usdPrim, SdfPathVector()); - - if (collectionName != _rprimCollection.GetName()) { - _rprimCollection.SetName(collectionName); - renderIndex->GetChangeTracker().AddCollection( - _rprimCollection.GetName()); - } - - _rprimCollection.SetReprSelector(HdReprSelector(HdReprTokens->refined)); - _rprimCollection.SetRootPath(delegateId); - - return true; -} - -UsdMayaGL_InstancerShapeAdapter::UsdMayaGL_InstancerShapeAdapter() -{ - TF_DEBUG(PXRUSDMAYAGL_SHAPE_ADAPTER_LIFECYCLE).Msg( - "Constructing UsdMayaGL_InstancerShapeAdapter: %p\n", - this); - - // Set up bare-bones instancer stage. - // Populate the required properties for the instancer. - _instancerStage = UsdStage::CreateInMemory(); - const SdfPath instancerPath = - SdfPath::AbsoluteRootPath().AppendChild(_tokens->Instancer); - const SdfPath prototypesPath = - instancerPath.AppendChild(_tokens->Prototypes); - const SdfPath emptyPrimPath = - instancerPath.AppendChild(_tokens->EmptyPrim); - const UsdGeomPointInstancer instancer = - UsdGeomPointInstancer::Define(_instancerStage, instancerPath); - const UsdPrim prototypesGroupPrim = - _instancerStage->DefinePrim(prototypesPath); - const UsdPrim emptyPrim = - _instancerStage->DefinePrim(emptyPrimPath); - instancer.CreatePrototypesRel().AddTarget(emptyPrimPath); - instancer.CreateProtoIndicesAttr().Set(VtIntArray()); - instancer.CreatePositionsAttr().Set(VtVec3fArray()); - instancer.CreateOrientationsAttr().Set(VtQuathArray()); - instancer.CreateScalesAttr().Set(VtVec3fArray()); - UsdModelAPI(instancer).SetKind(KindTokens->assembly); - UsdModelAPI(prototypesGroupPrim).SetKind(KindTokens->group); - _instancerStage->SetDefaultPrim(instancer.GetPrim()); -} - -/* virtual */ -UsdMayaGL_InstancerShapeAdapter::~UsdMayaGL_InstancerShapeAdapter() -{ - TF_DEBUG(PXRUSDMAYAGL_SHAPE_ADAPTER_LIFECYCLE).Msg( - "Destructing UsdMayaGL_InstancerShapeAdapter: %p\n", - this); -} - - -PXR_NAMESPACE_CLOSE_SCOPE diff --git a/plugin/pxr/maya/lib/pxrUsdMayaGL/instancerShapeAdapter.h b/plugin/pxr/maya/lib/pxrUsdMayaGL/instancerShapeAdapter.h deleted file mode 100644 index 1d8f45ef30..0000000000 --- a/plugin/pxr/maya/lib/pxrUsdMayaGL/instancerShapeAdapter.h +++ /dev/null @@ -1,140 +0,0 @@ -// -// Copyright 2018 Pixar -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef PXRUSDMAYAGL_INSTANCER_SHAPE_ADAPTER_H -#define PXRUSDMAYAGL_INSTANCER_SHAPE_ADAPTER_H - -/// \file pxrUsdMayaGL/instancerShapeAdapter.h - -#include "pxrUsdMayaGL/api.h" -#include "pxrUsdMayaGL/shapeAdapter.h" - -#include "pxr/base/gf/matrix4d.h" -#include "pxr/imaging/hd/renderIndex.h" -#include "pxr/usd/sdf/path.h" -#include "pxr/usd/usd/prim.h" -#include "pxr/usdImaging/usdImaging/delegate.h" - -#include - -#include - - -PXR_NAMESPACE_OPEN_SCOPE - - -/// Class to manage translation of native Maya instancers into -/// UsdGeomPointInstancers for imaging with Hydra. -/// This adapter will translate instancer prototypes that are USD reference -/// assemblies into UsdGeomPointInstancer prototypes, ignoring any prototypes -/// that are not reference assemblies. -class UsdMayaGL_InstancerShapeAdapter : public PxrMayaHdShapeAdapter -{ - public: - - /// Update the shape adapter's visibility state from the display status - /// of its shape. - /// - /// When a Maya shape is made invisible, it may no longer be included - /// in the "prepare" phase of a viewport render (i.e. we get no - /// getDrawRequests() or prepareForDraw() callbacks for that shape). - /// This method can be called on demand to ensure that the shape - /// adapter is updated with the current visibility state of the shape. - /// - /// The optional \p view parameter can be passed to have view-based - /// state such as view and/or plugin object filtering factor into the - /// shape's visibility. - /// - /// Returns true if the visibility state was changed, or false - /// otherwise. - bool UpdateVisibility(const M3dView* view = nullptr) override; - - /// Gets whether the shape adapter's shape is visible. - /// - /// This should be called after a call to UpdateVisibility() to ensure - /// that the returned value is correct. - bool IsVisible() const override; - - void SetRootXform(const GfMatrix4d& transform) override; - - const SdfPath& GetDelegateID() const override; - - ~UsdMayaGL_InstancerShapeAdapter() override; - - protected: - - /// Update the shape adapter's state from the shape with the given - /// \p dagPath and display state. - /// - /// This method should be called by both public versions of Sync() and - /// should perform shape data updates that are common to both the - /// legacy viewport and Viewport 2.0. The legacy viewport Sync() method - /// "promotes" the display state parameters to their Viewport 2.0 - /// equivalents before calling this method. - bool _Sync( - const MDagPath& shapeDagPath, - const unsigned int displayStyle, - const MHWRender::DisplayStatus displayStatus) override; - - /// Construct a new uninitialized UsdMayaGL_InstancerShapeAdapter. - /// - /// Note that only friends of this class are able to construct - /// instances of this class. - UsdMayaGL_InstancerShapeAdapter(); - - private: - - /// Initialize the shape adapter using the given \p renderIndex. - /// - /// This method is called automatically during Sync() when the shape - /// adapter's "identity" changes. This happens when the delegateId or - /// the rprim collection name computed from the shape adapter's shape - /// is different than what is currently stored in the shape adapter. - /// The shape adapter will then query the batch renderer for its render - /// index and use that to re-create its delegate and re-add its rprim - /// collection, if necessary. - bool _Init(HdRenderIndex* renderIndex); - - /// Updates the prototypes prims and the corresponding prototypes rel on - /// the point instancer. Errored or untranslatable prototypes are left - /// as empty prims in the prototype order. Returns the total number of - /// prototypes (including errored or untranslatable prototypes). - size_t _SyncInstancerPrototypes( - const UsdGeomPointInstancer& usdInstancer, - const MPlug& inputHierarchy); - - /// Updates all of the attributes on the \p usdInstancer from the native - /// Maya instancer given by \p mayaInstancerPath. - /// If there was a problem reading prototypes or there are no - /// prototypes, then the whole instancer will be emptied out. - void _SyncInstancer( - const UsdGeomPointInstancer& usdInstancer, - const MDagPath& mayaInstancerPath); - - UsdStageRefPtr _instancerStage; - - std::shared_ptr _delegate; - - /// The classes that maintain ownership of and are responsible for - /// updating the shape adapter for their shape are made friends of - /// UsdMayaGL_InstancerShapeAdapter so that they alone can set - /// properties on the shape adapter. - friend class UsdMayaGL_InstancerImager; -}; - - -PXR_NAMESPACE_CLOSE_SCOPE - -#endif diff --git a/plugin/pxr/maya/lib/usdMaya/CMakeLists.txt b/plugin/pxr/maya/lib/usdMaya/CMakeLists.txt index 0e67e993e0..b7f30f7394 100644 --- a/plugin/pxr/maya/lib/usdMaya/CMakeLists.txt +++ b/plugin/pxr/maya/lib/usdMaya/CMakeLists.txt @@ -49,6 +49,7 @@ pxr_shared_library(${PXR_PACKAGE} PRIVATE_CLASSES readJobWithSceneAssembly + instancerShapeAdapterWithSceneAssembly CPPFILES readJob_ImportWithProxies.cpp diff --git a/plugin/pxr/maya/lib/usdMaya/importTranslator.cpp b/plugin/pxr/maya/lib/usdMaya/importTranslator.cpp index a288125eef..1705f2b72b 100644 --- a/plugin/pxr/maya/lib/usdMaya/importTranslator.cpp +++ b/plugin/pxr/maya/lib/usdMaya/importTranslator.cpp @@ -111,13 +111,10 @@ UsdMayaImportTranslator::reader( userArgs, /* importWithProxyShapes = */ false, timeInterval); - UsdMaya_ReadJobWithSceneAssembly* mUsdReadJob = - new UsdMaya_ReadJobWithSceneAssembly(fileName, - primPath, - variants, - jobArgs); + UsdMaya_ReadJobWithSceneAssembly mUsdReadJob( + fileName, primPath, variants, jobArgs); std::vector addedDagPaths; - bool success = mUsdReadJob->Read(&addedDagPaths); + bool success = mUsdReadJob.Read(&addedDagPaths); return (success) ? MS::kSuccess : MS::kFailure; } diff --git a/plugin/pxr/maya/lib/usdMaya/instancerShapeAdapterWithSceneAssembly.cpp b/plugin/pxr/maya/lib/usdMaya/instancerShapeAdapterWithSceneAssembly.cpp new file mode 100644 index 0000000000..b00e0244bc --- /dev/null +++ b/plugin/pxr/maya/lib/usdMaya/instancerShapeAdapterWithSceneAssembly.cpp @@ -0,0 +1,135 @@ +// +// Copyright 2018 Pixar +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "usdMaya/instancerShapeAdapterWithSceneAssembly.h" + +#include +#include + +#include "usdMaya/referenceAssembly.h" + +#include +#include + +PXR_NAMESPACE_OPEN_SCOPE + +UsdMayaGL_InstancerShapeAdapterWithSceneAssembly::UsdMayaGL_InstancerShapeAdapterWithSceneAssembly() +{ + TF_DEBUG(PXRUSDMAYAGL_SHAPE_ADAPTER_LIFECYCLE).Msg( + "Constructing UsdMayaGL_InstancerShapeAdapterWithSceneAssembly: %p\n", + this); +} + +/* virtual */ +UsdMayaGL_InstancerShapeAdapterWithSceneAssembly::~UsdMayaGL_InstancerShapeAdapterWithSceneAssembly() +{ + TF_DEBUG(PXRUSDMAYAGL_SHAPE_ADAPTER_LIFECYCLE).Msg( + "Destructing UsdMayaGL_InstancerShapeAdapterWithSceneAssembly: %p\n", + this); +} + +/* virtual */ +void UsdMayaGL_InstancerShapeAdapterWithSceneAssembly::SyncInstancerPerPrototypePostHook( + const MPlug& hierarchyPlug, + UsdPrim& prototypePrim, + std::vector& layerIdsToMute +) +{ + UsdReferences prototypeRefs = prototypePrim.GetReferences(); + prototypeRefs.ClearReferences(); + + // Collect data about what prototype this is. + MPlug source = UsdMayaUtil::GetConnected(hierarchyPlug); + if (source.isNull()) { + return; + } + + MStatus status; + MFnDependencyNode sourceNode(source.node(), &status); + if (!status) { + return; + } + + // If this is a non-full-representation USD reference assembly, add a + // reference. Otherwise, leave the prim empty. + if (sourceNode.typeId() != UsdMayaReferenceAssembly::typeId) { + return; + } + + UsdMayaReferenceAssembly* usdRefAssem = + dynamic_cast( + sourceNode.userNode()); + if (!usdRefAssem) { + return; + } + + if (usdRefAssem->getActive() == + UsdMayaRepresentationFull::_assemblyType) { + return; + } + + UsdPrim prim = usdRefAssem->usdPrim(); + if (!prim) { + return; + } + + // Add main reference data. + const std::string& layerId = + prim.GetStage()->GetRootLayer()->GetIdentifier(); + const SdfPath primPath = prim.GetPath(); + prototypeRefs.AddReference(SdfReference(layerId, primPath)); + + // Reference session data. + // We also mute any sublayers of the session layer, because those + // correspond to assembly edits generated by UsdMayaReferenceAssembly, + // and UsdMayaReferenceAssembly won't give us the assembly edits + // consistently between different representations. + // (Most session layers won't have sublayers; they only show up when + // there's assembly edits in Collapsed/Expanded representations.) + // XXX Handle assembly edits on instancer prototypes? + if (SdfLayerHandle sessionLayer = prim.GetStage()->GetSessionLayer()) { + if (sessionLayer->GetPrimAtPath(primPath)) { + prototypeRefs.AddReference( + SdfReference(sessionLayer->GetIdentifier(), primPath), + UsdListPositionFrontOfPrependList); + const SdfSubLayerProxy subLayers = + sessionLayer->GetSubLayerPaths(); + layerIdsToMute.insert( + layerIdsToMute.end(), + subLayers.begin(), + subLayers.end()); + } + } + + // Also handles instancerTranslate. + // These are all in "physical", not "logical" indices. + auto holder = UsdMayaUtil::GetPlugDataHandle(hierarchyPlug); + MMatrix mMat = MFnMatrixData(holder->GetDataHandle().data()).matrix(); + GfMatrix4d gfMat(mMat.matrix); + + MPlug translatePlug = sourceNode.findPlug("translate", &status); + if (status) { + // OK if we didn't find plug, assume instancerTranslate is zero. + GfVec3d tr(translatePlug.child(0).asDouble(), + translatePlug.child(1).asDouble(), + translatePlug.child(2).asDouble()); + gfMat = gfMat * GfMatrix4d().SetTranslate(-tr); + } + + UsdGeomXformable xformable(prototypePrim); + xformable.MakeMatrixXform().Set(gfMat); +} + +PXR_NAMESPACE_CLOSE_SCOPE diff --git a/plugin/pxr/maya/lib/usdMaya/instancerShapeAdapterWithSceneAssembly.h b/plugin/pxr/maya/lib/usdMaya/instancerShapeAdapterWithSceneAssembly.h new file mode 100644 index 0000000000..dfb4427ed6 --- /dev/null +++ b/plugin/pxr/maya/lib/usdMaya/instancerShapeAdapterWithSceneAssembly.h @@ -0,0 +1,52 @@ +// +// Copyright 2018 Pixar +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#ifndef PXRUSDMAYAGL_INSTANCER_SHAPE_ADAPTER_WITH_SCENE_ASSEMBLY_H +#define PXRUSDMAYAGL_INSTANCER_SHAPE_ADAPTER_WITH_SCENE_ASSEMBLY_H + +/// \file pxrUsdMayaGL/instancerShapeAdapter.h + +#include + +PXR_NAMESPACE_OPEN_SCOPE + +/// Class to manage translation of native Maya instancers into +/// UsdGeomPointInstancers for imaging with Hydra. +/// This adapter will translate instancer prototypes that are USD reference +/// assemblies into UsdGeomPointInstancer prototypes, ignoring any prototypes +/// that are not reference assemblies. +class UsdMayaGL_InstancerShapeAdapterWithSceneAssembly : public UsdMayaGL_InstancerShapeAdapter +{ + public: + + ~UsdMayaGL_InstancerShapeAdapterWithSceneAssembly() override; + + /// Construct a new uninitialized UsdMayaGL_InstancerShapeAdapterWithSceneAssembly. + UsdMayaGL_InstancerShapeAdapterWithSceneAssembly(); + + private: + + // For each prototype in _SyncInstancerPrototypes(), perform scene + // assembly node processing. + void SyncInstancerPerPrototypePostHook( + const MPlug& hierarchyPlug, + UsdPrim& prototypePrim, + std::vector& layerIdsToMute + ) override; +}; + +PXR_NAMESPACE_CLOSE_SCOPE + +#endif diff --git a/plugin/pxr/maya/lib/usdMaya/proxyShape.cpp b/plugin/pxr/maya/lib/usdMaya/proxyShape.cpp index 57f110321f..704fb96bf2 100644 --- a/plugin/pxr/maya/lib/usdMaya/proxyShape.cpp +++ b/plugin/pxr/maya/lib/usdMaya/proxyShape.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "pxr/base/gf/bbox3d.h" #include "pxr/base/gf/range3d.h" @@ -322,5 +323,21 @@ void UsdMayaProxyShape::postConstructor() } } +/// Delegate for returning whether object soft-select mode is currently on +/// Technically, we could make ProxyShape track this itself, but then that would +/// be making two callbacks to track the same thing... so we use BatchRenderer +/// implementation +bool +UsdMayaGL_ObjectSoftSelectEnabled() +{ + return UsdMayaGLBatchRenderer::GetInstance().GetObjectSoftSelectEnabled(); +} + + +TF_REGISTRY_FUNCTION(UsdMayaProxyShape) +{ + UsdMayaProxyShape::SetObjectSoftSelectEnabledDelegate( + UsdMayaGL_ObjectSoftSelectEnabled); +} PXR_NAMESPACE_CLOSE_SCOPE diff --git a/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.cpp b/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.cpp index 65c9dec728..fc1f3f54a6 100644 --- a/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.cpp +++ b/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.cpp @@ -13,11 +13,19 @@ // See the License for the specific language governing permissions and // limitations under the License. // +#include + #include "usdMaya/readJobWithSceneAssembly.h" #include "usdMaya/translatorModelAssembly.h" PXR_NAMESPACE_OPEN_SCOPE +// For now, we hard code this to use displayColor. But maybe the more +// appropriate thing to do is just to leave shadingMode alone and pass +// "displayColor" in from the UsdMayaRepresentationFull +// (usdMaya/referenceAssembly.cpp) +const static TfToken ASSEMBLY_SHADING_MODE = UsdMayaShadingModeTokens->displayColor; + UsdMaya_ReadJobWithSceneAssembly::UsdMaya_ReadJobWithSceneAssembly( const std::string &iFileName, const std::string &iPrimPath, @@ -90,4 +98,20 @@ bool UsdMaya_ReadJobWithSceneAssembly::OverridePrimReader( return false; } +void UsdMaya_ReadJobWithSceneAssembly::PreImport() +{ + const bool isSceneAssembly = mMayaRootDagPath.node().hasFn(MFn::kAssembly); + if (isSceneAssembly) { + mArgs.shadingMode = ASSEMBLY_SHADING_MODE; + } +} + +bool UsdMaya_ReadJobWithSceneAssembly::SkipRootPrim(bool isImportingPseudoRoot) +{ + // Skip the root prim if it is the pseudoroot, or if we are importing + // on behalf of a scene assembly. + return isImportingPseudoRoot || + mMayaRootDagPath.node().hasFn(MFn::kAssembly); +} + PXR_NAMESPACE_CLOSE_SCOPE diff --git a/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.h b/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.h index 99bb350132..91ef54a77c 100644 --- a/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.h +++ b/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.h @@ -44,6 +44,11 @@ class UsdMaya_ReadJobWithSceneAssembly : public UsdMaya_ReadJob UsdPrimRange::iterator& primIt ) override; + // Hook to set the shading mode if dealing with scene assembly. + void PreImport() override; + + bool SkipRootPrim(bool isImportingPseudoRoot) override; + // XXX: Activating the 'Expanded' representation of a USD reference assembly // node is very much like performing a regular UsdMaya_ReadJob but with // a few key differences (e.g. creating proxy shapes at collapse points). diff --git a/plugin/pxr/maya/lib/usdMaya/referenceAssembly.cpp b/plugin/pxr/maya/lib/usdMaya/referenceAssembly.cpp index ea3d83d3c4..8029c8c4a1 100644 --- a/plugin/pxr/maya/lib/usdMaya/referenceAssembly.cpp +++ b/plugin/pxr/maya/lib/usdMaya/referenceAssembly.cpp @@ -23,6 +23,8 @@ #include "usdMaya/readJobWithSceneAssembly.h" #include #include +#include +#include "usdMaya/instancerShapeAdapterWithSceneAssembly.h" #include "pxr/base/tf/fileUtils.h" #include "pxr/base/tf/registryManager.h" @@ -1544,5 +1546,28 @@ const MString UsdMayaRepresentationExpanded::_assemblyType("Expanded"); const MString UsdMayaRepresentationFull::_assemblyType("Full"); -PXR_NAMESPACE_CLOSE_SCOPE +bool UsdMayaGL_InstancerImager_ContinueTrackingOnDisconnect( + const MFnDependencyNode& fn +) +{ + // There's at least one USD reference assembly still connected to + // this point instancer, so continue tracking the instancer node. + return (fn.typeId() == UsdMayaReferenceAssembly::typeId); +} + +UsdMayaGL_InstancerShapeAdapter* +UsdMayaGL_InstancerImager_InstancerShapeAdapterFactory() +{ + return new UsdMayaGL_InstancerShapeAdapterWithSceneAssembly(); +} +TF_REGISTRY_FUNCTION(UsdMayaReferenceAssembly) +{ + TfSingleton::GetInstance(); + UsdMayaGL_InstancerImager::SetContinueTrackingOnDisconnectDelegate( + UsdMayaGL_InstancerImager_ContinueTrackingOnDisconnect); + UsdMayaGL_InstancerImager::SetInstancerShapeAdapterFactory( + UsdMayaGL_InstancerImager_InstancerShapeAdapterFactory); +} + +PXR_NAMESPACE_CLOSE_SCOPE From a377b148780b0706ed985fd76f81964c8feff4aa Mon Sep 17 00:00:00 2001 From: Krystian Ligenza Date: Tue, 13 Aug 2019 14:32:23 -0400 Subject: [PATCH 21/22] Fix windows build. Missing exports. (#102) --- lib/render/pxrUsdMayaGL/instancerImager.h | 3 +++ lib/render/pxrUsdMayaGL/instancerShapeAdapter.h | 9 ++++++++- plugin/pxr/maya/lib/usdMaya/referenceAssembly.cpp | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/render/pxrUsdMayaGL/instancerImager.h b/lib/render/pxrUsdMayaGL/instancerImager.h index 7aa9d59ec0..67e6653e69 100644 --- a/lib/render/pxrUsdMayaGL/instancerImager.h +++ b/lib/render/pxrUsdMayaGL/instancerImager.h @@ -45,6 +45,7 @@ PXR_NAMESPACE_OPEN_SCOPE /// gets drawn by the draw override. class UsdMayaGL_InstancerImager : public TfWeakBase { public: + MAYAUSD_CORE_PUBLIC static UsdMayaGL_InstancerImager& GetInstance(); /// Sync all dirty instancer shape adapters for Viewport 2.0. @@ -67,6 +68,7 @@ class UsdMayaGL_InstancerImager : public TfWeakBase { /// instancer node on disconnect. typedef std::function ContinueTrackingOnDisconnectDelegate; + MAYAUSD_CORE_PUBLIC static void SetContinueTrackingOnDisconnectDelegate( ContinueTrackingOnDisconnectDelegate delegate); @@ -74,6 +76,7 @@ class UsdMayaGL_InstancerImager : public TfWeakBase { typedef std::function InstancerShapeAdapterFactory; /// Set the factory function for creating instancer shape adapters. + MAYAUSD_CORE_PUBLIC static void SetInstancerShapeAdapterFactory( InstancerShapeAdapterFactory factory); diff --git a/lib/render/pxrUsdMayaGL/instancerShapeAdapter.h b/lib/render/pxrUsdMayaGL/instancerShapeAdapter.h index 1154b2fa71..3c09b9ae2b 100644 --- a/lib/render/pxrUsdMayaGL/instancerShapeAdapter.h +++ b/lib/render/pxrUsdMayaGL/instancerShapeAdapter.h @@ -59,19 +59,24 @@ class UsdMayaGL_InstancerShapeAdapter : public PxrMayaHdShapeAdapter /// /// Returns true if the visibility state was changed, or false /// otherwise. + MAYAUSD_CORE_PUBLIC bool UpdateVisibility(const M3dView* view = nullptr) override; /// Gets whether the shape adapter's shape is visible. /// /// This should be called after a call to UpdateVisibility() to ensure /// that the returned value is correct. + MAYAUSD_CORE_PUBLIC bool IsVisible() const override; + MAYAUSD_CORE_PUBLIC void SetRootXform(const GfMatrix4d& transform) override; + MAYAUSD_CORE_PUBLIC const SdfPath& GetDelegateID() const override; - ~UsdMayaGL_InstancerShapeAdapter() override; + MAYAUSD_CORE_PUBLIC + ~UsdMayaGL_InstancerShapeAdapter() override; protected: @@ -83,6 +88,7 @@ class UsdMayaGL_InstancerShapeAdapter : public PxrMayaHdShapeAdapter /// legacy viewport and Viewport 2.0. The legacy viewport Sync() method /// "promotes" the display state parameters to their Viewport 2.0 /// equivalents before calling this method. + MAYAUSD_CORE_PUBLIC bool _Sync( const MDagPath& shapeDagPath, const unsigned int displayStyle, @@ -92,6 +98,7 @@ class UsdMayaGL_InstancerShapeAdapter : public PxrMayaHdShapeAdapter /// /// Note that only friends of this class are able to construct /// instances of this class. + MAYAUSD_CORE_PUBLIC UsdMayaGL_InstancerShapeAdapter(); // Derived class hook to allow derived classes to augment diff --git a/plugin/pxr/maya/lib/usdMaya/referenceAssembly.cpp b/plugin/pxr/maya/lib/usdMaya/referenceAssembly.cpp index 8029c8c4a1..e89b70ed1c 100644 --- a/plugin/pxr/maya/lib/usdMaya/referenceAssembly.cpp +++ b/plugin/pxr/maya/lib/usdMaya/referenceAssembly.cpp @@ -1563,7 +1563,7 @@ UsdMayaGL_InstancerImager_InstancerShapeAdapterFactory() TF_REGISTRY_FUNCTION(UsdMayaReferenceAssembly) { - TfSingleton::GetInstance(); + UsdMayaGL_InstancerImager::GetInstance(); UsdMayaGL_InstancerImager::SetContinueTrackingOnDisconnectDelegate( UsdMayaGL_InstancerImager_ContinueTrackingOnDisconnect); UsdMayaGL_InstancerImager::SetInstancerShapeAdapterFactory( From da9b60319700636aae77a3e24b2727e643a6b392 Mon Sep 17 00:00:00 2001 From: Pierre Tremblay Date: Tue, 13 Aug 2019 14:15:20 -0700 Subject: [PATCH 22/22] mayaUsd translator import / export MEL scripts. (#101) * mayaUsd translator import / export MEL scripts. * Addressed code review feedback. --- plugin/adsk/CMakeLists.txt | 1 + plugin/adsk/plugin/plugin.cpp | 2 +- plugin/adsk/scripts/CMakeLists.txt | 8 +++ .../adsk/scripts/mayaUsdTranslatorExport.mel | 60 +++++++++++++++++++ .../adsk/scripts/mayaUsdTranslatorImport.mel | 60 +++++++++++++++++++ 5 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 plugin/adsk/scripts/CMakeLists.txt create mode 100644 plugin/adsk/scripts/mayaUsdTranslatorExport.mel create mode 100644 plugin/adsk/scripts/mayaUsdTranslatorImport.mel diff --git a/plugin/adsk/CMakeLists.txt b/plugin/adsk/CMakeLists.txt index 16b7740cf4..e5ddf229bb 100644 --- a/plugin/adsk/CMakeLists.txt +++ b/plugin/adsk/CMakeLists.txt @@ -11,3 +11,4 @@ find_package(USD REQUIRED) include(${USD_CONFIG_FILE}) add_subdirectory(plugin) +add_subdirectory(scripts) diff --git a/plugin/adsk/plugin/plugin.cpp b/plugin/adsk/plugin/plugin.cpp index 836cf978dd..15770e7406 100644 --- a/plugin/adsk/plugin/plugin.cpp +++ b/plugin/adsk/plugin/plugin.cpp @@ -42,7 +42,7 @@ MStatus initializePlugin(MObject obj) "mayaUsdImport", "", UsdMayaImportTranslator::creator, - "usdTranslatorImport", // options script name + "mayaUsdTranslatorImport", // options script name const_cast(UsdMayaImportTranslator::GetDefaultOptions().c_str()), false); if (!status) { diff --git a/plugin/adsk/scripts/CMakeLists.txt b/plugin/adsk/scripts/CMakeLists.txt new file mode 100644 index 0000000000..6a3007ef00 --- /dev/null +++ b/plugin/adsk/scripts/CMakeLists.txt @@ -0,0 +1,8 @@ +list(APPEND scripts_src + mayaUsdTranslatorImport.mel + mayaUsdTranslatorExport.mel +) + +install(FILES ${scripts_src} + DESTINATION ${INSTALL_DIR_SUFFIX}/scripts +) diff --git a/plugin/adsk/scripts/mayaUsdTranslatorExport.mel b/plugin/adsk/scripts/mayaUsdTranslatorExport.mel new file mode 100644 index 0000000000..6fa6458ffa --- /dev/null +++ b/plugin/adsk/scripts/mayaUsdTranslatorExport.mel @@ -0,0 +1,60 @@ +// Copyright 2019 Autodesk +// +// Copyright 2019 Pixar +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +global proc int mayaUsdTranslatorExport (string $parent, + string $action, + string $initialSettings, + string $resultCallback ) +// +// Description: +// This script posts the mayaUsd export file translator options. +// The optionsString is of the form: +// varName1=value1;varName2=value2;... +// +// Parameters: +// $parent - the elf parent layout for this options layout. It is +// always a scrollLayout. +// $action - the action that is to be performed with this invocation of this proc. +// Valid options are: +// "query" - construct the options string and pass it to the resultCallback. +// "post" - post all the elf controls. +// $initialSettings - the current options string in effect at the time this script is invoked. +// $resultCallback - This is the proc to be called with the result string. +// resultCallback ( string $optionsString ) +// +// Returns: +// 1 if successful. +// 0 otherwise. +// +{ + int $bResult = 1; + + if ($action == "post") { + setParent $parent; + + text -label "Maya USD export options to be determined."; + } else if ($action == "query") { + string $currentOptions = ""; + + eval($resultCallback+" \""+$currentOptions+"\""); + + } else { + $bResult = 0; + } + + return $bResult; +} diff --git a/plugin/adsk/scripts/mayaUsdTranslatorImport.mel b/plugin/adsk/scripts/mayaUsdTranslatorImport.mel new file mode 100644 index 0000000000..a79eebd94c --- /dev/null +++ b/plugin/adsk/scripts/mayaUsdTranslatorImport.mel @@ -0,0 +1,60 @@ +// Copyright 2019 Autodesk +// +// Copyright 2019 Pixar +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +global proc int mayaUsdTranslatorImport (string $parent, + string $action, + string $initialSettings, + string $resultCallback ) +// +// Description: +// This script posts the mayaUsd import file translator options. +// The optionsString is of the form: +// varName1=value1;varName2=value2;... +// +// Parameters: +// $parent - the elf parent layout for this options layout. It is +// always a scrollLayout. +// $action - the action that is to be performed with this invocation of this proc. +// Valid options are: +// "query" - construct the options string and pass it to the resultCallback. +// "post" - post all the elf controls. +// $initialSettings - the current options string in effect at the time this script is invoked. +// $resultCallback - This is the proc to be called with the result string. +// resultCallback ( string $optionsString ) +// +// Returns: +// 1 if successful. +// 0 otherwise. +// +{ + int $bResult = 1; + + if ($action == "post") { + setParent $parent; + + text -label "Maya USD import options to be determined."; + } else if ($action == "query") { + string $currentOptions = ""; + + eval($resultCallback+" \""+$currentOptions+"\""); + + } else { + $bResult = 0; + } + + return $bResult; +}