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

Remove/replace all UFE_PREVIEW_VERSION_NUM now that latest MayaPR has UFE v3 #2096

Merged
merged 1 commit into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions cmake/modules/FindUFE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ if(UFE_INCLUDE_DIR AND EXISTS "${UFE_INCLUDE_DIR}/ufe/ufe.h")

if("${UFE_MAJOR_VERSION}" STREQUAL "0")
math(EXPR UFE_PREVIEW_VERSION_NUM "${UFE_MINOR_VERSION} * 1000 + ${UFE_PATCH_LEVEL}")
elseif("${UFE_VERSION}" STREQUAL "3.0.0")
# Temporary. Once next Maya PR is released with UFE v3.0.0 this should
# be removed (along with all the UFE_PREVIEW_VERSION_NUM checks).
set(UFE_PREVIEW_VERSION_NUM 3014)
endif()

file(STRINGS
Expand Down
14 changes: 5 additions & 9 deletions lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ ProxyShapeHierarchy::insertChild(const Ufe::SceneItem::Ptr& child, const Ufe::Sc
return insertChildCommand->insertedChild();
}

#if (UFE_PREVIEW_VERSION_NUM >= 3005)
#ifdef UFE_V3_FEATURES_AVAILABLE
Ufe::SceneItem::Ptr ProxyShapeHierarchy::createGroup(const Ufe::PathComponent& name) const
{
Ufe::SceneItem::Ptr createdItem;
Expand Down Expand Up @@ -272,22 +272,18 @@ Ufe::SceneItem::Ptr ProxyShapeHierarchy::createGroup(
}
#endif

#if (UFE_PREVIEW_VERSION_NUM >= 3001)
#ifdef UFE_V3_FEATURES_AVAILABLE
Ufe::InsertChildCommand::Ptr
#else
Ufe::UndoableCommand::Ptr
#endif

#if (UFE_PREVIEW_VERSION_NUM >= 3005)
ProxyShapeHierarchy::createGroupCmd(const Ufe::PathComponent& name) const
{
auto usdItem = UsdSceneItem::create(sceneItem()->path(), getUsdRootPrim());

return UsdUndoCreateGroupCommand::create(usdItem, name.string());
}
#else
ProxyShapeHierarchy::createGroupCmd(const Ufe::Selection& selection, const Ufe::PathComponent& name)
const
Ufe::UndoableCommand::Ptr ProxyShapeHierarchy::createGroupCmd(
const Ufe::Selection& selection,
const Ufe::PathComponent& name) const
{
auto usdItem = UsdSceneItem::create(sceneItem()->path(), getUsdRootPrim());

Expand Down
14 changes: 3 additions & 11 deletions lib/mayaUsd/ufe/ProxyShapeHierarchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,13 @@ class MAYAUSD_CORE_PUBLIC ProxyShapeHierarchy : public Ufe::Hierarchy
#endif

#ifdef UFE_V2_FEATURES_AVAILABLE
#if (UFE_PREVIEW_VERSION_NUM >= 3005)
Ufe::SceneItem::Ptr createGroup(const Ufe::PathComponent& name) const override;
#ifdef UFE_V3_FEATURES_AVAILABLE
Ufe::SceneItem::Ptr createGroup(const Ufe::PathComponent& name) const override;
Ufe::InsertChildCommand::Ptr createGroupCmd(const Ufe::PathComponent& name) const override;
#else
Ufe::SceneItem::Ptr
createGroup(const Ufe::Selection& selection, const Ufe::PathComponent& name) const override;
#endif

#if (UFE_PREVIEW_VERSION_NUM >= 3001)
Ufe::InsertChildCommand::Ptr
#else
Ufe::UndoableCommand::Ptr
#endif
#if (UFE_PREVIEW_VERSION_NUM >= 3005)
createGroupCmd(const Ufe::PathComponent& name) const override;
#else
createGroupCmd(const Ufe::Selection& selection, const Ufe::PathComponent& name) const override;
#endif

Expand Down
27 changes: 5 additions & 22 deletions lib/mayaUsd/ufe/UsdAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "private/Utils.h"

#if (UFE_PREVIEW_VERSION_NUM >= 3011)
#ifdef UFE_V3_FEATURES_AVAILABLE
#include <mayaUsd/base/tokens.h>
#endif
#include <mayaUsd/ufe/StagesSubject.h>
Expand All @@ -44,7 +44,7 @@ static constexpr char kErrorMsgFailedConvertToString[]
= "Could not convert the attribute to a string";
static constexpr char kErrorMsgInvalidType[]
= "USD attribute does not match created attribute class type";
#if (UFE_PREVIEW_VERSION_NUM >= 3013)
#ifdef UFE_V3_FEATURES_AVAILABLE
static constexpr char kErrorMsgInvalidValueType[] = "Unexpected Ufe::Value type";
#endif

Expand Down Expand Up @@ -93,7 +93,7 @@ template <typename T> bool setUsdAttr(const PXR_NS::UsdAttribute& attr, const T&
return attr.Set<T>(value);
}

#if (UFE_PREVIEW_VERSION_NUM >= 3011)
#ifdef UFE_V3_FEATURES_AVAILABLE
bool setUsdAttrMetadata(
const PXR_NS::UsdAttribute& attr,
const std::string& key,
Expand All @@ -118,7 +118,6 @@ bool setUsdAttrMetadata(
// We must convert the Ufe::Value to VtValue for storage in Usd.
// Figure out the type of the input Ufe Value and create proper Usd VtValue.
PXR_NS::VtValue usdValue;
#if (UFE_PREVIEW_VERSION_NUM >= 3013)
if (value.isType<bool>())
usdValue = value.get<bool>();
else if (value.isType<int>())
Expand All @@ -132,22 +131,6 @@ bool setUsdAttrMetadata(
else {
TF_CODING_ERROR(kErrorMsgInvalidValueType);
}
#else
if (value.type() == typeid(bool))
usdValue = value.get<bool>();
else if (value.type() == typeid(int))
usdValue = value.get<int>();
else if (value.type() == typeid(float))
usdValue = value.get<float>();
else if (value.type() == typeid(double))
usdValue = value.get<double>();
// Workaround a bug on OSX (with Clang) with the type_info not comparing correctly.
// For now we know the known types that Ufe::Value supports. So if not one of
// the basic types, then it must be std::string. Once Ufe is fixed we can change
// this else into else if and assert for unknown type.
else /*if (value.type() == typeid(std::string))*/
usdValue = value.get<std::string>();
#endif
if (!usdValue.IsEmpty()) {
PXR_NS::TfToken tok(key);
return attr.SetMetadata(tok, usdValue);
Expand Down Expand Up @@ -252,7 +235,7 @@ class SetUndoableCommand : public UsdUndoableCommand
const T _newValue;
};

#if (UFE_PREVIEW_VERSION_NUM >= 3011)
#ifdef UFE_V3_FEATURES_AVAILABLE
class SetUndoableMetadataCommand : public UsdUndoableCommand
{
public:
Expand Down Expand Up @@ -307,7 +290,7 @@ std::string UsdAttribute::string(const Ufe::SceneItem::Ptr& item) const
return getUsdAttributeValueAsString(fUsdAttr, getCurrentTime(item));
}

#if (UFE_PREVIEW_VERSION_NUM >= 3011)
#ifdef UFE_V3_FEATURES_AVAILABLE
Ufe::Value UsdAttribute::getMetadata(const std::string& key) const
{
// Special cases for known Ufe metadata keys.
Expand Down
22 changes: 11 additions & 11 deletions lib/mayaUsd/ufe/UsdAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,7 @@
#include <ufe/attribute.h>

// Ufe::Attribute overrides (minus the type method)
#if (UFE_PREVIEW_VERSION_NUM < 3011)
#define UFE_ATTRIBUTE_OVERRIDES \
bool hasValue() const override { return UsdAttribute::hasValue(); } \
std::string name() const override { return UsdAttribute::name(); } \
std::string documentation() const override { return UsdAttribute::documentation(); } \
std::string string() const override \
{ \
return UsdAttribute::string(Ufe::Attribute::sceneItem()); \
}
#else
#ifdef UFE_V3_FEATURES_AVAILABLE
#define UFE_ATTRIBUTE_OVERRIDES \
bool hasValue() const override { return UsdAttribute::hasValue(); } \
std::string name() const override { return UsdAttribute::name(); } \
Expand Down Expand Up @@ -62,6 +53,15 @@
{ \
return UsdAttribute::hasMetadata(key); \
}
#else
#define UFE_ATTRIBUTE_OVERRIDES \
bool hasValue() const override { return UsdAttribute::hasValue(); } \
std::string name() const override { return UsdAttribute::name(); } \
std::string documentation() const override { return UsdAttribute::documentation(); } \
std::string string() const override \
{ \
return UsdAttribute::string(Ufe::Attribute::sceneItem()); \
}
#endif

namespace MAYAUSD_NS_DEF {
Expand All @@ -79,7 +79,7 @@ class UsdAttribute
std::string name() const;
std::string documentation() const;
std::string string(const Ufe::SceneItem::Ptr& item) const;
#if (UFE_PREVIEW_VERSION_NUM >= 3011)
#ifdef UFE_V3_FEATURES_AVAILABLE
Ufe::Value getMetadata(const std::string& key) const;
bool setMetadata(const std::string& key, const Ufe::Value& value);
Ufe::UndoableCommand::Ptr setMetadataCmd(const std::string& key, const Ufe::Value& value);
Expand Down
13 changes: 4 additions & 9 deletions lib/mayaUsd/ufe/UsdHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ UsdHierarchy::insertChild(const Ufe::SceneItem::Ptr& child, const Ufe::SceneItem
}

// Create a transform.
#if (UFE_PREVIEW_VERSION_NUM >= 3005)
#ifdef UFE_V3_FEATURES_AVAILABLE
Ufe::SceneItem::Ptr UsdHierarchy::createGroup(const Ufe::PathComponent& name) const
{
Ufe::SceneItem::Ptr createdItem = nullptr;
Expand Down Expand Up @@ -284,18 +284,13 @@ UsdHierarchy::createGroup(const Ufe::Selection& selection, const Ufe::PathCompon
}
#endif

#if (UFE_PREVIEW_VERSION_NUM >= 3001)
Ufe::InsertChildCommand::Ptr
#else
Ufe::UndoableCommand::Ptr
#endif

#if (UFE_PREVIEW_VERSION_NUM >= 3005)
UsdHierarchy::createGroupCmd(const Ufe::PathComponent& name) const
#ifdef UFE_V3_FEATURES_AVAILABLE
Ufe::InsertChildCommand::Ptr UsdHierarchy::createGroupCmd(const Ufe::PathComponent& name) const
{
return UsdUndoCreateGroupCommand::create(fItem, name.string());
}
#else
Ufe::UndoableCommand::Ptr
UsdHierarchy::createGroupCmd(const Ufe::Selection& selection, const Ufe::PathComponent& name) const
{
return UsdUndoCreateGroupCommand::create(fItem, selection, name.string());
Expand Down
15 changes: 3 additions & 12 deletions lib/mayaUsd/ufe/UsdHierarchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,13 @@ class MAYAUSD_CORE_PUBLIC UsdHierarchy : public Ufe::Hierarchy

#ifdef UFE_V2_FEATURES_AVAILABLE

#if (UFE_PREVIEW_VERSION_NUM >= 3005)
Ufe::SceneItem::Ptr createGroup(const Ufe::PathComponent& name) const override;
#ifdef UFE_V3_FEATURES_AVAILABLE
Ufe::SceneItem::Ptr createGroup(const Ufe::PathComponent& name) const override;
Ufe::InsertChildCommand::Ptr createGroupCmd(const Ufe::PathComponent& name) const override;
#else
Ufe::SceneItem::Ptr
createGroup(const Ufe::Selection& selection, const Ufe::PathComponent& name) const override;
#endif

#if (UFE_PREVIEW_VERSION_NUM >= 3001)
Ufe::InsertChildCommand::Ptr
#else
Ufe::UndoableCommand::Ptr
#endif

#if (UFE_PREVIEW_VERSION_NUM >= 3005)
createGroupCmd(const Ufe::PathComponent& name) const override;
#else
createGroupCmd(const Ufe::Selection& selection, const Ufe::PathComponent& name) const override;
#endif

Expand Down
10 changes: 5 additions & 5 deletions lib/mayaUsd/ufe/UsdUndoCreateGroupCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ namespace ufe {

UsdUndoCreateGroupCommand::UsdUndoCreateGroupCommand(
const UsdSceneItem::Ptr& parentItem,
#if (UFE_PREVIEW_VERSION_NUM < 3005)
#ifndef UFE_V3_FEATURES_AVAILABLE
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is only included for Ufe v2. Here we don't want this extra selection arg for Ufe v2.

const Ufe::Selection& selection,
#endif
const Ufe::PathComponent& name)
: Ufe::InsertChildCommand()
, _parentItem(parentItem)
, _name(name)
#if (UFE_PREVIEW_VERSION_NUM < 3005)
#ifndef UFE_V3_FEATURES_AVAILABLE
, _selection(selection)
#endif
, _groupCompositeCmd(std::make_shared<Ufe::CompositeUndoableCommand>())
Expand All @@ -53,12 +53,12 @@ UsdUndoCreateGroupCommand::~UsdUndoCreateGroupCommand() { }

UsdUndoCreateGroupCommand::Ptr UsdUndoCreateGroupCommand::create(
const UsdSceneItem::Ptr& parentItem,
#if (UFE_PREVIEW_VERSION_NUM < 3005)
#ifndef UFE_V3_FEATURES_AVAILABLE
const Ufe::Selection& selection,
#endif
const Ufe::PathComponent& name)
{
#if (UFE_PREVIEW_VERSION_NUM >= 3005)
#ifdef UFE_V3_FEATURES_AVAILABLE
return std::make_shared<UsdUndoCreateGroupCommand>(parentItem, name);
#else
return std::make_shared<UsdUndoCreateGroupCommand>(parentItem, selection, name);
Expand All @@ -85,7 +85,7 @@ void UsdUndoCreateGroupCommand::execute()
_groupCompositeCmd->append(setKindCmd);
setKindCmd->execute();
}
#if (UFE_PREVIEW_VERSION_NUM < 3005)
#ifndef UFE_V3_FEATURES_AVAILABLE
// Make sure to handle the exception if the parenting operation fails.
// This scenario happens if a user tries to group prim(s) in a layer
// other than the one where they were defined. In this case, the group creation itself
Expand Down
6 changes: 3 additions & 3 deletions lib/mayaUsd/ufe/UsdUndoCreateGroupCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MAYAUSD_CORE_PUBLIC UsdUndoCreateGroupCommand : public Ufe::InsertChildCom

UsdUndoCreateGroupCommand(
const UsdSceneItem::Ptr& parentItem,
#if (UFE_PREVIEW_VERSION_NUM < 3005)
#ifndef UFE_V3_FEATURES_AVAILABLE
const Ufe::Selection& selection,
#endif
const Ufe::PathComponent& name);
Expand All @@ -49,7 +49,7 @@ class MAYAUSD_CORE_PUBLIC UsdUndoCreateGroupCommand : public Ufe::InsertChildCom
//! Create a UsdUndoCreateGroupCommand from a USD scene item and a UFE path component.
static UsdUndoCreateGroupCommand::Ptr create(
const UsdSceneItem::Ptr& parentItem,
#if (UFE_PREVIEW_VERSION_NUM < 3005)
#ifndef UFE_V3_FEATURES_AVAILABLE
const Ufe::Selection& selection,
#endif
const Ufe::PathComponent& name);
Expand All @@ -64,7 +64,7 @@ class MAYAUSD_CORE_PUBLIC UsdUndoCreateGroupCommand : public Ufe::InsertChildCom
UsdSceneItem::Ptr _parentItem;
Ufe::PathComponent _name;
UsdSceneItem::Ptr _groupItem;
#if (UFE_PREVIEW_VERSION_NUM < 3005)
#ifndef UFE_V3_FEATURES_AVAILABLE
Ufe::Selection _selection;
#endif

Expand Down
3 changes: 0 additions & 3 deletions test/lib/mayaUsd/fileio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ foreach(script ${TEST_SCRIPT_FILES})
mayaUsd_add_test(${target}
PYTHON_MODULE ${target}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
ENV
"UFE_PREVIEW_VERSION_NUM=${UFE_PREVIEW_VERSION_NUM}"
)

# Add a ctest label to these tests for easy filtering.
Expand Down Expand Up @@ -69,7 +67,6 @@ if(CMAKE_UFE_V3_FEATURES_AVAILABLE)
PYTHON_MODULE ${target}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
ENV
"UFE_PREVIEW_VERSION_NUM=${UFE_PREVIEW_VERSION_NUM}"
"${PXR_OVERRIDE_PLUGINPATH_NAME}=${CMAKE_CURRENT_SOURCE_DIR}/UsdCustomRigSchema/"
)
endif()
Expand Down
5 changes: 3 additions & 2 deletions test/lib/mayaUsd/fileio/testDiscardEdits.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from mayaUtils import setMayaTranslation
from usdUtils import createSimpleXformScene
from ufeUtils import ufeFeatureSetVersion

import mayaUsd.lib

Expand Down Expand Up @@ -60,7 +61,7 @@ def tearDownClass(cls):
def setUp(self):
cmds.file(new=True, force=True)

@unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3006', 'Test only available in UFE preview version 0.3.6 and greater')
@unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.')
def testDiscardEdits(self):
'''Discard edits on a USD transform.'''

Expand Down Expand Up @@ -106,7 +107,7 @@ def testDiscardEdits(self):
with self.assertRaises(RuntimeError):
om.MSelectionList().add(aMayaPathStr)

@unittest.skipIf(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '3006', 'Test only available in UFE preview version 0.3.6 and greater')
@unittest.skipUnless(ufeFeatureSetVersion() >= 3, 'Test only available in UFE v3 or greater.')
def testDiscardEditsUndoRedo(self):
'''Discard edits on a USD transform then undo and redo.'''

Expand Down
Loading