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-112608: add grouping with absolute, relative, world flags. #1600

Merged
merged 7 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
26 changes: 26 additions & 0 deletions lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,21 @@ ProxyShapeHierarchy::insertChild(const Ufe::SceneItem::Ptr& child, const Ufe::Sc
return insertChildCommand->insertedChild();
}

#if (UFE_PREVIEW_VERSION_NUM >= 3005)
Ufe::SceneItem::Ptr ProxyShapeHierarchy::createGroup(const Ufe::PathComponent& name) const
{
Ufe::SceneItem::Ptr createdItem;

auto usdItem = UsdSceneItem::create(sceneItem()->path(), getUsdRootPrim());
UsdUndoCreateGroupCommand::Ptr cmd = UsdUndoCreateGroupCommand::create(usdItem, name.string());
if (cmd) {
cmd->execute();
createdItem = cmd->insertedChild();
}

return createdItem;
}
#else
Ufe::SceneItem::Ptr ProxyShapeHierarchy::createGroup(
const Ufe::Selection& selection,
const Ufe::PathComponent& name) const
Expand All @@ -225,19 +240,30 @@ Ufe::SceneItem::Ptr ProxyShapeHierarchy::createGroup(

return createdItem;
}
#endif

#if (UFE_PREVIEW_VERSION_NUM >= 3001)
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
{
auto usdItem = UsdSceneItem::create(sceneItem()->path(), getUsdRootPrim());

return UsdUndoCreateGroupCommand::create(usdItem, selection, name.string());
}
#endif

Ufe::UndoableCommand::Ptr
ProxyShapeHierarchy::reorderCmd(const Ufe::SceneItemList& orderedList) const
Expand Down
8 changes: 8 additions & 0 deletions lib/mayaUsd/ufe/ProxyShapeHierarchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,23 @@ 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;
#else
Ufe::SceneItem::Ptr
createGroup(const Ufe::Selection& selection, const Ufe::PathComponent& name) const override;
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

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

adding guards against UFE v0.3.5 since selection is no longer passed to group command.


#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

Ufe::SceneItem::Ptr defaultParent() const override;

Expand Down
23 changes: 23 additions & 0 deletions lib/mayaUsd/ufe/UsdHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,20 @@ UsdHierarchy::insertChild(const Ufe::SceneItem::Ptr& child, const Ufe::SceneItem
}

