Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAYA-106529 - MayaUSD: Cleanup old UFE conditionals #746

Merged
merged 4 commits into from
Aug 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions lib/mayaUsd/ufe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,18 @@ target_sources(${PROJECT_NAME}
if(CMAKE_UFE_V2_FEATURES_AVAILABLE)
target_sources(${PROJECT_NAME}
PRIVATE
ProxyShapeContextOpsHandler.cpp
UsdAttribute.cpp
UsdAttributes.cpp
UsdAttributesHandler.cpp
UsdContextOps.cpp
UsdContextOpsHandler.cpp
UsdObject3d.cpp
UsdObject3dHandler.cpp
UsdUndoAddNewPrimCommand.cpp
UsdUndoCreateGroupCommand.cpp
UsdUndoInsertChildCommand.cpp
)
if(UFE_PREVIEW_VERSION_NUM GREATER_EQUAL 2009)
target_sources(${PROJECT_NAME}
PRIVATE
UsdContextOps.cpp
UsdContextOpsHandler.cpp
)
endif()
if(UFE_PREVIEW_VERSION_NUM GREATER_EQUAL 2015)
target_sources(${PROJECT_NAME}
PRIVATE
ProxyShapeContextOpsHandler.cpp
)
endif()
endif()

set(HEADERS
Expand Down
18 changes: 3 additions & 15 deletions lib/mayaUsd/ufe/Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,9 @@
// Note: must come after include of ufe files so we have the define.
#include <mayaUsd/ufe/UsdAttributesHandler.h>
#include <mayaUsd/ufe/UsdObject3dHandler.h>
#if UFE_PREVIEW_VERSION_NUM >= 2009
#include <mayaUsd/ufe/UsdContextOpsHandler.h>
#endif
#if UFE_PREVIEW_VERSION_NUM >= 2015
#include <mayaUsd/ufe/ProxyShapeContextOpsHandler.h>
#endif
#if UFE_PREVIEW_VERSION_NUM >= 2011
#include <ufe/pathString.h>
ppt-adsk marked this conversation as resolved.
Show resolved Hide resolved
#endif
#else
#include <mayaUsd/ufe/UfeVersionCompat.h>
#endif
Expand Down Expand Up @@ -73,7 +67,7 @@ Ufe::Rtid g_USDRtid = 0;
// Keep a reference to it to restore on finalization.
Ufe::HierarchyHandler::Ptr g_MayaHierarchyHandler;

#if UFE_PREVIEW_VERSION_NUM >= 2015
#ifdef UFE_V2_FEATURES_AVAILABLE
// The normal Maya context ops handler, which we decorate for ProxyShape support.
// Keep a reference to it to restore on finalization.
Ufe::ContextOpsHandler::Ptr g_MayaContextOpsHandler;
Expand Down Expand Up @@ -109,7 +103,7 @@ MStatus initialize()
auto proxyShapeHierHandler = ProxyShapeHierarchyHandler::create(g_MayaHierarchyHandler);
Ufe::RunTimeMgr::instance().setHierarchyHandler(g_MayaRtid, proxyShapeHierHandler);

#if UFE_PREVIEW_VERSION_NUM >= 2015
#ifdef UFE_V2_FEATURES_AVAILABLE
g_MayaContextOpsHandler = Ufe::RunTimeMgr::instance().contextOpsHandler(g_MayaRtid);
auto proxyShapeContextOpsHandler = ProxyShapeContextOpsHandler::create(g_MayaContextOpsHandler);
Ufe::RunTimeMgr::instance().setContextOpsHandler(g_MayaRtid, proxyShapeContextOpsHandler);
Expand All @@ -120,16 +114,12 @@ MStatus initialize()
auto usdSceneItemOpsHandler = UsdSceneItemOpsHandler::create();
UFE_V2(auto usdAttributesHandler = UsdAttributesHandler::create();)
UFE_V2(auto usdObject3dHandler = UsdObject3dHandler::create();)
#if UFE_PREVIEW_VERSION_NUM >= 2009
UFE_V2(auto usdContextOpsHandler = UsdContextOpsHandler::create();)
#endif
g_USDRtid = Ufe::RunTimeMgr::instance().register_(
kUSDRunTimeName, usdHierHandler, usdTrans3dHandler,
usdSceneItemOpsHandler
UFE_V2(, usdAttributesHandler, usdObject3dHandler)
#if UFE_PREVIEW_VERSION_NUM >= 2009
UFE_V2(, usdContextOpsHandler)
#endif
);

#if !defined(NDEBUG)
Expand All @@ -141,9 +131,7 @@ MStatus initialize()
g_StagesSubject = StagesSubject::create();

// Register for UFE string to path service using path component separator '/'
#if UFE_PREVIEW_VERSION_NUM >= 2011
UFE_V2(Ufe::PathString::registerPathComponentSeparator(g_USDRtid, '/');)
#endif

return MS::kSuccess;
}
Expand All @@ -156,7 +144,7 @@ MStatus finalize()

// Restore the normal Maya hierarchy handler, and unregister.
Ufe::RunTimeMgr::instance().setHierarchyHandler(g_MayaRtid, g_MayaHierarchyHandler);
#if UFE_PREVIEW_VERSION_NUM >= 2015
#ifdef UFE_V2_FEATURES_AVAILABLE
// Restore the normal Maya context ops handler (can be empty).
if (g_MayaContextOpsHandler)
Ufe::RunTimeMgr::instance().setContextOpsHandler(g_MayaRtid, g_MayaContextOpsHandler);
Expand Down
34 changes: 2 additions & 32 deletions lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,9 @@
#include <mayaUsd/ufe/Global.h>

#ifdef UFE_V2_FEATURES_AVAILABLE
#if UFE_PREVIEW_VERSION_NUM >= 2013
#include <mayaUsd/ufe/UsdUndoInsertChildCommand.h>
#endif

#if UFE_PREVIEW_VERSION_NUM >= 2017
#include <mayaUsd/ufe/UsdUndoCreateGroupCommand.h>
#endif
#endif

MAYAUSD_NS_DEF {
namespace ufe {
Expand Down Expand Up @@ -154,15 +149,15 @@ Ufe::SceneItem::Ptr ProxyShapeHierarchy::parent() const
return fMayaHierarchy->parent();
}

#if UFE_PREVIEW_VERSION_NUM < 2018
#ifndef UFE_V2_FEATURES_AVAILABLE
// UFE v1 specific method
Ufe::AppendedChild ProxyShapeHierarchy::appendChild(const Ufe::SceneItem::Ptr& child)
{
throw std::runtime_error("ProxyShapeHierarchy::appendChild() not implemented");
}
#endif

#ifdef UFE_V2_FEATURES_AVAILABLE
#if UFE_PREVIEW_VERSION_NUM >= 2013
Ufe::UndoableCommand::Ptr ProxyShapeHierarchy::insertChildCmd(
const Ufe::SceneItem::Ptr& child,
const Ufe::SceneItem::Ptr& pos
Expand All @@ -175,9 +170,6 @@ Ufe::UndoableCommand::Ptr ProxyShapeHierarchy::insertChildCmd(
return UsdUndoInsertChildCommand::create(
usdItem, downcast(child), downcast(pos));
}
#endif

#if UFE_PREVIEW_VERSION_NUM >= 2018

Ufe::SceneItem::Ptr ProxyShapeHierarchy::insertChild(
const Ufe::SceneItem::Ptr& ,
Expand All @@ -192,22 +184,6 @@ Ufe::SceneItem::Ptr ProxyShapeHierarchy::insertChild(
return nullptr;
}

#endif

#if UFE_PREVIEW_VERSION_NUM < 2017

Ufe::SceneItem::Ptr ProxyShapeHierarchy::createGroup(const Ufe::PathComponent& name) const
{
throw std::runtime_error("ProxyShapeHierarchy::createGroup() not implemented");
}

Ufe::Group ProxyShapeHierarchy::createGroupCmd(const Ufe::PathComponent& name) const
{
throw std::runtime_error("ProxyShapeHierarchy::createGroupCmd not implemented");
}

#else

Ufe::SceneItem::Ptr ProxyShapeHierarchy::createGroup(const Ufe::Selection& selection, const Ufe::PathComponent& name) const
{
Ufe::SceneItem::Ptr createdItem;
Expand All @@ -229,18 +205,12 @@ Ufe::UndoableCommand::Ptr ProxyShapeHierarchy::createGroupCmd(const Ufe::Selecti
return UsdUndoCreateGroupCommand::create(usdItem, selection, name.string());
}

#endif // UFE_PREVIEW_VERSION_NUM

#if UFE_PREVIEW_VERSION_NUM >= 2018

Ufe::SceneItem::Ptr ProxyShapeHierarchy::defaultParent() const
{
// Maya shape nodes cannot be unparented.
return nullptr;
}

#endif

#endif // UFE_V2_FEATURES_AVAILABLE

} // namespace ufe
Expand Down
11 changes: 1 addition & 10 deletions lib/mayaUsd/ufe/ProxyShapeHierarchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,25 @@ class MAYAUSD_CORE_PUBLIC ProxyShapeHierarchy : public Ufe::Hierarchy
bool hasChildren() const override;
Ufe::SceneItemList children() const override;
Ufe::SceneItem::Ptr parent() const override;
#if UFE_PREVIEW_VERSION_NUM < 2018
#ifndef UFE_V2_FEATURES_AVAILABLE
Ufe::AppendedChild appendChild(const Ufe::SceneItem::Ptr& child) override;
#endif

#ifdef UFE_V2_FEATURES_AVAILABLE
#if UFE_PREVIEW_VERSION_NUM >= 2013
Ufe::UndoableCommand::Ptr insertChildCmd(
const Ufe::SceneItem::Ptr& child,
const Ufe::SceneItem::Ptr& pos
) override;
#endif

#if UFE_PREVIEW_VERSION_NUM < 2017
Ufe::SceneItem::Ptr createGroup(const Ufe::PathComponent& name) const override;
Ufe::Group createGroupCmd(const Ufe::PathComponent& name) const override;
#else
Ufe::SceneItem::Ptr createGroup(const Ufe::Selection& selection, const Ufe::PathComponent& name) const override;
Ufe::UndoableCommand::Ptr createGroupCmd(const Ufe::Selection& selection, const Ufe::PathComponent& name) const override;
#endif

#if UFE_PREVIEW_VERSION_NUM >= 2018
Ufe::SceneItem::Ptr defaultParent() const override;
Ufe::SceneItem::Ptr insertChild(
const Ufe::SceneItem::Ptr& child,
const Ufe::SceneItem::Ptr& pos
) override;
#endif
#endif

private:
const UsdPrim& getUsdRootPrim() const;
Expand Down
14 changes: 4 additions & 10 deletions lib/mayaUsd/ufe/StagesSubject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
#include <ufe/transform3d.h>
#ifdef UFE_V2_FEATURES_AVAILABLE
#include <ufe/object3d.h>
#if UFE_PREVIEW_VERSION_NUM >= 2010
#include <ufe/object3dNotification.h>
#endif
#include <unordered_map>
#endif

Expand Down Expand Up @@ -234,18 +232,18 @@ void StagesSubject::stageChanged(UsdNotice::ObjectsChanged const& notice, UsdSta
Ufe::Scene::notifyObjectDelete(notification);
}
}
#ifdef UFE_V2_FEATURES_AVAILABLE
else
{
#if UFE_PREVIEW_VERSION_NUM >= 2014
// According to USD docs for GetResyncedPaths():
// - Resyncs imply entire subtree invalidation of all descendant prims and properties.
// So we send the UFE subtree invalidate notif.
auto notification = Ufe::SubtreeInvalidate(sceneItem);
Ufe::Scene::notifySubtreeInvalidate(notification);
#endif
}
#endif
ppt-adsk marked this conversation as resolved.
Show resolved Hide resolved
}
#if UFE_PREVIEW_VERSION_NUM >= 2015
#ifdef UFE_V2_FEATURES_AVAILABLE
ppt-adsk marked this conversation as resolved.
Show resolved Hide resolved
else if (!prim.IsValid() && !InPathChange::inPathChange())
{
if (InAddOrDeleteOperation::inAddOrDeleteOperation())
Expand All @@ -255,11 +253,9 @@ void StagesSubject::stageChanged(UsdNotice::ObjectsChanged const& notice, UsdSta
}
else
{
#if UFE_PREVIEW_VERSION_NUM >= 2014
auto sceneItem = Ufe::Hierarchy::createItem(ufePath);
auto notification = Ufe::SubtreeInvalidate(sceneItem);
Ufe::Scene::notifySubtreeInvalidate(notification);
#endif
}
}
#endif
Expand All @@ -284,14 +280,12 @@ void StagesSubject::stageChanged(UsdNotice::ObjectsChanged const& notice, UsdSta
}
}

#if UFE_PREVIEW_VERSION_NUM >= 2010
// Send a special message when visibility has changed.
if (changedPath.GetNameToken() == UsdGeomTokens->visibility)
{
Ufe::VisibilityChanged vis(ufePath);
Ufe::Object3d::notify(vis);
}
#endif
#endif

// We need to determine if the change is a Transform3d change.
Expand Down Expand Up @@ -323,7 +317,7 @@ void StagesSubject::onStageInvalidate(const MayaUsdProxyStageInvalidateNotice& n
{
afterOpen();

#if UFE_PREVIEW_VERSION_NUM >= 2014
#ifdef UFE_V2_FEATURES_AVAILABLE
Ufe::SceneItem::Ptr sceneItem = Ufe::Hierarchy::createItem(notice.GetProxyShape().ufePath());
auto notification = Ufe::SubtreeInvalidate(sceneItem);
Ufe::Scene::notifySubtreeInvalidate(notification);
Expand Down
4 changes: 0 additions & 4 deletions lib/mayaUsd/ufe/UsdContextOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,7 @@ Ufe::ContextOps::Items UsdContextOps::getItems(
MGlobal::executeCommand("runTimeCommand -exists UsdLayerEditor", hasLayerEditorCmd);
if (hasLayerEditorCmd) {
items.emplace_back(kUSDLayerEditorItem, kUSDLayerEditorLabel);
#if UFE_PREVIEW_VERSION_NUM >= 2015
items.emplace_back(Ufe::ContextItem::kSeparator);
ppt-adsk marked this conversation as resolved.
Show resolved Hide resolved
#endif
}

// Top-level items. Variant sets and visibility. Do not add for gateway type node.
Expand Down Expand Up @@ -303,9 +301,7 @@ Ufe::ContextOps::Items UsdContextOps::getItems(
items.emplace_back(kUSDDefPrimItem, kUSDDefPrimLabel); // typeless prim
items.emplace_back(kUSDScopePrimItem, kUSDScopePrimLabel);
items.emplace_back(kUSDXformPrimItem, kUSDXformPrimLabel);
#if UFE_PREVIEW_VERSION_NUM >= 2015
items.emplace_back(Ufe::ContextItem::kSeparator);
#endif
items.emplace_back(kUSDCapsulePrimItem, kUSDCapsulePrimLabel);
items.emplace_back(kUSDConePrimItem, kUSDConePrimLabel);
items.emplace_back(kUSDCubePrimItem, kUSDCubePrimLabel);
Expand Down
Loading