// Create a transform.
#if (UFE_PREVIEW_VERSION_NUM >= 3005)
Ufe::SceneItem::Ptr UsdHierarchy::createGroup(const Ufe::PathComponent& name) const
{
Ufe::SceneItem::Ptr createdItem = nullptr;

UsdUndoCreateGroupCommand::Ptr cmd = UsdUndoCreateGroupCommand::create(fItem, name.string());
if (cmd) {
cmd->execute();
createdItem = cmd->insertedChild();
}

return createdItem;
}
#else
Ufe::SceneItem::Ptr
UsdHierarchy::createGroup(const Ufe::Selection& selection, const Ufe::PathComponent& name) const
{
Expand All @@ -234,16 +248,25 @@ UsdHierarchy::createGroup(const Ufe::Selection& selection, const Ufe::PathCompon

return createdItem;
}
#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
{
return UsdUndoCreateGroupCommand::create(fItem, name.string());
}
#else
UsdHierarchy::createGroupCmd(const Ufe::Selection& selection, const Ufe::PathComponent& name) const
{
return UsdUndoCreateGroupCommand::create(fItem, selection, name.string());
}
#endif

Ufe::SceneItem::Ptr UsdHierarchy::defaultParent() const
{
Expand Down
10 changes: 10 additions & 0 deletions lib/mayaUsd/ufe/UsdHierarchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,25 @@ class MAYAUSD_CORE_PUBLIC UsdHierarchy : 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;
#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

Ufe::SceneItem::Ptr defaultParent() const override;

Expand Down
22 changes: 16 additions & 6 deletions lib/mayaUsd/ufe/UsdUndoCreateGroupCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,35 @@ namespace MAYAUSD_NS_DEF {
namespace ufe {

UsdUndoCreateGroupCommand::UsdUndoCreateGroupCommand(
const UsdSceneItem::Ptr& parentItem,
const Ufe::Selection& selection,
const UsdSceneItem::Ptr& parentItem,
#if (UFE_PREVIEW_VERSION_NUM < 3005)
const Ufe::Selection& selection,
#endif
const Ufe::PathComponent& name)
: Ufe::InsertChildCommand()
, _parentItem(parentItem)
, _name(name)
#if (UFE_PREVIEW_VERSION_NUM < 3005)
, _selection(selection)
#endif
, _groupCompositeCmd(std::make_shared<Ufe::CompositeUndoableCommand>())

{
}

UsdUndoCreateGroupCommand::~UsdUndoCreateGroupCommand() { }

UsdUndoCreateGroupCommand::Ptr UsdUndoCreateGroupCommand::create(
const UsdSceneItem::Ptr& parentItem,
const Ufe::Selection& selection,
const UsdSceneItem::Ptr& parentItem,
#if (UFE_PREVIEW_VERSION_NUM < 3005)
const Ufe::Selection& selection,
#endif
const Ufe::PathComponent& name)
{
#if (UFE_PREVIEW_VERSION_NUM >= 3005)
return std::make_shared<UsdUndoCreateGroupCommand>(parentItem, name);
#else
return std::make_shared<UsdUndoCreateGroupCommand>(parentItem, selection, name);
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of these UFE V3 guards should be cleaned up after switching to UFE V3.

}

Ufe::SceneItem::Ptr UsdUndoCreateGroupCommand::insertedChild() const { return _groupItem; }
Expand All @@ -76,7 +85,7 @@ void UsdUndoCreateGroupCommand::execute()
_groupCompositeCmd->append(setKindCmd);
setKindCmd->execute();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the plugin side, we only need to create the groupItem and set its Kind.

On the Maya side, the insertion (a.k.a move ) happens with support for different flag options.


#if (UFE_PREVIEW_VERSION_NUM < 3005)
// 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 Expand Up @@ -107,6 +116,7 @@ void UsdUndoCreateGroupCommand::execute()

throw; // re-throw the same exception
}
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

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

groupItem selection is now handled on the Maya side.

}

void UsdUndoCreateGroupCommand::undo() { _groupCompositeCmd->undo(); }
Expand Down
16 changes: 11 additions & 5 deletions lib/mayaUsd/ufe/UsdUndoCreateGroupCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ class MAYAUSD_CORE_PUBLIC UsdUndoCreateGroupCommand : public Ufe::InsertChildCom
typedef std::shared_ptr<UsdUndoCreateGroupCommand> Ptr;

UsdUndoCreateGroupCommand(
const UsdSceneItem::Ptr& parentItem,
const Ufe::Selection& selection,
const UsdSceneItem::Ptr& parentItem,
#if (UFE_PREVIEW_VERSION_NUM < 3005)
const Ufe::Selection& selection,
#endif
const Ufe::PathComponent& name);
~UsdUndoCreateGroupCommand() override;

Expand All @@ -46,8 +48,10 @@ 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,
const Ufe::Selection& selection,
const UsdSceneItem::Ptr& parentItem,
#if (UFE_PREVIEW_VERSION_NUM < 3005)
const Ufe::Selection& selection,
#endif
const Ufe::PathComponent& name);

Ufe::SceneItem::Ptr insertedChild() const override;
Expand All @@ -60,7 +64,9 @@ class MAYAUSD_CORE_PUBLIC UsdUndoCreateGroupCommand : public Ufe::InsertChildCom
UsdSceneItem::Ptr _parentItem;
Ufe::PathComponent _name;
UsdSceneItem::Ptr _groupItem;
Ufe::Selection _selection;
#if (UFE_PREVIEW_VERSION_NUM < 3005)
Ufe::Selection _selection;
#endif

std::shared_ptr<Ufe::CompositeUndoableCommand> _groupCompositeCmd;

Expand Down
Loading